... add dump of config for Asibfm700MountConfig class

This commit is contained in:
Timur A. Fatkhullin 2025-10-30 16:11:23 +03:00
parent 3682ccdda6
commit f2be52d17c
2 changed files with 155 additions and 235 deletions

View File

@ -30,6 +30,7 @@ template <config_record_valid_type_c T>
struct simple_config_record_t { struct simple_config_record_t {
std::string_view key; std::string_view key;
T value; T value;
std::vector<std::string_view> comment;
}; };
@ -38,60 +39,77 @@ struct simple_config_record_t {
// configuration description and its defaults // configuration description and its defaults
static auto Asibfm700MountConfigDefaults = std::make_tuple( static auto Asibfm700MountConfigDefaults = std::make_tuple(
// main cycle period in millisecs // main cycle period in millisecs
simple_config_record_t{"hardwarePollingPeriod", std::chrono::milliseconds{100}}, simple_config_record_t{"hardwarePollingPeriod", std::chrono::milliseconds{100}, {"main cycle period in millisecs"}},
/* geographic coordinates of the observation site */ /* geographic coordinates of the observation site */
// site latitude in degrees // site latitude in degrees
simple_config_record_t{"siteLatitude", mcc::MccAngle(43.646711_degs)}, simple_config_record_t{"siteLatitude", mcc::MccAngle(43.646711_degs), {"site latitude in degrees"}},
// site longitude in degrees // site longitude in degrees
simple_config_record_t{"siteLongitude", mcc::MccAngle(41.440732_degs)}, simple_config_record_t{"siteLongitude", mcc::MccAngle(41.440732_degs), {"site longitude in degrees"}},
// site elevation in meters // site elevation in meters
simple_config_record_t{"siteElevation", 2070.0}, simple_config_record_t{"siteElevation", 2070.0, {"site elevation in meters"}},
/* celestial coordinate transformation */ /* celestial coordinate transformation */
// wavelength at which refraction is calculated (in mkm) // wavelength at which refraction is calculated (in mkm)
simple_config_record_t{"refractWavelength", 0.55}, simple_config_record_t{"refractWavelength", 0.55, {"wavelength at which refraction is calculated (in mkm)"}},
// an empty filename means default precompiled string // an empty filename means default precompiled string
simple_config_record_t{"leapSecondFilename", std::string()}, simple_config_record_t{"leapSecondFilename", std::string(), {"an empty filename means default precompiled string"}},
// an empty filename means default precompiled string // an empty filename means default precompiled string
simple_config_record_t{"bulletinAFilename", std::string()}, simple_config_record_t{"bulletinAFilename", std::string(), {"an empty filename means default precompiled string"}},
/* pointing correction model */ /* pointing correction model */
// PCM default type // PCM default type
simple_config_record_t{"pcmType", mcc::MccDefaultPCMType::PCM_TYPE_GEOMETRY}, simple_config_record_t{"pcmType",
mcc::MccDefaultPCMType::PCM_TYPE_GEOMETRY,
{"PCM type:", "GEOMETRY - 'classic' geometry-based correction coefficients",
"GEOMETRY-BSPLINE - previous one and additional 2D B-spline corrections",
"BSPLINE - pure 2D B-spline corrections"}},
// PCM geometrical coefficients // PCM geometrical coefficients
simple_config_record_t{"pcmGeomCoeffs", std::vector<double>{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}}, simple_config_record_t{"pcmGeomCoeffs",
std::vector<double>{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{"PCM geometrical coefficients"}},
// PCM B-spline degrees // PCM B-spline degrees
simple_config_record_t{"pcmBsplineDegree", std::vector<size_t>{3, 3}}, simple_config_record_t{"pcmBsplineDegree", std::vector<size_t>{3, 3}, {"PCM B-spline degrees"}},
// PCM B-spline knots along X-axis (HA-angle or azimuth). By default from 0 to 2*PI radians // PCM B-spline knots along X-axis (HA-angle or azimuth). By default from 0 to 2*PI radians
// NOTE: The first and last values are interpretated as border knots!!! // NOTE: The first and last values are interpretated as border knots!!!
// Thus the array length must be equal to or greater than 2! // Thus the array length must be equal to or greater than 2!
simple_config_record_t{"pcmBsplineXknots", simple_config_record_t{"pcmBsplineXknots",
std::vector<double>{0.0, 0.6981317, 1.3962634, 2.0943951, 2.7925268, 3.4906585, 4.1887902, std::vector<double>{0.0, 0.6981317, 1.3962634, 2.0943951, 2.7925268, 3.4906585, 4.1887902,
4.88692191, 5.58505361, 6.28318531}}, 4.88692191, 5.58505361, 6.28318531},
{"PCM B-spline knots along X-axis (HA-angle or azimuth). By default from 0 to 2*PI radians",
"NOTE: The first and last values are interpretated as border knots!!!",
" Thus the array length must be equal to or greater than 2!"}},
// PCM B-spline knots along Y-axis (declination or zenithal distance). By default from -PI/6 to PI/2 radians // PCM B-spline knots along Y-axis (declination or zenithal distance). By default from -PI/6 to PI/2 radians
// NOTE: The first and last values are interpretated as border knots!!! // NOTE: The first and last values are interpretated as border knots!!!
// Thus the array length must be equal to or greater than 2! // Thus the array length must be equal to or greater than 2!
simple_config_record_t{"pcmBsplineYknots", simple_config_record_t{
std::vector<double>{-0.52359878, -0.29088821, -0.05817764, 0.17453293, 0.40724349, "pcmBsplineYknots",
0.63995406, 0.87266463, 1.10537519, 1.33808576, 1.57079633}}, std::vector<double>{-0.52359878, -0.29088821, -0.05817764, 0.17453293, 0.40724349, 0.63995406, 0.87266463,
1.10537519, 1.33808576, 1.57079633},
{"PCM B-spline knots along Y-axis (declination or zenithal distance). By default from -PI/6 to PI/2 radians",
"NOTE: The first and last values are interpretated as border knots!!!",
" Thus the array length must be equal to or greater than 2!"}},
// PCM B-spline coeffs for along X-axis (HA-angle or azimuth) // PCM B-spline coeffs for along X-axis (HA-angle or azimuth)
simple_config_record_t{"pcmBsplineXcoeffs", std::vector<double>{}}, simple_config_record_t{"pcmBsplineXcoeffs",
std::vector<double>{},
{"PCM B-spline coeffs for along X-axis (HA-angle)"}},
// PCM B-spline coeffs for along Y-axis (declination or zenithal distance) // PCM B-spline coeffs for along Y-axis (declination or zenithal distance)
simple_config_record_t{"pcmBsplineYcoeffs", std::vector<double>{}}, simple_config_record_t{"pcmBsplineYcoeffs",
std::vector<double>{},
{"PCM B-spline coeffs for along Y-axis (declination angle)"}},
/* slewing and tracking parameters */ /* slewing and tracking parameters */
@ -100,286 +118,144 @@ static auto Asibfm700MountConfigDefaults = std::make_tuple(
// simple_config_record_t{"sideralRate", 15.0410686}, // simple_config_record_t{"sideralRate", 15.0410686},
// timeout for telemetry updating in milliseconds // timeout for telemetry updating in milliseconds
simple_config_record_t{"telemetryTimeout", std::chrono::milliseconds(3000)}, simple_config_record_t{"telemetryTimeout",
std::chrono::milliseconds(3000),
{"timeout for telemetry updating in milliseconds"}},
// minimal allowed time in seconds to prohibited zone // minimal allowed time in seconds to prohibited zone
simple_config_record_t{"minTimeToPZone", std::chrono::seconds(10)}, simple_config_record_t{"minTimeToPZone",
std::chrono::seconds(10),
{"minimal allowed time in seconds to prohibited zone"}},
// a time interval to update prohibited zones related quantities (millisecs) // a time interval to update prohibited zones related quantities (millisecs)
simple_config_record_t{"updatingPZoneInterval", std::chrono::milliseconds(5000)}, simple_config_record_t{"updatingPZoneInterval",
std::chrono::milliseconds(5000),
{"a time interval to update prohibited zones related quantities (millisecs)"}},
// coordinates difference in arcsecs to stop slewing // coordinates difference in arcsecs to stop slewing
simple_config_record_t{"slewToleranceRadius", 5.0}, simple_config_record_t{"slewToleranceRadius", 5.0, {"coordinates difference in arcsecs to stop slewing"}},
// target-mount coordinate difference in arcsecs to start adjusting of slewing // target-mount coordinate difference in arcsecs to start adjusting of slewing
simple_config_record_t{"adjustCoordDiff", 50.0}, simple_config_record_t{"adjustCoordDiff",
50.0,
{"target-mount coordinate difference in arcsecs to start adjusting of slewing"}},
// minimum time in millisecs between two successive adjustments // minimum time in millisecs between two successive adjustments
simple_config_record_t{"adjustCycleInterval", std::chrono::milliseconds(300)}, simple_config_record_t{"adjustCycleInterval",
std::chrono::milliseconds(300),
{"minimum time in millisecs between two successive adjustments"}},
// slew process timeout in seconds // slew process timeout in seconds
simple_config_record_t{"slewTimeout", std::chrono::seconds(3600)}, simple_config_record_t{"slewTimeout", std::chrono::seconds(3600), {"slew process timeout in seconds"}},
// a time shift into future to compute target position in future (UT1-scale time duration, millisecs) // a time shift into future to compute target position in future (UT1-scale time duration, millisecs)
simple_config_record_t{"timeShiftToTargetPoint", std::chrono::milliseconds(10000)}, simple_config_record_t{
"timeShiftToTargetPoint",
std::chrono::milliseconds(10000),
{"a time shift into future to compute target position in future (UT1-scale time duration, millisecs)"}},
// minimum time in millisecs between two successive tracking corrections // minimum time in millisecs between two successive tracking corrections
simple_config_record_t{"trackingCycleInterval", std::chrono::milliseconds(300)}, simple_config_record_t{"trackingCycleInterval",
std::chrono::milliseconds(300),
{"minimum time in millisecs between two successive tracking corrections"}},
// maximal valid target-to-mount distance for tracking process (arcsecs) // maximal valid target-to-mount distance for tracking process (arcsecs)
// if current distance is greater than assume current mount coordinate as target point // if current distance is greater than assume current mount coordinate as target point
simple_config_record_t{"trackingMaxCoordDiff", 20.0}, simple_config_record_t{"trackingMaxCoordDiff",
20.0,
{"maximal valid target-to-mount distance for tracking process (arcsecs)",
"if current distance is greater than assume current mount coordinate as target point"}},
/* prohibited zones */ /* prohibited zones */
// minimal altitude // minimal altitude
simple_config_record_t{"pzMinAltitude", mcc::MccAngle(10.0_degs)}, simple_config_record_t{"pzMinAltitude", mcc::MccAngle(10.0_degs), {"minimal altitude"}},
// HA-axis limit switch minimal value // HA-axis limit switch minimal value
simple_config_record_t{"pzLimitSwitchHAMin", mcc::MccAngle(-170.0_degs)}, simple_config_record_t{"pzLimitSwitchHAMin", mcc::MccAngle(-170.0_degs), {"HA-axis limit switch minimal value"}},
// HA-axis limit switch maximal value // HA-axis limit switch maximal value
simple_config_record_t{"pzLimitSwitchHAMax", mcc::MccAngle(170.0_degs)}, simple_config_record_t{"pzLimitSwitchHAMax", mcc::MccAngle(170.0_degs), {"HA-axis limit switch maximal value"}},
// DEC-axis limit switch minimal value // DEC-axis limit switch minimal value
simple_config_record_t{"pzLimitSwitchDecMin", mcc::MccAngle(-90.0_degs)}, simple_config_record_t{"pzLimitSwitchDecMin", mcc::MccAngle(-90.0_degs), {"DEC-axis limit switch minimal value"}},
// DEC-axis limit switch maximal value // DEC-axis limit switch maximal value
simple_config_record_t{"pzLimitSwitchDecMax", mcc::MccAngle(90.0_degs)}, simple_config_record_t{"pzLimitSwitchDecMax", mcc::MccAngle(90.0_degs), {"DEC-axis limit switch maximal value"}},
/* hardware-related */ /* hardware-related */
// hardware mode: 1 - model mode, otherwise real mode // hardware mode: 1 - model mode, otherwise real mode
simple_config_record_t{"RunModel", 0}, simple_config_record_t{"RunModel", 0, {"hardware mode: 1 - model mode, otherwise real mode"}},
// mount serial device paths // mount serial device paths
simple_config_record_t{"MountDevPath", std::string("/dev/ttyUSB0")}, simple_config_record_t{"MountDevPath", std::string("/dev/ttyUSB0"), {"mount serial device paths"}},
// mount serial device speed // mount serial device speed
simple_config_record_t{"MountDevSpeed", 19200}, simple_config_record_t{"MountDevSpeed", 19200, {"mount serial device speed"}},
// motor encoders serial device path // motor encoders serial device path
simple_config_record_t{"EncoderDevPath", std::string("")}, simple_config_record_t{"EncoderDevPath", std::string(""), {"motor encoders serial device path"}},
// X-axis encoder serial device path // X-axis encoder serial device path
simple_config_record_t{"EncoderXDevPath", std::string("/dev/encoderX0")}, simple_config_record_t{"EncoderXDevPath", std::string("/dev/encoderX0"), {"X-axis encoder serial device path"}},
// Y-axis encoder serial device path // Y-axis encoder serial device path
simple_config_record_t{"EncoderYDevPath", std::string("/dev/encoderY0")}, simple_config_record_t{"EncoderYDevPath", std::string("/dev/encoderY0"), {"Y-axis encoder serial device path"}},
// encoders serial device speed // encoders serial device speed
simple_config_record_t{"EncoderDevSpeed", 153000}, simple_config_record_t{"EncoderDevSpeed", 153000, {"encoders serial device speed"}},
// ==1 if encoder works as separate serial device, ==2 if there's new version with two devices // ==1 if encoder works as separate serial device, ==2 if there's new version with two devices
simple_config_record_t{"SepEncoder", 2}, simple_config_record_t{
"SepEncoder",
2,
{"==1 if encoder works as separate serial device, ==2 if there's new version with two devices"}},
// mount polling interval in millisecs // mount polling interval in millisecs
simple_config_record_t{"MountReqInterval", std::chrono::milliseconds(100)}, simple_config_record_t{"MountReqInterval", std::chrono::milliseconds(100), {"mount polling interval in millisecs"}},
// encoders polling interval in millisecs // encoders polling interval in millisecs
simple_config_record_t{"EncoderReqInterval", std::chrono::milliseconds(50)}, simple_config_record_t{"EncoderReqInterval",
std::chrono::milliseconds(50),
{"encoders polling interval in millisecs"}},
// mount axes rate calculation interval in millisecs // mount axes rate calculation interval in millisecs
simple_config_record_t{"EncoderSpeedInterval", std::chrono::milliseconds(100)}, simple_config_record_t{"EncoderSpeedInterval",
std::chrono::milliseconds(100),
{"mount axes rate calculation interval in millisecs"}},
// X-axis coordinate PID P,I,D-params // X-axis coordinate PID P,I,D-params
simple_config_record_t{"XPIDC", std::vector<double>{0.8, 0.1, 0.3}}, simple_config_record_t{"XPIDC", std::vector<double>{0.8, 0.1, 0.3}, {"X-axis coordinate PID P,I,D-params"}},
// X-axis rate PID P,I,D-params // X-axis rate PID P,I,D-params
simple_config_record_t{"XPIDV", std::vector<double>{1.0, 0.01, 0.2}}, simple_config_record_t{"XPIDV", std::vector<double>{1.0, 0.01, 0.2}, {"X-axis rate PID P,I,D-params"}},
// Y-axis coordinate PID P, I, D-params // Y-axis coordinate PID P, I, D-params
simple_config_record_t{"YPIDC", std::vector<double>{0.8, 0.1, 0.3}}, simple_config_record_t{"YPIDC", std::vector<double>{0.8, 0.1, 0.3}, {"Y-axis coordinate PID P, I, D-params"}},
// Y-axis rate PID P,I,D-params // Y-axis rate PID P,I,D-params
simple_config_record_t{"YPIDV", std::vector<double>{0.5, 0.2, 0.5}}, simple_config_record_t{"YPIDV", std::vector<double>{0.5, 0.2, 0.5}, {"Y-axis rate PID P,I,D-params"}},
// maximal moving rate (degrees per second) along HA-axis (Y-axis of Sidereal servo microcontroller) // maximal moving rate (degrees per second) along HA-axis (Y-axis of Sidereal servo microcontroller)
simple_config_record_t{"hwMaxRateHA", mcc::MccAngle(8.0_degs)}, simple_config_record_t{
"hwMaxRateHA",
mcc::MccAngle(8.0_degs),
{"maximal moving rate (degrees per second) along HA-axis (Y-axis of Sidereal servo microcontroller)"}},
// maximal moving rate (degrees per second) along DEC-axis (X-axis of Sidereal servo microcontroller) // maximal moving rate (degrees per second) along DEC-axis (X-axis of Sidereal servo microcontroller)
simple_config_record_t{"hwMaxRateDEC", mcc::MccAngle(10.0_degs)} simple_config_record_t{
"hwMaxRateDEC",
mcc::MccAngle(10.0_degs),
{"maximal moving rate (degrees per second) along DEC-axis (X-axis of Sidereal servo microcontroller)"}}
); );
static constexpr std::string_view Asibfm700MountDefaultConfigString =
R"--(
#
# ASTROSIB FM-700 MOUNT DEFAULT CONFIGURATION
#
# (created 2025-10-01T03:00:00.0)
#
# main cycle period in millisecs
hardwarePollingPeriod = 100
# geographic coordinates of the observation site
# site latitude in degrees
siteLatitude = 43.646711
# site longitude in degrees
siteLongitude = 41.440732
# site elevation in meters
siteElevation = 2070.0
# celestial coordinate transformation
# wavelength at which refraction is calculated (in mkm)
refractWavelength = 0.5
# an empty filename means default precompiled string
leapSecondFilename =
# an empty filename means default precompiled string
bulletinAFilename =
# pointing correction model
# PCM default type:
# GEOMETRY - "classic" geometry-based correction coefficients
# GEOMETRY-BSPLINE - previous one and additional 2D B-spline corrections
# BSPLINE - pure 2D B-spline corrections
pcmType = GEOMETRY
# PCM geometrical coefficients
pcmGeomCoeffs = 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
# PCM B-spline degrees
pcmBsplineDegree = 3, 3
# PCM B-spline knots along X-axis (HA-angle). By default from 0 to 2*PI radians
pcmBsplineXknots = 0.0, 0.6981317, 1.3962634, 2.0943951, 2.7925268, 3.4906585, 4.1887902, 4.88692191, 5.58505361, 6.28318531
# PCM B-spline knots along Y-axis (declination-angle). By default from -PI/6 to PI/2 radians
pcmBsplineYknots = -0.52359878, -0.29088821, -0.05817764, 0.17453293, 0.40724349, 0.63995406, 0.87266463, 1.10537519, 1.33808576, 1.57079633
# PCM B-spline coeffs for along X-axis (HA-angle)
pcmBsplineXcoeffs =
# PCM B-spline coeffs for along Y-axis (declination-angle)
pcmBsplineYcoeffs =
# slewing and tracking parameters
# arcseconds per second
#sideralRate = 15.0410686
# timeout for telemetry updating in milliseconds
telemetryTimeout = 3000
# minimal allowed time in seconds to prohibited zone
minTimeToPZone = 10
# a time interval to update prohibited zones related quantities (millisecs)
updatingPZoneInterval = 5000
# coordinates difference in arcsecs to stop slewing
slewToleranceRadius = 5.0
# target-mount coordinate difference in arcsecs to start adjusting of slewing
adjustCoordDiff = 50.0
# minimum time in millisecs between two successive adjustments
adjustCycleInterval = 300
# slew process timeout in seconds
slewTimeout = 3600
# a time shift into future to compute target position in future (UT1-scale time duration, millisecs)
timeShiftToTargetPoint = 10000
# minimum time in millisecs between two successive tracking corrections
trackingCycleInterval = 300
# maximal valid target-to-mount distance for tracking process (arcsecs)
# if current distance is greater than assume current mount coordinate as target point
trackingMaxCoordDiff = 20.0
# prohibited zones
# minimal altitude in degrees
pzMinAltitude = 10.0
# HA-axis limit switch minimal value in degrees
pzLimitSwitchHAMin = -170.0
# HA-axis limit switch maximal value in degrees
pzLimitSwitchHAMax = 170.0
# DEC-axis limit switch minimal value in degrees
pzLimitSwitchDecMin = -90.0
# DEC-axis limit switch maximal value in degrees
pzLimitSwitchDecMax = 90.0
# hardware-related
# hardware mode: 1 - model mode, otherwise real mode
RunModel = 0
# mount serial device paths
MountDevPath = /dev/ttyUSB0
# mount serial device speed
MountDevSpeed = 19200
# motor encoders serial device path
EncoderDevPath =
# X-axis encoder serial device path
EncoderXDevPath = /dev/encoderX0
# Y-axis encoder serial device path
EncoderYDevPath = /dev/encoderY0
# encoders serial device speed
EncoderDevSpeed = 153000
# ==1 if encoder works as separate serial device, ==2 if there's new version with two devices
SepEncoder = 2
# mount polling interval in millisecs
MountReqInterval = 100
# encoders polling interval in millisecs
EncoderReqInterval = 50
# mount axes rate calculation interval in millisecs
EncoderSpeedInterval = 100
# X-axis coordinate PID P,I,D-params
XPIDC = 0.8, 0.1, 0.3
# X-axis rate PID P,I,D-params
XPIDV = 1.0, 0.01, 0.2
# Y-axis coordinate PID P,I,D-params
YPIDC = 0.8, 0.1, 0.3
# Y-axis rate PID P,I,D-params
YPIDV = 0.5, 0.2, 0.5
# maximal moving rate (degrees per second) along HA-axis (Y-axis of Sidereal servo microcontroller)
hwMaxRateHA = 8.0
# maximal moving rate (degrees per second) along DEC-axis (X-axis of Sidereal servo microcontroller)
hwMaxRateDEC = 10.0
)--";
class Asibfm700MountConfig : public mcc::utils::KeyValueHolder<decltype(Asibfm700MountConfigDefaults)> class Asibfm700MountConfig : public mcc::utils::KeyValueHolder<decltype(Asibfm700MountConfigDefaults)>
{ {
using base_t = mcc::utils::KeyValueHolder<decltype(Asibfm700MountConfigDefaults)>; using base_t = mcc::utils::KeyValueHolder<decltype(Asibfm700MountConfigDefaults)>;
@ -792,19 +668,70 @@ public:
return ec; return ec;
} }
// dump default values to file bool dumpDefaultsToFile(const std::filesystem::path& path)
static bool dumpDefaults(const std::filesystem::path& path)
{ {
std::ofstream fst(path); std::ofstream fst(path);
if (!fst.is_open()) { if (!fst.is_open()) {
return false; return false;
} }
fst << asibfm700::Asibfm700MountDefaultConfigString; fst << "#\n";
fst << "# ASTROSIB FM-700 MOUNT CONFIGURATION\n" << "#\n";
fst << "# (created at " << std::format("{:%FT%T UTC}", std::chrono::system_clock::now()) << ")\n";
fst << "#\n";
auto wrec = [&fst, this]<size_t I>() {
fst << "\n";
for (size_t i = 0; i < std::get<I>(_keyValue).comment.size(); ++i) {
fst << "# " << std::get<I>(_keyValue).comment[i] << "\n";
}
fst << std::get<I>(_keyValue).key << " = ";
auto v = std::get<I>(_keyValue).value;
using v_t = std::remove_cvref_t<decltype(v)>;
if constexpr (std::is_arithmetic_v<v_t> || mcc::traits::mcc_char_range<v_t>) {
fst << std::format("{}", v);
} else if constexpr (mcc::traits::mcc_time_duration_c<v_t>) {
fst << std::format("{}", v.count());
} else if constexpr (mcc::mcc_angle_c<v_t>) {
fst << std::format("{}", mcc::MccAngle(static_cast<double>(v)).degrees());
} else if constexpr (std::same_as<v_t, mcc::MccDefaultPCMType>) {
if (v == mcc::MccDefaultPCMType::PCM_TYPE_GEOMETRY) {
fst << mcc::MccDefaultPCMTypeString<mcc::MccDefaultPCMType::PCM_TYPE_GEOMETRY>;
} else if (v == mcc::MccDefaultPCMType::PCM_TYPE_GEOMETRY_BSPLINE) {
fst << mcc::MccDefaultPCMTypeString<mcc::MccDefaultPCMType::PCM_TYPE_GEOMETRY_BSPLINE>;
} else if (v == mcc::MccDefaultPCMType::PCM_TYPE_BSPLINE) {
fst << mcc::MccDefaultPCMTypeString<mcc::MccDefaultPCMType::PCM_TYPE_BSPLINE>;
}
} else if constexpr (std::ranges::range<v_t> && std::formattable<std::ranges::range_value_t<v_t>, char>) {
size_t sz = std::ranges::size(v);
if (!sz) {
return;
}
--sz;
auto it = v.begin();
for (size_t j = 0; j < sz; ++j, ++it) {
fst << std::format("{}", *it) << base_t::VALUE_ARRAY_DELIM;
}
fst << std::format("{}", *it);
} else if constexpr (std::formattable<v_t, char>) {
fst << std::format("{}", v);
} else {
static_assert(false, "INVALID TYPE!");
}
fst << "\n";
};
[&wrec, this]<size_t... Is>(std::index_sequence<Is...>) {
(wrec.operator()<Is>(), ...);
}(std::make_index_sequence<std::tuple_size_v<decltype(Asibfm700MountConfigDefaults)>>());
fst.close(); fst.close();
return true; return true;
} };
}; };

