doc fix, various improvements
This commit is contained in:
parent
72f3b16c24
commit
8a56964dab
@ -80,39 +80,49 @@ void CommandingServiceBase::handleCommandQueue() {
|
||||
ReturnValue_t result = RETURN_FAILED;
|
||||
for (result = commandQueue->receiveMessage(&reply); result == RETURN_OK;
|
||||
result = commandQueue->receiveMessage(&reply)) {
|
||||
handleCommandMessage(reply);
|
||||
handleCommandMessage(&reply);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CommandingServiceBase::handleCommandMessage(CommandMessage& reply) {
|
||||
void CommandingServiceBase::handleCommandMessage(CommandMessage* reply) {
|
||||
bool isStep = false;
|
||||
CommandMessage nextCommand;
|
||||
CommandMapIter iter;
|
||||
if (reply.getSender() == MessageQueueIF::NO_QUEUE) {
|
||||
handleUnrequestedReply(&reply);
|
||||
return;
|
||||
}
|
||||
if ((iter = commandMap.find(reply.getSender())) == commandMap.end()) {
|
||||
handleUnrequestedReply(&reply);
|
||||
CommandMapIter iter = commandMap.find(reply->getSender());
|
||||
|
||||
// handle unrequested reply first
|
||||
if (reply->getSender() == MessageQueueIF::NO_QUEUE or
|
||||
iter == commandMap.end()) {
|
||||
handleUnrequestedReply(reply);
|
||||
return;
|
||||
}
|
||||
nextCommand.setCommand(CommandMessage::CMD_NONE);
|
||||
|
||||
|
||||
// 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->command, &iter->state,
|
||||
&nextCommand, iter->objectId, &isStep);
|
||||
|
||||
/* If the child implementation does not implement special handling for
|
||||
* rejected replies (RETURN_FAILED is returned), a failure verification
|
||||
* will be generated with the reason as the return code and the initial
|
||||
* command as failure parameter 1 */
|
||||
if(reply->getCommand() == CommandMessage::REPLY_REJECTED and
|
||||
result == RETURN_FAILED) {
|
||||
result = reply->getReplyRejectedReason(
|
||||
reinterpret_cast<Command_t*>(&failureParameter1));
|
||||
}
|
||||
|
||||
switch (result) {
|
||||
case EXECUTION_COMPLETE:
|
||||
case RETURN_OK:
|
||||
case NO_STEP_MESSAGE:
|
||||
// handle result of reply handler implemented by developer.
|
||||
handleReplyHandlerResult(result, iter, nextCommand, reply, isStep);
|
||||
handleReplyHandlerResult(result, iter, &nextCommand, reply, isStep);
|
||||
break;
|
||||
case INVALID_REPLY:
|
||||
//might be just an unrequested reply at a bad moment
|
||||
handleUnrequestedReply(&reply);
|
||||
handleUnrequestedReply(reply);
|
||||
break;
|
||||
default:
|
||||
if (isStep) {
|
||||
@ -129,24 +139,24 @@ void CommandingServiceBase::handleCommandMessage(CommandMessage& reply) {
|
||||
}
|
||||
failureParameter1 = 0;
|
||||
failureParameter2 = 0;
|
||||
checkAndExecuteFifo(&iter);
|
||||
checkAndExecuteFifo(iter);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CommandingServiceBase::handleReplyHandlerResult(ReturnValue_t result,
|
||||
CommandMapIter iter, CommandMessage& nextCommand, CommandMessage& reply,
|
||||
bool& isStep) {
|
||||
iter->command = nextCommand.getCommand();
|
||||
CommandMapIter iter, CommandMessage* nextCommand,
|
||||
CommandMessage* reply, bool& isStep) {
|
||||
iter->command = nextCommand->getCommand();
|
||||
|
||||
// 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
|
||||
// sendResult as RETURN_OK
|
||||
ReturnValue_t sendResult = RETURN_OK;
|
||||
if (nextCommand.getCommand() != CommandMessage::CMD_NONE) {
|
||||
sendResult = commandQueue->sendMessage(reply.getSender(),
|
||||
&nextCommand);
|
||||
if (nextCommand->getCommand() != CommandMessage::CMD_NONE) {
|
||||
sendResult = commandQueue->sendMessage(reply->getSender(),
|
||||
nextCommand);
|
||||
}
|
||||
|
||||
if (sendResult == RETURN_OK) {
|
||||
@ -161,19 +171,19 @@ void CommandingServiceBase::handleReplyHandlerResult(ReturnValue_t result,
|
||||
TC_VERIFY::COMPLETION_SUCCESS,
|
||||
iter->tcInfo.ackFlags, iter->tcInfo.tcPacketId,
|
||||
iter->tcInfo.tcSequenceControl, 0);
|
||||
checkAndExecuteFifo(&iter);
|
||||
checkAndExecuteFifo(iter);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (isStep) {
|
||||
nextCommand.clearCommandMessage();
|
||||
nextCommand->clear();
|
||||
verificationReporter.sendFailureReport(
|
||||
TC_VERIFY::PROGRESS_FAILURE, iter->tcInfo.ackFlags,
|
||||
iter->tcInfo.tcPacketId,
|
||||
iter->tcInfo.tcSequenceControl, sendResult,
|
||||
++iter->step, failureParameter1, failureParameter2);
|
||||
} else {
|
||||
nextCommand.clearCommandMessage();
|
||||
nextCommand->clear();
|
||||
verificationReporter.sendFailureReport(
|
||||
TC_VERIFY::COMPLETION_FAILURE,
|
||||
iter->tcInfo.ackFlags, iter->tcInfo.tcPacketId,
|
||||
@ -182,7 +192,7 @@ void CommandingServiceBase::handleReplyHandlerResult(ReturnValue_t result,
|
||||
}
|
||||
failureParameter1 = 0;
|
||||
failureParameter2 = 0;
|
||||
checkAndExecuteFifo(&iter);
|
||||
checkAndExecuteFifo(iter);
|
||||
}
|
||||
}
|
||||
|
||||
@ -198,8 +208,8 @@ void CommandingServiceBase::handleRequestQueue() {
|
||||
address = message.getStorageId();
|
||||
packet.setStoreAddress(address);
|
||||
|
||||
if ((packet.getSubService() == 0)
|
||||
|| (isValidSubservice(packet.getSubService()) != RETURN_OK)) {
|
||||
if (packet.getSubService() == 0
|
||||
or isValidSubservice(packet.getSubService()) != RETURN_OK) {
|
||||
rejectPacket(TC_VERIFY::START_FAILURE, &packet, INVALID_SUBSERVICE);
|
||||
continue;
|
||||
}
|
||||
@ -212,8 +222,7 @@ void CommandingServiceBase::handleRequestQueue() {
|
||||
}
|
||||
|
||||
//Is a command already active for the target object?
|
||||
typename FixedMap<MessageQueueId_t,
|
||||
CommandingServiceBase::CommandInfo>::Iterator iter;
|
||||
CommandMapIter iter;
|
||||
iter = commandMap.find(queue);
|
||||
|
||||
if (iter != commandMap.end()) {
|
||||
@ -228,7 +237,7 @@ void CommandingServiceBase::handleRequestQueue() {
|
||||
if (result != RETURN_OK) {
|
||||
rejectPacket(TC_VERIFY::START_FAILURE, &packet, BUSY);
|
||||
} else {
|
||||
startExecution(&packet, &iter);
|
||||
startExecution(&packet, iter);
|
||||
}
|
||||
}
|
||||
|
||||
@ -281,46 +290,44 @@ ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice,
|
||||
}
|
||||
|
||||
|
||||
void CommandingServiceBase::startExecution(
|
||||
TcPacketStored *storedPacket,
|
||||
typename FixedMap<MessageQueueId_t,
|
||||
CommandingServiceBase::CommandInfo>::Iterator *iter) {
|
||||
ReturnValue_t result, sendResult = RETURN_OK;
|
||||
CommandMessage message;
|
||||
(*iter)->subservice = storedPacket->getSubService();
|
||||
result = prepareCommand(&message, (*iter)->subservice,
|
||||
storedPacket->getApplicationData(),
|
||||
storedPacket->getApplicationDataSize(), &(*iter)->state,
|
||||
(*iter)->objectId);
|
||||
void CommandingServiceBase::startExecution(TcPacketStored *storedPacket,
|
||||
CommandMapIter iter) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
CommandMessage command;
|
||||
iter->subservice = storedPacket->getSubService();
|
||||
result = prepareCommand(&command, iter->subservice,
|
||||
storedPacket->getApplicationData(),
|
||||
storedPacket->getApplicationDataSize(), &iter->state,
|
||||
iter->objectId);
|
||||
|
||||
ReturnValue_t sendResult = RETURN_OK;
|
||||
switch (result) {
|
||||
case RETURN_OK:
|
||||
if (message.getCommand() != CommandMessage::CMD_NONE) {
|
||||
sendResult = commandQueue->sendMessage((*iter).value->first,
|
||||
&message);
|
||||
if (command.getCommand() != CommandMessage::CMD_NONE) {
|
||||
sendResult = commandQueue->sendMessage(iter.value->first,
|
||||
&command);
|
||||
}
|
||||
if (sendResult == RETURN_OK) {
|
||||
Clock::getUptime(&(*iter)->uptimeOfStart);
|
||||
(*iter)->step = 0;
|
||||
// (*iter)->state = 0;
|
||||
(*iter)->subservice = storedPacket->getSubService();
|
||||
(*iter)->command = message.getCommand();
|
||||
(*iter)->tcInfo.ackFlags = storedPacket->getAcknowledgeFlags();
|
||||
(*iter)->tcInfo.tcPacketId = storedPacket->getPacketId();
|
||||
(*iter)->tcInfo.tcSequenceControl =
|
||||
Clock::getUptime(&iter->uptimeOfStart);
|
||||
iter->step = 0;
|
||||
iter->subservice = storedPacket->getSubService();
|
||||
iter->command = command.getCommand();
|
||||
iter->tcInfo.ackFlags = storedPacket->getAcknowledgeFlags();
|
||||
iter->tcInfo.tcPacketId = storedPacket->getPacketId();
|
||||
iter->tcInfo.tcSequenceControl =
|
||||
storedPacket->getPacketSequenceControl();
|
||||
acceptPacket(TC_VERIFY::START_SUCCESS, storedPacket);
|
||||
} else {
|
||||
message.clearCommandMessage();
|
||||
command.clear();
|
||||
rejectPacket(TC_VERIFY::START_FAILURE, storedPacket, sendResult);
|
||||
checkAndExecuteFifo(iter);
|
||||
}
|
||||
break;
|
||||
case EXECUTION_COMPLETE:
|
||||
if (message.getCommand() != CommandMessage::CMD_NONE) {
|
||||
if (command.getCommand() != CommandMessage::CMD_NONE) {
|
||||
//Fire-and-forget command.
|
||||
sendResult = commandQueue->sendMessage((*iter).value->first,
|
||||
&message);
|
||||
sendResult = commandQueue->sendMessage(iter.value->first,
|
||||
&command);
|
||||
}
|
||||
if (sendResult == RETURN_OK) {
|
||||
verificationReporter.sendSuccessReport(TC_VERIFY::START_SUCCESS,
|
||||
@ -328,7 +335,7 @@ void CommandingServiceBase::startExecution(
|
||||
acceptPacket(TC_VERIFY::COMPLETION_SUCCESS, storedPacket);
|
||||
checkAndExecuteFifo(iter);
|
||||
} else {
|
||||
message.clearCommandMessage();
|
||||
command.clear();
|
||||
rejectPacket(TC_VERIFY::START_FAILURE, storedPacket, sendResult);
|
||||
checkAndExecuteFifo(iter);
|
||||
}
|
||||
@ -355,12 +362,10 @@ void CommandingServiceBase::acceptPacket(uint8_t reportId,
|
||||
}
|
||||
|
||||
|
||||
void CommandingServiceBase::checkAndExecuteFifo(
|
||||
typename FixedMap<MessageQueueId_t,
|
||||
CommandingServiceBase::CommandInfo>::Iterator *iter) {
|
||||
void CommandingServiceBase::checkAndExecuteFifo(CommandMapIter iter) {
|
||||
store_address_t address;
|
||||
if ((*iter)->fifo.retrieve(&address) != RETURN_OK) {
|
||||
commandMap.erase(iter);
|
||||
if (iter->fifo.retrieve(&address) != RETURN_OK) {
|
||||
commandMap.erase(&iter);
|
||||
} else {
|
||||
TcPacketStored newPacket(address);
|
||||
startExecution(&newPacket, iter);
|
||||
@ -368,9 +373,8 @@ void CommandingServiceBase::checkAndExecuteFifo(
|
||||
}
|
||||
|
||||
|
||||
void CommandingServiceBase::handleUnrequestedReply(
|
||||
CommandMessage* reply) {
|
||||
reply->clearCommandMessage();
|
||||
void CommandingServiceBase::handleUnrequestedReply(CommandMessage* reply) {
|
||||
reply->clear();
|
||||
}
|
||||
|
||||
|
||||
@ -384,18 +388,18 @@ MessageQueueId_t CommandingServiceBase::getCommandQueue() {
|
||||
void CommandingServiceBase::checkTimeout() {
|
||||
uint32_t uptime;
|
||||
Clock::getUptime(&uptime);
|
||||
typename FixedMap<MessageQueueId_t,
|
||||
CommandingServiceBase::CommandInfo>::Iterator iter;
|
||||
CommandMapIter iter;
|
||||
for (iter = commandMap.begin(); iter != commandMap.end(); ++iter) {
|
||||
if ((iter->uptimeOfStart + (timeoutSeconds * 1000)) < uptime) {
|
||||
verificationReporter.sendFailureReport(
|
||||
TC_VERIFY::COMPLETION_FAILURE, iter->tcInfo.ackFlags,
|
||||
iter->tcInfo.tcPacketId, iter->tcInfo.tcSequenceControl,
|
||||
TIMEOUT);
|
||||
checkAndExecuteFifo(&iter);
|
||||
checkAndExecuteFifo(iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CommandingServiceBase::setTaskIF(PeriodicTaskIF* task_) {
|
||||
executingTask = task_;
|
||||
}
|
||||
|
@ -97,9 +97,7 @@ public:
|
||||
* Used to setup the reference of the task, that executes this component
|
||||
* @param task_ Pointer to the taskIF of this task
|
||||
*/
|
||||
virtual void setTaskIF(PeriodicTaskIF* task_){
|
||||
executingTask = task_;
|
||||
};
|
||||
virtual void setTaskIF(PeriodicTaskIF* task_);
|
||||
|
||||
protected:
|
||||
/**
|
||||
@ -141,15 +139,15 @@ protected:
|
||||
* @param objectId Target object ID
|
||||
* @return
|
||||
*/
|
||||
virtual ReturnValue_t prepareCommand(CommandMessage *message,
|
||||
virtual ReturnValue_t prepareCommand(CommandMessage* message,
|
||||
uint8_t subservice, const uint8_t *tcData, size_t tcDataLen,
|
||||
uint32_t *state, object_id_t objectId) = 0;
|
||||
|
||||
/**
|
||||
* This function is implemented by child services to specify how replies
|
||||
* to a command from another software component are handled
|
||||
* to a command from another software component are handled.
|
||||
* @param reply
|
||||
* This is the reply in form of a command message.
|
||||
* This is the reply in form of a generic read-only command message.
|
||||
* @param previousCommand
|
||||
* Command_t of related command
|
||||
* @param state [out/in]
|
||||
@ -163,19 +161,26 @@ protected:
|
||||
* - @c RETURN_OK, @c EXECUTION_COMPLETE or @c NO_STEP_MESSAGE to
|
||||
* generate TC verification success
|
||||
* - @c INVALID_REPLY calls handleUnrequestedReply
|
||||
* - Anything else triggers a TC verification failure
|
||||
* - Anything else triggers a TC verification failure. If RETURN_FAILED
|
||||
* is returned and the command ID is CommandMessage::REPLY_REJECTED,
|
||||
* a failure verification message with the reason as the error parameter
|
||||
* and the initial command as failure parameter 1.
|
||||
*/
|
||||
virtual ReturnValue_t handleReply(const CommandMessage *reply,
|
||||
virtual ReturnValue_t handleReply(const CommandMessage* reply,
|
||||
Command_t previousCommand, uint32_t *state,
|
||||
CommandMessage *optionalNextCommand, object_id_t objectId,
|
||||
CommandMessage* optionalNextCommand, object_id_t objectId,
|
||||
bool *isStep) = 0;
|
||||
|
||||
/**
|
||||
* This function can be overidden to handle unrequested reply,
|
||||
* when the reply sender ID is unknown or is not found is the command map.
|
||||
* The default implementation will clear the command message and all
|
||||
* its contents.
|
||||
* @param reply
|
||||
* Reply which is non-const so the default implementation can clear the
|
||||
* message.
|
||||
*/
|
||||
virtual void handleUnrequestedReply(CommandMessage *reply);
|
||||
virtual void handleUnrequestedReply(CommandMessage* reply);
|
||||
|
||||
virtual void doPeriodicOperation();
|
||||
|
||||
@ -195,6 +200,9 @@ protected:
|
||||
FIFO<store_address_t, 3> fifo;
|
||||
};
|
||||
|
||||
using CommandMapIter = FixedMap<MessageQueueId_t,
|
||||
CommandingServiceBase::CommandInfo>::Iterator;
|
||||
|
||||
const uint16_t apid;
|
||||
|
||||
const uint8_t service;
|
||||
@ -263,21 +271,21 @@ protected:
|
||||
ReturnValue_t sendTmPacket(uint8_t subservice, SerializeIF* content,
|
||||
SerializeIF* header = nullptr);
|
||||
|
||||
void checkAndExecuteFifo(
|
||||
typename FixedMap<MessageQueueId_t, CommandInfo>::Iterator *iter);
|
||||
void checkAndExecuteFifo(CommandMapIter iter);
|
||||
|
||||
private:
|
||||
using CommandMapIter = FixedMap<MessageQueueId_t,
|
||||
CommandingServiceBase::CommandInfo>::Iterator;
|
||||
|
||||
/**
|
||||
* This method handles internal execution of a command,
|
||||
* once it has been started by @sa{startExecution()} in the Request Queue handler.
|
||||
* It handles replies generated by the devices and relayed by the specific service implementation.
|
||||
* This means that it determines further course of action depending on the return values specified
|
||||
* in the service implementation.
|
||||
* once it has been started by @sa{startExecution()} in the request
|
||||
* queue handler.
|
||||
* It handles replies generated by the devices and relayed by the specific
|
||||
* service implementation. This means that it determines further course of
|
||||
* action depending on the return values specified in the service
|
||||
* implementation.
|
||||
* This includes the generation of TC verification messages. Note that
|
||||
* the static framework object ID @c VerificationReporter::messageReceiver needs to be set.
|
||||
* the static framework object ID @c VerificationReporter::messageReceiver
|
||||
* needs to be set.
|
||||
* - TM[1,5] Step Successs
|
||||
* - TM[1,6] Step Failure
|
||||
* - TM[1,7] Completion Success
|
||||
@ -298,12 +306,11 @@ private:
|
||||
|
||||
void acceptPacket(uint8_t reportId, TcPacketStored* packet);
|
||||
|
||||
void startExecution(TcPacketStored *storedPacket,
|
||||
typename FixedMap<MessageQueueId_t, CommandInfo>::Iterator *iter);
|
||||
void startExecution(TcPacketStored *storedPacket, CommandMapIter iter);
|
||||
|
||||
void handleCommandMessage(CommandMessage& reply);
|
||||
void handleCommandMessage(CommandMessage* reply);
|
||||
void handleReplyHandlerResult(ReturnValue_t result, CommandMapIter iter,
|
||||
CommandMessage& nextCommand,CommandMessage& reply, bool& isStep);
|
||||
CommandMessage* nextCommand, CommandMessage* reply, bool& isStep);
|
||||
|
||||
void checkTimeout();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user