srv3 continued

This commit is contained in:
Robin Müller 2020-09-19 17:08:08 +02:00
parent 32c0140cc2
commit 4ab7a08387
5 changed files with 65 additions and 18 deletions

View File

@ -130,15 +130,28 @@ ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage(
CommandMessage* message) {
Command_t command = message->getCommand();
sid_t sid = HousekeepingMessage::getSid(message);
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
switch(command) {
case(HousekeepingMessage::ENABLE_PERIODIC_DIAGNOSTICS_GENERATION):
return togglePeriodicGeneration(sid, true, true);
case(HousekeepingMessage::DISABLE_PERIODIC_DIAGNOSTICS_GENERATION):
return togglePeriodicGeneration(sid, false, true);
case(HousekeepingMessage::ENABLE_PERIODIC_HK_REPORT_GENERATION):
return togglePeriodicGeneration(sid, true, false);
case(HousekeepingMessage::DISABLE_PERIODIC_HK_REPORT_GENERATION):
return togglePeriodicGeneration(sid, false, false);
case(HousekeepingMessage::ENABLE_PERIODIC_DIAGNOSTICS_GENERATION): {
result = togglePeriodicGeneration(sid, true, true);
break;
}
case(HousekeepingMessage::DISABLE_PERIODIC_DIAGNOSTICS_GENERATION): {
result = togglePeriodicGeneration(sid, false, true);
break;
}
case(HousekeepingMessage::ENABLE_PERIODIC_HK_REPORT_GENERATION): {
result = togglePeriodicGeneration(sid, true, false);
break;
}
case(HousekeepingMessage::DISABLE_PERIODIC_HK_REPORT_GENERATION): {
result = togglePeriodicGeneration(sid, false, false);
break;
}
case(HousekeepingMessage::REPORT_DIAGNOSTICS_REPORT_STRUCTURES):
case(HousekeepingMessage::REPORT_HK_REPORT_STRUCTURES):
//return generateSetStructurePacket(sid, );
@ -175,6 +188,16 @@ ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage(
default:
return CommandMessageIF::UNKNOWN_COMMAND;
}
CommandMessage reply;
if(result != HasReturnvaluesIF::RETURN_OK) {
HousekeepingMessage::setHkRequestFailureReply(&reply, sid, result);
}
else {
HousekeepingMessage::setHkRequestSuccessReply(&reply, sid);
}
hkQueue->sendMessage(hkDestinationId, &reply);
return result;
}
ReturnValue_t LocalDataPoolManager::printPoolEntry(
@ -294,8 +317,7 @@ void LocalDataPoolManager::performPeriodicHkGeneration(HkReceiver& receiver) {
ReturnValue_t LocalDataPoolManager::togglePeriodicGeneration(sid_t sid,
bool enable, bool isDiagnostics) {
LocalPoolDataSetBase* dataSet = dynamic_cast<LocalPoolDataSetBase*>(
owner->getDataSetHandle(sid));
LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(sid);
if((dataSet->isDiagnostics() and not isDiagnostics) or
(not dataSet->isDiagnostics() and isDiagnostics)) {
return WRONG_HK_PACKET_TYPE;
@ -312,8 +334,7 @@ ReturnValue_t LocalDataPoolManager::togglePeriodicGeneration(sid_t sid,
ReturnValue_t LocalDataPoolManager::changeCollectionInterval(sid_t sid,
float newCollectionInterval, bool isDiagnostics) {
LocalPoolDataSetBase* dataSet = dynamic_cast<LocalPoolDataSetBase*>(
owner->getDataSetHandle(sid));
LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(sid);
bool targetIsDiagnostics = dataSet->isDiagnostics();
if((targetIsDiagnostics and not isDiagnostics) or
(not targetIsDiagnostics and isDiagnostics)) {

View File

@ -96,6 +96,27 @@ sid_t HousekeepingMessage::getCollectionIntervalModificationCommand(
return getSid(command);
}
void HousekeepingMessage::setHkRequestSuccessReply(CommandMessage *reply,
sid_t sid) {
setSid(reply, sid);
reply->setCommand(HK_REQUEST_SUCCESS);
}
void HousekeepingMessage::setHkRequestFailureReply(CommandMessage *reply,
sid_t sid, ReturnValue_t error) {
setSid(reply, sid);
reply->setCommand(HK_REQUEST_FAILURE);
reply->setParameter3(error);
}
sid_t HousekeepingMessage::getHkRequestFailureReply(const CommandMessage *reply,
ReturnValue_t *error) {
if(error != nullptr) {
*error = reply->getParameter3();
}
return getSid(reply);
}
sid_t HousekeepingMessage::getSid(const CommandMessage* message) {
sid_t sid;
std::memcpy(&sid.raw, message->getData(), sizeof(sid.raw));

View File

@ -118,6 +118,12 @@ public:
static void setHkDiagnosticsReply(CommandMessage* reply, sid_t sid,
store_address_t storeId);
static void setHkRequestSuccessReply(CommandMessage* reply, sid_t sid);
static void setHkRequestFailureReply(CommandMessage* reply, sid_t sid,
ReturnValue_t error);
static sid_t getHkRequestFailureReply(const CommandMessage* reply,
ReturnValue_t* error);
/**
* @brief Generic getter function for housekeeping data replies
* @details

View File

@ -6,7 +6,7 @@
Service3Housekeeping::Service3Housekeeping(object_id_t objectId, uint16_t apid,
uint8_t serviceId):
CommandingServiceBase(objectId, apid, serviceId,
NUM_OF_PARALLEL_COMMANDS, 5) {}
NUM_OF_PARALLEL_COMMANDS, COMMAND_TIMEOUT_SECONDS) {}
Service3Housekeeping::~Service3Housekeeping() {}
@ -204,9 +204,9 @@ ReturnValue_t Service3Housekeeping::handleReply(const CommandMessage* reply,
case(HousekeepingMessage::HK_REQUEST_FAILURE): {
failureParameter1 = objectId;
// also provide failure reason (returnvalue)
// will be most commonly invalid SID or the set already has the desired
// reporting status.
ReturnValue_t error = HasReturnvaluesIF::RETURN_FAILED;
HousekeepingMessage::getHkRequestFailureReply(reply,&error);
failureParameter2 = error;
return CommandingServiceBase::EXECUTION_COMPLETE;
}

View File

@ -414,11 +414,10 @@ void CommandingServiceBase::checkTimeout() {
// TODO: BUG HERE! Problems with comparison operator of iterator.
for (iter = commandMap.begin(); iter != commandMap.end(); ++iter) {
if(commandMap.empty()) {
// intermediate solution.
// intermediate solution!
break;
}
if ((iter->second.uptimeOfStart + (timeoutSeconds * 1000)) < uptime) {
sif::info << "test" << std::endl;
verificationReporter.sendFailureReport(
TC_VERIFY::COMPLETION_FAILURE, iter->second.tcInfo.ackFlags,
iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl,