parent
3905b72b08
commit
8c722feafb
@ -72,11 +72,15 @@ public:
|
|||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
T operator*() {
|
T& operator*(){
|
||||||
return *value;
|
return *value;
|
||||||
}
|
}
|
||||||
|
|
||||||
T *operator->() {
|
const T& operator*() const{
|
||||||
|
return *value;
|
||||||
|
}
|
||||||
|
|
||||||
|
T *operator->(){
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef FIXEDMAP_H_
|
#ifndef FRAMEWORK_CONTAINER_FIXEDMAP_H_
|
||||||
#define FIXEDMAP_H_
|
#define FRAMEWORK_CONTAINER_FIXEDMAP_H_
|
||||||
|
|
||||||
#include <framework/container/ArrayList.h>
|
#include <framework/container/ArrayList.h>
|
||||||
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
||||||
@ -7,6 +7,10 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* \ingroup container
|
* \ingroup container
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* \warning Iterators return a non-const key_t in the pair.
|
||||||
|
* \warning A User is not allowed to change the key, otherwise the map is corrupted.
|
||||||
*/
|
*/
|
||||||
template<typename key_t, typename T>
|
template<typename key_t, typename T>
|
||||||
class FixedMap: public SerializeIF {
|
class FixedMap: public SerializeIF {
|
||||||
@ -47,15 +51,6 @@ public:
|
|||||||
Iterator(std::pair<key_t, T> *pair) :
|
Iterator(std::pair<key_t, T> *pair) :
|
||||||
ArrayList<std::pair<key_t, T>, uint32_t>::Iterator(pair) {
|
ArrayList<std::pair<key_t, T>, uint32_t>::Iterator(pair) {
|
||||||
}
|
}
|
||||||
|
|
||||||
T operator*() {
|
|
||||||
return ArrayList<std::pair<key_t, T>, uint32_t>::Iterator::value->second;
|
|
||||||
}
|
|
||||||
|
|
||||||
T *operator->() {
|
|
||||||
return &ArrayList<std::pair<key_t, T>, uint32_t>::Iterator::value->second;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Iterator begin() const {
|
Iterator begin() const {
|
||||||
@ -70,7 +65,7 @@ public:
|
|||||||
return _size;
|
return _size;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t insert(key_t key, T value, Iterator *storedValue = NULL) {
|
ReturnValue_t insert(key_t key, T value, Iterator *storedValue = nullptr) {
|
||||||
if (exists(key) == HasReturnvaluesIF::RETURN_OK) {
|
if (exists(key) == HasReturnvaluesIF::RETURN_OK) {
|
||||||
return KEY_ALREADY_EXISTS;
|
return KEY_ALREADY_EXISTS;
|
||||||
}
|
}
|
||||||
@ -79,7 +74,7 @@ public:
|
|||||||
}
|
}
|
||||||
theMap[_size].first = key;
|
theMap[_size].first = key;
|
||||||
theMap[_size].second = value;
|
theMap[_size].second = value;
|
||||||
if (storedValue != NULL) {
|
if (storedValue != nullptr) {
|
||||||
*storedValue = Iterator(&theMap[_size]);
|
*storedValue = Iterator(&theMap[_size]);
|
||||||
}
|
}
|
||||||
++_size;
|
++_size;
|
||||||
@ -87,7 +82,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t insert(std::pair<key_t, T> pair) {
|
ReturnValue_t insert(std::pair<key_t, T> pair) {
|
||||||
return insert(pair.fist, pair.second);
|
return insert(pair.first, pair.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t exists(key_t key) const {
|
ReturnValue_t exists(key_t key) const {
|
||||||
|
@ -68,15 +68,6 @@ public:
|
|||||||
Iterator(std::pair<key_t, T> *pair) :
|
Iterator(std::pair<key_t, T> *pair) :
|
||||||
ArrayList<std::pair<key_t, T>, uint32_t>::Iterator(pair) {
|
ArrayList<std::pair<key_t, T>, uint32_t>::Iterator(pair) {
|
||||||
}
|
}
|
||||||
|
|
||||||
T operator*() {
|
|
||||||
return ArrayList<std::pair<key_t, T>, uint32_t>::Iterator::value->second;
|
|
||||||
}
|
|
||||||
|
|
||||||
T *operator->() {
|
|
||||||
return &ArrayList<std::pair<key_t, T>, uint32_t>::Iterator::value->second;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Iterator begin() const {
|
Iterator begin() const {
|
||||||
@ -91,7 +82,7 @@ public:
|
|||||||
return _size;
|
return _size;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t insert(key_t key, T value, Iterator *storedValue = NULL) {
|
ReturnValue_t insert(key_t key, T value, Iterator *storedValue = nullptr) {
|
||||||
if (_size == theMap.maxSize()) {
|
if (_size == theMap.maxSize()) {
|
||||||
return MAP_FULL;
|
return MAP_FULL;
|
||||||
}
|
}
|
||||||
@ -101,7 +92,7 @@ public:
|
|||||||
theMap[position].first = key;
|
theMap[position].first = key;
|
||||||
theMap[position].second = value;
|
theMap[position].second = value;
|
||||||
++_size;
|
++_size;
|
||||||
if (storedValue != NULL) {
|
if (storedValue != nullptr) {
|
||||||
*storedValue = Iterator(&theMap[position]);
|
*storedValue = Iterator(&theMap[position]);
|
||||||
}
|
}
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
@ -549,7 +549,7 @@ Mode_t Subsystem::getFallbackSequence(Mode_t sequence) {
|
|||||||
for (FixedMap<Mode_t, SequenceInfo>::Iterator iter = modeSequences.begin();
|
for (FixedMap<Mode_t, SequenceInfo>::Iterator iter = modeSequences.begin();
|
||||||
iter != modeSequences.end(); ++iter) {
|
iter != modeSequences.end(); ++iter) {
|
||||||
if (iter.value->first == sequence) {
|
if (iter.value->first == sequence) {
|
||||||
return iter->fallbackSequence;
|
return iter->second.fallbackSequence;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
@ -558,7 +558,7 @@ Mode_t Subsystem::getFallbackSequence(Mode_t sequence) {
|
|||||||
bool Subsystem::isFallbackSequence(Mode_t SequenceId) {
|
bool Subsystem::isFallbackSequence(Mode_t SequenceId) {
|
||||||
for (FixedMap<Mode_t, SequenceInfo>::Iterator iter = modeSequences.begin();
|
for (FixedMap<Mode_t, SequenceInfo>::Iterator iter = modeSequences.begin();
|
||||||
iter != modeSequences.end(); iter++) {
|
iter != modeSequences.end(); iter++) {
|
||||||
if (iter->fallbackSequence == SequenceId) {
|
if (iter->second.fallbackSequence == SequenceId) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,8 +104,8 @@ void CommandingServiceBase::handleCommandMessage(CommandMessage* reply) {
|
|||||||
|
|
||||||
|
|
||||||
// Implemented by child class, specifies what to do with reply.
|
// Implemented by child class, specifies what to do with reply.
|
||||||
ReturnValue_t result = handleReply(reply, iter->command, &iter->state,
|
ReturnValue_t result = handleReply(reply, iter->second.command, &iter->second.state,
|
||||||
&nextCommand, iter->objectId, &isStep);
|
&nextCommand, iter->second.objectId, &isStep);
|
||||||
|
|
||||||
/* If the child implementation does not implement special handling for
|
/* If the child implementation does not implement special handling for
|
||||||
* rejected replies (RETURN_FAILED is returned), a failure verification
|
* rejected replies (RETURN_FAILED is returned), a failure verification
|
||||||
@ -114,7 +114,7 @@ void CommandingServiceBase::handleCommandMessage(CommandMessage* reply) {
|
|||||||
if(reply->getCommand() == CommandMessage::REPLY_REJECTED and
|
if(reply->getCommand() == CommandMessage::REPLY_REJECTED and
|
||||||
result == RETURN_FAILED) {
|
result == RETURN_FAILED) {
|
||||||
result = reply->getReplyRejectedReason();
|
result = reply->getReplyRejectedReason();
|
||||||
failureParameter1 = iter->command;
|
failureParameter1 = iter->second.command;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (result) {
|
switch (result) {
|
||||||
@ -131,14 +131,14 @@ void CommandingServiceBase::handleCommandMessage(CommandMessage* reply) {
|
|||||||
default:
|
default:
|
||||||
if (isStep) {
|
if (isStep) {
|
||||||
verificationReporter.sendFailureReport(
|
verificationReporter.sendFailureReport(
|
||||||
TC_VERIFY::PROGRESS_FAILURE, iter->tcInfo.ackFlags,
|
TC_VERIFY::PROGRESS_FAILURE, iter->second.tcInfo.ackFlags,
|
||||||
iter->tcInfo.tcPacketId, iter->tcInfo.tcSequenceControl,
|
iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl,
|
||||||
result, ++iter->step, failureParameter1,
|
result, ++iter->second.step, failureParameter1,
|
||||||
failureParameter2);
|
failureParameter2);
|
||||||
} else {
|
} else {
|
||||||
verificationReporter.sendFailureReport(
|
verificationReporter.sendFailureReport(
|
||||||
TC_VERIFY::COMPLETION_FAILURE, iter->tcInfo.ackFlags,
|
TC_VERIFY::COMPLETION_FAILURE, iter->second.tcInfo.ackFlags,
|
||||||
iter->tcInfo.tcPacketId, iter->tcInfo.tcSequenceControl,
|
iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl,
|
||||||
result, 0, failureParameter1, failureParameter2);
|
result, 0, failureParameter1, failureParameter2);
|
||||||
}
|
}
|
||||||
failureParameter1 = 0;
|
failureParameter1 = 0;
|
||||||
@ -152,7 +152,7 @@ void CommandingServiceBase::handleCommandMessage(CommandMessage* reply) {
|
|||||||
void CommandingServiceBase::handleReplyHandlerResult(ReturnValue_t result,
|
void CommandingServiceBase::handleReplyHandlerResult(ReturnValue_t result,
|
||||||
CommandMapIter iter, CommandMessage* nextCommand,
|
CommandMapIter iter, CommandMessage* nextCommand,
|
||||||
CommandMessage* reply, bool& isStep) {
|
CommandMessage* reply, bool& isStep) {
|
||||||
iter->command = nextCommand->getCommand();
|
iter->second.command = nextCommand->getCommand();
|
||||||
|
|
||||||
// In case a new command is to be sent immediately, this is performed here.
|
// In case a new command is to be sent immediately, this is performed here.
|
||||||
// If no new command is sent, only analyse reply result by initializing
|
// If no new command is sent, only analyse reply result by initializing
|
||||||
@ -167,14 +167,14 @@ void CommandingServiceBase::handleReplyHandlerResult(ReturnValue_t result,
|
|||||||
if (isStep and result != NO_STEP_MESSAGE) {
|
if (isStep and result != NO_STEP_MESSAGE) {
|
||||||
verificationReporter.sendSuccessReport(
|
verificationReporter.sendSuccessReport(
|
||||||
TC_VERIFY::PROGRESS_SUCCESS,
|
TC_VERIFY::PROGRESS_SUCCESS,
|
||||||
iter->tcInfo.ackFlags, iter->tcInfo.tcPacketId,
|
iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId,
|
||||||
iter->tcInfo.tcSequenceControl, ++iter->step);
|
iter->second.tcInfo.tcSequenceControl, ++iter->second.step);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
verificationReporter.sendSuccessReport(
|
verificationReporter.sendSuccessReport(
|
||||||
TC_VERIFY::COMPLETION_SUCCESS,
|
TC_VERIFY::COMPLETION_SUCCESS,
|
||||||
iter->tcInfo.ackFlags, iter->tcInfo.tcPacketId,
|
iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId,
|
||||||
iter->tcInfo.tcSequenceControl, 0);
|
iter->second.tcInfo.tcSequenceControl, 0);
|
||||||
checkAndExecuteFifo(iter);
|
checkAndExecuteFifo(iter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -182,16 +182,16 @@ void CommandingServiceBase::handleReplyHandlerResult(ReturnValue_t result,
|
|||||||
if (isStep) {
|
if (isStep) {
|
||||||
nextCommand->clearCommandMessage();
|
nextCommand->clearCommandMessage();
|
||||||
verificationReporter.sendFailureReport(
|
verificationReporter.sendFailureReport(
|
||||||
TC_VERIFY::PROGRESS_FAILURE, iter->tcInfo.ackFlags,
|
TC_VERIFY::PROGRESS_FAILURE, iter->second.tcInfo.ackFlags,
|
||||||
iter->tcInfo.tcPacketId,
|
iter->second.tcInfo.tcPacketId,
|
||||||
iter->tcInfo.tcSequenceControl, sendResult,
|
iter->second.tcInfo.tcSequenceControl, sendResult,
|
||||||
++iter->step, failureParameter1, failureParameter2);
|
++iter->second.step, failureParameter1, failureParameter2);
|
||||||
} else {
|
} else {
|
||||||
nextCommand->clearCommandMessage();
|
nextCommand->clearCommandMessage();
|
||||||
verificationReporter.sendFailureReport(
|
verificationReporter.sendFailureReport(
|
||||||
TC_VERIFY::COMPLETION_FAILURE,
|
TC_VERIFY::COMPLETION_FAILURE,
|
||||||
iter->tcInfo.ackFlags, iter->tcInfo.tcPacketId,
|
iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId,
|
||||||
iter->tcInfo.tcSequenceControl, sendResult, 0,
|
iter->second.tcInfo.tcSequenceControl, sendResult, 0,
|
||||||
failureParameter1, failureParameter2);
|
failureParameter1, failureParameter2);
|
||||||
}
|
}
|
||||||
failureParameter1 = 0;
|
failureParameter1 = 0;
|
||||||
@ -230,7 +230,7 @@ void CommandingServiceBase::handleRequestQueue() {
|
|||||||
iter = commandMap.find(queue);
|
iter = commandMap.find(queue);
|
||||||
|
|
||||||
if (iter != commandMap.end()) {
|
if (iter != commandMap.end()) {
|
||||||
result = iter->fifo.insert(address);
|
result = iter->second.fifo.insert(address);
|
||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
rejectPacket(TC_VERIFY::START_FAILURE, &packet, OBJECT_BUSY);
|
rejectPacket(TC_VERIFY::START_FAILURE, &packet, OBJECT_BUSY);
|
||||||
}
|
}
|
||||||
@ -298,11 +298,11 @@ void CommandingServiceBase::startExecution(TcPacketStored *storedPacket,
|
|||||||
CommandMapIter iter) {
|
CommandMapIter iter) {
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = RETURN_OK;
|
||||||
CommandMessage command;
|
CommandMessage command;
|
||||||
iter->subservice = storedPacket->getSubService();
|
iter->second.subservice = storedPacket->getSubService();
|
||||||
result = prepareCommand(&command, iter->subservice,
|
result = prepareCommand(&command, iter->second.subservice,
|
||||||
storedPacket->getApplicationData(),
|
storedPacket->getApplicationData(),
|
||||||
storedPacket->getApplicationDataSize(), &iter->state,
|
storedPacket->getApplicationDataSize(), &iter->second.state,
|
||||||
iter->objectId);
|
iter->second.objectId);
|
||||||
|
|
||||||
ReturnValue_t sendResult = RETURN_OK;
|
ReturnValue_t sendResult = RETURN_OK;
|
||||||
switch (result) {
|
switch (result) {
|
||||||
@ -312,13 +312,13 @@ void CommandingServiceBase::startExecution(TcPacketStored *storedPacket,
|
|||||||
&command);
|
&command);
|
||||||
}
|
}
|
||||||
if (sendResult == RETURN_OK) {
|
if (sendResult == RETURN_OK) {
|
||||||
Clock::getUptime(&iter->uptimeOfStart);
|
Clock::getUptime(&iter->second.uptimeOfStart);
|
||||||
iter->step = 0;
|
iter->second.step = 0;
|
||||||
iter->subservice = storedPacket->getSubService();
|
iter->second.subservice = storedPacket->getSubService();
|
||||||
iter->command = command.getCommand();
|
iter->second.command = command.getCommand();
|
||||||
iter->tcInfo.ackFlags = storedPacket->getAcknowledgeFlags();
|
iter->second.tcInfo.ackFlags = storedPacket->getAcknowledgeFlags();
|
||||||
iter->tcInfo.tcPacketId = storedPacket->getPacketId();
|
iter->second.tcInfo.tcPacketId = storedPacket->getPacketId();
|
||||||
iter->tcInfo.tcSequenceControl =
|
iter->second.tcInfo.tcSequenceControl =
|
||||||
storedPacket->getPacketSequenceControl();
|
storedPacket->getPacketSequenceControl();
|
||||||
acceptPacket(TC_VERIFY::START_SUCCESS, storedPacket);
|
acceptPacket(TC_VERIFY::START_SUCCESS, storedPacket);
|
||||||
} else {
|
} else {
|
||||||
@ -368,7 +368,7 @@ void CommandingServiceBase::acceptPacket(uint8_t reportId,
|
|||||||
|
|
||||||
void CommandingServiceBase::checkAndExecuteFifo(CommandMapIter iter) {
|
void CommandingServiceBase::checkAndExecuteFifo(CommandMapIter iter) {
|
||||||
store_address_t address;
|
store_address_t address;
|
||||||
if (iter->fifo.retrieve(&address) != RETURN_OK) {
|
if (iter->second.fifo.retrieve(&address) != RETURN_OK) {
|
||||||
commandMap.erase(&iter);
|
commandMap.erase(&iter);
|
||||||
} else {
|
} else {
|
||||||
TcPacketStored newPacket(address);
|
TcPacketStored newPacket(address);
|
||||||
@ -394,10 +394,10 @@ void CommandingServiceBase::checkTimeout() {
|
|||||||
Clock::getUptime(&uptime);
|
Clock::getUptime(&uptime);
|
||||||
CommandMapIter iter;
|
CommandMapIter iter;
|
||||||
for (iter = commandMap.begin(); iter != commandMap.end(); ++iter) {
|
for (iter = commandMap.begin(); iter != commandMap.end(); ++iter) {
|
||||||
if ((iter->uptimeOfStart + (timeoutSeconds * 1000)) < uptime) {
|
if ((iter->second.uptimeOfStart + (timeoutSeconds * 1000)) < uptime) {
|
||||||
verificationReporter.sendFailureReport(
|
verificationReporter.sendFailureReport(
|
||||||
TC_VERIFY::COMPLETION_FAILURE, iter->tcInfo.ackFlags,
|
TC_VERIFY::COMPLETION_FAILURE, iter->second.tcInfo.ackFlags,
|
||||||
iter->tcInfo.tcPacketId, iter->tcInfo.tcSequenceControl,
|
iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl,
|
||||||
TIMEOUT);
|
TIMEOUT);
|
||||||
checkAndExecuteFifo(iter);
|
checkAndExecuteFifo(iter);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user