various Asibfm700MountConfig class fixes
This commit is contained in:
parent
a1fa54c636
commit
d69ea51b0c
@ -8,7 +8,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
|
||||
|
||||
|
||||
find_package(ASIO QUIET)
|
||||
find_package(ASIO QUIET CONFIG)
|
||||
if (ASIO_FOUND)
|
||||
message(STATUS "ASIO library was found in the host system")
|
||||
else()
|
||||
|
||||
@ -365,44 +365,35 @@ public:
|
||||
return getValue<double>("refractWavelength").value_or(0.0);
|
||||
};
|
||||
|
||||
template <mcc::traits::mcc_view_or_output_char_range R>
|
||||
template <mcc::traits::mcc_output_char_range R>
|
||||
R leapSecondFilename() const
|
||||
{
|
||||
R r;
|
||||
if constexpr (std::ranges::view<R>) {
|
||||
std::string const& val = getValue<std::string>("leapSecondFilename").value_or("");
|
||||
r = R{val.begin(), val.end()};
|
||||
} else {
|
||||
std::string val = getValue<std::string>("leapSecondFilename").value_or("");
|
||||
std::ranges::copy(val, std::back_inserter(r));
|
||||
}
|
||||
|
||||
std::string val = getValue<std::string>("leapSecondFilename").value_or("");
|
||||
std::ranges::copy(val, std::back_inserter(r));
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
std::string_view leapSecondFilename() const
|
||||
std::string leapSecondFilename() const
|
||||
{
|
||||
return leapSecondFilename<std::string_view>();
|
||||
return leapSecondFilename<std::string>();
|
||||
};
|
||||
|
||||
template <mcc::traits::mcc_view_or_output_char_range R>
|
||||
template <mcc::traits::mcc_output_char_range R>
|
||||
R bulletinAFilename() const
|
||||
{
|
||||
R r;
|
||||
if constexpr (std::ranges::view<R>) {
|
||||
std::string const& val = getValue<std::string>("bulletinAFilename").value_or("");
|
||||
r = R{val.begin(), val.end()};
|
||||
} else {
|
||||
std::string val = getValue<std::string>("bulletinAFilename").value_or("");
|
||||
std::ranges::copy(val, std::back_inserter(r));
|
||||
}
|
||||
std::string val = getValue<std::string>("bulletinAFilename").value_or("");
|
||||
std::ranges::copy(val, std::back_inserter(r));
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
std::string_view bulletinAFilename() const
|
||||
std::string bulletinAFilename() const
|
||||
{
|
||||
return bulletinAFilename<std::string_view>();
|
||||
return bulletinAFilename<std::string>();
|
||||
};
|
||||
|
||||
|
||||
@ -654,6 +645,34 @@ public:
|
||||
fst.close();
|
||||
|
||||
ec = base_t::fromCharRange(buffer, deserializer);
|
||||
if (!ec) {
|
||||
// remove possible spaces in filenames
|
||||
|
||||
std::string val = getValue<std::string>("leapSecondFilename").value_or("");
|
||||
auto fname = mcc::utils::trimSpaces(val);
|
||||
setValue("leapSecondFilename", fname);
|
||||
|
||||
|
||||
val = getValue<std::string>("bulletinAFilename").value_or("");
|
||||
fname = mcc::utils::trimSpaces(val);
|
||||
setValue("bulletinAFilename", fname);
|
||||
|
||||
val = getValue<std::string>("MountDevPath").value_or({});
|
||||
fname = mcc::utils::trimSpaces(val);
|
||||
setValue("MountDevPath", fname);
|
||||
|
||||
val = getValue<std::string>("EncoderDevPath").value_or({});
|
||||
fname = mcc::utils::trimSpaces(val);
|
||||
setValue("EncoderDevPath", fname);
|
||||
|
||||
val = getValue<std::string>("EncoderXDevPath").value_or({});
|
||||
fname = mcc::utils::trimSpaces(val);
|
||||
setValue("EncoderXDevPath", fname);
|
||||
|
||||
val = getValue<std::string>("EncoderYDevPath").value_or({});
|
||||
fname = mcc::utils::trimSpaces(val);
|
||||
setValue("EncoderYDevPath", fname);
|
||||
}
|
||||
} catch (std::ios_base::failure const& ex) {
|
||||
ec = ex.code();
|
||||
} catch (std::length_error const& ex) {
|
||||
|
||||
@ -104,6 +104,12 @@ Asibfm700Mount::error_t Asibfm700Mount::initMount()
|
||||
}
|
||||
logInfo("Slewing and tracking parameters have been set successfully");
|
||||
|
||||
using secs_t = std::chrono::duration<double>;
|
||||
auto to_msecs = [](double secs) {
|
||||
auto s = secs_t{secs};
|
||||
return std::chrono::duration_cast<std::chrono::milliseconds>(s);
|
||||
};
|
||||
|
||||
auto hw_cfg = _mountConfig.servoControllerConfig();
|
||||
logInfo("");
|
||||
logInfo("Hardware initialization ...");
|
||||
@ -116,9 +122,9 @@ Asibfm700Mount::error_t Asibfm700Mount::initMount()
|
||||
|
||||
logInfo(" EncoderDevSpeed: {}", hw_cfg.devConfig.EncoderDevSpeed);
|
||||
logInfo(" SepEncoder: {}", hw_cfg.devConfig.SepEncoder);
|
||||
logInfo(" MountReqInterval: {}", hw_cfg.devConfig.MountReqInterval);
|
||||
logInfo(" EncoderReqInterval: {}", hw_cfg.devConfig.EncoderReqInterval);
|
||||
logInfo(" EncoderSpeedInterval: {}", hw_cfg.devConfig.EncoderSpeedInterval);
|
||||
logInfo(" MountReqInterval: {}", to_msecs(hw_cfg.devConfig.MountReqInterval));
|
||||
logInfo(" EncoderReqInterval: {}", to_msecs(hw_cfg.devConfig.EncoderReqInterval));
|
||||
logInfo(" EncoderSpeedInterval: {}", to_msecs(hw_cfg.devConfig.EncoderSpeedInterval));
|
||||
|
||||
logInfo(" XPIDC: [P: {}, I: {}, D: {}]", hw_cfg.devConfig.XPIDC.P, hw_cfg.devConfig.XPIDC.I,
|
||||
hw_cfg.devConfig.XPIDC.D);
|
||||
@ -153,8 +159,8 @@ Asibfm700Mount::error_t Asibfm700Mount::initMount()
|
||||
.elev = _mountConfig.siteElevation()};
|
||||
|
||||
|
||||
if (!_mountConfig.leapSecondFilename().empty()) { // load leap seconds file
|
||||
logInfo("Loading leap second file: {} ...", _mountConfig.leapSecondFilename());
|
||||
if (_mountConfig.leapSecondFilename().size()) { // load leap seconds file
|
||||
logInfo("Loading leap second file: '{}' ...", _mountConfig.leapSecondFilename());
|
||||
bool ok = ccte_state._leapSeconds.load(_mountConfig.leapSecondFilename());
|
||||
if (ok) {
|
||||
logInfo("Leap second file was loaded successfully (expire date: {})", ccte_state._leapSeconds.expireDate());
|
||||
@ -166,8 +172,8 @@ Asibfm700Mount::error_t Asibfm700Mount::initMount()
|
||||
logInfo("Using hardcoded leap seconds defauls (expire date: {})", ccte_state._leapSeconds.expireDate());
|
||||
}
|
||||
|
||||
if (!_mountConfig.bulletinAFilename().empty()) { // load IERS Bulletin A file
|
||||
logInfo("Loading IERS Bulletin A file: {} ...", _mountConfig.bulletinAFilename());
|
||||
if (_mountConfig.bulletinAFilename().size()) { // load IERS Bulletin A file
|
||||
logInfo("Loading IERS Bulletin A file: '{}' ...", _mountConfig.bulletinAFilename());
|
||||
bool ok = ccte_state._bulletinA.load(_mountConfig.bulletinAFilename());
|
||||
if (ok) {
|
||||
logInfo("IERS Bulletin A file was loaded successfully (date range: {} - {})",
|
||||
|
||||
@ -71,7 +71,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
return 0;
|
||||
} else {
|
||||
return 255;
|
||||
// just ignore
|
||||
}
|
||||
|
||||
auto logname = opt_result["log"].as<std::string>();
|
||||
|
||||
@ -482,21 +482,23 @@ public:
|
||||
el_t elem;
|
||||
size_t i = 0;
|
||||
|
||||
auto els = std::views::split(bytes, _rangeDelim);
|
||||
if (trimSpaces(bytes).size()) {
|
||||
auto els = std::views::split(bytes, _rangeDelim);
|
||||
|
||||
for (auto const& el : els) {
|
||||
ret = (*this)(std::string_view(el), elem);
|
||||
if (!ret) {
|
||||
if constexpr (traits::mcc_array_c<VT>) {
|
||||
if (i < std::ranges::size(r)) {
|
||||
r[i] = elem;
|
||||
for (auto const& el : els) {
|
||||
ret = (*this)(std::string_view(el), elem);
|
||||
if (!ret) {
|
||||
if constexpr (traits::mcc_array_c<VT>) {
|
||||
if (i < std::ranges::size(r)) {
|
||||
r[i] = elem;
|
||||
}
|
||||
++i;
|
||||
} else {
|
||||
std::back_inserter(r) = elem;
|
||||
}
|
||||
++i;
|
||||
} else {
|
||||
std::back_inserter(r) = elem;
|
||||
return std::make_error_code(std::errc::invalid_argument);
|
||||
}
|
||||
} else {
|
||||
return std::make_error_code(std::errc::invalid_argument);
|
||||
}
|
||||
}
|
||||
|
||||
@ -630,6 +632,9 @@ public:
|
||||
if constexpr (std::convertible_to<T, VT>) {
|
||||
val = value;
|
||||
return std::error_code();
|
||||
} else if constexpr (std::constructible_from<VT, T>) {
|
||||
val = VT(value);
|
||||
return std::error_code();
|
||||
} else {
|
||||
return std::make_error_code(std::errc::invalid_argument);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user