Compare commits
No commits in common. "9066b3f091297fdd9dff5b49251e2ba236ccb8db" and "bf55a45cf9084d1125fce757282959b98c0e64ec" have entirely different histories.
9066b3f091
...
bf55a45cf9
@ -1086,6 +1086,34 @@ protected:
|
|||||||
err = vc.error();
|
err = vc.error();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// auto vc = input_msg.template paramValue<MccCelestialPoint>(0); // is it set operation?
|
||||||
|
// if (vc) { // coordinates are given - set
|
||||||
|
// operation
|
||||||
|
// auto m_err = mount_ptr->setPointingTarget(vc.value());
|
||||||
|
// if (m_err) {
|
||||||
|
// if (m_err) {
|
||||||
|
// err = mcc_deduce_error_code(m_err,
|
||||||
|
// MccGenericMountNetworkServerErrorCode::ERROR_MOUNT_SET_TARGET);
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// output_msg.construct(MCC_COMMPROTO_KEYWORD_SERVER_ACK_STR, input_msg.byteRepr());
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// auto vp = input_msg.template paramValue<MccCoordPairKind>(0);
|
||||||
|
// if (vp) { // coordinate pair kind is given
|
||||||
|
// cp.pair_kind = vp.value();
|
||||||
|
// err = coordsFromTelemetryData(*mount_ptr, true, cp);
|
||||||
|
// if (!err) {
|
||||||
|
// output_msg.construct(MCC_COMMPROTO_KEYWORD_SERVER_ACK_STR,
|
||||||
|
// MCC_COMMPROTO_KEYWORD_TARGET_STR,
|
||||||
|
// _coordFormat, _coordPrec, cp);
|
||||||
|
// }
|
||||||
|
// } else { // invalid command!!!
|
||||||
|
// err = vp.error();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
} else { // get operation
|
} else { // get operation
|
||||||
err = coordsFromTelemetryData(*mount_ptr, true, cp);
|
err = coordsFromTelemetryData(*mount_ptr, true, cp);
|
||||||
if (!err) {
|
if (!err) {
|
||||||
|
|||||||
@ -51,7 +51,10 @@ namespace mcc
|
|||||||
struct MccSimpleSlewingModelCategory : public std::error_category {
|
struct MccSimpleSlewingModelCategory : public std::error_category {
|
||||||
MccSimpleSlewingModelCategory() : std::error_category() {}
|
MccSimpleSlewingModelCategory() : std::error_category() {}
|
||||||
|
|
||||||
const char* name() const noexcept { return "SIMPLE-SLEWING-MODEL"; }
|
const char* name() const noexcept
|
||||||
|
{
|
||||||
|
return "SIMPLE-SLEWING-MODEL";
|
||||||
|
}
|
||||||
|
|
||||||
std::string message(int ec) const
|
std::string message(int ec) const
|
||||||
{
|
{
|
||||||
@ -119,9 +122,7 @@ public:
|
|||||||
|
|
||||||
template <mcc_all_controls_c CONTROLS_T, mcc_logger_c LoggerT = MccNullLogger>
|
template <mcc_all_controls_c CONTROLS_T, mcc_logger_c LoggerT = MccNullLogger>
|
||||||
MccSimpleSlewingModel(CONTROLS_T* controls, LoggerT logger)
|
MccSimpleSlewingModel(CONTROLS_T* controls, LoggerT logger)
|
||||||
: _stopSlewing(new std::atomic_bool()),
|
: _stopSlewing(new std::atomic_bool()), _currentParamsMutex(new std::mutex)
|
||||||
_currentParamsMutex(new std::mutex),
|
|
||||||
_lastError(MccSimpleSlewingModelErrorCode::ERROR_OK)
|
|
||||||
{
|
{
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << std::this_thread::get_id();
|
os << std::this_thread::get_id();
|
||||||
@ -164,9 +165,6 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
_slewingFunc = [controls, logger = std::move(logger), this](bool slew_and_stop) mutable -> error_t {
|
_slewingFunc = [controls, logger = std::move(logger), this](bool slew_and_stop) mutable -> error_t {
|
||||||
// reset error
|
|
||||||
_lastError = MccSimpleSlewingModelErrorCode::ERROR_OK;
|
|
||||||
|
|
||||||
// first, check target coordinates
|
// first, check target coordinates
|
||||||
typename CONTROLS_T::error_t t_err;
|
typename CONTROLS_T::error_t t_err;
|
||||||
MccTelemetryData tdata;
|
MccTelemetryData tdata;
|
||||||
@ -176,8 +174,7 @@ public:
|
|||||||
t_err = controls->telemetryData(&tdata);
|
t_err = controls->telemetryData(&tdata);
|
||||||
|
|
||||||
if (t_err) {
|
if (t_err) {
|
||||||
return _lastError =
|
return mcc_deduce_error_code(t_err, MccSimpleSlewingModelErrorCode::ERROR_GET_TELEMETRY);
|
||||||
mcc_deduce_error_code(t_err, MccSimpleSlewingModelErrorCode::ERROR_GET_TELEMETRY);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,8 +185,7 @@ public:
|
|||||||
auto pz_err = controls->inPZone(tdata.target, &in_zone, &in_zone_vec);
|
auto pz_err = controls->inPZone(tdata.target, &in_zone, &in_zone_vec);
|
||||||
if (pz_err) {
|
if (pz_err) {
|
||||||
*_stopSlewing = true;
|
*_stopSlewing = true;
|
||||||
return _lastError =
|
return mcc_deduce_error_code(pz_err, MccSimpleSlewingModelErrorCode::ERROR_PZONE_CONTAINER_COMP);
|
||||||
mcc_deduce_error_code(pz_err, MccSimpleSlewingModelErrorCode::ERROR_PZONE_CONTAINER_COMP);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_zone) {
|
if (in_zone) {
|
||||||
@ -219,7 +215,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (*_stopSlewing) {
|
if (*_stopSlewing) {
|
||||||
return _lastError = MccSimpleSlewingModelErrorCode::ERROR_STOPPED;
|
return MccSimpleSlewingModelErrorCode::ERROR_STOPPED;
|
||||||
}
|
}
|
||||||
|
|
||||||
double braking_accelX, braking_accelY;
|
double braking_accelX, braking_accelY;
|
||||||
@ -267,7 +263,7 @@ public:
|
|||||||
auto hw_err = controls->hardwareGetState(&hw_state);
|
auto hw_err = controls->hardwareGetState(&hw_state);
|
||||||
if (hw_err) {
|
if (hw_err) {
|
||||||
*_stopSlewing = true;
|
*_stopSlewing = true;
|
||||||
return _lastError = mcc_deduce_error_code(hw_err, MccSimpleSlewingModelErrorCode::ERROR_HW_GETSTATE);
|
return mcc_deduce_error_code(hw_err, MccSimpleSlewingModelErrorCode::ERROR_HW_GETSTATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -289,7 +285,7 @@ public:
|
|||||||
|
|
||||||
if (*_stopSlewing) {
|
if (*_stopSlewing) {
|
||||||
logger.logDebug("slewing was stopped!");
|
logger.logDebug("slewing was stopped!");
|
||||||
return _lastError = MccSimpleSlewingModelErrorCode::ERROR_STOPPED;
|
return MccSimpleSlewingModelErrorCode::ERROR_STOPPED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// start slewing
|
// start slewing
|
||||||
@ -314,7 +310,7 @@ public:
|
|||||||
hw_err = controls->hardwareSetState(hw_state);
|
hw_err = controls->hardwareSetState(hw_state);
|
||||||
if (hw_err) {
|
if (hw_err) {
|
||||||
*_stopSlewing = true;
|
*_stopSlewing = true;
|
||||||
return _lastError = mcc_deduce_error_code(hw_err, MccSimpleSlewingModelErrorCode::ERROR_HW_SETSTATE);
|
return mcc_deduce_error_code(hw_err, MccSimpleSlewingModelErrorCode::ERROR_HW_SETSTATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.logDebug(" the 'hardwareSetState' method performed successfully!");
|
logger.logDebug(" the 'hardwareSetState' method performed successfully!");
|
||||||
@ -353,17 +349,13 @@ public:
|
|||||||
t_err = controls->waitForTelemetryData(&tdata, _currentParams.telemetryTimeout);
|
t_err = controls->waitForTelemetryData(&tdata, _currentParams.telemetryTimeout);
|
||||||
|
|
||||||
if (t_err) {
|
if (t_err) {
|
||||||
_lastError = mcc_deduce_error_code(t_err, MccSimpleSlewingModelErrorCode::ERROR_GET_TELEMETRY);
|
*_stopSlewing = true;
|
||||||
break;
|
return mcc_deduce_error_code(t_err, MccSimpleSlewingModelErrorCode::ERROR_GET_TELEMETRY);
|
||||||
// *_stopSlewing = true;
|
|
||||||
// return mcc_deduce_error_code(t_err, MccSimpleSlewingModelErrorCode::ERROR_GET_TELEMETRY);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*_stopSlewing) {
|
if (*_stopSlewing) {
|
||||||
_lastError = MccSimpleSlewingModelErrorCode::ERROR_STOPPED;
|
return MccSimpleSlewingModelErrorCode::ERROR_STOPPED;
|
||||||
break;
|
|
||||||
// return MccSimpleSlewingModelErrorCode::ERROR_STOPPED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
distXY = mcc_compute_distance(tdata, min_time_to_pzone_in_secs, braking_accelX, braking_accelY);
|
distXY = mcc_compute_distance(tdata, min_time_to_pzone_in_secs, braking_accelX, braking_accelY);
|
||||||
@ -421,11 +413,8 @@ public:
|
|||||||
in_zone_vec.clear();
|
in_zone_vec.clear();
|
||||||
pz_err = controls->inPZone(cpt, &in_zone, &in_zone_vec);
|
pz_err = controls->inPZone(cpt, &in_zone, &in_zone_vec);
|
||||||
if (pz_err) {
|
if (pz_err) {
|
||||||
_lastError =
|
*_stopSlewing = true;
|
||||||
mcc_deduce_error_code(pz_err, MccSimpleSlewingModelErrorCode::ERROR_PZONE_CONTAINER_COMP);
|
return mcc_deduce_error_code(pz_err, MccSimpleSlewingModelErrorCode::ERROR_PZONE_CONTAINER_COMP);
|
||||||
break;
|
|
||||||
// *_stopSlewing = true;
|
|
||||||
// return mcc_deduce_error_code(pz_err, MccSimpleSlewingModelErrorCode::ERROR_PZONE_CONTAINER_COMP);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_zone) {
|
if (in_zone) {
|
||||||
@ -449,10 +438,8 @@ public:
|
|||||||
logger.logError(std::format(" hardware X, Y: {}, {}", mcc::MccAngle{tdata.X}.sexagesimal(),
|
logger.logError(std::format(" hardware X, Y: {}, {}", mcc::MccAngle{tdata.X}.sexagesimal(),
|
||||||
mcc::MccAngle{tdata.Y}.sexagesimal()));
|
mcc::MccAngle{tdata.Y}.sexagesimal()));
|
||||||
|
|
||||||
_lastError = MccSimpleSlewingModelErrorCode::ERROR_NEAR_PZONE;
|
*_stopSlewing = true;
|
||||||
break;
|
return MccSimpleSlewingModelErrorCode::ERROR_NEAR_PZONE;
|
||||||
// *_stopSlewing = true;
|
|
||||||
// return MccSimpleSlewingModelErrorCode::ERROR_NEAR_PZONE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -462,9 +449,7 @@ public:
|
|||||||
|
|
||||||
if ((std::chrono::steady_clock::now() - start_slewing_tp) > _currentParams.slewTimeout) {
|
if ((std::chrono::steady_clock::now() - start_slewing_tp) > _currentParams.slewTimeout) {
|
||||||
logger.logError("slewing process timeout!");
|
logger.logError("slewing process timeout!");
|
||||||
_lastError = MccSimpleSlewingModelErrorCode::ERROR_TIMEOUT;
|
return MccSimpleSlewingModelErrorCode::ERROR_TIMEOUT;
|
||||||
break;
|
|
||||||
// return MccSimpleSlewingModelErrorCode::ERROR_TIMEOUT;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -472,10 +457,8 @@ public:
|
|||||||
|
|
||||||
hw_err = controls->hardwareGetState(&hw_state);
|
hw_err = controls->hardwareGetState(&hw_state);
|
||||||
if (hw_err) {
|
if (hw_err) {
|
||||||
_lastError = mcc_deduce_error_code(hw_err, MccSimpleSlewingModelErrorCode::ERROR_HW_GETSTATE);
|
*_stopSlewing = true;
|
||||||
break;
|
return mcc_deduce_error_code(hw_err, MccSimpleSlewingModelErrorCode::ERROR_HW_GETSTATE);
|
||||||
// *_stopSlewing = true;
|
|
||||||
// return mcc_deduce_error_code(hw_err, MccSimpleSlewingModelErrorCode::ERROR_HW_GETSTATE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.logTrace(std::format("hw state was updated ({}, {})", MccAngle(hw_state.X).sexagesimal(true),
|
logger.logTrace(std::format("hw state was updated ({}, {})", MccAngle(hw_state.X).sexagesimal(true),
|
||||||
@ -496,10 +479,8 @@ public:
|
|||||||
|
|
||||||
t_err = controls->targetToMountDist(&dist);
|
t_err = controls->targetToMountDist(&dist);
|
||||||
if (t_err) {
|
if (t_err) {
|
||||||
_lastError = mcc_deduce_error_code(t_err, MccSimpleSlewingModelErrorCode::ERROR_DIST_TELEMETRY);
|
*_stopSlewing = true;
|
||||||
break;
|
return mcc_deduce_error_code(t_err, MccSimpleSlewingModelErrorCode::ERROR_DIST_TELEMETRY);
|
||||||
// *_stopSlewing = true;
|
|
||||||
// return mcc_deduce_error_code(t_err, MccSimpleSlewingModelErrorCode::ERROR_DIST_TELEMETRY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.logTrace(std::format(" target-to-mount distance: {}", mcc::MccAngleFancyString(dist)));
|
logger.logTrace(std::format(" target-to-mount distance: {}", mcc::MccAngleFancyString(dist)));
|
||||||
@ -514,9 +495,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
if (*_stopSlewing) {
|
if (*_stopSlewing) {
|
||||||
_lastError = MccSimpleSlewingModelErrorCode::ERROR_STOPPED;
|
return MccSimpleSlewingModelErrorCode::ERROR_STOPPED;
|
||||||
break;
|
|
||||||
// return MccSimpleSlewingModelErrorCode::ERROR_STOPPED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -539,10 +518,8 @@ public:
|
|||||||
|
|
||||||
hw_err = controls->hardwareSetState(hw_state);
|
hw_err = controls->hardwareSetState(hw_state);
|
||||||
if (hw_err) {
|
if (hw_err) {
|
||||||
_lastError = MccSimpleSlewingModelErrorCode::ERROR_HW_SETSTATE;
|
*_stopSlewing = true;
|
||||||
break;
|
return mcc_deduce_error_code(hw_err, MccSimpleSlewingModelErrorCode::ERROR_HW_SETSTATE);
|
||||||
// *_stopSlewing = true;
|
|
||||||
// return mcc_deduce_error_code(hw_err, MccSimpleSlewingModelErrorCode::ERROR_HW_SETSTATE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -555,10 +532,8 @@ public:
|
|||||||
|
|
||||||
hw_err = controls->hardwareGetState(&hw_state);
|
hw_err = controls->hardwareGetState(&hw_state);
|
||||||
if (hw_err) {
|
if (hw_err) {
|
||||||
_lastError = MccSimpleSlewingModelErrorCode::ERROR_HW_GETSTATE;
|
*_stopSlewing = true;
|
||||||
break;
|
return mcc_deduce_error_code(hw_err, MccSimpleSlewingModelErrorCode::ERROR_HW_GETSTATE);
|
||||||
// *_stopSlewing = true;
|
|
||||||
// return mcc_deduce_error_code(hw_err, MccSimpleSlewingModelErrorCode::ERROR_HW_GETSTATE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.logTrace(std::format("hw state was updated ({}, {})", MccAngle(hw_state.X).sexagesimal(true),
|
logger.logTrace(std::format("hw state was updated ({}, {})", MccAngle(hw_state.X).sexagesimal(true),
|
||||||
@ -566,9 +541,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (*_stopSlewing) {
|
if (*_stopSlewing) {
|
||||||
_lastError = MccSimpleSlewingModelErrorCode::ERROR_STOPPED;
|
return MccSimpleSlewingModelErrorCode::ERROR_STOPPED;
|
||||||
break;
|
|
||||||
// return MccSimpleSlewingModelErrorCode::ERROR_STOPPED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// sleep here
|
// sleep here
|
||||||
@ -586,8 +559,8 @@ public:
|
|||||||
t_err = controls->waitForTelemetryData(&tdata, _currentParams.telemetryTimeout);
|
t_err = controls->waitForTelemetryData(&tdata, _currentParams.telemetryTimeout);
|
||||||
|
|
||||||
if (t_err) {
|
if (t_err) {
|
||||||
return _lastError =
|
*_stopSlewing = true;
|
||||||
mcc_deduce_error_code(t_err, MccSimpleSlewingModelErrorCode::ERROR_GET_TELEMETRY);
|
return mcc_deduce_error_code(t_err, MccSimpleSlewingModelErrorCode::ERROR_GET_TELEMETRY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -607,7 +580,7 @@ public:
|
|||||||
mcc::MccAngle{tdata.ZD}.sexagesimal()));
|
mcc::MccAngle{tdata.ZD}.sexagesimal()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return _lastError = MccSimpleSlewingModelErrorCode::ERROR_OK;
|
return MccSimpleSlewingModelErrorCode::ERROR_OK;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -662,8 +635,6 @@ public:
|
|||||||
return _currentParams;
|
return _currentParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
error_t slewingLastError() const { return _lastError; }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::function<error_t(bool)> _slewingFunc{};
|
std::function<error_t(bool)> _slewingFunc{};
|
||||||
std::unique_ptr<std::atomic_bool> _stopSlewing;
|
std::unique_ptr<std::atomic_bool> _stopSlewing;
|
||||||
@ -671,8 +642,6 @@ protected:
|
|||||||
|
|
||||||
slewing_params_t _currentParams{};
|
slewing_params_t _currentParams{};
|
||||||
std::unique_ptr<std::mutex> _currentParamsMutex{};
|
std::unique_ptr<std::mutex> _currentParamsMutex{};
|
||||||
|
|
||||||
error_t _lastError;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -115,9 +115,7 @@ public:
|
|||||||
|
|
||||||
template <mcc_all_controls_c CONTROLS_T, mcc_logger_c LoggerT = MccNullLogger>
|
template <mcc_all_controls_c CONTROLS_T, mcc_logger_c LoggerT = MccNullLogger>
|
||||||
MccSimpleTrackingModel(CONTROLS_T* controls, LoggerT logger)
|
MccSimpleTrackingModel(CONTROLS_T* controls, LoggerT logger)
|
||||||
: _stopTracking(new std::atomic_bool()),
|
: _stopTracking(new std::atomic_bool()), _currentParamsMutex(new std::mutex())
|
||||||
_currentParamsMutex(new std::mutex()),
|
|
||||||
_lastError(MccSimpleTrackingModelErrorCode::ERROR_OK)
|
|
||||||
{
|
{
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << std::this_thread::get_id();
|
os << std::this_thread::get_id();
|
||||||
@ -467,10 +465,6 @@ public:
|
|||||||
return _currentParams;
|
return _currentParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
error_t trackinLastError() const
|
|
||||||
{
|
|
||||||
return _lastError;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::function<error_t()> _trackingFunc{};
|
std::function<error_t()> _trackingFunc{};
|
||||||
@ -478,8 +472,6 @@ protected:
|
|||||||
|
|
||||||
tracking_params_t _currentParams{};
|
tracking_params_t _currentParams{};
|
||||||
std::unique_ptr<std::mutex> _currentParamsMutex{};
|
std::unique_ptr<std::mutex> _currentParamsMutex{};
|
||||||
|
|
||||||
error_t _lastError;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace mcc
|
} // namespace mcc
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user