This commit is contained in:
2025-03-21 18:03:01 +03:00
parent 441743ff01
commit b9ee662850
4 changed files with 49 additions and 23 deletions

View File

@@ -110,6 +110,8 @@ class MccMount : public utils::MccSpdlogLogger
public:
static constexpr MccMountType mountType = MOUNT_TYPE;
enum IersDatabaseType { IERS_DB_LEAPSECS, IERS_DB_EARTH_ORIENT };
/* mount main-cycle variable quantities (mount orientation) */
struct mount_orient_t {
// time-related
@@ -162,23 +164,8 @@ public:
logInfo("Load leap seconds and Earth orientation databases ...");
auto time_db_loader = [this](const std::string& filename, std::string_view type, auto& db) {
if (filename.empty()) {
logWarn("An empty {} filename! Skip and keep default values!", type);
return;
}
bool ok = db.load(filename);
if (!ok) {
logError("CANNOT parse {} file '{}' or it is not accessible!", type, filename);
logWarn("Keep {} database in default state!", type);
} else {
logInfo("{} database was successfully loaded from '{}' file", type, filename);
}
};
time_db_loader(_mountCurrentConfig.leap_seconds_filename, "leap seconds", _leapSecondsDB);
time_db_loader(_mountCurrentConfig.earth_orient_filename, "Earth orientation", _earthOrientDB);
updateIERSDatabase(IERS_DB_LEAPSECS);
updateIERSDatabase(IERS_DB_EARTH_ORIENT);
}
virtual ~MccMount()
@@ -211,6 +198,37 @@ public:
_currentMeteo.store(meteo);
}
bool updateIERSDatabase(IersDatabaseType type)
{
auto time_db_loader = [this](const std::string& filename, std::string_view type, auto& db) {
if (filename.empty()) {
logWarn("An empty {} filename! Skip and keep default values!", type);
return false;
}
bool ok = db.load(filename);
if (!ok) {
logError("CANNOT parse {} file '{}' or it is not accessible!", type, filename);
logWarn("Keep {} database in default state!", type);
} else {
logInfo("{} database was successfully loaded from '{}' file", type, filename);
}
return ok;
};
switch (type) {
case IERS_DB_LEAPSECS:
return time_db_loader(_mountCurrentConfig.leap_seconds_filename, "leap seconds", _leapSecondsDB);
case IERS_DB_EARTH_ORIENT:
return time_db_loader(_mountCurrentConfig.earth_orient_filename, "Earth orientation", _earthOrientDB);
default:
logError("Invalid type for IERS database!");
return false;
}
}
protected:
mount_config_t _mountCurrentConfig;