...
This commit is contained in:
@@ -20,13 +20,10 @@ enum class MccSimpleSlewingModelErrorCode : int {
|
||||
ERROR_PCM_COMP,
|
||||
ERROR_GET_TELEMETRY,
|
||||
ERROR_DIST_TELEMETRY,
|
||||
ERROR_DIFF_TELEMETRY,
|
||||
ERROR_PZONE_CONTAINER_COMP,
|
||||
ERROR_TARGET_IN_PZONE,
|
||||
ERROR_IN_PZONE,
|
||||
ERROR_NEAR_PZONE,
|
||||
ERROR_TIMEOUT,
|
||||
ERROR_UNEXPECTED_AXIS_RATES,
|
||||
ERROR_ALREADY_SLEW,
|
||||
ERROR_ALREADY_STOPPED,
|
||||
ERROR_STOPPED
|
||||
@@ -50,6 +47,64 @@ class is_error_code_enum<mcc::MccSimpleSlewingModelErrorCode> : public true_type
|
||||
namespace mcc
|
||||
{
|
||||
|
||||
// error category
|
||||
struct MccSimpleSlewingModelCategory : public std::error_category {
|
||||
MccSimpleSlewingModelCategory() : std::error_category() {}
|
||||
|
||||
const char* name() const noexcept
|
||||
{
|
||||
return "SIMPLE-TRACKING-MODEL";
|
||||
}
|
||||
|
||||
std::string message(int ec) const
|
||||
{
|
||||
MccSimpleSlewingModelErrorCode err = static_cast<MccSimpleSlewingModelErrorCode>(ec);
|
||||
|
||||
switch (err) {
|
||||
case MccSimpleSlewingModelErrorCode::ERROR_OK:
|
||||
return "OK";
|
||||
case MccSimpleSlewingModelErrorCode::ERROR_HW_GETSTATE:
|
||||
return "cannot get hardware state";
|
||||
case MccSimpleSlewingModelErrorCode::ERROR_HW_SETSTATE:
|
||||
return "cannot set hardware state";
|
||||
case MccSimpleSlewingModelErrorCode::ERROR_PCM_COMP:
|
||||
return "PCM computation error";
|
||||
case MccSimpleSlewingModelErrorCode::ERROR_GET_TELEMETRY:
|
||||
return "cannot get telemetry";
|
||||
case MccSimpleSlewingModelErrorCode::ERROR_DIST_TELEMETRY:
|
||||
return "cannot get target-to-mount-position distance";
|
||||
case MccSimpleSlewingModelErrorCode::ERROR_PZONE_CONTAINER_COMP:
|
||||
return "pzone container computation error";
|
||||
case MccSimpleSlewingModelErrorCode::ERROR_TARGET_IN_PZONE:
|
||||
return "target is in prohibited zone";
|
||||
case MccSimpleSlewingModelErrorCode::ERROR_NEAR_PZONE:
|
||||
return "near prohibited zone";
|
||||
case MccSimpleSlewingModelErrorCode::ERROR_TIMEOUT:
|
||||
return "a timeout occured while slewing";
|
||||
case MccSimpleSlewingModelErrorCode::ERROR_ALREADY_SLEW:
|
||||
return "already slewing";
|
||||
case MccSimpleSlewingModelErrorCode::ERROR_ALREADY_STOPPED:
|
||||
return "slewing is already stopped";
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
static const MccSimpleSlewingModelCategory& get()
|
||||
{
|
||||
static const MccSimpleSlewingModelCategory constInst;
|
||||
return constInst;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
inline std::error_code make_error_code(MccSimpleSlewingModelErrorCode ec)
|
||||
{
|
||||
return std::error_code(static_cast<int>(ec), MccSimpleSlewingModelCategory::get());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
The target celestial point must be set in telemetry->target
|
||||
*/
|
||||
@@ -77,7 +132,7 @@ public:
|
||||
t_err = controls->telemetryData(&tdata);
|
||||
|
||||
if (t_err) {
|
||||
return mcc_deduce_error<error_t>(t_err, MccSimpleSlewingModelErrorCode::ERROR_GET_TELEMETRY);
|
||||
return mcc_deduce_error_code(t_err, MccSimpleSlewingModelErrorCode::ERROR_GET_TELEMETRY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +140,7 @@ public:
|
||||
auto pz_err = controls->inPZone(tdata.target, &in_zone);
|
||||
if (pz_err) {
|
||||
*_stopSlewing = true;
|
||||
return mcc_deduce_error<error_t>(pz_err, MccSimpleSlewingModelErrorCode::ERROR_PZONE_CONTAINER_COMP);
|
||||
return mcc_deduce_error_code(pz_err, MccSimpleSlewingModelErrorCode::ERROR_PZONE_CONTAINER_COMP);
|
||||
}
|
||||
|
||||
if (in_zone) {
|
||||
@@ -117,7 +172,7 @@ public:
|
||||
auto hw_err = controls->hardwareGetState(&hw_state);
|
||||
if (hw_err) {
|
||||
*_stopSlewing = true;
|
||||
return mcc_deduce_error<error_t>(hw_err, MccSimpleSlewingModelErrorCode::ERROR_HW_GETSTATE);
|
||||
return mcc_deduce_error_code(hw_err, MccSimpleSlewingModelErrorCode::ERROR_HW_GETSTATE);
|
||||
}
|
||||
|
||||
hw_state.X = (double)tdata.target.X;
|
||||
@@ -141,7 +196,7 @@ public:
|
||||
hw_err = controls->hardwareSetState(hw_state);
|
||||
if (hw_err) {
|
||||
*_stopSlewing = true;
|
||||
return mcc_deduce_error<error_t>(hw_err, MccSimpleSlewingModelErrorCode::ERROR_HW_SETSTATE);
|
||||
return mcc_deduce_error_code(hw_err, MccSimpleSlewingModelErrorCode::ERROR_HW_SETSTATE);
|
||||
}
|
||||
|
||||
std::chrono::steady_clock::time_point start_slewing_tp, last_adjust_tp;
|
||||
@@ -164,7 +219,7 @@ public:
|
||||
|
||||
if (t_err) {
|
||||
*_stopSlewing = true;
|
||||
return mcc_deduce_error<error_t>(t_err, MccSimpleSlewingModelErrorCode::ERROR_GET_TELEMETRY);
|
||||
return mcc_deduce_error_code(t_err, MccSimpleSlewingModelErrorCode::ERROR_GET_TELEMETRY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,8 +241,7 @@ public:
|
||||
pz_err = controls->inPZone(cpt, &in_zone);
|
||||
if (pz_err) {
|
||||
*_stopSlewing = true;
|
||||
return mcc_deduce_error<error_t>(pz_err,
|
||||
MccSimpleSlewingModelErrorCode::ERROR_PZONE_CONTAINER_COMP);
|
||||
return mcc_deduce_error_code(pz_err, MccSimpleSlewingModelErrorCode::ERROR_PZONE_CONTAINER_COMP);
|
||||
}
|
||||
|
||||
if (in_zone) {
|
||||
@@ -208,13 +262,13 @@ public:
|
||||
hw_err = controls->hardwareGetState(&hw_state);
|
||||
if (hw_err) {
|
||||
*_stopSlewing = true;
|
||||
return mcc_deduce_error<error_t>(hw_err, MccSimpleSlewingModelErrorCode::ERROR_HW_GETSTATE);
|
||||
return mcc_deduce_error_code(hw_err, MccSimpleSlewingModelErrorCode::ERROR_HW_GETSTATE);
|
||||
}
|
||||
|
||||
t_err = controls->targetToMountDist(&dist);
|
||||
if (t_err) {
|
||||
*_stopSlewing = true;
|
||||
return mcc_deduce_error<error_t>(t_err, MccSimpleSlewingModelErrorCode::ERROR_DIST_TELEMETRY);
|
||||
return mcc_deduce_error_code(t_err, MccSimpleSlewingModelErrorCode::ERROR_DIST_TELEMETRY);
|
||||
}
|
||||
|
||||
if (*_stopSlewing) {
|
||||
@@ -239,8 +293,8 @@ public:
|
||||
hw_err = controls->hardwareSetState(hw_state);
|
||||
if (hw_err) {
|
||||
*_stopSlewing = true;
|
||||
return mcc_deduce_error<error_t>(hw_err,
|
||||
MccSimpleSlewingModelErrorCode::ERROR_HW_SETSTATE);
|
||||
return mcc_deduce_error_code(hw_err,
|
||||
MccSimpleSlewingModelErrorCode::ERROR_HW_SETSTATE);
|
||||
}
|
||||
}
|
||||
} else if constexpr (mccIsAltAzMount(CONTROLS_T::mountType)) {
|
||||
@@ -274,7 +328,7 @@ public:
|
||||
hw_err = controls->hardwareSetState(hw_state);
|
||||
if (hw_err) {
|
||||
*_stopSlewing = true;
|
||||
return mcc_deduce_error<error_t>(hw_err, MccSimpleSlewingModelErrorCode::ERROR_HW_SETSTATE);
|
||||
return mcc_deduce_error_code(hw_err, MccSimpleSlewingModelErrorCode::ERROR_HW_SETSTATE);
|
||||
}
|
||||
|
||||
last_adjust_tp = now;
|
||||
|
||||
Reference in New Issue
Block a user