...
This commit is contained in:
parent
683da9739d
commit
3f108fcc13
@ -46,14 +46,16 @@ protected:
|
||||
struct Asibfm700ErrorState : base_gm_class_t::MccGenericFsmMountBaseState {
|
||||
static constexpr std::string_view ID{"ASIBFM700-MOUNT-ERROR-STATE"};
|
||||
|
||||
void exit(MccGenericFsmMountErrorEvent& event)
|
||||
{
|
||||
event.mount()->logWarn("The mount already in error state!");
|
||||
}
|
||||
// void exit(MccGenericFsmMountErrorEvent& event)
|
||||
// {
|
||||
// event.mount()->logWarn("The mount already in error state!");
|
||||
// }
|
||||
|
||||
void enter(MccGenericFsmMountErrorEvent& event)
|
||||
{
|
||||
event.mount()->logWarn("The mount already in error state!");
|
||||
// event.mount()->logWarn("The mount already in error state!");
|
||||
auto err = event.eventData();
|
||||
event.mount()->logError("An error occured: {} [{} {}]", err.message(), err.value(), err.category().name());
|
||||
}
|
||||
|
||||
void exit(mcc::fsm::traits::fsm_event_c auto& event)
|
||||
|
||||
@ -148,6 +148,8 @@ AsibFM700ServoController::error_t AsibFM700ServoController::hardwareGetState(har
|
||||
} else {
|
||||
state->time_point = tp_t{std::chrono::duration_cast<tp_t::duration>(secs)};
|
||||
}
|
||||
// WARNING: TEMPORARY (WAIT FOR Eddy fix its implementation of LibSidServo)!!!
|
||||
state->time_point = decltype(state->time_point)::clock::now();
|
||||
|
||||
// according to "SiTech protocol notes" X is DEC-axis and Y is HA-axis
|
||||
state->X = mdata.encYposition.val;
|
||||
|
||||
@ -590,6 +590,8 @@ protected:
|
||||
} else {
|
||||
return std::make_error_code(std::errc::invalid_argument);
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
template <traits::mcc_input_char_range IR>
|
||||
@ -602,6 +604,8 @@ protected:
|
||||
} else {
|
||||
return std::make_error_code(std::errc::invalid_argument);
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
@ -671,8 +675,8 @@ protected:
|
||||
template <mcc_celestial_point_c T, traits::mcc_output_char_range OR>
|
||||
void serializePairKindTimePoint(const T& value, OR& bytes)
|
||||
{
|
||||
std::format_to(std::back_inserter(bytes), "{0:}{1:}{2:}{3:%F}T{3:%T}", _delimiter,
|
||||
MccCoordPairKindToStr(value.pair_kind), _delimiter, value.time_point);
|
||||
std::format_to(std::back_inserter(bytes), "{0:}{1:}{2:%F}T{2:%T}", MccCoordPairKindToStr(value.pair_kind),
|
||||
_delimiter, value.time_point);
|
||||
}
|
||||
|
||||
template <traits::mcc_output_char_range OR, std::convertible_to<double>... Ts>
|
||||
@ -957,6 +961,8 @@ public:
|
||||
template <mcc_pointing_target_coord_c T, traits::mcc_output_char_range OR>
|
||||
void operator()(const T& value, OR& bytes)
|
||||
{
|
||||
static MccEqtHrzCoordsSerializer eqhrz_ser;
|
||||
|
||||
// output format: RA_ICRS, DEC_ICRS, RA_APP, DEC_APP, HA, AZ, ZD, ALT, X, Y, pair-kind, time-point
|
||||
// in the case of sexagesimal output X,Y coordinates will be interpretated
|
||||
// according to value.pair_kind field
|
||||
@ -972,7 +978,11 @@ public:
|
||||
|
||||
std::format_to(std::back_inserter(bytes), "{}", _delimiter);
|
||||
|
||||
MccEqtHrzCoordsSerializer{}(value, bytes);
|
||||
eqhrz_ser.setFormat(_currentFormat);
|
||||
eqhrz_ser.setPrecision(_currentPrec);
|
||||
eqhrz_ser(value, bytes);
|
||||
|
||||
// MccEqtHrzCoordsSerializer{}(value, bytes);
|
||||
}
|
||||
};
|
||||
|
||||
@ -1020,15 +1030,26 @@ public:
|
||||
template <mcc_telemetry_data_c T, traits::mcc_output_char_range OR>
|
||||
void operator()(const T& value, OR& bytes)
|
||||
{
|
||||
static MccEqtHrzCoordsSerializer eqhrz_ser;
|
||||
static MccPointingTargetSerializer pt_ser;
|
||||
|
||||
// output format: <mount data>, speedX, speedY, pcmX, pcmY, refCorr, <target data>
|
||||
|
||||
MccEqtHrzCoordsSerializer{}(value, bytes);
|
||||
eqhrz_ser.setFormat(_currentFormat);
|
||||
eqhrz_ser.setPrecision(_currentPrec);
|
||||
eqhrz_ser(value, bytes);
|
||||
|
||||
// MccEqtHrzCoordsSerializer{}(value, bytes);
|
||||
std::format_to(std::back_inserter(bytes), "{}", _delimiter);
|
||||
|
||||
toDegrees(bytes, value.speedX, value.speedY, value.pcmX, value.pcmY, value.refCorr);
|
||||
std::format_to(std::back_inserter(bytes), "{}", _delimiter);
|
||||
|
||||
MccPointingTargetSerializer{}(value.target, bytes);
|
||||
pt_ser.setFormat(_currentFormat);
|
||||
pt_ser.setPrecision(_currentPrec);
|
||||
pt_ser(value.target, bytes);
|
||||
|
||||
// MccPointingTargetSerializer{}(value.target, bytes);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -275,7 +275,7 @@ public:
|
||||
|
||||
error_t trackTarget()
|
||||
{
|
||||
auto err = TrackModelT::traclTarget();
|
||||
auto err = TrackModelT::trackTarget();
|
||||
if (err) {
|
||||
*_mountStatus = mount_status_t::ERROR;
|
||||
|
||||
@ -486,7 +486,7 @@ protected:
|
||||
struct MccGenericFsmMountIdleState
|
||||
: MccGenericFsmMountBaseState // IDLE state: mount is stopped, wait for client commands
|
||||
{
|
||||
static constexpr std::string_view ID{"GENERIC-MOUNT-IDLDE-STATE"};
|
||||
static constexpr std::string_view ID{"GENERIC-MOUNT-IDLE-STATE"};
|
||||
|
||||
using transition_t = fsm::fsm_transition_table_t<
|
||||
std::pair<MccGenericFsmMountIdleEvent, MccGenericFsmMountIdleState<ERROR_STATE_T>>,
|
||||
@ -584,23 +584,23 @@ protected:
|
||||
std::pair<MccGenericFsmMountSlewEvent, MccGenericFsmMountSlewState>>;
|
||||
|
||||
|
||||
void exit(MccGenericFsmMountSlewEvent& event)
|
||||
{
|
||||
if constexpr (mcc_generic_log_mount_c<MOUNT_T>) {
|
||||
event.mount()->logWarn(
|
||||
"It seems re-entering to slewing state was asked! Do not stop the current slewing process, just "
|
||||
"ignore this event!");
|
||||
}
|
||||
}
|
||||
// void exit(MccGenericFsmMountSlewEvent& event)
|
||||
// {
|
||||
// if constexpr (mcc_generic_log_mount_c<MOUNT_T>) {
|
||||
// event.mount()->logWarn(
|
||||
// "It seems re-entering to slewing state was asked! Do not stop the current slewing process, just "
|
||||
// "ignore this event!");
|
||||
// }
|
||||
// }
|
||||
|
||||
void enter(MccGenericFsmMountSlewEvent& event)
|
||||
{
|
||||
if constexpr (mcc_generic_log_mount_c<MOUNT_T>) {
|
||||
event.mount()->logWarn(
|
||||
"It seems re-entering to slewing state was asked! Do not start a new slewing process, just ignore "
|
||||
"this event!");
|
||||
}
|
||||
}
|
||||
// void enter(MccGenericFsmMountSlewEvent& event)
|
||||
// {
|
||||
// if constexpr (mcc_generic_log_mount_c<MOUNT_T>) {
|
||||
// event.mount()->logWarn(
|
||||
// "It seems re-entering to slewing state was asked! Do not start a new slewing process, just ignore
|
||||
// " "this event!");
|
||||
// }
|
||||
// }
|
||||
|
||||
void exit(fsm::traits::fsm_event_c auto& event)
|
||||
{
|
||||
@ -613,10 +613,17 @@ protected:
|
||||
|
||||
auto* mount_ptr = event.mount();
|
||||
|
||||
if (event.mount()->previousStateID() == ID) {
|
||||
event.mount()->logWarn(
|
||||
"It seems re-entering to slewing state was asked! Do not start a new slewing process, just ignore "
|
||||
"this event!");
|
||||
return;
|
||||
}
|
||||
|
||||
// call base-class stopMount method!
|
||||
auto err = static_cast<MOUNT_T*>(mount_ptr)->slewToTarget();
|
||||
if (err) {
|
||||
mount_ptr->dispatchEvent(MccGenericFsmMountErrorEvent{mount_ptr});
|
||||
mount_ptr->dispatchEvent(MccGenericFsmMountErrorEvent{mount_ptr, err});
|
||||
return;
|
||||
}
|
||||
|
||||
@ -642,23 +649,23 @@ protected:
|
||||
std::pair<MccGenericFsmMountTrackEvent, MccGenericFsmMountTrackState>>;
|
||||
|
||||
|
||||
void exit(MccGenericFsmMountTrackEvent& event)
|
||||
{
|
||||
if constexpr (mcc_generic_log_mount_c<MOUNT_T>) {
|
||||
event.mount()->logWarn(
|
||||
"It seems re-entering to tracking state was asked! Do not stop the current tracking process, just "
|
||||
"ignore this event!");
|
||||
}
|
||||
}
|
||||
// void exit(MccGenericFsmMountTrackEvent& event)
|
||||
// {
|
||||
// if constexpr (mcc_generic_log_mount_c<MOUNT_T>) {
|
||||
// event.mount()->logWarn(
|
||||
// "It seems re-entering to tracking state was asked! Do not stop the current tracking process, just
|
||||
// " "ignore this event!");
|
||||
// }
|
||||
// }
|
||||
|
||||
void enter(MccGenericFsmMountTrackEvent& event)
|
||||
{
|
||||
if constexpr (mcc_generic_log_mount_c<MOUNT_T>) {
|
||||
event.mount()->logWarn(
|
||||
"It seems re-entering to tracking state was asked! Do not start a new tracking process, just "
|
||||
"ignore this event!");
|
||||
}
|
||||
}
|
||||
// void enter(MccGenericFsmMountTrackEvent& event)
|
||||
// {
|
||||
// if constexpr (mcc_generic_log_mount_c<MOUNT_T>) {
|
||||
// event.mount()->logWarn(
|
||||
// "It seems re-entering to tracking state was asked! Do not start a new tracking process, just "
|
||||
// "ignore this event!");
|
||||
// }
|
||||
// }
|
||||
|
||||
void exit(fsm::traits::fsm_event_c auto& event)
|
||||
{
|
||||
@ -671,10 +678,17 @@ protected:
|
||||
|
||||
auto* mount_ptr = event.mount();
|
||||
|
||||
if (mount_ptr->previousStateID() == ID) {
|
||||
mount_ptr->logWarn(
|
||||
"It seems re-entering to tracking state was asked! Do not start a new tracking process, just "
|
||||
"ignore this event!");
|
||||
return;
|
||||
}
|
||||
|
||||
// call base-class stopMount method!
|
||||
auto err = static_cast<MOUNT_T*>(mount_ptr)->trackTarget();
|
||||
if (err) {
|
||||
mount_ptr->dispatchEvent(MccGenericFsmMountErrorEvent{mount_ptr});
|
||||
mount_ptr->dispatchEvent(MccGenericFsmMountErrorEvent{mount_ptr, err});
|
||||
return;
|
||||
}
|
||||
|
||||
@ -696,21 +710,21 @@ protected:
|
||||
std::pair<MccGenericFsmMountStopEvent, MccGenericFsmMountStopState>>;
|
||||
|
||||
|
||||
void exit(MccGenericFsmMountStopEvent& event)
|
||||
{
|
||||
if constexpr (mcc_generic_log_mount_c<MOUNT_T>) {
|
||||
event.mount()->logWarn("It seems a re-entering to the stop state was asked! Ignore the event!");
|
||||
}
|
||||
}
|
||||
// void exit(MccGenericFsmMountStopEvent& event)
|
||||
// {
|
||||
// if constexpr (mcc_generic_log_mount_c<MOUNT_T>) {
|
||||
// event.mount()->logWarn("It seems a re-entering to the stop state was asked! Ignore the event!");
|
||||
// }
|
||||
// }
|
||||
|
||||
void enter(MccGenericFsmMountStopEvent& event)
|
||||
{
|
||||
if constexpr (mcc_generic_log_mount_c<MOUNT_T>) {
|
||||
event.mount()->logWarn(
|
||||
"It seems a re-entering to the stop state was asked! Ignore the event and wait for the mount to "
|
||||
"stop!");
|
||||
}
|
||||
}
|
||||
// void enter(MccGenericFsmMountStopEvent& event)
|
||||
// {
|
||||
// if constexpr (mcc_generic_log_mount_c<MOUNT_T>) {
|
||||
// event.mount()->logWarn(
|
||||
// "It seems a re-entering to the stop state was asked! Ignore the event and wait for the mount to "
|
||||
// "stop!");
|
||||
// }
|
||||
// }
|
||||
|
||||
void exit(fsm::traits::fsm_event_c auto& event)
|
||||
{
|
||||
@ -723,10 +737,17 @@ protected:
|
||||
|
||||
auto* mount_ptr = event.mount();
|
||||
|
||||
if (mount_ptr->previousStateID() == ID) {
|
||||
mount_ptr->logWarn(
|
||||
"It seems a re-entering to the stop state was asked! Ignore the event and wait for the mount to "
|
||||
"stop!");
|
||||
return;
|
||||
}
|
||||
|
||||
// call base-class stopMount method!
|
||||
auto err = static_cast<MOUNT_T*>(mount_ptr)->stopMount();
|
||||
if (err) {
|
||||
mount_ptr->dispatchEvent(MccGenericFsmMountErrorEvent{mount_ptr});
|
||||
mount_ptr->dispatchEvent(MccGenericFsmMountErrorEvent{mount_ptr, err});
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -1064,6 +1064,16 @@ protected:
|
||||
_coordFormat, _coordPrec, cp);
|
||||
}
|
||||
}
|
||||
} else if (input_msg.withKey(MCC_COMMPROTO_KEYWORD_TELEMETRY_STR)) {
|
||||
MccTelemetryData tdata;
|
||||
|
||||
auto t_err = mount_ptr->telemetryData(&tdata);
|
||||
if (t_err) {
|
||||
err = mcc_deduce_error_code(t_err, MccGenericMountNetworkServerErrorCode::ERROR_MOUNT_GET_TELEMETRY);
|
||||
} else {
|
||||
output_msg.construct(MCC_COMMPROTO_KEYWORD_SERVER_ACK_STR, MCC_COMMPROTO_KEYWORD_TELEMETRY_STR,
|
||||
_coordFormat, _coordPrec, tdata);
|
||||
}
|
||||
} else if (input_msg.withKey(mcc::network::MCC_COMMPROTO_KEYWORD_STATUS_STR)) {
|
||||
auto st = mount_ptr->mountStatus(); // according to mcc_generic_mount_c 'st' is formattable
|
||||
using st_t = decltype(st);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user