This commit is contained in:
2025-08-06 02:06:20 +03:00
parent 138e4bf84d
commit 6315d5e18e
15 changed files with 630 additions and 152 deletions

View File

@@ -148,6 +148,32 @@ public:
{
}
MccMountTelemetry(MccMountTelemetry&& other)
: base_t(std::move(other)),
_data(std::move(other._data)),
_hardware(other._hardware),
_updateMutex(std::move(other._updateMutex)),
_updateCondVar(std::move(other._updateCondVar))
{
}
MccMountTelemetry& operator=(MccMountTelemetry&& other)
{
if (this == &other) {
return *this;
}
base_t::operator=(std::move(other));
_data = std::move(other._data);
_hardware = other._hardware;
_updateMutex = std::move(other._updateMutex);
_updateCondVar = std::move(other._updateCondVar);
return *this;
}
virtual ~MccMountTelemetry() = default;
@@ -155,7 +181,7 @@ public:
template <traits::mcc_celestial_point_c PointT>
error_t setTarget(PointT tag_point)
{
std::lock_guard lock{_updateMutex};
std::lock_guard lock{*_updateMutex};
auto err = this->toICRS(tag_point, _data.utc, _data.tagRA_ICRS, _data.tagDEC_ICRS);
if (!err) {
@@ -168,7 +194,7 @@ public:
// target - mount coordinate difference
auto targetToMountDiff()
{
std::lock_guard lk(_updateMutex);
std::lock_guard lk(*_updateMutex);
coord_diff_t result;
@@ -232,13 +258,16 @@ public:
// correction for PEC
// compute corrections for PEC and celestial apparent coordinates
if constexpr (base_t::equatorialMount) {
res_err = this->toApparent(point_t{.coordPairKind = MccCoordPairKind::COORDS_KIND_XY,
.x = current_data.mntPosX,
.y = current_data.mntPosY},
current_data.utc, current_data.mntHA, current_data.mntDEC);
if (!res_err) {
current_data.pecX = current_data.mntHA - current_data.mntPosX;
current_data.pecY = current_data.mntDEC - current_data.mntPosY;
ast_err = this->_astromEngine.hadec2azalt(current_data.mntHA, current_data.mntDEC, current_data.mntAZ,
current_data.mntALT);
}
@@ -248,6 +277,9 @@ public:
.y = current_data.mntPosY},
current_data.utc, current_data.mntAZ, current_data.mntALT);
if (!res_err) {
current_data.pecX = current_data.mntAZ - current_data.mntPosX;
current_data.pecY = current_data.mntALT - current_data.mntPosY;
ast_err = this->_astromEngine.azalt2hadec(current_data.mntAZ, current_data.mntALT, current_data.mntHA,
current_data.mntDEC);
}
@@ -284,12 +316,12 @@ public:
return MccMountTelemetryAstromTransformErrorCode::ERROR_ASTROMETRY_COMP;
}
std::lock_guard lock{_updateMutex};
std::lock_guard lock{*_updateMutex};
_data = std::move(current_data);
// notify all threads for new telemetry data
_updateCondVar.notify_all();
_updateCondVar->notify_all();
return MccMountTelemetryErrorCode::ERROR_OK;
}
@@ -297,7 +329,7 @@ public:
error_t data(mount_telemetry_data_t& data)
{
std::lock_guard lock{_updateMutex};
std::lock_guard lock{*_updateMutex};
data = _data;
@@ -310,9 +342,9 @@ public:
{
auto timeout_tp = std::chrono::steady_clock::now() + timeout;
std::unique_lock lk(_updateMutex);
std::unique_lock lk(*_updateMutex);
auto res = _updateCondVar.wait_until(
auto res = _updateCondVar->wait_until(
lk, timeout_tp, [last_time_point = _data.time_point, this]() { return last_time_point < _data.timepoint; });
if (res == std::cv_status::timeout) {
return MccMountTelemetryErrorCode::ERROR_DATA_TIMEOUT;
@@ -327,8 +359,8 @@ protected:
mount_telemetry_data_t _data{};
hardware_t& _hardware;
std::mutex _updateMutex;
std::condition_variable _updateCondVar;
std::unique_ptr<std::mutex> _updateMutex;
std::unique_ptr<std::condition_variable> _updateCondVar;
};