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

Routes decoded sensor frames to Elodin tables. More...

#include <SensorRouter.hpp>

Collaboration diagram for fsw::routing::SensorRouter:
[legend]

Public Member Functions

 SensorRouter ()
 ~SensorRouter ()=default
bool load_config (const std::string &config_path)
 Load routing configuration from TOML file.
void add_channel (const SensorChannelConfig &config)
 Add a sensor channel configuration manually.
std::array< uint8_t, 2 > get_table_id (const std::string &sensor_type, uint8_t channel_id) const
 Get table ID for a sensor channel.
std::string get_table_name (const std::string &sensor_type, uint8_t channel_id) const
 Get table name for a sensor channel (for debugging).
std::vector< std::pair< std::array< uint8_t, 2 >, comms::messages::sensor::RawPTMessage > > route_pt_samples (const daq_comms::protocol::SensorBatch &batch, uint64_t receive_timestamp_ns) const
 Convert a sensor batch into Elodin messages.
std::vector< std::pair< std::array< uint8_t, 2 >, comms::messages::sensor::CalibratedPTMessage > > route_pt_samples_calibrated (const daq_comms::protocol::SensorBatch &batch, uint64_t receive_timestamp_ns, uint8_t pt_board_slot=1) const
 Convert PT samples to calibrated messages.
void set_pt_calibration (const calibration::PTCalibrationManager *cal_manager)
 Set PT calibration manager (legacy).
void set_tc_calibration (const calibration::SensorCalibrationManager *m)
 Set calibration managers for each sensor type.
void set_rtd_calibration (const calibration::SensorCalibrationManager *m)
void set_lc_calibration (const calibration::SensorCalibrationManager *m)
std::vector< std::pair< std::array< uint8_t, 2 >, comms::messages::sensor::RawTCMessage > > route_tc_samples (const daq_comms::protocol::SensorBatch &batch, uint64_t receive_timestamp_ns) const
std::vector< std::pair< std::array< uint8_t, 2 >, comms::messages::sensor::RawRTDMessage > > route_rtd_samples (const daq_comms::protocol::SensorBatch &batch, uint64_t receive_timestamp_ns) const
std::vector< std::pair< std::array< uint8_t, 2 >, comms::messages::sensor::RawLCMessage > > route_lc_samples (const daq_comms::protocol::SensorBatch &batch, uint64_t receive_timestamp_ns) const
std::vector< std::pair< std::array< uint8_t, 2 >, comms::messages::sensor::CalibratedTCMessage > > route_tc_samples_calibrated (const daq_comms::protocol::SensorBatch &batch, uint64_t receive_timestamp_ns) const
std::vector< std::pair< std::array< uint8_t, 2 >, comms::messages::sensor::CalibratedRTDMessage > > route_rtd_samples_calibrated (const daq_comms::protocol::SensorBatch &batch, uint64_t receive_timestamp_ns) const
std::vector< std::pair< std::array< uint8_t, 2 >, comms::messages::sensor::CalibratedLCMessage > > route_lc_samples_calibrated (const daq_comms::protocol::SensorBatch &batch, uint64_t receive_timestamp_ns) const
std::vector< std::pair< std::array< uint8_t, 2 >, comms::messages::sensor::CalibratedRTDMessage > > route_rtd_samples_pt100 (const daq_comms::protocol::SensorBatch &batch, uint64_t receive_timestamp_ns) const
 RTD Pt100 temperature conversion — no calibration manager required.

Private Member Functions

std::string make_key (const std::string &sensor_type, uint8_t channel_id) const

Private Attributes

std::unordered_map< std::string, SensorChannelConfig > channel_map_
const calibration::PTCalibrationManager * pt_calibration_ = nullptr
const calibration::SensorCalibrationManager * tc_calibration_ = nullptr
const calibration::SensorCalibrationManager * rtd_calibration_ = nullptr
const calibration::SensorCalibrationManager * lc_calibration_ = nullptr

Detailed Description

Routes decoded sensor frames to Elodin tables.

Maps sensor channels to Elodin table IDs based on configuration. This allows adding/removing sensors without code changes.

Definition at line 36 of file SensorRouter.hpp.

Constructor & Destructor Documentation

