STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
fsw::config::SensorAssignmentManager Class Reference

Sensor Assignment Manager. More...

#include <SensorAssignment.hpp>

Collaboration diagram for fsw::config::SensorAssignmentManager:
[legend]

Public Member Functions

 SensorAssignmentManager ()
 ~SensorAssignmentManager ()=default
bool load_sensor_definitions (const std::string &config_path)
 Load sensor definitions from config.
void set_static_board_ip (uint8_t board_id, const std::string &ip)
 Set a static IP for a board from loaded configuration.
std::string assign_board_ip (uint8_t board_id, const std::string &mac_address, SystemState system_state, const std::string &source_ip="")
 Assign IP address to board (called by FSW) If a static IP was set for this board_id, it will be used regardless of MAC/source_ip.
bool assign_sensors_to_board (uint8_t board_id, const std::vector< std::string > &sensor_ids, uint8_t start_channel=0)
 Assign sensors to board (called by FSW).
std::vector< uint8_t > generate_board_config_packet (uint8_t board_id) const
 Get board configuration for sending to board.
std::optional< SensorAssignment > get_sensor_assignment (const std::string &sensor_id) const
 Get sensor assignment for a sensor ID.
std::vector< SensorAssignment > get_board_sensors (uint8_t board_id) const
 Get all sensors for a board.
std::vector< SensorAssignment > get_system_sensors (SystemState state) const
 Get all sensors for a system state.
std::optional< BoardConfiguration > get_board_config (uint8_t board_id) const
 Get board configuration.
bool update_board_config_from_packet (uint8_t board_id, const uint8_t *data, size_t size)
 Update board configuration from received packet.
bool load_assignments_from_config (const std::string &config_path)
 Load assignments from config file.
const std::map< std::string, PressureSensorSpec > & get_pressure_sensor_specs () const
 Get all pressure sensor specs.
void register_config_update_callback (std::function< void(uint8_t, const BoardConfiguration &)> callback)
 Register callback for board configuration updates.

Private Member Functions

std::string calculate_ip_from_mac (const std::string &mac_address, SystemState state) const
SensorType sensor_type_from_string (const std::string &type_str) const
std::string sensor_type_to_string (SensorType type) const

Private Attributes

std::map< std::string, PressureSensorSpec > pressure_sensor_specs_
std::map< uint8_t, BoardConfiguration > board_configs_
std::map< uint8_t, std::string > static_board_ips_
std::map< std::string, SensorAssignment > sensor_assignments_
std::string gse_base_ip_
std::string flight_base_ip_
uint8_t gse_ip_range_start_
uint8_t gse_ip_range_end_
uint8_t flight_ip_range_start_
uint8_t flight_ip_range_end_
std::vector< std::function< void(uint8_t, const BoardConfiguration &)> > config_callbacks_

Detailed Description

Sensor Assignment Manager.

Manages sensor-to-board assignments, IP assignment from FSW, and configuration distribution to boards.

Definition at line 85 of file SensorAssignment.hpp.

Constructor & Destructor Documentation

◆ SensorAssignmentManager()

fsw::config::SensorAssignmentManager::SensorAssignmentManager ( )

◆ ~SensorAssignmentManager()

fsw::config::SensorAssignmentManager::~SensorAssignmentManager ( )
default

References board_id, and state.

Member Function Documentation

◆ assign_board_ip()

std::string fsw::config::SensorAssignmentManager::assign_board_ip ( uint8_t board_id,
const std::string & mac_address,
SystemState system_state,
const std::string & source_ip = "" )

Assign IP address to board (called by FSW) If a static IP was set for this board_id, it will be used regardless of MAC/source_ip.

Parameters
board_idBoard identifier
mac_addressBoard MAC address
system_stateGSE or FLIGHT
source_ipIP address from which the heartbeat was received
Returns
Assigned IP address

Definition at line 135 of file SensorAssignment.cpp.

References board_configs_, board_id, calculate_ip_from_mac(), fsw::config::GSE, sensor_assignments_, and static_board_ips_.

◆ assign_sensors_to_board()

bool fsw::config::SensorAssignmentManager::assign_sensors_to_board ( uint8_t board_id,
const std::vector< std::string > & sensor_ids,
uint8_t start_channel = 0 )

◆ calculate_ip_from_mac()

std::string fsw::config::SensorAssignmentManager::calculate_ip_from_mac ( const std::string & mac_address,
SystemState state ) const
private

◆ generate_board_config_packet()

std::vector< uint8_t > fsw::config::SensorAssignmentManager::generate_board_config_packet ( uint8_t board_id) const

Get board configuration for sending to board.

Parameters
board_idBoard identifier
Returns
Board configuration packet data

Definition at line 261 of file SensorAssignment.cpp.

References board_configs_, board_id, daq::create_sensor_config_packet(), and MAX_PACKET_SIZE.

◆ get_board_config()

std::optional< BoardConfiguration > fsw::config::SensorAssignmentManager::get_board_config ( uint8_t board_id) const

Get board configuration.

Definition at line 332 of file SensorAssignment.cpp.

References board_configs_, and board_id.

◆ get_board_sensors()

std::vector< SensorAssignment > fsw::config::SensorAssignmentManager::get_board_sensors ( uint8_t board_id) const

