From f9d2d35f86cd27adccb634ca36f4c2231cc28211 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 21 Nov 2023 14:34:15 +0100 Subject: [PATCH] this is stupid --- mission/acs/str/StarTrackerHandler.cpp | 41 +++++++++++++------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/mission/acs/str/StarTrackerHandler.cpp b/mission/acs/str/StarTrackerHandler.cpp index 9e7d3b5e..0b58d61e 100644 --- a/mission/acs/str/StarTrackerHandler.cpp +++ b/mission/acs/str/StarTrackerHandler.cpp @@ -169,6 +169,7 @@ bool StarTrackerHandler::reloadJsonCfgFile() { auto strCfgPath = cfgPathGetter.getCfgPath(); if (strCfgPath.has_value()) { jcfgPending = true; + JCFG_DONE = false; jsonCfgTask = std::thread{setUpJsonCfgs, std::ref(jcfgs), strCfgPath.value()}; return true; } @@ -182,6 +183,21 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu ReturnValue_t result = returnvalue::OK; switch (actionId) { + case (startracker::RELOAD_JSON_CFG_FILE): { + if (jcfgPending) { + return HasActionsIF::IS_BUSY; + } + // It should be noted that this just reloads the JSON config structure in memory from the + // JSON file. The configuration still needs to be sent to the STR. The easiest way to achieve + // this is to simply reboot the device after a reload. + if(reloadJsonCfgFile()) { + // Could trigger this after the thread has finished, but the base class does not accept + // commands for buildCommandForCommand when it is OFF. I am sure there is way to solve + // this, but I don't care anymore. This is fine. + return HasActionsIF::EXECUTION_FINISHED; + }; + return returnvalue::OK; + } case (startracker::ADD_SECONDARY_TM_TO_NORMAL_MODE): { if (size < 4) { return HasActionsIF::INVALID_PARAMETERS; @@ -195,16 +211,6 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu addSecondaryTmForNormalMode(idToAdd); return EXECUTION_FINISHED; } - case (startracker::RELOAD_JSON_CFG_FILE): { - if (jcfgPending) { - return HasActionsIF::IS_BUSY; - } - // It should be noted that this just reloads the JSON config structure in memory from the - // JSON file. The configuration still needs to be sent to the STR. The easiest way to achieve - // this is to simply reboot the device after a reload. - reloadJsonCfgFile(); - return returnvalue::OK; - } case (startracker::RESET_SECONDARY_TM_SET): { resetSecondaryTmSet(); return EXECUTION_FINISHED; @@ -355,20 +361,11 @@ void StarTrackerHandler::performOperationHook() { } if (jcfgPending) { if (JCFG_DONE) { - auto iter = deviceCommandMap.find(startracker::RELOAD_JSON_CFG_FILE); - if (iter != deviceCommandMap.end()) { - if (iter->second.sendReplyTo != MessageQueueIF::NO_QUEUE) { - actionHelper.finish(true, iter->second.sendReplyTo, startracker::RELOAD_JSON_CFG_FILE); - } - } jsonCfgTask.join(); jcfgPending = false; + JCFG_DONE = false; } else if (jcfgCountdown.hasTimedOut()) { - auto iter = deviceCommandMap.find(startracker::RELOAD_JSON_CFG_FILE); - if (iter->second.sendReplyTo != MessageQueueIF::NO_QUEUE) { - actionHelper.finish(false, iter->second.sendReplyTo, startracker::RELOAD_JSON_CFG_FILE, - returnvalue::FAILED); - } + JCFG_DONE = false; } } } @@ -549,6 +546,7 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi rawPacket = commandBuffer; return returnvalue::OK; } + case (startracker::REQ_TIME): { prepareTimeRequest(); return returnvalue::OK; @@ -762,6 +760,7 @@ void StarTrackerHandler::fillCommandAndReplyMap() { startracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandMap(startracker::UPLOAD_IMAGE); this->insertInCommandMap(startracker::DOWNLOAD_IMAGE); + this->insertInCommandMap(startracker::RELOAD_JSON_CFG_FILE); this->insertInCommandAndReplyMap(startracker::REQ_POWER, 3, &powerSet, startracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(startracker::REQ_INTERFACE, 3, &interfaceSet,