F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
QueuedComponentBase.cpp
Go to the documentation of this file.
3 #include <Fw/Types/Assert.hpp>
4 #include <Os/QueueString.hpp>
5 
6 #include <cstdio>
7 
8 namespace Fw {
9 
10 QueuedComponentBase::QueuedComponentBase(const char* name) : PassiveComponentBase(name), m_msgsDropped(0) {}
11 
13 
16 }
17 
19  this->m_queue.teardown();
20 }
21 
22 #if FW_OBJECT_TO_STRING == 1
23 const char* QueuedComponentBase::getToStringFormatString() {
24  return "QueueComp: %s";
25 }
26 #endif
27 
29  Os::QueueString queueName;
30 #if FW_OBJECT_NAMES == 1
31  queueName = this->m_objName;
32 #else
33  // Truncation of a queue name is benign
34  (void)queueName.format("CompQ_%" PRI_FwSizeType, Os::Queue::getNumQueues());
35 #endif
36  return this->m_queue.create(this->getInstance(), queueName, depth, msgSize);
37 }
38 
40  return this->m_msgsDropped;
41 }
42 
44  this->m_msgsDropped++;
45 }
46 
49  const FwSizeType num_messages = this->m_queue.getMessagesAvailable();
50  for (FwSizeType i = 0; i < num_messages; i++) {
51  status = this->doDispatch();
52  if (status != MSG_DISPATCH_OK) {
53  break;
54  }
55  }
56  return status;
57 }
58 } // namespace Fw
MsgDispatchStatus dispatchAvailableMessages()
dispatches all messages currently in the queue, returning status of the dispatch
virtual ~QueuedComponentBase()
Destructor.
Status create(FwEnumStoreType id, const Fw::ConstStringBase &name, FwSizeType depth, FwSizeType messageSize) override
create queue storage through delegate
Definition: Queue.cpp:22
PlatformSizeType FwSizeType
I32 FwEnumStoreType
QueuedComponentBase(const char *name)
Constructor.
#define PRI_FwSizeType
static FwSizeType getNumQueues()
get number of queues system-wide
Definition: Queue.cpp:139
FwEnumStoreType getInstance() const
virtual MsgDispatchStatus doDispatch()=0
method to dispatch a single message in the queue.
Os::Queue m_queue
queue object for active component
void init()
Object initializer.
Definition: ObjBase.cpp:24
FwSizeType getNumMsgsDropped()
return number of messages dropped
Os::Queue::Status createQueue(FwSizeType depth, FwSizeType msgSize)
void deinit() override
Allows de-initialization on teardown.
void teardown() override
teardown the queue
Definition: Queue.cpp:49
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:58
FwSizeType getMessagesAvailable() const override
get number of messages available
Definition: Queue.cpp:89
void incNumMsgDropped()
increment the number of messages dropped
Implementation of malloc based allocator.