DynExp
Highly flexible laboratory automation for dynamically changing experiments.
Loading...
Searching...
No Matches
DynExp::TaskBase Class Referenceabstract

Base class for all tasks being processed by instruments. The class must not contain public virtual functions since TaskBase::CallbackFunc could call them in TaskBase's destructor. More...

#include <Instrument.h>

Inherited by DynExp::ArriveAtLatchTask, DynExp::DefaultTask, DynExp::ExitTaskBase, DynExp::InitTaskBase, DynExp::UpdateTaskBase, DynExpInstr::DataStreamInstrumentTasks::SetStreamSizeTask, DynExpInstr::DummyDataStreamInstrumentTasks::ResetStreamSizeTask, DynExpInstr::FunctionGeneratorTasks::SetArbitraryFunctionTask, DynExpInstr::FunctionGeneratorTasks::SetPulseFunctionTask, DynExpInstr::FunctionGeneratorTasks::SetRampFunctionTask, DynExpInstr::FunctionGeneratorTasks::SetRectFunctionTask, DynExpInstr::FunctionGeneratorTasks::SetSineFunctionTask, DynExpInstr::FunctionGeneratorTasks::SetTriggerTask, DynExpInstr::InputPortTasks::ResetBufferSizeTask, DynExpInstr::NIDAQAnalogInTasks::ReadTask, DynExpInstr::NIDAQAnalogInTasks::RestartTask, DynExpInstr::NIDAQAnalogInTasks::StartTask, DynExpInstr::NIDAQAnalogInTasks::StopTask, DynExpInstr::NIDAQAnalogOutTasks::ClearTask, DynExpInstr::NIDAQAnalogOutTasks::RestartTask, DynExpInstr::NIDAQAnalogOutTasks::StartTask, DynExpInstr::NIDAQAnalogOutTasks::StopTask, DynExpInstr::NIDAQAnalogOutTasks::WriteTask, DynExpInstr::NIDAQDigitalInTasks::ReadTask, DynExpInstr::NIDAQDigitalInTasks::RestartTask, DynExpInstr::NIDAQDigitalInTasks::StartTask, DynExpInstr::NIDAQDigitalInTasks::StopTask, DynExpInstr::NIDAQDigitalOutTasks::ClearTask, DynExpInstr::NIDAQDigitalOutTasks::RestartTask, DynExpInstr::NIDAQDigitalOutTasks::StartTask, DynExpInstr::NIDAQDigitalOutTasks::StopTask, DynExpInstr::NIDAQDigitalOutTasks::WriteTask, DynExpInstr::NP_Conex_CC_Tasks::MoveAbsoluteExecutionTask, DynExpInstr::NP_Conex_CC_Tasks::MoveAbsoluteTask, DynExpInstr::NP_Conex_CC_Tasks::MoveRelativeExecutionTask, DynExpInstr::NP_Conex_CC_Tasks::MoveRelativeTask, DynExpInstr::NP_Conex_CC_Tasks::MoveToHomeExecutionTask, DynExpInstr::NP_Conex_CC_Tasks::MoveToHomeTask, DynExpInstr::NP_Conex_CC_Tasks::ReferenceExecutionTask, DynExpInstr::NP_Conex_CC_Tasks::ReferenceTask, DynExpInstr::NP_Conex_CC_Tasks::ResetTask, DynExpInstr::NP_Conex_CC_Tasks::SetHomeExecutionTask, DynExpInstr::NP_Conex_CC_Tasks::SetHomeTask, DynExpInstr::NP_Conex_CC_Tasks::SetReadyTask, DynExpInstr::NP_Conex_CC_Tasks::SetVelocityTask, DynExpInstr::NP_Conex_CC_Tasks::StopMotionTask, DynExpInstr::NenionLeakvalveF3Tasks::MoveAbsoluteTask, DynExpInstr::NenionLeakvalveF3Tasks::MoveRelativeTask, DynExpInstr::NenionLeakvalveF3Tasks::MoveToHomeTask, DynExpInstr::NenionLeakvalveF3Tasks::ReferenceTask, DynExpInstr::NenionLeakvalveF3Tasks::SetHomeTask, DynExpInstr::NenionLeakvalveF3Tasks::SetVelocityTask, DynExpInstr::NenionLeakvalveF3Tasks::StopMotionTask, DynExpInstr::NetworkAnalogOutTasks::SetDefaultTask< BaseInstr,, gRPCStubs >, DynExpInstr::NetworkAnalogOutTasks::SetTask< BaseInstr,, gRPCStubs >, DynExpInstr::NetworkDataStreamInstrumentTasks::ClearTask< BaseInstr,, gRPCStubs >, DynExpInstr::NetworkDataStreamInstrumentTasks::ReadTask< BaseInstr,, gRPCStubs >, DynExpInstr::NetworkDataStreamInstrumentTasks::ResetStreamSizeTask< BaseInstr,, gRPCStubs >, DynExpInstr::NetworkDataStreamInstrumentTasks::RestartTask< BaseInstr,, gRPCStubs >, DynExpInstr::NetworkDataStreamInstrumentTasks::SetStreamSizeTask< BaseInstr,, gRPCStubs >, DynExpInstr::NetworkDataStreamInstrumentTasks::StartTask< BaseInstr,, gRPCStubs >, DynExpInstr::NetworkDataStreamInstrumentTasks::StopTask< BaseInstr,, gRPCStubs >, DynExpInstr::NetworkDataStreamInstrumentTasks::WriteTask< BaseInstr,, gRPCStubs >, DynExpInstr::NetworkDigitalOutTasks::SetDefaultTask< BaseInstr,, gRPCStubs >, DynExpInstr::NetworkDigitalOutTasks::SetTask< BaseInstr,, gRPCStubs >, DynExpInstr::NetworkLaserTasks::DisableScanTask, DynExpInstr::NetworkLaserTasks::DisableTask, DynExpInstr::NetworkLaserTasks::EnableTask, DynExpInstr::NetworkLaserTasks::ScanContinuouslyTask, DynExpInstr::NetworkLaserTasks::SetFrequencyTask, DynExpInstr::NetworkLaserTasks::SetIntensityTask, DynExpInstr::NetworkLaserTasks::SetScanRangeTask, DynExpInstr::NetworkLaserTasks::SetScanRateTask, DynExpInstr::NetworkSpectrometerTasks::AbortTask, DynExpInstr::NetworkSpectrometerTasks::RecordTask, DynExpInstr::NetworkSpectrometerTasks::SetExposureTimeTask, DynExpInstr::NetworkSpectrometerTasks::SetFrequencyRangeTask, DynExpInstr::NetworkSpectrometerTasks::SetSetSilentModeTask, DynExpInstr::NetworkTimeTaggerTasks::ClearTask< BaseInstr,, gRPCStubs >, DynExpInstr::NetworkTimeTaggerTasks::ConfigureHBTTask< BaseInstr,, gRPCStubs >, DynExpInstr::NetworkTimeTaggerTasks::ConfigureInputTask< BaseInstr,, gRPCStubs >, DynExpInstr::NetworkTimeTaggerTasks::ReadTask< BaseInstr,, gRPCStubs >, DynExpInstr::NetworkTimeTaggerTasks::ResetHBTTask< BaseInstr,, gRPCStubs >, DynExpInstr::NetworkTimeTaggerTasks::SetCoincidenceWindowTask< BaseInstr,, gRPCStubs >, DynExpInstr::NetworkTimeTaggerTasks::SetDelayTask< BaseInstr,, gRPCStubs >, DynExpInstr::NetworkTimeTaggerTasks::SetExposureTimeTask< BaseInstr,, gRPCStubs >, DynExpInstr::NetworkTimeTaggerTasks::SetHBTActiveTask< BaseInstr,, gRPCStubs >, DynExpInstr::OutputPortTasks::ResetBufferSizeTask, DynExpInstr::PI_C_862_Tasks::MoveAbsoluteTask, DynExpInstr::PI_C_862_Tasks::MoveRelativeTask, DynExpInstr::PI_C_862_Tasks::MoveToHomeTask, DynExpInstr::PI_C_862_Tasks::ReferenceTask, DynExpInstr::PI_C_862_Tasks::SetHomeTask, DynExpInstr::PI_C_862_Tasks::SetVelocityTask, DynExpInstr::PI_C_862_Tasks::StopMotionTask, DynExpInstr::PVCamTasks::CaptureSingleTask, DynExpInstr::PVCamTasks::SetCameraMode, DynExpInstr::PVCamTasks::SetExposureTimeTask, DynExpInstr::PVCamTasks::StartCapturingTask, DynExpInstr::PVCamTasks::StopCapturingTask, DynExpInstr::QutoolsQuTAGTasks::ClearTask, DynExpInstr::QutoolsQuTAGTasks::ConfigureHBTTask, DynExpInstr::QutoolsQuTAGTasks::ConfigureInputTask, DynExpInstr::QutoolsQuTAGTasks::ReadDataTask, DynExpInstr::QutoolsQuTAGTasks::ResetHBTTask, DynExpInstr::QutoolsQuTAGTasks::SetCoincidenceWindowTask, DynExpInstr::QutoolsQuTAGTasks::SetDelayTask, DynExpInstr::QutoolsQuTAGTasks::SetExposureTimeTask, DynExpInstr::QutoolsQuTAGTasks::SetHBTActiveTask, DynExpInstr::QutoolsQuTAGTasks::SetStreamSizeTask, DynExpInstr::RS_SMB100BTasks::ForceTriggerTask, DynExpInstr::RS_SMB100BTasks::SetModulationTask, DynExpInstr::RS_SMB100BTasks::SetSineFunctionTask, DynExpInstr::RS_SMB100BTasks::SetSweepTask, DynExpInstr::RS_SMB100BTasks::SetTriggerTask, DynExpInstr::RS_SMB100BTasks::StartTask, DynExpInstr::RS_SMB100BTasks::StopTask, DynExpInstr::RS_SMC100ATasks::ForceTriggerTask, DynExpInstr::RS_SMC100ATasks::SetModulationTask, DynExpInstr::RS_SMC100ATasks::SetSineFunctionTask, DynExpInstr::RS_SMC100ATasks::SetSweepTask, DynExpInstr::RS_SMC100ATasks::SetTriggerTask, DynExpInstr::RS_SMC100ATasks::StartTask, DynExpInstr::RS_SMC100ATasks::StopTask, DynExpInstr::SmarActTasks::CalibrateTask, DynExpInstr::SmarActTasks::MoveAbsoluteTask, DynExpInstr::SmarActTasks::MoveRelativeTask, DynExpInstr::SmarActTasks::MoveToHomeTask, DynExpInstr::SmarActTasks::ReferenceTask, DynExpInstr::SmarActTasks::SetHomeTask, DynExpInstr::SmarActTasks::SetVelocityTask, DynExpInstr::SmarActTasks::StopMotionTask, DynExpInstr::SwabianInstrumentsPulseStreamerTasks::ClearTask, DynExpInstr::SwabianInstrumentsPulseStreamerTasks::ForceFinalSampleTask, DynExpInstr::SwabianInstrumentsPulseStreamerTasks::ForceTriggerTask, DynExpInstr::SwabianInstrumentsPulseStreamerTasks::ResetBufferSizeTask, DynExpInstr::SwabianInstrumentsPulseStreamerTasks::RestartTask, DynExpInstr::SwabianInstrumentsPulseStreamerTasks::SetConstantOutputTask, DynExpInstr::SwabianInstrumentsPulseStreamerTasks::SetNumRunsTask, DynExpInstr::SwabianInstrumentsPulseStreamerTasks::SetTriggerTask, DynExpInstr::SwabianInstrumentsPulseStreamerTasks::StartTask, DynExpInstr::SwabianInstrumentsPulseStreamerTasks::StopTask, DynExpInstr::SwabianInstrumentsPulseStreamerTasks::WriteTask, DynExpInstr::TimeTaggerTasks::ResetBufferSizeTask, DynExpInstr::WidefieldLocalizationTasks::AnalyzeDistortionTask, DynExpInstr::WidefieldLocalizationTasks::AnalyzeWidefieldTask, DynExpInstr::WidefieldLocalizationTasks::ReadCellIDTask, DynExpInstr::WidefieldLocalizationTasks::RecallPositionsTask, DynExpInstr::ZI_MFLITasks::AutoAdjustPhaseTask, DynExpInstr::ZI_MFLITasks::AutoAdjustSensitivityTask, DynExpInstr::ZI_MFLITasks::ClearDataTask, DynExpInstr::ZI_MFLITasks::ForceTriggerTask, DynExpInstr::ZI_MFLITasks::ReadTask, DynExpInstr::ZI_MFLITasks::SetEnableTask, DynExpInstr::ZI_MFLITasks::SetFilterOrderTask, DynExpInstr::ZI_MFLITasks::SetPhaseTask, DynExpInstr::ZI_MFLITasks::SetSamplingRateTask, DynExpInstr::ZI_MFLITasks::SetSensitivityTask, DynExpInstr::ZI_MFLITasks::SetSignalTypeTask, DynExpInstr::ZI_MFLITasks::SetTimeConstantTask, DynExpInstr::ZI_MFLITasks::SetTriggerEdgeTask, DynExpInstr::ZI_MFLITasks::SetTriggerModeTask, DynExpInstr::ZI_MFLITasks::StartTask, and DynExpInstr::ZI_MFLITasks::StopTask.