◆ SensorRouter()

fsw::routing::SensorRouter::SensorRouter ( )

Definition at line 11 of file SensorRouter.cpp.

◆ ~SensorRouter()

fsw::routing::SensorRouter::~SensorRouter ( )
default

Member Function Documentation

◆ add_channel()

void fsw::routing::SensorRouter::add_channel ( const SensorChannelConfig & config)

Add a sensor channel configuration manually.

Definition at line 85 of file SensorRouter.cpp.

References channel_map_, and make_key().

Referenced by load_config().

◆ get_table_id()

std::array< uint8_t, 2 > fsw::routing::SensorRouter::get_table_id ( const std::string & sensor_type,
uint8_t channel_id ) const

Get table ID for a sensor channel.

Parameters
sensor_type"PT", "TC", "RTD", or "LC"
channel_idChannel identifier
Returns
Table ID if found, empty array otherwise

Definition at line 90 of file SensorRouter.cpp.

References channel_map_, and make_key().

◆ get_table_name()

std::string fsw::routing::SensorRouter::get_table_name ( const std::string & sensor_type,
uint8_t channel_id ) const

Get table name for a sensor channel (for debugging).

Definition at line 101 of file SensorRouter.cpp.

References channel_map_, and make_key().

◆ load_config()

bool fsw::routing::SensorRouter::load_config ( const std::string & config_path)

Load routing configuration from TOML file.

Parameters
config_pathPath to TOML configuration file
Returns
true if loaded successfully

Definition at line 17 of file SensorRouter.cpp.

References add_channel().

◆ make_key()

std::string fsw::routing::SensorRouter::make_key ( const std::string & sensor_type,
uint8_t channel_id ) const
private

Definition at line 322 of file SensorRouter.cpp.

Referenced by add_channel(), get_table_id(), and get_table_name().

◆ route_lc_samples()

std::vector< std::pair< std::array< uint8_t, 2 >, comms::messages::sensor::RawLCMessage > > fsw::routing::SensorRouter::route_lc_samples ( const daq_comms::protocol::SensorBatch & batch,
uint64_t receive_timestamp_ns ) const

◆ route_lc_samples_calibrated()

std::vector< std::pair< std::array< uint8_t, 2 >, comms::messages::sensor::CalibratedLCMessage > > fsw::routing::SensorRouter::route_lc_samples_calibrated ( const daq_comms::protocol::SensorBatch & batch,
uint64_t receive_timestamp_ns ) const

◆ route_pt_samples()

std::vector< std::pair< std::array< uint8_t, 2 >, comms::messages::sensor::RawPTMessage > > fsw::routing::SensorRouter::route_pt_samples ( const daq_comms::protocol::SensorBatch & batch,
uint64_t receive_timestamp_ns ) const

Convert a sensor batch into Elodin messages.

Parameters
batchDecoded sensor batch
Returns
Vector of (table_id, message) pairs ready for publishing

Definition at line 111 of file SensorRouter.cpp.

References daq_comms::protocol::SensorBatch::pt_samples, and comms::CommsMessage< Fields >::setField().

◆ route_pt_samples_calibrated()

std::vector< std::pair< std::array< uint8_t, 2 >, comms::messages::sensor::CalibratedPTMessage > > fsw::routing::SensorRouter::route_pt_samples_calibrated ( const daq_comms::protocol::SensorBatch & batch,
uint64_t receive_timestamp_ns,
uint8_t pt_board_slot = 1 ) const

Convert PT samples to calibrated messages.

Parameters
batchDecoded sensor batch
Returns
Vector of (table_id, calibrated_message) pairs

Definition at line 134 of file SensorRouter.cpp.

References pt_calibration_, fsw::calibration::pt_logical_calibration_channel(), daq_comms::protocol::SensorBatch::pt_samples, and comms::CommsMessage< Fields >::setField().

◆ route_rtd_samples()

std::vector< std::pair< std::array< uint8_t, 2 >, comms::messages::sensor::RawRTDMessage > > fsw::routing::SensorRouter::route_rtd_samples ( const daq_comms::protocol::SensorBatch & batch,
uint64_t receive_timestamp_ns ) const

◆ route_rtd_samples_calibrated()

