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 
14 #include "Os/Mutex.hpp"
17 #include "config/TlmPacketizerCfg.hpp"
18 
19 namespace Svc {
20 
22  public:
23  // ----------------------------------------------------------------------
24  // Construction, initialization, and destruction
25  // ----------------------------------------------------------------------
26 
29  TlmPacketizer(const char* const compName
30  );
31 
32  void setPacketList(
33  const TlmPacketizerPacketList& packetList, // channels to packetize
34  const Svc::TlmPacketizerPacket& ignoreList, // channels to ignore (i.e. no warning event if not packetized)
35  const FwChanIdType startLevel); // starting level of packets to send
36 
39  ~TlmPacketizer(void);
40 
41  private:
42  // ----------------------------------------------------------------------
43  // Handler implementations for user-defined typed input ports
44  // ----------------------------------------------------------------------
45 
48  void TlmRecv_handler(const FwIndexType portNum,
49  FwChanIdType id,
50  Fw::Time& timeTag,
51  Fw::TlmBuffer& val
52  ) override;
53 
56  void Run_handler(const FwIndexType portNum,
57  U32 context
58  ) override;
59 
62  void pingIn_handler(const FwIndexType portNum,
63  U32 key
64  ) override;
65 
67  Fw::TlmValid TlmGet_handler(FwIndexType portNum,
68  FwChanIdType id,
69  Fw::Time& timeTag,
70  Fw::TlmBuffer& val
71  ) override;
73 
76  void SET_LEVEL_cmdHandler(const FwOpcodeType opCode,
77  const U32 cmdSeq,
78  FwChanIdType level
79  ) override;
80 
83  void SEND_PKT_cmdHandler(const FwOpcodeType opCode,
84  const U32 cmdSeq,
85  U32 id
86  ) override;
87 
88  // number of packets to fill
89  FwChanIdType m_numPackets;
90  // Array of packet buffers to send
91  // Double-buffered to fill one while sending one
92 
93  struct BufferEntry {
94  Fw::ComBuffer buffer;
95  Fw::Time latestTime;
96  FwChanIdType id;
97  FwChanIdType level;
98  bool updated;
99  bool requested;
100  };
101 
102  // buffers for filling with telemetry
103  BufferEntry m_fillBuffers[MAX_PACKETIZER_PACKETS];
104  // buffers for sending - will be copied from fill buffers
105  BufferEntry m_sendBuffers[MAX_PACKETIZER_PACKETS];
106 
107  struct TlmEntry {
108  FwChanIdType id;
109  // Offsets into packet buffers.
110  // -1 means that channel is not in that packet
112  FwSizeType channelSize;
113  TlmEntry* next;
114  bool used;
115  bool ignored;
116  bool hasValue;
117  FwChanIdType bucketNo;
118  };
119 
120  struct TlmSet {
121  TlmEntry* slots[TLMPACKETIZER_NUM_TLM_HASH_SLOTS];
122  TlmEntry buckets[TLMPACKETIZER_HASH_BUCKETS];
123  FwChanIdType free;
124  } m_tlmEntries;
125 
126  // hash function for looking up telemetry channel
127  FwChanIdType doHash(FwChanIdType id);
128 
129  Os::Mutex m_lock;
130 
131  bool m_configured;
132 
133  struct MissingTlmChan {
134  FwChanIdType id;
135  bool checked;
136  } m_missTlmCheck[TLMPACKETIZER_MAX_MISSING_TLM_CHECK];
137 
138  void missingChannel(FwChanIdType id);
139 
140  TlmEntry* findBucket(FwChanIdType id);
141 
142  FwChanIdType m_startLevel;
143  FwChanIdType m_maxLevel;
144 };
145 
146 } // end namespace Svc
147 
148 #endif
Definition: Time.hpp:9
TlmPacketizer(const char *const compName)
FwIdType FwOpcodeType
The type of a command opcode.
PlatformSizeType FwSizeType
static const FwChanIdType TLMPACKETIZER_HASH_BUCKETS
static const FwChanIdType MAX_PACKETIZER_PACKETS
PlatformSignedSizeType FwSignedSizeType
static const FwChanIdType TLMPACKETIZER_NUM_TLM_HASH_SLOTS
static const FwChanIdType TLMPACKETIZER_MAX_MISSING_TLM_CHECK
FwIdType FwChanIdType
The type of a telemetry channel identifier.
void setPacketList(const TlmPacketizerPacketList &packetList, const Svc::TlmPacketizerPacket &ignoreList, const FwChanIdType startLevel)
PlatformIndexType FwIndexType
RateGroupDivider component implementation.
Auto-generated base for TlmPacketizer component.