This commit is contained in:
Timur A. Fatkhullin
2025-10-01 06:26:50 +03:00
parent 0b7261a431
commit 3d769d79eb
8 changed files with 505 additions and 26 deletions

View File

@@ -92,9 +92,5 @@ if (WITH_TESTS)
target_include_directories(${CTTE_TEST_APP} PRIVATE ${ERFA_INCLUDE_DIR})
target_link_libraries(${CTTE_TEST_APP} ERFA_LIB bsplines)
set(CFG_TEST_APP cfg_test)
add_executable(${CFG_TEST_APP} tests/cfg_test.cpp)
target_link_libraries(${CFG_TEST_APP} PRIVATE mcc)
enable_testing()
endif()
endif()

View File

@@ -21,7 +21,7 @@ struct MccSimpleMovingModelParams {
static constexpr double sideralRate = 15.0410686_arcsecs; // in radians per second
// timeout to telemetry updating
std::chrono::seconds telemetryTimeout{3};
std::chrono::milliseconds telemetryTimeout{3000};
// minimal time to prohibited zone (at current speed in slewing mode). if it is lesser then exit with error
std::chrono::seconds minTimeToPZone{10};
@@ -60,7 +60,7 @@ struct MccSimpleMovingModelParams {
bool dualAxisTracking{true}; // mount must be of an equatorial type: false means guiding along only HA-axis
// time shift into future to compute target position in future (UT1-scale time duration)
std::chrono::duration<double> timeShiftToTargetPoint{10.0};
std::chrono::milliseconds timeShiftToTargetPoint{10000};
// ******* guiding mode *******

View File

@@ -1,54 +0,0 @@
#include <iostream>
#include "../../asibfm700/asibfm700_configfile.h"
template <typename VT>
struct rec_t {
std::string_view key;
VT value;
};
static std::string_view cfg_str = R"--(A = 11
B=3.3
# this is comment
C = WWWWWeeeWWWW
E = 10,20, 40, 32
)--";
int main()
{
auto desc = std::make_tuple(rec_t{"A", 1}, rec_t{"B", 2.2}, rec_t{"C", std::string("EEE")}, rec_t{"D", 3.3},
rec_t{"E", std::vector<int>{1, 2, 3}});
asibfm700::ConfigHolder ch(desc);
// auto err = ch.parse(cfg_str, [](auto s, auto &v) {
// if constexpr (std::is_arithmetic_v<std::decay_t<decltype(v)>>) {
// v = 77;
// } else {
// v = std::string{s.begin(), s.end()};
// }
// return true;
// });
auto err = ch.parse(cfg_str);
auto v = ch.value<float>("A");
std::cout << v.value() << "\n";
// auto v2 = ch.value<std::string>("D");
auto v2 = ch.value<std::string>("C");
std::cout << v2.value_or("<no value>") << "\n";
auto v3 = ch.value<std::vector<int>>("E");
std::cout << "[";
for (auto& el : v3.value_or({0, 0, 0})) {
std::cout << el << " ";
}
std::cout << "]\n";
return 0;
}