F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
TlmPacketizer.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title TlmPacketizerImpl.hpp
3 // \author tcanham
4 // \brief hpp file for TlmPacketizer component implementation class
5 //
6 // \copyright
7 // Copyright 2009-2015, by the California Institute of Technology.
8 // ALL RIGHTS RESERVED. United States Government Sponsorship
9 // acknowledged.
10 
11 #ifndef TlmPacketizer_HPP
12 #define TlmPacketizer_HPP
13 
18 #include "Os/Mutex.hpp"
23 #include "TlmPacketizerConfig/TlmPacketizerCfg.hpp"
24 
25 namespace Svc {
26 
28 constexpr Svc::TlmPacketizerPacket IGNORE_OMIT_LIST = {nullptr, 0, 0, 0};
29 
31  friend class TlmPacketizerTester;
32 
33  public:
34  // ----------------------------------------------------------------------
35  // Construction, initialization, and destruction
36  // ----------------------------------------------------------------------
37 
40  TlmPacketizer(const char* const compName
41  );
42 
43  void setPacketList(
44  const TlmPacketizerPacketList& packetList, // channels to packetize
45  const Svc::TlmPacketizerPacket& ignoreList, // channels to ignore (i.e. no warning event if not packetized)
46  const FwChanIdType startLevel // starting level of packets to send
47  );
48 
52 
53  private:
54  // ----------------------------------------------------------------------
55  // Handler implementations for user-defined typed input ports
56  // ----------------------------------------------------------------------
57 
60  void TlmRecv_handler(const FwIndexType portNum,
61  FwChanIdType id,
62  Fw::Time& timeTag,
63  Fw::TlmBuffer& val
64  ) override;
65 
69  void configureSectionGroupRate_handler(
70  FwIndexType portNum,
71  const Svc::TelemetrySection& section,
72  FwChanIdType tlmGroup,
73  const Svc::RateLogic& rateLogic,
74  U32 minDelta,
75  U32 maxDelta
76  ) override;
77 
80  void Run_handler(const FwIndexType portNum,
81  U32 context
82  ) override;
83 
85  void controlIn_handler(FwIndexType portNum,
86  const Svc::TelemetrySection& section,
87  const Fw::Enabled& enabled
88  ) override;
89 
92  void pingIn_handler(const FwIndexType portNum,
93  U32 key
94  ) override;
95 
97  Fw::TlmValid TlmGet_handler(FwIndexType portNum,
98  FwChanIdType id,
99  Fw::Time& timeTag,
100  Fw::TlmBuffer& val
101  ) override;
103 
106  void SET_LEVEL_cmdHandler(FwOpcodeType opCode,
107  U32 cmdSeq,
108  FwChanIdType level
109  ) override;
110 
113  void SEND_PKT_cmdHandler(FwOpcodeType opCode,
114  U32 cmdSeq,
115  U32 id,
116  Svc::TelemetrySection section
117  ) override;
118 
120  void ENABLE_SECTION_cmdHandler(FwOpcodeType opCode,
121  U32 cmdSeq,
122  Svc::TelemetrySection section,
123  Fw::Enabled enable
124  ) override;
125 
129  void ENABLE_GROUP_cmdHandler(FwOpcodeType opCode,
130  U32 cmdSeq,
131  Svc::TelemetrySection section,
132  FwChanIdType tlmGroup,
133  Fw::Enabled enable
134  ) override;
135 
137  void FORCE_GROUP_cmdHandler(FwOpcodeType opCode,
138  U32 cmdSeq,
139  Svc::TelemetrySection section,
140  FwChanIdType tlmGroup,
141  Fw::Enabled enable
142  ) override;
143 
145  void CONFIGURE_GROUP_RATES_cmdHandler(
146  FwOpcodeType opCode,
147  U32 cmdSeq,
148  Svc::TelemetrySection section,
149  FwChanIdType tlmGroup,
150  Svc::RateLogic rateLogic,
151  U32 minDelta,
152  U32 maxDelta
153  ) override;
154 
155  // number of packets to fill
156  FwChanIdType m_numPackets;
157  // Array of packet buffers to send
158  // Double-buffered to fill one while sending one
159 
160  struct BufferEntry {
161  Fw::ComBuffer buffer;
162  Fw::Time latestTime;
163  FwChanIdType id;
164  FwChanIdType level;
165  bool updated;
166  };
167 
168  // buffers for filling with telemetry
169  BufferEntry m_fillBuffers[MAX_PACKETIZER_PACKETS];
170 
171  struct TlmEntry {
172  FwChanIdType id;
173  // Offsets into packet buffers.
174  // -1 means that channel is not in that packet
176  FwSizeType channelSize;
177  bool ignored;
178  bool hasValue;
179  };
180 
181  Os::Mutex m_lock;
182 
183  bool m_configured;
184 
185  struct MissingTlmChan {
186  FwChanIdType id;
187  bool checked;
188  } m_missTlmCheck[TLMPACKETIZER_MAX_MISSING_TLM_CHECK];
189 
190  void missingChannel(FwChanIdType id);
191 
192  TlmPacketizer_SectionEnabled m_sectionEnabled{};
193 
194  TlmPacketizer_SectionConfigs m_groupConfigs{};
195 
196  enum UpdateFlag : U8 {
197  NEVER_UPDATED = 0,
198  PAST = 1,
199  NEW = 2,
200  REQUESTED = 3,
201  };
202 
203  struct PktSendCounters {
204  U32 prevSentCounter = std::numeric_limits<U32>::max(); // Prevent Start up spam
205  UpdateFlag updateFlag = UpdateFlag::NEVER_UPDATED;
207 
209  static const TlmPacketizer_TelemetrySendPortMap TELEMETRY_SEND_PORT_MAP;
210 
211  private:
212  Fw::SerializeStatus serializeParam(const FwPrmIdType base_id,
213  const FwPrmIdType local_id,
214  Fw::SerialBufferBase& buff) const override;
215 
216  Fw::SerializeStatus deserializeParam(const FwPrmIdType base_id,
217  const FwPrmIdType local_id,
218  const Fw::ParamValid prmStat,
219  Fw::SerialBufferBase& buff) override;
220 
221  private:
225  void configureSectionGroupRate(
226  const Svc::TelemetrySection& section,
227  FwChanIdType tlmGroup,
228  const Svc::RateLogic& rateLogic,
229  U32 minDelta,
230  U32 maxDelta
231  );
232 
240  static FwIndexType sectionGroupToPort(const FwIndexType section, const FwSizeType group);
241 
242  private:
243  FwSizeType m_numChannels;
246  m_channels;
247 };
248 
249 } // end namespace Svc
250 
251 #endif
TlmPacketizer(const char *const compName)
REQUIRED: Counter, leave as last element.
FwIdType FwOpcodeType
The type of a command opcode.
PlatformSizeType FwSizeType
FwIdType FwPrmIdType
The type of a parameter identifier.
static const FwChanIdType MAX_PACKETIZER_PACKETS
Maximum number of packets that the packetizer can handle.
PlatformSignedSizeType FwSignedSizeType
static const FwChanIdType TLMPACKETIZER_MAX_MISSING_TLM_CHECK
Maximum number of missing channels to track and report.
constexpr Svc::TlmPacketizerPacket IGNORE_OMIT_LIST
Constant allowing users to ignore the omit list allowing a reduction in required buckets and thus sto...
SerializeStatus
forward declaration for string
friend class TlmPacketizerTester
Enumeration for rate logic types for telemetry groups.
FwIdType FwChanIdType
The type of a telemetry channel identifier.
Enabled and disabled states.
void setPacketList(const TlmPacketizerPacketList &packetList, const Svc::TlmPacketizerPacket &ignoreList, const FwChanIdType startLevel)
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:53
PlatformIndexType FwIndexType
RateGroupDivider component implementation.
Enum representing parameter validity.
Auto-generated base for TlmPacketizer component.