This commit is contained in:
Timur A. Fatkhullin 2025-07-28 17:32:41 +03:00
parent a96682bc12
commit c39496ff25
3 changed files with 35 additions and 13 deletions

View File

@ -60,10 +60,7 @@ struct MccNullLogger {
typedef int loglevel_t;
void setLogLevel(loglevel_t){};
loglevel_t getLogLevel() const
{
return 0;
};
loglevel_t getLogLevel() const { return 0; };
void logMessage(loglevel_t, const std::string&) {};
void logError(const std::string&) {};
@ -384,6 +381,7 @@ concept mcc_slew_model_c = requires(T t) {
// { t.slew(std::declval<typename T::slew_params_t>()) } -> std::same_as<typename T::error_t>;
{ t.slew(std::declval<typename T::slew_point_t>()) } -> std::same_as<typename T::error_t>;
{ t.stop() } -> std::same_as<typename T::error_t>;
};
@ -394,6 +392,7 @@ concept mcc_guiding_model_c = requires(T t) {
// start process of guiding
{ t.guiding(std::declval<typename T::guiding_point_t>()) } -> std::same_as<typename T::error_t>;
{ t.stop() } -> std::same_as<typename T::error_t>;
};

View File

@ -20,10 +20,7 @@ enum class MccMountTelemetryErrorCode : int { ERROR_OK, ERROR_HARDWARE };
struct MccMountTelemetryCategory : public std::error_category {
MccMountTelemetryCategory() : 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
{
@ -105,7 +102,7 @@ struct MccMountTelemetryData {
coord_t mntRateX, mntRateY;
// current refraction coefficients
typename PEC_T::pec_result_t currRefrCoeffs;
typename ASTROM_ENGINE_T::refract_result_t currRefrCoeffs;
// current refraction correction (for mntALT)
coord_t currRefr;
@ -144,6 +141,8 @@ public:
typedef std::function<void(mount_telemetry_data_t)> update_callback_func_t;
typedef std::list<update_callback_func_t> update_callback_container_t;
typedef std::list<std::shared_ptr<std::packaged_task<update_callback_func_t>>> cc_t;
MccMountTelemetry(astrom_engine_t& astrom_engine, pec_t& pec, hardware_t& hardware)
: base_t(astrom_engine, pec), _hardware(hardware)
{

View File

@ -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;