...
This commit is contained in:
parent
962504ed98
commit
5fe2788cd7
@ -249,6 +249,31 @@ public:
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
bool update(std::string_view key, const T& value)
|
||||||
|
{
|
||||||
|
auto it = _configDB.find(key);
|
||||||
|
if (it == _configDB.end()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ok;
|
||||||
|
std::visit(
|
||||||
|
[&value, &ok](auto& val) {
|
||||||
|
using v_t = std::decay_t<decltype(val)>;
|
||||||
|
|
||||||
|
if constexpr (std::convertible_to<T, v_t>) {
|
||||||
|
val = static_cast<v_t>(value);
|
||||||
|
ok = true;
|
||||||
|
} else {
|
||||||
|
ok = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
it->second);
|
||||||
|
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::unordered_map<std::string_view, variant_from_tuple_t<deduce_val_types_t<DESCR_T>>> _configDB;
|
std::unordered_map<std::string_view, variant_from_tuple_t<deduce_val_types_t<DESCR_T>>> _configDB;
|
||||||
|
|
||||||
@ -453,11 +478,12 @@ class Asibfm700MountConfig : protected ConfigHolder<decltype(Asibfm700MountConfi
|
|||||||
using base_t = ConfigHolder<decltype(Asibfm700MountConfigDefaults)>;
|
using base_t = ConfigHolder<decltype(Asibfm700MountConfigDefaults)>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
using base_t::update;
|
||||||
using base_t::value;
|
using base_t::value;
|
||||||
|
|
||||||
Asibfm700MountConfig() : base_t(Asibfm700MountConfigDefaults)
|
Asibfm700MountConfig() : base_t(Asibfm700MountConfigDefaults)
|
||||||
{
|
{
|
||||||
update();
|
updateAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
~Asibfm700MountConfig() = default;
|
~Asibfm700MountConfig() = default;
|
||||||
@ -481,7 +507,7 @@ public:
|
|||||||
|
|
||||||
ec = base_t::parse(buffer, deserializer);
|
ec = base_t::parse(buffer, deserializer);
|
||||||
if (!ec) {
|
if (!ec) {
|
||||||
update();
|
updateAll();
|
||||||
}
|
}
|
||||||
} catch (std::ios_base::failure const& ex) {
|
} catch (std::ios_base::failure const& ex) {
|
||||||
ec = ex.code();
|
ec = ex.code();
|
||||||
@ -497,6 +523,17 @@ public:
|
|||||||
return ec;
|
return ec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
bool update(std::string_view key, const T& value)
|
||||||
|
{
|
||||||
|
bool ok = base_t::update(key, value);
|
||||||
|
if (ok) {
|
||||||
|
updateAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
std::chrono::milliseconds hardwarePollingPeriod{};
|
std::chrono::milliseconds hardwarePollingPeriod{};
|
||||||
|
|
||||||
mcc::MccAngle siteLatitude{};
|
mcc::MccAngle siteLatitude{};
|
||||||
@ -517,7 +554,7 @@ public:
|
|||||||
Asibfm700PCM::pcm_data_t pcmData{};
|
Asibfm700PCM::pcm_data_t pcmData{};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void update()
|
void updateAll()
|
||||||
{
|
{
|
||||||
hardwarePollingPeriod = std::get<decltype(hardwarePollingPeriod)>(this->_configDB["hardwarePollingPeriod"]);
|
hardwarePollingPeriod = std::get<decltype(hardwarePollingPeriod)>(this->_configDB["hardwarePollingPeriod"]);
|
||||||
|
|
||||||
|
|||||||
@ -62,6 +62,11 @@ int main()
|
|||||||
|
|
||||||
std::cout << "refr w: " << acfg.refractWavelength << "\n";
|
std::cout << "refr w: " << acfg.refractWavelength << "\n";
|
||||||
|
|
||||||
|
acfg.update("refractWavelength", 0.3);
|
||||||
|
|
||||||
|
auto e = acfg.value<double>("refractWavelength");
|
||||||
|
std::cout << "refr w: " << e.value_or(0.0) << "\n";
|
||||||
|
std::cout << "refr w: " << acfg.refractWavelength << "\n";
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,13 +6,21 @@
|
|||||||
/* GENERIC MOUNT REFERENCE IMPLEMENTATION */
|
/* GENERIC MOUNT REFERENCE IMPLEMENTATION */
|
||||||
|
|
||||||
|
|
||||||
|
#include "mcc_defaults.h"
|
||||||
#include "mcc_generics.h"
|
#include "mcc_generics.h"
|
||||||
|
|
||||||
|
|
||||||
namespace mcc
|
namespace mcc
|
||||||
{
|
{
|
||||||
|
|
||||||
enum class MccGenericMountErrorCode : int { ERROR_OK, ERROR_HW_INIT, ERROR_HW_STOP, ERROR_HW_GETSTATE };
|
enum class MccGenericMountErrorCode : int {
|
||||||
|
ERROR_OK,
|
||||||
|
ERROR_HW_INIT,
|
||||||
|
ERROR_HW_STOP,
|
||||||
|
ERROR_HW_GETSTATE,
|
||||||
|
ERROR_SET_TARGET,
|
||||||
|
ERROR_MOUNT_SLEW
|
||||||
|
};
|
||||||
|
|
||||||
enum class MccGenericFsmMountErrorCode : int { ERROR_OK, ERROR_INVALID_OPERATION, ERROR_UNKNOWN_EVENT };
|
enum class MccGenericFsmMountErrorCode : int { ERROR_OK, ERROR_INVALID_OPERATION, ERROR_UNKNOWN_EVENT };
|
||||||
|
|
||||||
@ -197,6 +205,43 @@ public:
|
|||||||
|
|
||||||
return MccGenericMountErrorCode::ERROR_OK;
|
return MccGenericMountErrorCode::ERROR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// re-implements TelemetryT::setPointingTarget to hold target coordinates
|
||||||
|
// in some intermediate buffer
|
||||||
|
error_t setPointingTarget(mcc_celestial_point_c auto pt)
|
||||||
|
{
|
||||||
|
mcc_copy_celestial_point(std::move(pt), &_inputTargetCoordiniates);
|
||||||
|
|
||||||
|
std::string xstr;
|
||||||
|
if (_inputTargetCoordiniates.pair_kind == MccCoordPairKind::COORDS_KIND_RADEC_ICRS ||
|
||||||
|
_inputTargetCoordiniates.pair_kind == MccCoordPairKind::COORDS_KIND_RADEC_APP ||
|
||||||
|
_inputTargetCoordiniates.pair_kind == MccCoordPairKind::COORDS_KIND_HADEC_APP) {
|
||||||
|
xstr = MccAngle(_inputTargetCoordiniates.X).sexagesimal(true);
|
||||||
|
} else {
|
||||||
|
MccAngle(_inputTargetCoordiniates.X).sexagesimal();
|
||||||
|
}
|
||||||
|
|
||||||
|
logInfo(std::format("Set input target coordinates to: {} {} {}", xstr,
|
||||||
|
MccAngle(_inputTargetCoordiniates.Y).sexagesimal(),
|
||||||
|
MccCoordPairKindStr<_inputTargetCoordiniates.pair_kind>));
|
||||||
|
|
||||||
|
return MccGenericMountErrorCode::ERROR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
// re-implements SlewModelT::slewToTarget to fetch input target coordinates from intermediate buffer
|
||||||
|
error_t slewToTarget(bool slew_and_stop = false)
|
||||||
|
{
|
||||||
|
auto err = TelemetryT::setPointingTarget(_inputTargetCoordiniates);
|
||||||
|
if (err) {
|
||||||
|
return mcc_deduce_error_code(err, MccGenericMountErrorCode::ERROR_SET_TARGET);
|
||||||
|
}
|
||||||
|
|
||||||
|
return mcc_deduce_error_code(SlewModelT::slewToTarget(slew_and_stop),
|
||||||
|
MccGenericMountErrorCode::ERROR_MOUNT_SLEW);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
MccCelestialPoint _inputTargetCoordiniates;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -663,7 +663,7 @@ struct mcc_telemetry_interface_t {
|
|||||||
template <std::derived_from<mcc_telemetry_interface_t> SelfT>
|
template <std::derived_from<mcc_telemetry_interface_t> SelfT>
|
||||||
RetT setPointingTarget(this SelfT&& self, mcc_celestial_point_c auto pt)
|
RetT setPointingTarget(this SelfT&& self, mcc_celestial_point_c auto pt)
|
||||||
{
|
{
|
||||||
return std::forward<SelfT>(self).telemetryData(std::move(pt));
|
return std::forward<SelfT>(self).setPointingTarget(std::move(pt));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -929,7 +929,7 @@ concept mcc_generic_mount_c = mcc_telemetry_c<T> && mcc_pzone_container_c<T> &&
|
|||||||
// requires mcc_error_c<typename T::error_t>;
|
// requires mcc_error_c<typename T::error_t>;
|
||||||
|
|
||||||
// slew mount to target (it is assumed that the target coordinates are determined in the telemetry data)
|
// slew mount to target (it is assumed that the target coordinates are determined in the telemetry data)
|
||||||
{ t.slewToTarget() };
|
{ t.slewToTarget(std::declval<bool>()) };
|
||||||
// { t.slewToTarget() } -> std::same_as<typename T::error_t>;
|
// { t.slewToTarget() } -> std::same_as<typename T::error_t>;
|
||||||
|
|
||||||
// track target, i.e., the mount moves with celestial speed
|
// track target, i.e., the mount moves with celestial speed
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user