diff --git a/cxx/CMakeLists.txt b/cxx/CMakeLists.txt index 9672fe2..9be0934 100644 --- a/cxx/CMakeLists.txt +++ b/cxx/CMakeLists.txt @@ -137,7 +137,9 @@ target_include_directories(${MCC_LIBRARY} INTERFACE ${FITPACK_INCLUDE_DIR}) set(ASIBFM700_LIB_SRC asibfm700_common.h asibfm700_hardware.h asibfm700_hardware.cpp) set(ASIBFM700_LIB asibfm700) -add_library(${ASIBFM700_LIB} STATIC ${ASIBFM700_LIB_SRC}) +add_library(${ASIBFM700_LIB} STATIC ${ASIBFM700_LIB_SRC} + asibfm700_mount.h asibfm700_mount.cpp + asibfm700_config.h) target_include_directories(${ASIBFM700_LIB} PRIVATE ${FITPACK_INCLUDE_DIR}) # set(MOUNT_SERVER_APP_SRC mount.h mount_state.h mount_server.cpp comm_server.h comm_server_endpoint.h comm_server_configfile.h mount_astrom.h diff --git a/cxx/asibfm700_common.h b/cxx/asibfm700_common.h index 9a14e5f..b14561a 100644 --- a/cxx/asibfm700_common.h +++ b/cxx/asibfm700_common.h @@ -6,13 +6,14 @@ #include "asibfm700_hardware.h" -#include "mcc_fsm_mount.h" +// #include "mcc_fsm_mount.h" #include "mcc_guiding_model.h" #include "mcc_mount_astro_erfa.h" #include "mcc_mount_pec.h" #include "mcc_mount_pz.h" #include "mcc_mount_telemetry.h" #include "mcc_slew_model.h" +// #include "mcc_spdlog.h" namespace asibfm700 { @@ -33,8 +34,8 @@ static_assert(std::movable); static_assert(std::movable); static_assert(std::movable>); -// typedef mcc::MccSimpleSlewModel<> AsibFM700SlewModel; -// typedef mcc::MccSimpleGuidingModel<> AsibFM700GuidingModel; +// typedef mcc::MccSimpleSlewModel AsibFM700SlewModel; +// typedef mcc::MccSimpleGuidingModel AsibFM700GuidingModel; template @@ -43,6 +44,7 @@ using AsibFM700SlewModel = mcc::MccSimpleSlewModel; template using AsibFM700GuidingModel = mcc::MccSimpleGuidingModel; +/* template struct AsibFM700MountControls { @@ -65,12 +67,6 @@ static_assert(mcc::traits::mcc_mount_controls_c> @@ -81,5 +77,5 @@ class AsibFM700Mount : public mcc::MccMount +AsibFM700Mount::AsibFM700Mount(AsibFM700Config config, std::shared_ptr logger, const R& pattern_range) + : mcc::utils::MccSpdlogLogger(std::move(logger), pattern_range), + _currentConfig(std::move(config)), + base_gm_t(std::make_tuple(_currentConfig.astromEngineState), + std::make_tuple(_currentConfig.hardwareConfig), + std::make_tuple(_currentConfig.pecData), + std::make_tuple(std::ref(_astromEngine), std::ref(_pec), std::ref(_hardware)), + std::make_tuple(std::ref(_telemetry), std::ref(_hardware), std::ref(_pzFuncs)), + std::make_tuple(std::ref(_telemetry), std::ref(_hardware), std::ref(_pzFuncs))) +{ +} + + +} // namespace asibfm700 diff --git a/cxx/asibfm700_mount.h b/cxx/asibfm700_mount.h new file mode 100644 index 0000000..0dcb2c9 --- /dev/null +++ b/cxx/asibfm700_mount.h @@ -0,0 +1,45 @@ +#pragma once + +/* AstroSIB-FM700 FORK MOUNT CONTROL LIBRARY */ + + +#include "asibfm700_common.h" +#include "asibfm700_config.h" + +#include "mcc_generic_mount.h" +#include "mcc_spdlog.h" + +namespace asibfm700 +{ + + +class AsibFM700Mount : public mcc::utils::MccSpdlogLogger, + public mcc::MccGenericMount, + AsibFM700GuidingModel> +{ + using base_gm_t = mcc::MccGenericMount, + AsibFM700GuidingModel>; + +public: + template + AsibFM700Mount(AsibFM700Config config, + std::shared_ptr logger, + const R& pattern_range = LOGGER_DEFAULT_FORMAT); + + ~AsibFM700Mount(); + + +private: + AsibFM700Config _currentConfig; +}; + + +} // namespace asibfm700 diff --git a/cxx/mcc_generic_mount.h b/cxx/mcc_generic_mount.h index 0272eb8..cfc60f4 100644 --- a/cxx/mcc_generic_mount.h +++ b/cxx/mcc_generic_mount.h @@ -40,29 +40,43 @@ template -class MccGenericMount : public LOGGER_T + traits::mcc_guiding_model_c GUIDINGMODEL_T> +class MccGenericMount { - typedef LOGGER_T logger_t; - - using logger_t::logDebug; - using logger_t::logError; - using logger_t::logInfo; - using logger_t::logWarn; - +public: typedef ASTROM_ENGINE_T astrom_engine_t; typedef HARDWARE_T hardware_t; typedef PEC_T pec_t; typedef TELEMETRY_T telemetry_t; - typedef typename TELEMETRY_T::telemetry_data_t telemetry_data_t; + typedef typename TELEMETRY_T::mount_telemetry_data_t telemetry_data_t; typedef SLEWMODEL_T slew_model_t; - typedef GUIDEMODEL_T guiding_model_t; + typedef GUIDINGMODEL_T guiding_model_t; typedef typename MccPZoneWrapper::duration_t pz_duration_t; static constexpr MccMountType mountType = pec_t::mountType; + template + MccGenericMount(ASTROM_ENGINE_CTOR_T aengine_ctor_args, + HARDWARE_CTOR_T hw_ctor_args, + PEC_CTOR_T pec_ctor_args, + TELEMETRY_CTOR_T t_ctor_args, + SLEWMODEL_CTOR_T smodel_ctor_args, + GUIDINGMODEL_CTOR_T gmodel_ctor_args) + : _astromEngine(std::make_from_tuple(std::move(aengine_ctor_args))), + _hardware(std::make_from_tuple(std::move(hw_ctor_args))), + _pec(std::make_from_tuple(std::move(pec_ctor_args))), + _telemetry(std::make_from_tuple(std::move(t_ctor_args))), + _slewModel(std::make_from_tuple(std::move(smodel_ctor_args))), + _guidingModel(std::make_from_tuple(std::move(gmodel_ctor_args))) + { + } + virtual ~MccGenericMount() = default; // get telemetry data @@ -227,7 +241,7 @@ protected: PEC_T _pec; TELEMETRY_T _telemetry; SLEWMODEL_T _slewModel; - GUIDEMODEL_T _gudingModel; + GUIDINGMODEL_T _guidingModel; std::vector> _pzFuncs{}; }; diff --git a/cxx/mcc_guiding_model.h b/cxx/mcc_guiding_model.h index 6101e98..db9788c 100644 --- a/cxx/mcc_guiding_model.h +++ b/cxx/mcc_guiding_model.h @@ -96,31 +96,6 @@ inline std::error_code make_error_code(MccSimpleGuidingModelErrorCode ec) -/* */ - -class MccCelestialPointTrack final -{ -public: - template - MccCelestialPointTrack(ASTROM_ENGINE_T& astrom_engine, - typename ASTROM_ENGINE_T::juldate_t start, - DT step, - size_t Npoints) - { - const auto p_astrom_engine = &astrom_engine; - - _compFunc = []() { - - }; - } - -private: - std::function _compFunc; -}; - -/* */ - - template class MccSimpleGuidingModel : public LoggerT { diff --git a/cxx/mcc_slew_guiding_model_common.h b/cxx/mcc_slew_guiding_model_common.h index a0bea74..8d329d7 100644 --- a/cxx/mcc_slew_guiding_model_common.h +++ b/cxx/mcc_slew_guiding_model_common.h @@ -27,7 +27,8 @@ static_assert(traits::mcc_celestial_point_c, "MccCelestialPoi /* COMMON SLEW-AND-GUIDING POINT CLASS DEFINITION */ -struct MccSlewAndGuidingPoint : MccCelestialPoint { +template +struct MccSimpleSlewAndGuidingModelParams { // ******* default constants ******* static constexpr size_t defaultWithinToleranceCycleNumber = 10; @@ -74,6 +75,11 @@ struct MccSlewAndGuidingPoint : MccCelestialPoint { bool dualAxisGuiding{true}; // mount must be of an equatorial type: false means guiding along only HA-axis }; +struct MccSlewAndGuidingPoint : MccCelestialPoint, + MccSimpleSlewAndGuidingModelParams { + typedef MccSimpleSlewAndGuidingModelParams slew_guiding_params_t; +}; + /* CHECK FOR CURRENT MOUNT POSITION IN PROHIBITED ZONES */ @@ -100,24 +106,32 @@ template ResT> auto mccCheckInZonePZRange(const TelemetryDataT& telemetry_data, const RT& pzones, ResT& result) { + bool in_zone = false; + auto Npz = std::ranges::distance(pzones); if (!Npz) { - return; + return in_zone; } auto res_sz = std::ranges::distance(result); + bool ok; size_t i = 1; auto res_iter = result.begin(); for (auto& el : pzones) { + ok = el.inZone(telemetry_data); + in_zone |= ok; + if (i > res_sz) { - std::back_inserter(result) = el.inZone(telemetry_data); + std::back_inserter(result) = ok; } else { std::ranges::advance(res_iter, 1); - *res_iter = el.inZone(telemetry_data); + *res_iter = ok; } ++i; } + + return in_zone; } } // namespace mcc