Python API
deimos
Controller
The control program that communicates with hardware peripherals, runs calculations, and dispatches data.
Source code in deimos/deimos.pyi
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | |
controller_loss_of_contact_limit: int
property
writable
Number of missed packets from a peripheral that indicates disconnection.
dt_ns: int
property
writable
[ns] control program cycle period.
enable_manual_inputs: bool
property
writable
Whether manual input overrides should be applied during the control loop.
loop_method: LoopMethod
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: LossOfContactPolicy
property
writable
The response of the control program when a peripheral disconnects during run.
op_dir: str
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: str
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: int
property
writable
Number of missed packets from the controller that indicates disconnection.
rate_hz: float
property
writable
[Hz] control program cycle rate.
termination_criteria: Termination | None
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.
Source code in deimos/deimos.pyi
add_calc(name, calc)
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_peripheral(name, p)
add_socket(name, socket)
attach_hootl_driver(peripheral_name, transport, end_epoch_ns=None)
Wrap an existing peripheral with a hootl wrapper and start its driver.
available_inputs()
clear_calcs()
clear_dispatchers()
clear_peripherals()
clear_sockets()
graphviz_dot()
remove_socket(name)
run()
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
|
Source code in deimos/deimos.pyi
scan(timeout_ms=10)
set_peripheral_input_source(input_field, source_field)
LoopMethod
Source code in deimos/deimos.pyi
Efficient: Self
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: Self
class-attribute
Use 100% of a CPU to protect timing. This increases maximum usable control frequency.
efficient()
staticmethod
LossOfContactPolicy
Source code in deimos/deimos.pyi
Reconnect: Self
class-attribute
Attempt to reconnect to the peripheral
Terminate: Self
class-attribute
Terminate the control program.
reconnect_indefinite()
staticmethod
reconnect_s(timeout_s)
staticmethod
Overflow
Source code in deimos/deimos.pyi
Error: Self
class-attribute
Emit an error and shut down.
NewFile: Self
class-attribute
Create a new shard.
Wrap: Self
class-attribute
Overwrite oldest data first.
error()
staticmethod
new_file()
staticmethod
Termination
Source code in deimos/deimos.pyi
Scheduled: Self
class-attribute
End the control program at a specific UTC system time.
Timeout: Self
class-attribute
End the control program after some duration from the start of the first cycle.