Skip to main content

state_interface

module core.interfaces.state_interface


class StateInterface


method load_state

load_state() → StateObject

Load the state from the state file.


method update_state

update_state(
position: 'Optional[Position]' = None,
recent_cli_calls: 'Optional[int]' = None,
helios_indicates_good_conditions: "Optional[Literal['yes', 'no', 'inconclusive']]" = None,
measurements_should_be_running: 'Optional[bool]' = None,
plc_state: 'Optional[PLCState]' = None,
operating_system_state: 'Optional[OperatingSystemState]' = None,
current_exceptions: 'Optional[list[str]]' = None,
upload_is_running: 'Optional[bool]' = None,
enforce_none_values: 'bool' = False
)None

Update the state file. Values that are not explicitly set will not be changed in the state file. Only if enforce_none_values is set to True, all values not explicitly set will be set to None.


method update_state_in_context

update_state_in_context() → Generator[StateObject, None, None]

Update the state file in a context manager.

Example:

with interfaces.StateInterface.update_state_in_context() as state:
state.helios_indicates_good_conditions = "yes"

The file will be locked correctly, so that no other process can interfere with the state file and the state