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

View File

@ -120,7 +120,7 @@ set(MOUNT_SERVER_APP_SRC mount.h mount_state.h mount_server.cpp comm_server.h co
set(MOUNT_SERVER_APP mount_server)
add_executable(${MOUNT_SERVER_APP} ${MOUNT_SERVER_APP_SRC})
# target_include_directories(${MOUNT_SERVER_APP} PUBLIC ${ERFA_INCLUDE_DIR})
target_link_libraries(${MOUNT_SERVER_APP} ${CNTR_PROTO_LIB} spdlog::spdlog_header_only ${ERFA_LIB})
target_link_libraries(${MOUNT_SERVER_APP} ${CNTR_PROTO_LIB} spdlog::spdlog_header_only ERFA_LIB)
if (WITH_TESTS)
set(CNTR_PROTO_TEST_APP cntr_proto_test)
@ -133,6 +133,6 @@ if (WITH_TESTS)
add_executable(${CFGFILE_TEST_APP} tests/configfile_test.cpp)
set(ASTROM_TEST_APP astrom_test)
add_executable(${ASTROM_TEST_APP} tests/astrom_test.cpp
mcc_traits.h)
add_executable(${ASTROM_TEST_APP} tests/astrom_test.cpp)
target_link_libraries(${ASTROM_TEST_APP} ERFA_LIB)
endif()

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;

View File

@ -42,9 +42,8 @@ concept mcc_real_or_char_range =
namespace mcc::astrom
{
// a time duration represented in radians (the precision is near 1 nanosecond)
// typedef std::chrono::duration<double, std::ratio<134670467, 10000000000000000>> mcc_radsec_duration_t;
typedef std::chrono::duration<double, std::ratio<134670467, 10000000000000000>> mcc_chrono_radians;
// a time duration represented in radians (the precision is about 100 nanosecond for 10E8 secs (~1157 days))
typedef std::chrono::duration<double, std::ratio<314159265358979, 4320000000000000000>> mcc_chrono_radians;
// https://gssc.esa.int/navipedia/index.php?title=CEP_to_ITRF

View File

@ -59,6 +59,15 @@ int main(int argc, char* argv[])
auto st = mcc::astrom::mcc_julday(now, mjd);
std::cout << "MJD for now: " << std::setprecision(19) << mjd << " (" << now << ")\n";
// double pres = 786.6;
// double temp = 0.0;
// double hum = 0.8;
// double A, B;
// erfa::eraRefco(pres, temp, hum, 0.5, &A, &B);
// const double rr = 180.0 / std::numbers::pi * 60.0;
// std::cout << "A(arcmin) = " << A * rr << "; B(arcmin) = " << B * rr << "\n";
return ecode;
}