Classes

class  CallbackType
 Type owning a callback function which is invoked when a task has finished, failed, or has been aborted. It is ensured that the callback function is invoked latest upon destruction of the respective CallbackType instance. A callback function can only be invoked once through a CallbackType instance. More...
 
class  InstrumentBaseOnlyType
 Allow exclusive access to some of TaskBase's private methods to InstrumentBase. More...
 
class  InstrumentDataBaseOnlyType
 Allow exclusive access to some of TaskBase's private methods to InstrumentDataBase. More...
 

Public Types

enum class  TaskState {
  Waiting , Locked , Running , Finished ,
  Failed , Aborted
}
 Defines states an instrument's task can undergo. Possible state transitions are: More...
 

Public Member Functions

 TaskBase (CallbackType CallbackFunc=nullptr, std::chrono::system_clock::time_point DeferUntil={}) noexcept
 Constructs an instrument task.
 
 TaskBase (TaskBase &Other, std::chrono::system_clock::time_point DeferUntil={}) noexcept
 Constructs an instrument task, moving CallbackFunc from another task to this task. The other task is left with a CallbackFunc that will not be executed anymore after this operation. Using this constructor is useful, if a running task enqueues (an)other task(s). In this case, the callback function should not be called by the original task but by the last task in this chain of tasks.
 
