...
This commit is contained in:
65
cxx/mount.h
65
cxx/mount.h
@@ -151,78 +151,33 @@ public:
|
||||
|
||||
addMarkToPatternIdx(logger_mark);
|
||||
|
||||
logDebug("Create MccMount class instance: thread = {}", getThreadId());
|
||||
|
||||
logDebug("Create MccMount class instance: thread = {}", std::this_thread::get_id());
|
||||
|
||||
|
||||
// init time scales related databases to default (pre-defined) state
|
||||
|
||||
logInfo("initializing leap seconds database to default state ...");
|
||||
strst.str(defaults::MCC_DEFAULT_LEAP_SECONDS_FILE);
|
||||
_leapSecondsDB = astro::mcc_parse_leapsecs(strst);
|
||||
logInfo("leap seconds default database expired date: {}", _leapSecondsDB.expireDate);
|
||||
|
||||
logInfo("initializing Earth orientation (pole coordinates, UT1-UTC) database to default state ...");
|
||||
strst.clear();
|
||||
strst.str(defaults::MCC_DEFAULT_IERS_BULLETIN_A_FILE);
|
||||
_earthOrientDB = astro::mcc_parse_bulletinA(strst);
|
||||
logInfo("Earth orientation default database (Bulletin A) date: {}", _earthOrientDB.bulletinDate);
|
||||
|
||||
// load time scales relates databases from files
|
||||
std::ifstream fst;
|
||||
|
||||
logInfo("Load leap seconds and Earth orientation databases ...");
|
||||
|
||||
auto time_db_loader = [&fst, this](const std::string& filename, std::string_view type, auto& db) {
|
||||
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;
|
||||
}
|
||||
|
||||
fst.open(filename);
|
||||
if (!fst.is_open()) {
|
||||
logError("CANNOT open {} file '{}'!", type, filename);
|
||||
logWarn("Keep {} database in default state!", type);
|
||||
return;
|
||||
}
|
||||
|
||||
if constexpr (std::same_as<astro::leapsecond_db_t, std::decay_t<decltype(db)>>) {
|
||||
db = astro::mcc_parse_leapsecs(fst);
|
||||
} else if constexpr (std::same_as<astro::earth_orient_db_t, std::decay_t<decltype(db)>>) {
|
||||
db = astro::mcc_parse_bulletinA(fst);
|
||||
} else {
|
||||
static_assert(false, "INVALID DATABASE TYPE!!!");
|
||||
}
|
||||
|
||||
if (db.state != astro::IERS_DB_STATE_OK) {
|
||||
logError("CANNOT parse {} file '{}'!", type, filename);
|
||||
bool ok = db.load(filename);
|
||||
if (!ok) {
|
||||
logError("CANNOT parse {} file '{}' or it is not accessable!", type, filename);
|
||||
logWarn("Keep {} database in default state!", type);
|
||||
} else {
|
||||
logInfo("{} database was successfully loaded from '{}' file", type, filename);
|
||||
}
|
||||
|
||||
fst.close();
|
||||
};
|
||||
|
||||
astro::leapsecond_db_t ldb;
|
||||
astro::earth_orient_db_t edb;
|
||||
|
||||
time_db_loader(_mountCurrentConfig.leap_seconds_filename, "leap seconds", ldb);
|
||||
if (ldb.state == astro::IERS_DB_STATE_OK) {
|
||||
_leapSecondsDB = std::move(ldb);
|
||||
logInfo("leap seconds default database expired date: {}", _leapSecondsDB.expireDate);
|
||||
}
|
||||
|
||||
time_db_loader(_mountCurrentConfig.earth_orient_filename, "Earth orientation", edb);
|
||||
if (edb.state == astro::IERS_DB_STATE_OK) {
|
||||
_earthOrientDB = std::move(edb);
|
||||
logInfo("Earth orientation default database (Bulletin A) date: {}", _earthOrientDB.bulletinDate);
|
||||
}
|
||||
time_db_loader(_mountCurrentConfig.leap_seconds_filename, "leap seconds", _leapSecondsDB);
|
||||
time_db_loader(_mountCurrentConfig.earth_orient_filename, "Earth orientation", _earthOrientDB);
|
||||
}
|
||||
|
||||
virtual ~MccMount()
|
||||
{
|
||||
logDebug("Delete MccMount class instance: thread = {}", std::this_thread::get_id());
|
||||
logDebug("Delete MccMount class instance: thread = {}", getThreadId());
|
||||
}
|
||||
|
||||
|
||||
@@ -257,8 +212,8 @@ protected:
|
||||
std::function<void()> _exitCurrentState;
|
||||
|
||||
// time scales related databases
|
||||
astro::leapsecond_db_t _leapSecondsDB;
|
||||
astro::earth_orient_db_t _earthOrientDB;
|
||||
astrom::MccLeapSeconds _leapSecondsDB;
|
||||
astrom::MccIersBulletinA _earthOrientDB;
|
||||
|
||||
std::atomic<mount_orient_t> _currentMountOrient;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user