openpectus.engine.engine
Attributes
Classes
Represents timing information used by engine and any related components. |
|
Main engine class. Handles |
Module Contents
- openpectus.engine.engine.logger
- openpectus.engine.engine.frontend_logger
- class openpectus.engine.engine.EngineTiming(clock, timer, interval, speed)
Represents timing information used by engine and any related components.
- Parameters:
clock (openpectus.lang.exec.clock.Clock)
interval (float)
speed (float)
- _clock
- _timer
- _interval
- _speed
- __str__()
- Return type:
str
- static default()
- Return type:
- property clock: openpectus.lang.exec.clock.Clock
- Return type:
- property timer: openpectus.lang.exec.timer.EngineTimer
- Return type:
- property interval: float
- Return type:
float
- property speed: float
- Return type:
float
- class openpectus.engine.engine.Engine(uod, timing=EngineTiming.default(), enable_archiver=False)
Bases:
openpectus.lang.exec.pinterpreter.InterpreterContextMain engine class. Handles - io loop, reads and writes hardware process image (sync) - invokes interpreter to interpret next instruction (sync, generator based) - signals state changes via tag_updates queue (to EngineReporter) - accepts commands from cmd_queue (from interpreter and from aggregator)
- Parameters:
timing (EngineTiming)
- uod
- _running: bool = False
Indicates whether the scan cycle loop is running, set to False to shut down
- registry
Manages internal engine commands
- _clock: openpectus.lang.exec.clock.Clock
The time source
- _tick_timer: openpectus.lang.exec.timer.EngineTimer
Timer that invokes tick()
- _tick_time: float = 0.0
The time of the last tick
- _tick_number: int = -1
Tick count since last START command. It is incremented at the start of each tick. First tick is effectively number 0.
- _system_tags
- cmd_queue: queue.Queue[openpectus.lang.exec.commands.CommandRequest]
Commands to execute, coming from interpreter and from aggregator
- cmd_executing: list[openpectus.lang.exec.commands.CommandRequest] = []
Uod commands currently being excuted
- tag_updates: queue.Queue[openpectus.lang.exec.tags.Tag]
Tags updated in last tick
- _uod_listener
- _system_listener
- _runstate_started: bool = False
Indicates the current Start/Stop state
- _runstate_started_time: float = 0
Indicates the time of the last Start state
- _runstate_paused: bool = False
Indicates whether the engine is paused
- _runstate_holding: bool = False
Indicates whether the engine is on hold
- _runstate_stopping: bool = False
Indicates whether the engine is on stopping
- _prev_state: openpectus.lang.exec.tags.TagValueCollection | None = None
The state prior to applying safe state
- _last_error: Exception | None = None
Cause of error_state
- _method_manager: openpectus.engine.method_manager.MethodManager
The model handling changes to method code and interpreter running it
- _cancel_command_exec_ids: set[uuid.UUID]
- _tags
- _emitter
- __str__()
- Return type:
str
- _iter_all_tags()
- Return type:
Iterable[openpectus.lang.exec.tags.Tag]
- tags_as_readonly()
- Return type:
- property tags: openpectus.lang.exec.tags.TagCollection
- Return type:
- property emitter: openpectus.lang.exec.events.EventEmitter
- Return type:
- property base_unit_provider: openpectus.lang.exec.base_unit.BaseUnitProvider
- Return type:
- property method_manager: openpectus.engine.method_manager.MethodManager
- Return type:
- property interpreter: openpectus.lang.exec.pinterpreter.PInterpreter
- Return type:
- property runtimeinfo: openpectus.lang.exec.runlog.RuntimeInfo
- Return type:
- cleanup()
- get_runlog()
- Return type:
- run(skip_timer_start=False)
- is_running()
- Return type:
bool
- _run(skip_timer_start=True)
Starts the scan cycle
- stop()
- tick(tick_time, increment_time)
Performs a scan cycle tick.
- Parameters:
tick_time (float)
increment_time (float)
- read_process_image()
Read data from relevant hw registers into tags
- update_calculated_tags(tick_time, increment_time)
- Parameters:
tick_time (float)
increment_time (float)
- execute_commands()
- _execute_command(cmd_request, cmds_done)
- Parameters:
cmd_request (openpectus.lang.exec.commands.CommandRequest)
cmds_done (Set[openpectus.lang.exec.commands.CommandRequest])
- _execute_internal_command(cmd_request, cmds_done)
- Parameters:
cmd_request (openpectus.lang.exec.commands.CommandRequest)
cmds_done (Set[openpectus.lang.exec.commands.CommandRequest])
- set_run_id()
Creates a new run_id, sets the Run Id tag to it and returns it.
- Return type:
str
- clear_run_id()
- _stop_interpreter()
- _cancel_uod_commands()
- _finalize_uod_commands()
- _execute_uod_command(cmd_request, cmds_done)
- Parameters:
cmd_request (openpectus.lang.exec.commands.CommandRequest)
cmds_done (Set[openpectus.lang.exec.commands.CommandRequest])
- _apply_safe_state()
- Return type:
- _apply_state(state)
- Parameters:
- notify_all_tags()
Collect tag updates from all tags, even unmodified tags
- notify_tag_updates()
Collect tag updates from tags modified since last cycle
- set_error_state(exception)
- Parameters:
exception (Exception)
- has_error_state()
- Return type:
bool
- get_error_state_exception()
- Return type:
Exception | None
- write_process_image()
- schedule_execution(name, arguments='', exec_id=None)
Execute named command from interpreter
- Parameters:
name (str)
arguments (str)
exec_id (uuid.UUID | None)
- _validate_control_command(command_name)
Raise a ValueError if the command is a control command that is not valid in the current engine state.
- Parameters:
command_name (str)
- execute_control_command_from_user(name)
Execute named command from user
- Parameters:
name (str)
- inject_code(pcode)
Inject a code snippet to run in the current scope of the current program
- Parameters:
pcode (str)
- set_method(method)
Set new method. This will replace the current method, either by merging in changes in case the method is already running or just setting the method otherwise.
- Parameters:
method (openpectus.protocol.models.Method)
- Return type:
Literal[‘merge_method’, ‘set_method’]
- cancel_instruction(exec_id)
- Parameters:
exec_id (uuid.UUID)
- force_instruction(exec_id)
- Parameters:
exec_id (uuid.UUID)
- get_command_definitions()
Return engine command definitions.
- Return type: