new config implementation

This commit is contained in:
2026-06-01 16:55:53 +03:00
parent e199a73640
commit a984f77351
2 changed files with 129 additions and 6 deletions

View File

@@ -131,6 +131,17 @@ static auto Asibfm700MountConfigurationDefaults = std::make_tuple(
/* hardware-related */ /* 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 // hardware mode: 1 - model mode, otherwise real mode
make_config_record("RunModel", 0, {" 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 // slew process timeout in seconds
make_config_record("slewTimeout", std::chrono::seconds(3600), {" 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) // slewing trajectory filename (used for debugging purposes)
// if it is an empty - just skip saving // if it is an empty - just skip saving
make_config_record("slewingPathFilename", make_config_record("slewingPathFilename",
@@ -552,6 +566,12 @@ public:
hw_cfg.hwConfig = {}; hw_cfg.hwConfig = {};
hw_cfg.pollingInterval =
getValue<std::chrono::milliseconds>("hardwarePollingPeriod").value_or(std::chrono::milliseconds(300));
hw_cfg.pollingInterval =
getValue<std::chrono::milliseconds>("hardwarePollingTimeout").value_or(std::chrono::milliseconds(30000));
hw_cfg.MountDevPath = getValue<std::string>("MountDevPath").value_or(std::string{}); hw_cfg.MountDevPath = getValue<std::string>("MountDevPath").value_or(std::string{});
hw_cfg.EncoderDevPath = getValue<std::string>("EncoderDevPath").value_or(std::string{}); hw_cfg.EncoderDevPath = getValue<std::string>("EncoderDevPath").value_or(std::string{});
hw_cfg.EncoderXDevPath = getValue<std::string>("EncoderXDevPath").value_or(std::string{}); hw_cfg.EncoderXDevPath = getValue<std::string>("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]<typename VT>(std::string_view name, VT& val) {
val = getValue<VT>(name).value_or(val);
};
pars.telemetryTimeout =
getValue<decltype(pars.telemetryTimeout)>("telemetryTimeout").value_or(pars.telemetryTimeout);
pars.minTimeToPZone = getValue<decltype(pars.minTimeToPZone)>("minTimeToPZone").value_or(pars.minTimeToPZone);
pars.slewToleranceRadius =
getValue<decltype(pars.slewToleranceRadius)>("slewToleranceRadius").value_or(pars.slewToleranceRadius) *
mcc::MCC_ARCSECS_TO_RADS;
get_value("slewingTelemetryInterval", pars.slewingTelemetryInterval);
pars.slewRateX = getValue<decltype(pars.slewRateX)>("hwMaxRateHA").value_or(pars.slewRateX);
pars.slewRateY = getValue<decltype(pars.slewRateY)>("hwMaxRateDEC").value_or(pars.slewRateY);
pars.adjustCoordDiff =
getValue<decltype(pars.adjustCoordDiff)>("adjustCoordDiff").value_or(pars.adjustCoordDiff) *
mcc::MCC_DEGRESS_TO_RADS;
pars.slewTimeout = getValue<decltype(pars.slewTimeout)>("slewTimeout").value_or(pars.slewTimeout);
pars.slewingPathFilename =
getValue<decltype(pars.slewingPathFilename)>("slewingPathFilename").value_or(std::string());
get_value("trackingTelemetryInterval", pars.trackingTelemetryInterval);
pars.trackingCycleInterval = getValue<decltype(pars.trackingCycleInterval)>("trackingCycleInterval")
.value_or(pars.trackingCycleInterval);
pars.trackingMaxCoordDiff =
getValue<decltype(pars.trackingMaxCoordDiff)>("trackingMaxCoordDiff").value_or(pars.trackingMaxCoordDiff) *
mcc::MCC_ARCSECS_TO_RADS;
pars.trackingPathFilename =
getValue<decltype(pars.trackingPathFilename)>("trackingPathFilename").value_or(std::string());
return pars;
}
private: private:
std::filesystem::path _lastConfigPath{}; std::filesystem::path _lastConfigPath{};

View File

@@ -9,7 +9,7 @@
#include <mcc/mcc_pcm_fit.h> #include <mcc/mcc_pcm_fit.h>
#include "asibfm700_config.h" #include "asibfm700_config.h"
#include "asibfm700_configfile.h" // #include "asibfm700_configfile.h"
// static constexpr mcc::MccMountType MOUNT_TYPE{mcc::MccMountType::CROSSAXIS_TYPE}; // static constexpr mcc::MccMountType MOUNT_TYPE{mcc::MccMountType::CROSSAXIS_TYPE};
@@ -37,13 +37,14 @@ int main(int argc, char* argv[])
mcc::impl::MccPCMFitter<asibfm700::asibfm700MountType> pcm_fitter; mcc::impl::MccPCMFitter<asibfm700::asibfm700MountType> pcm_fitter;
mcc::impl::MccPCMFitter<asibfm700::asibfm700MountType>::compute_params_t comp_pars; mcc::impl::MccPCMFitter<asibfm700::asibfm700MountType>::compute_params_t comp_pars;
asibfm700::Asibfm700MountConfig mount_cfg; // asibfm700::Asibfm700MountConfig mount_cfg;
asibfm700::Asibfm700MountConfiguration cfg; asibfm700::Asibfm700MountConfiguration mount_cfg;
// asibfm700::Asibfm700MountConfiguration cfg;
cfg.dumpDefaultsToFile("eecc.cfg"); // cfg.dumpDefaultsToFile("eecc.cfg");
cfg.load("eecc.cfg"); // cfg.load("eecc.cfg");
cfg.save("eecc.cfg1"); // cfg.save("eecc.cfg1");
try { try {
auto opt_result = options.parse(argc, argv); auto opt_result = options.parse(argc, argv);
@@ -289,6 +290,60 @@ int main(int argc, char* argv[])
return 200; 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(); auto tab = pcm_fitter.getPCMTable();
std::ofstream ofst; std::ofstream ofst;