The execution system
AWAIT(promise)
Creates a entity to wait (non-blocking) for a promise to complete
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
Promise
|
A promise |
required |
END()
End the current task Returns: PollResults: The poll results of the jump. used by the task.
get_shared_variable(key, default=None)
get the value of a variable at shared scope. Or returns the passed default if it doesn't exist.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
the variable name |
required |
default
|
optional
|
What to return if the variable doesn't exist. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
any |
any
|
The value of the variable, or default value |
get_variable(key, default=None)
get the value of a variable at task scope. Or returns the passed default if it doesn't exist.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
the variable name |
required |
default
|
optional
|
What to return if the variable doesn't exist. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
any |
any
|
The value of the variable, or default value |
gui_sub_task_schedule(label, data=None, var=None)
create an new task and start running at the specified label This is a GUI sub task. It will be marked to end if a new GUI is presented.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str or label
|
The label to run |
required |
data
|
duct
|
Data to initialie task variables. Defaults to None. |
None
|
var
|
str
|
Set the variable to the task created. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
MastAsyncTask |
MastAsyncTask
|
The MAST task created |
gui_task_jump(label)
Will redirect the gui_task to a new label
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str or label
|
The label to run |
required |
jump(label)
reset the program flow to a label
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str or label
|
The label to jump to |
required |
Returns:
| Name | Type | Description |
|---|---|---|
PollResults |
PollResults
|
The poll results of the jump. used by the task. |
log(message, name=None, level=None, use_mast_scope=False)
generate a log message
note: MAST exposes mast_log as log so it by default uses MAST scope
Args: message (str): The message to log name (str, optional): Name of the logger to log to. Defaults to None. level (str, optional): The logging level to use. Defaults to None.
logger(name=None, file=None, var=None, std_err=False)
create or retreive a looger
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the logger. Defaults to None. |
None
|
file
|
str
|
The file to log to. Defaults to None. |
None
|
var
|
str
|
The name of a string variable to log to. Defaults to None. |
None
|
mast_log(message, name=None, level=None, use_mast_scope=True)
generate a log message using MAST current task
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
The message to log |
required |
name
|
str
|
Name of the logger to log to. Defaults to None. |
None
|
level
|
str
|
The logging level to use. Defaults to None. |
None
|
set_shared_variable(key, value)
set the value of a variable at shared scope. Or returns the passed default if it doesn't exist.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
the variable name |
required |
value
|
any
|
The value to set the variable to |
required |
set_variable(key, value)
set the value of a variable at task scope. Or returns the passed default if it doesn't exist.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
the variable name |
required |
value
|
any
|
The value to set the variable to |
required |
sub_task_all(*args, **kwargs)
Creates a task for each argument that is a label. Also supports a data named argument to pass the data to all the tasks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
0..n labels
|
the labels to schedule. |
()
|
data
|
dict
|
keyword arg to pass data to the tasks. |
required |
Returns: Promise: A promise that is finished when all tasks are completed.
sub_task_schedule(label, data=None, var=None)
create an new task and start running at the specified label
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str or label
|
The label to run |
required |
data
|
duct
|
Data to initialie task variables. Defaults to None. |
None
|
var
|
str
|
Set the variable to the task created. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
MastAsyncTask |
MastAsyncTask
|
The MAST task created |
task_all(*args, **kwargs)
Creates a task for each argument that is a label. Also supports a data named argument to pass the data to all the tasks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
0..n labels
|
the labels to schedule. |
()
|
data
|
dict
|
keyword arg to pass data to the tasks. |
required |
Returns: Promise: A promise that is finished when all tasks are completed.
task_any(*args, **kwargs)
Creates a task for each argument that is a label. Also supports a data named argument to pass the data to all the tasks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
0..n labels
|
the labels to schedule. |
()
|
data
|
dict
|
keyword arg to pass data to the tasks. |
required |
Returns: Promise: A promise that is finished when any of the tasks completes.
task_cancel(task)
ends the specified task
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task
|
MastAsyncTask
|
The task to end |
required |
task_schedule(label, data=None, var=None, defer=False, inherit=True, unscheduled=False)
create an new task and start running at the specified label
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str or label
|
The label to run |
required |
data
|
duct
|
Data to initialie task variables. Defaults to None. |
None
|
var
|
str
|
Set the variable to the task created. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
MastAsyncTask |
MastAsyncTask
|
The MAST task created |
task_schedule_client(label, data=None, var=None)
create an new task and start running at the specified label assuring it runs on the client (which should be the same as task_schedule, but this is more explicit)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str or label
|
The label to run |
required |
data
|
duct
|
Data to initialie task variables. Defaults to None. |
None
|
var
|
str
|
Set the variable to the task created. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
MastAsyncTask |
MastAsyncTask
|
The MAST task created |
task_schedule_server(label, data=None, var=None)
create an new task and start running at the specified label assuring it runs on the server
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str or label
|
The label to run |
required |
data
|
duct
|
Data to initialie task variables. Defaults to None. |
None
|
var
|
str
|
Set the variable to the task created. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
MastAsyncTask |
MastAsyncTask
|
The MAST task created |