Get all sensors for a board.

Definition at line 314 of file SensorAssignment.cpp.

References board_configs_, and board_id.

◆ get_pressure_sensor_specs()

const std::map< std::string, PressureSensorSpec > & fsw::config::SensorAssignmentManager::get_pressure_sensor_specs ( ) const
inline

Get all pressure sensor specs.

Definition at line 164 of file SensorAssignment.hpp.

References pressure_sensor_specs_.

◆ get_sensor_assignment()

std::optional< SensorAssignment > fsw::config::SensorAssignmentManager::get_sensor_assignment ( const std::string & sensor_id) const

Get sensor assignment for a sensor ID.

Definition at line 305 of file SensorAssignment.cpp.

References sensor_assignments_.

◆ get_system_sensors()

std::vector< SensorAssignment > fsw::config::SensorAssignmentManager::get_system_sensors ( SystemState state) const

Get all sensors for a system state.

Definition at line 322 of file SensorAssignment.cpp.

References sensor_assignments_, and state.

◆ load_assignments_from_config()

bool fsw::config::SensorAssignmentManager::load_assignments_from_config ( const std::string & config_path)

Load assignments from config file.

◆ load_sensor_definitions()

bool fsw::config::SensorAssignmentManager::load_sensor_definitions ( const std::string & config_path)

Load sensor definitions from config.

Definition at line 25 of file SensorAssignment.cpp.

References fsw::config::FLIGHT, fsw::config::GSE, and pressure_sensor_specs_.

◆ register_config_update_callback()

void fsw::config::SensorAssignmentManager::register_config_update_callback ( std::function< void(uint8_t, const BoardConfiguration &)> callback)

Register callback for board configuration updates.

Definition at line 420 of file SensorAssignment.cpp.

References config_callbacks_.

◆ sensor_type_from_string()

SensorType fsw::config::SensorAssignmentManager::sensor_type_from_string ( const std::string & type_str) const
private

◆ sensor_type_to_string()

std::string fsw::config::SensorAssignmentManager::sensor_type_to_string ( SensorType type) const
private

◆ set_static_board_ip()

void fsw::config::SensorAssignmentManager::set_static_board_ip ( uint8_t board_id,
const std::string & ip )

Set a static IP for a board from loaded configuration.

Parameters
board_idBoard identifier
ipThe IP address configured for this board

Definition at line 114 of file SensorAssignment.cpp.

References board_configs_, board_id, sensor_assignments_, and static_board_ips_.

◆ update_board_config_from_packet()

bool fsw::config::SensorAssignmentManager::update_board_config_from_packet ( uint8_t board_id,
const uint8_t * data,
size_t size )

Update board configuration from received packet.

Definition at line 341 of file SensorAssignment.cpp.

References board_configs_, board_id, and config_callbacks_.

Member Data Documentation

◆ board_configs_

std::map<uint8_t, BoardConfiguration> fsw::config::SensorAssignmentManager::board_configs_
private

◆ config_callbacks_

std::vector<std::function<void(uint8_t, const BoardConfiguration&)> > fsw::config::SensorAssignmentManager::config_callbacks_
private

◆ flight_base_ip_

std::string fsw::config::SensorAssignmentManager::flight_base_ip_
private

Definition at line 189 of file SensorAssignment.hpp.

Referenced by calculate_ip_from_mac(), and SensorAssignmentManager().

◆ flight_ip_range_end_

uint8_t fsw::config::SensorAssignmentManager::flight_ip_range_end_
private

Definition at line 193 of file SensorAssignment.hpp.

Referenced by calculate_ip_from_mac(), and SensorAssignmentManager().

◆ flight_ip_range_start_

uint8_t fsw::config::SensorAssignmentManager::flight_ip_range_start_
private

Definition at line 192 of file SensorAssignment.hpp.

Referenced by calculate_ip_from_mac(), and SensorAssignmentManager().

◆ gse_base_ip_

std::string fsw::config::SensorAssignmentManager::gse_base_ip_
private

Definition at line 188 of file SensorAssignment.hpp.

Referenced by calculate_ip_from_mac(), and SensorAssignmentManager().

◆ gse_ip_range_end_

uint8_t fsw::config::SensorAssignmentManager::gse_ip_range_end_
private

Definition at line 191 of file SensorAssignment.hpp.

Referenced by calculate_ip_from_mac(), and SensorAssignmentManager().

◆ gse_ip_range_start_

uint8_t fsw::config::SensorAssignmentManager::gse_ip_range_start_
private

Definition at line 190 of file SensorAssignment.hpp.

Referenced by calculate_ip_from_mac(), and SensorAssignmentManager().

◆ pressure_sensor_specs_

std::map<std::string, PressureSensorSpec> fsw::config::SensorAssignmentManager::pressure_sensor_specs_
private

◆ sensor_assignments_

std::map<std::string, SensorAssignment> fsw::config::SensorAssignmentManager::sensor_assignments_
private

◆ static_board_ips_

std::map<uint8_t, std::string> fsw::config::SensorAssignmentManager::static_board_ips_
private

Definition at line 182 of file SensorAssignment.hpp.

Referenced by assign_board_ip(), and set_static_board_ip().


The documentation for this class was generated from the following files: