Python API
deimos
Controller
The control program that communicates with hardware peripherals, runs calculations, and dispatches data.
controller_loss_of_contact_limit
property
writable
Number of missed packets from a peripheral that indicates disconnection.
dt_ns
property
writable
[ns] control program cycle period.
enable_manual_inputs
property
writable
Whether manual input overrides should be applied during the control loop.
loop_method
property
writable
The loop waiting method for the controller.
Busywaiting is performant, but inefficient; relying on the operating system for scheduling is efficient, but not performant.
loss_of_contact_policy
property
writable
The response of the control program when a peripheral disconnects during run.
op_dir
property
writable
The directory where this operation's logs and other data will be placed, and where calcs with linked configuration (like a SequenceMachine) can find their linked files or folders by relative path.
op_name
property
writable
The name of the operation. Used to set database table names, set log and data file names, etc.
peripheral_loss_of_contact_limit
property
writable
Number of missed packets from the controller that indicates disconnection.
rate_hz
property
writable
[Hz] control program cycle rate.
termination_criteria
property
writable
Criteria for exiting the control program.
__init__(op_name, op_dir, rate_hz)
Build a new controller.
rate_hz will be rounded to the nearest nanosecond when converted
to the sample period.
This constructor does not run the controller or attach any peripherals.
add_calc(name, calc)
Add a calc to the expression graph that runs on every cycle
add_dataframe_dispatcher(name, max_size_megabytes, overflow_behavior)
Add an in-memory dataframe dispatcher and return its shared handle.
add_dispatcher(name, dispatcher)
Add a dispatcher via a JSON-serializable dispatcher instance.
add_peripheral(name, p)
Register a peripheral with the control program
add_socket(name, socket)
Add a socket via a JSON-serializable socket instance.
attach_hootl_driver(peripheral_name, transport, end_epoch_ns=None)
Wrap an existing peripheral with a hootl wrapper and start its driver.
available_inputs()
List peripheral inputs that can be written manually.
clear_calcs()
Remove all calcs.
clear_dispatchers()
Remove all dispatchers.
clear_peripherals()
Remove all peripherals.
clear_sockets()
Remove all sockets.
remove_socket(name)
Remove a socket by name.
run()
Run the control program.
run_nonblocking(latest_value_cutoff_freq=None, wait_for_ready=True)
Run the control program on a separate thread and return a handle for coordination.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
latest_value_cutoff_freq
|
float | None
|
Optional second-order Butterworth low-pass filter cutoff frequency to apply to latest-value data. If the selected frequency is outside the viable range for the filter, the cutoff frequency will be clamped to the viable bounds and a warning will be emitted. |
None
|
wait_for_ready
|
bool
|
Block until the controller has completed its first cycle. |
True
|
scan(timeout_ms=10)
Scan the local network (and any other attached sockets) for available peripherals.
set_peripheral_input_source(input_field, source_field)
Connect an entry in the calc graph to a command to be sent to the peripheral.
LoopMethod
Efficient
class-attribute
Use operating system scheduling to reduce CPU usage at the expense of degraded cycle performance. Typically viable up to about 50Hz control rate.
Performant
class-attribute
Use 100% of a CPU to protect timing. This increases maximum usable control frequency.
efficient()
staticmethod
Use operating system scheduling for lower CPU usage.
performant()
staticmethod
Use 100% of a CPU to protect timing.
LossOfContactPolicy
Reconnect
class-attribute
Attempt to reconnect to the peripheral
Terminate
class-attribute
Terminate the control program.
reconnect_indefinite()
staticmethod
Construct a reconnect policy with no timeout.
reconnect_s(timeout_s)
staticmethod
Construct a reconnect policy with a timeout in seconds.
terminate()
staticmethod
Construct a policy that terminates the control program.
Overflow
Error
class-attribute
Emit an error and shut down.
NewFile
class-attribute
Create a new shard.
Wrap
class-attribute
Overwrite oldest data first.
error()
staticmethod
Error on overflow.
new_file()
staticmethod
Create a new file on overflow.
wrap()
staticmethod
Wrap back to the beginning of the file.
Termination
Scheduled
class-attribute
End the control program at a specific UTC system time.
Timeout
class-attribute
End the control program after some duration from the start of the first cycle.
scheduled_epoch_ns(ns)
staticmethod
End at a specified absolute system time in UTC nanoseconds.
timeout_s(s)
staticmethod
End after s seconds from the start of the first cycle.