#pragma once /* MOUNT CONTROL COMPONENTS LIBRARY */ #include #include #include #include namespace mcc { enum class MccMountType : uint8_t { GERMAN_TYPE, FORK_TYPE, CROSSAXIS_TYPE, ALTAZ_TYPE }; // mount state type concept template concept mcc_mount_state_c = requires(T t, const T t_const) { { t_const.ident() } -> std::same_as; typename T::context_t; { t.enter(std::declval()) } -> std::same_as; { t.exit(std::declval()) } -> std::same_as; }; // implements a Finite State Machine Pattern template class MccMount { typedef double coord_t; typedef double time_point_t; public: static constexpr MccMountType mountType = MOUNT_TYPE; /* mount main-cycle variable quantities */ struct mount_state_t { // time-related time_point_t siderTime; // sideral time // target (user-input) current coordinates (in radians) coord_t tagRA, tagDEC; coord_t tagHA; coord_t tagAZ, tagZD; // encoder-measured current mount coordinates (in radians) coord_t mntRA, mntDEC; coord_t mntHA; coord_t mntAZ, mntZD; // current refraction coefficient coord_t currRefr; // PCS (pointing correction system) corrections coord_t pcsX, pcsY; // X - HA, Y - DEC for equatorial-type mount; X - AZ, Y - ZD for horizontal-type one // mount current state }; MccMount() { _exitCurrentState = []() {}; // do nothing } virtual ~MccMount() {} template void setMountState(StateT& state) { _exitCurrentState(); // exit from current state _exitCurrentState = [&state, this]() { state.exit(this); }; state.enter(this); } protected: std::function _exitCurrentState; void updateMountState() {} }; } // namespace mcc