F´ Flight Software - C/C++ Documentation  NASA-v2.1.0
A framework for building embedded system applications to NASA flight quality standards.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 "Svc/TlmPacketizer/TlmPacketizerComponentAc.hpp"
17 #include "Os/Mutex.hpp"
18 
19 namespace Svc {
20 
21  class TlmPacketizer :
22  public TlmPacketizerComponentBase
23  {
24 
25  public:
26 
27  // ----------------------------------------------------------------------
28  // Construction, initialization, and destruction
29  // ----------------------------------------------------------------------
30 
34  const char *const compName
35  );
36 
39  void init(
40  const NATIVE_INT_TYPE queueDepth,
41  const NATIVE_INT_TYPE instance = 0
42  );
43 
44  void setPacketList(
45  const TlmPacketizerPacketList& packetList, // channels to packetize
46  const Svc::TlmPacketizerPacket& ignoreList, // channels to ignore (i.e. no warning event if not packetized)
47  const NATIVE_UINT_TYPE startLevel); // starting level of packets to send
48 
51  ~TlmPacketizer(void);
52 
53  PRIVATE:
54 
55  // ----------------------------------------------------------------------
56  // Handler implementations for user-defined typed input ports
57  // ----------------------------------------------------------------------
58 
61  void TlmRecv_handler(
62  const NATIVE_INT_TYPE portNum,
63  FwChanIdType id,
64  Fw::Time &timeTag,
65  Fw::TlmBuffer &val
66  );
67 
70  void Run_handler(
71  const NATIVE_INT_TYPE portNum,
72  NATIVE_UINT_TYPE context
73  );
74 
77  void pingIn_handler(
78  const NATIVE_INT_TYPE portNum,
79  U32 key
80  );
81 
84  void SET_LEVEL_cmdHandler(
85  const FwOpcodeType opCode,
86  const U32 cmdSeq,
87  U32 level
88  );
89 
92  void SEND_PKT_cmdHandler(
93  const FwOpcodeType opCode,
94  const U32 cmdSeq,
95  U32 id
96  );
97 
98  // number of packets to fill
99  NATIVE_UINT_TYPE m_numPackets;
100  // Array of packet buffers to send
101  // Double-buffered to fill one while sending one
102 
103  struct BufferEntry {
104  Fw::ComBuffer buffer;
105  Fw::Time latestTime;
106  NATIVE_UINT_TYPE id;
107  NATIVE_UINT_TYPE level;
108  bool updated;
109  bool requested;
110  };
111 
112  // buffers for filling with telemetry
113  BufferEntry m_fillBuffers[MAX_PACKETIZER_PACKETS];
114  // buffers for sending - will be copied from fill buffers
115  BufferEntry m_sendBuffers[MAX_PACKETIZER_PACKETS];
116 
117  struct TlmEntry {
118  FwChanIdType id;
119  // Offsets into packet buffers.
120  // -1 means that channel is not in that packet
122  TlmEntry* next;
123  bool used;
124  bool ignored;
125  NATIVE_UINT_TYPE bucketNo;
126  };
127 
128  struct TlmSet {
129  TlmEntry* slots[TLMPACKETIZER_NUM_TLM_HASH_SLOTS];
130  TlmEntry buckets[TLMPACKETIZER_HASH_BUCKETS];
131  NATIVE_UINT_TYPE free;
132  } m_tlmEntries;
133 
134  // hash function for looking up telemetry channel
135  NATIVE_UINT_TYPE doHash(FwChanIdType id);
136 
137  Os::Mutex m_lock;
138 
139  bool m_configured;
140 
141  struct MissingTlmChan {
142  FwChanIdType id;
143  bool checked;
144  } m_missTlmCheck[TLMPACKETIZER_MAX_MISSING_TLM_CHECK];
145 
146  void missingChannel(FwChanIdType id);
147 
148  TlmEntry* findBucket(FwChanIdType id);
149 
150  NATIVE_UINT_TYPE m_startLevel;
151  NATIVE_UINT_TYPE m_maxLevel;
152 
153  };
154 
155 } // end namespace Svc
156 
157 #endif
Svc::TlmPacketizer::TlmPacketizer
TlmPacketizer(const char *const compName)
Definition: TlmPacketizer.cpp:22
Svc::TLMPACKETIZER_MAX_MISSING_TLM_CHECK
static const NATIVE_UINT_TYPE TLMPACKETIZER_MAX_MISSING_TLM_CHECK
Definition: TlmPacketizerComponentImplCfg.hpp:28
Fw::Time
Definition: Time.hpp:10
Svc::MAX_PACKETIZER_PACKETS
static const NATIVE_UINT_TYPE MAX_PACKETIZER_PACKETS
Definition: TlmPacketizerComponentImplCfg.hpp:20
Fw::TlmBuffer
Definition: TlmBuffer.hpp:21
FwChanIdType
#define FwChanIdType
Type representation for a channel id.
Definition: FpConfig.hpp:66
Svc::TLMPACKETIZER_NUM_TLM_HASH_SLOTS
static const NATIVE_UINT_TYPE TLMPACKETIZER_NUM_TLM_HASH_SLOTS
Definition: TlmPacketizerComponentImplCfg.hpp:21
Svc::TlmPacketizerPacket
Definition: TlmPacketizerTypes.hpp:27
Svc::TlmPacketizer
Definition: TlmPacketizer.hpp:21
Os::Mutex
Definition: Mutex.hpp:8
FwOpcodeType
#define FwOpcodeType
Type representation for a command opcode.
Definition: FpConfig.hpp:62
NATIVE_UINT_TYPE
unsigned int NATIVE_UINT_TYPE
native unsigned integer type declaration
Definition: BasicTypes.hpp:30
Svc::TlmPacketizerPacketList
Definition: TlmPacketizerTypes.hpp:34
Svc::TlmPacketizer::setPacketList
void setPacketList(const TlmPacketizerPacketList &packetList, const Svc::TlmPacketizerPacket &ignoreList, const NATIVE_UINT_TYPE startLevel)
Definition: TlmPacketizer.cpp:73
Svc::TlmPacketizer::~TlmPacketizer
~TlmPacketizer(void)
Definition: TlmPacketizer.cpp:68
Svc
Definition: ActiveRateGroupImplCfg.hpp:18
TlmPacketizerTypes.hpp
Svc::TLMPACKETIZER_HASH_BUCKETS
static const NATIVE_UINT_TYPE TLMPACKETIZER_HASH_BUCKETS
Definition: TlmPacketizerComponentImplCfg.hpp:26
Svc::TlmPacketizer::init
void init(const NATIVE_INT_TYPE queueDepth, const NATIVE_INT_TYPE instance=0)
Definition: TlmPacketizer.cpp:59
Mutex.hpp
NATIVE_INT_TYPE
int NATIVE_INT_TYPE
native integer type declaration
Definition: BasicTypes.hpp:29
Fw::ComBuffer
Definition: ComBuffer.hpp:21
TlmPacketizerComponentImplCfg.hpp