68 lines
1.9 KiB
C++
68 lines
1.9 KiB
C++
#pragma once
|
|
|
|
/* MOUNT CONTROL COMPONENTS LIBRARY */
|
|
|
|
|
|
|
|
/* COMMON DECLARATION FOR SLEW AND GUIDING MODELS GENERIC IMPLEMENTATIONS */
|
|
|
|
|
|
#include "mcc_mount_concepts.h"
|
|
|
|
namespace mcc
|
|
{
|
|
|
|
/* DEFAULT CLASS TO REPRESENT CELESTIAL POINT */
|
|
|
|
struct MccCelestialPoint {
|
|
typedef double coord_t;
|
|
|
|
MccCoordPairKind coordPairKind{MccCoordPairKind::COORDS_KIND_RADEC_ICRS};
|
|
coord_t x{0.0}, y{0.0};
|
|
};
|
|
|
|
static_assert(traits::mcc_celestial_point_c<MccCelestialPoint>, "MccCelestialPoint INVALID DECLARATION!");
|
|
|
|
|
|
|
|
/* CHECK FOR CURRENT MOUNT POSITION IN PROHIBITED ZONES */
|
|
|
|
/*
|
|
* WARNING: if an error occured during telemetry data request
|
|
* result 'in zone' flags cannot be interpretated correctly!
|
|
*/
|
|
template <traits::mcc_mount_telemetry_c TelemetryT,
|
|
traits::mcc_prohibited_zone_c<typename TelemetryT::mount_telemetry_data_t>... ZTs>
|
|
auto mccCheckInZonePZTuple(TelemetryT& telemetry,
|
|
std::tuple<ZTs...>& tuple_zones,
|
|
std::array<bool, sizeof...(ZTs)>& in_zone)
|
|
{
|
|
const auto p_telemetry = &telemetry;
|
|
const auto p_tuple_zones = &tuple_zones;
|
|
const auto p_in_zone = &in_zone;
|
|
|
|
return [p_telemetry, p_tuple_zones, p_in_zone]<size_t... Is>(std::index_sequence<Is...>) {
|
|
typename TelemetryT::error_t t_err;
|
|
(
|
|
[&t_err]() {
|
|
if constexpr (Is) {
|
|
if (t_err) {
|
|
(*p_in_zone)[Is] = false;
|
|
return;
|
|
}
|
|
}
|
|
|
|
typename TelemetryT::mount_telemetry_data_t tdata;
|
|
t_err = p_telemetry->data(tdata);
|
|
|
|
if (!t_err) {
|
|
(*p_in_zone)[Is] = std::get<Is>(p_tuple_zones).inZone(tdata);
|
|
}
|
|
}(),
|
|
...);
|
|
}(std::make_index_sequence<sizeof...(ZTs)>{});
|
|
}
|
|
|
|
|
|
} // namespace mcc
|