This commit is contained in:
Timur A. Fatkhullin 2025-04-16 18:12:02 +03:00
parent e80116d4ae
commit ea99bc721b
3 changed files with 25 additions and 11 deletions

View File

@ -120,10 +120,9 @@ set(CNTR_PROTO_LIB comm_proto)
add_library(${CNTR_PROTO_LIB} STATIC ${CNTR_PROTO_LIB_SRC})
set(MOUNT_SERVER_APP_SRC mount.h mount_state.h mount_server.cpp comm_server.h comm_server_endpoint.h comm_server_configfile.h mount_astrom.h
mount_astrom_default.h)
mount_astrom_default.h mcc_coord.h)
set(MOUNT_SERVER_APP mount_server)
add_executable(${MOUNT_SERVER_APP} ${MOUNT_SERVER_APP_SRC}
mcc_coord.h)
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)

View File

@ -73,28 +73,30 @@ public:
// auto ang = MccCoordinate{180.0, mcc_degrees};
MccCoordinate(std::convertible_to<double> auto const& val, const MccDegreeTag tag)
{
_angleInRads = val * std::numbers::pi / 180.0;
_angleInRads = val * utils::deg2radCoeff;
}
// constuct angle from sexagesimal representation, e.g.:
// constuct angle from sexagesimal representation or floating-point number of degrees, e.g.:
// auto ang = MccCoordinate{"-12:34:56.789"}; // from degrees:minutes:seconds
// auto ang = MccCoordinate{"123.574698"}; // from degrees
MccCoordinate(traits::mcc_input_char_range auto const& val)
{
auto res = utils::parsAngleString(val);
if (res.has_value()) {
_angleInRads = res.value() * std::numbers::pi / 180.0;
_angleInRads = res.value() * utils::deg2radCoeff;
} else {
throw std::invalid_argument("invalid sexagesimal representation");
}
}
// construct angle from sexagesimal representation, e.g.:
// construct angle from sexagesimal representation or floating-point number of degrees, e.g.:
// auto ang = MccCoordinate{"01:23:45.6789", mcc_hms}; // from hours:minutes:seconds
// auto ang = MccCoordinate{"123.574698"}; // from degrees
MccCoordinate(traits::mcc_input_char_range auto const& val, const MccHMSTag)
{
auto res = utils::parsAngleString(val, true);
if (res.has_value()) {
_angleInRads = res.value() * std::numbers::pi / 180.0;
_angleInRads = res.value() * utils::deg2radCoeff;
} else {
throw std::invalid_argument("invalid sexagesimal representation");
}

View File

@ -151,7 +151,7 @@ public:
MccMount(traits::mcc_input_char_range auto const& logger_mark = "[MOUNT]",
std::shared_ptr<spdlog::logger> logger = spdlog::null_logger_mt("NULL"))
: utils::MccSpdlogLogger(logger), _exitCurrentState([]() {})
: utils::MccSpdlogLogger(logger), _exitCurrentState([]() {}), _currentStateName([]() {})
{
std::istringstream strst;
@ -180,9 +180,15 @@ public:
_exitCurrentState(); // exit from current state
_exitCurrentState = [&state]() { state.exit(); };
_currentStateName = [&state]() { return state.name(); };
state.enter();
}
std::string_view currenStateName() const
{
return _currentStateName();
}
MccMountPosition getMountData() const noexcept
{
@ -271,7 +277,7 @@ public:
// returns a time to reach the prohibited area:
// 0 - already in the zone
// std::chrono::sys_time<>::max() - never reach the zone
// std::chrono::duration<>::max() - never reach the zone
// the kind of cordinates (e.g. IRCS or apparent, equatorial or horizontal) is a subject of implementation
auto pzTimeTo(const MccCoordinate& xcoord,
const MccCoordinate& ycoord,
@ -284,7 +290,7 @@ public:
// returns a time to exit the prohibited area:
// 0 - already out of the zone
// std::chrono::sys_time<>::max() - the zone itself
// std::chrono::duration<>::max() - the zone itself
// the kind of cordinates (e.g. IRCS or apparent, equatorial or horizontal) is a subject of implementation
auto pzTimeFrom(const MccCoordinate& xcoord,
const MccCoordinate& ycoord,
@ -296,6 +302,12 @@ public:
}
// above two methods in one call
// returns a std::tuple with elements
// 0 - boolean: true - coordinates in zone, false - otherwise
// 1 - time duration to reach the zone (0 - if already in the zone, chrono::duration<>::max() if never reach the
// zone)
// 2 - time duration to exit the zone (0 - if already out of the zone, chrono::duration<>::max() if never
// exit the zone)
auto pzCheck(const MccCoordinate& xcoord,
const MccCoordinate& ycoord,
traits::mcc_systime_c auto const& utc = std::chrono::system_clock::now())
@ -342,6 +354,7 @@ protected:
// std::shared_ptr<spdlog::logger> _mountLogger;
std::function<void()> _exitCurrentState;
std::function<std::string_view()> _currentStateName;
// time scales related databases
astrom::MccLeapSeconds _leapSecondsDB;