23 const char *
const compName
25 TlmPacketizerComponentBase(compName)
33 this->m_tlmEntries.slots[entry] = 0;
37 this->m_tlmEntries.buckets[entry].used =
false;
38 this->m_tlmEntries.buckets[entry].bucketNo = entry;
39 this->m_tlmEntries.buckets[entry].next = 0;
40 this->m_tlmEntries.buckets[entry].id = 0;
43 this->m_tlmEntries.free = 0;
46 this->m_missTlmCheck[entry].checked =
false;
47 this->m_missTlmCheck[entry].id = 0;
52 this->m_fillBuffers[buffer].updated =
false;
53 this->m_fillBuffers[buffer].requested =
false;
54 this->m_sendBuffers[buffer].updated =
false;
64 TlmPacketizerComponentBase::init(queueDepth, instance);
91 TlmEntry *entryToUse = this->findBucket(
id);
94 entryToUse->used =
true;
96 entryToUse->ignored =
false;
99 entryToUse->packetOffset[pktEntry] = packetLen;
101 packetLen += packetList.
list[pktEntry]->
list[tlmEntry].
size;
106 memset(this->m_fillBuffers[pktEntry].buffer.getBuffAddr(),0,packetLen);
110 stat = this->m_fillBuffers[pktEntry].buffer.serialize(packetList.
list[pktEntry]->
id);
113 stat = this->m_fillBuffers[pktEntry].buffer.setBuffLen(packetLen);
116 this->m_fillBuffers[pktEntry].id = packetList.
list[pktEntry]->
id;
118 this->m_fillBuffers[pktEntry].level = packetList.
list[pktEntry]->
level;
120 if (packetList.
list[pktEntry]->
level > this->m_maxLevel) {
121 this->m_maxLevel = packetList.
list[pktEntry]->
level;
124 this->m_startLevel = startLevel;
133 TlmEntry *entryToUse = this->findBucket(
id);
137 entryToUse->used =
true;
139 entryToUse->ignored =
true;
147 this->m_configured =
true;
150 TlmPacketizer::TlmEntry* TlmPacketizer::findBucket(
FwChanIdType id) {
153 TlmEntry* entryToUse = 0;
154 TlmEntry* prevEntry = 0;
157 if (this->m_tlmEntries.slots[index]) {
158 entryToUse = this->m_tlmEntries.slots[index];
161 if (entryToUse->id ==
id) {
164 prevEntry = entryToUse;
165 entryToUse = entryToUse->next;
171 entryToUse = &this->m_tlmEntries.buckets[this->m_tlmEntries.free++];
174 prevEntry->next = entryToUse;
176 entryToUse->next = 0;
179 entryToUse->packetOffset[pktOffsetEntry] = -1;
188 this->m_tlmEntries.slots[index] = &this->m_tlmEntries.buckets[this->m_tlmEntries.free++];
189 entryToUse = this->m_tlmEntries.slots[index];
190 entryToUse->next = 0;
193 entryToUse->packetOffset[pktOffsetEntry] = -1;
207 void TlmPacketizer ::
218 TlmEntry* entryToUse = 0;
221 entryToUse = this->m_tlmEntries.slots[index];
224 if (not entryToUse) {
225 this->missingChannel(
id);
231 if (entryToUse->id ==
id) {
233 if (entryToUse->ignored) {
238 entryToUse = entryToUse->next;
242 this->missingChannel(
id);
250 if (entryToUse->packetOffset[pkt] != -1) {
254 this->m_fillBuffers[pkt].updated =
true;
255 this->m_fillBuffers[pkt].latestTime = timeTag;
256 U8* ptr = &this->m_fillBuffers[pkt].buffer.getBuffAddr()[entryToUse->packetOffset[pkt]];
264 void TlmPacketizer ::
273 if (not this->isConnected_PktSend_OutputPort(0)) {
282 if ((this->m_fillBuffers[pkt].updated) and
283 ((this->m_fillBuffers[pkt].level <= this->m_startLevel) or
284 (this->m_fillBuffers[pkt].requested))) {
286 this->m_sendBuffers[pkt] = this->m_fillBuffers[pkt];
288 this->m_fillBuffers[pkt].updated =
false;
290 this->m_fillBuffers[pkt].requested =
false;
293 this->m_sendBuffers[pkt] = this->m_fillBuffers[pkt];
294 this->m_sendBuffers[pkt].updated =
true;
296 this->m_sendBuffers[pkt].updated =
false;
303 if (this->m_sendBuffers[pkt].updated) {
309 this->PktSend_out(0,this->m_sendBuffers[pkt].buffer,0);
314 void TlmPacketizer ::
321 this->pingOut_out(0,key);
328 void TlmPacketizer ::
329 SET_LEVEL_cmdHandler(
335 this->m_startLevel = level;
336 if (level > this->m_maxLevel) {
337 this->log_WARNING_LO_MaxLevelExceed(level,this->m_maxLevel);
339 this->tlmWrite_SendLevel(level);
340 this->log_ACTIVITY_HI_LevelSet(level);
341 this->cmdResponse_out(opCode, cmdSeq, Fw::COMMAND_OK);
344 void TlmPacketizer ::
352 for (pkt = 0; pkt < this->m_numPackets; pkt++) {
353 if (this->m_fillBuffers[pkt].
id ==
id) {
356 this->m_fillBuffers[pkt].updated =
true;
357 this->m_fillBuffers[pkt].latestTime = this->getTime();
358 this->m_fillBuffers[pkt].requested =
true;
361 this->log_ACTIVITY_LO_PacketSent(
id);
367 if (pkt == this->m_numPackets) {
368 log_WARNING_LO_PacketNotFound(
id);
369 this->cmdResponse_out(opCode, cmdSeq, Fw::COMMAND_VALIDATION_ERROR);
373 this->cmdResponse_out(opCode, cmdSeq, Fw::COMMAND_OK);
385 if (this->m_missTlmCheck[slot].checked and (this->m_missTlmCheck[slot].
id ==
id)) {
387 }
else if (not this->m_missTlmCheck[slot].checked) {
388 this->m_missTlmCheck[slot].checked =
true;
389 this->m_missTlmCheck[slot].id = id;
390 this->log_WARNING_LO_NoChan(
id);