...
This commit is contained in:
@@ -58,10 +58,23 @@ concept mcc_error_c = std::default_initializable<T> && (std::convertible_to<T, b
|
|||||||
|
|
||||||
|
|
||||||
template <mcc_error_c ErrT, mcc_error_c DefErrT>
|
template <mcc_error_c ErrT, mcc_error_c DefErrT>
|
||||||
DefErrT mcc_deduced_err(ErrT const& err, DefErrT const& default_err)
|
auto mcc_deduced_err(ErrT const& err, DefErrT const& default_err)
|
||||||
|
// DefErrT mcc_deduced_err(ErrT const& err, DefErrT const& default_err)
|
||||||
{
|
{
|
||||||
if constexpr (std::same_as<ErrT, DefErrT>) {
|
if constexpr (std::same_as<ErrT, DefErrT>) {
|
||||||
return err;
|
return err;
|
||||||
|
} else if constexpr (std::is_error_code_enum_v<DefErrT>) {
|
||||||
|
if constexpr (std::same_as<ErrT, std::error_code>) {
|
||||||
|
return err;
|
||||||
|
} else {
|
||||||
|
return default_err;
|
||||||
|
}
|
||||||
|
} else if constexpr (std::is_error_condition_enum_v<DefErrT>) {
|
||||||
|
if constexpr (std::same_as<ErrT, std::error_condition>) {
|
||||||
|
return err;
|
||||||
|
} else {
|
||||||
|
return default_err;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return default_err;
|
return default_err;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -587,7 +587,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
error_t EO(mcc_angle_c auto* eo)
|
error_t EO(mcc_angle_c auto* eo) const
|
||||||
{
|
{
|
||||||
return cctEngine.equationOrigins(_epoch, eo);
|
return cctEngine.equationOrigins(_epoch, eo);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ public:
|
|||||||
{
|
{
|
||||||
auto sptr = std::make_shared<decltype(zone)>(std::move(zone));
|
auto sptr = std::make_shared<decltype(zone)>(std::move(zone));
|
||||||
|
|
||||||
_inZoneFunc.emplace_back([sptr](MccSkyPoint const& pt, bool* res) {
|
_inZoneFunc.emplace_back([sptr](MccSkyPoint const& pt, bool* res) -> error_t {
|
||||||
auto err = sptr->inPZone(pt, res);
|
auto err = sptr->inPZone(pt, res);
|
||||||
if (err) {
|
if (err) {
|
||||||
return mcc_deduced_err(err, MccPZoneContainerErrorCode::ERROR_INZONE_FUNC);
|
return mcc_deduced_err(err, MccPZoneContainerErrorCode::ERROR_INZONE_FUNC);
|
||||||
@@ -125,7 +125,7 @@ public:
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
_timeToZoneFunc.emplace_back([sptr](MccSkyPoint const& pt, duration_t* res) {
|
_timeToZoneFunc.emplace_back([sptr](MccSkyPoint const& pt, duration_t* res) -> error_t {
|
||||||
auto err = sptr->timeToPZone(pt, res);
|
auto err = sptr->timeToPZone(pt, res);
|
||||||
if (err) {
|
if (err) {
|
||||||
return mcc_deduced_err(err, MccPZoneContainerErrorCode::ERROR_TIMETO_FUNC);
|
return mcc_deduced_err(err, MccPZoneContainerErrorCode::ERROR_TIMETO_FUNC);
|
||||||
@@ -135,7 +135,7 @@ public:
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
_timeFromZoneFunc.emplace_back([sptr](MccSkyPoint const& pt, duration_t* res) {
|
_timeFromZoneFunc.emplace_back([sptr](MccSkyPoint const& pt, duration_t* res) -> error_t {
|
||||||
auto err = sptr->timeFromPZone(pt, res);
|
auto err = sptr->timeFromPZone(pt, res);
|
||||||
if (err) {
|
if (err) {
|
||||||
return mcc_deduced_err(err, MccPZoneContainerErrorCode::ERROR_TIMEFROM_FUNC);
|
return mcc_deduced_err(err, MccPZoneContainerErrorCode::ERROR_TIMEFROM_FUNC);
|
||||||
|
|||||||
@@ -383,7 +383,7 @@ struct MccSerializer<VT> : MccSerializerBase {
|
|||||||
VT const& value,
|
VT const& value,
|
||||||
ParamsT const& params = mcc_serialization_params_t{})
|
ParamsT const& params = mcc_serialization_params_t{})
|
||||||
{
|
{
|
||||||
auto serialize_cpair = [&]<typename T>(T& cp) {
|
auto serialize_cpair = [&]<typename T>(T& cp) -> error_t {
|
||||||
auto ccte_err = value.to(cp);
|
auto ccte_err = value.to(cp);
|
||||||
if (ccte_err) {
|
if (ccte_err) {
|
||||||
return mcc_deduced_err(ccte_err, MccSerializerErrorCode::ERROR_COORD_TRANSFORM);
|
return mcc_deduced_err(ccte_err, MccSerializerErrorCode::ERROR_COORD_TRANSFORM);
|
||||||
@@ -474,10 +474,12 @@ struct MccSerializer<VT> : MccSerializerBase {
|
|||||||
MccSkyAZZD azzd;
|
MccSkyAZZD azzd;
|
||||||
|
|
||||||
// quantities in hour representation
|
// quantities in hour representation
|
||||||
MccSerializerBase::angleFormatFromCoordPairType<VT::pairKind, MccSerializerBase::CO_LON>(pars_h);
|
MccSerializerBase::angleFormatFromCoordPairType<MccCoordPairKind::COORDS_KIND_RADEC_ICRS,
|
||||||
|
MccSerializerBase::CO_LON>(pars_h);
|
||||||
|
|
||||||
// quantities in degree representation
|
// quantities in degree representation
|
||||||
MccSerializerBase::angleFormatFromCoordPairType<VT::pairKind, MccSerializerBase::CO_LON>(pars_d);
|
MccSerializerBase::angleFormatFromCoordPairType<MccCoordPairKind::COORDS_KIND_RADEC_ICRS,
|
||||||
|
MccSerializerBase::CO_LON>(pars_d);
|
||||||
|
|
||||||
MccSerializer<MccAngle> ang_sr;
|
MccSerializer<MccAngle> ang_sr;
|
||||||
|
|
||||||
@@ -590,14 +592,14 @@ struct MccSerializer<VT> : MccSerializerBase {
|
|||||||
|
|
||||||
// PCM X and Y
|
// PCM X and Y
|
||||||
|
|
||||||
err = ang_sr(output, value.pcmCorrection.pcmX(), pars_d);
|
err = ang_sr(output, value.pcmCorrection.pcmX, pars_d);
|
||||||
if (err) {
|
if (err) {
|
||||||
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
|
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
|
||||||
}
|
}
|
||||||
|
|
||||||
MccSerializerBase::addElemDelimiter(output, pars_h);
|
MccSerializerBase::addElemDelimiter(output, pars_h);
|
||||||
|
|
||||||
err = ang_sr(output, value.pcmCorrection.pcmY(), pars_d);
|
err = ang_sr(output, value.pcmCorrection.pcmY, pars_d);
|
||||||
if (err) {
|
if (err) {
|
||||||
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
|
return mcc_deduced_err(err, MccSerializerErrorCode::ERROR_UNDERLYING_SERIALIZER);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
#include <random>
|
#include <random>
|
||||||
|
|
||||||
#include <mcc_pcm.h>
|
#include <mcc_pcm.h>
|
||||||
|
#include <mcc_serializer.h>
|
||||||
#include <mcc_telemetry.h>
|
#include <mcc_telemetry.h>
|
||||||
|
|
||||||
|
|
||||||
static std::random_device rd;
|
static std::random_device rd;
|
||||||
static std::mt19937 gen(rd());
|
static std::mt19937 gen(rd());
|
||||||
static std::uniform_int_distribution<long> tm_distrib(100, 700);
|
static std::uniform_int_distribution<long> tm_distrib(100, 700);
|
||||||
@@ -62,16 +62,31 @@ struct hw_t {
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct std::formatter<hw_t::hardware_movement_state_t, char>
|
struct std::formatter<hw_t::hardware_movement_state_t, char> : std::formatter<std::string_view> {
|
||||||
: std::formatter<std::underlying_type_t<hw_t::hardware_movement_state_t>, char> {
|
|
||||||
auto format(hw_t::hardware_movement_state_t e, auto& ctx) const
|
auto format(hw_t::hardware_movement_state_t e, auto& ctx) const
|
||||||
{
|
{
|
||||||
return formatter<std::underlying_type_t<hw_t::hardware_movement_state_t>>::format(
|
return formatter<std::string_view>::format(e == hw_t::hardware_movement_state_t::HW_MOVE_ERROR ? "ERROR"
|
||||||
std::underlying_type_t<hw_t::hardware_movement_state_t>(e), ctx);
|
: e == hw_t::hardware_movement_state_t::HW_MOVE_STOPPED ? "STOPPED"
|
||||||
|
: e == hw_t::hardware_movement_state_t::HW_MOVE_STOPPING ? "STOPPING"
|
||||||
|
: e == hw_t::hardware_movement_state_t::HW_MOVE_SLEWING ? "SLEWING"
|
||||||
|
: e == hw_t::hardware_movement_state_t::HW_MOVE_TRACKING ? "TRACKING"
|
||||||
|
: "UNKNOWN",
|
||||||
|
ctx);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// template <>
|
||||||
|
// struct std::formatter<hw_t::hardware_movement_state_t, char>
|
||||||
|
// : std::formatter<std::underlying_type_t<hw_t::hardware_movement_state_t>, char> {
|
||||||
|
// auto format(hw_t::hardware_movement_state_t e, auto& ctx) const
|
||||||
|
// {
|
||||||
|
// return formatter<std::underlying_type_t<hw_t::hardware_movement_state_t>>::format(
|
||||||
|
// std::underlying_type_t<hw_t::hardware_movement_state_t>(e), ctx);
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static_assert(mcc::mcc_hardware_c<hw_t>, "!!!!!");
|
static_assert(mcc::mcc_hardware_c<hw_t>, "!!!!!");
|
||||||
|
|
||||||
@@ -97,5 +112,18 @@ int main()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
mcc::impl::MccSerializer<typename t_t::telemetry_data_t> ser;
|
||||||
|
|
||||||
|
std::string str;
|
||||||
|
|
||||||
|
auto err = ser(str, tdata);
|
||||||
|
if (err) {
|
||||||
|
std::cout << "ERR: " << err.message() << "\n";
|
||||||
|
} else {
|
||||||
|
std::cout << "\n\n";
|
||||||
|
std::cout << str << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user