move json init somewhere else
This commit is contained in:
parent
1b00029202
commit
fd62efcae2
@ -908,9 +908,23 @@ void ObjectFactory::createStrComponents(PowerSwitchIF* pwrSwitcher) {
|
|||||||
startracker::MAX_FRAME_SIZE * 2 + 2, UartModes::NON_CANONICAL);
|
startracker::MAX_FRAME_SIZE * 2 + 2, UartModes::NON_CANONICAL);
|
||||||
starTrackerCookie->setNoFixedSizeReply();
|
starTrackerCookie->setNoFixedSizeReply();
|
||||||
StrHelper* strHelper = new StrHelper(objects::STR_HELPER);
|
StrHelper* strHelper = new StrHelper(objects::STR_HELPER);
|
||||||
|
|
||||||
|
const char* paramJsonFile = nullptr;
|
||||||
|
#ifdef EGSE
|
||||||
|
paramJsonFile = "/home/pi/arcsec/json/flight-config.json";
|
||||||
|
#else
|
||||||
|
#if OBSW_STAR_TRACKER_GROUND_CONFIG == 1
|
||||||
|
paramJsonFile = "/mnt/sd0/startracker/ground-config.json";
|
||||||
|
#else
|
||||||
|
paramJsonFile = "/mnt/sd0/startracker/flight-config.json";
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
if (paramJsonFile == nullptr) {
|
||||||
|
sif::error << "No valid Star Tracker parameter JSON file" << std::endl;
|
||||||
|
}
|
||||||
auto starTracker =
|
auto starTracker =
|
||||||
new StarTrackerHandler(objects::STAR_TRACKER, objects::UART_COM_IF, starTrackerCookie,
|
new StarTrackerHandler(objects::STAR_TRACKER, objects::UART_COM_IF, starTrackerCookie,
|
||||||
strHelper, pcdu::PDU1_CH2_STAR_TRACKER_5V);
|
paramJsonFile, strHelper, pcdu::PDU1_CH2_STAR_TRACKER_5V);
|
||||||
starTracker->setPowerSwitcher(pwrSwitcher);
|
starTracker->setPowerSwitcher(pwrSwitcher);
|
||||||
starTracker->connectModeTreeParent(satsystem::acs::ACS_SUBSYSTEM);
|
starTracker->connectModeTreeParent(satsystem::acs::ACS_SUBSYSTEM);
|
||||||
}
|
}
|
||||||
|
@ -5,14 +5,14 @@
|
|||||||
ArcsecJsonParamBase::ArcsecJsonParamBase(std::string setName) : setName(setName) {}
|
ArcsecJsonParamBase::ArcsecJsonParamBase(std::string setName) : setName(setName) {}
|
||||||
|
|
||||||
ReturnValue_t ArcsecJsonParamBase::create(std::string fullname, uint8_t* buffer) {
|
ReturnValue_t ArcsecJsonParamBase::create(std::string fullname, uint8_t* buffer) {
|
||||||
ReturnValue_t result = returnvalue::OK;
|
// ReturnValue_t result = returnvalue::OK;
|
||||||
result = init(fullname);
|
// result = init(fullname);
|
||||||
if (result != returnvalue::OK) {
|
// if (result != returnvalue::OK) {
|
||||||
sif::warning << "ArcsecJsonParamBase::create: Failed to init parameter command for set "
|
// sif::warning << "ArcsecJsonParamBase::create: Failed to init parameter command for set "
|
||||||
<< setName << std::endl;
|
// << setName << std::endl;
|
||||||
return result;
|
// return result;
|
||||||
}
|
// }
|
||||||
result = createCommand(buffer);
|
ReturnValue_t result = createCommand(buffer);
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
sif::warning << "ArcsecJsonParamBase::create: Failed to create parameter command for set "
|
sif::warning << "ArcsecJsonParamBase::create: Failed to create parameter command for set "
|
||||||
<< setName << std::endl;
|
<< setName << std::endl;
|
||||||
@ -74,12 +74,17 @@ ReturnValue_t ArcsecJsonParamBase::init(const std::string filename) {
|
|||||||
<< std::endl;
|
<< std::endl;
|
||||||
return JSON_FILE_NOT_EXISTS;
|
return JSON_FILE_NOT_EXISTS;
|
||||||
}
|
}
|
||||||
createJsonObject(filename);
|
try {
|
||||||
result = initSet();
|
createJsonObject(filename);
|
||||||
if (result != returnvalue::OK) {
|
result = initSet();
|
||||||
return result;
|
if (result != returnvalue::OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return returnvalue::OK;
|
||||||
|
} catch (json::exception& e) {
|
||||||
|
// TODO: Re-create json file from backup here.
|
||||||
|
return returnvalue::FAILED;
|
||||||
}
|
}
|
||||||
return returnvalue::OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArcsecJsonParamBase::createJsonObject(const std::string fullname) {
|
void ArcsecJsonParamBase::createJsonObject(const std::string fullname) {
|
||||||
|
@ -41,6 +41,17 @@ class ArcsecJsonParamBase {
|
|||||||
*/
|
*/
|
||||||
ArcsecJsonParamBase(std::string setName);
|
ArcsecJsonParamBase(std::string setName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Initializes the properties json object and the set json object
|
||||||
|
*
|
||||||
|
* @param fullname Name including absolute path to json file
|
||||||
|
* @param setName The name of the set to work on
|
||||||
|
*
|
||||||
|
* @param return JSON_FILE_NOT_EXISTS if specified file does not exist, otherwise
|
||||||
|
* returnvalue::OK
|
||||||
|
*/
|
||||||
|
ReturnValue_t init(const std::string filename);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Fills a buffer with a parameter set
|
* @brief Fills a buffer with a parameter set
|
||||||
*
|
*
|
||||||
@ -124,17 +135,6 @@ class ArcsecJsonParamBase {
|
|||||||
*/
|
*/
|
||||||
virtual ReturnValue_t createCommand(uint8_t* buffer) = 0;
|
virtual ReturnValue_t createCommand(uint8_t* buffer) = 0;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Initializes the properties json object and the set json object
|
|
||||||
*
|
|
||||||
* @param fullname Name including absolute path to json file
|
|
||||||
* @param setName The name of the set to work on
|
|
||||||
*
|
|
||||||
* @param return JSON_FILE_NOT_EXISTS if specified file does not exist, otherwise
|
|
||||||
* returnvalue::OK
|
|
||||||
*/
|
|
||||||
ReturnValue_t init(const std::string filename);
|
|
||||||
|
|
||||||
void createJsonObject(const std::string fullname);
|
void createJsonObject(const std::string fullname);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,7 +16,8 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie,
|
StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie,
|
||||||
StrHelper* strHelper, power::Switch_t powerSwitch)
|
const char* jsonFileStr, StrHelper* strHelper,
|
||||||
|
power::Switch_t powerSwitch)
|
||||||
: DeviceHandlerBase(objectId, comIF, comCookie),
|
: DeviceHandlerBase(objectId, comIF, comCookie),
|
||||||
temperatureSet(this),
|
temperatureSet(this),
|
||||||
versionSet(this),
|
versionSet(this),
|
||||||
@ -41,6 +42,7 @@ StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF,
|
|||||||
logSubscriptionSet(this),
|
logSubscriptionSet(this),
|
||||||
debugCameraSet(this),
|
debugCameraSet(this),
|
||||||
strHelper(strHelper),
|
strHelper(strHelper),
|
||||||
|
paramJsonFile(jsonFileStr),
|
||||||
powerSwitch(powerSwitch) {
|
powerSwitch(powerSwitch) {
|
||||||
if (comCookie == nullptr) {
|
if (comCookie == nullptr) {
|
||||||
sif::error << "StarTrackerHandler: Invalid com cookie" << std::endl;
|
sif::error << "StarTrackerHandler: Invalid com cookie" << std::endl;
|
||||||
@ -60,6 +62,24 @@ ReturnValue_t StarTrackerHandler::initialize() {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: This takes ages. Move it into a separate thread, use a mutexed boolean
|
||||||
|
// to check whether init was done. Or move it into the helper class..
|
||||||
|
// Also move update of these classes into the helper class.
|
||||||
|
tracking.init(paramJsonFile);
|
||||||
|
logLevel.init(paramJsonFile);
|
||||||
|
logSubscription.init(paramJsonFile);
|
||||||
|
debugCamera.init(paramJsonFile);
|
||||||
|
algo.init(paramJsonFile);
|
||||||
|
validation.init(paramJsonFile);
|
||||||
|
matching.init(paramJsonFile);
|
||||||
|
lisa.init(paramJsonFile);
|
||||||
|
centroiding.init(paramJsonFile);
|
||||||
|
camera.init(paramJsonFile);
|
||||||
|
imageProcessor.init(paramJsonFile);
|
||||||
|
mounting.init(paramJsonFile);
|
||||||
|
limits.init(paramJsonFile);
|
||||||
|
subscription.init(paramJsonFile);
|
||||||
|
|
||||||
EventManagerIF* manager = ObjectManager::instance()->get<EventManagerIF>(objects::EVENT_MANAGER);
|
EventManagerIF* manager = ObjectManager::instance()->get<EventManagerIF>(objects::EVENT_MANAGER);
|
||||||
if (manager == nullptr) {
|
if (manager == nullptr) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
@ -36,7 +36,7 @@ class StarTrackerHandler : public DeviceHandlerBase {
|
|||||||
* to high to enable the device.
|
* to high to enable the device.
|
||||||
*/
|
*/
|
||||||
StarTrackerHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie,
|
StarTrackerHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie,
|
||||||
StrHelper* strHelper, power::Switch_t powerSwitch);
|
const char* jsonFileStr, StrHelper* strHelper, power::Switch_t powerSwitch);
|
||||||
virtual ~StarTrackerHandler();
|
virtual ~StarTrackerHandler();
|
||||||
|
|
||||||
ReturnValue_t initialize() override;
|
ReturnValue_t initialize() override;
|
||||||
@ -232,15 +232,7 @@ class StarTrackerHandler : public DeviceHandlerBase {
|
|||||||
Limits limits;
|
Limits limits;
|
||||||
Subscription subscription;
|
Subscription subscription;
|
||||||
|
|
||||||
#ifdef EGSE
|
std::string paramJsonFile;
|
||||||
std::string paramJsonFile = "/home/pi/arcsec/json/flight-config.json";
|
|
||||||
#else
|
|
||||||
#if OBSW_STAR_TRACKER_GROUND_CONFIG == 1
|
|
||||||
std::string paramJsonFile = "/mnt/sd0/startracker/ground-config.json";
|
|
||||||
#else
|
|
||||||
std::string paramJsonFile = "/mnt/sd0/startracker/flight-config.json";
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
enum class NormalState { TEMPERATURE_REQUEST, SOLUTION_REQUEST };
|
enum class NormalState { TEMPERATURE_REQUEST, SOLUTION_REQUEST };
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user