DynExp
Highly flexible laboratory automation for dynamically changing experiments.
DynExpInstr::FunctionGeneratorTasks::SetRampFunctionTask Class Reference

Task to write a ramp function to the related data stream instrument. More...

+ Inheritance diagram for DynExpInstr::FunctionGeneratorTasks::SetRampFunctionTask:

Public Member Functions

 SetRampFunctionTask (const FunctionGeneratorDefs::RampFunctionDescType &FunctionDesc, bool Autostart, CallbackType CallbackFunc) noexcept
 Constructs a SetRampFunctionTask instance. More...
 
- Public Member Functions inherited from DynExp::TaskBase
 TaskBase (CallbackType CallbackFunc=nullptr) noexcept
 Constructs an instrument task. More...
 
virtual ~TaskBase ()=0
 The destructor aborts a waiting task setting State to TaskState::Aborted. Then, it calls CallbackFunc with a default-constructed ExceptionContainer instance. More...
 
TaskState GetState () const noexcept
 Getter for the instrument task's current state. More...
 
bool IsLocked () const noexcept
 Determines whether the task is locked. More...
 
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. More...
 
int GetErrorCode () const noexcept
 Getter for the error code related to an error possibly occurred while the task was executed. More...
 
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. More...
 

Private Member Functions

virtual DynExp::TaskResultType RunChild (DynExp::InstrumentInstance &Instance) override
 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(). More...
 

Private Attributes

FunctionGeneratorDefs::RampFunctionDescType FunctionDesc
 Description of the ramp function. More...
 
bool Autostart
 Determines whether to directly make the underlying hardware device start generating the function (true) or whether to await a trigger signal (false). More...
 

Additional Inherited Members

- Public Types inherited from DynExp::TaskBase
enum class  TaskState {
  Waiting , Locked , Running , Finished ,
  Failed , Aborted
}
 Defines states an instrument's task can undergo. Possible state transitions are: More...
 
using CallbackType = std::function< void(const TaskBase &, ExceptionContainer &)>
 Type of a callback function which is invoked when a task has finished, failed or has been aborted. The function receives a reference to the task it originates from as well as a reference to a wrapper holding an exception which might have occurred while executing the task. More...
 
- Public Attributes inherited from DynExp::TaskBase
InstrumentBaseOnlyType InstrumentBaseOnly
 Allow exclusive access to some of TaskBase's private methods to InstrumentBase. More...
 
InstrumentDataBaseOnlyType InstrumentDataBaseOnly
 Allow exclusive access to some of TaskBase's private methods to InstrumentDataBase. More...
 

Detailed Description

Task to write a ramp function to the related data stream instrument.

Definition at line 478 of file FunctionGenerator.h.

Constructor & Destructor Documentation

◆ SetRampFunctionTask()

DynExpInstr::FunctionGeneratorTasks::SetRampFunctionTask::SetRampFunctionTask ( const FunctionGeneratorDefs::RampFunctionDescType FunctionDesc,
bool  Autostart,
CallbackType  CallbackFunc 
)
inlinenoexcept

Constructs a SetRampFunctionTask instance.

Parameters
FunctionDescDescription of the ramp function.
AutostartDetermines whether to directly make the underlying hardware device start generating the function (true) or whether to await a trigger signal (false).
CallbackFuncThis callback function is called after the task has finished (either successfully or not) with a reference 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 487 of file FunctionGenerator.h.

Member Function Documentation

◆ RunChild()

DynExp::TaskResultType DynExpInstr::FunctionGeneratorTasks::SetRampFunctionTask::RunChild ( DynExp::InstrumentInstance Instance)
overrideprivatevirtual

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 true if task handling should continue, false if the instrument thread should terminate.
Exceptions
Util::InvalidStateExceptionis thrown if the task is not in the TaskState::Waiting or TaskState::Locked state.

Implements DynExp::TaskBase.

Definition at line 184 of file FunctionGenerator.cpp.

Member Data Documentation

◆ Autostart

bool DynExpInstr::FunctionGeneratorTasks::SetRampFunctionTask::Autostart
private

Determines whether to directly make the underlying hardware device start generating the function (true) or whether to await a trigger signal (false).

Definition at line 494 of file FunctionGenerator.h.

◆ FunctionDesc

FunctionGeneratorDefs::RampFunctionDescType DynExpInstr::FunctionGeneratorTasks::SetRampFunctionTask::FunctionDesc
private

Description of the ramp function.

Definition at line 493 of file FunctionGenerator.h.


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