diff --git a/CMakeLists.txt b/CMakeLists.txt index f91d8c1..fce22fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # pass to mcc-library option(USE_BSPLINE_PCM "Use of FITPACK bivariate splines for PCM" ON) -find_package(cxxopts REQUIRED) +# find_package(cxxopts REQUIRED) #set(EXAMPLES OFF CACHE BOOL "" FORCE) # set(CMAKE_BUILD_TYPE "Release") @@ -82,14 +82,23 @@ set(CMAKE_BUILD_TYPE "Debug") include(FetchContent) +FetchContent_Declare( + cxxopts + GIT_REPOSITORY https://github.com/jarro2783/cxxopts.git + GIT_SHALLOW 1 + GIT_PROGRESS 1 + CMAKE_ARGS + -DCXXOPTS_USE_UNICODE=0 +) +FetchContent_MakeAvailable(cxxopts) + set(EXAMPLES OFF CACHE BOOL "" FORCE) FetchContent_Declare( servo_lib GIT_REPOSITORY https://timur@git.sao.ru/timur/LibSidServo.git GIT_SHALLOW 1 GIT_PROGRESS 1 - SOURCE_DIR - ${CMAKE_BINARY_DIR}/LibSidServo + SOURCE_DIR ${CMAKE_BINARY_DIR}/LibSidServo ) FetchContent_MakeAvailable(servo_lib) @@ -101,8 +110,7 @@ FetchContent_Declare( # GIT_REPOSITORY ssh://git@95.140.147.151:/home/git/mcc.git GIT_SHALLOW 1 GIT_PROGRESS 1 - SOURCE_DIR - ${CMAKE_BINARY_DIR}/mcc + SOURCE_DIR ${CMAKE_BINARY_DIR}/mcc # OVERRIDE_FIND_PACKAGE ) set(BUILD_TESTS OFF) diff --git a/asibfm700_config.h b/asibfm700_config.h index 9d193c7..c4a4e73 100644 --- a/asibfm700_config.h +++ b/asibfm700_config.h @@ -293,6 +293,11 @@ static auto Asibfm700MountConfigurationDefaults = std::make_tuple( ); +static_assert(std::is_copy_assignable_v>); +static_assert(std::is_copy_assignable_v>); + +// static_assert(std::is_copy_assignable_v); + class Asibfm700MountConfiguration : public mcc::impl::MccKeyValueHolder { using base_t = mcc::impl::MccKeyValueHolder; @@ -321,6 +326,12 @@ public: ~Asibfm700MountConfiguration() = default; + Asibfm700MountConfiguration(const Asibfm700MountConfiguration&) = default; + Asibfm700MountConfiguration(Asibfm700MountConfiguration&&) = default; + + Asibfm700MountConfiguration& operator=(const Asibfm700MountConfiguration&) = default; + Asibfm700MountConfiguration& operator=(Asibfm700MountConfiguration&&) = default; + std::error_code load(const std::filesystem::path& path) { std::string buffer; diff --git a/asibfm700_mount.cpp b/asibfm700_mount.cpp index 2fd92ff..ebca9c5 100644 --- a/asibfm700_mount.cpp +++ b/asibfm700_mount.cpp @@ -10,7 +10,8 @@ namespace asibfm700 /* CONSTRUCTOR AND DESTRUCTOR */ -Asibfm700Mount::Asibfm700Mount(Asibfm700MountConfig const& config, std::shared_ptr logger) +// Asibfm700Mount::Asibfm700Mount(Asibfm700MountConfig const& config, std::shared_ptr logger) +Asibfm700Mount::Asibfm700Mount(Asibfm700MountConfiguration const& config, std::shared_ptr logger) : _servolController(config.servoControllerConfig()), _pcm(config.pcmData()), gm_class_t(std::make_tuple(&_servolController, &_pcm), @@ -106,17 +107,36 @@ Asibfm700Mount::error_t Asibfm700Mount::initMount() clearPZones(); logInfo("Add prohibited zones ..."); + // logInfo(" Add MccAltLimitPZ zone: min alt = {}, lat = {} (pzone type: '{}')", + // _mountConfig.pzMinAltitude().degrees(), _mountConfig.siteLatitude().degrees(), + // "Minimal altitude prohibited zone"); + // addPZone(mcc::impl::MccAltLimitPZ{_mountConfig.pzMinAltitude(), + // _mountConfig.siteLatitude()}); + + // logInfo(" Add MccAxisLimitSwitchPZ zone: min value = {}, max value = {} (pzone type: '{}')", + // _mountConfig.pzLimitSwitchHAMin().degrees(), _mountConfig.pzLimitSwitchHAMax().degrees(), + // "HA-axis limit switch"); + // size_t pz_num = addPZone(mcc::impl::MccAxisLimitSwitchPZ{ + // _mountConfig.pzLimitSwitchHAMin(), _mountConfig.pzLimitSwitchHAMax(), &_pcm}); + + size_t pz_num = addPZone(_mountConfig.minAltPZone()); logInfo(" Add MccAltLimitPZ zone: min alt = {}, lat = {} (pzone type: '{}')", - _mountConfig.pzMinAltitude().degrees(), _mountConfig.siteLatitude().degrees(), + _mountConfig.minAltPZone().altLimit().degrees(), _mountConfig.minAltPZone().latitude().sexagesimal(), "Minimal altitude prohibited zone"); - addPZone(mcc::impl::MccAltLimitPZ{_mountConfig.pzMinAltitude(), - _mountConfig.siteLatitude()}); + + auto haPZone = _mountConfig.axisLimitSwitchHA(); + haPZone.setPCM(&_pcm); logInfo(" Add MccAxisLimitSwitchPZ zone: min value = {}, max value = {} (pzone type: '{}')", - _mountConfig.pzLimitSwitchHAMin().degrees(), _mountConfig.pzLimitSwitchHAMax().degrees(), - "HA-axis limit switch"); - size_t pz_num = addPZone(mcc::impl::MccAxisLimitSwitchPZ{ - _mountConfig.pzLimitSwitchHAMin(), _mountConfig.pzLimitSwitchHAMax(), &_pcm}); + haPZone.maxLimit().degrees(), haPZone.maxLimit().degrees(), "HA-axis limit switch"); + pz_num = addPZone(std::move(haPZone)); + + auto decPZone = _mountConfig.axisLimitSwitchDEC(); + decPZone.setPCM(&_pcm); + + logInfo(" Add MccAxisLimitSwitchPZ zone: min value = {}, max value = {} (pzone type: '{}')", + decPZone.maxLimit().degrees(), decPZone.maxLimit().degrees(), "DEC-axis limit switch"); + pz_num = addPZone(std::move(decPZone)); logInfo("{} prohibited zones were added successfully", pz_num); @@ -149,12 +169,12 @@ Asibfm700Mount::error_t Asibfm700Mount::initMount() logInfo(" PIDRefreshDt: {}", to_msecs(hw_cfg.devConfig.PIDRefreshDt)); logInfo(" PIDCycleDt: {}", to_msecs(hw_cfg.devConfig.PIDCycleDt)); - logInfo(" XPIDC: [P: {}, I: {}, D: {}]", hw_cfg.devConfig.XPIDC.P, hw_cfg.devConfig.XPIDC.I, - hw_cfg.devConfig.XPIDC.D); + // logInfo(" XPIDC: [P: {}, I: {}, D: {}]", hw_cfg.devConfig.XPIDC.P, hw_cfg.devConfig.XPIDC.I, + // hw_cfg.devConfig.XPIDC.D); logInfo(" XPIDV: [P: {}, I: {}, D: {}]", hw_cfg.devConfig.XPIDV.P, hw_cfg.devConfig.XPIDV.I, hw_cfg.devConfig.XPIDV.D); - logInfo(" YPIDC: [P: {}, I: {}, D: {}]", hw_cfg.devConfig.YPIDC.P, hw_cfg.devConfig.YPIDC.I, - hw_cfg.devConfig.YPIDC.D); + // logInfo(" YPIDC: [P: {}, I: {}, D: {}]", hw_cfg.devConfig.YPIDC.P, hw_cfg.devConfig.YPIDC.I, + // hw_cfg.devConfig.YPIDC.D); logInfo(" YPIDV: [P: {}, I: {}, D: {}]", hw_cfg.devConfig.YPIDV.P, hw_cfg.devConfig.YPIDV.I, hw_cfg.devConfig.YPIDV.D); logInfo(" XEncZero: {}", hw_cfg.devConfig.XEncZero); @@ -359,7 +379,8 @@ Asibfm700Mount::error_t Asibfm700Mount::initMount() } -Asibfm700Mount::error_t Asibfm700Mount::updateMountConfig(const Asibfm700MountConfig& cfg) +// Asibfm700Mount::error_t Asibfm700Mount::updateMountConfig(const Asibfm700MountConfig& cfg) +Asibfm700Mount::error_t Asibfm700Mount::updateMountConfig(const Asibfm700MountConfiguration& cfg) { std::lock_guard lock{*_mountConfigMutex}; @@ -375,7 +396,8 @@ Asibfm700Mount::error_t Asibfm700Mount::updateMountConfig(const Asibfm700MountCo Asibfm700Mount::error_t Asibfm700Mount::updateMountConfig(const std::string& cfg_filename) { - Asibfm700MountConfig new_config; + // Asibfm700MountConfig new_config; + Asibfm700MountConfiguration new_config; auto err = new_config.load(cfg_filename.empty() ? _mountConfig.configFilename() : std::filesystem::path{cfg_filename}); if (err) { diff --git a/asibfm700_mount.h b/asibfm700_mount.h index f6d3858..cdbb844 100644 --- a/asibfm700_mount.h +++ b/asibfm700_mount.h @@ -8,7 +8,8 @@ #include #include "asibfm700_common.h" -#include "asibfm700_configfile.h" +// #include "asibfm700_configfile.h" +#include "asibfm700_config.h" namespace asibfm700 { @@ -50,7 +51,8 @@ public: // using Asibfm700PZoneContainer::addPZone; - Asibfm700Mount(Asibfm700MountConfig const& config, std::shared_ptr logger); + // Asibfm700Mount(Asibfm700MountConfig const& config, std::shared_ptr logger); + Asibfm700Mount(Asibfm700MountConfiguration const& config, std::shared_ptr logger); ~Asibfm700Mount(); @@ -62,9 +64,11 @@ public: error_t initMount(); - error_t updateMountConfig(Asibfm700MountConfig const&); + // error_t updateMountConfig(Asibfm700MountConfig const&); + error_t updateMountConfig(Asibfm700MountConfiguration const&); error_t updateMountConfig(std::string const& = std::string{}); // new filename - Asibfm700MountConfig currentMountConfig(); + // Asibfm700MountConfig currentMountConfig(); + Asibfm700MountConfiguration currentMountConfig(); // redefined method auto getPointingTarget() const @@ -73,7 +77,8 @@ public: } protected: - Asibfm700MountConfig _mountConfig; + // Asibfm700MountConfig _mountConfig; + Asibfm700MountConfiguration _mountConfig; std::unique_ptr _mountConfigMutex; AsibFM700ServoController _servolController; diff --git a/asibfm700_netserver_main.cpp b/asibfm700_netserver_main.cpp index 6cb19be..cc1366e 100644 --- a/asibfm700_netserver_main.cpp +++ b/asibfm700_netserver_main.cpp @@ -64,12 +64,17 @@ int main(int argc, char* argv[]) return 0; } - asibfm700::Asibfm700MountConfig mount_cfg; + // asibfm700::Asibfm700MountConfig mount_cfg; + asibfm700::Asibfm700MountConfiguration mount_cfg; std::string fname = opt_result["dump"].as(); if (fname.size()) { - bool ok = mount_cfg.dumpDefaultsToFile(fname); - if (!ok) { + // bool ok = mount_cfg.dumpDefaultsToFile(fname); + // if (!ok) { + // return 255; + // } + auto err = mount_cfg.dumpDefaultsToFile(fname); + if (!err) { return 255; }