Browse Source

DZ_260623_2

zhunk 5 months ago
parent
commit
f64b4a296e

+ 77 - 0
Application_CBD/applications/control.c

@@ -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);
 }
 

+ 12 - 7
Application_CBD/applications/control.h

@@ -21,26 +21,31 @@
 #define BOOT_ERR         1              //1-新bootloader,0-旧bootloader()2023年9月份之前的设备升级需要设置为0
 #define DZ_250723        0              //触发雨控后隔天再解除
 #define DZ_260519        0              //进入工作后,每小时转一次仓
+#define DZ_260623_2      0              //中端款测报灯  每次工作前和雨控解除后  上下仓门打开 等待5分钟 清扫10次 关闭上下仓门 开始正常工作  假设8点开始正常工作 可能需要7点30或者35来执行这个动作
 ////////////////////////////////////////////////////////////////
 #if LAMP_EN == 1
     #define VERSION_HK          "1.(3ledV9).41(HK)"      //4.0海康-三色光源
     #define VERSION_HK_2000W    "1.3led0.40(2000W)"       //水稻
 #else
-    #define VERSION_HK          "1.68.41(HK)"            //4.0海康-1200W
+     #define VERSION_HK          "1.68.41(HK)"            //4.0海康-1200W
+#if DZ_260623_2 == 0
     #define VERSION_HK_2000W    "1.68.40(2000W)"         //4.0水稻
+#else
+    #define VERSION_HK_2000W    "DZ_260623_2"         //4.0水稻
+#endif
 #endif
 #if DZ_260519 == 0
-#define VERSION_ZP          "1.68.1(ZP)"            //1.0转盘
+#define VERSION_ZP          "1.68.1(ZP)"                //1.0转盘
 #else
-#define VERSION_ZP          "DZ_260519"            //1.0转盘
+#define VERSION_ZP          "DZ_260519"                 //1.0转盘
 #endif
 
-#define VERSION_GK          "1.68.1(GK)"            //1.0高空
+#define VERSION_GK          "1.68.1(GK)"                //1.0高空
 
-#define VERSION_XCT         "1.13.6(HK)"            //吸虫塔-海康
-#define VERSION_Robot       "1.0(robot)"            //展厅机器人
+#define VERSION_XCT         "1.13.6(HK)"                //吸虫塔-海康
+#define VERSION_Robot       "1.0(robot)"                //展厅机器人
 
-#define VERSION_BZY         "2.60"                   //孢子仪
+#define VERSION_BZY         "2.60"                      //孢子仪
 
 
 #define CompileTime         sprintf(device_status.driver_compile,"%s-%s",__DATE__,__TIME__)              //编译时间,每次更新代码修改

+ 53 - 1
Application_CBD/applications/sht30_collect.c

@@ -136,6 +136,10 @@ static void adc_collect_thread_entry(void *parameter)
     static unsigned int light_value = 0;
     const unsigned int log_freq = 100;  //100ms
     static unsigned log_cnt = 0;
+    static uint8_t handle_rain = 0;
+    static uint8_t prework_state = 0;
+    static uint32_t prework_timer = 0;
+    static uint8_t clean_count = 0; 
     while (1)
     {
         log_cnt ++;
@@ -183,17 +187,65 @@ static void adc_collect_thread_entry(void *parameter)
                 device_status.ctr_up_motor = 2; //关闭上仓门
                 checkrain_num = 0;
                 checkrain_unlock = 0;
+                handle_rain = 1;
+                prework_state = 0;
             }
         }
         else {
             checkrain_unlock++;
             checkrain_num = 0;
-            //雨控消抖,5分钟
             if(checkrain_unlock==10*60*60)
             {
                 checkrain_unlock = 0;
                 device_status.rain_status = 0;
+#if DZ_260623_2 == 1
+                if(prework_state == 0&& handle_rain == 1)
+                {
+                    prework_state = 1;
+                    handle_rain = 0;
+                    LOG_I("DZ260623_2: 雨控解除,开始预处理");
+                }
+#endif
             }
+#if DZ_260623_2 == 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 * 10;  // 5分钟(100ms为单位)
+                        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(log_cnt==50){   //每5s打印
             log_cnt = 0;