State

class State(value)[source]

Bases: SuperEnum

Enum representing the state of the village system.

__init__(description: str) → None[source]

Initializes the State enum with a description.

Methods

Attributes

WAIT = 'All subjects are at home, waiting for RFID detection'
DETECTION = 'Gathering subject data, checking requirements to enter'
ACCESS = 'Closing door1, opening door2'
LAUNCH_AUTO = 'Automatically launching the task'
RUN_INITIAL = 'Task running, waiting for the corridor to become empty'
CLOSE_DOOR2 = 'Closing door2'
RUN_CLOSED = 'Task running, the subject cannot leave yet'
OPEN_DOOR2 = 'Opening door2'
RUN_OPEN = 'Task running, the subject can leave'
EXIT_UNSAVED = 'Closing door2, opening door1; data still not saved'
SAVE_OUTSIDE = 'Stopping the task, saving the data; the subject is already outside'
SAVE_INSIDE = 'Stopping the task, saving the data; the subject is still inside'
WAIT_SUBJECT_EXIT = 'Task finished, waiting for the subject to leave'
EXIT_SAVED = 'Closing door2, opening door1; data already saved'
OPEN_DOOR2_STOP = 'Opening door2, disconnecting RFID'
MANUAL_MODE = 'Settings are being changed or task is being manually prepared'
LAUNCH_MANUAL = 'Manually launching the task'
RUN_MANUAL = 'Task running manually'
SAVE_MANUAL = 'Stopping the task, saving the data; task is running manually'
SYNC = 'Synchronizing data or doing user-defined tasks'
QUIT_APP = 'Confirming whether to quit the app'
can_exit() → bool[source]

Checks if the system can exit in this state.

Returns:

True if exit is allowed.

Return type:

bool

can_edit_data() → bool[source]

Checks if data editing is allowed in this state.

Returns:

True if editing is allowed.

Return type:

bool

can_calibrate_scale() → bool[source]

Checks if scale calibration is allowed in this state.

Returns:

True if calibration is allowed.

Return type:

bool

is_heavy_work() → bool[source]

Checks if this is a state where the system saves or syncs data.

That work (saving the session and video CSVs, the garbage collection and the rsync in SYNC) can keep Python busy long enough for the cameras to miss frames, so their watchdog tolerates it.

Returns:

True if heavy saving/syncing work happens in this state.

Return type:

bool

can_restart_corridor_video() → bool[source]

Checks if a new corridor video can be started in this state.

Starting one stalls Python for ~1 s (stopping the encoder, launching ffmpeg), which would disturb a running task, so the periodic split (CORRIDOR_VIDEO_DURATION) waits until no task is being launched, run or saved. A restart after a camera failure is not restricted.

Returns:

True if a new corridor video can be started.

Return type:

bool

box_in_use() → bool[source]

Checks if the box is in use in this state.

True from the moment a task is launched until the subject has left the box (or, for a manual task, until it is saved): a task is running in the box or a subject may be inside. Not the same as “a subject is in the box”: while launching the subject may still be in the corridor, and a manual task or a calibration may run with no subject at all.

Returns:

True if the box is in use.

Return type:

bool

task_is_running() → bool[source]

Checks if a task is currently running.

Returns:

True if a task is running.

Return type:

bool

manual_task_running() → bool[source]

Checks if a manual task is being launched or running.

Returns:

True if a manual task is being launched or running.

Return type:

bool

auto_task_running() → bool[source]

Checks if an automatic task is being launched or running.

Returns:

True if an automatic task is being launched or running.

Return type:

bool

manual_task_in_progress() → bool[source]

Checks if a manual task (or calibration) is running or being saved.

Returns:

True if a manual task has not finished yet.

Return type:

bool

can_enter_manual_mode() → bool[source]

Checks if the system can switch to MANUAL_MODE in this state.

Returns:

True if switching to MANUAL_MODE is allowed.

Return type:

bool

can_stop_syncing() → bool[source]

Checks if syncing process can be stopped.

Returns:

True if syncing can be stopped.

Return type:

bool

can_go_to_wait() → bool[source]

Checks if the state can transition to WAIT.

Returns:

True if transition to WAIT is allowed.

Return type:

bool