STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
PTMessage.hpp
Go to the documentation of this file.
1#ifndef PT_MESSAGE_HPP
2#define PT_MESSAGE_HPP
3
4#include <array>
5#include <cstdint>
6
7#include "CommsMessage.hpp"
8
9/**
10 * @brief PT Location enumeration for engine system
11 */
12enum class PTLocation {
13 PRESSURANT_TANK = 0, // Pressurant tank PT
14 KERO_INLET = 1, // Kero Inlet PT
15 KERO_OUTLET = 2, // Kero Outlet PT
16 LOX_INLET = 3, // Lox Inlet PT
17 LOX_OUTLET = 4, // Lox Outlet PT
18 INJECTOR = 5, // Injector PT
19 CHAMBER_WALL_1 = 6, // Chamber Wall PT #1
20 CHAMBER_WALL_2 = 7, // Chamber Wall PT #2
21 NOZZLE_EXIT = 8, // Nozzle Exit PT
22 UNKNOWN = 9 // Unknown/Unused
23};
24
25/**
26 * @brief Pressure Transducer Message - Raw Rec18 format from ESP32
27 *
28 * Matches the Rec18 struct from Arduino exactly
29 */
30using PTMessage = comms::CommsMessage<uint8_t, // (0) ch - channel id
31 uint8_t, // (1) ok - 0 or 1
32 uint16_t, // (2) padding - for 4-byte alignment
33 uint32_t, // (3) raw - ADC code
34 uint32_t, // (4) sample_time - per-sample timestamp
35 uint32_t, // (5) read_time_dur - per read()
36 uint32_t>; // (6) conv_time_dur - wait for DRDY
37
38// Function to set PT sensor measurements with raw voltage
39static void set_pt_measurement(PTMessage& message, uint64_t timestamp_ns, uint8_t sensor_id,
40 double raw_voltage_v, PTLocation location) {
41 message.setField<0>(timestamp_ns);
42 message.setField<1>(sensor_id);
43 message.setField<2>(raw_voltage_v);
44 message.setField<3>(static_cast<uint8_t>(location));
45}
46
47// Helper function to get PT location name
48static std::string getPTLocationName(PTLocation location) {
49 switch (location) {
51 return "Pressurant Tank";
53 return "Kero Inlet";
55 return "Kero Outlet";
57 return "Lox Inlet";
59 return "Lox Outlet";
61 return "Injector";
63 return "Chamber Wall #1";
65 return "Chamber Wall #2";
67 return "Nozzle Exit";
69 return "Unknown";
70 default:
71 return "Invalid";
72 }
73}
74
76 PTMessage message;
77 set_pt_measurement(message, 0, 0, 2.5, PTLocation::PRESSURANT_TANK); // 2.5V raw reading
78 return message;
79}
80
81// Specialized PT messages for different locations
82using PTChamberMessage = PTMessage; // Chamber pressure PT
83using PTFuelInletMessage = PTMessage; // Fuel inlet PT
84using PTOxInletMessage = PTMessage; // Oxidizer inlet PT
85using PTCoolantInletMessage = PTMessage; // Coolant inlet PT
86using PTIgniterMessage = PTMessage; // Igniter PT
87
88#endif // PT_MESSAGE_HPP
PTMessage PTOxInletMessage
Definition PTMessage.hpp:84
static void set_pt_measurement(PTMessage &message, uint64_t timestamp_ns, uint8_t sensor_id, double raw_voltage_v, PTLocation location)
Definition PTMessage.hpp:39
PTMessage PTChamberMessage
Definition PTMessage.hpp:82
static std::string getPTLocationName(PTLocation location)
Definition PTMessage.hpp:48
comms::CommsMessage< uint8_t, uint8_t, uint16_t, uint32_t, uint32_t, uint32_t, uint32_t > PTMessage
Pressure Transducer Message - Raw Rec18 format from ESP32.
Definition PTMessage.hpp:30
PTLocation
PT Location enumeration for engine system.
Definition PTMessage.hpp:12
PTMessage PTIgniterMessage
Definition PTMessage.hpp:86
PTMessage PTFuelInletMessage
Definition PTMessage.hpp:83
static PTMessage generateTestMessagePT()
Definition PTMessage.hpp:75
PTMessage PTCoolantInletMessage
Definition PTMessage.hpp:85
CommsMessage - Template-based message serialization.