added void* args to queue factory and mq ctor

This commit is contained in:
Robin Müller 2022-02-18 14:00:06 +01:00
parent a12e98d948
commit a5871ed0b1
14 changed files with 28 additions and 23 deletions

View File

@ -52,9 +52,9 @@ void EventManager::notifyListeners(EventMessage* message) {
MessageQueueSenderIF::sendMessage(listener.first, message, message->getSender());
if (result != HasReturnvaluesIF::RETURN_OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << std::hex << "EventManager::notifyListeners: MSG to " << std::setw(8)
<< std::setfill('0') << "0x" << listener.first << " failed with result "
<< std::setw(4) << "0x" << result << std::setfill(' ') << std::endl;
sif::error << std::hex << "EventManager::notifyListeners: MSG to 0x" << std::setfill('0')
<< std::setw(8) << listener.first << " failed with result 0x"
<< std::setw(4) << result << std::setfill(' ') << std::endl;
#else
sif::printError("Sending message to listener 0x%08x failed with result %04x\n",
listener.first, result);
@ -202,11 +202,11 @@ void EventManager::printUtility(sif::OutputTypes printType, EventMessage* messag
void EventManager::printListeners() {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "Event manager listener MQ IDs:" << std::endl;
sif::info << "Event manager listener MQ IDs:" << std::setfill('0') << std::hex << std::endl;
for (auto& listener : listenerList) {
sif::info << std::hex << std::setw(8) << std::setfill('0') << "0x" << listener.first << std::dec
<< std::setfill(' ') << std::endl;
sif::info << "0x" << std::setw(8) << listener.first << std::endl;
}
sif::info << std::dec << std::setfill(' ');
#else
sif::printInfo("Event manager listener MQ IDs:\n");
for (auto& listener : listenerList) {

View File

@ -22,7 +22,8 @@ class QueueFactory {
static QueueFactory* instance();
MessageQueueIF* createMessageQueue(uint32_t messageDepth = 3,
size_t maxMessageSize = MessageQueueMessage::MAX_MESSAGE_SIZE);
size_t maxMessageSize = MessageQueueMessage::MAX_MESSAGE_SIZE,
void* args = nullptr);
void deleteMessageQueue(MessageQueueIF* queue);

View File

@ -4,7 +4,7 @@
#include "fsfw/osal/freertos/QueueMapManager.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize)
MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize, void* args)
: maxMessageSize(maxMessageSize) {
handle = xQueueCreate(messageDepth, maxMessageSize);
if (handle == nullptr) {

View File

@ -53,7 +53,8 @@ class MessageQueue : public MessageQueueIF {
* This should be left default.
*/
MessageQueue(size_t messageDepth = 3,
size_t maxMessageSize = MessageQueueMessage::MAX_MESSAGE_SIZE);
size_t maxMessageSize = MessageQueueMessage::MAX_MESSAGE_SIZE,
void* args = nullptr);
/** Copying message queues forbidden */
MessageQueue(const MessageQueue&) = delete;

View File

@ -22,8 +22,8 @@ QueueFactory::QueueFactory() {}
QueueFactory::~QueueFactory() {}
MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth, size_t maxMessageSize) {
return new MessageQueue(messageDepth, maxMessageSize);
MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth, size_t maxMessageSize, void* args) {
return new MessageQueue(messageDepth, maxMessageSize, args);
}
void QueueFactory::deleteMessageQueue(MessageQueueIF* queue) { delete queue; }

View File

@ -8,7 +8,7 @@
#include "fsfw/osal/host/QueueMapManager.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize)
MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize, void* args)
: messageSize(maxMessageSize), messageDepth(messageDepth) {
queueLock = MutexFactory::instance()->createMutex();
auto result = QueueMapManager::instance()->addMessageQueue(this, &mqId);

View File

@ -54,7 +54,8 @@ class MessageQueue : public MessageQueueIF {
* This should be left default.
*/
MessageQueue(size_t messageDepth = 3,
size_t maxMessageSize = MessageQueueMessage::MAX_MESSAGE_SIZE);
size_t maxMessageSize = MessageQueueMessage::MAX_MESSAGE_SIZE,
void* args);
/** Copying message queues forbidden */
MessageQueue(const MessageQueue&) = delete;

View File

@ -27,12 +27,12 @@ QueueFactory::QueueFactory() {}
QueueFactory::~QueueFactory() {}
MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth, size_t maxMessageSize) {
MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth, size_t maxMessageSize, void* args) {
// A thread-safe queue can be implemented by using a combination
// of std::queue and std::mutex. This uses dynamic memory allocation
// which could be alleviated by using a custom allocator, external library
// (etl::queue) or simply using std::queue, we're on a host machine anyway.
return new MessageQueue(messageDepth, maxMessageSize);
return new MessageQueue(messageDepth, maxMessageSize, args);
}
void QueueFactory::deleteMessageQueue(MessageQueueIF* queue) { delete queue; }

View File

@ -11,7 +11,7 @@
#include "fsfw/osal/linux/unixUtility.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
MessageQueue::MessageQueue(uint32_t messageDepth, size_t maxMessageSize)
MessageQueue::MessageQueue(uint32_t messageDepth, size_t maxMessageSize, void* args)
: id(MessageQueueIF::NO_QUEUE),
lastPartner(MessageQueueIF::NO_QUEUE),
defaultDestination(MessageQueueIF::NO_QUEUE),

View File

@ -42,7 +42,8 @@ class MessageQueue : public MessageQueueIF {
* This should be left default.
*/
MessageQueue(uint32_t messageDepth = 3,
size_t maxMessageSize = MessageQueueMessage::MAX_MESSAGE_SIZE);
size_t maxMessageSize = MessageQueueMessage::MAX_MESSAGE_SIZE,
void* args = nullptr);
/**
* @brief The destructor deletes the formerly created message queue.
* @details This is accomplished by using the delete call provided by the operating system.

View File

@ -28,8 +28,8 @@ QueueFactory::QueueFactory() {}
QueueFactory::~QueueFactory() {}
MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth, size_t maxMessageSize) {
return new MessageQueue(messageDepth, maxMessageSize);
MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth, size_t maxMessageSize, void* args) {
return new MessageQueue(messageDepth, maxMessageSize, args);
}
void QueueFactory::deleteMessageQueue(MessageQueueIF* queue) { delete queue; }

View File

@ -6,7 +6,7 @@
#include "fsfw/osal/rtems/RtemsBasic.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
MessageQueue::MessageQueue(size_t message_depth, size_t max_message_size)
MessageQueue::MessageQueue(size_t message_depth, size_t max_message_size, void* args)
: id(0), lastPartner(0), defaultDestination(NO_QUEUE), internalErrorReporter(nullptr) {
rtems_name name = ('Q' << 24) + (queueCounter++ << 8);
rtems_status_code status =

View File

@ -34,7 +34,8 @@ class MessageQueue : public MessageQueueIF {
* This should be left default.
*/
MessageQueue(size_t message_depth = 3,
size_t max_message_size = MessageQueueMessage::MAX_MESSAGE_SIZE);
size_t max_message_size = MessageQueueMessage::MAX_MESSAGE_SIZE,
void* args);
/**
* @brief The destructor deletes the formerly created message queue.
* @details This is accomplished by using the delete call provided by the operating system.

View File

@ -49,8 +49,8 @@ QueueFactory::QueueFactory() {}
QueueFactory::~QueueFactory() {}
MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth, size_t maxMessageSize) {
return new MessageQueue(messageDepth, maxMessageSize);
MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth, size_t maxMessageSize, void* args) {
return new MessageQueue(messageDepth, maxMessageSize, args);
}
void QueueFactory::deleteMessageQueue(MessageQueueIF* queue) { delete queue; }