virtual ~TaskBase ()=0
 The destructor aborts a waiting task setting State to TaskState::Aborted. Then, it calls CallbackFunc with a default-constructed ExceptionContainer instance.
 
Thread-safe public functions

Methods can be called from any thread. Only atomic operations are performed.

auto GetDeferUntil () const noexcept
 Getter for the instrument task's earliest execution time point.
 
TaskState GetState () const noexcept
 Getter for the instrument task's current state.
 
bool IsLocked () const noexcept
 Determines whether the task is locked.
 
bool IsAborting () const noexcept
 Determines whether the task should abort. A derived task is encouraged to call this method before performing any action or in between the individual steps of a more complex action.
 
int GetErrorCode () const noexcept
 Getter for the error code related to an error possibly occurred while the task was executed.
 
void Abort ()
 Requests the task to abort. There is no guarantee that the derived task does call IsAborting() to check whether it should abort. The task could have finished already or the implementation of RunChild() in the derived class does not allow for aborting.
 

Public Attributes

InstrumentBaseOnlyType InstrumentBaseOnly
 Allow exclusive access to some of TaskBase's private methods to InstrumentBase.
 
InstrumentDataBaseOnlyType InstrumentDataBaseOnly
 Allow exclusive access to some of TaskBase's private methods to InstrumentDataBase.
 

