renormalized line endings
This commit is contained in:
@ -1,164 +1,164 @@
|
||||
#ifndef SUBSYSTEM_H_
|
||||
#define SUBSYSTEM_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:
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::SUBSYSTEM;
|
||||
static const ReturnValue_t SEQUENCE_ALREADY_EXISTS = MAKE_RETURN_CODE(0x01);
|
||||
static const ReturnValue_t TABLE_ALREADY_EXISTS = MAKE_RETURN_CODE(0x02);
|
||||
static const ReturnValue_t TABLE_DOES_NOT_EXIST = MAKE_RETURN_CODE(0x03);
|
||||
static const ReturnValue_t TABLE_OR_SEQUENCE_LENGTH_INVALID = MAKE_RETURN_CODE(0x04);
|
||||
static const ReturnValue_t SEQUENCE_DOES_NOT_EXIST = MAKE_RETURN_CODE(0x05);
|
||||
static const ReturnValue_t TABLE_CONTAINS_INVALID_OBJECT_ID =
|
||||
MAKE_RETURN_CODE(0x06);
|
||||
static const ReturnValue_t FALLBACK_SEQUENCE_DOES_NOT_EXIST =
|
||||
MAKE_RETURN_CODE(0x07);
|
||||
static const ReturnValue_t NO_TARGET_TABLE = MAKE_RETURN_CODE(0x08);
|
||||
static const ReturnValue_t SEQUENCE_OR_TABLE_TOO_LONG = MAKE_RETURN_CODE(0x09);
|
||||
static const ReturnValue_t IS_FALLBACK_SEQUENCE = MAKE_RETURN_CODE(0x0B);
|
||||
static const ReturnValue_t ACCESS_DENIED = MAKE_RETURN_CODE(0x0C);
|
||||
static const ReturnValue_t TABLE_IN_USE = MAKE_RETURN_CODE(0x0E);
|
||||
|
||||
static const ReturnValue_t TARGET_TABLE_NOT_REACHED = MAKE_RETURN_CODE(0xA1);
|
||||
static const ReturnValue_t TABLE_CHECK_FAILED = MAKE_RETURN_CODE(0xA2);
|
||||
|
||||
|
||||
|
||||
Subsystem(object_id_t setObjectId, object_id_t parent,
|
||||
uint32_t maxNumberOfSequences, uint32_t maxNumberOfTables);
|
||||
virtual ~Subsystem();
|
||||
|
||||
ReturnValue_t addSequence(ArrayList<ModeListEntry>* sequence, Mode_t id,
|
||||
Mode_t fallbackSequence, bool inStore = true, bool preInit = true);
|
||||
|
||||
ReturnValue_t addTable(ArrayList<ModeListEntry> *table, Mode_t id,
|
||||
bool inStore = true, bool preInit = true);
|
||||
|
||||
void setInitialMode(Mode_t mode);
|
||||
|
||||
virtual ReturnValue_t initialize();
|
||||
|
||||
virtual ReturnValue_t checkObjectConnections();
|
||||
|
||||
virtual MessageQueueId_t getSequenceCommandQueue() const;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* 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 {
|
||||
bool islinked;
|
||||
union {
|
||||
ModeListEntry *firstLinkedElement;
|
||||
ArrayList<ModeListEntry> *array;
|
||||
};
|
||||
};
|
||||
|
||||
struct SequenceInfo {
|
||||
Mode_t fallbackSequence;
|
||||
EntryPointer entries;
|
||||
};
|
||||
|
||||
static const uint8_t MAX_NUMBER_OF_TABLES_OR_SEQUENCES = 70;
|
||||
|
||||
static const uint8_t MAX_LENGTH_OF_TABLE_OR_SEQUENCE = 20;
|
||||
|
||||
bool isInTransition;
|
||||
|
||||
bool childrenChangedHealth;
|
||||
|
||||
uint32_t uptimeStartTable = 0;
|
||||
|
||||
HybridIterator<ModeListEntry> currentTargetTable;
|
||||
|
||||
Mode_t targetMode;
|
||||
|
||||
Submode_t targetSubmode;
|
||||
|
||||
Mode_t initialMode;
|
||||
|
||||
HybridIterator<ModeListEntry> currentSequenceIterator;
|
||||
|
||||
FixedMap<Mode_t, EntryPointer> modeTables;
|
||||
|
||||
FixedMap<Mode_t, SequenceInfo> modeSequences;
|
||||
|
||||
StorageManagerIF *IPCStore = nullptr;
|
||||
|
||||
#ifdef USE_MODESTORE
|
||||
ModeStoreIF *modeStore = nullptr;
|
||||
#endif
|
||||
|
||||
bool existsModeSequence(Mode_t id);
|
||||
|
||||
HybridIterator<ModeListEntry> getSequence(Mode_t id);
|
||||
|
||||
bool existsModeTable(Mode_t id);
|
||||
|
||||
HybridIterator<ModeListEntry> getTable(Mode_t id);
|
||||
|
||||
HybridIterator<ModeListEntry> getCurrentTable();
|
||||
|
||||
// void startSequence(Mode_t sequence);
|
||||
|
||||
/**
|
||||
* DO NOT USE ON NON EXISTING SEQUENCE
|
||||
*
|
||||
* @param a sequence
|
||||
* @return the fallback sequence's Id
|
||||
*/
|
||||
Mode_t getFallbackSequence(Mode_t sequence);
|
||||
|
||||
void replyToCommand(ReturnValue_t status, uint32_t parameter);
|
||||
|
||||
ReturnValue_t deleteSequence(Mode_t id);
|
||||
|
||||
ReturnValue_t deleteTable(Mode_t id);
|
||||
|
||||
virtual void performChildOperation();
|
||||
|
||||
virtual ReturnValue_t handleCommandMessage(CommandMessage *message);
|
||||
|
||||
bool isFallbackSequence(Mode_t SequenceId);
|
||||
|
||||
bool isTableUsed(Mode_t tableId);
|
||||
|
||||
virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
|
||||
uint32_t *msToReachTheMode);
|
||||
|
||||
virtual void startTransition(Mode_t mode, Submode_t submode);
|
||||
|
||||
void sendSerializablesAsCommandMessage(Command_t command, SerializeIF **elements, uint8_t count);
|
||||
|
||||
void transitionFailed(ReturnValue_t failureCode, uint32_t parameter);
|
||||
|
||||
void cantKeepMode();
|
||||
|
||||
};
|
||||
|
||||
#endif /* SUBSYSTEM_H_ */
|
||||
#ifndef SUBSYSTEM_H_
|
||||
#define SUBSYSTEM_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:
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::SUBSYSTEM;
|
||||
static const ReturnValue_t SEQUENCE_ALREADY_EXISTS = MAKE_RETURN_CODE(0x01);
|
||||
static const ReturnValue_t TABLE_ALREADY_EXISTS = MAKE_RETURN_CODE(0x02);
|
||||
static const ReturnValue_t TABLE_DOES_NOT_EXIST = MAKE_RETURN_CODE(0x03);
|
||||
static const ReturnValue_t TABLE_OR_SEQUENCE_LENGTH_INVALID = MAKE_RETURN_CODE(0x04);
|
||||
static const ReturnValue_t SEQUENCE_DOES_NOT_EXIST = MAKE_RETURN_CODE(0x05);
|
||||
static const ReturnValue_t TABLE_CONTAINS_INVALID_OBJECT_ID =
|
||||
MAKE_RETURN_CODE(0x06);
|
||||
static const ReturnValue_t FALLBACK_SEQUENCE_DOES_NOT_EXIST =
|
||||
MAKE_RETURN_CODE(0x07);
|
||||
static const ReturnValue_t NO_TARGET_TABLE = MAKE_RETURN_CODE(0x08);
|
||||
static const ReturnValue_t SEQUENCE_OR_TABLE_TOO_LONG = MAKE_RETURN_CODE(0x09);
|
||||
static const ReturnValue_t IS_FALLBACK_SEQUENCE = MAKE_RETURN_CODE(0x0B);
|
||||
static const ReturnValue_t ACCESS_DENIED = MAKE_RETURN_CODE(0x0C);
|
||||
static const ReturnValue_t TABLE_IN_USE = MAKE_RETURN_CODE(0x0E);
|
||||
|
||||
static const ReturnValue_t TARGET_TABLE_NOT_REACHED = MAKE_RETURN_CODE(0xA1);
|
||||
static const ReturnValue_t TABLE_CHECK_FAILED = MAKE_RETURN_CODE(0xA2);
|
||||
|
||||
|
||||
|
||||
Subsystem(object_id_t setObjectId, object_id_t parent,
|
||||
uint32_t maxNumberOfSequences, uint32_t maxNumberOfTables);
|
||||
virtual ~Subsystem();
|
||||
|
||||
ReturnValue_t addSequence(ArrayList<ModeListEntry>* sequence, Mode_t id,
|
||||
Mode_t fallbackSequence, bool inStore = true, bool preInit = true);
|
||||
|
||||
ReturnValue_t addTable(ArrayList<ModeListEntry> *table, Mode_t id,
|
||||
bool inStore = true, bool preInit = true);
|
||||
|
||||
void setInitialMode(Mode_t mode);
|
||||
|
||||
virtual ReturnValue_t initialize();
|
||||
|
||||
virtual ReturnValue_t checkObjectConnections();
|
||||
|
||||
virtual MessageQueueId_t getSequenceCommandQueue() const;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* 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 {
|
||||
bool islinked;
|
||||
union {
|
||||
ModeListEntry *firstLinkedElement;
|
||||
ArrayList<ModeListEntry> *array;
|
||||
};
|
||||
};
|
||||
|
||||
struct SequenceInfo {
|
||||
Mode_t fallbackSequence;
|
||||
EntryPointer entries;
|
||||
};
|
||||
|
||||
static const uint8_t MAX_NUMBER_OF_TABLES_OR_SEQUENCES = 70;
|
||||
|
||||
static const uint8_t MAX_LENGTH_OF_TABLE_OR_SEQUENCE = 20;
|
||||
|
||||
bool isInTransition;
|
||||
|
||||
bool childrenChangedHealth;
|
||||
|
||||
uint32_t uptimeStartTable = 0;
|
||||
|
||||
HybridIterator<ModeListEntry> currentTargetTable;
|
||||
|
||||
Mode_t targetMode;
|
||||
|
||||
Submode_t targetSubmode;
|
||||
|
||||
Mode_t initialMode;
|
||||
|
||||
HybridIterator<ModeListEntry> currentSequenceIterator;
|
||||
|
||||
FixedMap<Mode_t, EntryPointer> modeTables;
|
||||
|
||||
FixedMap<Mode_t, SequenceInfo> modeSequences;
|
||||
|
||||
StorageManagerIF *IPCStore = nullptr;
|
||||
|
||||
#ifdef USE_MODESTORE
|
||||
ModeStoreIF *modeStore = nullptr;
|
||||
#endif
|
||||
|
||||
bool existsModeSequence(Mode_t id);
|
||||
|
||||
HybridIterator<ModeListEntry> getSequence(Mode_t id);
|
||||
|
||||
bool existsModeTable(Mode_t id);
|
||||
|
||||
HybridIterator<ModeListEntry> getTable(Mode_t id);
|
||||
|
||||
HybridIterator<ModeListEntry> getCurrentTable();
|
||||
|
||||
// void startSequence(Mode_t sequence);
|
||||
|
||||
/**
|
||||
* DO NOT USE ON NON EXISTING SEQUENCE
|
||||
*
|
||||
* @param a sequence
|
||||
* @return the fallback sequence's Id
|
||||
*/
|
||||
Mode_t getFallbackSequence(Mode_t sequence);
|
||||
|
||||
void replyToCommand(ReturnValue_t status, uint32_t parameter);
|
||||
|
||||
ReturnValue_t deleteSequence(Mode_t id);
|
||||
|
||||
ReturnValue_t deleteTable(Mode_t id);
|
||||
|
||||
virtual void performChildOperation();
|
||||
|
||||
virtual ReturnValue_t handleCommandMessage(CommandMessage *message);
|
||||
|
||||
bool isFallbackSequence(Mode_t SequenceId);
|
||||
|
||||
bool isTableUsed(Mode_t tableId);
|
||||
|
||||
virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
|
||||
uint32_t *msToReachTheMode);
|
||||
|
||||
virtual void startTransition(Mode_t mode, Submode_t submode);
|
||||
|
||||
void sendSerializablesAsCommandMessage(Command_t command, SerializeIF **elements, uint8_t count);
|
||||
|
||||
void transitionFailed(ReturnValue_t failureCode, uint32_t parameter);
|
||||
|
||||
void cantKeepMode();
|
||||
|
||||
};
|
||||
|
||||
#endif /* SUBSYSTEM_H_ */
|
||||
|
@ -1,356 +1,356 @@
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../serviceinterface/ServiceInterfaceStream.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,
|
||||
MessageQueueMessage::MAX_MESSAGE_SIZE);
|
||||
}
|
||||
|
||||
SubsystemBase::~SubsystemBase() {
|
||||
QueueFactory::instance()->deleteMessageQueue(commandQueue);
|
||||
|
||||
}
|
||||
|
||||
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).
|
||||
HasHealthIF* healthChild = objectManager->get<HasHealthIF>(objectId);
|
||||
if (child == nullptr) {
|
||||
if (healthChild == nullptr) {
|
||||
return CHILD_DOESNT_HAVE_MODES;
|
||||
} else {
|
||||
info.commandQueue = healthChild->getCommandQueue();
|
||||
info.mode = MODE_OFF;
|
||||
}
|
||||
} else {
|
||||
info.commandQueue = child->getCommandQueue();
|
||||
info.mode = -1; //intentional to force an initial command during system startup
|
||||
}
|
||||
|
||||
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)) {
|
||||
return COULD_NOT_INSERT_CHILD;
|
||||
} else {
|
||||
return RETURN_OK;
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t SubsystemBase::checkStateAgainstTable(
|
||||
HybridIterator<ModeListEntry> tableIter, Submode_t targetSubmode) {
|
||||
|
||||
std::map<object_id_t, ChildInfo>::iterator childIter;
|
||||
|
||||
for (; tableIter.value != NULL; ++tableIter) {
|
||||
object_id_t object = tableIter.value->getObject();
|
||||
|
||||
if ((childIter = childrenMap.find(object)) == childrenMap.end()) {
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
if (childIter->second.mode != tableIter.value->getMode()) {
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
Submode_t submodeToCheckAgainst = tableIter.value->getSubmode();
|
||||
if (tableIter.value->inheritSubmode()) {
|
||||
submodeToCheckAgainst = targetSubmode;
|
||||
}
|
||||
|
||||
if (childIter->second.submode != submodeToCheckAgainst) {
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
void SubsystemBase::executeTable(HybridIterator<ModeListEntry> tableIter,
|
||||
Submode_t targetSubmode) {
|
||||
CommandMessage command;
|
||||
|
||||
std::map<object_id_t, ChildInfo>::iterator iter;
|
||||
|
||||
commandsOutstanding = 0;
|
||||
|
||||
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
|
||||
sif::debug << std::hex << getObjectId() << ": invalid mode table entry"
|
||||
<< std::endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
Submode_t submodeToCommand = tableIter.value->getSubmode();
|
||||
if (tableIter.value->inheritSubmode()) {
|
||||
submodeToCommand = targetSubmode;
|
||||
}
|
||||
|
||||
if (healthHelper.healthTable->hasHealth(object)) {
|
||||
if (healthHelper.healthTable->isFaulty(object)) {
|
||||
ModeMessage::setModeMessage(&command,
|
||||
ModeMessage::CMD_MODE_COMMAND, HasModesIF::MODE_OFF,
|
||||
SUBMODE_NONE);
|
||||
} else {
|
||||
if (modeHelper.isForced()) {
|
||||
ModeMessage::setModeMessage(&command,
|
||||
ModeMessage::CMD_MODE_COMMAND_FORCED,
|
||||
tableIter.value->getMode(), submodeToCommand);
|
||||
} else {
|
||||
if (healthHelper.healthTable->isCommandable(object)) {
|
||||
ModeMessage::setModeMessage(&command,
|
||||
ModeMessage::CMD_MODE_COMMAND,
|
||||
tableIter.value->getMode(), submodeToCommand);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ModeMessage::setModeMessage(&command, ModeMessage::CMD_MODE_COMMAND,
|
||||
tableIter.value->getMode(), submodeToCommand);
|
||||
}
|
||||
|
||||
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, &command);
|
||||
if (result == RETURN_OK) {
|
||||
++commandsOutstanding;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ReturnValue_t SubsystemBase::updateChildMode(MessageQueueId_t queue,
|
||||
Mode_t mode, Submode_t submode) {
|
||||
std::map<object_id_t, ChildInfo>::iterator iter;
|
||||
|
||||
for (iter = childrenMap.begin(); iter != childrenMap.end(); iter++) {
|
||||
if (iter->second.commandQueue == queue) {
|
||||
iter->second.mode = mode;
|
||||
iter->second.submode = submode;
|
||||
return RETURN_OK;
|
||||
}
|
||||
}
|
||||
return CHILD_NOT_FOUND;
|
||||
}
|
||||
|
||||
ReturnValue_t SubsystemBase::updateChildChangedHealth(MessageQueueId_t queue,
|
||||
bool changedHealth) {
|
||||
for (auto iter = childrenMap.begin(); iter != childrenMap.end(); iter++) {
|
||||
if (iter->second.commandQueue == queue) {
|
||||
iter->second.healthChanged = changedHealth;
|
||||
return RETURN_OK;
|
||||
}
|
||||
}
|
||||
return CHILD_NOT_FOUND;
|
||||
}
|
||||
|
||||
MessageQueueId_t SubsystemBase::getCommandQueue() const {
|
||||
return commandQueue->getId();
|
||||
}
|
||||
|
||||
ReturnValue_t SubsystemBase::initialize() {
|
||||
MessageQueueId_t parentQueue = 0;
|
||||
ReturnValue_t result = SystemObject::initialize();
|
||||
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (parentId != 0) {
|
||||
SubsystemBase *parent = objectManager->get<SubsystemBase>(parentId);
|
||||
if (parent == NULL) {
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
parentQueue = parent->getCommandQueue();
|
||||
|
||||
parent->registerChild(getObjectId());
|
||||
}
|
||||
|
||||
result = healthHelper.initialize(parentQueue);
|
||||
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = modeHelper.initialize(parentQueue);
|
||||
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t SubsystemBase::performOperation(uint8_t opCode) {
|
||||
|
||||
childrenChangedMode = false;
|
||||
|
||||
checkCommandQueue();
|
||||
|
||||
performChildOperation();
|
||||
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t SubsystemBase::handleModeReply(CommandMessage* message) {
|
||||
switch (message->getCommand()) {
|
||||
case ModeMessage::REPLY_MODE_INFO:
|
||||
updateChildMode(message->getSender(), ModeMessage::getMode(message),
|
||||
ModeMessage::getSubmode(message));
|
||||
childrenChangedMode = true;
|
||||
return RETURN_OK;
|
||||
case ModeMessage::REPLY_MODE_REPLY:
|
||||
case ModeMessage::REPLY_WRONG_MODE_REPLY:
|
||||
updateChildMode(message->getSender(), ModeMessage::getMode(message),
|
||||
ModeMessage::getSubmode(message));
|
||||
childrenChangedMode = true;
|
||||
commandsOutstanding--;
|
||||
return RETURN_OK;
|
||||
case ModeMessage::REPLY_CANT_REACH_MODE:
|
||||
commandsOutstanding--;
|
||||
{
|
||||
for (auto iter = childrenMap.begin(); iter != childrenMap.end();
|
||||
iter++) {
|
||||
if (iter->second.commandQueue == message->getSender()) {
|
||||
triggerEvent(MODE_CMD_REJECTED, iter->first,
|
||||
message->getParameter());
|
||||
}
|
||||
}
|
||||
}
|
||||
return RETURN_OK;
|
||||
// case ModeMessage::CMD_MODE_COMMAND:
|
||||
// handleCommandedMode(message);
|
||||
// return RETURN_OK;
|
||||
// case ModeMessage::CMD_MODE_ANNOUNCE:
|
||||
// triggerEvent(MODE_INFO, mode, submode);
|
||||
// return RETURN_OK;
|
||||
// case ModeMessage::CMD_MODE_ANNOUNCE_RECURSIVELY:
|
||||
// triggerEvent(MODE_INFO, mode, submode);
|
||||
// commandAllChildren(message);
|
||||
// return RETURN_OK;
|
||||
default:
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t SubsystemBase::checkTable(
|
||||
HybridIterator<ModeListEntry> tableIter) {
|
||||
for (; tableIter.value != NULL; ++tableIter) {
|
||||
if (childrenMap.find(tableIter.value->getObject())
|
||||
== childrenMap.end()) {
|
||||
return TABLE_CONTAINS_INVALID_OBJECT_ID;
|
||||
}
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
void SubsystemBase::replyToCommand(CommandMessage* message) {
|
||||
commandQueue->reply(message);
|
||||
}
|
||||
|
||||
void SubsystemBase::setMode(Mode_t newMode, Submode_t newSubmode) {
|
||||
modeHelper.modeChanged(newMode, newSubmode);
|
||||
mode = newMode;
|
||||
submode = newSubmode;
|
||||
modeChanged();
|
||||
announceMode(false);
|
||||
}
|
||||
|
||||
void SubsystemBase::setMode(Mode_t newMode) {
|
||||
setMode(newMode, submode);
|
||||
}
|
||||
|
||||
void SubsystemBase::commandAllChildren(CommandMessage* message) {
|
||||
std::map<object_id_t, ChildInfo>::iterator iter;
|
||||
for (iter = childrenMap.begin(); iter != childrenMap.end(); ++iter) {
|
||||
commandQueue->sendMessage(iter->second.commandQueue, message);
|
||||
}
|
||||
}
|
||||
|
||||
void SubsystemBase::getMode(Mode_t* mode, Submode_t* submode) {
|
||||
*mode = this->mode;
|
||||
*submode = this->submode;
|
||||
}
|
||||
|
||||
void SubsystemBase::setToExternalControl() {
|
||||
healthHelper.setHealth(EXTERNAL_CONTROL);
|
||||
}
|
||||
|
||||
void SubsystemBase::announceMode(bool recursive) {
|
||||
triggerEvent(MODE_INFO, mode, submode);
|
||||
if (recursive) {
|
||||
CommandMessage command;
|
||||
ModeMessage::setModeMessage(&command,
|
||||
ModeMessage::CMD_MODE_ANNOUNCE_RECURSIVELY, 0, 0);
|
||||
commandAllChildren(&command);
|
||||
}
|
||||
}
|
||||
|
||||
void SubsystemBase::checkCommandQueue() {
|
||||
ReturnValue_t result;
|
||||
CommandMessage command;
|
||||
|
||||
for (result = commandQueue->receiveMessage(&command); result == RETURN_OK;
|
||||
result = commandQueue->receiveMessage(&command)) {
|
||||
|
||||
result = healthHelper.handleHealthCommand(&command);
|
||||
if (result == RETURN_OK) {
|
||||
continue;
|
||||
}
|
||||
|
||||
result = modeHelper.handleModeCommand(&command);
|
||||
if (result == RETURN_OK) {
|
||||
continue;
|
||||
}
|
||||
|
||||
result = handleModeReply(&command);
|
||||
if (result == RETURN_OK) {
|
||||
continue;
|
||||
}
|
||||
|
||||
result = handleCommandMessage(&command);
|
||||
if (result != RETURN_OK) {
|
||||
CommandMessage reply;
|
||||
reply.setReplyRejected(CommandMessage::UNKNOWN_COMMAND,
|
||||
command.getCommand());
|
||||
replyToCommand(&reply);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t SubsystemBase::setHealth(HealthState health) {
|
||||
switch (health) {
|
||||
case HEALTHY:
|
||||
case EXTERNAL_CONTROL:
|
||||
healthHelper.setHealth(health);
|
||||
return RETURN_OK;
|
||||
default:
|
||||
return INVALID_HEALTH_STATE;
|
||||
}
|
||||
}
|
||||
|
||||
HasHealthIF::HealthState SubsystemBase::getHealth() {
|
||||
return healthHelper.getHealth();
|
||||
}
|
||||
|
||||
void SubsystemBase::modeChanged() {
|
||||
}
|
||||
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../serviceinterface/ServiceInterfaceStream.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,
|
||||
MessageQueueMessage::MAX_MESSAGE_SIZE);
|
||||
}
|
||||
|
||||
SubsystemBase::~SubsystemBase() {
|
||||
QueueFactory::instance()->deleteMessageQueue(commandQueue);
|
||||
|
||||
}
|
||||
|
||||
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).
|
||||
HasHealthIF* healthChild = objectManager->get<HasHealthIF>(objectId);
|
||||
if (child == nullptr) {
|
||||
if (healthChild == nullptr) {
|
||||
return CHILD_DOESNT_HAVE_MODES;
|
||||
} else {
|
||||
info.commandQueue = healthChild->getCommandQueue();
|
||||
info.mode = MODE_OFF;
|
||||
}
|
||||
} else {
|
||||
info.commandQueue = child->getCommandQueue();
|
||||
info.mode = -1; //intentional to force an initial command during system startup
|
||||
}
|
||||
|
||||
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)) {
|
||||
return COULD_NOT_INSERT_CHILD;
|
||||
} else {
|
||||
return RETURN_OK;
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t SubsystemBase::checkStateAgainstTable(
|
||||
HybridIterator<ModeListEntry> tableIter, Submode_t targetSubmode) {
|
||||
|
||||
std::map<object_id_t, ChildInfo>::iterator childIter;
|
||||
|
||||
for (; tableIter.value != NULL; ++tableIter) {
|
||||
object_id_t object = tableIter.value->getObject();
|
||||
|
||||
if ((childIter = childrenMap.find(object)) == childrenMap.end()) {
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
if (childIter->second.mode != tableIter.value->getMode()) {
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
Submode_t submodeToCheckAgainst = tableIter.value->getSubmode();
|
||||
if (tableIter.value->inheritSubmode()) {
|
||||
submodeToCheckAgainst = targetSubmode;
|
||||
}
|
||||
|
||||
if (childIter->second.submode != submodeToCheckAgainst) {
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
void SubsystemBase::executeTable(HybridIterator<ModeListEntry> tableIter,
|
||||
Submode_t targetSubmode) {
|
||||
CommandMessage command;
|
||||
|
||||
std::map<object_id_t, ChildInfo>::iterator iter;
|
||||
|
||||
commandsOutstanding = 0;
|
||||
|
||||
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
|
||||
sif::debug << std::hex << getObjectId() << ": invalid mode table entry"
|
||||
<< std::endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
Submode_t submodeToCommand = tableIter.value->getSubmode();
|
||||
if (tableIter.value->inheritSubmode()) {
|
||||
submodeToCommand = targetSubmode;
|
||||
}
|
||||
|
||||
if (healthHelper.healthTable->hasHealth(object)) {
|
||||
if (healthHelper.healthTable->isFaulty(object)) {
|
||||
ModeMessage::setModeMessage(&command,
|
||||
ModeMessage::CMD_MODE_COMMAND, HasModesIF::MODE_OFF,
|
||||
SUBMODE_NONE);
|
||||
} else {
|
||||
if (modeHelper.isForced()) {
|
||||
ModeMessage::setModeMessage(&command,
|
||||
ModeMessage::CMD_MODE_COMMAND_FORCED,
|
||||
tableIter.value->getMode(), submodeToCommand);
|
||||
} else {
|
||||
if (healthHelper.healthTable->isCommandable(object)) {
|
||||
ModeMessage::setModeMessage(&command,
|
||||
ModeMessage::CMD_MODE_COMMAND,
|
||||
tableIter.value->getMode(), submodeToCommand);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ModeMessage::setModeMessage(&command, ModeMessage::CMD_MODE_COMMAND,
|
||||
tableIter.value->getMode(), submodeToCommand);
|
||||
}
|
||||
|
||||
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, &command);
|
||||
if (result == RETURN_OK) {
|
||||
++commandsOutstanding;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ReturnValue_t SubsystemBase::updateChildMode(MessageQueueId_t queue,
|
||||
Mode_t mode, Submode_t submode) {
|
||||
std::map<object_id_t, ChildInfo>::iterator iter;
|
||||
|
||||
for (iter = childrenMap.begin(); iter != childrenMap.end(); iter++) {
|
||||
if (iter->second.commandQueue == queue) {
|
||||
iter->second.mode = mode;
|
||||
iter->second.submode = submode;
|
||||
return RETURN_OK;
|
||||
}
|
||||
}
|
||||
return CHILD_NOT_FOUND;
|
||||
}
|
||||
|
||||
ReturnValue_t SubsystemBase::updateChildChangedHealth(MessageQueueId_t queue,
|
||||
bool changedHealth) {
|
||||
for (auto iter = childrenMap.begin(); iter != childrenMap.end(); iter++) {
|
||||
if (iter->second.commandQueue == queue) {
|
||||
iter->second.healthChanged = changedHealth;
|
||||
return RETURN_OK;
|
||||
}
|
||||
}
|
||||
return CHILD_NOT_FOUND;
|
||||
}
|
||||
|
||||
MessageQueueId_t SubsystemBase::getCommandQueue() const {
|
||||
return commandQueue->getId();
|
||||
}
|
||||
|
||||
ReturnValue_t SubsystemBase::initialize() {
|
||||
MessageQueueId_t parentQueue = 0;
|
||||
ReturnValue_t result = SystemObject::initialize();
|
||||
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (parentId != 0) {
|
||||
SubsystemBase *parent = objectManager->get<SubsystemBase>(parentId);
|
||||
if (parent == NULL) {
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
parentQueue = parent->getCommandQueue();
|
||||
|
||||
parent->registerChild(getObjectId());
|
||||
}
|
||||
|
||||
result = healthHelper.initialize(parentQueue);
|
||||
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = modeHelper.initialize(parentQueue);
|
||||
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t SubsystemBase::performOperation(uint8_t opCode) {
|
||||
|
||||
childrenChangedMode = false;
|
||||
|
||||
checkCommandQueue();
|
||||
|
||||
performChildOperation();
|
||||
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t SubsystemBase::handleModeReply(CommandMessage* message) {
|
||||
switch (message->getCommand()) {
|
||||
case ModeMessage::REPLY_MODE_INFO:
|
||||
updateChildMode(message->getSender(), ModeMessage::getMode(message),
|
||||
ModeMessage::getSubmode(message));
|
||||
childrenChangedMode = true;
|
||||
return RETURN_OK;
|
||||
case ModeMessage::REPLY_MODE_REPLY:
|
||||
case ModeMessage::REPLY_WRONG_MODE_REPLY:
|
||||
updateChildMode(message->getSender(), ModeMessage::getMode(message),
|
||||
ModeMessage::getSubmode(message));
|
||||
childrenChangedMode = true;
|
||||
commandsOutstanding--;
|
||||
return RETURN_OK;
|
||||
case ModeMessage::REPLY_CANT_REACH_MODE:
|
||||
commandsOutstanding--;
|
||||
{
|
||||
for (auto iter = childrenMap.begin(); iter != childrenMap.end();
|
||||
iter++) {
|
||||
if (iter->second.commandQueue == message->getSender()) {
|
||||
triggerEvent(MODE_CMD_REJECTED, iter->first,
|
||||
message->getParameter());
|
||||
}
|
||||
}
|
||||
}
|
||||
return RETURN_OK;
|
||||
// case ModeMessage::CMD_MODE_COMMAND:
|
||||
// handleCommandedMode(message);
|
||||
// return RETURN_OK;
|
||||
// case ModeMessage::CMD_MODE_ANNOUNCE:
|
||||
// triggerEvent(MODE_INFO, mode, submode);
|
||||
// return RETURN_OK;
|
||||
// case ModeMessage::CMD_MODE_ANNOUNCE_RECURSIVELY:
|
||||
// triggerEvent(MODE_INFO, mode, submode);
|
||||
// commandAllChildren(message);
|
||||
// return RETURN_OK;
|
||||
default:
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t SubsystemBase::checkTable(
|
||||
HybridIterator<ModeListEntry> tableIter) {
|
||||
for (; tableIter.value != NULL; ++tableIter) {
|
||||
if (childrenMap.find(tableIter.value->getObject())
|
||||
== childrenMap.end()) {
|
||||
return TABLE_CONTAINS_INVALID_OBJECT_ID;
|
||||
}
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
void SubsystemBase::replyToCommand(CommandMessage* message) {
|
||||
commandQueue->reply(message);
|
||||
}
|
||||
|
||||
void SubsystemBase::setMode(Mode_t newMode, Submode_t newSubmode) {
|
||||
modeHelper.modeChanged(newMode, newSubmode);
|
||||
mode = newMode;
|
||||
submode = newSubmode;
|
||||
modeChanged();
|
||||
announceMode(false);
|
||||
}
|
||||
|
||||
void SubsystemBase::setMode(Mode_t newMode) {
|
||||
setMode(newMode, submode);
|
||||
}
|
||||
|
||||
void SubsystemBase::commandAllChildren(CommandMessage* message) {
|
||||
std::map<object_id_t, ChildInfo>::iterator iter;
|
||||
for (iter = childrenMap.begin(); iter != childrenMap.end(); ++iter) {
|
||||
commandQueue->sendMessage(iter->second.commandQueue, message);
|
||||
}
|
||||
}
|
||||
|
||||
void SubsystemBase::getMode(Mode_t* mode, Submode_t* submode) {
|
||||
*mode = this->mode;
|
||||
*submode = this->submode;
|
||||
}
|
||||
|
||||
void SubsystemBase::setToExternalControl() {
|
||||
healthHelper.setHealth(EXTERNAL_CONTROL);
|
||||
}
|
||||
|
||||
void SubsystemBase::announceMode(bool recursive) {
|
||||
triggerEvent(MODE_INFO, mode, submode);
|
||||
if (recursive) {
|
||||
CommandMessage command;
|
||||
ModeMessage::setModeMessage(&command,
|
||||
ModeMessage::CMD_MODE_ANNOUNCE_RECURSIVELY, 0, 0);
|
||||
commandAllChildren(&command);
|
||||
}
|
||||
}
|
||||
|
||||
void SubsystemBase::checkCommandQueue() {
|
||||
ReturnValue_t result;
|
||||
CommandMessage command;
|
||||
|
||||
for (result = commandQueue->receiveMessage(&command); result == RETURN_OK;
|
||||
result = commandQueue->receiveMessage(&command)) {
|
||||
|
||||
result = healthHelper.handleHealthCommand(&command);
|
||||
if (result == RETURN_OK) {
|
||||
continue;
|
||||
}
|
||||
|
||||
result = modeHelper.handleModeCommand(&command);
|
||||
if (result == RETURN_OK) {
|
||||
continue;
|
||||
}
|
||||
|
||||
result = handleModeReply(&command);
|
||||
if (result == RETURN_OK) {
|
||||
continue;
|
||||
}
|
||||
|
||||
result = handleCommandMessage(&command);
|
||||
if (result != RETURN_OK) {
|
||||
CommandMessage reply;
|
||||
reply.setReplyRejected(CommandMessage::UNKNOWN_COMMAND,
|
||||
command.getCommand());
|
||||
replyToCommand(&reply);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t SubsystemBase::setHealth(HealthState health) {
|
||||
switch (health) {
|
||||
case HEALTHY:
|
||||
case EXTERNAL_CONTROL:
|
||||
healthHelper.setHealth(health);
|
||||
return RETURN_OK;
|
||||
default:
|
||||
return INVALID_HEALTH_STATE;
|
||||
}
|
||||
}
|
||||
|
||||
HasHealthIF::HealthState SubsystemBase::getHealth() {
|
||||
return healthHelper.getHealth();
|
||||
}
|
||||
|
||||
void SubsystemBase::modeChanged() {
|
||||
}
|
||||
|
||||
|
@ -1,129 +1,129 @@
|
||||
#ifndef SUBSYSTEMBASE_H_
|
||||
#define SUBSYSTEMBASE_H_
|
||||
|
||||
#include "../container/HybridIterator.h"
|
||||
#include "../health/HasHealthIF.h"
|
||||
#include "../health/HealthHelper.h"
|
||||
#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>
|
||||
|
||||
/**
|
||||
* @defgroup subsystems Subsystem Objects
|
||||
* Contains all Subsystem and Assemblies
|
||||
*/
|
||||
class SubsystemBase: public SystemObject,
|
||||
public HasModesIF,
|
||||
public HasHealthIF,
|
||||
public HasReturnvaluesIF,
|
||||
public ExecutableObjectIF {
|
||||
public:
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::SUBSYSTEM_BASE;
|
||||
static const ReturnValue_t CHILD_NOT_FOUND = MAKE_RETURN_CODE(0x01);
|
||||
static const ReturnValue_t CHILD_INFO_UPDATED = MAKE_RETURN_CODE(0x02);
|
||||
static const ReturnValue_t CHILD_DOESNT_HAVE_MODES = MAKE_RETURN_CODE(0x03);
|
||||
static const ReturnValue_t COULD_NOT_INSERT_CHILD = MAKE_RETURN_CODE(0x04);
|
||||
static const ReturnValue_t TABLE_CONTAINS_INVALID_OBJECT_ID =
|
||||
MAKE_RETURN_CODE(0x05);
|
||||
|
||||
SubsystemBase(object_id_t setObjectId, object_id_t parent,
|
||||
Mode_t initialMode = 0, uint16_t commandQueueDepth = 8);
|
||||
virtual ~SubsystemBase();
|
||||
|
||||
virtual MessageQueueId_t getCommandQueue() const;
|
||||
|
||||
ReturnValue_t registerChild(object_id_t objectId);
|
||||
|
||||
virtual ReturnValue_t initialize();
|
||||
|
||||
virtual ReturnValue_t performOperation(uint8_t opCode);
|
||||
|
||||
virtual ReturnValue_t setHealth(HealthState health);
|
||||
|
||||
virtual HasHealthIF::HealthState getHealth();
|
||||
|
||||
protected:
|
||||
struct ChildInfo {
|
||||
MessageQueueId_t commandQueue;
|
||||
Mode_t mode;
|
||||
Submode_t submode;bool healthChanged;
|
||||
};
|
||||
|
||||
Mode_t mode;
|
||||
|
||||
Submode_t submode;
|
||||
|
||||
bool childrenChangedMode;
|
||||
|
||||
/**
|
||||
* Always check this against <=0, so you are robust against too many replies
|
||||
*/
|
||||
int32_t commandsOutstanding;
|
||||
|
||||
MessageQueueIF* commandQueue;
|
||||
|
||||
HealthHelper healthHelper;
|
||||
|
||||
ModeHelper modeHelper;
|
||||
|
||||
const object_id_t parentId;
|
||||
|
||||
typedef std::map<object_id_t, ChildInfo> ChildrenMap;
|
||||
ChildrenMap childrenMap;
|
||||
|
||||
void checkCommandQueue();
|
||||
|
||||
/**
|
||||
* We need to know the target Submode, as children are able to inherit the submode
|
||||
*/
|
||||
ReturnValue_t checkStateAgainstTable(
|
||||
HybridIterator<ModeListEntry> tableIter, Submode_t targetSubmode);
|
||||
|
||||
/**
|
||||
* We need to know the target Submode, as children are able to inherit the submode
|
||||
* Still, we have a default for all child implementations which do not use submode inheritance
|
||||
*/
|
||||
void executeTable(HybridIterator<ModeListEntry> tableIter,
|
||||
Submode_t targetSubmode = SUBMODE_NONE);
|
||||
|
||||
ReturnValue_t updateChildMode(MessageQueueId_t queue, Mode_t mode,
|
||||
Submode_t submode);
|
||||
|
||||
ReturnValue_t updateChildChangedHealth(MessageQueueId_t queue,
|
||||
bool changedHealth = true);
|
||||
|
||||
virtual ReturnValue_t handleModeReply(CommandMessage *message);
|
||||
|
||||
void commandAllChildren(CommandMessage *message);
|
||||
|
||||
ReturnValue_t checkTable(HybridIterator<ModeListEntry> tableIter);
|
||||
|
||||
void replyToCommand(CommandMessage *message);
|
||||
|
||||
void setMode(Mode_t newMode, Submode_t newSubmode);
|
||||
|
||||
void setMode(Mode_t newMode);
|
||||
|
||||
virtual ReturnValue_t handleCommandMessage(CommandMessage *message) = 0;
|
||||
|
||||
virtual void performChildOperation() = 0;
|
||||
|
||||
virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
|
||||
uint32_t *msToReachTheMode) = 0;
|
||||
|
||||
virtual void startTransition(Mode_t mode, Submode_t submode) = 0;
|
||||
|
||||
virtual void getMode(Mode_t *mode, Submode_t *submode);
|
||||
|
||||
virtual void setToExternalControl();
|
||||
|
||||
virtual void announceMode(bool recursive);
|
||||
|
||||
virtual void modeChanged();
|
||||
};
|
||||
|
||||
#endif /* SUBSYSTEMBASE_H_ */
|
||||
#ifndef SUBSYSTEMBASE_H_
|
||||
#define SUBSYSTEMBASE_H_
|
||||
|
||||
#include "../container/HybridIterator.h"
|
||||
#include "../health/HasHealthIF.h"
|
||||
#include "../health/HealthHelper.h"
|
||||
#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>
|
||||
|
||||
/**
|
||||
* @defgroup subsystems Subsystem Objects
|
||||
* Contains all Subsystem and Assemblies
|
||||
*/
|
||||
class SubsystemBase: public SystemObject,
|
||||
public HasModesIF,
|
||||
public HasHealthIF,
|
||||
public HasReturnvaluesIF,
|
||||
public ExecutableObjectIF {
|
||||
public:
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::SUBSYSTEM_BASE;
|
||||
static const ReturnValue_t CHILD_NOT_FOUND = MAKE_RETURN_CODE(0x01);
|
||||
static const ReturnValue_t CHILD_INFO_UPDATED = MAKE_RETURN_CODE(0x02);
|
||||
static const ReturnValue_t CHILD_DOESNT_HAVE_MODES = MAKE_RETURN_CODE(0x03);
|
||||
static const ReturnValue_t COULD_NOT_INSERT_CHILD = MAKE_RETURN_CODE(0x04);
|
||||
static const ReturnValue_t TABLE_CONTAINS_INVALID_OBJECT_ID =
|
||||
MAKE_RETURN_CODE(0x05);
|
||||
|
||||
SubsystemBase(object_id_t setObjectId, object_id_t parent,
|
||||
Mode_t initialMode = 0, uint16_t commandQueueDepth = 8);
|
||||
virtual ~SubsystemBase();
|
||||
|
||||
virtual MessageQueueId_t getCommandQueue() const;
|
||||
|
||||
ReturnValue_t registerChild(object_id_t objectId);
|
||||
|
||||
virtual ReturnValue_t initialize();
|
||||
|
||||
virtual ReturnValue_t performOperation(uint8_t opCode);
|
||||
|
||||
virtual ReturnValue_t setHealth(HealthState health);
|
||||
|
||||
virtual HasHealthIF::HealthState getHealth();
|
||||
|
||||
protected:
|
||||
struct ChildInfo {
|
||||
MessageQueueId_t commandQueue;
|
||||
Mode_t mode;
|
||||
Submode_t submode;bool healthChanged;
|
||||
};
|
||||
|
||||
Mode_t mode;
|
||||
|
||||
Submode_t submode;
|
||||
|
||||
bool childrenChangedMode;
|
||||
|
||||
/**
|
||||
* Always check this against <=0, so you are robust against too many replies
|
||||
*/
|
||||
int32_t commandsOutstanding;
|
||||
|
||||
MessageQueueIF* commandQueue;
|
||||
|
||||
HealthHelper healthHelper;
|
||||
|
||||
ModeHelper modeHelper;
|
||||
|
||||
const object_id_t parentId;
|
||||
|
||||
typedef std::map<object_id_t, ChildInfo> ChildrenMap;
|
||||
ChildrenMap childrenMap;
|
||||
|
||||
void checkCommandQueue();
|
||||
|
||||
/**
|
||||
* We need to know the target Submode, as children are able to inherit the submode
|
||||
*/
|
||||
ReturnValue_t checkStateAgainstTable(
|
||||
HybridIterator<ModeListEntry> tableIter, Submode_t targetSubmode);
|
||||
|
||||
/**
|
||||
* We need to know the target Submode, as children are able to inherit the submode
|
||||
* Still, we have a default for all child implementations which do not use submode inheritance
|
||||
*/
|
||||
void executeTable(HybridIterator<ModeListEntry> tableIter,
|
||||
Submode_t targetSubmode = SUBMODE_NONE);
|
||||
|
||||
ReturnValue_t updateChildMode(MessageQueueId_t queue, Mode_t mode,
|
||||
Submode_t submode);
|
||||
|
||||
ReturnValue_t updateChildChangedHealth(MessageQueueId_t queue,
|
||||
bool changedHealth = true);
|
||||
|
||||
virtual ReturnValue_t handleModeReply(CommandMessage *message);
|
||||
|
||||
void commandAllChildren(CommandMessage *message);
|
||||
|
||||
ReturnValue_t checkTable(HybridIterator<ModeListEntry> tableIter);
|
||||
|
||||
void replyToCommand(CommandMessage *message);
|
||||
|
||||
void setMode(Mode_t newMode, Submode_t newSubmode);
|
||||
|
||||
void setMode(Mode_t newMode);
|
||||
|
||||
virtual ReturnValue_t handleCommandMessage(CommandMessage *message) = 0;
|
||||
|
||||
virtual void performChildOperation() = 0;
|
||||
|
||||
virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
|
||||
uint32_t *msToReachTheMode) = 0;
|
||||
|
||||
virtual void startTransition(Mode_t mode, Submode_t submode) = 0;
|
||||
|
||||
virtual void getMode(Mode_t *mode, Submode_t *submode);
|
||||
|
||||
virtual void setToExternalControl();
|
||||
|
||||
virtual void announceMode(bool recursive);
|
||||
|
||||
virtual void modeChanged();
|
||||
};
|
||||
|
||||
#endif /* SUBSYSTEMBASE_H_ */
|
||||
|
@ -1,20 +1,20 @@
|
||||
#ifndef HASMODESEQUENCEIF_H_
|
||||
#define HASMODESEQUENCEIF_H_
|
||||
|
||||
#include "../../subsystem/modes/ModeDefinitions.h"
|
||||
#include "../../subsystem/modes/ModeSequenceMessage.h"
|
||||
#include "../../subsystem/modes/ModeStoreIF.h"
|
||||
|
||||
|
||||
class HasModeSequenceIF {
|
||||
public:
|
||||
virtual ~HasModeSequenceIF() {
|
||||
|
||||
}
|
||||
|
||||
virtual MessageQueueId_t getSequenceCommandQueue() const = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* HASMODESEQUENCEIF_H_ */
|
||||
#ifndef HASMODESEQUENCEIF_H_
|
||||
#define HASMODESEQUENCEIF_H_
|
||||
|
||||
#include "../../subsystem/modes/ModeDefinitions.h"
|
||||
#include "../../subsystem/modes/ModeSequenceMessage.h"
|
||||
#include "../../subsystem/modes/ModeStoreIF.h"
|
||||
|
||||
|
||||
class HasModeSequenceIF {
|
||||
public:
|
||||
virtual ~HasModeSequenceIF() {
|
||||
|
||||
}
|
||||
|
||||
virtual MessageQueueId_t getSequenceCommandQueue() const = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* HASMODESEQUENCEIF_H_ */
|
||||
|
@ -1,152 +1,152 @@
|
||||
#ifndef MODEDEFINITIONS_H_
|
||||
#define 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) {
|
||||
|
||||
}
|
||||
|
||||
uint32_t value1;
|
||||
uint32_t value2;
|
||||
uint8_t value3;
|
||||
uint8_t value4;
|
||||
|
||||
virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size,
|
||||
size_t maxSize, Endianness streamEndianness) const {
|
||||
|
||||
ReturnValue_t result;
|
||||
|
||||
result = SerializeAdapter::serialize(&value1, buffer, size,
|
||||
maxSize, streamEndianness);
|
||||
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = SerializeAdapter::serialize(&value2, buffer, size,
|
||||
maxSize, streamEndianness);
|
||||
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = SerializeAdapter::serialize(&value3, buffer, size,
|
||||
maxSize, streamEndianness);
|
||||
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = SerializeAdapter::serialize(&value4, buffer, size,
|
||||
maxSize, streamEndianness);
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
virtual size_t getSerializedSize() const {
|
||||
return sizeof(value1) + sizeof(value2) + sizeof(value3) + sizeof(value4);
|
||||
}
|
||||
|
||||
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||
Endianness streamEndianness) {
|
||||
ReturnValue_t result;
|
||||
|
||||
result = SerializeAdapter::deSerialize(&value1, buffer, size,
|
||||
streamEndianness);
|
||||
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = SerializeAdapter::deSerialize(&value2, buffer, size,
|
||||
streamEndianness);
|
||||
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = SerializeAdapter::deSerialize(&value3, buffer, size,
|
||||
streamEndianness);
|
||||
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = SerializeAdapter::deSerialize(&value4, buffer, size,
|
||||
streamEndianness);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//for Sequences
|
||||
Mode_t getTableId() const {
|
||||
return value1;
|
||||
}
|
||||
|
||||
void setTableId(Mode_t tableId) {
|
||||
this->value1 = tableId;
|
||||
}
|
||||
|
||||
uint8_t getWaitSeconds() const {
|
||||
return value2;
|
||||
}
|
||||
|
||||
void setWaitSeconds(uint8_t waitSeconds) {
|
||||
this->value2 = waitSeconds;
|
||||
}
|
||||
|
||||
bool checkSuccess() const {
|
||||
return value3 == 1;
|
||||
}
|
||||
|
||||
void setCheckSuccess(bool checkSuccess) {
|
||||
this->value3 = checkSuccess;
|
||||
}
|
||||
|
||||
//for Tables
|
||||
object_id_t getObject() const {
|
||||
return value1;
|
||||
}
|
||||
|
||||
void setObject(object_id_t object) {
|
||||
this->value1 = object;
|
||||
}
|
||||
|
||||
Mode_t getMode() const {
|
||||
return value2;
|
||||
}
|
||||
|
||||
void setMode(Mode_t mode) {
|
||||
this->value2 = mode;
|
||||
}
|
||||
|
||||
Submode_t getSubmode() const {
|
||||
return value3;
|
||||
}
|
||||
|
||||
void setSubmode(Submode_t submode) {
|
||||
this->value3 = submode;
|
||||
}
|
||||
|
||||
bool inheritSubmode() const {
|
||||
return value4 == 1;
|
||||
}
|
||||
|
||||
void setInheritSubmode(bool inherit){
|
||||
if (inherit){
|
||||
value4 = 1;
|
||||
} else {
|
||||
value4 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool operator==(ModeListEntry other) {
|
||||
return ((value1 == other.value1) && (value2 == other.value2)
|
||||
&& (value3 == other.value3));
|
||||
}
|
||||
};
|
||||
|
||||
#endif //MODEDEFINITIONS_H_
|
||||
#ifndef MODEDEFINITIONS_H_
|
||||
#define 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) {
|
||||
|
||||
}
|
||||
|
||||
uint32_t value1;
|
||||
uint32_t value2;
|
||||
uint8_t value3;
|
||||
uint8_t value4;
|
||||
|
||||
virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size,
|
||||
size_t maxSize, Endianness streamEndianness) const {
|
||||
|
||||
ReturnValue_t result;
|
||||
|
||||
result = SerializeAdapter::serialize(&value1, buffer, size,
|
||||
maxSize, streamEndianness);
|
||||
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = SerializeAdapter::serialize(&value2, buffer, size,
|
||||
maxSize, streamEndianness);
|
||||
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = SerializeAdapter::serialize(&value3, buffer, size,
|
||||
maxSize, streamEndianness);
|
||||
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = SerializeAdapter::serialize(&value4, buffer, size,
|
||||
maxSize, streamEndianness);
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
virtual size_t getSerializedSize() const {
|
||||
return sizeof(value1) + sizeof(value2) + sizeof(value3) + sizeof(value4);
|
||||
}
|
||||
|
||||
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||
Endianness streamEndianness) {
|
||||
ReturnValue_t result;
|
||||
|
||||
result = SerializeAdapter::deSerialize(&value1, buffer, size,
|
||||
streamEndianness);
|
||||
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = SerializeAdapter::deSerialize(&value2, buffer, size,
|
||||
streamEndianness);
|
||||
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = SerializeAdapter::deSerialize(&value3, buffer, size,
|
||||
streamEndianness);
|
||||
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = SerializeAdapter::deSerialize(&value4, buffer, size,
|
||||
streamEndianness);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//for Sequences
|
||||
Mode_t getTableId() const {
|
||||
return value1;
|
||||
}
|
||||
|
||||
void setTableId(Mode_t tableId) {
|
||||
this->value1 = tableId;
|
||||
}
|
||||
|
||||
uint8_t getWaitSeconds() const {
|
||||
return value2;
|
||||
}
|
||||
|
||||
void setWaitSeconds(uint8_t waitSeconds) {
|
||||
this->value2 = waitSeconds;
|
||||
}
|
||||
|
||||
bool checkSuccess() const {
|
||||
return value3 == 1;
|
||||
}
|
||||
|
||||
void setCheckSuccess(bool checkSuccess) {
|
||||
this->value3 = checkSuccess;
|
||||
}
|
||||
|
||||
//for Tables
|
||||
object_id_t getObject() const {
|
||||
return value1;
|
||||
}
|
||||
|
||||
void setObject(object_id_t object) {
|
||||
this->value1 = object;
|
||||
}
|
||||
|
||||
Mode_t getMode() const {
|
||||
return value2;
|
||||
}
|
||||
|
||||
void setMode(Mode_t mode) {
|
||||
this->value2 = mode;
|
||||
}
|
||||
|
||||
Submode_t getSubmode() const {
|
||||
return value3;
|
||||
}
|
||||
|
||||
void setSubmode(Submode_t submode) {
|
||||
this->value3 = submode;
|
||||
}
|
||||
|
||||
bool inheritSubmode() const {
|
||||
return value4 == 1;
|
||||
}
|
||||
|
||||
void setInheritSubmode(bool inherit){
|
||||
if (inherit){
|
||||
value4 = 1;
|
||||
} else {
|
||||
value4 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool operator==(ModeListEntry other) {
|
||||
return ((value1 == other.value1) && (value2 == other.value2)
|
||||
&& (value3 == other.value3));
|
||||
}
|
||||
};
|
||||
|
||||
#endif //MODEDEFINITIONS_H_
|
||||
|
@ -1,89 +1,89 @@
|
||||
#include "../../objectmanager/ObjectManagerIF.h"
|
||||
#include "../../objectmanager/ObjectManagerIF.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) {
|
||||
message->setCommand(command);
|
||||
message->setParameter(storeAddress.raw);
|
||||
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);
|
||||
message->setParameter(storeAddress.raw);
|
||||
}
|
||||
|
||||
store_address_t ModeSequenceMessage::getStoreAddress(
|
||||
const CommandMessage* message) {
|
||||
store_address_t address;
|
||||
address.raw = message->getParameter();
|
||||
return address;
|
||||
}
|
||||
|
||||
Mode_t ModeSequenceMessage::getSequenceId(const CommandMessage* message) {
|
||||
return message->getParameter2();
|
||||
}
|
||||
|
||||
Mode_t ModeSequenceMessage::getTableId(const CommandMessage* message) {
|
||||
return message->getParameter2();
|
||||
}
|
||||
|
||||
|
||||
uint32_t ModeSequenceMessage::getNumber(const CommandMessage* message) {
|
||||
return message->getParameter2();
|
||||
}
|
||||
|
||||
void ModeSequenceMessage::clear(CommandMessage *message) {
|
||||
switch (message->getCommand()) {
|
||||
case ADD_SEQUENCE:
|
||||
case ADD_TABLE:
|
||||
case SEQUENCE_LIST:
|
||||
case TABLE_LIST:
|
||||
case TABLE:
|
||||
case SEQUENCE:{
|
||||
StorageManagerIF *ipcStore = objectManager->get<StorageManagerIF>(objects::IPC_STORE);
|
||||
if (ipcStore != NULL){
|
||||
ipcStore->deleteData(ModeSequenceMessage::getStoreAddress(message));
|
||||
}
|
||||
}
|
||||
/* NO BREAK falls through*/
|
||||
case DELETE_SEQUENCE:
|
||||
case DELETE_TABLE:
|
||||
case READ_SEQUENCE:
|
||||
case READ_TABLE:
|
||||
case LIST_SEQUENCES:
|
||||
case LIST_TABLES:
|
||||
case READ_FREE_SEQUENCE_SLOTS:
|
||||
case FREE_SEQUENCE_SLOTS:
|
||||
case READ_FREE_TABLE_SLOTS:
|
||||
case FREE_TABLE_SLOTS:
|
||||
default:
|
||||
message->setCommand(CommandMessage::CMD_NONE);
|
||||
message->setParameter(0);
|
||||
message->setParameter2(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#include "../../objectmanager/ObjectManagerIF.h"
|
||||
#include "../../objectmanager/ObjectManagerIF.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) {
|
||||
message->setCommand(command);
|
||||
message->setParameter(storeAddress.raw);
|
||||
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);
|
||||
message->setParameter(storeAddress.raw);
|
||||
}
|
||||
|
||||
store_address_t ModeSequenceMessage::getStoreAddress(
|
||||
const CommandMessage* message) {
|
||||
store_address_t address;
|
||||
address.raw = message->getParameter();
|
||||
return address;
|
||||
}
|
||||
|
||||
Mode_t ModeSequenceMessage::getSequenceId(const CommandMessage* message) {
|
||||
return message->getParameter2();
|
||||
}
|
||||
|
||||
Mode_t ModeSequenceMessage::getTableId(const CommandMessage* message) {
|
||||
return message->getParameter2();
|
||||
}
|
||||
|
||||
|
||||
uint32_t ModeSequenceMessage::getNumber(const CommandMessage* message) {
|
||||
return message->getParameter2();
|
||||
}
|
||||
|
||||
void ModeSequenceMessage::clear(CommandMessage *message) {
|
||||
switch (message->getCommand()) {
|
||||
case ADD_SEQUENCE:
|
||||
case ADD_TABLE:
|
||||
case SEQUENCE_LIST:
|
||||
case TABLE_LIST:
|
||||
case TABLE:
|
||||
case SEQUENCE:{
|
||||
StorageManagerIF *ipcStore = objectManager->get<StorageManagerIF>(objects::IPC_STORE);
|
||||
if (ipcStore != NULL){
|
||||
ipcStore->deleteData(ModeSequenceMessage::getStoreAddress(message));
|
||||
}
|
||||
}
|
||||
/* NO BREAK falls through*/
|
||||
case DELETE_SEQUENCE:
|
||||
case DELETE_TABLE:
|
||||
case READ_SEQUENCE:
|
||||
case READ_TABLE:
|
||||
case LIST_SEQUENCES:
|
||||
case LIST_TABLES:
|
||||
case READ_FREE_SEQUENCE_SLOTS:
|
||||
case FREE_SEQUENCE_SLOTS:
|
||||
case READ_FREE_TABLE_SLOTS:
|
||||
case FREE_TABLE_SLOTS:
|
||||
default:
|
||||
message->setCommand(CommandMessage::CMD_NONE);
|
||||
message->setParameter(0);
|
||||
message->setParameter2(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1,48 +1,48 @@
|
||||
#ifndef MODESEQUENCEMESSAGE_H_
|
||||
#define MODESEQUENCEMESSAGE_H_
|
||||
|
||||
#include "../../ipc/CommandMessage.h"
|
||||
#include "../../storagemanager/StorageManagerIF.h"
|
||||
#include "../../subsystem/modes/ModeDefinitions.h"
|
||||
|
||||
class ModeSequenceMessage {
|
||||
public:
|
||||
static const uint8_t MESSAGE_ID = messagetypes::MODE_SEQUENCE;
|
||||
|
||||
static const Command_t ADD_SEQUENCE = MAKE_COMMAND_ID(0x01);
|
||||
static const Command_t ADD_TABLE = MAKE_COMMAND_ID(0x02);
|
||||
static const Command_t DELETE_SEQUENCE = MAKE_COMMAND_ID(0x03);
|
||||
static const Command_t DELETE_TABLE = MAKE_COMMAND_ID(0x04);
|
||||
static const Command_t READ_SEQUENCE = MAKE_COMMAND_ID(0x05);
|
||||
static const Command_t READ_TABLE = MAKE_COMMAND_ID(0x06);
|
||||
static const Command_t LIST_SEQUENCES = MAKE_COMMAND_ID(0x07);
|
||||
static const Command_t LIST_TABLES = MAKE_COMMAND_ID(0x08);
|
||||
static const Command_t SEQUENCE_LIST = MAKE_COMMAND_ID(0x09);
|
||||
static const Command_t TABLE_LIST = MAKE_COMMAND_ID(0x0A);
|
||||
static const Command_t TABLE = MAKE_COMMAND_ID(0x0B);
|
||||
static const Command_t SEQUENCE = MAKE_COMMAND_ID(0x0C);
|
||||
static const Command_t READ_FREE_SEQUENCE_SLOTS = MAKE_COMMAND_ID(0x0D);
|
||||
static const Command_t FREE_SEQUENCE_SLOTS = MAKE_COMMAND_ID(0x0E);
|
||||
static const Command_t READ_FREE_TABLE_SLOTS = MAKE_COMMAND_ID(0x0F);
|
||||
static const Command_t FREE_TABLE_SLOTS = MAKE_COMMAND_ID(0x10);
|
||||
|
||||
static void setModeSequenceMessage(CommandMessage *message,
|
||||
Command_t command, Mode_t sequenceOrTable,
|
||||
store_address_t storeAddress);
|
||||
static void setModeSequenceMessage(CommandMessage *message,
|
||||
Command_t command, Mode_t sequenceOrTable);
|
||||
static void setModeSequenceMessage(CommandMessage *message,
|
||||
Command_t command, store_address_t storeAddress);
|
||||
|
||||
static store_address_t getStoreAddress(const CommandMessage *message);
|
||||
static Mode_t getSequenceId(const CommandMessage *message);
|
||||
static Mode_t getTableId(const CommandMessage *message);
|
||||
static uint32_t getNumber(const CommandMessage *message);
|
||||
|
||||
static void clear(CommandMessage *message);
|
||||
|
||||
private:
|
||||
ModeSequenceMessage();
|
||||
};
|
||||
|
||||
#endif /* MODESEQUENCEMESSAGE_H_ */
|
||||
#ifndef MODESEQUENCEMESSAGE_H_
|
||||
#define MODESEQUENCEMESSAGE_H_
|
||||
|
||||
#include "../../ipc/CommandMessage.h"
|
||||
#include "../../storagemanager/StorageManagerIF.h"
|
||||
#include "../../subsystem/modes/ModeDefinitions.h"
|
||||
|
||||
class ModeSequenceMessage {
|
||||
public:
|
||||
static const uint8_t MESSAGE_ID = messagetypes::MODE_SEQUENCE;
|
||||
|
||||
static const Command_t ADD_SEQUENCE = MAKE_COMMAND_ID(0x01);
|
||||
static const Command_t ADD_TABLE = MAKE_COMMAND_ID(0x02);
|
||||
static const Command_t DELETE_SEQUENCE = MAKE_COMMAND_ID(0x03);
|
||||
static const Command_t DELETE_TABLE = MAKE_COMMAND_ID(0x04);
|
||||
static const Command_t READ_SEQUENCE = MAKE_COMMAND_ID(0x05);
|
||||
static const Command_t READ_TABLE = MAKE_COMMAND_ID(0x06);
|
||||
static const Command_t LIST_SEQUENCES = MAKE_COMMAND_ID(0x07);
|
||||
static const Command_t LIST_TABLES = MAKE_COMMAND_ID(0x08);
|
||||
static const Command_t SEQUENCE_LIST = MAKE_COMMAND_ID(0x09);
|
||||
static const Command_t TABLE_LIST = MAKE_COMMAND_ID(0x0A);
|
||||
static const Command_t TABLE = MAKE_COMMAND_ID(0x0B);
|
||||
static const Command_t SEQUENCE = MAKE_COMMAND_ID(0x0C);
|
||||
static const Command_t READ_FREE_SEQUENCE_SLOTS = MAKE_COMMAND_ID(0x0D);
|
||||
static const Command_t FREE_SEQUENCE_SLOTS = MAKE_COMMAND_ID(0x0E);
|
||||
static const Command_t READ_FREE_TABLE_SLOTS = MAKE_COMMAND_ID(0x0F);
|
||||
static const Command_t FREE_TABLE_SLOTS = MAKE_COMMAND_ID(0x10);
|
||||
|
||||
static void setModeSequenceMessage(CommandMessage *message,
|
||||
Command_t command, Mode_t sequenceOrTable,
|
||||
store_address_t storeAddress);
|
||||
static void setModeSequenceMessage(CommandMessage *message,
|
||||
Command_t command, Mode_t sequenceOrTable);
|
||||
static void setModeSequenceMessage(CommandMessage *message,
|
||||
Command_t command, store_address_t storeAddress);
|
||||
|
||||
static store_address_t getStoreAddress(const CommandMessage *message);
|
||||
static Mode_t getSequenceId(const CommandMessage *message);
|
||||
static Mode_t getTableId(const CommandMessage *message);
|
||||
static uint32_t getNumber(const CommandMessage *message);
|
||||
|
||||
static void clear(CommandMessage *message);
|
||||
|
||||
private:
|
||||
ModeSequenceMessage();
|
||||
};
|
||||
|
||||
#endif /* MODESEQUENCEMESSAGE_H_ */
|
||||
|
@ -1,126 +1,126 @@
|
||||
#include "../../subsystem/modes/ModeStore.h"
|
||||
|
||||
#ifdef USE_MODESTORE
|
||||
|
||||
ModeStore::ModeStore(object_id_t objectId, uint32_t slots) :
|
||||
SystemObject(objectId), store(slots), emptySlot(store.front()) {
|
||||
mutex = MutexFactory::instance()->createMutex();;
|
||||
OSAL::createMutex(objectId + 1, mutex);
|
||||
clear();
|
||||
}
|
||||
|
||||
ModeStore::~ModeStore() {
|
||||
delete mutex;
|
||||
}
|
||||
|
||||
uint32_t ModeStore::getFreeSlots() {
|
||||
OSAL::lockMutex(mutex, OSAL::NO_TIMEOUT);
|
||||
uint32_t count = 0;
|
||||
ArrayList<ModeListEntry, uint32_t>::Iterator iter;
|
||||
for (iter = store.begin(); iter != store.end(); ++iter) {
|
||||
if (iter->getNext() == emptySlot) {
|
||||
++count;
|
||||
}
|
||||
}
|
||||
OSAL::unlockMutex(mutex);
|
||||
return count;
|
||||
}
|
||||
|
||||
ReturnValue_t ModeStore::storeArray(ArrayList<ModeListEntry>* sequence,
|
||||
ModeListEntry** storedFirstEntry) {
|
||||
if (sequence->size == 0) {
|
||||
return CANT_STORE_EMPTY;
|
||||
}
|
||||
OSAL::lockMutex(mutex, OSAL::NO_TIMEOUT);
|
||||
*storedFirstEntry = findEmptySlotNoLock(store.front());
|
||||
|
||||
ModeListEntry* pointer =
|
||||
*storedFirstEntry;
|
||||
pointer->setNext(pointer);
|
||||
|
||||
ArrayList<ModeListEntry>::Iterator iter;
|
||||
for (iter = sequence->begin(); iter != sequence->end(); ++iter) {
|
||||
//SHOULDDO: I need to check this in detail. What is the idea? Why does it not work?
|
||||
pointer = pointer->getNext()->value;
|
||||
if (pointer == NULL) {
|
||||
deleteListNoLock(*storedFirstEntry);
|
||||
OSAL::unlockMutex(mutex);
|
||||
return TOO_MANY_ELEMENTS;
|
||||
}
|
||||
pointer->value->value1 = iter->value1;
|
||||
pointer->value->value2 = iter->value2;
|
||||
pointer->value->value3 = iter->value3;
|
||||
pointer->setNext(findEmptySlotNoLock(pointer + 1));
|
||||
}
|
||||
pointer->setNext(NULL);
|
||||
OSAL::unlockMutex(mutex);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t ModeStore::deleteList(ModeListEntry* sequence) {
|
||||
ReturnValue_t result = isValidEntry(sequence);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
OSAL::lockMutex(mutex, OSAL::NO_TIMEOUT);
|
||||
deleteListNoLock(sequence);
|
||||
OSAL::unlockMutex(mutex);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t ModeStore::readList(ModeListEntry* sequence,
|
||||
ArrayList<ModeListEntry>* into) {
|
||||
ReturnValue_t result = isValidEntry(sequence);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
OSAL::lockMutex(mutex, OSAL::NO_TIMEOUT);
|
||||
result = into->insert(*sequence->value);
|
||||
while ((result == HasReturnvaluesIF::RETURN_OK) && (sequence->getNext() != NULL)) {
|
||||
result = into->insert(*sequence->value);
|
||||
sequence = sequence->getNext()->value;
|
||||
}
|
||||
OSAL::unlockMutex(mutex);
|
||||
return result;
|
||||
}
|
||||
|
||||
void ModeStore::clear() {
|
||||
OSAL::lockMutex(mutex, OSAL::NO_TIMEOUT);
|
||||
store.size = store.maxSize();
|
||||
ArrayList<ModeListEntry, uint32_t>::Iterator iter;
|
||||
for (iter = store.begin(); iter != store.end(); ++iter) {
|
||||
iter->setNext(emptySlot);
|
||||
}
|
||||
OSAL::unlockMutex(mutex);
|
||||
}
|
||||
|
||||
ModeListEntry* ModeStore::findEmptySlotNoLock(ModeListEntry* startFrom) {
|
||||
ArrayList<ModeListEntry, uint32_t>::Iterator iter(
|
||||
startFrom);
|
||||
for (; iter != store.end(); ++iter) {
|
||||
if (iter.value->getNext() == emptySlot) {
|
||||
OSAL::unlockMutex(mutex);
|
||||
return iter.value;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void ModeStore::deleteListNoLock(ModeListEntry* sequence) {
|
||||
ModeListEntry* next = sequence;
|
||||
while (next != NULL) {
|
||||
next = sequence->getNext()->value;
|
||||
sequence->setNext(emptySlot);
|
||||
sequence = next;
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t ModeStore::isValidEntry(ModeListEntry* sequence) {
|
||||
if ((sequence < store.front()) || (sequence > store.back())
|
||||
|| sequence->getNext() == emptySlot) {
|
||||
return INVALID_ENTRY;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
#endif
|
||||
#include "../../subsystem/modes/ModeStore.h"
|
||||
|
||||
#ifdef USE_MODESTORE
|
||||
|
||||
ModeStore::ModeStore(object_id_t objectId, uint32_t slots) :
|
||||
SystemObject(objectId), store(slots), emptySlot(store.front()) {
|
||||
mutex = MutexFactory::instance()->createMutex();;
|
||||
OSAL::createMutex(objectId + 1, mutex);
|
||||
clear();
|
||||
}
|
||||
|
||||
ModeStore::~ModeStore() {
|
||||
delete mutex;
|
||||
}
|
||||
|
||||
uint32_t ModeStore::getFreeSlots() {
|
||||
OSAL::lockMutex(mutex, OSAL::NO_TIMEOUT);
|
||||
uint32_t count = 0;
|
||||
ArrayList<ModeListEntry, uint32_t>::Iterator iter;
|
||||
for (iter = store.begin(); iter != store.end(); ++iter) {
|
||||
if (iter->getNext() == emptySlot) {
|
||||
++count;
|
||||
}
|
||||
}
|
||||
OSAL::unlockMutex(mutex);
|
||||
return count;
|
||||
}
|
||||
|
||||
ReturnValue_t ModeStore::storeArray(ArrayList<ModeListEntry>* sequence,
|
||||
ModeListEntry** storedFirstEntry) {
|
||||
if (sequence->size == 0) {
|
||||
return CANT_STORE_EMPTY;
|
||||
}
|
||||
OSAL::lockMutex(mutex, OSAL::NO_TIMEOUT);
|
||||
*storedFirstEntry = findEmptySlotNoLock(store.front());
|
||||
|
||||
ModeListEntry* pointer =
|
||||
*storedFirstEntry;
|
||||
pointer->setNext(pointer);
|
||||
|
||||
ArrayList<ModeListEntry>::Iterator iter;
|
||||
for (iter = sequence->begin(); iter != sequence->end(); ++iter) {
|
||||
//SHOULDDO: I need to check this in detail. What is the idea? Why does it not work?
|
||||
pointer = pointer->getNext()->value;
|
||||
if (pointer == NULL) {
|
||||
deleteListNoLock(*storedFirstEntry);
|
||||
OSAL::unlockMutex(mutex);
|
||||
return TOO_MANY_ELEMENTS;
|
||||
}
|
||||
pointer->value->value1 = iter->value1;
|
||||
pointer->value->value2 = iter->value2;
|
||||
pointer->value->value3 = iter->value3;
|
||||
pointer->setNext(findEmptySlotNoLock(pointer + 1));
|
||||
}
|
||||
pointer->setNext(NULL);
|
||||
OSAL::unlockMutex(mutex);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t ModeStore::deleteList(ModeListEntry* sequence) {
|
||||
ReturnValue_t result = isValidEntry(sequence);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
OSAL::lockMutex(mutex, OSAL::NO_TIMEOUT);
|
||||
deleteListNoLock(sequence);
|
||||
OSAL::unlockMutex(mutex);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t ModeStore::readList(ModeListEntry* sequence,
|
||||
ArrayList<ModeListEntry>* into) {
|
||||
ReturnValue_t result = isValidEntry(sequence);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
OSAL::lockMutex(mutex, OSAL::NO_TIMEOUT);
|
||||
result = into->insert(*sequence->value);
|
||||
while ((result == HasReturnvaluesIF::RETURN_OK) && (sequence->getNext() != NULL)) {
|
||||
result = into->insert(*sequence->value);
|
||||
sequence = sequence->getNext()->value;
|
||||
}
|
||||
OSAL::unlockMutex(mutex);
|
||||
return result;
|
||||
}
|
||||
|
||||
void ModeStore::clear() {
|
||||
OSAL::lockMutex(mutex, OSAL::NO_TIMEOUT);
|
||||
store.size = store.maxSize();
|
||||
ArrayList<ModeListEntry, uint32_t>::Iterator iter;
|
||||
for (iter = store.begin(); iter != store.end(); ++iter) {
|
||||
iter->setNext(emptySlot);
|
||||
}
|
||||
OSAL::unlockMutex(mutex);
|
||||
}
|
||||
|
||||
ModeListEntry* ModeStore::findEmptySlotNoLock(ModeListEntry* startFrom) {
|
||||
ArrayList<ModeListEntry, uint32_t>::Iterator iter(
|
||||
startFrom);
|
||||
for (; iter != store.end(); ++iter) {
|
||||
if (iter.value->getNext() == emptySlot) {
|
||||
OSAL::unlockMutex(mutex);
|
||||
return iter.value;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void ModeStore::deleteListNoLock(ModeListEntry* sequence) {
|
||||
ModeListEntry* next = sequence;
|
||||
while (next != NULL) {
|
||||
next = sequence->getNext()->value;
|
||||
sequence->setNext(emptySlot);
|
||||
sequence = next;
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t ModeStore::isValidEntry(ModeListEntry* sequence) {
|
||||
if ((sequence < store.front()) || (sequence > store.back())
|
||||
|| sequence->getNext() == emptySlot) {
|
||||
return INVALID_ENTRY;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,45 +1,45 @@
|
||||
#ifndef MODESTORE_H_
|
||||
#define MODESTORE_H_
|
||||
|
||||
#ifdef USE_MODESTORE
|
||||
|
||||
#include "../../container/ArrayList.h"
|
||||
#include "../../container/SinglyLinkedList.h"
|
||||
#include "../../objectmanager/SystemObject.h"
|
||||
#include "../../subsystem/modes/ModeStoreIF.h"
|
||||
|
||||
class ModeStore: public ModeStoreIF, public SystemObject {
|
||||
public:
|
||||
ModeStore(object_id_t objectId, uint32_t slots);
|
||||
virtual ~ModeStore();
|
||||
|
||||
virtual ReturnValue_t storeArray(ArrayList<ModeListEntry> *sequence,
|
||||
ModeListEntry **storedFirstEntry);
|
||||
|
||||
virtual ReturnValue_t deleteList(
|
||||
ModeListEntry *sequence);
|
||||
|
||||
virtual ReturnValue_t readList(
|
||||
ModeListEntry *sequence,
|
||||
ArrayList<ModeListEntry> *into);
|
||||
|
||||
virtual uint32_t getFreeSlots();
|
||||
|
||||
private:
|
||||
MutexId_t* mutex;
|
||||
ArrayList<ModeListEntry, uint32_t> store;
|
||||
ModeListEntry *emptySlot;
|
||||
|
||||
void clear();
|
||||
ModeListEntry* findEmptySlotNoLock(
|
||||
ModeListEntry* startFrom);
|
||||
void deleteListNoLock(
|
||||
ModeListEntry *sequence);
|
||||
|
||||
ReturnValue_t isValidEntry(ModeListEntry *sequence);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* MODESTORE_H_ */
|
||||
|
||||
#ifndef MODESTORE_H_
|
||||
#define MODESTORE_H_
|
||||
|
||||
#ifdef USE_MODESTORE
|
||||
|
||||
#include "../../container/ArrayList.h"
|
||||
#include "../../container/SinglyLinkedList.h"
|
||||
#include "../../objectmanager/SystemObject.h"
|
||||
#include "../../subsystem/modes/ModeStoreIF.h"
|
||||
|
||||
class ModeStore: public ModeStoreIF, public SystemObject {
|
||||
public:
|
||||
ModeStore(object_id_t objectId, uint32_t slots);
|
||||
virtual ~ModeStore();
|
||||
|
||||
virtual ReturnValue_t storeArray(ArrayList<ModeListEntry> *sequence,
|
||||
ModeListEntry **storedFirstEntry);
|
||||
|
||||
virtual ReturnValue_t deleteList(
|
||||
ModeListEntry *sequence);
|
||||
|
||||
virtual ReturnValue_t readList(
|
||||
ModeListEntry *sequence,
|
||||
ArrayList<ModeListEntry> *into);
|
||||
|
||||
virtual uint32_t getFreeSlots();
|
||||
|
||||
private:
|
||||
MutexId_t* mutex;
|
||||
ArrayList<ModeListEntry, uint32_t> store;
|
||||
ModeListEntry *emptySlot;
|
||||
|
||||
void clear();
|
||||
ModeListEntry* findEmptySlotNoLock(
|
||||
ModeListEntry* startFrom);
|
||||
void deleteListNoLock(
|
||||
ModeListEntry *sequence);
|
||||
|
||||
ReturnValue_t isValidEntry(ModeListEntry *sequence);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* MODESTORE_H_ */
|
||||
|
||||
|
@ -1,37 +1,37 @@
|
||||
#ifndef MODESTOREIF_H_
|
||||
#define MODESTOREIF_H_
|
||||
|
||||
#ifdef USE_MODESTORE
|
||||
|
||||
#include "../../container/ArrayList.h"
|
||||
#include "../../container/SinglyLinkedList.h"
|
||||
#include "../../returnvalues/HasReturnvaluesIF.h"
|
||||
#include "../../subsystem/modes/ModeDefinitions.h"
|
||||
|
||||
class ModeStoreIF {
|
||||
public:
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::MODE_STORE_IF;
|
||||
static const ReturnValue_t INVALID_ENTRY = MAKE_RETURN_CODE(0x02);
|
||||
static const ReturnValue_t TOO_MANY_ELEMENTS = MAKE_RETURN_CODE(0x03);
|
||||
static const ReturnValue_t CANT_STORE_EMPTY = MAKE_RETURN_CODE(0x04);
|
||||
|
||||
virtual ~ModeStoreIF() {
|
||||
|
||||
}
|
||||
|
||||
virtual ReturnValue_t storeArray(ArrayList<ModeListEntry> *sequence,
|
||||
ModeListEntry **storedFirstEntry) = 0;
|
||||
|
||||
virtual ReturnValue_t deleteList(
|
||||
ModeListEntry *sequence) = 0;
|
||||
|
||||
virtual ReturnValue_t readList(
|
||||
ModeListEntry *sequence,
|
||||
ArrayList<ModeListEntry> *into) = 0;
|
||||
|
||||
virtual uint32_t getFreeSlots() = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* MODESTOREIF_H_ */
|
||||
#ifndef MODESTOREIF_H_
|
||||
#define MODESTOREIF_H_
|
||||
|
||||
#ifdef USE_MODESTORE
|
||||
|
||||
#include "../../container/ArrayList.h"
|
||||
#include "../../container/SinglyLinkedList.h"
|
||||
#include "../../returnvalues/HasReturnvaluesIF.h"
|
||||
#include "../../subsystem/modes/ModeDefinitions.h"
|
||||
|
||||
class ModeStoreIF {
|
||||
public:
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::MODE_STORE_IF;
|
||||
static const ReturnValue_t INVALID_ENTRY = MAKE_RETURN_CODE(0x02);
|
||||
static const ReturnValue_t TOO_MANY_ELEMENTS = MAKE_RETURN_CODE(0x03);
|
||||
static const ReturnValue_t CANT_STORE_EMPTY = MAKE_RETURN_CODE(0x04);
|
||||
|
||||
virtual ~ModeStoreIF() {
|
||||
|
||||
}
|
||||
|
||||
virtual ReturnValue_t storeArray(ArrayList<ModeListEntry> *sequence,
|
||||
ModeListEntry **storedFirstEntry) = 0;
|
||||
|
||||
virtual ReturnValue_t deleteList(
|
||||
ModeListEntry *sequence) = 0;
|
||||
|
||||
virtual ReturnValue_t readList(
|
||||
ModeListEntry *sequence,
|
||||
ArrayList<ModeListEntry> *into) = 0;
|
||||
|
||||
virtual uint32_t getFreeSlots() = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* MODESTOREIF_H_ */
|
||||
|
Reference in New Issue
Block a user