...
This commit is contained in:
@@ -28,10 +28,7 @@ public:
|
||||
|
||||
virtual ~MccMountEventBase() = default;
|
||||
|
||||
mount_t& mount() const
|
||||
{
|
||||
return _mount;
|
||||
}
|
||||
mount_t& mount() const { return _mount; }
|
||||
|
||||
protected:
|
||||
MccMountEventBase(mount_t& mount) : _mount(mount) {}
|
||||
@@ -78,10 +75,7 @@ struct MccMountEventError : public MccMountEventBase<MountT> {
|
||||
|
||||
using event_data_t = std::error_code;
|
||||
|
||||
event_data_t eventData() const
|
||||
{
|
||||
return _error;
|
||||
}
|
||||
event_data_t eventData() const { return _error; }
|
||||
|
||||
MccMountEventError(MountT& mount, const event_data_t& error) : base_t(mount), _error(error) {}
|
||||
|
||||
@@ -98,12 +92,9 @@ struct MccMountEventSlew : public MccMountEventBase<MountT> {
|
||||
|
||||
static constexpr std::string_view ID = "MCC-MOUNT-SLEW-EVENT";
|
||||
|
||||
using event_data_t = typename MountT::slew_params_t;
|
||||
using event_data_t = typename MountT::slew_model_t::slew_point_t;
|
||||
|
||||
event_data_t eventData() const
|
||||
{
|
||||
return _eventData;
|
||||
}
|
||||
event_data_t eventData() const { return _eventData; }
|
||||
|
||||
MccMountEventSlew(MountT& mount, const event_data_t& ev_data) : base_t(mount), _eventData(ev_data) {}
|
||||
|
||||
@@ -120,9 +111,14 @@ struct MccMountEventGuiding : public MccMountEventBase<MountT> {
|
||||
|
||||
static constexpr std::string_view ID = "MCC-MOUNT-GUIDING-EVENT";
|
||||
|
||||
// CTAD does not work for clang++ (at least till v. 20 and -std=c++23)!
|
||||
// so, one must explicitly define constructor here
|
||||
MccMountEventGuiding(MountT& mount) : base_t(mount) {}
|
||||
using event_data_t = typename MountT::guiding_model_t::guiding_point_t;
|
||||
|
||||
event_data_t eventData() const { return _eventData; }
|
||||
|
||||
MccMountEventGuiding(MountT& mount, const event_data_t& ev_data) : base_t(mount), _eventData(ev_data) {}
|
||||
|
||||
protected:
|
||||
event_data_t _eventData;
|
||||
};
|
||||
|
||||
|
||||
@@ -139,10 +135,7 @@ struct MccMountEventStop : public MccMountEventBase<MountT> {
|
||||
EVENT_STOP_BUTTON // hardware button
|
||||
};
|
||||
|
||||
event_data_t eventData() const
|
||||
{
|
||||
return _reason;
|
||||
}
|
||||
event_data_t eventData() const { return _reason; }
|
||||
|
||||
std::string_view reason() const
|
||||
{
|
||||
@@ -286,7 +279,10 @@ struct MccMountStateStop : MccMountStateBase<MountT> {
|
||||
|
||||
auto mount = event.mount();
|
||||
|
||||
mount.stopMount();
|
||||
// should one check current state (slewing, guiding)?
|
||||
mount.slewModel.stop();
|
||||
mount.guidingModel.stop();
|
||||
mount.hardware.stop();
|
||||
|
||||
if constexpr (std::same_as<EvT, MccMountEventStop<MountT>>) {
|
||||
mount.logInfo(std::format("Stop reason: {}", event.reason()));
|
||||
@@ -446,7 +442,8 @@ struct MccMountStateShutdown : MccMountStateBase<MountT> {
|
||||
|
||||
|
||||
// slew state
|
||||
|
||||
// WARNING: It must be a friend to 'MountT' class if it inherits it base class mount_controls_t
|
||||
// as protected or private!!!
|
||||
template <traits::mcc_fsm_log_mount_c MountT>
|
||||
struct MccMountStateSlew : MccMountStateBase<MountT> {
|
||||
static constexpr std::string_view ID = "MCC-MOUNT-SLEW-STATE";
|
||||
@@ -472,7 +469,18 @@ struct MccMountStateSlew : MccMountStateBase<MountT> {
|
||||
{
|
||||
this->enterLog(event);
|
||||
|
||||
event.mount().slewMount(event.eventData());
|
||||
auto slew_err = event.mount().slewModel.slew(event.eventData());
|
||||
if (slew_err) {
|
||||
if constexpr (std::same_as<decltype(slew_err), std::error_code>) {
|
||||
event.mount().dispatchEvent(MccMountEventError<MountT>{event.mount(), slew_err});
|
||||
} else {
|
||||
// ...
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// switch to IDLE state
|
||||
event.mount().template dispatchEvent<MccMountEventIDLE<MountT>>({event.mount()});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -505,7 +513,17 @@ struct MccMountStateGuiding : MccMountStateBase<MountT> {
|
||||
{
|
||||
this->enterLog(event);
|
||||
|
||||
event.mount().startGuiding();
|
||||
auto err = event.mount().guidingModel.guiding(event.eventData());
|
||||
if (err) {
|
||||
if constexpr (std::same_as<decltype(err), std::error_code>) {
|
||||
event.mount().dispatchEvent(MccMountEventError<MountT>{event.mount(), err});
|
||||
} else {
|
||||
// ...
|
||||
}
|
||||
}
|
||||
|
||||
// switch to IDLE state
|
||||
event.mount().template dispatchEvent<MccMountEventIDLE<MountT>>({event.mount()});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user