Qudi
|
This class represents a task in a module that can be safely executed by checking preconditions and pausing other tasks that are being executed as well. More...
Public Member Functions | |
def | __init__ (self, name, runner, references, config, kwargs) |
Create an Interruptable task. More... | |
def | log (self) |
Returns a logger object. | |
def | onchangestate (self, e) |
Fysom callback for state transition. More... | |
def | checkStartPrerequisites (self) |
Check whether this task can be started by checking if all tasks to be paused are either stopped or can be paused. More... | |
def | checkExtraStartPrerequisites (self) |
If your task has extra prerequisites that are not covered by checking if a certain task can be paused, overwrite this function when sub-classing. More... | |
def | checkPausePrerequisites (self) |
Check if task is allowed to pause based on external state. More... | |
def | checkExtraPausePrerequisites (self) |
If yout task has prerequisites for pausing, overwrite this function when subclassing and put the check here. More... | |
def | canPause (self) |
Check if task can pause based on its own state only. | |
def | startTask (self) |
Implement the operation to start your task here. | |
def | runTaskStep (self) |
Implement one work step of your task here. More... | |
def | pauseTask (self) |
Implement the operations necessary to pause your task here. | |
def | resumeTask (self) |
Implement the operations necessary to resume your task from being paused here. | |
def | cleanupTask (self) |
If your task leaves behind any undesired state, take care to remove it in this function. More... | |
Public Attributes | |
lock | |
name | |
interruptable | |
success | |
runner | |
ref | |
config | |
result | |
This class represents a task in a module that can be safely executed by checking preconditions and pausing other tasks that are being executed as well.
The task can also be paused, given that the preconditions for pausing are met.
State diagram for InterruptableTask:
stopped -> starting --------—> running ------—> finishing -* ^ | _______| ^_________ | |<------—* v | v | pausing -> paused -> resuming | | | | | ^ v v | |----------—<-----—|-------—<------—|-----—<----—
Each state has a transition state that allow for checks, synchronizatuion and for parts of the task to influence its own execution via signals. This also allows the TaskRunner to be informed about what the task is doing and ensuring that a task is executed in the correct thread.
def generic_task.InterruptableTask.__init__ | ( | self, | |
name, | |||
runner, | |||
references, | |||
config, | |||
kwargs | |||
) |
Create an Interruptable task.
str | name: unique task name |
object | runner: reference to the TaskRunner managing this task |
dict | references: a dictionary of all required modules |
dict | config: configuration dictionary |
def generic_task.InterruptableTask.checkExtraPausePrerequisites | ( | self | ) |
If yout task has prerequisites for pausing, overwrite this function when subclassing and put the check here.
def generic_task.InterruptableTask.checkExtraStartPrerequisites | ( | self | ) |
If your task has extra prerequisites that are not covered by checking if a certain task can be paused, overwrite this function when sub-classing.
def generic_task.InterruptableTask.checkPausePrerequisites | ( | self | ) |
Check if task is allowed to pause based on external state.
def generic_task.InterruptableTask.checkStartPrerequisites | ( | self | ) |
Check whether this task can be started by checking if all tasks to be paused are either stopped or can be paused.
Also check custom prerequisites.
def generic_task.InterruptableTask.cleanupTask | ( | self | ) |
If your task leaves behind any undesired state, take care to remove it in this function.
It is called after a task has finished.
def generic_task.InterruptableTask.onchangestate | ( | self, | |
e | |||
) |
Fysom callback for state transition.
object | e: Fysom state transition description |
def generic_task.InterruptableTask.runTaskStep | ( | self | ) |
Implement one work step of your task here.