This commit is contained in:
parent
a648b4be37
commit
f9d2d35f86
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user