|
|
@@ -1,4 +1,5 @@
|
|
|
#include <control.h>
|
|
|
+#include <stdint.h>
|
|
|
/*
|
|
|
* Copyright (c) 2006-2020, RT-Thread Development Team
|
|
|
*
|
|
|
@@ -2024,6 +2025,35 @@ void HardWare_Check(uint8_t boot)
|
|
|
|
|
|
}
|
|
|
|
|
|
+static void handle_rain(void)
|
|
|
+{
|
|
|
+ //执行预处理
|
|
|
+ //打开上下仓门
|
|
|
+ device_status.ctr_up_motor = 1;
|
|
|
+ device_status.ctr_down_motor = 1;
|
|
|
+ //等待5分钟
|
|
|
+ for(int i=0;i<300;i++)
|
|
|
+ {
|
|
|
+ rt_thread_delay(1000);
|
|
|
+ LOG_I("等待5分钟...%d",i);
|
|
|
+ }
|
|
|
+ //清扫10次
|
|
|
+ for(int i=0;i<10;i++)
|
|
|
+ {
|
|
|
+ device_status.clear_status = 1;
|
|
|
+ while (device_status.clear_status==1) {
|
|
|
+ rt_thread_delay(10000);
|
|
|
+ LOG_I("清扫中...%d",i);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //关闭上下仓门
|
|
|
+ device_status.ctr_up_motor = 2;
|
|
|
+ device_status.ctr_down_motor = 2;
|
|
|
+}
|
|
|
+
|
|
|
+static uint8_t prework_state = 0;
|
|
|
+static uint32_t prework_timer = 0;
|
|
|
+static uint8_t clean_count = 0;
|
|
|
void WorkCheck(void)
|
|
|
{
|
|
|
static rt_uint32_t light_timeout = 3600;
|
|
|
@@ -2050,6 +2080,52 @@ void WorkCheck(void)
|
|
|
rt_uint32_t start_sec = device_status.startBar * 3600;
|
|
|
rt_uint32_t end_sec = device_status.stopBar * 3600;
|
|
|
|
|
|
+#if DZ_260623_2 == 1
|
|
|
+ //判断当前时间是否是开始时间的前30分钟
|
|
|
+ if(curr_sec >= start_sec - 1800 && prework_state == 0)
|
|
|
+ {
|
|
|
+ prework_state = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 预处理状态机
|
|
|
+ switch(prework_state) {
|
|
|
+ case 1: // 打开上下仓门
|
|
|
+ device_status.ctr_up_motor = 1;
|
|
|
+ device_status.ctr_down_motor = 1;
|
|
|
+ // 仓门已打开,进入等待阶段
|
|
|
+ prework_state = 2;
|
|
|
+ prework_timer = 5 * 60; // 5分钟(1000ms为单位)
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 2: // 等待5分钟
|
|
|
+ prework_timer--;
|
|
|
+ if(prework_timer == 0) {
|
|
|
+ prework_state = 3;
|
|
|
+ clean_count = 0;
|
|
|
+ LOG_I("DZ260623_2: 等待5分钟结束,开始清扫");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 3: // 清扫10次
|
|
|
+ if(device_status.clear_status == 0) {
|
|
|
+ device_status.clear_status = 1;
|
|
|
+ clean_count++;
|
|
|
+ LOG_I("DZ260623_2: 第%d次清扫", clean_count);
|
|
|
+ }
|
|
|
+ if(clean_count >= 10) {
|
|
|
+ prework_state = 4;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 4: // 关闭上下仓门
|
|
|
+ device_status.ctr_up_motor = 2;
|
|
|
+ device_status.ctr_down_motor = 2;
|
|
|
+ prework_state = 0; // 完成
|
|
|
+ LOG_I("DZ260623_2: 预处理完成");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+#endif
|
|
|
+
|
|
|
// 修复跨天判断逻辑
|
|
|
if (start_sec < end_sec)
|
|
|
{
|
|
|
@@ -2107,6 +2183,7 @@ void WorkCheck(void)
|
|
|
}
|
|
|
// 异常状态处理while之外
|
|
|
device_status.work_status = 0;
|
|
|
+ prework_state = 0;
|
|
|
rt_thread_delay(1000);
|
|
|
}
|
|
|
|