From a984f7735194d18a0b424b8d457fd20eafa52f0d Mon Sep 17 00:00:00 2001 From: "Timur A. Fatkhullin" Date: Mon, 1 Jun 2026 16:55:53 +0300 Subject: [PATCH] new config implementation --- asibfm700_config.h | 68 +++++++++++++++++++++++++++++++++++++++++++ asibfm700_pcm_fit.cpp | 67 ++++++++++++++++++++++++++++++++++++++---- 2 files changed, 129 insertions(+), 6 deletions(-) diff --git a/asibfm700_config.h b/asibfm700_config.h index 96e3e0d..9d193c7 100644 --- a/asibfm700_config.h +++ b/asibfm700_config.h @@ -131,6 +131,17 @@ static auto Asibfm700MountConfigurationDefaults = std::make_tuple( /* hardware-related */ + // hardware polling period in millisecs (used in hardwareSetState method; see asibfm700_servocontroller.cpp) + make_config_record("hardwarePollingPeriod", + std::chrono::milliseconds{300}, + {"hardware driver polling period in millisecs"}), + + // hardware polling timeout in millisecs (used in hardwareSetState method; see asibfm700_servocontroller.cpp) + make_config_record("hardwarePollingTimeout", + std::chrono::milliseconds{30000}, + {"hardware driver polling timeout in millisecs"}), + + // hardware mode: 1 - model mode, otherwise real mode make_config_record("RunModel", 0, {" hardware mode: 1 - model mode, otherwise real mode"}), @@ -253,6 +264,9 @@ static auto Asibfm700MountConfigurationDefaults = std::make_tuple( // slew process timeout in seconds make_config_record("slewTimeout", std::chrono::seconds(3600), {" slew process timeout in seconds"}), + // coordinates difference in arcsecs to stop slewing + make_config_record("slewToleranceRadius", 5.0, {"coordinates difference in arcsecs to stop slewing"}), + // slewing trajectory filename (used for debugging purposes) // if it is an empty - just skip saving make_config_record("slewingPathFilename", @@ -552,6 +566,12 @@ public: hw_cfg.hwConfig = {}; + hw_cfg.pollingInterval = + getValue("hardwarePollingPeriod").value_or(std::chrono::milliseconds(300)); + + hw_cfg.pollingInterval = + getValue("hardwarePollingTimeout").value_or(std::chrono::milliseconds(30000)); + hw_cfg.MountDevPath = getValue("MountDevPath").value_or(std::string{}); hw_cfg.EncoderDevPath = getValue("EncoderDevPath").value_or(std::string{}); hw_cfg.EncoderXDevPath = getValue("EncoderXDevPath").value_or(std::string{}); @@ -756,6 +776,54 @@ public: } + details::movement_pars_t movingModelParams() const + { + details::movement_pars_t pars; + + auto get_value = [this](std::string_view name, VT& val) { + val = getValue(name).value_or(val); + }; + + pars.telemetryTimeout = + getValue("telemetryTimeout").value_or(pars.telemetryTimeout); + + pars.minTimeToPZone = getValue("minTimeToPZone").value_or(pars.minTimeToPZone); + + + pars.slewToleranceRadius = + getValue("slewToleranceRadius").value_or(pars.slewToleranceRadius) * + mcc::MCC_ARCSECS_TO_RADS; + + get_value("slewingTelemetryInterval", pars.slewingTelemetryInterval); + + pars.slewRateX = getValue("hwMaxRateHA").value_or(pars.slewRateX); + pars.slewRateY = getValue("hwMaxRateDEC").value_or(pars.slewRateY); + + pars.adjustCoordDiff = + getValue("adjustCoordDiff").value_or(pars.adjustCoordDiff) * + mcc::MCC_DEGRESS_TO_RADS; + + pars.slewTimeout = getValue("slewTimeout").value_or(pars.slewTimeout); + + pars.slewingPathFilename = + getValue("slewingPathFilename").value_or(std::string()); + + get_value("trackingTelemetryInterval", pars.trackingTelemetryInterval); + + + pars.trackingCycleInterval = getValue("trackingCycleInterval") + .value_or(pars.trackingCycleInterval); + + pars.trackingMaxCoordDiff = + getValue("trackingMaxCoordDiff").value_or(pars.trackingMaxCoordDiff) * + mcc::MCC_ARCSECS_TO_RADS; + + pars.trackingPathFilename = + getValue("trackingPathFilename").value_or(std::string()); + + return pars; + } + private: std::filesystem::path _lastConfigPath{}; diff --git a/asibfm700_pcm_fit.cpp b/asibfm700_pcm_fit.cpp index dc8e5e7..7f91043 100644 --- a/asibfm700_pcm_fit.cpp +++ b/asibfm700_pcm_fit.cpp @@ -9,7 +9,7 @@ #include #include "asibfm700_config.h" -#include "asibfm700_configfile.h" +// #include "asibfm700_configfile.h" // static constexpr mcc::MccMountType MOUNT_TYPE{mcc::MccMountType::CROSSAXIS_TYPE}; @@ -37,13 +37,14 @@ int main(int argc, char* argv[]) mcc::impl::MccPCMFitter pcm_fitter; mcc::impl::MccPCMFitter::compute_params_t comp_pars; - asibfm700::Asibfm700MountConfig mount_cfg; - asibfm700::Asibfm700MountConfiguration cfg; + // asibfm700::Asibfm700MountConfig mount_cfg; + asibfm700::Asibfm700MountConfiguration mount_cfg; + // asibfm700::Asibfm700MountConfiguration cfg; - cfg.dumpDefaultsToFile("eecc.cfg"); + // cfg.dumpDefaultsToFile("eecc.cfg"); - cfg.load("eecc.cfg"); - cfg.save("eecc.cfg1"); + // cfg.load("eecc.cfg"); + // cfg.save("eecc.cfg1"); try { auto opt_result = options.parse(argc, argv); @@ -289,6 +290,60 @@ int main(int argc, char* argv[]) return 200; } + // change corresponded mount config items + + if (comp_result.pcm_type == mcc::impl::MccDefaultPCMType::PCM_TYPE_GEOMETRY_BSPLINE +#ifdef USE_BSPLINE_PCM + || comp_result.pcm_type == mcc::impl::MccDefaultPCMType::PCM_TYPE_GEOMETRY) +#endif + { + auto err = mount_cfg.setValue("pcmGeomCoeffs", pcm_data.geomCoefficients); + if (err) { + std::println("Unexpected error while setting geometric coefficiens to mount configuration! (err = {})", + err.message()); + return 300; + } +#ifdef USE_BSPLINE_PCM + } else if (comp_result.pcm_type == mcc::impl::MccDefaultPCMType::PCM_TYPE_GEOMETRY_BSPLINE || + comp_result.pcm_type == mcc::impl::MccDefaultPCMType::PCM_TYPE_BSPLINE) { + auto err = mount_cfg.setValue("pcmBsplineXcoeffs", pcm_data.bspline.coeffsX); + if (err) { + std::println( + "Unexpected error while setting B-spline HA-coefficiens to mount configuration! (err = {})", + err.message()); + return 300; + } + err = mount_cfg.setValue("pcmBsplineYcoeffs", pcm_data.bspline.coeffsY); + if (err) { + std::println( + "Unexpected error while setting B-spline DEC-coefficiens to mount configuration! (err = {})", + err.message()); + return 300; + } + + if (comp_result.pcm_type == mcc::impl::MccDefaultPCMType::PCM_TYPE_BSPLINE) { + err = mount_cfg.setValue("pcmInverseBsplineXcoeffs", pcm_data.bspline.inverseCoeffsX); + if (err) { + std::println( + "Unexpected error while setting inverse B-spline HA-coefficiens to mount configuration! (err = " + "{})", + err.message()); + return 300; + } + err = mount_cfg.setValue("pcmInverseBsplineYcoeffs", pcm_data.bspline.inverseCoeffsY); + if (err) { + std::println( + "Unexpected error while setting inverse B-spline DEC-coefficiens to mount configuration! (err " + "= {})", + err.message()); + return 300; + } + } +#endif + } + + mount_cfg.save(); // NOTE: THE SAME FILENAME! + auto tab = pcm_fitter.getPCMTable(); std::ofstream ofst;