|
|
@@ -1294,83 +1294,7 @@ void ResetInit(void)
|
|
|
//6.关闭补光灯
|
|
|
ctr_led(OFF);
|
|
|
}
|
|
|
-/*三色光源*/
|
|
|
-void Led_Check(uint8_t tp)
|
|
|
-{
|
|
|
- if(tp==3)
|
|
|
- {
|
|
|
- if(device_status.light_over_tim>2*3600)
|
|
|
- {
|
|
|
- device_status.work_status = 1;
|
|
|
- device_status.lamp_status = 1;
|
|
|
- device_status.lamp1_status = 0;
|
|
|
- device_status.lamp2_status = 0;
|
|
|
- LOG_I("光控定时,计时中:光源1计数:%d",device_status.light_over_tim);
|
|
|
- }
|
|
|
- else if (device_status.light_over_tim>3600&&device_status.light_over_tim<7200) {
|
|
|
- device_status.work_status = 1;
|
|
|
- device_status.lamp_status = 0;
|
|
|
- device_status.lamp1_status = 1;
|
|
|
- device_status.lamp2_status = 0;
|
|
|
- LOG_I("光控定时,计时中:光源2计数:%d",device_status.light_over_tim);
|
|
|
- }
|
|
|
- else if (device_status.light_over_tim<1*3600) {
|
|
|
- device_status.work_status = 1;
|
|
|
- device_status.lamp_status = 0;
|
|
|
- device_status.lamp1_status = 0;
|
|
|
- device_status.lamp2_status = 1;
|
|
|
- LOG_I("光控定时,计时中:光源3计数:%d",device_status.light_over_tim);
|
|
|
- }
|
|
|
- }
|
|
|
- else if (tp==6) {
|
|
|
- if(device_status.light_over_tim>4*3600)
|
|
|
- {
|
|
|
- device_status.work_status = 1;
|
|
|
- device_status.lamp_status = 1;
|
|
|
- device_status.lamp1_status = 0;
|
|
|
- device_status.lamp2_status = 0;
|
|
|
- LOG_I("光控定时,计时中:光源1计数:%d",device_status.light_over_tim);
|
|
|
- }
|
|
|
- else if (device_status.light_over_tim<14400&&device_status.light_over_tim>7200) {
|
|
|
- device_status.work_status = 1;
|
|
|
- device_status.lamp_status = 0;
|
|
|
- device_status.lamp1_status = 1;
|
|
|
- device_status.lamp2_status = 0;
|
|
|
- LOG_I("光控定时,计时中:光源2计数:%d",device_status.light_over_tim);
|
|
|
- }
|
|
|
- else if (device_status.light_over_tim<7200) {
|
|
|
- device_status.work_status = 1;
|
|
|
- device_status.lamp_status = 0;
|
|
|
- device_status.lamp1_status = 0;
|
|
|
- device_status.lamp2_status = 1;
|
|
|
- LOG_I("光控定时,计时中:光源3计数:%d",device_status.light_over_tim);
|
|
|
- }
|
|
|
- }
|
|
|
- else if (tp==9) {
|
|
|
- if(device_status.light_over_tim>6*3600)
|
|
|
- {
|
|
|
- device_status.work_status = 1;
|
|
|
- device_status.lamp_status = 1;
|
|
|
- device_status.lamp1_status = 0;
|
|
|
- device_status.lamp2_status = 0;
|
|
|
- LOG_I("光控定时,计时中:光源1计数:%d",device_status.light_over_tim);
|
|
|
- }
|
|
|
- else if (device_status.light_over_tim<6*3600&&device_status.light_over_tim>3*3600) {
|
|
|
- device_status.work_status = 1;
|
|
|
- device_status.lamp_status = 0;
|
|
|
- device_status.lamp1_status = 1;
|
|
|
- device_status.lamp2_status = 0;
|
|
|
- LOG_I("光控定时,计时中:光源2计数:%d",device_status.light_over_tim);
|
|
|
- }
|
|
|
- else if (device_status.light_over_tim<3*3600) {
|
|
|
- device_status.work_status = 1;
|
|
|
- device_status.lamp_status = 0;
|
|
|
- device_status.lamp1_status = 0;
|
|
|
- device_status.lamp2_status = 1;
|
|
|
- LOG_I("光控定时,计时中:光源3计数:%d",device_status.light_over_tim);
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
+
|
|
|
//出厂前自检 0-开机自检 1-屏幕或指令下发手动自检
|
|
|
void HardWare_Check(uint8_t boot)
|
|
|
{
|
|
|
@@ -1394,6 +1318,207 @@ void HardWare_Check(uint8_t boot)
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+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);
|
|
|
+}
|
|
|
+
|
|
|
+#if 0
|
|
|
+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 &&
|
|
|
+ device_status.startBar == 0)
|
|
|
+ {
|
|
|
+ // 24小时模式处理
|
|
|
+ device_status.work_status = 1;
|
|
|
+ rt_thread_delay(10000);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ time_t now;
|
|
|
+ time(&now);
|
|
|
+ struct tm now_tm = *localtime(&now);
|
|
|
+ struct tm start_tm = *localtime(&now);
|
|
|
+ struct tm end_tm = *localtime(&now);
|
|
|
+
|
|
|
+ // 设置开始时间
|
|
|
+ now_tm.tm_hour = now_tm.tm_hour-8;
|
|
|
+ time_t now_time = mktime(&now_tm);
|
|
|
+
|
|
|
+ // 设置开始时间
|
|
|
+ start_tm.tm_hour = device_status.startBar-8;
|
|
|
+ start_tm.tm_min = 0;
|
|
|
+ start_tm.tm_sec = 0;
|
|
|
+ time_t start_time = mktime(&start_tm);
|
|
|
+
|
|
|
+ // 设置结束时间(自动处理跨天)
|
|
|
+ end_tm.tm_hour = device_status.stopBar-8;
|
|
|
+ end_tm.tm_min = 0;
|
|
|
+ end_tm.tm_sec = 0;
|
|
|
+ if(device_status.startBar >= device_status.stopBar) {
|
|
|
+ end_tm.tm_mday += 1; // 结束时间+1天
|
|
|
+ }
|
|
|
+ time_t end_time = mktime(&end_tm);
|
|
|
+
|
|
|
+ // 工作时间判断
|
|
|
+ if(now_time >= start_time && now_time < end_time)
|
|
|
+ {
|
|
|
+ device_status.work_status = 1;
|
|
|
+ LOG_I("时控工作模式:现在:%d- 开始:%d-结束:%d",now_time,start_time,end_time);
|
|
|
+ rt_thread_delay(10000);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ device_status.work_status = 0;
|
|
|
+ LOG_I("时控待机模式:现在:%d- 开始:%d-结束:%d",now_time,start_time,end_time);
|
|
|
+ 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);
|
|
|
+}
|
|
|
+#endif
|
|
|
+#if 0
|
|
|
//工作状态检测
|
|
|
void WorkCheck(void)
|
|
|
{
|
|
|
@@ -1585,7 +1710,7 @@ void WorkCheck(void)
|
|
|
device_status.work_status = 0;
|
|
|
rt_thread_delay(1000);
|
|
|
}
|
|
|
-
|
|
|
+#endif
|
|
|
|
|
|
|
|
|
static uint8_t sleep_cnt = 0;
|