1#ifndef PRESSURE_STATE_MACHINE_HPP
2#define PRESSURE_STATE_MACHINE_HPP
107 bool initialize(std::shared_ptr<elodin::ElodinClient> elodin_client,
108 std::shared_ptr<config::BoardDiscovery> board_discovery,
void readPressureData()
Read pressure data from Elodin.
void registerPSMVTables()
Register Elodin VTables for PSM actuator commands and state transitions.
void stop()
Stop the state machine.
std::chrono::milliseconds pressure_read_period_
bool requestTransition(SystemState target_state)
Request transition to a specific state (manual override).
uint16_t actuatorToMessageID(ActuatorID actuator) const
Convert actuator ID to message ID from config.
uint16_t actuator_board_port_
void stateMachineLoop()
Main state machine loop.
uint16_t pt_oup_message_id_
SystemState
System states matching the state machine diagram.
PressureThresholds thresholds_
void sendActuatorCommand(ActuatorID actuator, CommandType command, float value=0.0f)
Send actuator command.
std::atomic< bool > running_
uint16_t pt_hp_message_id_
uint16_t pt_fdp_message_id_
uint16_t pt_lp_message_id_
PressureReadings latest_pressures_
bool initialize(std::shared_ptr< elodin::ElodinClient > elodin_client, std::shared_ptr< config::BoardDiscovery > board_discovery, const PressureThresholds &thresholds)
Initialize the state machine.
std::string getCurrentStateName() const
Get current state name as string.
std::chrono::steady_clock::time_point state_entry_time_
std::atomic< SystemState > current_state_
CommandType
Command types for actuators.
void executeStateActions(SystemState state)
Execute state actions (while in state).
std::thread state_machine_thread_
uint16_t pt_fup_message_id_
void executeStateEntryActions(SystemState state)
Execute state entry actions.
SystemState getCurrentState() const
Get current state.
std::map< ActuatorID, uint16_t > actuator_message_ids_
PressureReadings getLatestPressures() const
Get latest pressure readings.
std::chrono::milliseconds state_machine_period_
uint16_t pt_odp_message_id_
std::string actuator_board_ip_
std::pair< std::string, uint16_t > getActuatorBoardAddress(ActuatorID actuator) const
Get board IP and port for actuator.
std::atomic< bool > abort_requested_
void start()
Start the state machine.
void requestAbort()
Request abort.
void sendActuatorCommandUDP(ActuatorID actuator, CommandType command, float value=0.0f)
Send actuator command via UDP to board.
ActuatorID
Actuator identifiers matching config.
std::shared_ptr< elodin::ElodinClient > elodin_client_
std::unique_ptr< daq_comms::transport::UDPSocket > command_socket_
std::shared_ptr< config::BoardDiscovery > board_discovery_
std::mutex pressure_mutex_
void checkTransitions()
Check transition conditions based on current state and pressures.
static ActuatorControllerState state
Motorized ball valve position: raw ADC counts -> % open.
Pressure sensor readings.
std::chrono::steady_clock::time_point timestamp
Configuration for pressure thresholds.
double gn2_low_target_psi
double gn2_high_target_psi