Private Member Functions

void Lock ()
 Locks the task to prepare it for execution.
 
InstrumentBase::TaskHandlingContinuationType Run (InstrumentInstance &Instance)
 Runs the task. Override RunChild() to define a derived task's action(s). Any exception leaving RunChild() will terminate the instrument thread. In this case, the instrument has to be reset in order to restart it. For minor errors occurring in RunChild(), return a TaskResultType instance with TaskResultType::ErrorCode set to an appropriate (non-zero) value. This sets State to TaskState::Failed. Note that in this case there might be no way to retrieve the error if finished tasks are not kept (i.e. KeepFinishedTask() returns false) and if no CallbackFunc has been set. RunChild() is supposed to check the return value of IsAborting().
 
Override

Override by derived classes.

virtual TaskResultType RunChild (InstrumentInstance &Instance)=0
 Runs the task. Override RunChild() to define a derived task's action(s). Any exception leaving RunChild() will terminate the instrument thread. In this case, the instrument has to be reset in order to restart it. For minor errors occurring in RunChild(), return a TaskResultType instance with TaskResultType::ErrorCode set to an appropriate (non-zero) value. This sets State to TaskState::Failed. Note that in this case there might be no way to retrieve the error if finished tasks are not kept (i.e. KeepFinishedTask() returns false) and if no CallbackFunc has been set. RunChild() is supposed to check the return value of IsAborting().
 
virtual bool KeepFinishedTask () const noexcept
 Determines whether the task should be kept to check its results after execution. InstrumentDataBase::RemoveTaskFromQueue().
 

Private Attributes

CallbackType CallbackFunc
 This callback function is called after the task has finished (either successfully or not) with a pointer to the current task and with a reference to the exception which occurred during the task execution (if an exception has occurred).
 
const std::chrono::system_clock::time_point DeferUntil
 The execution of this task is deferred until the specified point in time is reached if time_since_epoch() of DeferUntil is non-zero. Tasks being deferred block the task queue of the instrument they are assigned to, i.e., other enqueued tasks do not run before this task to maintain the task order.
 
Instrument-to-other communication

These variables are for communication from the instrument thread to other thread(s) only.

std::atomic< TaskStateState
 Holds the task's current state. Refer to TaskBase::TaskState.
 
std::atomic< int > ErrorCode
 Holds the error code of an error which occurred during execution of the task function.
 
Other-to-instrument communication

These variables are for communication from other thread(s) to the instrument thread only.

std::atomic< bool > ShouldAbort
 Indicates whether the task should abort. Refer to Abort() and IsAborting().
 

Detailed Description

Base class for all tasks being processed by instruments. The class must not contain public virtual functions since TaskBase::CallbackFunc could call them in TaskBase's destructor.

Definition at line 928 of file Instrument.h.

Member Enumeration Documentation

◆ TaskState

enum class DynExp::TaskBase::TaskState
strong

Defines states an instrument's task can undergo. Possible state transitions are:

  • Waiting -> Locked/Running/Aborted
  • Locked -> Running
  • Running -> Finished/Failed/Aborted
Enumerator
Waiting 

The task is enqueued and waiting for execution. This is the starting state after construction.

Locked 

The task is locked since its execution is being prepared. It will be the next task to be executed.

Running 

The task is currently being executed.

Finished 

The task execution has finished. No error has occurred.

Failed 

The task execution has failed due to an exception leaving RunChild().

Aborted 

The task has been aborted either by ~TaskBase() or by returning a TaskResultType instance with TaskResultType::Aborted set to TaskResultType::AbortedType::Aborted from RunChild().

Definition at line 1051 of file Instrument.h.

Constructor & Destructor Documentation

◆ TaskBase() [1/2]

DynExp::TaskBase::TaskBase ( CallbackType  CallbackFunc = nullptr,
std::chrono::system_clock::time_point  DeferUntil = {} 
)
inlinenoexcept

Constructs an instrument task.

Parameters
CallbackFuncThis callback function is called after the task has finished (either successfully or not) with a pointer to the current task and with a reference to the exception which occurred during the task execution (if an exception has occurred).
DeferUntilThe execution of this task is deferred until the specified point in time is reached if time_since_epoch() of DeferUntil is non-zero. Tasks being deferred block the task queue of the instrument they are assigned to, i.e., other enqueued tasks do not run before this task to maintain the task order. If the task does not support being deferred, the DeferUntil parameter is not available in the task's constructor.

