20 static_assert(std::numeric_limits<FwChanIdType>::max() >= TLMCHAN_HASH_BUCKETS,
"Cannot have more hash buckets than maximum telemetry ids in the system");
22 static_assert(std::numeric_limits<FwChanIdType>::max() >= TLMCHAN_NUM_TLM_HASH_SLOTS,
"Cannot have more hash slots than maximum telemetry ids in the system");
26 for (
FwChanIdType entry = 0; entry < TLMCHAN_NUM_TLM_HASH_SLOTS; entry++) {
27 this->m_tlmEntries[0].slots[entry] =
nullptr;
28 this->m_tlmEntries[1].slots[entry] =
nullptr;
31 for (
FwChanIdType entry = 0; entry < TLMCHAN_HASH_BUCKETS; entry++) {
32 this->m_tlmEntries[0].buckets[entry].used =
false;
33 this->m_tlmEntries[0].buckets[entry].updated =
false;
34 this->m_tlmEntries[0].buckets[entry].bucketNo = entry;
35 this->m_tlmEntries[0].buckets[entry].next =
nullptr;
36 this->m_tlmEntries[0].buckets[entry].id = 0;
37 this->m_tlmEntries[1].buckets[entry].used =
false;
38 this->m_tlmEntries[1].buckets[entry].updated =
false;
39 this->m_tlmEntries[1].buckets[entry].bucketNo = entry;
40 this->m_tlmEntries[1].buckets[entry].next =
nullptr;
41 this->m_tlmEntries[1].buckets[entry].id = 0;
44 this->m_tlmEntries[0].free = 0;
45 this->m_tlmEntries[1].free = 0;
51 return (
id % TLMCHAN_HASH_MOD_VALUE) % TLMCHAN_NUM_TLM_HASH_SLOTS;
54 void TlmChan::pingIn_handler(
const FwIndexType portNum, U32 key) {
65 TlmEntry* entryToUse = this->m_tlmEntries[this->m_activeBuffer].slots[index];
66 for (
FwChanIdType bucket = 0; bucket < TLMCHAN_HASH_BUCKETS; bucket++) {
68 if (entryToUse->id ==
id) {
71 entryToUse = entryToUse->next;
79 val = entryToUse->buffer;
80 timeTag = entryToUse->lastUpdate;
90 TlmEntry* entryToUse =
nullptr;
91 TlmEntry* prevEntry =
nullptr;
94 if (this->m_tlmEntries[this->m_activeBuffer].slots[index]) {
95 entryToUse = this->m_tlmEntries[this->m_activeBuffer].slots[index];
96 for (
FwChanIdType bucket = 0; bucket < TLMCHAN_HASH_BUCKETS; bucket++) {
98 if (entryToUse->id ==
id) {
101 prevEntry = entryToUse;
102 entryToUse = entryToUse->next;
106 FW_ASSERT(this->m_tlmEntries[this->m_activeBuffer].free < TLMCHAN_HASH_BUCKETS);
109 &this->m_tlmEntries[this->m_activeBuffer].buckets[this->m_tlmEntries[this->m_activeBuffer].free++];
111 prevEntry->next = entryToUse;
113 entryToUse->next =
nullptr;
119 FW_ASSERT(this->m_tlmEntries[this->m_activeBuffer].free < TLMCHAN_HASH_BUCKETS);
121 this->m_tlmEntries[this->m_activeBuffer].slots[index] =
122 &this->m_tlmEntries[this->m_activeBuffer].buckets[this->m_tlmEntries[this->m_activeBuffer].free++];
123 entryToUse = this->m_tlmEntries[this->m_activeBuffer].slots[index];
124 entryToUse->next =
nullptr;
129 entryToUse->used =
true;
131 entryToUse->updated =
true;
132 entryToUse->lastUpdate = timeTag;
133 entryToUse->buffer = val;
136 void TlmChan::Run_handler(
FwIndexType portNum, U32 context) {
145 this->m_activeBuffer = 1 - this->m_activeBuffer;
147 for (U32 entry = 0; entry < TLMCHAN_HASH_BUCKETS; entry++) {
148 this->m_tlmEntries[this->m_activeBuffer].buckets[entry].updated =
false;
156 for (U32 entry = 0; entry < TLMCHAN_HASH_BUCKETS; entry++) {
157 TlmEntry* p_entry = &this->m_tlmEntries[1 - this->m_activeBuffer].buckets[entry];
158 if ((p_entry->updated) && (p_entry->used)) {
167 stat = pkt.
addValue(p_entry->id, p_entry->lastUpdate, p_entry->buffer);
175 FW_ASSERT(0, static_cast<FwAssertArgType>(stat));
178 p_entry->updated =
false;
Serialization/Deserialization operation was successful.
void resetSer()
reset to beginning of buffer to reuse for serialization
TlmChan(const char *compName)
U32 FwChanIdType
The type of a telemetry channel identifier.
No room left in the buffer to serialize data.
void PktSend_out(FwIndexType portNum, Fw::ComBuffer &data, U32 context)
Invoke output port PktSend.
Fw::ComBuffer & getBuffer()
get buffer to send to the ground
Auto-generated base for TlmChan component.
Component that stores telemetry channel values.
FwSizeType getNumEntries()
get the number of packets added via addValue()
SerializeStatus
forward declaration for string
SerializeStatus addValue(FwChanIdType id, Time &timeTag, TlmBuffer &buffer)
Add telemetry value to buffer.
virtual void lock()
Lock the guarded mutex.
bool isConnected_PktSend_OutputPort(FwIndexType portNum)
void pingOut_out(FwIndexType portNum, U32 key)
Invoke output port pingOut.
SerializeStatus resetPktSer()
Reset serialization of values. This should be done when starting to accumulate a new set of values...
virtual FwChanIdType doHash(FwChanIdType id)
PlatformIndexType FwIndexType
virtual void unLock()
Unlock the guarded mutex.
RateGroupDivider component implementation.