Merge remote-tracking branch 'sidestream/mohr_introspection' into mohr/introspection

This commit is contained in:
Ulrich Mohr 2022-08-24 17:49:29 +02:00
commit d634bdb775
8 changed files with 37 additions and 6 deletions

View File

@ -57,7 +57,9 @@ void ActionHelper::finish(bool success, MessageQueueId_t reportTo, ActionId_t co
void ActionHelper::setQueueToUse(MessageQueueIF* queue) { queueToUse = queue; } void ActionHelper::setQueueToUse(MessageQueueIF* queue) { queueToUse = queue; }
#include <stdio.h> MessageQueueIF const * ActionHelper::getQueue() const {
return queueToUse;
}
void ActionHelper::prepareExecution(MessageQueueId_t commandedBy, ActionId_t actionId, void ActionHelper::prepareExecution(MessageQueueId_t commandedBy, ActionId_t actionId,
store_address_t dataAddress) { store_address_t dataAddress) {

View File

@ -102,6 +102,12 @@ class ActionHelper {
*/ */
void setQueueToUse(MessageQueueIF* queue); void setQueueToUse(MessageQueueIF* queue);
/**
* Needed so templateAction can check if actionHelper was
* contructed already to aid in debuggig a nasty coding error.
*/
MessageQueueIF const * getQueue() const;
void registerAction(Action* action); void registerAction(Action* action);
std::map<ActionId_t, Action*> const* getActionMap(); std::map<ActionId_t, Action*> const* getActionMap();

View File

@ -40,6 +40,11 @@ class Parameter : public ParameterIF {
return value; return value;
} }
Parameter& operator =(const T& newValue){
value = newValue;
return *this;
}
#ifdef FSFW_INTROSPECTION #ifdef FSFW_INTROSPECTION
Types::ParameterType getType() override { Types::ParameterType getType() override {
return enumHelper<std::is_base_of<EnumIF, T>::value>::template getType<T>(); return enumHelper<std::is_base_of<EnumIF, T>::value>::template getType<T>();
@ -66,7 +71,6 @@ class Parameter : public ParameterIF {
bool setFloating(double value) override { bool setFloating(double value) override {
if (getType() != Types::FLOATING) { if (getType() != Types::FLOATING) {
puts("fups");
return false; return false;
} }
this->value = T(value); this->value = T(value);
@ -75,7 +79,6 @@ class Parameter : public ParameterIF {
bool setSigned(int64_t value) override { bool setSigned(int64_t value) override {
if ((getType() != Types::SIGNED) && (getType() != Types::ENUM)) { if ((getType() != Types::SIGNED) && (getType() != Types::ENUM)) {
puts("sups");
return false; return false;
} }
this->value = T(value); this->value = T(value);

View File

@ -1,6 +1,7 @@
#pragma once #pragma once
#include "Action.h" #include "Action.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
template <class owner, class action, class ActionEnum> template <class owner, class action, class ActionEnum>
class TemplateAction : public Action { class TemplateAction : public Action {
@ -8,10 +9,15 @@ class TemplateAction : public Action {
#ifdef FSFW_INTROSPECTION #ifdef FSFW_INTROSPECTION
TemplateAction(owner *myOwner, ActionEnum id) : Action(), myOwner(myOwner) { TemplateAction(owner *myOwner, ActionEnum id) : Action(), myOwner(myOwner) {
Action::setEnum(&id); Action::setEnum(&id);
if (myOwner->getActionHelper()->getQueue() == nullptr) {
sif::error
<< "TemplateAction::TemplateAction: Action instances need to be created (ie located) after the actionHelper instance."
<< "Program will segfault now..." << std::endl;
}
myOwner->getActionHelper()->registerAction(this); myOwner->getActionHelper()->registerAction(this);
} }
#else #else
TemplateAction(owner *myOwner, ActionEnum id) : Action((uint32_t) id), myOwner(myOwner) { TemplateAction(owner *myOwner, ActionEnum id) : Action((uint32_t)id), myOwner(myOwner) {
myOwner->getActionHelper()->registerAction(this); myOwner->getActionHelper()->registerAction(this);
} }
#endif #endif

View File

@ -342,7 +342,7 @@ class DeviceHandlerBase : public DeviceHandlerIF,
*/ */
virtual ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, virtual ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t *commandData, const uint8_t *commandData,
size_t commandDataLen) = 0; size_t commandDataLen) {exit(0);}
/* Reply handling */ /* Reply handling */
/** /**

View File

@ -78,7 +78,7 @@ SystemObjectIF* ObjectManager::getSystemObject(object_id_t id) {
} }
} }
void ObjectManager::initialize() { void ObjectManager::produce() {
if (objectFactoryFunction == nullptr) { if (objectFactoryFunction == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "ObjectManager::initialize: Passed produceObjects " sif::error << "ObjectManager::initialize: Passed produceObjects "
@ -90,6 +90,10 @@ void ObjectManager::initialize() {
return; return;
} }
objectFactoryFunction(factoryArgs); objectFactoryFunction(factoryArgs);
}
void ObjectManager::initialize() {
produce();
ReturnValue_t result = RETURN_FAILED; ReturnValue_t result = RETURN_FAILED;
uint32_t errorCount = 0; uint32_t errorCount = 0;
for (auto const& it : objectList) { for (auto const& it : objectList) {
@ -143,3 +147,7 @@ void ObjectManager::printList() {
} }
#endif #endif
} }
const std::map<object_id_t, SystemObjectIF*> * ObjectManager::getObjectList(){
return &objectList;
}

View File

@ -42,7 +42,9 @@ class ObjectManager : public ObjectManagerIF {
ReturnValue_t insert(object_id_t id, SystemObjectIF* object) override; ReturnValue_t insert(object_id_t id, SystemObjectIF* object) override;
ReturnValue_t remove(object_id_t id) override; ReturnValue_t remove(object_id_t id) override;
void initialize() override; void initialize() override;
void produce() override;
void printList() override; void printList() override;
const std::map<object_id_t, SystemObjectIF*> * getObjectList() override;
protected: protected:
SystemObjectIF* getSystemObject(object_id_t id) override; SystemObjectIF* getSystemObject(object_id_t id) override;

View File

@ -1,6 +1,8 @@
#ifndef FSFW_OBJECTMANAGER_OBJECTMANAGERIF_H_ #ifndef FSFW_OBJECTMANAGER_OBJECTMANAGERIF_H_
#define FSFW_OBJECTMANAGER_OBJECTMANAGERIF_H_ #define FSFW_OBJECTMANAGER_OBJECTMANAGERIF_H_
#include <map>
#include "../returnvalues/HasReturnvaluesIF.h" #include "../returnvalues/HasReturnvaluesIF.h"
#include "../serviceinterface/ServiceInterface.h" #include "../serviceinterface/ServiceInterface.h"
#include "SystemObjectIF.h" #include "SystemObjectIF.h"
@ -58,12 +60,14 @@ class ObjectManagerIF : public HasReturnvaluesIF {
* @li RETURN_OK in case the object was successfully removed * @li RETURN_OK in case the object was successfully removed
*/ */
virtual ReturnValue_t remove(object_id_t id) = 0; virtual ReturnValue_t remove(object_id_t id) = 0;
virtual void produce() = 0;
virtual void initialize() = 0; virtual void initialize() = 0;
/** /**
* @brief This is a debug function, that prints the current content of the * @brief This is a debug function, that prints the current content of the
* object list. * object list.
*/ */
virtual void printList() = 0; virtual void printList() = 0;
virtual const std::map<object_id_t, SystemObjectIF*>* getObjectList() = 0;
}; };
#endif /* OBJECTMANAGERIF_H_ */ #endif /* OBJECTMANAGERIF_H_ */