subsystem folder update
This commit is contained in:
parent
3aa666633e
commit
837a18135e
@ -12,13 +12,10 @@ Subsystem::Subsystem(object_id_t setObjectId, object_id_t parent,
|
||||
uint32_t maxNumberOfSequences, uint32_t maxNumberOfTables) :
|
||||
SubsystemBase(setObjectId, parent, 0), isInTransition(false),
|
||||
childrenChangedHealth(false), currentTargetTable(),
|
||||
targetMode(0), targetSubmode(SUBMODE_NONE), initialMode(0),
|
||||
currentSequenceIterator(), modeTables(maxNumberOfTables),
|
||||
modeSequences(maxNumberOfSequences) {}
|
||||
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) {
|
||||
@ -344,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(
|
||||
@ -390,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()));
|
||||
@ -582,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);
|
||||
@ -651,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,13 +1,14 @@
|
||||
#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 "../subsystem/modes/ModeDefinitions.h"
|
||||
#include "../subsystem/SubsystemBase.h"
|
||||
|
||||
class Subsystem: public SubsystemBase, public HasModeSequenceIF {
|
||||
public:
|
||||
@ -44,11 +45,11 @@ 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;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -96,11 +97,11 @@ protected:
|
||||
|
||||
HybridIterator<ModeListEntry> currentTargetTable;
|
||||
|
||||
Mode_t targetMode;
|
||||
Mode_t targetMode = 0;
|
||||
|
||||
Submode_t targetSubmode;
|
||||
|
||||
Mode_t initialMode;
|
||||
Mode_t initialMode = 0;
|
||||
|
||||
HybridIterator<ModeListEntry> currentSequenceIterator;
|
||||
|
||||
@ -153,7 +154,8 @@ 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);
|
||||
|
||||
@ -161,4 +163,4 @@ protected:
|
||||
|
||||
};
|
||||
|
||||
#endif /* SUBSYSTEM_H_ */
|
||||
#endif /* FSFW_SUBSYSTEM_SUBSYSTEM_H_ */
|
||||
|
@ -6,10 +6,10 @@
|
||||
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),
|
||||
childrenChangedMode(false),
|
||||
commandQueue(QueueFactory::instance()->createMessageQueue(
|
||||
commandQueueDepth, CommandMessage::MAX_MESSAGE_SIZE)),
|
||||
healthHelper(this, setObjectId), modeHelper(this), parentId(parent) {
|
||||
commandQueue = QueueFactory::instance()->createMessageQueue(commandQueueDepth,
|
||||
MessageQueueMessage::MAX_MESSAGE_SIZE);
|
||||
}
|
||||
|
||||
SubsystemBase::~SubsystemBase() {
|
||||
@ -21,7 +21,8 @@ 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 == nullptr) {
|
||||
if (healthChild == nullptr) {
|
||||
@ -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(
|
||||
|
@ -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,7 +9,6 @@
|
||||
#include "../modes/HasModesIF.h"
|
||||
#include "../objectmanager/SystemObject.h"
|
||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||
#include "../subsystem/modes/HasModeSequenceIF.h"
|
||||
#include "../tasks/ExecutableObjectIF.h"
|
||||
#include "../ipc/MessageQueueIF.h"
|
||||
#include <map>
|
||||
@ -34,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 {
|
||||
@ -62,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;
|
||||
|
||||
@ -126,4 +127,4 @@ protected:
|
||||
virtual void modeChanged();
|
||||
};
|
||||
|
||||
#endif /* SUBSYSTEMBASE_H_ */
|
||||
#endif /* FSFW_SUBSYSTEM_SUBSYSTEMBASE_H_ */
|
||||
|
@ -1,9 +1,9 @@
|
||||
#ifndef HASMODESEQUENCEIF_H_
|
||||
#define HASMODESEQUENCEIF_H_
|
||||
|
||||
#include "../../subsystem/modes/ModeDefinitions.h"
|
||||
#include "../../subsystem/modes/ModeSequenceMessage.h"
|
||||
#include "../../subsystem/modes/ModeStoreIF.h"
|
||||
#include "ModeDefinitions.h"
|
||||
#include "ModeSequenceMessage.h"
|
||||
#include "ModeStoreIF.h"
|
||||
|
||||
|
||||
class HasModeSequenceIF {
|
||||
|
@ -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 "../../subsystem/modes/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);
|
||||
@ -64,8 +50,9 @@ void ModeSequenceMessage::clear(CommandMessage *message) {
|
||||
case TABLE_LIST:
|
||||
case TABLE:
|
||||
case SEQUENCE: {
|
||||
StorageManagerIF *ipcStore = objectManager->get<StorageManagerIF>(objects::IPC_STORE);
|
||||
if (ipcStore != NULL){
|
||||
StorageManagerIF *ipcStore = objectManager->get<StorageManagerIF>(
|
||||
objects::IPC_STORE);
|
||||
if (ipcStore != nullptr){
|
||||
ipcStore->deleteData(ModeSequenceMessage::getStoreAddress(message));
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
#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 "../../subsystem/modes/ModeDefinitions.h"
|
||||
|
||||
|
||||
class ModeSequenceMessage {
|
||||
public:
|
||||
@ -45,4 +46,4 @@ private:
|
||||
ModeSequenceMessage();
|
||||
};
|
||||
|
||||
#endif /* MODESEQUENCEMESSAGE_H_ */
|
||||
#endif /* FSFW_SUBSYSTEM_MODES_MODESEQUENCEMESSAGE_H_ */
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "../../subsystem/modes/ModeStore.h"
|
||||
|
||||
// todo: I think some parts are deprecated. If this is used, the define
|
||||
// USE_MODESTORE could be part of the new FSFWConfig.h file.
|
||||
#ifdef USE_MODESTORE
|
||||
|
||||
ModeStore::ModeStore(object_id_t objectId, uint32_t slots) :
|
||||
|
Loading…
Reference in New Issue
Block a user