1. 优化下榜称重逻辑。

main
baocm 8 months ago
parent 6ca90acde0
commit e2a1400ab8

@ -349,7 +349,6 @@ void PublisherApp::run()
float stable_weight1 = 0;
float stable_weight2 = 0;
int weigh_state = WEIGH_IDLE;
int weigh_timeout = 0;
while (!is_stopped())
{
@ -510,7 +509,6 @@ void PublisherApp::run()
DEBUG("license_no " << license_no);
stable_weight1 = stable_weight;
weigh_state = WEIGH_STABLE1;
weigh_timeout = 0;
}
break;
case WEIGH_STABLE1:
@ -519,13 +517,6 @@ void PublisherApp::run()
DEBUG("weigh1 clear");
weigh_state = WEIGH_STABLE2;
}
if (weigh_timeout++ > 600)
{
DEBUG("weigh1 clear timeout");
weigh_timeout = 0;
stable_weight2 = stable_weight;
weigh_state = WEIGH_SEND;
}
break;
case WEIGH_STABLE2:
if ((stable_weight != 0) && (license_no.empty() != true))
@ -542,7 +533,6 @@ void PublisherApp::run()
DEBUG("stable_weight2 error");
stable_weight1 = stable_weight;
weigh_state = WEIGH_STABLE1;
weigh_timeout = 0;
}
}
break;

@ -347,7 +347,7 @@ bool WeightStabilityDetector::isVehicleLeaving(float weight_kg) const {
}
bool WeightStabilityDetector::isVehicleShaking(float weight_kg) {
if (std::abs(weight_kg - previous_weight_) > config_.jitter_threshold)
if (std::abs(weight_kg - stable_weight_) > config_.jitter_threshold)
{
is_leaving_state_ = false; // 清除离开状态标记
stable_count_ = 0; // 重置稳定计数

Loading…
Cancel
Save