Definition at line 1084 of file Instrument.h.

◆ TaskBase() [2/2]

DynExp::TaskBase::TaskBase ( TaskBase Other,
std::chrono::system_clock::time_point  DeferUntil = {} 
)
inlinenoexcept

Constructs an instrument task, moving CallbackFunc from another task to this task. The other task is left with a CallbackFunc that will not be executed anymore after this operation. Using this constructor is useful, if a running task enqueues (an)other task(s). In this case, the callback function should not be called by the original task but by the last task in this chain of tasks.

Parameters
OtherOther task to steal CallbackFunc from.
DeferUntilThe execution of this task is deferred until the specified point in time is reached if time_since_epoch() of DeferUntil is non-zero. Tasks being deferred block the task queue of the instrument they are assigned to, i.e., other enqueued tasks do not run before this task to maintain the task order.

Definition at line 1097 of file Instrument.h.

◆ ~TaskBase()

DynExp::TaskBase::~TaskBase ( )
pure virtual

The destructor aborts a waiting task setting State to TaskState::Aborted. Then, it calls CallbackFunc with a default-constructed ExceptionContainer instance.

Definition at line 516 of file Instrument.cpp.

Member Function Documentation

◆ Abort()

void DynExp::TaskBase::Abort ( )
inline

Requests the task to abort. There is no guarantee that the derived task does call IsAborting() to check whether it should abort. The task could have finished already or the implementation of RunChild() in the derived class does not allow for aborting.

Definition at line 1146 of file Instrument.h.

◆ GetDeferUntil()

auto DynExp::TaskBase::GetDeferUntil ( ) const
inlinenoexcept

Getter for the instrument task's earliest execution time point.

Returns
Returns DeferUntil.

Definition at line 1114 of file Instrument.h.

◆ GetErrorCode()

int DynExp::TaskBase::GetErrorCode ( ) const
inlinenoexcept

Getter for the error code related to an error possibly occurred while the task was executed.

Returns
Returns ErrorCode.

Definition at line 1139 of file Instrument.h.

◆ GetState()

TaskState DynExp::TaskBase::GetState ( ) const
inlinenoexcept

Getter for the instrument task's current state.

Returns
Returns State.

Definition at line 1120 of file Instrument.h.

◆ IsAborting()

bool DynExp::TaskBase::IsAborting ( ) const
inlinenoexcept

Determines whether the task should abort. A derived task is encouraged to call this method before performing any action or in between the individual steps of a more complex action.

Returns
Returns ShouldAbort.

Definition at line 1133 of file Instrument.h.

◆ IsLocked()

bool DynExp::TaskBase::IsLocked ( ) const
noexcept

Determines whether the task is locked.

Returns
Returns true if the task is in the state TaskState::Locked or TaskState::Running, false otherwise.

Definition at line 536 of file Instrument.cpp.

◆ KeepFinishedTask()

virtual bool DynExp::TaskBase::KeepFinishedTask ( ) const
inlineprivatevirtualnoexcept

Determines whether the task should be kept to check its results after execution. InstrumentDataBase::RemoveTaskFromQueue().

Returns
Return true to append the task to InstrumentDataBase::FinishedTasks after execution. Return false to destroy the task directly after execution.

Definition at line 1187 of file Instrument.h.

◆ Lock()

void DynExp::TaskBase::Lock ( )
private

Locks the task to prepare it for execution.

Exceptions
Util::InvalidStateExceptionis thrown if the task is not in the TaskState::Waiting state.

Definition at line 544 of file Instrument.cpp.

◆ Run()

InstrumentBase::TaskHandlingContinuationType DynExp::TaskBase::Run ( InstrumentInstance Instance)
private

Runs the task. Override RunChild() to define a derived task's action(s). Any exception leaving RunChild() will terminate the instrument thread. In this case, the instrument has to be reset in order to restart it. For minor errors occurring in RunChild(), return a TaskResultType instance with TaskResultType::ErrorCode set to an appropriate (non-zero) value. This sets State to TaskState::Failed. Note that in this case there might be no way to retrieve the error if finished tasks are not kept (i.e. KeepFinishedTask() returns false) and if no CallbackFunc has been set. RunChild() is supposed to check the return value of IsAborting().

Parameters
InstanceHandle to the instrument thread's data
Returns
Returns whether task handling should continue or whether the instrument thread should terminate.
Exceptions
Util::InvalidStateExceptionis thrown if the task is not in the TaskState::Waiting or TaskState::Locked state.

Definition at line 552 of file Instrument.cpp.

◆ RunChild()

virtual TaskResultType DynExp::TaskBase::RunChild ( InstrumentInstance Instance)
privatepure virtual

Runs the task. Override RunChild() to define a derived task's action(s). Any exception leaving RunChild() will terminate the instrument thread. In this case, the instrument has to be reset in order to restart it. For minor errors occurring in RunChild(), return a TaskResultType instance with TaskResultType::ErrorCode set to an appropriate (non-zero) value. This sets State to TaskState::Failed. Note that in this case there might be no way to retrieve the error if finished tasks are not kept (i.e. KeepFinishedTask() returns false) and if no CallbackFunc has been set. RunChild() is supposed to check the return value of IsAborting().

