F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
QueuedComponentBase.cpp
Go to the documentation of this file.
2 #include <Fw/Types/Assert.hpp>
3 #include <FpConfig.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 
12  }
13 
15 
16  }
17 
20  }
21 
22 #if FW_OBJECT_TO_STRING == 1 && FW_OBJECT_NAMES == 1
23  void QueuedComponentBase::toString(char* buffer, NATIVE_INT_TYPE size) {
24  FW_ASSERT(size > 0);
25  if (snprintf(buffer, size,"QueueComp: %s", this->m_objName) < 0) {
26  buffer[0] = 0;
27  }
28  }
29 #endif
30 
32 
33  Os::QueueString queueName;
34 #if FW_OBJECT_NAMES == 1
35  queueName = this->m_objName;
36 #else
37  char queueNameChar[FW_QUEUE_NAME_MAX_SIZE];
38  (void)snprintf(queueNameChar,sizeof(queueNameChar),"CompQ_%d",Os::Queue::getNumQueues());
39  queueName = queueNameChar;
40 #endif
41  return this->m_queue.create(queueName, depth, msgSize);
42  }
43 
45  return this->m_msgsDropped;
46  }
47 
49  this->m_msgsDropped++;
50  }
51 
52 }
#define FW_ASSERT(...)
Definition: Assert.hpp:14
PlatformIntType NATIVE_INT_TYPE
Definition: BasicTypes.h:51
#define FW_QUEUE_NAME_MAX_SIZE
Max size of message queue name.
Definition: FpConfig.h:218
C++-compatible configuration header for fprime configuration.
void init()
Object initializer.
Definition: ObjBase.cpp:27
QueuedComponentBase(const char *name)
Constructor.
Os::Queue::QueueStatus createQueue(NATIVE_INT_TYPE depth, NATIVE_INT_TYPE msgSize)
Os::Queue m_queue
queue object for active component
void incNumMsgDropped()
increment the number of messages dropped
NATIVE_INT_TYPE getNumMsgsDropped()
return number of messages dropped
virtual ~QueuedComponentBase()
Destructor.
QueueStatus create(const Fw::StringBase &name, NATIVE_INT_TYPE depth, NATIVE_INT_TYPE msgSize)
create a message queue
Definition: QueueCommon.cpp:41
QueueStatus
Definition: Queue.hpp:27
static NATIVE_INT_TYPE getNumQueues()
get the number of queues in the system
Definition: QueueCommon.cpp:57