Merge branch 'development' into mueller/tmtcservices-update
This commit is contained in:
commit
e7da1e37c3
@ -21,13 +21,11 @@
|
||||
#define FSFW_OBJ_EVENT_TRANSLATION 0
|
||||
|
||||
#if FSFW_OBJ_EVENT_TRANSLATION == 1
|
||||
#define FSFW_DEBUG_OUTPUT 1
|
||||
//! Specify whether info events are printed too.
|
||||
#define FSFW_DEBUG_INFO 1
|
||||
#include <translateObjects.h>
|
||||
#include <translateEvents.h>
|
||||
#else
|
||||
#define FSFW_DEBUG_OUTPUT 0
|
||||
#endif
|
||||
|
||||
//! When using the newlib nano library, C99 support for stdio facilities
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "EventManager.h"
|
||||
#include "EventMessage.h"
|
||||
#include <FSFWConfig.h>
|
||||
|
||||
#include <FSFWConfig.h>
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../ipc/QueueFactory.h"
|
||||
#include "../ipc/MutexFactory.h"
|
||||
@ -43,7 +43,7 @@ ReturnValue_t EventManager::performOperation(uint8_t opCode) {
|
||||
EventMessage message;
|
||||
result = eventReportQueue->receiveMessage(&message);
|
||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
#ifdef DEBUG
|
||||
#if FSFW_OBJ_EVENT_TRANSLATION == 1
|
||||
printEvent(&message);
|
||||
#endif
|
||||
notifyListeners(&message);
|
||||
@ -114,13 +114,13 @@ ReturnValue_t EventManager::unsubscribeFromEventRange(MessageQueueId_t listener,
|
||||
return result;
|
||||
}
|
||||
|
||||
#if FSFW_DEBUG_OUTPUT == 1
|
||||
#if FSFW_OBJ_EVENT_TRANSLATION == 1
|
||||
|
||||
void EventManager::printEvent(EventMessage* message) {
|
||||
const char *string = 0;
|
||||
switch (message->getSeverity()) {
|
||||
case severity::INFO:
|
||||
#ifdef DEBUG_INFO_EVENT
|
||||
#if DEBUG_INFO_EVENT == 1
|
||||
string = translateObject(message->getReporter());
|
||||
sif::info << "EVENT: ";
|
||||
if (string != 0) {
|
||||
|
@ -1,18 +1,20 @@
|
||||
#ifndef EVENTMANAGER_H_
|
||||
#define EVENTMANAGER_H_
|
||||
#ifndef FSFW_EVENT_EVENTMANAGER_H_
|
||||
#define FSFW_EVENT_EVENTMANAGER_H_
|
||||
|
||||
#include "eventmatching/EventMatchTree.h"
|
||||
#include "EventManagerIF.h"
|
||||
#include "eventmatching/EventMatchTree.h"
|
||||
|
||||
#include <FSFWConfig.h>
|
||||
|
||||
#include "../objectmanager/SystemObject.h"
|
||||
#include "../storagemanager/LocalPool.h"
|
||||
#include "../tasks/ExecutableObjectIF.h"
|
||||
#include "../ipc/MessageQueueIF.h"
|
||||
#include "../ipc/MutexIF.h"
|
||||
#include <FSFWConfig.h>
|
||||
|
||||
#include <map>
|
||||
|
||||
#if FSFW_DEBUG_OUTPUT == 1
|
||||
#if FSFW_OBJ_EVENT_TRANSLATION == 1
|
||||
// forward declaration, should be implemented by mission
|
||||
extern const char* translateObject(object_id_t object);
|
||||
extern const char* translateEvents(Event event);
|
||||
@ -59,7 +61,7 @@ protected:
|
||||
|
||||
void notifyListeners(EventMessage *message);
|
||||
|
||||
#if FSFW_DEBUG_OUTPUT == 1
|
||||
#if FSFW_OBJ_EVENT_TRANSLATION == 1
|
||||
void printEvent(EventMessage *message);
|
||||
#endif
|
||||
|
||||
@ -68,4 +70,4 @@ protected:
|
||||
void unlockMutex();
|
||||
};
|
||||
|
||||
#endif /* EVENTMANAGER_H_ */
|
||||
#endif /* FSFW_EVENT_EVENTMANAGER_H_ */
|
||||
|
@ -1,10 +1,11 @@
|
||||
#ifndef EVENTMANAGERIF_H_
|
||||
#define EVENTMANAGERIF_H_
|
||||
|
||||
#include "eventmatching/eventmatching.h"
|
||||
#include "EventMessage.h"
|
||||
#include "eventmatching/eventmatching.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
#include "../ipc/MessageQueueSenderIF.h"
|
||||
#include "../ipc/MessageQueueIF.h"
|
||||
|
||||
class EventManagerIF {
|
||||
public:
|
||||
@ -16,7 +17,8 @@ public:
|
||||
|
||||
virtual MessageQueueId_t getEventReportQueue() = 0;
|
||||
|
||||
virtual ReturnValue_t registerListener(MessageQueueId_t listener, bool forwardAllButSelected = false) = 0;
|
||||
virtual ReturnValue_t registerListener(MessageQueueId_t listener,
|
||||
bool forwardAllButSelected = false) = 0;
|
||||
virtual ReturnValue_t subscribeToEvent(MessageQueueId_t listener,
|
||||
EventId_t event) = 0;
|
||||
virtual ReturnValue_t subscribeToAllEventsFrom(MessageQueueId_t listener,
|
||||
@ -31,18 +33,22 @@ public:
|
||||
bool reporterInverted = false) = 0;
|
||||
|
||||
static void triggerEvent(object_id_t reportingObject, Event event,
|
||||
uint32_t parameter1 = 0, uint32_t parameter2 = 0, MessageQueueId_t sentFrom = 0) {
|
||||
uint32_t parameter1 = 0, uint32_t parameter2 = 0,
|
||||
MessageQueueId_t sentFrom = 0) {
|
||||
EventMessage message(event, reportingObject, parameter1, parameter2);
|
||||
triggerEvent(&message, sentFrom);
|
||||
}
|
||||
static void triggerEvent(EventMessage* message, MessageQueueId_t sentFrom = 0) {
|
||||
static MessageQueueId_t eventmanagerQueue = 0;
|
||||
if (eventmanagerQueue == 0) {
|
||||
|
||||
static void triggerEvent(EventMessage* message,
|
||||
MessageQueueId_t sentFrom = 0) {
|
||||
static MessageQueueId_t eventmanagerQueue = MessageQueueIF::NO_QUEUE;
|
||||
if (eventmanagerQueue == MessageQueueIF::NO_QUEUE) {
|
||||
EventManagerIF *eventmanager = objectManager->get<EventManagerIF>(
|
||||
objects::EVENT_MANAGER);
|
||||
if (eventmanager != NULL) {
|
||||
eventmanagerQueue = eventmanager->getEventReportQueue();
|
||||
if (eventmanager == nullptr) {
|
||||
return;
|
||||
}
|
||||
eventmanagerQueue = eventmanager->getEventReportQueue();
|
||||
}
|
||||
MessageQueueSenderIF::sendMessage(eventmanagerQueue, message, sentFrom);
|
||||
}
|
||||
|
@ -1,29 +1,21 @@
|
||||
#include "Subsystem.h"
|
||||
#include "../health/HealthMessage.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
#include "../serialize/SerialArrayListAdapter.h"
|
||||
#include "../serialize/SerialFixedArrayListAdapter.h"
|
||||
#include "../serialize/SerializeElement.h"
|
||||
#include "../serialize/SerialLinkedListAdapter.h"
|
||||
#include "Subsystem.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
Subsystem::Subsystem(object_id_t setObjectId, object_id_t parent,
|
||||
uint32_t maxNumberOfSequences, uint32_t maxNumberOfTables) :
|
||||
SubsystemBase(setObjectId, parent, 0), isInTransition(false), childrenChangedHealth(
|
||||
false), uptimeStartTable(0), currentTargetTable(), targetMode(
|
||||
0), targetSubmode(SUBMODE_NONE), initialMode(0), currentSequenceIterator(), modeTables(
|
||||
maxNumberOfTables), modeSequences(maxNumberOfSequences), IPCStore(
|
||||
NULL)
|
||||
#ifdef USE_MODESTORE
|
||||
,modeStore(NULL)
|
||||
#endif
|
||||
{
|
||||
SubsystemBase(setObjectId, parent, 0), isInTransition(false),
|
||||
childrenChangedHealth(false), currentTargetTable(),
|
||||
targetSubmode(SUBMODE_NONE), currentSequenceIterator(),
|
||||
modeTables(maxNumberOfTables), modeSequences(maxNumberOfSequences) {}
|
||||
|
||||
}
|
||||
|
||||
Subsystem::~Subsystem() {
|
||||
//Auto-generated destructor stub
|
||||
}
|
||||
Subsystem::~Subsystem() {}
|
||||
|
||||
ReturnValue_t Subsystem::checkSequence(HybridIterator<ModeListEntry> iter,
|
||||
Mode_t fallbackSequence) {
|
||||
@ -349,7 +341,8 @@ ReturnValue_t Subsystem::addSequence(ArrayList<ModeListEntry> *sequence,
|
||||
|
||||
ReturnValue_t result;
|
||||
|
||||
//Before initialize() is called, tables must not be checked as the children are not added yet.
|
||||
//Before initialize() is called, tables must not be checked as the
|
||||
//children are not added yet.
|
||||
//Sequences added before are checked by initialize()
|
||||
if (!preInit) {
|
||||
result = checkSequence(
|
||||
@ -374,7 +367,7 @@ ReturnValue_t Subsystem::addSequence(ArrayList<ModeListEntry> *sequence,
|
||||
}
|
||||
|
||||
if (inStore) {
|
||||
#ifdef USE_MODESTORE
|
||||
#if FSFW_USE_MODESTORE == 1
|
||||
result = modeStore->storeArray(sequence,
|
||||
&(modeSequences.find(id)->entries.firstLinkedElement));
|
||||
if (result != RETURN_OK) {
|
||||
@ -395,8 +388,8 @@ ReturnValue_t Subsystem::addTable(ArrayList<ModeListEntry> *table, Mode_t id,
|
||||
|
||||
ReturnValue_t result;
|
||||
|
||||
//Before initialize() is called, tables must not be checked as the children are not added yet.
|
||||
//Tables added before are checked by initialize()
|
||||
//Before initialize() is called, tables must not be checked as the children
|
||||
//are not added yet. Tables added before are checked by initialize()
|
||||
if (!preInit) {
|
||||
result = checkTable(
|
||||
HybridIterator<ModeListEntry>(table->front(), table->back()));
|
||||
@ -417,7 +410,7 @@ ReturnValue_t Subsystem::addTable(ArrayList<ModeListEntry> *table, Mode_t id,
|
||||
}
|
||||
|
||||
if (inStore) {
|
||||
#ifdef USE_MODESTORE
|
||||
#if FSFW_USE_MODESTORE == 1
|
||||
result = modeStore->storeArray(table,
|
||||
&(modeTables.find(id)->firstLinkedElement));
|
||||
if (result != RETURN_OK) {
|
||||
@ -447,7 +440,7 @@ ReturnValue_t Subsystem::deleteSequence(Mode_t id) {
|
||||
return ACCESS_DENIED;
|
||||
}
|
||||
|
||||
#ifdef USE_MODESTORE
|
||||
#if FSFW_USE_MODESTORE == 1
|
||||
modeStore->deleteList(sequenceInfo->entries.firstLinkedElement);
|
||||
#endif
|
||||
modeSequences.erase(id);
|
||||
@ -470,7 +463,7 @@ ReturnValue_t Subsystem::deleteTable(Mode_t id) {
|
||||
return ACCESS_DENIED;
|
||||
}
|
||||
|
||||
#ifdef USE_MODESTORE
|
||||
#if FSFW_USE_MODESTORE == 1
|
||||
modeStore->deleteList(pointer->firstLinkedElement);
|
||||
#endif
|
||||
modeSequences.erase(id);
|
||||
@ -489,10 +482,10 @@ ReturnValue_t Subsystem::initialize() {
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
#ifdef USE_MODESTORE
|
||||
#if FSFW_USE_MODESTORE == 1
|
||||
modeStore = objectManager->get<ModeStoreIF>(objects::MODE_STORE);
|
||||
|
||||
if (modeStore == NULL) {
|
||||
if (modeStore == nullptr) {
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
#endif
|
||||
@ -587,12 +580,14 @@ void Subsystem::transitionFailed(ReturnValue_t failureCode,
|
||||
triggerEvent(MODE_TRANSITION_FAILED, failureCode, parameter);
|
||||
if (mode == targetMode) {
|
||||
//already tried going back to the current mode
|
||||
//go into fallback mode, also set current mode to fallback mode, so we come here at the next fail
|
||||
//go into fallback mode, also set current mode to fallback mode,
|
||||
//so we come here at the next fail
|
||||
modeHelper.setForced(true);
|
||||
ReturnValue_t result;
|
||||
if ((result = checkSequence(getFallbackSequence(mode))) != RETURN_OK) {
|
||||
triggerEvent(FALLBACK_FAILED, result, getFallbackSequence(mode));
|
||||
isInTransition = false; //keep still and allow arbitrary mode commands to recover
|
||||
//keep still and allow arbitrary mode commands to recover
|
||||
isInTransition = false;
|
||||
return;
|
||||
}
|
||||
mode = getFallbackSequence(mode);
|
||||
@ -656,8 +651,10 @@ void Subsystem::cantKeepMode() {
|
||||
|
||||
modeHelper.setForced(true);
|
||||
|
||||
//already set the mode, so that we do not try to go back in our old mode when the transition fails
|
||||
//already set the mode, so that we do not try to go back in our old mode
|
||||
//when the transition fails
|
||||
mode = getFallbackSequence(mode);
|
||||
//SHOULDDO: We should store submodes for fallback sequence as well, otherwise we should get rid of submodes completely.
|
||||
//SHOULDDO: We should store submodes for fallback sequence as well,
|
||||
//otherwise we should get rid of submodes completely.
|
||||
startTransition(mode, SUBMODE_NONE);
|
||||
}
|
||||
|
@ -1,14 +1,21 @@
|
||||
#ifndef SUBSYSTEM_H_
|
||||
#define SUBSYSTEM_H_
|
||||
#ifndef FSFW_SUBSYSTEM_SUBSYSTEM_H_
|
||||
#define FSFW_SUBSYSTEM_SUBSYSTEM_H_
|
||||
|
||||
#include "SubsystemBase.h"
|
||||
#include "modes/ModeDefinitions.h"
|
||||
|
||||
#include "../container/FixedArrayList.h"
|
||||
#include "../container/FixedMap.h"
|
||||
#include "../container/HybridIterator.h"
|
||||
#include "../container/SinglyLinkedList.h"
|
||||
#include "../serialize/SerialArrayListAdapter.h"
|
||||
#include "modes/ModeDefinitions.h"
|
||||
#include "SubsystemBase.h"
|
||||
|
||||
#include <FSFWConfig.h>
|
||||
|
||||
/**
|
||||
* @brief TODO: documentation missing
|
||||
* @details
|
||||
*/
|
||||
class Subsystem: public SubsystemBase, public HasModeSequenceIF {
|
||||
public:
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::SUBSYSTEM;
|
||||
@ -30,8 +37,13 @@ public:
|
||||
static const ReturnValue_t TARGET_TABLE_NOT_REACHED = MAKE_RETURN_CODE(0xA1);
|
||||
static const ReturnValue_t TABLE_CHECK_FAILED = MAKE_RETURN_CODE(0xA2);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* TODO: Doc for constructor
|
||||
* @param setObjectId
|
||||
* @param parent
|
||||
* @param maxNumberOfSequences
|
||||
* @param maxNumberOfTables
|
||||
*/
|
||||
Subsystem(object_id_t setObjectId, object_id_t parent,
|
||||
uint32_t maxNumberOfSequences, uint32_t maxNumberOfTables);
|
||||
virtual ~Subsystem();
|
||||
@ -44,31 +56,12 @@ public:
|
||||
|
||||
void setInitialMode(Mode_t mode);
|
||||
|
||||
virtual ReturnValue_t initialize();
|
||||
virtual ReturnValue_t initialize() override;
|
||||
|
||||
virtual ReturnValue_t checkObjectConnections();
|
||||
virtual ReturnValue_t checkObjectConnections() override;
|
||||
|
||||
virtual MessageQueueId_t getSequenceCommandQueue() const;
|
||||
virtual MessageQueueId_t getSequenceCommandQueue() const override;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* IMPORTANT: Do not call on non existing sequence! Use existsSequence() first
|
||||
*
|
||||
* @param sequence
|
||||
* @return
|
||||
*/
|
||||
ReturnValue_t checkSequence(Mode_t sequence);
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* IMPORTANT: Do not call on non existing sequence! Use existsSequence() first
|
||||
*
|
||||
* @param iter
|
||||
* @return
|
||||
*/
|
||||
ReturnValue_t checkSequence(HybridIterator<ModeListEntry> iter, Mode_t fallbackSequence);
|
||||
protected:
|
||||
|
||||
struct EntryPointer {
|
||||
@ -92,15 +85,15 @@ protected:
|
||||
|
||||
bool childrenChangedHealth;
|
||||
|
||||
uint32_t uptimeStartTable;
|
||||
uint32_t uptimeStartTable = 0;
|
||||
|
||||
HybridIterator<ModeListEntry> currentTargetTable;
|
||||
|
||||
Mode_t targetMode;
|
||||
Mode_t targetMode = 0;
|
||||
|
||||
Submode_t targetSubmode;
|
||||
|
||||
Mode_t initialMode;
|
||||
Mode_t initialMode = 0;
|
||||
|
||||
HybridIterator<ModeListEntry> currentSequenceIterator;
|
||||
|
||||
@ -108,10 +101,10 @@ protected:
|
||||
|
||||
FixedMap<Mode_t, SequenceInfo> modeSequences;
|
||||
|
||||
StorageManagerIF *IPCStore;
|
||||
StorageManagerIF *IPCStore = nullptr;
|
||||
|
||||
#ifdef USE_MODESTORE
|
||||
ModeStoreIF *modeStore;
|
||||
#if FSFW_USE_MODESTORE == 1
|
||||
ModeStoreIF *modeStore = nullptr;
|
||||
#endif
|
||||
|
||||
bool existsModeSequence(Mode_t id);
|
||||
@ -124,8 +117,6 @@ protected:
|
||||
|
||||
HybridIterator<ModeListEntry> getCurrentTable();
|
||||
|
||||
// void startSequence(Mode_t sequence);
|
||||
|
||||
/**
|
||||
* DO NOT USE ON NON EXISTING SEQUENCE
|
||||
*
|
||||
@ -153,12 +144,29 @@ protected:
|
||||
|
||||
virtual void startTransition(Mode_t mode, Submode_t submode);
|
||||
|
||||
void sendSerializablesAsCommandMessage(Command_t command, SerializeIF **elements, uint8_t count);
|
||||
void sendSerializablesAsCommandMessage(Command_t command,
|
||||
SerializeIF **elements, uint8_t count);
|
||||
|
||||
void transitionFailed(ReturnValue_t failureCode, uint32_t parameter);
|
||||
|
||||
void cantKeepMode();
|
||||
|
||||
/**
|
||||
* @brief Checks whether a sequence, identified by a mode.
|
||||
* @param sequence
|
||||
* @return
|
||||
*/
|
||||
ReturnValue_t checkSequence(Mode_t sequence);
|
||||
|
||||
/**
|
||||
* @brief Checks whether a sequence, identified by a mode list iterator
|
||||
* and a fallback sequence. Iterator needs to point to a valid
|
||||
* sequence.
|
||||
* @param iter
|
||||
* @return
|
||||
*/
|
||||
ReturnValue_t checkSequence(HybridIterator<ModeListEntry> iter,
|
||||
Mode_t fallbackSequence);
|
||||
};
|
||||
|
||||
#endif /* SUBSYSTEM_H_ */
|
||||
#endif /* FSFW_SUBSYSTEM_SUBSYSTEM_H_ */
|
||||
|
@ -1,15 +1,15 @@
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "SubsystemBase.h"
|
||||
#include "../subsystem/SubsystemBase.h"
|
||||
#include "../ipc/QueueFactory.h"
|
||||
|
||||
SubsystemBase::SubsystemBase(object_id_t setObjectId, object_id_t parent,
|
||||
Mode_t initialMode, uint16_t commandQueueDepth) :
|
||||
SystemObject(setObjectId), mode(initialMode), submode(SUBMODE_NONE), childrenChangedMode(
|
||||
false), commandsOutstanding(0), commandQueue(NULL), healthHelper(this,
|
||||
setObjectId), modeHelper(this), parentId(parent) {
|
||||
commandQueue = QueueFactory::instance()->createMessageQueue(commandQueueDepth,
|
||||
CommandMessage::MAX_MESSAGE_SIZE);
|
||||
SystemObject(setObjectId), mode(initialMode), submode(SUBMODE_NONE),
|
||||
childrenChangedMode(false),
|
||||
commandQueue(QueueFactory::instance()->createMessageQueue(
|
||||
commandQueueDepth, CommandMessage::MAX_MESSAGE_SIZE)),
|
||||
healthHelper(this, setObjectId), modeHelper(this), parentId(parent) {
|
||||
}
|
||||
|
||||
SubsystemBase::~SubsystemBase() {
|
||||
@ -21,10 +21,11 @@ ReturnValue_t SubsystemBase::registerChild(object_id_t objectId) {
|
||||
ChildInfo info;
|
||||
|
||||
HasModesIF *child = objectManager->get<HasModesIF>(objectId);
|
||||
//This is a rather ugly hack to have the changedHealth info for all children available. (needed for FOGs).
|
||||
// This is a rather ugly hack to have the changedHealth info for all
|
||||
// children available.
|
||||
HasHealthIF* healthChild = objectManager->get<HasHealthIF>(objectId);
|
||||
if (child == NULL) {
|
||||
if (healthChild == NULL) {
|
||||
if (child == nullptr) {
|
||||
if (healthChild == nullptr) {
|
||||
return CHILD_DOESNT_HAVE_MODES;
|
||||
} else {
|
||||
info.commandQueue = healthChild->getCommandQueue();
|
||||
@ -38,14 +39,11 @@ ReturnValue_t SubsystemBase::registerChild(object_id_t objectId) {
|
||||
info.submode = SUBMODE_NONE;
|
||||
info.healthChanged = false;
|
||||
|
||||
std::pair<std::map<object_id_t, ChildInfo>::iterator, bool> returnValue =
|
||||
childrenMap.insert(
|
||||
std::pair<object_id_t, ChildInfo>(objectId, info));
|
||||
if (!(returnValue.second)) {
|
||||
auto resultPair = childrenMap.emplace(objectId, info);
|
||||
if (not resultPair.second) {
|
||||
return COULD_NOT_INSERT_CHILD;
|
||||
} else {
|
||||
return RETURN_OK;
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t SubsystemBase::checkStateAgainstTable(
|
||||
@ -76,15 +74,15 @@ ReturnValue_t SubsystemBase::checkStateAgainstTable(
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
void SubsystemBase::executeTable(HybridIterator<ModeListEntry> tableIter, Submode_t targetSubmode) {
|
||||
|
||||
CommandMessage message;
|
||||
void SubsystemBase::executeTable(HybridIterator<ModeListEntry> tableIter,
|
||||
Submode_t targetSubmode) {
|
||||
CommandMessage command;
|
||||
|
||||
std::map<object_id_t, ChildInfo>::iterator iter;
|
||||
|
||||
commandsOutstanding = 0;
|
||||
|
||||
for (; tableIter.value != NULL; ++tableIter) {
|
||||
for (; tableIter.value != nullptr; ++tableIter) {
|
||||
object_id_t object = tableIter.value->getObject();
|
||||
if ((iter = childrenMap.find(object)) == childrenMap.end()) {
|
||||
//illegal table entry, should only happen due to misconfigured mode table
|
||||
@ -100,17 +98,17 @@ void SubsystemBase::executeTable(HybridIterator<ModeListEntry> tableIter, Submod
|
||||
|
||||
if (healthHelper.healthTable->hasHealth(object)) {
|
||||
if (healthHelper.healthTable->isFaulty(object)) {
|
||||
ModeMessage::setModeMessage(&message,
|
||||
ModeMessage::setModeMessage(&command,
|
||||
ModeMessage::CMD_MODE_COMMAND, HasModesIF::MODE_OFF,
|
||||
SUBMODE_NONE);
|
||||
} else {
|
||||
if (modeHelper.isForced()) {
|
||||
ModeMessage::setModeMessage(&message,
|
||||
ModeMessage::setModeMessage(&command,
|
||||
ModeMessage::CMD_MODE_COMMAND_FORCED,
|
||||
tableIter.value->getMode(), submodeToCommand);
|
||||
} else {
|
||||
if (healthHelper.healthTable->isCommandable(object)) {
|
||||
ModeMessage::setModeMessage(&message,
|
||||
ModeMessage::setModeMessage(&command,
|
||||
ModeMessage::CMD_MODE_COMMAND,
|
||||
tableIter.value->getMode(), submodeToCommand);
|
||||
} else {
|
||||
@ -119,17 +117,17 @@ void SubsystemBase::executeTable(HybridIterator<ModeListEntry> tableIter, Submod
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ModeMessage::setModeMessage(&message, ModeMessage::CMD_MODE_COMMAND,
|
||||
ModeMessage::setModeMessage(&command, ModeMessage::CMD_MODE_COMMAND,
|
||||
tableIter.value->getMode(), submodeToCommand);
|
||||
}
|
||||
|
||||
if ((iter->second.mode == ModeMessage::getMode(&message))
|
||||
&& (iter->second.submode == ModeMessage::getSubmode(&message))
|
||||
if ((iter->second.mode == ModeMessage::getMode(&command))
|
||||
&& (iter->second.submode == ModeMessage::getSubmode(&command))
|
||||
&& !modeHelper.isForced()) {
|
||||
continue; //don't send redundant mode commands (produces event spam), but still command if mode is forced to reach lower levels
|
||||
}
|
||||
ReturnValue_t result = commandQueue->sendMessage(
|
||||
iter->second.commandQueue, &message);
|
||||
iter->second.commandQueue, &command);
|
||||
if (result == RETURN_OK) {
|
||||
++commandsOutstanding;
|
||||
}
|
||||
@ -306,31 +304,31 @@ void SubsystemBase::announceMode(bool recursive) {
|
||||
|
||||
void SubsystemBase::checkCommandQueue() {
|
||||
ReturnValue_t result;
|
||||
CommandMessage message;
|
||||
CommandMessage command;
|
||||
|
||||
for (result = commandQueue->receiveMessage(&message); result == RETURN_OK;
|
||||
result = commandQueue->receiveMessage(&message)) {
|
||||
for (result = commandQueue->receiveMessage(&command); result == RETURN_OK;
|
||||
result = commandQueue->receiveMessage(&command)) {
|
||||
|
||||
result = healthHelper.handleHealthCommand(&message);
|
||||
result = healthHelper.handleHealthCommand(&command);
|
||||
if (result == RETURN_OK) {
|
||||
continue;
|
||||
}
|
||||
|
||||
result = modeHelper.handleModeCommand(&message);
|
||||
result = modeHelper.handleModeCommand(&command);
|
||||
if (result == RETURN_OK) {
|
||||
continue;
|
||||
}
|
||||
|
||||
result = handleModeReply(&message);
|
||||
result = handleModeReply(&command);
|
||||
if (result == RETURN_OK) {
|
||||
continue;
|
||||
}
|
||||
|
||||
result = handleCommandMessage(&message);
|
||||
result = handleCommandMessage(&command);
|
||||
if (result != RETURN_OK) {
|
||||
CommandMessage reply;
|
||||
reply.setReplyRejected(CommandMessage::UNKNOWN_COMMAND,
|
||||
message.getCommand());
|
||||
command.getCommand());
|
||||
replyToCommand(&reply);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
#ifndef SUBSYSTEMBASE_H_
|
||||
#define SUBSYSTEMBASE_H_
|
||||
#ifndef FSFW_SUBSYSTEM_SUBSYSTEMBASE_H_
|
||||
#define FSFW_SUBSYSTEM_SUBSYSTEMBASE_H_
|
||||
|
||||
#include "modes/HasModeSequenceIF.h"
|
||||
|
||||
#include "../container/HybridIterator.h"
|
||||
#include "../health/HasHealthIF.h"
|
||||
@ -7,11 +9,14 @@
|
||||
#include "../modes/HasModesIF.h"
|
||||
#include "../objectmanager/SystemObject.h"
|
||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||
#include "modes/HasModeSequenceIF.h"
|
||||
#include "../tasks/ExecutableObjectIF.h"
|
||||
#include "../ipc/MessageQueueIF.h"
|
||||
#include <map>
|
||||
|
||||
/**
|
||||
* @defgroup subsystems Subsystem Objects
|
||||
* Contains all Subsystem and Assemblies
|
||||
*/
|
||||
class SubsystemBase: public SystemObject,
|
||||
public HasModesIF,
|
||||
public HasHealthIF,
|
||||
@ -30,17 +35,17 @@ public:
|
||||
Mode_t initialMode = 0, uint16_t commandQueueDepth = 8);
|
||||
virtual ~SubsystemBase();
|
||||
|
||||
virtual MessageQueueId_t getCommandQueue() const;
|
||||
virtual MessageQueueId_t getCommandQueue() const override;
|
||||
|
||||
ReturnValue_t registerChild(object_id_t objectId);
|
||||
|
||||
virtual ReturnValue_t initialize();
|
||||
virtual ReturnValue_t initialize() override;
|
||||
|
||||
virtual ReturnValue_t performOperation(uint8_t opCode);
|
||||
virtual ReturnValue_t performOperation(uint8_t opCode) override;
|
||||
|
||||
virtual ReturnValue_t setHealth(HealthState health);
|
||||
virtual ReturnValue_t setHealth(HealthState health) override;
|
||||
|
||||
virtual HasHealthIF::HealthState getHealth();
|
||||
virtual HasHealthIF::HealthState getHealth() override;
|
||||
|
||||
protected:
|
||||
struct ChildInfo {
|
||||
@ -58,9 +63,9 @@ protected:
|
||||
/**
|
||||
* Always check this against <=0, so you are robust against too many replies
|
||||
*/
|
||||
int32_t commandsOutstanding;
|
||||
int32_t commandsOutstanding = 0;
|
||||
|
||||
MessageQueueIF* commandQueue;
|
||||
MessageQueueIF* commandQueue = nullptr;
|
||||
|
||||
HealthHelper healthHelper;
|
||||
|
||||
@ -122,4 +127,4 @@ protected:
|
||||
virtual void modeChanged();
|
||||
};
|
||||
|
||||
#endif /* SUBSYSTEMBASE_H_ */
|
||||
#endif /* FSFW_SUBSYSTEM_SUBSYSTEMBASE_H_ */
|
||||
|
@ -1,22 +1,19 @@
|
||||
#ifndef MODEDEFINITIONS_H_
|
||||
#define MODEDEFINITIONS_H_
|
||||
#ifndef FSFW_SUBSYSTEM_MODES_MODEDEFINITIONS_H_
|
||||
#define FSFW_SUBSYSTEM_MODES_MODEDEFINITIONS_H_
|
||||
|
||||
#include "../../modes/HasModesIF.h"
|
||||
#include "../../objectmanager/SystemObjectIF.h"
|
||||
#include "../../serialize/SerializeIF.h"
|
||||
#include "../../serialize/SerialLinkedListAdapter.h"
|
||||
|
||||
class ModeListEntry: public SerializeIF, public LinkedElement<ModeListEntry> {
|
||||
public:
|
||||
ModeListEntry() :
|
||||
LinkedElement<ModeListEntry>(this), value1(0), value2(0), value3(0), value4(
|
||||
0) {
|
||||
ModeListEntry(): LinkedElement<ModeListEntry>(this) {}
|
||||
|
||||
}
|
||||
|
||||
uint32_t value1;
|
||||
uint32_t value2;
|
||||
uint8_t value3;
|
||||
uint8_t value4;
|
||||
uint32_t value1 = 0;
|
||||
uint32_t value2 = 0;
|
||||
uint8_t value3 = 0;
|
||||
uint8_t value4 = 0;
|
||||
|
||||
virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size,
|
||||
size_t maxSize, Endianness streamEndianness) const {
|
||||
@ -149,4 +146,4 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
#endif //MODEDEFINITIONS_H_
|
||||
#endif /* FSFW_SUBSYSTEM_MODES_MODEDEFINITIONS_H_ */
|
||||
|
@ -1,8 +1,7 @@
|
||||
#include "../../objectmanager/ObjectManagerIF.h"
|
||||
#include "../../objectmanager/ObjectManagerIF.h"
|
||||
#include "ModeSequenceMessage.h"
|
||||
|
||||
#include "../../objectmanager/ObjectManagerIF.h"
|
||||
#include "../../storagemanager/StorageManagerIF.h"
|
||||
#include "ModeSequenceMessage.h"
|
||||
|
||||
void ModeSequenceMessage::setModeSequenceMessage(CommandMessage* message,
|
||||
Command_t command, Mode_t sequence, store_address_t storeAddress) {
|
||||
@ -11,25 +10,12 @@ void ModeSequenceMessage::setModeSequenceMessage(CommandMessage* message,
|
||||
message->setParameter2(sequence);
|
||||
}
|
||||
|
||||
//void ModeSequenceMessage::setModeSequenceMessage(CommandMessage* message,
|
||||
// Command_t command, ModeTableId_t table, store_address_t storeAddress) {
|
||||
// message->setCommand(command);
|
||||
// message->setParameter(storeAddress.raw);
|
||||
// message->setParameter2(table);
|
||||
//}
|
||||
|
||||
void ModeSequenceMessage::setModeSequenceMessage(CommandMessage* message,
|
||||
Command_t command, Mode_t sequence) {
|
||||
message->setCommand(command);
|
||||
message->setParameter2(sequence);
|
||||
}
|
||||
|
||||
//void ModeSequenceMessage::setModeSequenceMessage(CommandMessage* message,
|
||||
// Command_t command, ModeTableId_t table) {
|
||||
// message->setCommand(command);
|
||||
// message->setParameter2(table);
|
||||
//}
|
||||
|
||||
void ModeSequenceMessage::setModeSequenceMessage(CommandMessage* message,
|
||||
Command_t command, store_address_t storeAddress) {
|
||||
message->setCommand(command);
|
||||
@ -63,9 +49,10 @@ void ModeSequenceMessage::clear(CommandMessage *message) {
|
||||
case SEQUENCE_LIST:
|
||||
case TABLE_LIST:
|
||||
case TABLE:
|
||||
case SEQUENCE:{
|
||||
StorageManagerIF *ipcStore = objectManager->get<StorageManagerIF>(objects::IPC_STORE);
|
||||
if (ipcStore != NULL){
|
||||
case SEQUENCE: {
|
||||
StorageManagerIF *ipcStore = objectManager->get<StorageManagerIF>(
|
||||
objects::IPC_STORE);
|
||||
if (ipcStore != nullptr){
|
||||
ipcStore->deleteData(ModeSequenceMessage::getStoreAddress(message));
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
#ifndef MODESEQUENCEMESSAGE_H_
|
||||
#define MODESEQUENCEMESSAGE_H_
|
||||
#ifndef FSFW_SUBSYSTEM_MODES_MODESEQUENCEMESSAGE_H_
|
||||
#define FSFW_SUBSYSTEM_MODES_MODESEQUENCEMESSAGE_H_
|
||||
|
||||
#include "ModeDefinitions.h"
|
||||
|
||||
#include "../../ipc/CommandMessage.h"
|
||||
#include "../../storagemanager/StorageManagerIF.h"
|
||||
#include "ModeDefinitions.h"
|
||||
|
||||
|
||||
class ModeSequenceMessage {
|
||||
public:
|
||||
@ -45,4 +47,4 @@ private:
|
||||
ModeSequenceMessage();
|
||||
};
|
||||
|
||||
#endif /* MODESEQUENCEMESSAGE_H_ */
|
||||
#endif /* FSFW_SUBSYSTEM_MODES_MODESEQUENCEMESSAGE_H_ */
|
||||
|
@ -1,6 +1,8 @@
|
||||
#include "ModeStore.h"
|
||||
|
||||
#ifdef USE_MODESTORE
|
||||
// todo: I think some parts are deprecated. If this is used, the define
|
||||
// USE_MODESTORE could be part of the new FSFWConfig.h file.
|
||||
#if FSFW_USE_MODESTORE == 1
|
||||
|
||||
ModeStore::ModeStore(object_id_t objectId, uint32_t slots) :
|
||||
SystemObject(objectId), store(slots), emptySlot(store.front()) {
|
||||
|
@ -1,12 +1,15 @@
|
||||
#ifndef MODESTORE_H_
|
||||
#define MODESTORE_H_
|
||||
#ifndef FSFW_SUBSYSTEM_MODES_MODESTORE_H_
|
||||
#define FSFW_SUBSYSTEM_MODES_MODESTORE_H_
|
||||
|
||||
#ifdef USE_MODESTORE
|
||||
#include <FSFWConfig.h>
|
||||
|
||||
#if FSFW_USE_MODESTORE == 1
|
||||
|
||||
#include "ModeStoreIF.h"
|
||||
|
||||
#include "../../container/ArrayList.h"
|
||||
#include "../../container/SinglyLinkedList.h"
|
||||
#include "../../objectmanager/SystemObject.h"
|
||||
#include "ModeStoreIF.h"
|
||||
|
||||
class ModeStore: public ModeStoreIF, public SystemObject {
|
||||
public:
|
||||
@ -41,5 +44,5 @@ private:
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* MODESTORE_H_ */
|
||||
#endif /* FSFW_SUBSYSTEM_MODES_MODESTORE_H_ */
|
||||
|
||||
|
@ -1,12 +1,15 @@
|
||||
#ifndef MODESTOREIF_H_
|
||||
#define MODESTOREIF_H_
|
||||
|
||||
#ifdef USE_MODESTORE
|
||||
#include <FSFWConfig.h>
|
||||
|
||||
#if FSFW_USE_MODESTORE == 1
|
||||
|
||||
#include "ModeDefinitions.h"
|
||||
|
||||
#include "../../container/ArrayList.h"
|
||||
#include "../../container/SinglyLinkedList.h"
|
||||
#include "../../returnvalues/HasReturnvaluesIF.h"
|
||||
#include "ModeDefinitions.h"
|
||||
|
||||
class ModeStoreIF {
|
||||
public:
|
||||
|
@ -1,16 +1,32 @@
|
||||
#ifndef FRAMEWORK_TASKS_FIXEDTIMESLOTTASKIF_H_
|
||||
#define FRAMEWORK_TASKS_FIXEDTIMESLOTTASKIF_H_
|
||||
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
#include "PeriodicTaskIF.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
|
||||
/**
|
||||
* Following the same principle as the base class IF. This is the interface for a Fixed timeslot task
|
||||
* @brief Following the same principle as the base class IF.
|
||||
* This is the interface for a Fixed timeslot task
|
||||
*/
|
||||
class FixedTimeslotTaskIF : public PeriodicTaskIF {
|
||||
public:
|
||||
virtual ~FixedTimeslotTaskIF() {}
|
||||
virtual ReturnValue_t addSlot(object_id_t componentId, uint32_t slotTimeMs, int8_t executionStep) = 0;
|
||||
|
||||
/**
|
||||
* Add an object with a slot time and the execution step to the task.
|
||||
* The execution step will be passed to the object (e.g. as an operation
|
||||
* code in #performOperation)
|
||||
* @param componentId
|
||||
* @param slotTimeMs
|
||||
* @param executionStep
|
||||
* @return
|
||||
*/
|
||||
virtual ReturnValue_t addSlot(object_id_t componentId, uint32_t slotTimeMs,
|
||||
int8_t executionStep) = 0;
|
||||
/**
|
||||
* Check whether the sequence is valid and perform all other required
|
||||
* initialization steps which are needed after task creation
|
||||
*/
|
||||
virtual ReturnValue_t checkSequence() const = 0;
|
||||
};
|
||||
|
||||
|
@ -1,10 +1,11 @@
|
||||
#ifndef FRAMEWORK_TASKS_TASKFACTORY_H_
|
||||
#define FRAMEWORK_TASKS_TASKFACTORY_H_
|
||||
#ifndef FSFW_TASKS_TASKFACTORY_H_
|
||||
#define FSFW_TASKS_TASKFACTORY_H_
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "FixedTimeslotTaskIF.h"
|
||||
#include "Typedef.h"
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
/**
|
||||
* Singleton Class that produces Tasks.
|
||||
*/
|
||||
@ -48,10 +49,11 @@ public:
|
||||
|
||||
/**
|
||||
* Function to be called to delete a task
|
||||
* @param task The pointer to the task that shall be deleted, NULL specifies current Task
|
||||
* @param task The pointer to the task that shall be deleted,
|
||||
* nullptr specifies current Task
|
||||
* @return Success of deletion
|
||||
*/
|
||||
static ReturnValue_t deleteTask(PeriodicTaskIF* task = NULL);
|
||||
static ReturnValue_t deleteTask(PeriodicTaskIF* task = nullptr);
|
||||
|
||||
/**
|
||||
* Function to be called to delay current task
|
||||
@ -69,4 +71,4 @@ private:
|
||||
|
||||
};
|
||||
|
||||
#endif /* FRAMEWORK_TASKS_TASKFACTORY_H_ */
|
||||
#endif /* FSFW_TASKS_TASKFACTORY_H_ */
|
||||
|
@ -29,13 +29,11 @@
|
||||
//! additional output which requires the translation files translateObjects
|
||||
//! and translateEvents (and their compiles source files)
|
||||
#if FSFW_OBJ_EVENT_TRANSLATION == 1
|
||||
#define FSFW_DEBUG_OUTPUT 1
|
||||
//! Specify whether info events are printed too.
|
||||
#define FSFW_DEBUG_INFO 1
|
||||
#include <translateObjects.h>
|
||||
#include <translateEvents.h>
|
||||
#else
|
||||
#define FSFW_DEBUG_OUTPUT 0
|
||||
#endif
|
||||
|
||||
//! When using the newlib nano library, C99 support for stdio facilities
|
||||
|
Loading…
Reference in New Issue
Block a user