...
This commit is contained in:
@@ -24,6 +24,8 @@ enum class MccSimpleSlewModelErrorCode : int {
|
||||
ERROR_PEC_COMP,
|
||||
ERROR_HARDWARE_SETPOS,
|
||||
ERROR_HARDWARE_GETPOS,
|
||||
ERROR_SLEW_STOPPED,
|
||||
ERROR_SLEW_ADJ_MAXITER,
|
||||
ERROR_SLEW_TIMEOUT
|
||||
};
|
||||
|
||||
@@ -50,10 +52,7 @@ namespace mcc
|
||||
struct MccSimpleSlewModelCategory : public std::error_category {
|
||||
MccSimpleSlewModelCategory() : std::error_category() {}
|
||||
|
||||
const char* name() const noexcept
|
||||
{
|
||||
return "ADC_GENERIC_DEVICE";
|
||||
}
|
||||
const char* name() const noexcept { return "ADC_GENERIC_DEVICE"; }
|
||||
|
||||
std::string message(int ec) const
|
||||
{
|
||||
@@ -76,6 +75,12 @@ struct MccSimpleSlewModelCategory : public std::error_category {
|
||||
return "slew model: cannot set position";
|
||||
case MccSimpleSlewModelErrorCode::ERROR_HARDWARE_GETPOS:
|
||||
return "slew model: cannot get position";
|
||||
case MccSimpleSlewModelErrorCode::ERROR_SLEW_STOPPED:
|
||||
return "slew model: stopped";
|
||||
case MccSimpleSlewModelErrorCode::ERROR_SLEW_ADJ_MAXITER:
|
||||
return "slew model: max number of adjusting iteration was exceeded";
|
||||
case MccSimpleSlewModelErrorCode::ERROR_SLEW_TIMEOUT:
|
||||
return "slew model: timeout occured while slewing";
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
@@ -167,12 +172,20 @@ public:
|
||||
|
||||
error_t slew(slew_point_t pars)
|
||||
{
|
||||
_stopRequested = false;
|
||||
error_t res_err = _slewFunc(std::move(pars));
|
||||
|
||||
return res_err;
|
||||
}
|
||||
|
||||
error_t stop()
|
||||
{
|
||||
_stopRequested = true;
|
||||
return MccSimpleSlewModelErrorCode::ERROR_OK;
|
||||
}
|
||||
|
||||
protected:
|
||||
std::atomic_bool _stopRequested{false};
|
||||
std::function<error_t(const slew_point_t&)> _slewFunc{};
|
||||
|
||||
void init(auto& mount_controls)
|
||||
@@ -288,6 +301,10 @@ protected:
|
||||
};
|
||||
|
||||
auto cycle_func = [&](auto t_data) mutable {
|
||||
if (_stopRequested) {
|
||||
res_err = MccSimpleSlewModelErrorCode::ERROR_SLEW_STOPPED;
|
||||
}
|
||||
|
||||
// check for prohibited zones
|
||||
auto t_err = mccCheckInZonePZTuple(*telemetry, p_mount_controls->prohibitedZones, in_zone_flag);
|
||||
|
||||
@@ -308,6 +325,10 @@ protected:
|
||||
// t_data was updated in caller!!!
|
||||
coord_diff2 = coord_diff_func(t_data);
|
||||
|
||||
if (_stopRequested) {
|
||||
res_err = MccSimpleSlewModelErrorCode::ERROR_SLEW_STOPPED;
|
||||
}
|
||||
|
||||
if (coord_diff2 < adj_rad2) { // adjusting mode
|
||||
in_adj_mode = true;
|
||||
hw_err = hardware->setPos(adj_ax_pos);
|
||||
@@ -357,6 +378,9 @@ protected:
|
||||
|
||||
|
||||
while (true) {
|
||||
t_err = telemetry.data(t_data);
|
||||
cycle_func(t_data);
|
||||
|
||||
if ((std::chrono::steady_clock::now() - start_poll_tm) > slew_point.slewTimeout) {
|
||||
logError("Waiting time for completion of slewing expired!");
|
||||
return MccSimpleSlewModelErrorCode::ERROR_SLEW_TIMEOUT;
|
||||
|
||||
Reference in New Issue
Block a user