F´ Flight Software - C/C++ Documentation  devel
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 "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 NATIVE_UINT_TYPE 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 NATIVE_INT_TYPE portNum,
49  FwChanIdType id,
50  Fw::Time& timeTag,
51  Fw::TlmBuffer& val
52  );
53 
56  void Run_handler(const NATIVE_INT_TYPE portNum,
57  U32 context
58  );
59 
62  void pingIn_handler(const NATIVE_INT_TYPE portNum,
63  U32 key
64  );
65 
68  void SET_LEVEL_cmdHandler(const FwOpcodeType opCode,
69  const U32 cmdSeq,
70  U32 level
71  );
72 
75  void SEND_PKT_cmdHandler(const FwOpcodeType opCode,
76  const U32 cmdSeq,
77  U32 id
78  );
79 
80  // number of packets to fill
81  NATIVE_UINT_TYPE m_numPackets;
82  // Array of packet buffers to send
83  // Double-buffered to fill one while sending one
84 
85  struct BufferEntry {
86  Fw::ComBuffer buffer;
87  Fw::Time latestTime;
88  NATIVE_UINT_TYPE id;
89  NATIVE_UINT_TYPE level;
90  bool updated;
91  bool requested;
92  };
93 
94  // buffers for filling with telemetry
95  BufferEntry m_fillBuffers[MAX_PACKETIZER_PACKETS];
96  // buffers for sending - will be copied from fill buffers
97  BufferEntry m_sendBuffers[MAX_PACKETIZER_PACKETS];
98 
99  struct TlmEntry {
100  FwChanIdType id;
101  // Offsets into packet buffers.
102  // -1 means that channel is not in that packet
104  TlmEntry* next;
105  bool used;
106  bool ignored;
107  NATIVE_UINT_TYPE bucketNo;
108  };
109 
110  struct TlmSet {
111  TlmEntry* slots[TLMPACKETIZER_NUM_TLM_HASH_SLOTS];
112  TlmEntry buckets[TLMPACKETIZER_HASH_BUCKETS];
113  NATIVE_UINT_TYPE free;
114  } m_tlmEntries;
115 
116  // hash function for looking up telemetry channel
117  NATIVE_UINT_TYPE doHash(FwChanIdType id);
118 
119  Os::Mutex m_lock;
120 
121  bool m_configured;
122 
123  struct MissingTlmChan {
124  FwChanIdType id;
125  bool checked;
126  } m_missTlmCheck[TLMPACKETIZER_MAX_MISSING_TLM_CHECK];
127 
128  void missingChannel(FwChanIdType id);
129 
130  TlmEntry* findBucket(FwChanIdType id);
131 
132  NATIVE_UINT_TYPE m_startLevel;
133  NATIVE_UINT_TYPE m_maxLevel;
134 };
135 
136 } // end namespace Svc
137 
138 #endif
PlatformIntType NATIVE_INT_TYPE
Definition: BasicTypes.h:55
PlatformUIntType NATIVE_UINT_TYPE
Definition: BasicTypes.h:56
U32 FwChanIdType
Definition: FpConfig.h:95
U32 FwOpcodeType
Definition: FpConfig.h:91
Definition: Time.hpp:9
Auto-generated base for TlmPacketizer component.
TlmPacketizer(const char *const compName)
void setPacketList(const TlmPacketizerPacketList &packetList, const Svc::TlmPacketizerPacket &ignoreList, const NATIVE_UINT_TYPE startLevel)
static const NATIVE_UINT_TYPE TLMPACKETIZER_MAX_MISSING_TLM_CHECK
static const NATIVE_UINT_TYPE TLMPACKETIZER_HASH_BUCKETS
static const NATIVE_UINT_TYPE MAX_PACKETIZER_PACKETS
static const NATIVE_UINT_TYPE TLMPACKETIZER_NUM_TLM_HASH_SLOTS