This commit is contained in:
2026-02-18 18:50:55 +03:00
parent 889d4ff3b2
commit 18e6a99267
2 changed files with 27 additions and 14 deletions

View File

@@ -433,7 +433,7 @@ static T1 operator/(const T1& v1, const T2& v2)
std::string MccAngleFancyString(std::convertible_to<MccAngle> auto const& ang, std::string MccAngleFancyString(std::convertible_to<MccAngle> auto const& ang,
std::format_string<double> val_fmt = "{}") std::format_string<double> val_fmt = "{:.2f}")
{ {
std::string s; std::string s;

View File

@@ -464,16 +464,18 @@ public:
x_tag = coord_pair.x(); x_tag = coord_pair.x();
y_tag = coord_pair.y(); y_tag = coord_pair.y();
logger->logTrace(std::format(" current target: {} = {}, {} = {}", x_str, logger->logTrace(std::format(" current target: {} = {}, {} = {} (encoders: {} {})", x_str,
coord_pair.x().sexagesimal(true), y_str, coord_pair.y().sexagesimal())); coord_pair.x().sexagesimal(true), y_str, coord_pair.y().sexagesimal(),
tdata.targetXY.x().sexagesimal(), tdata.targetXY.y().sexagesimal()));
ccte_err = tdata.mountPos.toAtSameEpoch(coord_pair); ccte_err = tdata.mountPos.toAtSameEpoch(coord_pair);
if (ccte_err) { if (ccte_err) {
return mcc_deduced_err(ccte_err, MccSimpleMovementControlsErrorCode::ERROR_CCTE_COMP); return mcc_deduced_err(ccte_err, MccSimpleMovementControlsErrorCode::ERROR_CCTE_COMP);
} }
logger->logTrace(std::format(" current mount: {} = {}, {} = {}", x_str, coord_pair.x().sexagesimal(true), logger->logTrace(std::format(" current mount: {} = {}, {} = {} (encoders: {} {})", x_str,
y_str, coord_pair.y().sexagesimal())); coord_pair.x().sexagesimal(true), y_str, coord_pair.y().sexagesimal(),
tdata.hwState.XY.x().sexagesimal(), tdata.hwState.XY.y().sexagesimal()));
_pathFile << tdata.mountPos.epoch().UTC().time_since_epoch().count() << " " << x_tag << " " << y_tag << " " _pathFile << tdata.mountPos.epoch().UTC().time_since_epoch().count() << " " << x_tag << " " << y_tag << " "
<< x_mnt << " " << y_mnt << " " << (x_tag - x_mnt) << " " << (y_tag - y_mnt) << " " << x_mnt << " " << y_mnt << " " << (x_tag - x_mnt) << " " << (y_tag - y_mnt) << " "
@@ -605,6 +607,8 @@ public:
mcc_deduced_coord_pair_t<HARDWARE_T::hwMountType> tag_cp, mnt_cp; mcc_deduced_coord_pair_t<HARDWARE_T::hwMountType> tag_cp, mnt_cp;
*_stopMoving = false;
while (!*_stopMoving) { while (!*_stopMoving) {
t_err = telemetry->telemetryData(&tdata); t_err = telemetry->telemetryData(&tdata);
if (t_err) { if (t_err) {
@@ -661,9 +665,9 @@ public:
auto dist = utils::distanceOnSphere(tag_cp.x(), tag_cp.y(), mnt_cp.x(), mnt_cp.y()); auto dist = utils::distanceOnSphere(tag_cp.x(), tag_cp.y(), mnt_cp.x(), mnt_cp.y());
logger->logTrace(std::format(" target-to-mount distance: {} (dx = {}, dy = {})", logger->logTrace(std::format(
MccAngleFancyString(std::get<2>(dist)), std::get<0>(dist), " target-to-mount distance: {} (dx = {}, dy = {})", MccAngleFancyString(std::get<2>(dist)),
std::get<1>(dist))); MccAngleFancyString(std::get<0>(dist)), MccAngleFancyString(std::get<1>(dist))));
// stop slewing and exit from the cycle? // stop slewing and exit from the cycle?
@@ -682,7 +686,6 @@ public:
if (*_stopMoving) { if (*_stopMoving) {
*_lastError = MccSimpleMovementControlsErrorCode::ERROR_STOPPED;
break; break;
} }
@@ -702,6 +705,11 @@ public:
} }
} }
if (_stopMoving->load()) { // external stop
logger->logWarn("Slewing was stopped!");
*_lastError = MccSimpleMovementControlsErrorCode::ERROR_OK;
}
*_stopMoving = true; *_stopMoving = true;
logger->logInfo("Slewing finished"); logger->logInfo("Slewing finished");
@@ -752,7 +760,7 @@ public:
}; };
_trackingFunc = [telemetry, cb_sptr, logger, this]() { _trackingFunc = [log_pos, check_pzones, send_to_hardware, telemetry, cb_sptr, logger, this]() {
double braking_accelX, braking_accelY; double braking_accelX, braking_accelY;
double min_time_to_pzone_in_secs; double min_time_to_pzone_in_secs;
@@ -824,6 +832,7 @@ public:
mcc_deduced_coord_pair_t<HARDWARE_T::hwMountType> tag_cp, mnt_cp; mcc_deduced_coord_pair_t<HARDWARE_T::hwMountType> tag_cp, mnt_cp;
*_stopMoving = false;
while (!_stopMoving->load()) { while (!_stopMoving->load()) {
t_err = telemetry->telemetryData(&tdata); t_err = telemetry->telemetryData(&tdata);
@@ -865,9 +874,9 @@ public:
auto dist = utils::distanceOnSphere(tag_cp.x(), tag_cp.y(), mnt_cp.x(), mnt_cp.y()); auto dist = utils::distanceOnSphere(tag_cp.x(), tag_cp.y(), mnt_cp.x(), mnt_cp.y());
logger->logTrace(std::format(" target-to-mount distance: {} (dx = {}, dy = {})", logger->logTrace(std::format(
MccAngleFancyString(std::get<2>(dist)), std::get<0>(dist), " target-to-mount distance: {} (dx = {}, dy = {})", MccAngleFancyString(std::get<2>(dist)),
std::get<1>(dist))); MccAngleFancyString(std::get<0>(dist)), MccAngleFancyString(std::get<1>(dist))));
// resend new position since target coordinates are changed in time // resend new position since target coordinates are changed in time
hw_state.movementState = HARDWARE_T::hardware_movement_state_t::HW_MOVE_TRACKING; hw_state.movementState = HARDWARE_T::hardware_movement_state_t::HW_MOVE_TRACKING;
@@ -880,7 +889,6 @@ public:
} }
if (*_stopMoving) { if (*_stopMoving) {
*_lastError = MccSimpleMovementControlsErrorCode::ERROR_STOPPED;
break; break;
} }
@@ -888,6 +896,11 @@ public:
std::this_thread::sleep_for(_currentParams.trackingTelemetryInterval); std::this_thread::sleep_for(_currentParams.trackingTelemetryInterval);
} }
if (_stopMoving->load()) { // external stop
logger->logWarn("Tracking was stopped!");
*_lastError = MccSimpleMovementControlsErrorCode::ERROR_OK;
}
*_stopMoving = true; *_stopMoving = true;
logger->logInfo("Tracking finished"); logger->logInfo("Tracking finished");