add protection

This commit is contained in:
pandx 2026-02-07 18:41:15 +08:00
parent 6ce3eb9f0c
commit cd1b6dd1eb

View File

@ -1349,12 +1349,16 @@ void SensorScheduler::GenerateUpgradeSchedule() {
// 3 如果是1到2个传感器隔2分钟(两个波形间隔)测试一次; 如果是大于2个传感器一直连排就行了
long current_ts = GetLocalTs();
long nth_wave_start_slice = (current_ts - start_timestamp_) / wave_form_send_interval_;
long nth_wave_start_slice = abs(current_ts - start_timestamp_) / wave_form_send_interval_;
zlog_debug(zbt, "current ts: %ld, start ts:%ld", current_ts, start_timestamp_);
long current_wave_start_ts = nth_wave_start_slice * wave_form_send_interval_ + start_timestamp_;
long seconds_in_current_wave_slice = current_ts_ - current_wave_start_ts;
long nth_eigen_value_slice = seconds_in_current_wave_slice / eigen_value_send_interval_;
long seconds_in_current_eigen_slice = seconds_in_current_wave_slice % eigen_value_send_interval_;
int previous_wave_slice = wave_slice_num_per_eigen_interval_ * (nth_eigen_value_slice + 1);
if (previous_wave_slice < 0) {
zlog_error(zbt, "previous_wave_slice: %d", previous_wave_slice);
}
if (previous_wave_slice == available_slice_) {
previous_wave_slice = 0;
}