...
This commit is contained in:
parent
e80116d4ae
commit
ea99bc721b
@ -120,10 +120,9 @@ set(CNTR_PROTO_LIB comm_proto)
|
|||||||
add_library(${CNTR_PROTO_LIB} STATIC ${CNTR_PROTO_LIB_SRC})
|
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
|
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)
|
set(MOUNT_SERVER_APP mount_server)
|
||||||
add_executable(${MOUNT_SERVER_APP} ${MOUNT_SERVER_APP_SRC}
|
add_executable(${MOUNT_SERVER_APP} ${MOUNT_SERVER_APP_SRC})
|
||||||
mcc_coord.h)
|
|
||||||
# target_include_directories(${MOUNT_SERVER_APP} PUBLIC ${ERFA_INCLUDE_DIR})
|
# 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)
|
||||||
|
|
||||||
|
|||||||
@ -73,28 +73,30 @@ public:
|
|||||||
// auto ang = MccCoordinate{180.0, mcc_degrees};
|
// auto ang = MccCoordinate{180.0, mcc_degrees};
|
||||||
MccCoordinate(std::convertible_to<double> auto const& val, const MccDegreeTag tag)
|
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{"-12:34:56.789"}; // from degrees:minutes:seconds
|
||||||
|
// auto ang = MccCoordinate{"123.574698"}; // from degrees
|
||||||
MccCoordinate(traits::mcc_input_char_range auto const& val)
|
MccCoordinate(traits::mcc_input_char_range auto const& val)
|
||||||
{
|
{
|
||||||
auto res = utils::parsAngleString(val);
|
auto res = utils::parsAngleString(val);
|
||||||
if (res.has_value()) {
|
if (res.has_value()) {
|
||||||
_angleInRads = res.value() * std::numbers::pi / 180.0;
|
_angleInRads = res.value() * utils::deg2radCoeff;
|
||||||
} else {
|
} else {
|
||||||
throw std::invalid_argument("invalid sexagesimal representation");
|
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{"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)
|
MccCoordinate(traits::mcc_input_char_range auto const& val, const MccHMSTag)
|
||||||
{
|
{
|
||||||
auto res = utils::parsAngleString(val, true);
|
auto res = utils::parsAngleString(val, true);
|
||||||
if (res.has_value()) {
|
if (res.has_value()) {
|
||||||
_angleInRads = res.value() * std::numbers::pi / 180.0;
|
_angleInRads = res.value() * utils::deg2radCoeff;
|
||||||
} else {
|
} else {
|
||||||
throw std::invalid_argument("invalid sexagesimal representation");
|
throw std::invalid_argument("invalid sexagesimal representation");
|
||||||
}
|
}
|
||||||
|
|||||||
19
cxx/mount.h
19
cxx/mount.h
@ -151,7 +151,7 @@ public:
|
|||||||
|
|
||||||
MccMount(traits::mcc_input_char_range auto const& logger_mark = "[MOUNT]",
|
MccMount(traits::mcc_input_char_range auto const& logger_mark = "[MOUNT]",
|
||||||
std::shared_ptr<spdlog::logger> logger = spdlog::null_logger_mt("NULL"))
|
std::shared_ptr<spdlog::logger> logger = spdlog::null_logger_mt("NULL"))
|
||||||
: utils::MccSpdlogLogger(logger), _exitCurrentState([]() {})
|
: utils::MccSpdlogLogger(logger), _exitCurrentState([]() {}), _currentStateName([]() {})
|
||||||
{
|
{
|
||||||
std::istringstream strst;
|
std::istringstream strst;
|
||||||
|
|
||||||
@ -180,9 +180,15 @@ public:
|
|||||||
_exitCurrentState(); // exit from current state
|
_exitCurrentState(); // exit from current state
|
||||||
_exitCurrentState = [&state]() { state.exit(); };
|
_exitCurrentState = [&state]() { state.exit(); };
|
||||||
|
|
||||||
|
_currentStateName = [&state]() { return state.name(); };
|
||||||
|
|
||||||
state.enter();
|
state.enter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string_view currenStateName() const
|
||||||
|
{
|
||||||
|
return _currentStateName();
|
||||||
|
}
|
||||||
|
|
||||||
MccMountPosition getMountData() const noexcept
|
MccMountPosition getMountData() const noexcept
|
||||||
{
|
{
|
||||||
@ -271,7 +277,7 @@ public:
|
|||||||
|
|
||||||
// returns a time to reach the prohibited area:
|
// returns a time to reach the prohibited area:
|
||||||
// 0 - already in the zone
|
// 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
|
// the kind of cordinates (e.g. IRCS or apparent, equatorial or horizontal) is a subject of implementation
|
||||||
auto pzTimeTo(const MccCoordinate& xcoord,
|
auto pzTimeTo(const MccCoordinate& xcoord,
|
||||||
const MccCoordinate& ycoord,
|
const MccCoordinate& ycoord,
|
||||||
@ -284,7 +290,7 @@ public:
|
|||||||
|
|
||||||
// returns a time to exit the prohibited area:
|
// returns a time to exit the prohibited area:
|
||||||
// 0 - already out of the zone
|
// 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
|
// the kind of cordinates (e.g. IRCS or apparent, equatorial or horizontal) is a subject of implementation
|
||||||
auto pzTimeFrom(const MccCoordinate& xcoord,
|
auto pzTimeFrom(const MccCoordinate& xcoord,
|
||||||
const MccCoordinate& ycoord,
|
const MccCoordinate& ycoord,
|
||||||
@ -296,6 +302,12 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// above two methods in one call
|
// 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,
|
auto pzCheck(const MccCoordinate& xcoord,
|
||||||
const MccCoordinate& ycoord,
|
const MccCoordinate& ycoord,
|
||||||
traits::mcc_systime_c auto const& utc = std::chrono::system_clock::now())
|
traits::mcc_systime_c auto const& utc = std::chrono::system_clock::now())
|
||||||
@ -342,6 +354,7 @@ protected:
|
|||||||
|
|
||||||
// std::shared_ptr<spdlog::logger> _mountLogger;
|
// std::shared_ptr<spdlog::logger> _mountLogger;
|
||||||
std::function<void()> _exitCurrentState;
|
std::function<void()> _exitCurrentState;
|
||||||
|
std::function<std::string_view()> _currentStateName;
|
||||||
|
|
||||||
// time scales related databases
|
// time scales related databases
|
||||||
astrom::MccLeapSeconds _leapSecondsDB;
|
astrom::MccLeapSeconds _leapSecondsDB;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user