Parameters
InstanceHandle to the instrument thread's data
Returns
Returns whether task handling should continue or whether the instrument thread should terminate.
Exceptions
Util::InvalidStateExceptionis thrown if the task is not in the TaskState::Waiting or TaskState::Locked state.

Implemented in DynExpInstr::DummyDataStreamInstrumentTasks::ResetStreamSizeTask, DynExpInstr::NenionLeakvalveF3Tasks::SetHomeTask, DynExpInstr::NenionLeakvalveF3Tasks::ReferenceTask, DynExpInstr::NenionLeakvalveF3Tasks::SetVelocityTask, DynExpInstr::NenionLeakvalveF3Tasks::MoveToHomeTask, DynExpInstr::NenionLeakvalveF3Tasks::MoveAbsoluteTask, DynExpInstr::NenionLeakvalveF3Tasks::MoveRelativeTask, DynExpInstr::NenionLeakvalveF3Tasks::StopMotionTask, DynExpInstr::NetworkAnalogOutTasks::SetTask< BaseInstr,, gRPCStubs >, DynExpInstr::NetworkAnalogOutTasks::SetDefaultTask< BaseInstr,, gRPCStubs >, DynExpInstr::NetworkDataStreamInstrumentTasks::ReadTask< BaseInstr,, gRPCStubs >, DynExpInstr::NetworkDataStreamInstrumentTasks::WriteTask< BaseInstr,, gRPCStubs >, DynExpInstr::NetworkDataStreamInstrumentTasks::ClearTask< BaseInstr,, gRPCStubs >, DynExpInstr::NetworkDataStreamInstrumentTasks::StartTask< BaseInstr,, gRPCStubs >, DynExpInstr::NetworkDataStreamInstrumentTasks::StopTask< BaseInstr,, gRPCStubs >, DynExpInstr::NetworkDataStreamInstrumentTasks::RestartTask< BaseInstr,, gRPCStubs >, DynExpInstr::NetworkDataStreamInstrumentTasks::SetStreamSizeTask< BaseInstr,, gRPCStubs >, DynExpInstr::NetworkDataStreamInstrumentTasks::ResetStreamSizeTask< BaseInstr,, gRPCStubs >, DynExpInstr::NetworkDigitalOutTasks::SetTask< BaseInstr,, gRPCStubs >, DynExpInstr::NetworkDigitalOutTasks::SetDefaultTask< BaseInstr,, gRPCStubs >, DynExpInstr::NetworkLaserTasks::SetFrequencyTask, DynExpInstr::NetworkLaserTasks::SetIntensityTask, DynExpInstr::NetworkLaserTasks::SetScanRangeTask, DynExpInstr::NetworkLaserTasks::SetScanRateTask, DynExpInstr::NetworkLaserTasks::EnableTask, DynExpInstr::NetworkLaserTasks::ScanContinuouslyTask, DynExpInstr::NetworkLaserTasks::DisableScanTask, DynExpInstr::NetworkLaserTasks::DisableTask, DynExpInstr::NetworkSpectrometerTasks::SetExposureTimeTask, DynExpInstr::NetworkSpectrometerTasks::SetFrequencyRangeTask, DynExpInstr::NetworkSpectrometerTasks::SetSetSilentModeTask, DynExpInstr::NetworkSpectrometerTasks::RecordTask, DynExpInstr::NetworkSpectrometerTasks::AbortTask, DynExpInstr::NetworkTimeTaggerTasks::ReadTask< BaseInstr,, gRPCStubs >, DynExpInstr::NetworkTimeTaggerTasks::ClearTask< BaseInstr,, gRPCStubs >, DynExpInstr::NetworkTimeTaggerTasks::ConfigureInputTask< BaseInstr,, gRPCStubs >, DynExpInstr::NetworkTimeTaggerTasks::SetExposureTimeTask< BaseInstr,, gRPCStubs >, DynExpInstr::NetworkTimeTaggerTasks::SetCoincidenceWindowTask< BaseInstr,, gRPCStubs >, DynExpInstr::NetworkTimeTaggerTasks::SetDelayTask< BaseInstr,, gRPCStubs >, DynExpInstr::NetworkTimeTaggerTasks::SetHBTActiveTask< BaseInstr,, gRPCStubs >, DynExpInstr::NetworkTimeTaggerTasks::ConfigureHBTTask< BaseInstr,, gRPCStubs >, DynExpInstr::NetworkTimeTaggerTasks::ResetHBTTask< BaseInstr,, gRPCStubs >, DynExpInstr::NIDAQAnalogInTasks::ReadTask, DynExpInstr::NIDAQAnalogInTasks::StartTask, DynExpInstr::NIDAQAnalogInTasks::StopTask, DynExpInstr::NIDAQAnalogInTasks::RestartTask, DynExpInstr::NIDAQAnalogOutTasks::WriteTask, DynExpInstr::NIDAQAnalogOutTasks::ClearTask, DynExpInstr::NIDAQAnalogOutTasks::StartTask, DynExpInstr::NIDAQAnalogOutTasks::StopTask, DynExpInstr::NIDAQAnalogOutTasks::RestartTask, DynExpInstr::NIDAQDigitalInTasks::ReadTask, DynExpInstr::NIDAQDigitalInTasks::StartTask, DynExpInstr::NIDAQDigitalInTasks::StopTask, DynExpInstr::NIDAQDigitalInTasks::RestartTask, DynExpInstr::NIDAQDigitalOutTasks::WriteTask, DynExpInstr::NIDAQDigitalOutTasks::ClearTask, DynExpInstr::NIDAQDigitalOutTasks::StartTask, DynExpInstr::NIDAQDigitalOutTasks::StopTask, DynExpInstr::NIDAQDigitalOutTasks::RestartTask, DynExpInstr::NP_Conex_CC_Tasks::ResetTask, DynExpInstr::NP_Conex_CC_Tasks::SetReadyTask, DynExpInstr::NP_Conex_CC_Tasks::SetHomeTask, DynExpInstr::NP_Conex_CC_Tasks::SetHomeExecutionTask, DynExpInstr::NP_Conex_CC_Tasks::ReferenceTask, DynExpInstr::NP_Conex_CC_Tasks::ReferenceExecutionTask, DynExpInstr::NP_Conex_CC_Tasks::SetVelocityTask, DynExpInstr::NP_Conex_CC_Tasks::MoveToHomeTask, DynExpInstr::NP_Conex_CC_Tasks::MoveToHomeExecutionTask, DynExpInstr::NP_Conex_CC_Tasks::MoveAbsoluteTask, DynExpInstr::NP_Conex_CC_Tasks::MoveAbsoluteExecutionTask, DynExpInstr::NP_Conex_CC_Tasks::MoveRelativeTask, DynExpInstr::NP_Conex_CC_Tasks::MoveRelativeExecutionTask, DynExpInstr::NP_Conex_CC_Tasks::StopMotionTask, DynExpInstr::PI_C_862_Tasks::SetHomeTask, DynExpInstr::PI_C_862_Tasks::ReferenceTask, DynExpInstr::PI_C_862_Tasks::SetVelocityTask, DynExpInstr::PI_C_862_Tasks::MoveToHomeTask, DynExpInstr::PI_C_862_Tasks::MoveAbsoluteTask, DynExpInstr::PI_C_862_Tasks::MoveRelativeTask, DynExpInstr::PI_C_862_Tasks::StopMotionTask, DynExpInstr::PVCamTasks::SetCameraMode, DynExpInstr::PVCamTasks::SetExposureTimeTask, DynExpInstr::PVCamTasks::CaptureSingleTask, DynExpInstr::PVCamTasks::StartCapturingTask, DynExpInstr::PVCamTasks::StopCapturingTask, DynExpInstr::QutoolsQuTAGTasks::ReadDataTask, DynExpInstr::QutoolsQuTAGTasks::SetStreamSizeTask, DynExpInstr::QutoolsQuTAGTasks::ClearTask, DynExpInstr::QutoolsQuTAGTasks::ConfigureInputTask, DynExpInstr::QutoolsQuTAGTasks::SetExposureTimeTask, DynExpInstr::QutoolsQuTAGTasks::SetCoincidenceWindowTask, DynExpInstr::QutoolsQuTAGTasks::SetDelayTask, DynExpInstr::QutoolsQuTAGTasks::SetHBTActiveTask, DynExpInstr::QutoolsQuTAGTasks::ConfigureHBTTask, DynExpInstr::QutoolsQuTAGTasks::ResetHBTTask, DynExpInstr::RS_SMB100BTasks::StartTask, DynExpInstr::RS_SMB100BTasks::StopTask, DynExpInstr::RS_SMB100BTasks::SetSineFunctionTask, DynExpInstr::RS_SMB100BTasks::SetModulationTask, DynExpInstr::RS_SMB100BTasks::SetSweepTask, DynExpInstr::RS_SMB100BTasks::ForceTriggerTask, DynExpInstr::RS_SMB100BTasks::SetTriggerTask, DynExpInstr::RS_SMC100ATasks::StartTask, DynExpInstr::RS_SMC100ATasks::StopTask, DynExpInstr::RS_SMC100ATasks::SetSineFunctionTask, DynExpInstr::RS_SMC100ATasks::SetModulationTask, DynExpInstr::RS_SMC100ATasks::SetSweepTask, DynExpInstr::RS_SMC100ATasks::ForceTriggerTask, DynExpInstr::RS_SMC100ATasks::SetTriggerTask, DynExpInstr::SmarActTasks::SetHomeTask, DynExpInstr::SmarActTasks::ReferenceTask, DynExpInstr::SmarActTasks::CalibrateTask, DynExpInstr::SmarActTasks::SetVelocityTask, DynExpInstr::SmarActTasks::MoveToHomeTask, DynExpInstr::SmarActTasks::MoveAbsoluteTask, DynExpInstr::SmarActTasks::MoveRelativeTask, DynExpInstr::SmarActTasks::StopMotionTask, DynExpInstr::SwabianInstrumentsPulseStreamerTasks::WriteTask, DynExpInstr::SwabianInstrumentsPulseStreamerTasks::ClearTask, DynExpInstr::SwabianInstrumentsPulseStreamerTasks::StartTask, DynExpInstr::SwabianInstrumentsPulseStreamerTasks::StopTask, DynExpInstr::SwabianInstrumentsPulseStreamerTasks::RestartTask, DynExpInstr::SwabianInstrumentsPulseStreamerTasks::ResetBufferSizeTask, DynExpInstr::SwabianInstrumentsPulseStreamerTasks::ForceTriggerTask, DynExpInstr::SwabianInstrumentsPulseStreamerTasks::SetTriggerTask, DynExpInstr::SwabianInstrumentsPulseStreamerTasks::SetConstantOutputTask, DynExpInstr::SwabianInstrumentsPulseStreamerTasks::ForceFinalSampleTask, DynExpInstr::SwabianInstrumentsPulseStreamerTasks::SetNumRunsTask, DynExpInstr::WidefieldLocalizationTasks::ReadCellIDTask, DynExpInstr::WidefieldLocalizationTasks::AnalyzeWidefieldTask, DynExpInstr::WidefieldLocalizationTasks::AnalyzeDistortionTask, DynExpInstr::WidefieldLocalizationTasks::RecallPositionsTask, DynExpInstr::ZI_MFLITasks::ReadTask, DynExpInstr::ZI_MFLITasks::ClearDataTask, DynExpInstr::ZI_MFLITasks::StartTask, DynExpInstr::ZI_MFLITasks::StopTask, DynExpInstr::ZI_MFLITasks::SetSensitivityTask, DynExpInstr::ZI_MFLITasks::AutoAdjustSensitivityTask, DynExpInstr::ZI_MFLITasks::SetPhaseTask, DynExpInstr::ZI_MFLITasks::AutoAdjustPhaseTask, DynExpInstr::ZI_MFLITasks::SetTimeConstantTask, DynExpInstr::ZI_MFLITasks::SetFilterOrderTask, DynExpInstr::ZI_MFLITasks::SetTriggerModeTask, DynExpInstr::ZI_MFLITasks::SetTriggerEdgeTask, DynExpInstr::ZI_MFLITasks::SetSignalTypeTask, DynExpInstr::ZI_MFLITasks::SetSamplingRateTask, DynExpInstr::ZI_MFLITasks::SetEnableTask, DynExpInstr::ZI_MFLITasks::ForceTriggerTask, DynExpInstr::DataStreamInstrumentTasks::SetStreamSizeTask, DynExpInstr::FunctionGeneratorTasks::SetSineFunctionTask, DynExpInstr::FunctionGeneratorTasks::SetRectFunctionTask, DynExpInstr::FunctionGeneratorTasks::SetRampFunctionTask, DynExpInstr::FunctionGeneratorTasks::SetPulseFunctionTask, DynExpInstr::FunctionGeneratorTasks::SetArbitraryFunctionTask, DynExpInstr::FunctionGeneratorTasks::SetTriggerTask, DynExpInstr::InputPortTasks::ResetBufferSizeTask, DynExpInstr::OutputPortTasks::ResetBufferSizeTask, DynExpInstr::TimeTaggerTasks::ResetBufferSizeTask, DynExp::DefaultTask, DynExp::ArriveAtLatchTask, DynExp::InitTaskBase, DynExp::ExitTaskBase, and DynExp::UpdateTaskBase.

