This commit is contained in:
2025-07-31 22:47:26 +03:00
parent 9fbd858086
commit 750d29ceb9
8 changed files with 240 additions and 415 deletions

View File

@@ -138,8 +138,13 @@ public:
typedef HARDWARE_T hardware_t;
typedef DATA_T mount_telemetry_data_t;
typedef std::error_code error_t;
struct coord_diff_t {
typename ASTROM_ENGINE_T::coord_t xdiff, ydiff, r2;
};
MccMountTelemetry(astrom_engine_t& astrom_engine, pec_t& pec, hardware_t& hardware)
: base_t(astrom_engine, pec), _hardware(hardware)
{
@@ -162,7 +167,30 @@ public:
return err;
}
// target - mount coordinate difference
auto targetToMountDiff()
{
std::lock_guard lk(_updateMutex);
coord_diff_t result;
if constexpr (mccIsEquatorialMount(pec_t::mountType)) {
result.xdiff = _data.tagRA - _data.mntHA;
result.ydiff = _data.tagDEC - _data.mntDEC;
} else if constexpr (mccIsAltAzMount(pec_t::mountType)) {
result.xdiff = _data.tagAZ - _data.mntAZ;
result.ydiff = _data.tagALT - _data.mntALT;
} else {
static_assert(false, "UNSUPPORTED MOUNT TYPE!");
}
result.r2 = result.xdiff * result.xdiff + result.ydiff * result.ydiff;
return result;
}
// update telemetry right now
error_t update()
{
mount_telemetry_data_t current_data;
@@ -278,7 +306,7 @@ public:
return MccMountTelemetryErrorCode::ERROR_OK;
}
// wait until data is updated or given timeout occurs
// wait (block current thread) until data is updated or given timeout occurs
template <traits::mcc_time_duration_c DT>
error_t waitForUpdatedData(mount_telemetry_data_t& data, const DT& timeout)
{