This commit is contained in:
2025-07-15 17:32:48 +03:00
parent 62258a991b
commit 46e4b1e95f
8 changed files with 383 additions and 226 deletions

View File

@@ -37,9 +37,12 @@ protected:
"time point is out of range",
"time point is out of range",
"dubious year",
"unacceptable year"};
"unacceptable year",
"leap seconds update error",
"bulletin A update error"};
public:
static constexpr double DEFAULT_WAVELENGTH = 0.55; // default observed wavelength in mkm
enum error_t : size_t {
ERROR_OK = 0,
ERROR_INVALID_INPUT_ARG,
@@ -48,7 +51,9 @@ public:
ERROR_BULLETINA_OUT_OF_RANGE,
ERROR_LEAPSECONDS_OUT_OF_RANGE,
ERROR_DUBIOUS_YEAR,
ERROR_UNACCEPTABLE_DATE
ERROR_UNACCEPTABLE_DATE,
ERROR_UPDATE_LEAPSECONDS,
ERROR_UPDATE_BULLETINA,
};
@@ -66,7 +71,7 @@ public:
struct engine_state_t {
meteo_t meteo{.temperature = 0.0, .humidity = 0.5, .pressure = 1010.0};
double wavelength = 0.55; // observed wavelength in mkm
double wavelength = DEFAULT_WAVELENGTH; // observed wavelength in mkm
AngleT lat = "00:00:00"_dms; // site latitude
AngleT lon = "00:00:00"_dms; // site longitude
@@ -123,6 +128,61 @@ public:
return _currentState;
}
void updateMeteo(meteo_t meteo)
{
std::lock_guard lock{_stateMutex};
_currentState.meteo = std::move(meteo);
}
error_t updateLeapSeconds(std::derived_from<std::basic_istream<char>> auto& stream, char comment_sym = '#')
{
std::lock_guard lock{_stateMutex};
if (!_currentState._leapSeconds.load(stream, comment_sym)) {
return ERROR_UPDATE_LEAPSECONDS;
}
return ERROR_OK;
}
error_t updateLeapSeconds(traits::mcc_input_char_range auto const& filename, char comment_sym = '#')
{
std::lock_guard lock{_stateMutex};
if (!_currentState._leapSeconds.load(filename, comment_sym)) {
return ERROR_UPDATE_LEAPSECONDS;
}
return ERROR_OK;
}
error_t updateBulletinA(std::derived_from<std::basic_istream<char>> auto& stream, char comment_sym = '*')
{
std::lock_guard lock{_stateMutex};
if (!_currentState._bulletinA.load(stream, comment_sym)) {
return ERROR_UPDATE_BULLETINA;
}
return ERROR_OK;
}
error_t updateBulletinA(traits::mcc_input_char_range auto const& filename, char comment_sym = '*')
{
std::lock_guard lock{_stateMutex};
if (!_currentState._bulletinA.load(filename, comment_sym)) {
return ERROR_UPDATE_BULLETINA;
}
return ERROR_OK;
}
std::string errorString(error_t err) const
{