|
|
@@ -1842,6 +1842,7 @@ void HardWare_Check(uint8_t boot)
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+#if 0
|
|
|
//工作状态检测
|
|
|
void WorkCheck(void)
|
|
|
{
|
|
|
@@ -2033,6 +2034,98 @@ void WorkCheck(void)
|
|
|
device_status.work_status = 0;
|
|
|
rt_thread_delay(1000);
|
|
|
}
|
|
|
+#endif
|
|
|
+void WorkCheck(void)
|
|
|
+{
|
|
|
+ static rt_uint32_t light_timeout = 3600;
|
|
|
+ while(device_status.ds == 1 &&
|
|
|
+ device_status.rain_status == 0 &&
|
|
|
+ device_status.temp_status == 0 &&
|
|
|
+ device_status.bat_status == 0)
|
|
|
+ {
|
|
|
+ if(device_status.timeSwitch == 1) // 时控模式
|
|
|
+ {
|
|
|
+ LOG_I("***********时控*****************");
|
|
|
+ if(device_status.startBar == device_status.stopBar)
|
|
|
+ {
|
|
|
+ // 开始结束时间相同则24小时模式
|
|
|
+ device_status.work_status = 1;
|
|
|
+ rt_thread_delay(10000);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ time_t now;
|
|
|
+ time(&now);
|
|
|
+ struct tm now_tm = *localtime(&now);
|
|
|
+ rt_uint32_t curr_sec = now_tm.tm_hour*3600 + now_tm.tm_min*60 + now_tm.tm_sec;
|
|
|
+ rt_uint32_t start_sec = device_status.startBar * 3600;
|
|
|
+ rt_uint32_t end_sec = device_status.stopBar * 3600;
|
|
|
+
|
|
|
+ // 修复跨天判断逻辑
|
|
|
+ if (start_sec < end_sec)
|
|
|
+ {
|
|
|
+ // 不跨天模式
|
|
|
+ device_status.work_status = (curr_sec >= start_sec && curr_sec < end_sec) ? 1 : 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // 跨天模式
|
|
|
+ device_status.work_status = (curr_sec >= start_sec || curr_sec < end_sec) ? 1 : 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ LOG_I("时控模式:状态[%s] 当前时间:%02d:%02d:%02d 设置:%02d:00-%02d:00",
|
|
|
+ device_status.work_status ? "工作" : "待机",
|
|
|
+ now_tm.tm_hour, now_tm.tm_min, now_tm.tm_sec,
|
|
|
+ device_status.startBar, device_status.stopBar);
|
|
|
+ rt_thread_delay(10000);
|
|
|
+ }
|
|
|
+ else // 光控模式
|
|
|
+ {
|
|
|
+ LOG_I("光控定时模式!");
|
|
|
+ if(device_status.sun_status == 0 && device_status.light_over_tim != 0)
|
|
|
+ {
|
|
|
+ device_status.light_over_tim--;
|
|
|
+ light_timeout = 3600; // 重置超时计数器
|
|
|
+ device_status.work_status = 1;
|
|
|
+ LOG_I("光控定时,计时中>>>>>>>>>:%d",device_status.light_over_tim);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // 仅在白天递减超时计数器
|
|
|
+ if(device_status.sun_status == 1 && light_timeout > 0) {
|
|
|
+ light_timeout--;
|
|
|
+ }
|
|
|
+
|
|
|
+ device_status.work_status = 0;
|
|
|
+
|
|
|
+ //没有在测试并且没有在自检
|
|
|
+ if(device_status.test_flag==0 && device_status.selfcheck_ws==0)
|
|
|
+ {
|
|
|
+ ctr_lamp(OFF,1);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 连续1小时白天后重置
|
|
|
+ if(light_timeout == 0) {
|
|
|
+ device_status.light_over_tim = 0;
|
|
|
+ light_timeout = 3600; // 重置防止负数
|
|
|
+ }
|
|
|
+
|
|
|
+ // 白天且倒计时结束:重置夜晚时长
|
|
|
+ if(device_status.light_over_tim == 0 &&
|
|
|
+ device_status.sun_status == 1)
|
|
|
+ {
|
|
|
+ device_status.light_over_tim = device_status.sunBar * 3600;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ rt_thread_delay(1000);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 异常状态处理
|
|
|
+ device_status.work_status = 0;
|
|
|
+ rt_thread_delay(1000);
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
void WorkTask_BZY(void)
|
|
|
{
|