std::vector< std::pair< std::array< uint8_t, 2 >, comms::messages::sensor::CalibratedRTDMessage > > fsw::routing::SensorRouter::route_rtd_samples_calibrated ( const daq_comms::protocol::SensorBatch & batch,
uint64_t receive_timestamp_ns ) const

◆ route_rtd_samples_pt100()

std::vector< std::pair< std::array< uint8_t, 2 >, comms::messages::sensor::CalibratedRTDMessage > > fsw::routing::SensorRouter::route_rtd_samples_pt100 ( const daq_comms::protocol::SensorBatch & batch,
uint64_t receive_timestamp_ns ) const

RTD Pt100 temperature conversion — no calibration manager required.

Applies Callendar-Van Dusen (Pt100, R0=100Ω, A=3.9083e-3, B=-5.775e-7): resistance_ohm = raw_resistance_counts * 0.001 T = (-R0*A + sqrt((R0*A)^2 - 4*R0*B*(R0 - R))) / (2*R0*B)

Outputs CalibratedRTDMessage at packet_id {0x22, 0x10 + channel_id + 1} (matching the RTD_Cal VTable registered in DatabaseConfig).

◆ route_tc_samples()

std::vector< std::pair< std::array< uint8_t, 2 >, comms::messages::sensor::RawTCMessage > > fsw::routing::SensorRouter::route_tc_samples ( const daq_comms::protocol::SensorBatch & batch,
uint64_t receive_timestamp_ns ) const

◆ route_tc_samples_calibrated()

std::vector< std::pair< std::array< uint8_t, 2 >, comms::messages::sensor::CalibratedTCMessage > > fsw::routing::SensorRouter::route_tc_samples_calibrated ( const daq_comms::protocol::SensorBatch & batch,
uint64_t receive_timestamp_ns ) const

◆ set_lc_calibration()

void fsw::routing::SensorRouter::set_lc_calibration ( const calibration::SensorCalibrationManager * m)
inline

Definition at line 98 of file SensorRouter.hpp.

References lc_calibration_.

◆ set_pt_calibration()

void fsw::routing::SensorRouter::set_pt_calibration ( const calibration::PTCalibrationManager * cal_manager)
inline

Set PT calibration manager (legacy).

Definition at line 87 of file SensorRouter.hpp.

References pt_calibration_.

◆ set_rtd_calibration()

void fsw::routing::SensorRouter::set_rtd_calibration ( const calibration::SensorCalibrationManager * m)
inline

Definition at line 95 of file SensorRouter.hpp.

References rtd_calibration_.

◆ set_tc_calibration()

void fsw::routing::SensorRouter::set_tc_calibration ( const calibration::SensorCalibrationManager * m)
inline

Set calibration managers for each sensor type.

Definition at line 92 of file SensorRouter.hpp.

References tc_calibration_.

Member Data Documentation

◆ channel_map_

std::unordered_map<std::string, SensorChannelConfig> fsw::routing::SensorRouter::channel_map_
private

Definition at line 144 of file SensorRouter.hpp.

Referenced by add_channel(), get_table_id(), and get_table_name().

◆ lc_calibration_

const calibration::SensorCalibrationManager* fsw::routing::SensorRouter::lc_calibration_ = nullptr
private

Definition at line 149 of file SensorRouter.hpp.

Referenced by route_lc_samples_calibrated(), and set_lc_calibration().

◆ pt_calibration_

const calibration::PTCalibrationManager* fsw::routing::SensorRouter::pt_calibration_ = nullptr
private

Definition at line 146 of file SensorRouter.hpp.

Referenced by route_pt_samples_calibrated(), and set_pt_calibration().

◆ rtd_calibration_

const calibration::SensorCalibrationManager* fsw::routing::SensorRouter::rtd_calibration_ = nullptr
private

Definition at line 148 of file SensorRouter.hpp.

Referenced by route_rtd_samples_calibrated(), and set_rtd_calibration().

◆ tc_calibration_

const calibration::SensorCalibrationManager* fsw::routing::SensorRouter::tc_calibration_ = nullptr
private

Definition at line 147 of file SensorRouter.hpp.

Referenced by route_tc_samples_calibrated(), and set_tc_calibration().


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