STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
FSWConfigManager.hpp
Go to the documentation of this file.
1#ifndef DAQ_FSW_CONFIG_MANAGER_HPP
2#define DAQ_FSW_CONFIG_MANAGER_HPP
3
4#include <cstdint>
5#include <functional>
6#include <map>
7#include <memory>
8#include <string>
9
12
13namespace daq {
14struct PacketHeader;
15struct BoardHeartbeatPacket;
16} // namespace daq
17
18namespace fsw {
19namespace fsw {
20
21/**
22 * @brief FSW Configuration Manager
23 *
24 * Manages IP assignment and sensor configuration distribution to boards.
25 * This runs on the FSW side and assigns configurations to boards.
26 */
28public:
30 ~FSWConfigManager() = default;
31
32 /**
33 * @brief Initialize FSW config manager
34 * @param bind_address Address to bind UDP socket for sending configs
35 * @param bind_port Port for sending configs
36 */
37 bool initialize(const std::string& bind_address, uint16_t bind_port);
38
39private:
40 /** Local address board config packets are sent from — the same NIC this manager listens on.
41 * Empty/"0.0.0.0" leaves the egress interface to the kernel. */
42 std::string bind_address_;
43
44public:
45 /**
46 * @brief Process board heartbeat and assign IP if needed
47 * @param heartbeat Parsed heartbeat packet
48 * @param source_ip Source IP address
49 * @param mac_address Board MAC address
50 * @return Assigned IP address
51 */
52 std::string process_board_heartbeat(const daq::PacketHeader& header,
53 const daq::BoardHeartbeatPacket& body,
54 const std::string& source_ip,
55 const std::string& mac_address);
56
57 /**
58 * @brief Assign sensors to a board
59 * @param board_id Board ID
60 * @param sensor_ids List of sensor IDs to assign
61 * @param start_channel Starting channel on board
62 * @return true if successful
63 */
64 bool assign_sensors(uint8_t board_id, const std::vector<std::string>& sensor_ids,
65 uint8_t start_channel = 0);
66
67 /**
68 * @brief Send configuration packet to board
69 * @param board_id Board ID
70 * @return true if sent successfully
71 */
72 bool send_config_to_board(uint8_t board_id);
73
74 /**
75 * @brief Send configuration to all configured boards
76 */
78
79 /**
80 * @brief Get sensor assignment manager
81 */
85
86 /**
87 * @brief Set system state (GSE or FLIGHT)
88 */
89 void set_system_state(config::SystemState state);
90
91 /**
92 * @brief Configure static board IP address loaded from config.toml
93 */
94 void set_board_static_ip(uint8_t board_id, const std::string& ip);
95
96 /**
97 * @brief Get current system state
98 */
102
103private:
105 std::unique_ptr<daq_comms::transport::UDPSocket> config_socket_;
107
108 // Track which boards have been configured
109 std::map<uint8_t, bool> boards_configured_;
110
111 // Helper to determine system state from board type/IP
112 config::SystemState infer_system_state(uint8_t board_id, const std::string& source_ip) const;
113};
114
115} // namespace fsw
116} // namespace fsw
117
118#endif // DAQ_FSW_CONFIG_MANAGER_HPP
std::string process_board_heartbeat(const daq::PacketHeader &header, const daq::BoardHeartbeatPacket &body, const std::string &source_ip, const std::string &mac_address)
Process board heartbeat and assign IP if needed.
config::SystemState get_system_state() const
Get current system state.
config::SensorAssignmentManager & get_assignment_manager()
Get sensor assignment manager.
config::SensorAssignmentManager assignment_manager_
std::map< uint8_t, bool > boards_configured_
bool send_config_to_board(uint8_t board_id)
Send configuration packet to board.
void send_configs_to_all_boards()
Send configuration to all configured boards.
config::SystemState current_state_
config::SystemState infer_system_state(uint8_t board_id, const std::string &source_ip) const
std::string bind_address_
Local address board config packets are sent from — the same NIC this manager listens on.
bool initialize(const std::string &bind_address, uint16_t bind_port)
Initialize FSW config manager.
bool assign_sensors(uint8_t board_id, const std::vector< std::string > &sensor_ids, uint8_t start_channel=0)
Assign sensors to a board.
std::unique_ptr< daq_comms::transport::UDPSocket > config_socket_
static uint8_t board_id
Definition main.cpp:30
static ActuatorControllerState state
Definition main.cpp:57
SystemState
System state (GSE or Flight).
Motorized ball valve position: raw ADC counts -> % open.