This commit is contained in:
2025-10-29 18:47:24 +03:00
parent 6a72ead855
commit 50e79aa0ae
18 changed files with 273 additions and 62 deletions

View File

@@ -62,6 +62,7 @@ add_library(ERFA_LIB STATIC IMPORTED)
set_target_properties(ERFA_LIB PROPERTIES IMPORTED_LOCATION ${CMAKE_BINARY_DIR}/erfa_lib/liberfa.a)
add_dependencies(ERFA_LIB erfalib)
set(ERFA_INCLUDE_DIR ${CMAKE_BINARY_DIR}/erfa_lib)
set(ERFA_LIBFILE ${CMAKE_BINARY_DIR}/erfa_lib/erfa)
# include_directories(${ERFA_INCLUDE_DIR})
message(STATUS ${ERFA_INCLUDE_DIR})

View File

@@ -396,7 +396,7 @@ public:
[p_event, states, currentState, this]<traits::fsm_state_c curr_state_t>(curr_state_t*) {
using to_state_t = curr_state_t::transition_t::template find_state_by_event_t<EvT>;
if constexpr (std::holds_alternative<to_state_t>(*currentState)) {
if (std::holds_alternative<to_state_t>(*currentState)) {
// ?!!!! from self
}

View File

@@ -168,7 +168,7 @@ public:
SlewModelT(std::move(slew_model)),
TrackModelT(std::move(track_model)),
LoggerT(std::move(logger)),
_mountStatus(new mount_status_t)
_mountStatus(new std::atomic<mount_status_t>)
{
*_mountStatus = mount_status_t::IDLE;
}
@@ -481,12 +481,12 @@ protected:
void exit(fsm::traits::fsm_event_c auto& event)
{
exitLog(event);
this->exitLog(event);
}
void enter(fsm::traits::fsm_event_c auto& event)
{
enterLog(event);
this->enterLog(event);
}
};
@@ -522,7 +522,7 @@ protected:
void exit(fsm::traits::fsm_event_c auto& event)
{
exitLog(event);
this->exitLog(event);
}
void enter(fsm::traits::fsm_event_c auto& event)
@@ -575,12 +575,12 @@ protected:
void exit(fsm::traits::fsm_event_c auto& event)
{
exitLog(event);
this->exitLog(event);
}
void enter(fsm::traits::fsm_event_c auto& event)
{
enterLog(event);
this->enterLog(event);
auto* mount_ptr = event.mount();
@@ -633,12 +633,12 @@ protected:
void exit(fsm::traits::fsm_event_c auto& event)
{
exitLog(event);
this->exitLog(event);
}
void enter(fsm::traits::fsm_event_c auto& event)
{
enterLog(event);
this->enterLog(event);
auto* mount_ptr = event.mount();
@@ -685,12 +685,12 @@ protected:
void exit(fsm::traits::fsm_event_c auto& event)
{
exitLog(event);
this->exitLog(event);
}
void enter(fsm::traits::fsm_event_c auto& event)
{
enterLog(event);
this->enterLog(event);
auto* mount_ptr = event.mount();
@@ -722,7 +722,7 @@ protected:
// just reset error
event.mount()->_lastError = MccGenericFsmMountErrorCode::ERROR_OK;
exitLog(event);
this->exitLog(event);
if constexpr (mcc_generic_log_mount_c<MOUNT_T>) {
event.mount()->logWarn(
@@ -736,7 +736,7 @@ protected:
{
event.mount()->_lastError = event.eventData();
enterLog(event);
this->enterLog(event);
if constexpr (mcc_generic_log_mount_c<MOUNT_T>) {
auto err = event.eventData();

View File

@@ -75,7 +75,7 @@ struct MccSimpleMovingModelParams {
template <mcc_pzone_container_c PZoneContT>
bool mcc_is_near_pzones(PZoneContT* pz_cont,
mcc_telemetry_c auto const& tdata,
mcc_telemetry_data_c auto const& tdata,
traits::mcc_time_duration_c auto const& min_timeto,
typename PZoneContT::error_t& err)
{
@@ -100,7 +100,7 @@ bool mcc_is_near_pzones(PZoneContT* pz_cont,
template <mcc_pzone_container_c PZoneContT>
typename PZoneContT::error_t mcc_find_closest_pzone(PZoneContT* pz_cont,
mcc_telemetry_c auto const& tdata,
mcc_telemetry_data_c auto const& tdata,
mcc_eqt_hrz_coord_c auto* closest_coords)
{
using res_t = std::decay_t<decltype(*closest_coords)>;

View File

@@ -211,7 +211,7 @@ public:
template <typename... CtorArgTs>
asio::awaitable<void> listen(std::derived_from<MccServerEndpoint> auto endpoint, CtorArgTs&&... ctor_args)
asio::awaitable<void> listen(std::derived_from<MccNetServerEndpoint> auto endpoint, CtorArgTs&&... ctor_args)
{
if (!endpoint.isValid()) {
logError(std::format("Cannot start listening! Invalid endpoint string representation ('{}')!",

View File

@@ -67,7 +67,7 @@ static constexpr bool mcc_char_range_compare(const traits::mcc_char_view auto& w
*/
class MccServerEndpoint
class MccNetServerEndpoint
{
public:
static constexpr std::string_view protoHostDelim = "://";
@@ -99,25 +99,25 @@ public:
template <traits::mcc_input_char_range R>
MccServerEndpoint(const R& ept)
MccNetServerEndpoint(const R& ept)
{
fromRange(ept);
}
MccServerEndpoint(const MccServerEndpoint& other)
MccNetServerEndpoint(const MccNetServerEndpoint& other)
{
copyInst(other);
}
MccServerEndpoint(MccServerEndpoint&& other)
MccNetServerEndpoint(MccNetServerEndpoint&& other)
{
moveInst(std::move(other));
}
virtual ~MccServerEndpoint() = default;
virtual ~MccNetServerEndpoint() = default;
MccServerEndpoint& operator=(const MccServerEndpoint& other)
MccNetServerEndpoint& operator=(const MccNetServerEndpoint& other)
{
copyInst(other);
@@ -125,7 +125,7 @@ public:
}
MccServerEndpoint& operator=(MccServerEndpoint&& other)
MccNetServerEndpoint& operator=(MccNetServerEndpoint&& other)
{
moveInst(std::move(other));
@@ -358,7 +358,7 @@ public:
// add '\0' char (or replace special-meaning char/char-sequence) to construct UNIX abstract namespace
// endpoint path
template <typename T = std::nullptr_t>
MccServerEndpoint& makeAbstract(const T& mark = nullptr)
MccNetServerEndpoint& makeAbstract(const T& mark = nullptr)
requires(traits::mcc_input_char_range<T> || std::same_as<std::remove_cv_t<T>, char> ||
std::is_null_pointer_v<std::remove_cv_t<T>>)
{
@@ -397,7 +397,7 @@ protected:
ssize_t idx = 0;
// case-insensitive look-up
bool found = std::ranges::any_of(MccServerEndpoint::validProtoMarks, [&idx, &proto_mark](const auto& el) {
bool found = std::ranges::any_of(MccNetServerEndpoint::validProtoMarks, [&idx, &proto_mark](const auto& el) {
bool ok = utils::mcc_char_range_compare(proto_mark, el, true);
if (!ok) {
@@ -449,7 +449,7 @@ protected:
return res;
}
void copyInst(const MccServerEndpoint& other)
void copyInst(const MccNetServerEndpoint& other)
{
if (&other != this) {
if (other._isValid) {
@@ -485,7 +485,7 @@ protected:
}
void moveInst(MccServerEndpoint&& other)
void moveInst(MccNetServerEndpoint&& other)
{
if (&other != this) {
if (other._isValid) {

View File

@@ -46,7 +46,10 @@ namespace mcc
struct MccPZoneContainerCategory : public std::error_category {
MccPZoneContainerCategory() : std::error_category() {}
const char* name() const noexcept { return "ALTITUDE-LIMIT-PZ"; }
const char* name() const noexcept
{
return "ALTITUDE-LIMIT-PZ";
}
std::string message(int ec) const
{
@@ -248,11 +251,14 @@ public:
}
size_t sizePZones() const { return _inZoneFuncCPT.size(); }
size_t sizePZones() const
{
return _inZoneFuncCPT.size();
}
template <typename InputT>
error_t inPZone(InputT coords, bool* common_result, std::ranges::output_range<bool> auto* result = nullptr)
template <typename InputT, std::ranges::output_range<bool> ResT = std::vector<bool>>
error_t inPZone(InputT coords, bool* common_result, ResT* result = nullptr)
requires(mcc_eqt_hrz_coord_c<InputT> || mcc_celestial_point_c<InputT>)
{
if (common_result == nullptr) {
@@ -418,7 +424,7 @@ public:
std::ranges::advance(ptr, i);
error_t ret;
if constexpr (mcc_eqt_hrz_coord_c<ResultT>) {
if constexpr (mcc_eqt_hrz_coord_c<std::ranges::range_value_t<ResultT>>) {
MccEqtHrzCoords pt;
mcc_tp2tp(ptr->time_point, pt.time_point);

View File

@@ -200,7 +200,7 @@ public:
}
std::chrono::steady_clock::time_point start_slewing_tp, last_adjust_tp;
mcc_tp2tp(hw_state.time_point, start_slewing_tp);
// mcc_tp2tp(hw_state.time_point, start_slewing_tp); // not compiled!!
// double dist, dx, dy, sinY, rate2, xrate;
// std::chrono::duration<double> dtx, dty; // seconds in double

View File

@@ -298,7 +298,7 @@ public:
};
*/
_updateFunc = [controls, this](std::stop_token stop_token) {
_updateFunc = [controls, this](std::stop_token stop_token) -> std::error_code {
// first, update mount quantities
typename hardware_t::hardware_state_t hw_pos;
auto hw_err = controls->hardwareGetState(&hw_pos);
@@ -619,8 +619,8 @@ public:
std::unique_lock ulock(*_updateMutex);
auto res = _updateCondVar->wait_for(ulock, timeout, [this]() { return *_isDataUpdated; });
if (res == std::cv_status::timeout) {
auto res = _updateCondVar->wait_for(ulock, timeout, [this]() -> bool { return _isDataUpdated.get(); });
if (!res) {
return MccTelemetryErrorCode::ERROR_DATA_TIMEOUT;
}

View File

@@ -170,10 +170,12 @@ public:
} else {
static_assert(false, "UNKNOW MOUNT TYPE!");
}
return MccSimpleTrackingModelErrorCode::ERROR_OK;
};
auto target_point = [&, this](MccCelestialPoint* point) {
auto target_point = [&, this](MccCelestialPoint* point) -> std::error_code {
auto dt = std::chrono::duration<double>{tdata.HA} +
_currentParams.timeShiftToTargetPoint * mcc_sideral_to_UT1_ratio; // hour seconds
@@ -226,7 +228,7 @@ public:
return mcc_deduce_error_code(pz_err, MccSimpleTrackingModelErrorCode::ERROR_PZONE_CONTAINER_COMP);
}
hw_state.moving_state = CONTROLS_T::hardware_moving_state_t::HW_MOVE_Tracking;
hw_state.moving_state = CONTROLS_T::hardware_moving_state_t::HW_MOVE_TRACKING;
{
std::lock_guard lock{*_currentParamsMutex};
@@ -311,7 +313,7 @@ public:
}
// send corrections
hw_state.moving_state = CONTROLS_T::hardware_moving_state_t::HW_MOVE_Tracking;
hw_state.moving_state = CONTROLS_T::hardware_moving_state_t::HW_MOVE_TRACKING;
hw_err = controls->hardwareSetState(hw_state);
if (hw_err) {
*_stopTracking = true;