STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
SensorFramePipeline.hpp
Go to the documentation of this file.
1#ifndef DAQ_SENSOR_FRAME_PIPELINE_HPP
2#define DAQ_SENSOR_FRAME_PIPELINE_HPP
3
4#include <memory>
5#include <optional>
6#include <string>
7#include <utility>
8#include <vector>
9
12
13namespace fsw {
14namespace streams {
15
16/**
17 * @brief UDP pipeline: DAQv2-Comms board packets → internal SensorBatch.
18 */
20public:
21 explicit SensorFramePipeline(const std::string& bind_address, uint16_t bind_port);
23
24 std::optional<daq_comms::protocol::SensorBatch> poll();
25
26 const std::string& last_source_ip() const {
27 return last_source_ip_;
28 }
29
30 bool is_ready() const;
31 std::string last_error() const;
32
33 ssize_t send_to(const std::string& dest_ip, uint16_t dest_port, const uint8_t* data,
34 size_t size);
35
36 bool set_broadcast(bool enable);
37
39 std::vector<uint8_t> data;
40 std::string source_ip;
41 };
42 std::optional<LastHeartbeat> get_last_heartbeat();
43
44 // Raw type-15 LOGS packet, surfaced like heartbeats (poll() returns no
45 // SensorBatch for it). daq_bridge parses + forwards it to the backend.
46 struct LastLog {
47 std::vector<uint8_t> data;
48 std::string source_ip;
49 };
50 std::optional<LastLog> get_last_log();
51
54 uint32_t pressure_pa;
57 std::string source_ip;
58 };
59 std::optional<EnvironmentalSample> get_last_environmental();
60
61private:
62 std::unique_ptr<daq_comms::transport::UDPSocket> socket_;
63 std::vector<uint8_t> receive_buffer_;
64 std::string last_error_;
65 std::string last_source_ip_;
66
67 std::vector<uint8_t> last_heartbeat_buffer_;
69
70 std::vector<uint8_t> last_log_buffer_;
72 std::optional<EnvironmentalSample> last_environmental_;
73
74 static constexpr size_t RECEIVE_BUFFER_SIZE = 8192;
75};
76
77} // namespace streams
78} // namespace fsw
79
80#endif
static void enable(board_bringup_t *b, uint16_t device_id)
std::vector< uint8_t > last_heartbeat_buffer_
static constexpr size_t RECEIVE_BUFFER_SIZE
std::unique_ptr< daq_comms::transport::UDPSocket > socket_
SensorFramePipeline(const std::string &bind_address, uint16_t bind_port)
std::optional< EnvironmentalSample > get_last_environmental()
const std::string & last_source_ip() const
std::optional< daq_comms::protocol::SensorBatch > poll()
std::optional< LastLog > get_last_log()
std::optional< EnvironmentalSample > last_environmental_
std::optional< LastHeartbeat > get_last_heartbeat()
ssize_t send_to(const std::string &dest_ip, uint16_t dest_port, const uint8_t *data, size_t size)
Motorized ball valve position: raw ADC counts -> % open.