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")
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
|
||||||
|
|
||||||
|
|
||||||
find_package(ASIO QUIET)
|
find_package(ASIO QUIET CONFIG)
|
||||||
if (ASIO_FOUND)
|
if (ASIO_FOUND)
|
||||||
message(STATUS "ASIO library was found in the host system")
|
message(STATUS "ASIO library was found in the host system")
|
||||||
else()
|
else()
|
||||||
|
|||||||
@ -365,44 +365,35 @@ public:
|
|||||||
return getValue<double>("refractWavelength").value_or(0.0);
|
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 leapSecondFilename() const
|
||||||
{
|
{
|
||||||
R r;
|
R r;
|
||||||
if constexpr (std::ranges::view<R>) {
|
|
||||||
std::string const& val = getValue<std::string>("leapSecondFilename").value_or("");
|
std::string val = getValue<std::string>("leapSecondFilename").value_or("");
|
||||||
r = R{val.begin(), val.end()};
|
std::ranges::copy(val, std::back_inserter(r));
|
||||||
} else {
|
|
||||||
std::string val = getValue<std::string>("leapSecondFilename").value_or("");
|
|
||||||
std::ranges::copy(val, std::back_inserter(r));
|
|
||||||
}
|
|
||||||
|
|
||||||
return 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 bulletinAFilename() const
|
||||||
{
|
{
|
||||||
R r;
|
R r;
|
||||||
if constexpr (std::ranges::view<R>) {
|
std::string val = getValue<std::string>("bulletinAFilename").value_or("");
|
||||||
std::string const& val = getValue<std::string>("bulletinAFilename").value_or("");
|
std::ranges::copy(val, std::back_inserter(r));
|
||||||
r = R{val.begin(), val.end()};
|
|
||||||
} else {
|
|
||||||
std::string val = getValue<std::string>("bulletinAFilename").value_or("");
|
|
||||||
std::ranges::copy(val, std::back_inserter(r));
|
|
||||||
}
|
|
||||||
|
|
||||||
return 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();
|
fst.close();
|
||||||
|
|
||||||
ec = base_t::fromCharRange(buffer, deserializer);
|
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) {
|
} catch (std::ios_base::failure const& ex) {
|
||||||
ec = ex.code();
|
ec = ex.code();
|
||||||
} catch (std::length_error const& ex) {
|
} catch (std::length_error const& ex) {
|
||||||
|
|||||||
@ -104,6 +104,12 @@ Asibfm700Mount::error_t Asibfm700Mount::initMount()
|
|||||||
}
|
}
|
||||||
logInfo("Slewing and tracking parameters have been set successfully");
|
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();
|
auto hw_cfg = _mountConfig.servoControllerConfig();
|
||||||
logInfo("");
|
logInfo("");
|
||||||
logInfo("Hardware initialization ...");
|
logInfo("Hardware initialization ...");
|
||||||
@ -116,9 +122,9 @@ Asibfm700Mount::error_t Asibfm700Mount::initMount()
|
|||||||
|
|
||||||
logInfo(" EncoderDevSpeed: {}", hw_cfg.devConfig.EncoderDevSpeed);
|
logInfo(" EncoderDevSpeed: {}", hw_cfg.devConfig.EncoderDevSpeed);
|
||||||
logInfo(" SepEncoder: {}", hw_cfg.devConfig.SepEncoder);
|
logInfo(" SepEncoder: {}", hw_cfg.devConfig.SepEncoder);
|
||||||
logInfo(" MountReqInterval: {}", hw_cfg.devConfig.MountReqInterval);
|
logInfo(" MountReqInterval: {}", to_msecs(hw_cfg.devConfig.MountReqInterval));
|
||||||
logInfo(" EncoderReqInterval: {}", hw_cfg.devConfig.EncoderReqInterval);
|
logInfo(" EncoderReqInterval: {}", to_msecs(hw_cfg.devConfig.EncoderReqInterval));
|
||||||
logInfo(" EncoderSpeedInterval: {}", hw_cfg.devConfig.EncoderSpeedInterval);
|
logInfo(" EncoderSpeedInterval: {}", to_msecs(hw_cfg.devConfig.EncoderSpeedInterval));
|
||||||
|
|
||||||
logInfo(" XPIDC: [P: {}, I: {}, D: {}]", hw_cfg.devConfig.XPIDC.P, hw_cfg.devConfig.XPIDC.I,
|
logInfo(" XPIDC: [P: {}, I: {}, D: {}]", hw_cfg.devConfig.XPIDC.P, hw_cfg.devConfig.XPIDC.I,
|
||||||
hw_cfg.devConfig.XPIDC.D);
|
hw_cfg.devConfig.XPIDC.D);
|
||||||
@ -153,8 +159,8 @@ Asibfm700Mount::error_t Asibfm700Mount::initMount()
|
|||||||
.elev = _mountConfig.siteElevation()};
|
.elev = _mountConfig.siteElevation()};
|
||||||
|
|
||||||
|
|
||||||
if (!_mountConfig.leapSecondFilename().empty()) { // load leap seconds file
|
if (_mountConfig.leapSecondFilename().size()) { // load leap seconds file
|
||||||
logInfo("Loading leap second file: {} ...", _mountConfig.leapSecondFilename());
|
logInfo("Loading leap second file: '{}' ...", _mountConfig.leapSecondFilename());
|
||||||
bool ok = ccte_state._leapSeconds.load(_mountConfig.leapSecondFilename());
|
bool ok = ccte_state._leapSeconds.load(_mountConfig.leapSecondFilename());
|
||||||
if (ok) {
|
if (ok) {
|
||||||
logInfo("Leap second file was loaded successfully (expire date: {})", ccte_state._leapSeconds.expireDate());
|
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());
|
logInfo("Using hardcoded leap seconds defauls (expire date: {})", ccte_state._leapSeconds.expireDate());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_mountConfig.bulletinAFilename().empty()) { // load IERS Bulletin A file
|
if (_mountConfig.bulletinAFilename().size()) { // load IERS Bulletin A file
|
||||||
logInfo("Loading IERS Bulletin A file: {} ...", _mountConfig.bulletinAFilename());
|
logInfo("Loading IERS Bulletin A file: '{}' ...", _mountConfig.bulletinAFilename());
|
||||||
bool ok = ccte_state._bulletinA.load(_mountConfig.bulletinAFilename());
|
bool ok = ccte_state._bulletinA.load(_mountConfig.bulletinAFilename());
|
||||||
if (ok) {
|
if (ok) {
|
||||||
logInfo("IERS Bulletin A file was loaded successfully (date range: {} - {})",
|
logInfo("IERS Bulletin A file was loaded successfully (date range: {} - {})",
|
||||||
|
|||||||
@ -71,7 +71,7 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
return 255;
|
// just ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
auto logname = opt_result["log"].as<std::string>();
|
auto logname = opt_result["log"].as<std::string>();
|
||||||
|
|||||||
@ -482,21 +482,23 @@ public:
|
|||||||
el_t elem;
|
el_t elem;
|
||||||
size_t i = 0;
|
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) {
|
for (auto const& el : els) {
|
||||||
ret = (*this)(std::string_view(el), elem);
|
ret = (*this)(std::string_view(el), elem);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
if constexpr (traits::mcc_array_c<VT>) {
|
if constexpr (traits::mcc_array_c<VT>) {
|
||||||
if (i < std::ranges::size(r)) {
|
if (i < std::ranges::size(r)) {
|
||||||
r[i] = elem;
|
r[i] = elem;
|
||||||
|
}
|
||||||
|
++i;
|
||||||
|
} else {
|
||||||
|
std::back_inserter(r) = elem;
|
||||||
}
|
}
|
||||||
++i;
|
|
||||||
} else {
|
} 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>) {
|
if constexpr (std::convertible_to<T, VT>) {
|
||||||
val = value;
|
val = value;
|
||||||
return std::error_code();
|
return std::error_code();
|
||||||
|
} else if constexpr (std::constructible_from<VT, T>) {
|
||||||
|
val = VT(value);
|
||||||
|
return std::error_code();
|
||||||
} else {
|
} else {
|
||||||
return std::make_error_code(std::errc::invalid_argument);
|
return std::make_error_code(std::errc::invalid_argument);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user