...
This commit is contained in:
@@ -13,6 +13,8 @@
|
||||
|
||||
// #include "mcc_traits.h"
|
||||
#include "mcc_angle.h"
|
||||
#include "mcc_finite_state_machine.h"
|
||||
|
||||
|
||||
namespace mcc
|
||||
{
|
||||
@@ -73,6 +75,27 @@ static consteval bool mccIsAltAzMount(const MccMountType type)
|
||||
// };
|
||||
|
||||
|
||||
|
||||
/* GENERIC LOGGER CLASS CONCEPT */
|
||||
|
||||
template <typename T>
|
||||
concept mcc_logger_c = requires(T t, const T t_const) {
|
||||
{ t.logError(std::declval<const std::string&>()) };
|
||||
{ t.logDebug(std::declval<const std::string&>()) };
|
||||
{ t.logWarn(std::declval<const std::string&>()) };
|
||||
{ t.logInfo(std::declval<const std::string&>()) };
|
||||
};
|
||||
|
||||
|
||||
struct MccNullLogger {
|
||||
void logError(const std::string&) {}
|
||||
void logDebug(const std::string&) {}
|
||||
void logWarn(const std::string&) {}
|
||||
void logInfo(const std::string&) {}
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* FLOATING-POINT LIKE CLASS CONCEPT */
|
||||
|
||||
template <typename T>
|
||||
@@ -450,6 +473,17 @@ struct mcc_telemetry_interface_t {
|
||||
return std::forward<SelfT>(self).telemetryData(std::move(pt));
|
||||
}
|
||||
|
||||
|
||||
// compute difference in coordinates:
|
||||
// dx = targetX - mountX
|
||||
// dy = targetY - mountY
|
||||
// where X and Y is in according to 'pair_kind' input parameter
|
||||
template <std::derived_from<mcc_telemetry_interface_t> SelfT>
|
||||
RetT targetToMountDiff(this SelfT&& self, MccCoordPairKind pair_kind, mcc_angle_c auto* dx, mcc_angle_c auto* dy)
|
||||
{
|
||||
std::forward<SelfT>(self).targetToMountDiff(pair_kind, dx, dy);
|
||||
}
|
||||
|
||||
protected:
|
||||
mcc_telemetry_interface_t() = default;
|
||||
};
|
||||
@@ -515,8 +549,7 @@ concept mcc_hardware_c = requires(T t, const T t_const) {
|
||||
|
||||
// set positions (angles) of mount axes with given speeds
|
||||
// NOTE: exact interpretation (or even ignoring) of the given moving speeds is subject of a hardware-class
|
||||
// implementation.
|
||||
// e.g. it can be maximal speeds at slewing ramp
|
||||
// implementation, e.g. it can be maximal speeds at slewing ramp
|
||||
{ t.setPos(std::declval<typename T::axes_pos_t>()) } -> std::same_as<typename T::error_t>;
|
||||
|
||||
// get current positions and speeds (angles) of mount axes
|
||||
@@ -651,22 +684,119 @@ template <typename T>
|
||||
concept mcc_pzone_container_c = std::derived_from<T, mcc_pzone_container_interface_t<typename T::error_t>>;
|
||||
|
||||
|
||||
template <mcc_error_c RetT>
|
||||
template <typename T>
|
||||
concept mcc_slewing_model_c = requires(T t, const T t_const) {
|
||||
requires mcc_error_c<typename T::error_t>;
|
||||
|
||||
// a class of slewing process parameters
|
||||
requires requires(typename T::slewing_params_t pars) {
|
||||
// slew mount to target and stop
|
||||
std::convertible_to<decltype(pars.slewAndStop), bool>;
|
||||
};
|
||||
|
||||
{ t_const.name() } -> std::formattable<char>;
|
||||
|
||||
{ t.slewToTarget() } -> std::same_as<typename T::error_t>;
|
||||
{ t.stopSlewing() } -> std::same_as<typename T::error_t>;
|
||||
};
|
||||
|
||||
|
||||
template <typename T>
|
||||
concept mcc_tracking_model_c = requires(T t, const T t_const) {
|
||||
requires mcc_error_c<typename T::error_t>;
|
||||
|
||||
// a class of tracking process parameters
|
||||
requires requires(typename T::tracking_params_t pars) {
|
||||
requires mcc_angle_c<decltype(pars.trackSpeedX)>;
|
||||
requires mcc_angle_c<decltype(pars.trackSpeedY)>;
|
||||
};
|
||||
|
||||
{ t_const.name() } -> std::formattable<char>;
|
||||
|
||||
{ t.trackTarget() } -> std::same_as<typename T::error_t>;
|
||||
{ t.stopTracking() } -> std::same_as<typename T::error_t>;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
concept mcc_guiding_model_c = requires(T t, const T t_const) {
|
||||
requires mcc_error_c<typename T::error_t>;
|
||||
|
||||
// a class of guiding process parameters
|
||||
requires requires(typename T::guiding_params_t pars) {
|
||||
// guide along both mount axis
|
||||
std::convertible_to<decltype(pars.dualAxisGuiding), bool>;
|
||||
};
|
||||
|
||||
{ t_const.name() } -> std::formattable<char>;
|
||||
|
||||
{ t.startGuidingTarget() } -> std::same_as<typename T::error_t>;
|
||||
{ t.stopGuidingTarget() } -> std::same_as<typename T::error_t>;
|
||||
};
|
||||
|
||||
|
||||
/* GENERIC MOUNT CLASS CONCEPT */
|
||||
|
||||
|
||||
|
||||
template <mcc_error_c RetT, typename StopReasonT>
|
||||
struct mcc_generic_mount_interface_t {
|
||||
virtual ~mcc_generic_mount_interface_t() = default;
|
||||
|
||||
RetT slew(mcc_celestial_point_c auto pt) {}
|
||||
// slew mount to target (target coordinates were defined in telemetry data)
|
||||
template <std::derived_from<mcc_generic_mount_interface_t> SelfT>
|
||||
RetT slewToTarget(this SelfT&& self, mcc_slewing_model_c auto model)
|
||||
{
|
||||
return std::forward<SelfT>(self).slewToTarget(std::move(model));
|
||||
}
|
||||
|
||||
// track target, i.e., the mount moves with celestial speed
|
||||
template <std::derived_from<mcc_generic_mount_interface_t> SelfT>
|
||||
RetT trackTarget(this SelfT&& self, mcc_tracking_model_c auto model)
|
||||
{
|
||||
return std::forward<SelfT>(self).trackTarget(std::move(model));
|
||||
}
|
||||
|
||||
template <std::derived_from<mcc_generic_mount_interface_t> SelfT>
|
||||
RetT startGuidingTarget(this SelfT&& self, mcc_guiding_model_c auto model)
|
||||
{
|
||||
return std::forward<SelfT>(self).startGuidingTarget(std::move(model));
|
||||
}
|
||||
|
||||
template <std::derived_from<mcc_generic_mount_interface_t> SelfT>
|
||||
RetT stopGuidingTarget(this SelfT&& self)
|
||||
{
|
||||
return std::forward<SelfT>(self).stopGuidingTarget();
|
||||
}
|
||||
|
||||
template <std::derived_from<mcc_generic_mount_interface_t> SelfT>
|
||||
RetT stopMount(this SelfT&& self, StopReasonT reason)
|
||||
{
|
||||
return std::forward<SelfT>(self).stopMount(std::move(reason));
|
||||
}
|
||||
|
||||
protected:
|
||||
mcc_generic_mount_interface_t() = default;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
concept mcc_generic_mount_c = mcc_telemetry_c<T> && requires(T t) {
|
||||
requires mcc_error_c<typename T::error_t>;
|
||||
|
||||
{ t.slewToTarget() } -> std::same_as<typename T::error_t>;
|
||||
{ t.guidingTarget() } -> std::same_as<typename T::error_t>;
|
||||
};
|
||||
template <typename T>
|
||||
concept mcc_generic_mount_c =
|
||||
std::derived_from<T, mcc_generic_mount_interface_t<typename T::error_t, typename T::stop_reason_t>> &&
|
||||
mcc_telemetry_c<T> && mcc_pzone_container_c<T>;
|
||||
|
||||
|
||||
// with logging methods
|
||||
template <typename T>
|
||||
concept mcc_generic_log_mount_c = mcc_generic_mount_c<T> && mcc_logger_c<T>;
|
||||
|
||||
|
||||
// Finite-state-machine
|
||||
template <typename T>
|
||||
concept mcc_generic_fsm_mount_c = mcc_generic_mount_c<T> && std::derived_from<T, fsm::MccFiniteStateMachine>;
|
||||
|
||||
template <typename T>
|
||||
concept mcc_generic_fsm_log_mount_c =
|
||||
mcc_generic_mount_c<T> && mcc_logger_c<T> && std::derived_from<T, fsm::MccFiniteStateMachine>;
|
||||
|
||||
|
||||
} // namespace mcc
|
||||
|
||||
Reference in New Issue
Block a user