From e53b687b5dec0ffe0935dbaf2308e18a6020ecd8 Mon Sep 17 00:00:00 2001 From: zhangsheng Date: Mon, 16 Mar 2026 15:13:20 +0800 Subject: [PATCH] modify bugs --- scheduler/schedule.cpp | 8 +++++++- uart/uart.cpp | 13 ++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/scheduler/schedule.cpp b/scheduler/schedule.cpp index 8249d01..abe1939 100644 --- a/scheduler/schedule.cpp +++ b/scheduler/schedule.cpp @@ -26,6 +26,7 @@ int SensorScheduler::StartSchedule(uint16_t short_addr, int &next_duration, bool } else { id = iter->second; } + current_ts_ = GetLocalTs(); CleanIdleOccupiedSet(current_ts_); @@ -35,15 +36,20 @@ int SensorScheduler::StartSchedule(uint16_t short_addr, int &next_duration, bool nth_eigen_value_slice_ = seconds_in_current_wave_slice_ / eigen_value_send_interval_; seconds_in_current_eigen_slice_ = seconds_in_current_wave_slice_ % eigen_value_send_interval_; ts_in_eigen_slice_ = false; + if (seconds_in_current_eigen_slice_ < 60 - 3) { ts_in_eigen_slice_ = true; } + if (ts_in_eigen_slice_) { - nth_eigen_slice_ = (seconds_in_current_eigen_slice_ + 2) / eigen_value_send_duration_; + // nth_eigen_slice_ = (seconds_in_current_eigen_slice_ + 2) / eigen_value_send_duration_; if (nth_eigen_value_slice_ == 0) { ClearFailureSuccessMap(); } } else { + if (seconds_per_wave_slice_ == 0) { + seconds_per_wave_slice_ = 60; + } nth_wave_slice_ = (seconds_in_current_eigen_slice_ - 60 + 3) / seconds_per_wave_slice_; } zlog_debug(zbt, "[%d:%x] ts:%ld, current utc:%s, nth eigen_value slice:%d, seconds in eigen slice:%d, eigen slice:%d", diff --git a/uart/uart.cpp b/uart/uart.cpp index e361d55..8a6f7fb 100644 --- a/uart/uart.cpp +++ b/uart/uart.cpp @@ -349,26 +349,25 @@ int Uart::DealAskTask(uint16_t ushortAdd){ zlog_warn(zct, "device info not found %02x%02x ", UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd)); return 1; } - int next_task_id = 0; + int next_duration_,next_task_id = 0; int taskID; ScheduleTask scheduleTask; bool z = false; //taskID = scheduler::instance().StartSchedule(ushortAdd,next_duration,z, next_task_id); - uint16_t next_duration = scheduler::instance().GetNextDuration(ushortAdd,z,next_task_id); - zlog_info(zct, "next_duration = %d next_taskID = %d,z = %d", next_duration,next_task_id,z); - current_z = z; - zlog_info(zct, "taskID = %d next_duration = %d next_task_id = %d,current_z = %d", taskID, next_duration, next_task_id,current_z); - if (taskID == kScheduleConfigSensor) + if (scheduler::instance().StartSchedule(ushortAdd,next_duration_,z, next_task_id) == kScheduleConfigSensor) { scheduleTask.cmd = CONFIG; - scheduleTask.duration = next_duration; + scheduleTask.duration = next_duration_; scheduleTask.next_taskID = next_task_id; scheduleTask.shortAddr = ushortAdd; TaskResp(scheduleTask); mssleep(50000); UpdateConfig(ushortAdd); } + uint16_t next_duration = scheduler::instance().GetNextDuration(ushortAdd,z,next_task_id); + zlog_info(zct, "taskID = %d next_duration = %d next_task_id = %d,current_z = %d", taskID, next_duration, next_task_id,current_z); + if(next_task_id == kScheduleWaveForm){ scheduleTask.cmd = REVIVE_DURATION; scheduleTask.shortAddr = ushortAdd;