Member Data Documentation

◆ CallbackFunc

CallbackType DynExp::TaskBase::CallbackFunc
private

This callback function is called after the task has finished (either successfully or not) with a pointer to the current task and with a reference to the exception which occurred during the task execution (if an exception has occurred).

Definition at line 1195 of file Instrument.h.

◆ DeferUntil

const std::chrono::system_clock::time_point DynExp::TaskBase::DeferUntil
private

The execution of this task is deferred until the specified point in time is reached if time_since_epoch() of DeferUntil is non-zero. Tasks being deferred block the task queue of the instrument they are assigned to, i.e., other enqueued tasks do not run before this task to maintain the task order.

Definition at line 1203 of file Instrument.h.

◆ ErrorCode

std::atomic<int> DynExp::TaskBase::ErrorCode
private

Holds the error code of an error which occurred during execution of the task function.

Definition at line 1210 of file Instrument.h.

◆ InstrumentBaseOnly

InstrumentBaseOnlyType DynExp::TaskBase::InstrumentBaseOnly

Allow exclusive access to some of TaskBase's private methods to InstrumentBase.

Definition at line 1149 of file Instrument.h.

◆ InstrumentDataBaseOnly

InstrumentDataBaseOnlyType DynExp::TaskBase::InstrumentDataBaseOnly

Allow exclusive access to some of TaskBase's private methods to InstrumentDataBase.

Definition at line 1150 of file Instrument.h.

◆ ShouldAbort

std::atomic<bool> DynExp::TaskBase::ShouldAbort
private

Indicates whether the task should abort. Refer to Abort() and IsAborting().

Definition at line 1217 of file Instrument.h.

◆ State

std::atomic<TaskState> DynExp::TaskBase::State
private

Holds the task's current state. Refer to TaskBase::TaskState.

Definition at line 1209 of file Instrument.h.


The documentation for this class was generated from the following files: