yaaay, hardcoded values

This commit is contained in:
Robin Müller 2020-06-07 01:17:24 +02:00
parent c81613690b
commit 33cc8591dc
8 changed files with 61 additions and 42 deletions

View File

@ -1,9 +1,8 @@
#include <framework/health/HealthHelper.h> #include <framework/health/HealthHelper.h>
#include <framework/ipc/MessageQueueSenderIF.h>
#include <framework/serviceinterface/ServiceInterfaceStream.h> #include <framework/serviceinterface/ServiceInterfaceStream.h>
HealthHelper::HealthHelper(HasHealthIF* owner, object_id_t objectId) : HealthHelper::HealthHelper(HasHealthIF* owner, object_id_t objectId) :
healthTable(NULL), eventSender(NULL), objectId(objectId), parentQueue( objectId(objectId), owner(owner) {
0), owner(owner) {
} }
HealthHelper::~HealthHelper() { HealthHelper::~HealthHelper() {

View File

@ -1,11 +1,12 @@
#ifndef HEALTHHELPER_H_ #ifndef FRAMEWORK_HEALTH_HEALTHHELPER_H_
#define HEALTHHELPER_H_ #define FRAMEWORK_HEALTH_HEALTHHELPER_H_
#include <framework/events/EventManagerIF.h> #include <framework/events/EventManagerIF.h>
#include <framework/events/EventReportingProxyIF.h> #include <framework/events/EventReportingProxyIF.h>
#include <framework/health/HasHealthIF.h> #include <framework/health/HasHealthIF.h>
#include <framework/health/HealthMessage.h> #include <framework/health/HealthMessage.h>
#include <framework/health/HealthTableIF.h> #include <framework/health/HealthTableIF.h>
#include <framework/ipc/MessageQueueIF.h>
#include <framework/objectmanager/ObjectManagerIF.h> #include <framework/objectmanager/ObjectManagerIF.h>
#include <framework/returnvalues/HasReturnvaluesIF.h> #include <framework/returnvalues/HasReturnvaluesIF.h>
@ -39,12 +40,12 @@ public:
* *
* only valid after initialize() has been called * only valid after initialize() has been called
*/ */
HealthTableIF *healthTable; HealthTableIF *healthTable = nullptr;
/** /**
* Proxy to forward events. * Proxy to forward events.
*/ */
EventReportingProxyIF* eventSender; EventReportingProxyIF* eventSender = nullptr;
/** /**
* Try to handle the message. * Try to handle the message.
@ -100,7 +101,7 @@ private:
/** /**
* The Queue of the parent * The Queue of the parent
*/ */
MessageQueueId_t parentQueue; MessageQueueId_t parentQueue = MessageQueueIF::NO_QUEUE;
/** /**
* The one using the healthHelper. * The one using the healthHelper.

View File

@ -5,10 +5,10 @@
#include <framework/serialize/EndianSwapper.h> #include <framework/serialize/EndianSwapper.h>
#include <framework/serviceinterface/ServiceInterfaceStream.h> #include <framework/serviceinterface/ServiceInterfaceStream.h>
MemoryHelper::MemoryHelper(HasMemoryIF* workOnThis, MessageQueueIF* useThisQueue) : MemoryHelper::MemoryHelper(HasMemoryIF* workOnThis,
workOnThis(workOnThis), queueToUse(useThisQueue), ipcStore(NULL), ipcAddress(), lastCommand( MessageQueueIF* useThisQueue):
CommandMessage::CMD_NONE), lastSender(0), reservedSpaceInIPC( workOnThis(workOnThis), queueToUse(useThisQueue), ipcStore(nullptr),
NULL), busy(false) { ipcAddress(), lastCommand(CommandMessage::CMD_NONE), busy(false) {
} }
ReturnValue_t MemoryHelper::handleMemoryCommand(CommandMessage* message) { ReturnValue_t MemoryHelper::handleMemoryCommand(CommandMessage* message) {

View File

@ -1,5 +1,5 @@
#ifndef MEMORYHELPER_H_ #ifndef FRAMEWORK_MEMORY_MEMORYHELPER_H_
#define MEMORYHELPER_H_ #define FRAMEWORK_MEMORY_MEMORYHELPER_H_
#include <framework/ipc/CommandMessage.h> #include <framework/ipc/CommandMessage.h>
#include <framework/memory/AcceptsMemoryMessagesIF.h> #include <framework/memory/AcceptsMemoryMessagesIF.h>
#include <framework/returnvalues/HasReturnvaluesIF.h> #include <framework/returnvalues/HasReturnvaluesIF.h>
@ -16,11 +16,11 @@ public:
private: private:
HasMemoryIF* workOnThis; HasMemoryIF* workOnThis;
MessageQueueIF* queueToUse; MessageQueueIF* queueToUse;
StorageManagerIF* ipcStore; StorageManagerIF* ipcStore = nullptr;
store_address_t ipcAddress; store_address_t ipcAddress;
Command_t lastCommand; Command_t lastCommand;
MessageQueueId_t lastSender; MessageQueueId_t lastSender = MessageQueueIF::NO_QUEUE;
uint8_t* reservedSpaceInIPC; uint8_t* reservedSpaceInIPC = nullptr;
bool busy; bool busy;
void handleMemoryLoad(CommandMessage* message); void handleMemoryLoad(CommandMessage* message);
void handleMemoryCheckOrDump(CommandMessage* message); void handleMemoryCheckOrDump(CommandMessage* message);

View File

@ -1,13 +1,11 @@
#include <framework/modes/HasModesIF.h> #include <framework/modes/HasModesIF.h>
#include <framework/modes/ModeHelper.h> #include <framework/modes/ModeHelper.h>
#include <framework/ipc/MessageQueueSenderIF.h>
#include <framework/serviceinterface/ServiceInterfaceStream.h> #include <framework/serviceinterface/ServiceInterfaceStream.h>
ModeHelper::ModeHelper(HasModesIF *owner) : ModeHelper::ModeHelper(HasModesIF *owner) :
theOneWhoCommandedAMode(0), commandedMode(HasModesIF::MODE_OFF), commandedSubmode( commandedMode(HasModesIF::MODE_OFF),
HasModesIF::SUBMODE_NONE), owner(owner), parentQueueId(0), forced( commandedSubmode(HasModesIF::SUBMODE_NONE),
false) { owner(owner), forced(false) {}
}
ModeHelper::~ModeHelper() { ModeHelper::~ModeHelper() {
@ -71,27 +69,45 @@ ReturnValue_t ModeHelper::initialize(MessageQueueId_t parentQueueId) {
return initialize(); return initialize();
} }
void ModeHelper::modeChanged(Mode_t mode, Submode_t submode) { void ModeHelper::modeChanged(Mode_t ownerMode, Submode_t ownerSubmode) {
forced = false; forced = false;
sendModeReplyMessage(ownerMode, ownerSubmode);
sendModeInfoMessage(ownerMode, ownerSubmode);
theOneWhoCommandedAMode = MessageQueueSenderIF::NO_QUEUE;
}
void ModeHelper::sendModeReplyMessage(Mode_t ownerMode,
Submode_t ownerSubmode) {
CommandMessage reply; CommandMessage reply;
if (theOneWhoCommandedAMode != MessageQueueSenderIF::NO_QUEUE) { if (theOneWhoCommandedAMode != MessageQueueSenderIF::NO_QUEUE)
if ((mode != commandedMode) || (submode != commandedSubmode)) { {
if (ownerMode != commandedMode or ownerSubmode != commandedSubmode)
{
ModeMessage::setModeMessage(&reply, ModeMessage::setModeMessage(&reply,
ModeMessage::REPLY_WRONG_MODE_REPLY, mode, submode); ModeMessage::REPLY_WRONG_MODE_REPLY, ownerMode,
} else { ownerSubmode);
}
else
{
ModeMessage::setModeMessage(&reply, ModeMessage::REPLY_MODE_REPLY, ModeMessage::setModeMessage(&reply, ModeMessage::REPLY_MODE_REPLY,
mode, submode); ownerMode, ownerSubmode);
} }
MessageQueueSenderIF::sendMessage(theOneWhoCommandedAMode, &reply, MessageQueueSenderIF::sendMessage(theOneWhoCommandedAMode, &reply,
owner->getCommandQueue()); owner->getCommandQueue());
} }
}
void ModeHelper::sendModeInfoMessage(Mode_t ownerMode,
Submode_t ownerSubmode) {
CommandMessage reply;
if (theOneWhoCommandedAMode != parentQueueId if (theOneWhoCommandedAMode != parentQueueId
&& parentQueueId != MessageQueueSenderIF::NO_QUEUE) { and parentQueueId != MessageQueueSenderIF::NO_QUEUE)
ModeMessage::setModeMessage(&reply, ModeMessage::REPLY_MODE_INFO, mode, {
submode); ModeMessage::setModeMessage(&reply, ModeMessage::REPLY_MODE_INFO,
MessageQueueSenderIF::sendMessage(parentQueueId, &reply, owner->getCommandQueue()); ownerMode, ownerSubmode);
MessageQueueSenderIF::sendMessage(parentQueueId, &reply,
owner->getCommandQueue());
} }
theOneWhoCommandedAMode = MessageQueueSenderIF::NO_QUEUE;
} }
void ModeHelper::startTimer(uint32_t timeoutMs) { void ModeHelper::startTimer(uint32_t timeoutMs) {

View File

@ -1,6 +1,7 @@
#ifndef MODEHELPER_H_ #ifndef MODEHELPER_H_
#define MODEHELPER_H_ #define MODEHELPER_H_
#include <framework/ipc/MessageQueueIF.h>
#include <framework/modes/ModeMessage.h> #include <framework/modes/ModeMessage.h>
#include <framework/returnvalues/HasReturnvaluesIF.h> #include <framework/returnvalues/HasReturnvaluesIF.h>
#include <framework/timemanager/Countdown.h> #include <framework/timemanager/Countdown.h>
@ -9,7 +10,7 @@ class HasModesIF;
class ModeHelper { class ModeHelper {
public: public:
MessageQueueId_t theOneWhoCommandedAMode; MessageQueueId_t theOneWhoCommandedAMode = MessageQueueIF::NO_QUEUE;
Mode_t commandedMode; Mode_t commandedMode;
Submode_t commandedSubmode; Submode_t commandedSubmode;
@ -39,11 +40,14 @@ public:
void setForced(bool forced); void setForced(bool forced);
protected: protected:
HasModesIF *owner; HasModesIF *owner;
MessageQueueId_t parentQueueId; MessageQueueId_t parentQueueId = MessageQueueIF::NO_QUEUE;
Countdown countdown; Countdown countdown;
bool forced; bool forced;
private:
void sendModeReplyMessage(Mode_t ownerMode, Submode_t ownerSubmode);
void sendModeInfoMessage(Mode_t ownerMode, Submode_t ownerSubmode);
}; };
#endif /* MODEHELPER_H_ */ #endif /* MODEHELPER_H_ */

View File

@ -3,9 +3,7 @@
#include <framework/parameters/ParameterMessage.h> #include <framework/parameters/ParameterMessage.h>
ParameterHelper::ParameterHelper(ReceivesParameterMessagesIF* owner) : ParameterHelper::ParameterHelper(ReceivesParameterMessagesIF* owner) :
owner(owner), ownerQueueId(0), storage(NULL){ owner(owner) {}
}
ParameterHelper::~ParameterHelper() { ParameterHelper::~ParameterHelper() {
} }

View File

@ -1,6 +1,7 @@
#ifndef PARAMETERHELPER_H_ #ifndef FRAMEWORK_PARAMETERS_PARAMETERHELPER_H_
#define PARAMETERHELPER_H_ #define FRAMEWORK_PARAMETERS_PARAMETERHELPER_H_
#include <framework/ipc/MessageQueueIF.h>
#include <framework/parameters/ParameterMessage.h> #include <framework/parameters/ParameterMessage.h>
#include <framework/parameters/ReceivesParameterMessagesIF.h> #include <framework/parameters/ReceivesParameterMessagesIF.h>
@ -15,9 +16,9 @@ public:
private: private:
ReceivesParameterMessagesIF *owner; ReceivesParameterMessagesIF *owner;
MessageQueueId_t ownerQueueId; MessageQueueId_t ownerQueueId = MessageQueueIF::NO_QUEUE;
StorageManagerIF *storage; StorageManagerIF *storage = nullptr;
ReturnValue_t sendParameter(MessageQueueId_t to, uint32_t id, const ParameterWrapper *description); ReturnValue_t sendParameter(MessageQueueId_t to, uint32_t id, const ParameterWrapper *description);