View File

@ -23,28 +23,21 @@ int main()
std::error_code err; std::error_code err;
// std::ofstream fst("/tmp/cfg.cfg"); asibfm700::Asibfm700MountConfig acfg;
// fst << asibfm700::Asibfm700MountConfigString; bool ok = acfg.dumpDefaultsToFile("/tmp/cfg.cfg");
// fst.close();
bool ok = asibfm700::Asibfm700MountConfig::dumpDefaults("/tmp/cfg.cfg");
if (!ok) { if (!ok) {
std::cerr << "Cannot dump default configuration!\n"; std::cerr << "Cannot dump default configuration!\n";
exit(10); exit(10);
} }
asibfm700::Asibfm700MountConfig acfg;
auto ec = acfg.load("/tmp/cfg.cfg"); auto ec = acfg.load("/tmp/cfg.cfg");
std::cout << "EC (load) = " << ec.message() << "\n"; std::cout << "EC (load) = " << ec.message() << "\n";
std::cout << "refr w: " << acfg.refractWavelength() << "\n"; std::cout << "refr w: " << acfg.refractWavelength() << "\n";
// acfg.update("refractWavelength", 0.3);
acfg.setValue("refractWavelength", 0.3); acfg.setValue("refractWavelength", 0.3);
auto e = acfg.getValue<double>("refractWavelength"); auto e = acfg.getValue<double>("refractWavelength");
// auto e = acfg.value<double>("refractWavelength");
std::cout << "refr w: " << e.value_or(0.0) << "\n"; std::cout << "refr w: " << e.value_or(0.0) << "\n";
std::cout << "refr w: " << acfg.refractWavelength() << "\n"; std::cout << "refr w: " << acfg.refractWavelength() << "\n";