#pragma once /* MOUNT CONTROL COMPONENTS LIBRARY */ /* GENERIC MOUNT REFERENCE IMPLEMENTATION */ #include "mcc_generics.h" namespace mcc { enum class MccGenericMountErrorCode : int { ERROR_OK, ERROR_HW_STOP, ERROR_HW_GETSTATE }; } // namespace mcc namespace std { template <> class is_error_code_enum : public true_type { }; } // namespace std namespace mcc { template class MccGenericMount : public HardwareT, public TelemetryT, public PZoneContT, public SlewModelT, public TrackModelT, public GuidingModelT, public LoggerT { public: typedef std::error_code error_t; using LoggerT::logDebug; using LoggerT::logError; using LoggerT::logInfo; using LoggerT::logWarn; using typename GuidingModelT::guiding_params_t; using typename SlewModelT::slewing_params_t; using typename TrackModelT::tracking_params_t; MccGenericMount(HardwareT hardware, TelemetryT telemetry, PZoneContT pzone_cont, SlewModelT slew_model, TrackModelT track_model, GuidingModelT guiding_model, LoggerT logger = MccNullLogger{}) : HardwareT(std::move(hardware)), TelemetryT(std::move(telemetry)), PZoneContT(std::move(pzone_cont)), SlewModelT(std::move(slew_model)), TrackModelT(std::move(track_model)), GuidingModelT(std::move(guiding_model)), LoggerT(std::move(logger)) { } virtual ~MccGenericMount() = default; error_t stopMount() { logInfo("stop any movements ..."); this->stopGuidingTarget(); this->stopTracking(); this->stopSlewing(); auto hw_err = this->hardwareStop(); if (hw_err) { return mcc_deduce_error(hw_err, MccGenericMountErrorCode::ERROR_HW_STOP); } // poll hardware till stopped-state detected ... logInfo("mount was stopped"); return MccGenericMountErrorCode::ERROR_OK; } }; template class MccGenericMountFSM : public fsm::MccFiniteStateMachine, protected MccGenericMount { protected: typedef MccGenericMount base_gmount_t; public: struct MccGenericMountStateUninit { using transition_t = fsm::fsm_transition_table_t<>; }; MccGenericMountFSM(HardwareT hardware, TelemetryT telemetry, PZoneContT pzone_cont, SlewModelT slew_model, TrackModelT track_model, GuidingModelT guiding_model, LoggerT logger = MccNullLogger{}) : fsm::MccFiniteStateMachine(MccGenericMountStateUninit{}), base_gmount_t(std::move(hardware), std::move(telemetry), std::move(pzone_cont), std::move(slew_model), std::move(track_model), std::move(guiding_model), std::move(logger)) { } }; } // namespace mcc