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  FW_ASSERT(buffer != nullptr);
26  PlatformIntType status = snprintf(buffer, static_cast<size_t>(size), "QueueComp: %s", this->m_objName.toChar());
27  if (status < 0) {
28  buffer[0] = 0;
29  }
30  }
31 #endif
32 
34 
35  Os::QueueString queueName;
36 #if FW_OBJECT_NAMES == 1
37  queueName = this->m_objName;
38 #else
39  char queueNameChar[FW_QUEUE_NAME_BUFFER_SIZE];
40  (void)snprintf(queueNameChar,sizeof(queueNameChar),"CompQ_%d",Os::Queue::getNumQueues());
41  queueName = queueNameChar;
42 #endif
43  return this->m_queue.create(queueName, depth, msgSize);
44  }
45 
47  return this->m_msgsDropped;
48  }
49 
51  this->m_msgsDropped++;
52  }
53 
54 }
#define FW_ASSERT(...)
Definition: Assert.hpp:14
PlatformIntType NATIVE_INT_TYPE
Definition: BasicTypes.h:55
int PlatformIntType
DefaultTypes.hpp provides fallback defaults for the platform types.
PlatformSizeType FwSizeType
Definition: FpConfig.h:35
#define FW_QUEUE_NAME_BUFFER_SIZE
Max size of message queue name.
Definition: FpConfig.h:272
C++-compatible configuration header for fprime configuration.
void init()
Object initializer.
Definition: ObjBase.cpp:27
QueuedComponentBase(const char *name)
Constructor.
Os::Queue::Status createQueue(FwSizeType depth, FwSizeType 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.
Status create(const Fw::StringBase &name, FwSizeType depth, FwSizeType messageSize) override
create queue storage through delegate
Definition: Queue.cpp:20
static FwSizeType getNumQueues()
get number of queues system-wide
Definition: Queue.cpp:127
Status
Generic OK/ERROR status.
Definition: Os.hpp:25