zhunk 1 год назад
Родитель
Сommit
5a25a7b527

+ 10 - 284
Application_cbd_apm32f1/applications/control.c

@@ -259,6 +259,7 @@ uint8_t ctr_Cold(uint8_t status_cold)
 /*相机供电*/
 /*相机供电*/
 void ctr_photo(uint8_t status_photo)
 void ctr_photo(uint8_t status_photo)
 {
 {
+    LOG_W("ctr_photo:%d",status_photo);
     rt_pin_mode(PHOTO,PIN_MODE_OUTPUT);
     rt_pin_mode(PHOTO,PIN_MODE_OUTPUT);
     rt_pin_write(PHOTO,status_photo);
     rt_pin_write(PHOTO,status_photo);
 }
 }
@@ -447,7 +448,6 @@ uint8_t ctr_lamp(uint8_t status_lamp,uint8_t lamp_num)
             break;
             break;
         }
         }
     }
     }
-    HMI_WRITE("sysTest.switchLamp.val=%d",device_status.lamp_status);
     return device_status.lamp_status;
     return device_status.lamp_status;
 }
 }
 
 
@@ -999,113 +999,32 @@ uint8_t ctr_clear(uint16_t status_clear)
 //路由器供电
 //路由器供电
 void ctr_router(uint8_t status_router)
 void ctr_router(uint8_t status_router)
 {
 {
+    LOG_W("ctr_router:%d",status_router);
     rt_pin_mode(ROUTER, PIN_MODE_OUTPUT);
     rt_pin_mode(ROUTER, PIN_MODE_OUTPUT);
-    if(device_status.version_type==6)
-    rt_pin_mode(ROUTER_P,PIN_MODE_OUTPUT);
-
     //rt_pin_mode(POWER_CLEAR, PIN_MODE_OUTPUT);
     //rt_pin_mode(POWER_CLEAR, PIN_MODE_OUTPUT);
     if(status_router==ON)
     if(status_router==ON)
     {
     {
         rt_pin_write(ROUTER,ON);
         rt_pin_write(ROUTER,ON);
-        //
-        #if LAMP_EN == 0
-        if(device_status.version_type==6)
-            rt_pin_write(ROUTER_P,ON);
-        #endif
     }
     }
     else {
     else {
         rt_pin_write(ROUTER,OFF);
         rt_pin_write(ROUTER,OFF);
-        //
-        #if LAMP_EN == 0
-        if(device_status.version_type==6)
-            rt_pin_write(ROUTER_P,OFF);
-        #endif
     }
     }
 }
 }
-//清扫-推杆电机
-void ctr_TG_Clear(uint16_t clear_timeout)
+
+void ctr_Motor_OP_3(uint8_t sw)
 {
 {
-    #if 0
-    int current_clear[200];
-    int16_t Electric_current = atoi(device_status.power);  //获取电机运动前的电流
-    LOG_I("清扫电机待机:%d",Electric_current);
-    #endif
-    static uint16_t clear_count = 0;
-    clear_count = clear_timeout;
-    #if PWM_EN == 0
-        rt_pin_mode(CLEAR_R, PIN_MODE_OUTPUT);
-        rt_pin_mode(CLEAR_L, PIN_MODE_OUTPUT);
-    #endif
-    while(clear_count!=0)
+    rt_pin_mode(CLEAR_R, PIN_MODE_OUTPUT);
+    rt_pin_mode(CLEAR_L, PIN_MODE_OUTPUT);
+    if(sw==ON)
     {
     {
-         #if PWM_EN == 0
-             rt_pin_write(CLEAR_R,ON);
-             rt_pin_write(CLEAR_L,OFF);
-        #else
-             #if QINGSAO_IO == 1
-             Motor_Qingsao_R_PWM(OFF);
-             Motor_Qingsao_L_PWM(ON);
-             #else
-             Motor_Qingsao_R_PWM(ON);
-             Motor_Qingsao_L_PWM(OFF);
-             #endif
-
-        #endif
-        clear_count--;
-        rt_thread_delay(100);
-    }
-      #if PWM_EN == 0
         rt_pin_write(CLEAR_R,ON);
         rt_pin_write(CLEAR_R,ON);
-        rt_pin_write(CLEAR_L,ON);
-      #else
-        Motor_Qingsao_R_PWM(OFF);
-        Motor_Qingsao_L_PWM(OFF);
-      #endif
-    rt_thread_delay(3000);
-    clear_count = 0;
-    while(clear_timeout!=clear_count)
-    {
-        #if PWM_EN == 0
-            rt_pin_write(CLEAR_R,OFF);
-            rt_pin_write(CLEAR_L,ON);
-        #else
-        #if QINGSAO_IO == 1
-        Motor_Qingsao_R_PWM(ON);
-        Motor_Qingsao_L_PWM(OFF);
-        #else
-
-        Motor_Qingsao_R_PWM(OFF);
-        Motor_Qingsao_L_PWM(ON);
-        #endif
-
-        #endif
-//        if(clear_count<200)
-//        current_clear[clear_count] = atoi(device_status.power);
-        clear_count++;
-        rt_thread_delay(100);
-    }
-    #if PWM_EN == 0
+        rt_pin_write(CLEAR_L,OFF);
+    }else {
         rt_pin_write(CLEAR_R,ON);
         rt_pin_write(CLEAR_R,ON);
         rt_pin_write(CLEAR_L,ON);
         rt_pin_write(CLEAR_L,ON);
-    #else
-        Motor_Qingsao_R_PWM(OFF);
-        Motor_Qingsao_L_PWM(OFF);
-    #endif
-    #if 0
-    bubblesort(current_clear,200);
-    if(current_clear[199]-Electric_current <100&&device_status.work_status==1&&Electric_current!=0&&Electric_current<5000)
-    {
-        LOG_E("清扫电机电流不足:%d!",current_clear[199]);
-        char *ctr_clear_warn = makeJson_Warn("电流不足","清扫电机");
-        DTU_Write("%s",ctr_clear_warn);
-        rt_free(ctr_clear_warn);
     }
     }
-    #endif
-    rt_thread_delay(2000);
-    device_status.clear_status = 0;
-    HMI_WRITE("cangWei.rotateFlag.val=%d",0);
-    HMI_WRITE("sysTest.switchClear.val=%d",0);
 }
 }
+
 //DTU,RTU供电
 //DTU,RTU供电
 void ctr_RTU_DTU(uint8_t status_rtu)
 void ctr_RTU_DTU(uint8_t status_rtu)
 {
 {
@@ -1580,199 +1499,6 @@ void WorkCheck(void)
     rt_thread_delay(1000);
     rt_thread_delay(1000);
 }
 }
 
 
-
-#if 0
-//工作状态检测
-void WorkCheck(void)
-{
-    static rt_uint32_t light_timeout = 3600;
-    static int check_stamp_cnt = 0;
-    //雨控检测,温控检测,电池电压检测
-    while(device_status.ds==1&&device_status.rain_status==0&&device_status.temp_status==0&&device_status.bat_status==0)
-    {
-        //工作模式检测(RTC时间正常,1-时控/0-光控)(RTC时间异常强行使用光控)
-        if(device_status.timeSwitch==1)
-        {
-            LOG_I("***********时控*****************");
-            if(device_status.startBar==device_status.stopBar&&device_status.startBar==0){
-                device_status.work_status = 1;
-                LOG_I("24 hours work...");
-                #if LAMP_EN == 1
-                device_status.lamp_status = 1;
-                device_status.lamp1_status = 0;
-                device_status.lamp2_status = 0;
-                if(device_status.sun_status==1){
-                    ctr_lamp(OFF, 1);
-                    ctr_lamp(OFF, 2);
-                    ctr_lamp(OFF, 3);
-                }
-                #endif
-            }
-
-            //如果开始和结束是同一天
-            if(device_status.startBar<device_status.stopBar)
-            {
-                LOG_I("开始和结束是同一天");
-                time_t now;
-                time(&now);
-                static struct tm nowtime;   //现在
-                static struct tm starttime; //开始
-                static struct tm endtime;   //结束
-                //获取当前时间戳
-                nowtime =*localtime(&now);
-                nowtime.tm_hour = nowtime.tm_hour-8;
-                //获取定时开始的时间戳
-                starttime = *localtime(&now);
-                starttime.tm_hour = device_status.startBar-8;
-                starttime.tm_min = 0;
-                starttime.tm_sec = 0;
-                //获取定时结束的时间戳
-                endtime = *localtime(&now);
-                endtime.tm_hour = device_status.stopBar-8;
-                endtime.tm_min = 0;
-                endtime.tm_sec = 0;
-                LOG_I("***工作结束在当天:现在时间:%d-开始时间:%d-结束时间:%d***",mktime(&nowtime),mktime(&starttime),mktime(&endtime));
-                //如果当前时间大于开始时间且小于结束时间,且没有开始工作
-                if((difftime(mktime(&nowtime), mktime(&starttime)) >=0) && (difftime(mktime(&nowtime),mktime(&endtime))<0))
-                {
-                    LOG_I("当前时间大于开始时间,小于结束时间,工作中!!!");
-                    check_stamp_cnt++;
-                    if(check_stamp_cnt>20)
-                    {
-                        device_status.work_status = 1;
-                    }
-
-                }
-                //如果当前时间小于开始时间
-                else if(difftime(mktime(&nowtime),mktime(&starttime))<0)
-                {
-                    LOG_I("当前时间小于开始时间,不工作!!!-%d-%d",mktime(&nowtime),mktime(&starttime));
-                    device_status.work_status = 0;
-                    check_stamp_cnt = 0;
-                }
-                //当前时间大于结束时间
-                else {
-                    LOG_I("当前时间大于结束时间,不工作!!!-%d-%d",mktime(&nowtime),mktime(&starttime));
-                    device_status.work_status = 0;
-                    check_stamp_cnt = 0;
-                }
-                #if LAMP_EN == 1
-                //如果当前时间超过20点,未到21点
-                if((difftime(mktime(&nowtime), mktime(&starttime)) >=0) && (difftime(mktime(&nowtime),mktime(&starttime)+3600)<0))
-                {
-                    LOG_I("3led:20~21");
-                    device_status.lamp_status = 1;
-                    device_status.lamp1_status = 0;
-                    device_status.lamp2_status = 0;
-                }
-                else if ((difftime(mktime(&nowtime), mktime(&starttime)+3600) >=0) && (difftime(mktime(&nowtime),mktime(&starttime)+7200)<0)) {
-                    LOG_I("3led:21~22");
-                    device_status.lamp1_status = 1;
-                    device_status.lamp_status = 0;
-                    device_status.lamp2_status = 0;
-                }
-                else if ((difftime(mktime(&nowtime), mktime(&starttime)+7200) >=0) && (difftime(mktime(&nowtime),mktime(&starttime)+10800)<0)) {
-                    LOG_I("3led:22~23");
-                    device_status.lamp2_status = 1;
-                    device_status.lamp_status = 0;
-                    device_status.lamp1_status =0;
-                }
-                #endif
-            }
-            //如果结束时间是第二天
-            else if (device_status.startBar>device_status.stopBar) {
-                time_t now;
-                time(&now);
-                static struct tm nowtime;   //现在
-                static struct tm starttime; //开始
-                static struct tm endtime;   //结束
-                //获取当前时间戳
-                nowtime =*localtime(&now);
-                nowtime.tm_hour = nowtime.tm_hour-8;
-                //获取定时开始的时间戳
-                starttime = *localtime(&now);
-                starttime.tm_hour = device_status.startBar-8;
-                starttime.tm_min = 0;
-                starttime.tm_sec = 0;
-                //获取定时结束的时间戳
-                endtime = *localtime(&now);
-                endtime.tm_hour = device_status.stopBar-8;
-                endtime.tm_min = 0;
-                endtime.tm_sec = 0;
-                LOG_I("工作结束在第二天:现在时间:%d-开始时间:%d-结束时间:%d!!!",mktime(&nowtime),mktime(&starttime),mktime(&endtime));
-                //如果当前时间大于开始时间,且没有开始工作 ,注意时间戳日期加1
-                if((difftime(mktime(&nowtime), mktime(&starttime)) > 0 ))
-                {
-                    //获取定时结束的时间戳
-                    endtime = *localtime(&now);  //将获取到的时间转换为时间戳
-                    endtime.tm_hour = device_status.stopBar-8;  //这里需减8用于时区转换
-                    endtime.tm_min = 0;
-                    endtime.tm_sec = 0;
-                    device_status.work_status = 1;
-                    LOG_I("当前前时间大于开始时间,且没有开始工作");
-                }
-                //当前时间小于开始时间
-                else if ((difftime(mktime(&nowtime), mktime(&starttime)) < 0))
-                {
-                    //获取定时结束的时间戳
-                    endtime = *localtime(&now);  //将获取到的时间转换为时间戳
-                    endtime.tm_hour = device_status.stopBar-8;  //这里需减8用于时区转换
-                    endtime.tm_min = 0;
-                    endtime.tm_sec = 0;
-                    //如果当前时间戳小于结束时间戳
-                    if(difftime(mktime(&nowtime),mktime(&endtime)) < 0)
-                    {
-                        LOG_I("当前时间大于开始时间,且没有开始工作,当前时间小于结束时间的情况:计算工作时间:从当前时间工作第二天的结束时间");
-                        device_status.work_status = 1;
-                    }
-                    else
-                    {
-                        LOG_I("当前时间小于开始时间,且没有开始工作,不是重启引起的,即还没到开始时间");
-                        device_status.work_status = 0; //不在工作时间,待机
-                    }
-                }
-            }
-        }
-        else {
-                LOG_I("光控定时模式!");
-
-                if(device_status.sun_status==0&&device_status.light_over_tim!=0)
-                {
-
-                    device_status.light_over_tim--;
-                    light_timeout = 3600;
-                    #if LAMP_EN == 1
-                    Led_Check(device_status.sunBar);
-                    #else
-                    device_status.work_status = 1;;
-                    LOG_I("光控定时,计时中>>>>>>>>>:%d",device_status.light_over_tim);
-                    #endif
-                }
-                else
-                {
-                    light_timeout --;
-                    //没有在测试并且没有在自检
-                    if(device_status.test_flag==0&&device_status.selfcheck_ws==0)
-                    {
-                        ctr_lamp(OFF,1);
-                        #if LAMP_EN == 1
-                        ctr_lamp(OFF,2);
-                        ctr_lamp(OFF,3);
-                        #endif
-                    }
-                    device_status.work_status = 0;
-                    if(light_timeout==0) device_status.light_over_tim = 0;  //持续1小时白天,清除光控计时,20250519
-                    if(device_status.light_over_tim==0&&device_status.sun_status==1) device_status.light_over_tim = device_status.sunBar * 3600;
-                    LOG_I("光控中,白天:%d!!!",device_status.sun_status);
-                }
-        }
-        rt_thread_delay(1000);
-    }
-    LOG_I("雨控状态,温控状态,电压状态:%d-%d-%d",device_status.rain_status,device_status.temp_status,device_status.bat_status);
-    device_status.work_status = 0;
-    rt_thread_delay(1000);
-}
-#endif
 //工作任务流程s
 //工作任务流程s
 void WorkTask(void)
 void WorkTask(void)
 {
 {

+ 32 - 1
Application_cbd_apm32f1/applications/control.h

@@ -175,6 +175,37 @@ typedef struct  _packed
     char photolink[128];        //图片地址
     char photolink[128];        //图片地址
 }Device_Status_typedef;
 }Device_Status_typedef;
 
 
+typedef struct
+{
+    char OP_24V_1[8];               //24V输出通道1负载电流
+    char OP_24V_2[8];               //24V输出通道2负载电流
+    char OP_24V_3[8];               //24V输出通道3负载电流
+    char OP_24V_4[8];               //24V输出通道4负载电流
+    char OP_MOTOR_1[8];
+    char OP_MOTOR_2[8];
+    char OP_MOTOR_3[8];
+    uint8_t  OP_24V_1_STA;          //24V输出通道1检测结果,0通过,1失败
+    uint8_t  OP_24V_2_STA;          //24V输出通道1检测结果,0通过,1失败
+    uint8_t  OP_24V_3_STA;          //24V输出通道1检测结果,0通过,1失败
+    uint8_t  OP_24V_4_STA;          //24V输出通道1检测结果,0通过,1失败
+
+    uint8_t  OP_MOTOR_1_STA;
+    uint8_t  OP_MOTOR_2_STA;
+    uint8_t  OP_MOTOR_3_STA;
+
+    uint8_t  UATR_4_RX_STA;
+    uint8_t  UATR_4_TX_STA;
+
+    uint8_t  UATR_2_RX_STA;
+    uint8_t  UATR_2_TX_STA;
+
+
+    uint8_t list_all;               //检测总数
+    uint8_t checked;                //已检测
+
+}CheckResult;
+
+
 /************************************************/
 /************************************************/
 #define ON 1
 #define ON 1
 #define OFF 0
 #define OFF 0
@@ -314,7 +345,7 @@ void HardWare_Check(uint8_t boot);              //自检
 void ResetInit(void);                           //上电复位
 void ResetInit(void);                           //上电复位
 void SunTest(void);                             //光控测试
 void SunTest(void);                             //光控测试
 /*****************************************************/
 /*****************************************************/
-uint16_t ctr_xmove(uint32_t xdis,uint16_t pulse);
+void ctr_Motor_OP_3(uint8_t sw);
 /***********************孢子仪****************************/
 /***********************孢子仪****************************/
 void alarm_app_router(void);
 void alarm_app_router(void);
 /***************************************************/
 /***************************************************/

Разница между файлами не показана из-за своего большого размера
+ 5 - 1406
Application_cbd_apm32f1/applications/dtu_uart2.c


+ 163 - 463
Application_cbd_apm32f1/applications/hmi.c

@@ -52,7 +52,7 @@ void list_mem(void);
 int mb_master_samlpe();
 int mb_master_samlpe();
 /**/
 /**/
 Device_Status_typedef device_status;
 Device_Status_typedef device_status;
-
+CheckResult check_results;
 extern eMBMasterReqErrCode _485_play(USHORT *Buffer,USHORT NREGS);
 extern eMBMasterReqErrCode _485_play(USHORT *Buffer,USHORT NREGS);
 
 
 time_t time(time_t *t);
 time_t time(time_t *t);
@@ -161,11 +161,6 @@ static void Hmi_thread_entry(void *parameter)
     struct rx_msg msg;
     struct rx_msg msg;
     rt_err_t result;
     rt_err_t result;
     rt_uint32_t rx_length;
     rt_uint32_t rx_length;
-    if(device_status.dtype==3){
-        device_status.collt_box_sta = 0;
-        device_status.run_sta = 0;
-    }
-    device_status.camsta = 1;
     while(1)
     while(1)
     {
     {
         rt_memset(&msg, 0, sizeof(msg));
         rt_memset(&msg, 0, sizeof(msg));
@@ -176,13 +171,10 @@ static void Hmi_thread_entry(void *parameter)
 
 
                 rx_length = rt_device_read(msg.dev, 0, rx_buffer, msg.size);
                 rx_length = rt_device_read(msg.dev, 0, rx_buffer, msg.size);
                 rx_buffer[rx_length] = '\0';
                 rx_buffer[rx_length] = '\0';
-                //LOG_I("%s",rx_buffer);
+                LOG_I("HMI RX:%s",rx_buffer);
                 //\r 对应的hex为0x0d,0x0a,占两个字节,屏幕发送的数据都以\r结尾
                 //\r 对应的hex为0x0d,0x0a,占两个字节,屏幕发送的数据都以\r结尾
-                HMI_Decode();
+                //HMI_Decode();
         }
         }
-        /*********************************************************************************************************************/
-        //rt_kprintf("%04d-%02d-%02d %02d:%02d:%02d\n",tm.tm_year+1900,tm.tm_mon+1,tm.tm_mday,tm.tm_hour,tm.tm_min,tm.tm_sec);
-        //rt_kprintf("workSta.vbat.txt=%c%d.%02d%c\n",hmi_str,voltage/100,voltage%100,hmi_str);
     }
     }
 }
 }
 /*******************************************************************************************/
 /*******************************************************************************************/
@@ -205,227 +197,11 @@ void Start_timer_Uart2(void)
     }
     }
 }
 }
 
 
-
-/***************************** 解析从屏幕收到的数据 begin **********************************/
-static void HMI_Decode(void)
-{
-
-}
-
-
-//入口函数-电机控制及
-static void Ctr_Mortor_entry(void* parameter)
-{
-   rt_uint16_t num_up_open = 200;    //20s  上仓门打开时间
-   rt_uint16_t num_up_close = 200;   //     上仓门关闭时间
-   rt_uint16_t num_down_open = 200;  //     下仓门打开时间
-   rt_uint16_t num_down_close = 200;  //    下仓门关闭时间
-   rt_int16_t photo_led_sec = 900;  //55S
-   rt_uint8_t num_tg_open = 200;    //20S
-   rt_uint8_t num_tg_init = 200;
-   static rt_uint16_t route_off_t = 0;
-   device_status.route_off_t = 0;
-
-   rt_pin_mode(CTR_UPC_LIMIT, PIN_MODE_INPUT);
-    while(1)
-    {
-        #if 1
-        time_t time_reset12V;
-        time(&time_reset12V);
-        static struct tm alarm_reset12V;
-        alarm_reset12V =*localtime(&time_reset12V);
-        if((alarm_reset12V.tm_hour)==8&&(alarm_reset12V.tm_min==19)&&(alarm_reset12V.tm_sec==50))
-        {
-            ctr_RTU_DTU(OFF);
-            rt_thread_delay(1000*10);
-            ctr_RTU_DTU(ON);
-        }
-        #endif
-        if(device_status.ctr_up_motor==1)
-        {
-            ctr_cangmen_up(OPEN);
-            num_up_open--;
-            if (num_up_open == 0)
-            {
-                ctr_cangmen_up(OFF);
-                num_up_open = 200;
-            }
-            num_up_close = 200;
-        }
-        else if(device_status.ctr_up_motor==2)
-        {
-            ctr_cangmen_up(CLOSE);
-            num_up_close --;
-            if (num_up_close == 0)
-            {
-                ctr_cangmen_up(OFF);
-                num_up_close= 200;
-            }
-            num_up_open = 200;
-        }
-        if (device_status.ctr_down_motor == 1)
-        {
-            ctr_cangmen_down(OPEN);
-            num_down_open--;
-
-            if (num_down_open == 0)    //2025-07-07,增加限位检测
-            {
-                ctr_cangmen_down(OFF);
-                num_down_open = 200;
-            }
-            num_down_close = 200;
-        }
-        else if (device_status.ctr_down_motor == 2)
-        {
-            ctr_cangmen_down(CLOSE);
-            num_down_close--;
-
-            if (num_down_close == 0)
-            {
-               ctr_cangmen_down(OFF);
-               num_down_close = 200;
-            }
-            num_down_open = 200;
-        }
-        if(device_status.sun_test==1)
-        {
-            SunTest();
-        }
-        //拍照
-        if(device_status.photo_ws==1)
-        {
-            struct timeval tv;
-            gettimeofday(&tv, NULL);
-            device_status.photo_stamp = tv.tv_sec-8*3600;
-            if(photo_led_sec==900)
-                ctr_led(ON);
-            //打开补光灯
-            if(photo_led_sec==800)
-            {
-                LOG_I("测试拍照!");
-                #if 1
-                char *takephotojson = makeJson_takephoto();
-                DTU_Write("%s",takephotojson);
-                rt_free(takephotojson);
-                #endif
-                rt_thread_delay(5000);  //延时
-            }
-            //15S后执行拍照
-            else if (photo_led_sec==750)
-            {
-                //DTU_Write("takephoto.mp3");
-                //延时
-                rt_thread_delay(1000);
-                LOG_I("测试拍照!");
-                Hk_Take_io();
-            }
-            photo_led_sec--;
-            if(photo_led_sec==300)    //
-            {
-                ctr_led(OFF);
-                device_status.photo_ws = 0;
-                if(device_status.work_status==1)
-                {
-                    device_status.clear_status = 1;
-                }
-                HMI_WRITE("sysTest.switchPhoto.val=0");
-                HMI_WRITE("sysTest.switchFill.val=0");
-            }
-        }else{
-            photo_led_sec = 900;
-        }
-
-        if(device_status.collt_box_sta==111){
-            ctr_Fan_IN(ON);   //推杆电机收缩(供电打开,复位)
-            num_tg_init--;
-            if(num_tg_init%10==0)
-                HMI_WRITE("sysTest.result.txt=\"排虫复位中:%d\"",num_tg_init/10);
-            if(num_tg_init==0){
-                HMI_WRITE("sysTest.result.txt=\"排虫复位完成\"");
-                ctr_Fan_PUT(ON);
-                num_tg_init = 200;
-                device_status.collt_box_sta=112;
-            }
-        }else if(device_status.collt_box_sta==112){
-            num_tg_open--;
-            if(num_tg_open%10==0)
-                HMI_WRITE("sysTest.result.txt=\"开始执行排虫:%d\"",num_tg_open/10);
-            if(num_tg_open==0){
-                HMI_WRITE("sysTest.result.txt=\"排虫复位中\"");
-                ctr_Fan_PUT(OFF);
-                num_tg_open = 200;
-                device_status.collt_box_sta=113;
-            }
-        }else if(device_status.collt_box_sta==113){
-            num_tg_init--;
-            if(num_tg_init%10==0)
-                HMI_WRITE("sysTest.result.txt=\"排虫复位中:%d\"",num_tg_init/10);
-            if(num_tg_init==0){
-                HMI_WRITE("sysTest.result.txt=\"排虫机执行已完成!\"");
-                ctr_Fan_PUT(OFF);
-                ctr_Fan_IN(OFF);
-                num_tg_init = 200;
-                device_status.collt_box_sta=0;
-            }
-        }
-
-        if(device_status.run_sta==111){         //排虫-收缩
-            ctr_Fan_IN(ON);   //推杆电机收缩(供电打开,复位)
-            ctr_Fan_PUT(OFF);
-            num_tg_init--;
-            if(num_tg_init%10==0)
-                HMI_WRITE("sysTest.result.txt=\"排虫复位中:%d\"",num_tg_init/10);
-            if(num_tg_init==0){
-                HMI_WRITE("sysTest.result.txt=\"排虫复位完成\"");
-                ctr_Fan_IN(OFF);
-                num_tg_init = 200;
-                device_status.run_sta=0;
-            }
-        }else if(device_status.run_sta==112){   //收虫-推出
-            ctr_Fan_IN(ON);
-            ctr_Fan_PUT(ON);
-            num_tg_open--;
-            if(num_tg_open%10==0)
-                HMI_WRITE("sysTest.result.txt=\"开始执行收虫:%d\"",num_tg_open/10);
-            if(num_tg_open==0){
-                HMI_WRITE("sysTest.result.txt=\"收虫中...\"");
-                ctr_Fan_PUT(OFF);
-                ctr_Fan_IN(OFF);
-                num_tg_open = 200;
-                device_status.run_sta=0;
-            }
-        }
-
-        if(device_status.selfcheck_ws==2)
-        {
-           selfcheck(1);
-        }else if (device_status.selfcheck_ws==3) {
-           selfcheck(0);
-        }
-
-        if(device_status.route_off_t!=0)
-        {
-            ctr_router(OFF);
-            route_off_t = device_status.route_off_t * 60 * 10;
-            device_status.route_off_t = 0;
-        }
-        if(route_off_t>0)
-        {
-            route_off_t--;
-            if(route_off_t==1)
-            {
-                ctr_router(ON);
-                route_off_t = 0;
-            }
-        }
-        rt_thread_delay(100);
-    }
-}
 /*屏幕写数据*/
 /*屏幕写数据*/
 int Hmi_Fresh(void)
 int Hmi_Fresh(void)
 {
 {
     //初始化串口4
     //初始化串口4
-    //HMI_uart4_init();
+    HMI_uart4_init();
     rt_err_t ret = RT_EOK;
     rt_err_t ret = RT_EOK;
     /* 初始化消息队列 */
     /* 初始化消息队列 */
     rt_mq_init(&rx_mq, "rx_mq",
     rt_mq_init(&rx_mq, "rx_mq",
@@ -442,17 +218,7 @@ int Hmi_Fresh(void)
                             HMI_THREAD_STACK_SIZE,
                             HMI_THREAD_STACK_SIZE,
                             HMI_THREAD_PRIORITY,
                             HMI_THREAD_PRIORITY,
                             HMI_THREAD_TIMESLICE);
                             HMI_THREAD_TIMESLICE);
-    /*部分控制的线程*/
-    ctr_motor = rt_thread_create("Ctr motor",
-                            Ctr_Mortor_entry,
-                            RT_NULL,
-                            CONTROL_MOTOR_STACK_SIZE,
-                            CONTROL_MOTOR_PRIORITY,
-                            CONTROL_MOTOR_TIMESLICE);
-    if(ctr_motor != RT_NULL)
-    {
-        rt_thread_startup(ctr_motor);
-    }
+
     /* 如果获得线程控制块,启动这个线程 */
     /* 如果获得线程控制块,启动这个线程 */
     if (hmi1 != RT_NULL)
     if (hmi1 != RT_NULL)
     {
     {
@@ -462,16 +228,17 @@ int Hmi_Fresh(void)
     {
     {
        ret = RT_ERROR;
        ret = RT_ERROR;
     }
     }
-    //定时器,串口通信超时监测20S
-    timer_uart2 = rt_timer_create("t_uart2",t_uart2_callback,RT_NULL, 20000, RT_TIMER_FLAG_ONE_SHOT);
-    if(timer_uart2==RT_NULL)
-    {
-        LOG_E("rt_timer_create timer_uart2 failed!");
-    }
+
     return ret;
     return ret;
 }
 }
+
+
+
 void Check_ParamConfig(void)
 void Check_ParamConfig(void)
 {
 {
+    uint16_t current_1 = 0;
+    ctr_photo(OFF);
+    sht30_collect();
     time_t now = time(RT_NULL);
     time_t now = time(RT_NULL);
     static struct tm tm;
     static struct tm tm;
     gmtime_r(&now, &tm);
     gmtime_r(&now, &tm);
@@ -483,241 +250,174 @@ void Check_ParamConfig(void)
         LOG_E("Flash初始化失败!");
         LOG_E("Flash初始化失败!");
     }
     }
     LOG_I("Flash写测试...");
     LOG_I("Flash写测试...");
-    size_t saved_value_len;
     /* 设置一个名为 ‘test_key’ 的变量,值为 ‘20250826’ */
     /* 设置一个名为 ‘test_key’ 的变量,值为 ‘20250826’ */
-    ef_set_env("testkey", "20250826");
-    ef_save_env();
-    //ef_set_and_save_env("testkey", "20250826");
+    ef_set_and_save_env("testkey", "20250826");
     LOG_I("Flash写完成...");
     LOG_I("Flash写完成...");
     LOG_I("Flash读测试...");
     LOG_I("Flash读测试...");
     /* 读取字符串 */
     /* 读取字符串 */
     size_t len;
     size_t len;
     char *value;
     char *value;
-    value = ef_get_env("test_key");
+    value = ef_get_env("testkey");
     if (value) {
     if (value) {
          LOG_I("test_key value: %s (len=%d)\n", value, sizeof(value));
          LOG_I("test_key value: %s (len=%d)\n", value, sizeof(value));
      } else {
      } else {
          LOG_E("test_key not found!\n");
          LOG_E("test_key not found!\n");
      }
      }
-}
-void ResetParamDefault(void)
-{
-    #if MATCH_DEVICE == 1
-    rt_sprintf(device_status.tempture,"%d",30);
-    #else
-    rt_sprintf(device_status.tempture,"%d",-15);
-    #endif
-    device_status.ds = 1;           //设备状态开机
-    device_status.thsp = 300;
-    device_status.passWord = 8888;
-    device_status.dattim = 10;
-    device_status.collecting_sh1 = 9;
-    device_status.collecting_eh1 = 10;
-    device_status.collecting_sh2 = 14;
-    device_status.collecting_eh2 = 16;
-    device_status.Power_Type = 0;
-
-    ef_set_env_blob("Power_Type", &device_status.Power_Type, sizeof(device_status.Power_Type));
-
-    ef_set_env_blob("dattim",&device_status.dattim,sizeof(device_status.dattim));        //上传时间
-    if(device_status.dtype==3)
+    LOG_I("串口通信测试...");
+    HMI_WRITE("{\"UART4\": 1,    \"write\": 5,   \"message\": \"自检\",    \"status\": \"OK\" }");
+    rt_thread_delay(1000);
+    DTU_Write("{\"UART2\": 1,    \"write\": 5,   \"message\": \"自检\",    \"status\": \"OK\" }");
+    rt_thread_delay(3000);
+    uint16_t current = atoi(device_status.power);
+    uint16_t voltage_ = atoi(device_status.voltage);
+    current_1  = atoi(device_status.heat_power);
+    if(current>100)
     {
     {
-        device_status.clt_time = 10;    //收集时间
-        #if LAMP_EN == 0
-        device_status.startBar = 20;    //定时开始时间
-        device_status.stopBar = 5;      //定时结束时间
-        #endif
-        device_status.heattime = 10;    //加热时间
-        device_status.shake_ws = 1;     //针对开关
-        device_status.shake_sec = 1;    //震动时间1-100ms
-        #if LAMP_EN == 1
-        device_status.sunBar = 3;       //光控定时时长
-        #else
-        device_status.sunBar = 8;
-        #endif
-        device_status.tph = 70;         //高温保护阈值
-        device_status.tpl = -5;          //低温保护阈值
-        device_status.timeSwitch = 0;   //定时模式:光控
-        device_status.heatvalue=100;    //加热温度
-        device_status.heat_sw = 1;
-        ef_set_env_blob("heat_sw", &device_status.heat_sw, sizeof(device_status.heat_sw));
-        ef_set_env_blob("stime", &device_status.clt_time, sizeof(device_status.clt_time));
-        ef_set_env_blob("startBar", &device_status.startBar, sizeof(device_status.startBar));
-        ef_set_env_blob("stopBar", &device_status.stopBar, sizeof(device_status.stopBar));
-        ef_set_env_blob("timeSwitch", &device_status.timeSwitch, sizeof(device_status.timeSwitch));
-        ef_set_env_blob("sunBar", &device_status.sunBar, sizeof(device_status.sunBar));
-        ef_set_env_blob("jtime", &device_status.heattime, sizeof(device_status.heattime));
-        ef_set_env_blob("jheat", &device_status.heatvalue, sizeof(device_status.heatvalue));
-        ef_set_env_blob("tph", &device_status.tph, sizeof(device_status.tph));
-        ef_set_env_blob("tpl", &device_status.tpl, sizeof(device_status.tpl));
-        ef_set_env_blob("shake_ws", &device_status.shake_ws, sizeof(device_status.shake_ws));       //震动开关
-        ef_set_env_blob("shake_sec", &device_status.shake_sec, sizeof(device_status.shake_sec));    //震动时间
-        device_status.handle_bugger = 0;
-        ef_set_env_blob("handle_bugger", &device_status.handle_bugger, sizeof(device_status.handle_bugger));
+        LOG_E("负载电流异常!");
+        Beep_Tip(2000);
+        return;
     }
     }
-    else if(device_status.dtype==7)
+    if(voltage_<=23)
     {
     {
-        device_status.run_sta = 0;
-        device_status.heatvalue = 25;    //培养温度
-        ef_set_env_blob("run_sta", &device_status.run_sta, sizeof(device_status.run_sta));
-        ef_set_env_blob("collecting_sh1", &device_status.collecting_sh1, sizeof(device_status.collecting_sh1));    //采集时间
-        ef_set_env_blob("collecting_eh1", &device_status.collecting_eh1, sizeof(device_status.collecting_eh1));    //采集时间
-        ef_set_env_blob("collecting_sh2", &device_status.collecting_sh2, sizeof(device_status.collecting_sh2));    //采集时间
-        ef_set_env_blob("collecting_eh2", &device_status.collecting_eh2, sizeof(device_status.collecting_eh2));    //采集时间
-        ef_set_env_blob("jheat", &device_status.heatvalue, sizeof(device_status.heatvalue));
+        LOG_E("电压异常!");
+        Beep_Tip(2000);
+        return;
     }
     }
-    ef_set_env_blob("ds", &device_status.ds, sizeof(device_status.ds));
-    ef_set_env_blob("thsp", &device_status.thsp, sizeof(device_status.thsp));
-    ef_set_env_blob("passWord", &device_status.passWord,sizeof(device_status.passWord));
-    HMI_WRITE("play %d,%d,%d",1,5,0);
-    DTU_Write("reset.mp3");
-    rt_thread_delay(1000);
-}
-void ResetParamDefault_DC(void)
-{
-    //将温度数据设置为-15摄氏度,以便上传的数据中包含温控数据
-    rt_sprintf(device_status.tempture,"%d",-15);
-    device_status.clt_time = 10;    //收集时间
-    device_status.dattim = 10;      //数据上传间隔
-    #if LAMP_EN == 0
-    device_status.startBar = 20;    //定时开始时间
-    device_status.stopBar = 0;      //定时结束时间
-    #endif
-    device_status.heattime = 10;    //加热时间
-    device_status.shake_ws = 1;     //针对开关
-    device_status.shake_sec = 1;    //震动时间1-100ms
-    #if LAMP_EN == 1
-    device_status.sunBar = 3;       //光控定时时长
-    #else
-    device_status.sunBar = 4;
-    #endif
-    device_status.tph = 70;         //高温保护阈值
-    device_status.tpl = -5;          //低温保护阈值
-    device_status.timeSwitch = 0;   //定时模式
-    device_status.heatvalue=100;
-    device_status.ds = 1;           //设备状态开机
-    device_status.thsp = 300;
-    device_status.passWord = 8888;
-    device_status.timeSwitch = 0;
-    device_status.Power_Type = 1;
-    device_status.handle_bugger = 0;
-    device_status.heat_sw = 0;
-    ef_set_env_blob("dattim",&device_status.dattim,sizeof(device_status.dattim));        //上传时间
-    ef_set_env_blob("handle_bugger", &device_status.handle_bugger, sizeof(device_status.handle_bugger));
-    ef_set_env_blob("Power_Type", &device_status.Power_Type, sizeof(device_status.Power_Type));
-    ef_set_env_blob("ds", &device_status.ds, sizeof(device_status.ds));
-    ef_set_env_blob("stime", &device_status.clt_time, sizeof(device_status.clt_time));
-    ef_set_env_blob("startBar", &device_status.startBar, sizeof(device_status.startBar));
-    ef_set_env_blob("stopBar", &device_status.stopBar, sizeof(device_status.stopBar));
-    ef_set_env_blob("timeSwitch", &device_status.timeSwitch, sizeof(device_status.timeSwitch));
-    ef_set_env_blob("sunBar", &device_status.sunBar, sizeof(device_status.sunBar));
-    ef_set_env_blob("jtime", &device_status.heattime, sizeof(device_status.heattime));
-    ef_set_env_blob("jheat", &device_status.heatvalue, sizeof(device_status.heatvalue));
-    ef_set_env_blob("tph", &device_status.tph, sizeof(device_status.tph));
-    ef_set_env_blob("tpl", &device_status.tpl, sizeof(device_status.tpl));
-    ef_set_env_blob("shake_ws", &device_status.shake_ws, sizeof(device_status.shake_ws));      //震动开关
-    ef_set_env_blob("shake_sec", &device_status.shake_sec, sizeof(device_status.shake_sec));   //震动时间
-    ef_set_env_blob("thsp", &device_status.thsp, sizeof(device_status.thsp));
-    ef_set_env_blob("passWord", &device_status.passWord,sizeof(device_status.passWord));
-    ef_set_env_blob("heat_sw", &device_status.heat_sw,sizeof(device_status.heat_sw));
-    DTU_Write("reset.mp3");
-    rt_thread_delay(1000);
-}
-//固件备份
-void app_partion_backup(void)
-{
-            rt_kprintf("固件恢复!!!\n");
-            const char *dst_part_name = "df_area";
-            const char *src_part_name = "app";
-            const struct fal_partition *dst_part;
-            const struct fal_partition *src_part;
-            dst_part = fal_partition_find(dst_part_name);
-            src_part = fal_partition_find(src_part_name);
-            if (dst_part == RT_NULL || src_part == RT_NULL)
-            {
-                if (dst_part == RT_NULL)
-                rt_kprintf("%s partition is not exist!\n", dst_part_name);
-                if (src_part == RT_NULL)
-                rt_kprintf("%s partition is not exist!\n", src_part_name);
-            }
-            else
-            {
-                            rt_kprintf("Clone %s partition to %s partition:\n", src_part_name, dst_part_name);
-                            if (fal_partition_erase(dst_part, 0, dst_part->len) >= 0)
-                            {
-                                int clone_pos = 0;
-                                int clone_len = 0, clone_tol_len;
-                                rt_uint8_t *buf = rt_malloc(4096);
-
-                                if (dst_part->len < src_part->len)
-                                    clone_tol_len = dst_part->len;
-                                else
-                                    clone_tol_len = src_part->len;
-
-                                while ((clone_pos < clone_tol_len) && (buf != RT_NULL))
-                                {
-                                    clone_len = fal_partition_read(src_part, clone_pos, buf, 4096);
-                                    if (clone_len < 0)
-                                    {
-                                        rt_kprintf("\nread %s partition failed, clone stop!\n", src_part_name);
-                                        break;
-                                    }
-
-                                    if (fal_partition_write(dst_part, clone_pos, buf, clone_len) < 0)
-                                    {
-                                        rt_kprintf("\nwrite %s partition failed, clone stop!\n", dst_part_name);
-                                        break;
-                                    }
-
-                                    HMI_WRITE("#");
-                                    rt_kprintf("#");
-                                    clone_pos += clone_len;
-                                }
-
-                                if (clone_pos >= clone_tol_len)
-                                {
-
-                                    rt_kprintf("\nClone partition success, total %d bytes!\n", clone_tol_len);
-
-                                }
-                                else
-                                {
-                                    rt_kprintf("Clone partition failed!");
-
-                                }
-                                if (buf)
-                                    rt_free(buf);
-                            }
-            }
-}
-void Debug_log_ON(void)
-{
-    rt_console_set_device("uart4");
-    finsh_set_device("uart4");
-}
-void Debug_log_OFF(void)
-{
-    rt_console_set_device("uart1");
-    finsh_set_device("uart1");
-    rt_mq_init(&rx_mq, "rx_mq",
-                   msg_pool,                 /* 存放消息的缓冲区 */
-                   sizeof(struct rx_msg),    /* 一条消息的最大长度 */
-                   sizeof(msg_pool),         /* 存放消息的缓冲区大小 */
-                   RT_IPC_FLAG_FIFO);        /* 如果有多个线程等待,按照先来先得到的方法分配消息 */
-    rt_device_set_rx_indicate(serial, uart_input);
-    hmi1 = rt_thread_create("Hmi_Fresh_thread",
-                            Hmi_thread_entry,
-                            RT_NULL,
-                            HMI_THREAD_STACK_SIZE,
-                            HMI_THREAD_PRIORITY,
-                            HMI_THREAD_TIMESLICE);
-    if (hmi1 != RT_NULL)
+    if(current_1>0)
     {
     {
-       rt_thread_startup(hmi1);
+        LOG_E("负载电流1异常!");
+        Beep_Tip(2000);
+        return;
+    }
+
+
+    LOG_I("打开24V输出通道1!");
+    ctr_lamp(ON, 1);
+    rt_thread_delay(5000);
+    uint16_t current_ = atoi(device_status.power);
+    rt_sprintf(check_results.OP_24V_1,"%s",device_status.power);
+    LOG_I("24V输出通道1负载电流:[%d]mA",current_);
+    LOG_I("关闭24V输出通道1!");
+    ctr_lamp(OFF, 1);
+    if(current_-current>800)
+    {
+        LOG_W("24V输出通道1正常!");
+        check_results.OP_24V_1_STA = 0;
+    }else {
+        LOG_W("24V输出通道1负载电流异常!");
+        check_results.OP_24V_1_STA = 1;
+    }
+
+    rt_thread_delay(5000);
+    LOG_I("打开24V输出通道2!");
+    ctr_Collect_Fan(ON);
+    rt_thread_delay(5000);
+    current_1 = atoi(device_status.heat_power);
+    rt_sprintf(check_results.OP_24V_2,"%s",device_status.heat_power);
+    LOG_I("24V输出通道2负载电流:[%d]mA",current_1);
+    LOG_I("关闭24V输出通道2!");
+    ctr_Collect_Fan(OFF);
+    if(current_1>800)
+    {
+        LOG_W("24V输出通道2正常!");
+        check_results.OP_24V_2_STA = 0;
+    }else {
+        LOG_W("24V输出通道2负载电流异常!");
+        check_results.OP_24V_2_STA = 1;
+    }
+
+    rt_thread_delay(5000);
+    LOG_I("打开24V输出通道3!");
+    ctr_Cold(ON);
+    rt_thread_delay(5000);
+    current_1 = atoi(device_status.heat_power);
+    rt_sprintf(check_results.OP_24V_3,"%s",device_status.heat_power);
+    LOG_I("24V输出通道3负载电流:[%d]mA",current_1);
+    LOG_I("关闭24V输出通道3!");
+    ctr_Cold(OFF);
+    if(current_1>800)
+    {
+        LOG_W("24V输出通道3正常!");
+        check_results.OP_24V_3_STA = 0;
+    }else {
+        LOG_W("24V输出通道3负载电流异常!");
+        check_results.OP_24V_3_STA = 1;
+    }
+
+    rt_thread_delay(5000);
+    LOG_I("打开24V输出通道4!");
+    ctr_Heat(ON);
+    rt_thread_delay(5000);
+    current_1 = atoi(device_status.heat_power);
+    rt_sprintf(check_results.OP_24V_4,"%s",device_status.heat_power);
+    LOG_I("24V输出通道4负载电流:[%d]mA",current_1);
+    LOG_I("关闭24V输出通道4!");
+    ctr_Heat(OFF);
+    if(current_1>800)
+    {
+        LOG_W("24V输出通道4正常!");
+        check_results.OP_24V_4_STA = 0;
+    }else {
+        LOG_W("24V输出通道4负载电流异常!");
+        check_results.OP_24V_4_STA = 1;
+    }
+
+    rt_thread_delay(5000);
+    LOG_I("打开电机驱动通道1...");
+    ctr_cangmen_down(CLOSE);
+    rt_thread_delay(5000);
+    current_ = atoi(device_status.power);
+    rt_sprintf(check_results.OP_MOTOR_1,"%s",device_status.power);
+    LOG_I("电机驱动通道1负载电流:[%d]mA",current_);
+    LOG_I("关闭电机驱动通道1...");
+    ctr_cangmen_down(OFF);
+    if(current_-current>800)
+    {
+        LOG_W("电机驱动通道1正常!");
+        check_results.OP_MOTOR_1_STA = 0;
+    }else {
+        LOG_W("电机驱动通道1负载电流异常!");
+        check_results.OP_MOTOR_1_STA = 1;
+    }
+
+    rt_thread_delay(5000);
+    LOG_I("打开电机驱动通道2...");
+    ctr_cangmen_up(OPEN);
+    rt_thread_delay(5000);
+    current_ = atoi(device_status.power);
+    rt_sprintf(check_results.OP_MOTOR_2,"%s",device_status.power);
+    LOG_I("电机驱动通道2负载电流:[%d]mA",current_);
+    LOG_I("关闭电机驱动通道2...");
+    ctr_cangmen_up(OFF);
+    if(current_-current>800)
+    {
+        LOG_W("电机驱动通道2正常!");
+        check_results.OP_MOTOR_2_STA = 0;
+    }else {
+        LOG_W("电机驱动通道2负载电流异常!");
+        check_results.OP_MOTOR_2_STA = 1;
+    }
+
+    rt_thread_delay(5000);
+    LOG_I("打开电机驱动通道3...");
+    ctr_Motor_OP_3(ON);
+    rt_thread_delay(5000);
+    current_ = atoi(device_status.power);
+    rt_sprintf(check_results.OP_MOTOR_3,"%s",device_status.power);
+    LOG_I("电机驱动通道3负载电流:[%d]mA",current_);
+    LOG_I("关闭电机驱动通道3...");
+    ctr_Motor_OP_3(OFF);
+    if(current_-current>800)
+    {
+        LOG_W("电机驱动通道3正常!");
+        check_results.OP_MOTOR_3_STA = 0;
+    }else {
+        LOG_W("电机驱动通道3负载电流异常!");
+        check_results.OP_MOTOR_3_STA = 1;
     }
     }
 
 
 }
 }
-MSH_CMD_EXPORT(Debug_log_ON,Debug_log_ON);
-MSH_CMD_EXPORT(Debug_log_OFF,Debug_log_OFF);
+
+
 //
 //
-INIT_BOARD_EXPORT(HMI_uart4_init);
+INIT_APP_EXPORT(Hmi_Fresh);

+ 1 - 1
Application_cbd_apm32f1/applications/main.c

@@ -35,7 +35,7 @@ int main(void)
     //初始化
     //初始化
     Check_ParamConfig();
     Check_ParamConfig();
     //打印内存占用
     //打印内存占用
-    memtrace(0, NULL);
+    //memtrace(0, NULL);
     while(1)
     while(1)
     {
     {
         rt_thread_mdelay(1000);
         rt_thread_mdelay(1000);

+ 5 - 58
Application_cbd_apm32f1/applications/sht30_collect.c

@@ -182,7 +182,7 @@ static void sht30_collect_thread_entry(void *parameter)
             device_status.C01 &= ~(1<<7);
             device_status.C01 &= ~(1<<7);
             device_status.temp_status = 0;
             device_status.temp_status = 0;
         }
         }
-        LOG_I("光控计数:%d-%d",checklightnum,checknightnum);
+        LOG_I("电压:%s,电流:%s,电流2:%s",device_status.voltage,device_status.power,device_status.heat_power);
         rt_thread_mdelay(5000);
         rt_thread_mdelay(5000);
     }
     }
 }
 }
@@ -192,15 +192,15 @@ static void Power_ReadCheck(void *parameter)
     int rain_cnt = 0;
     int rain_cnt = 0;
     int bat_cnt = 0;
     int bat_cnt = 0;
     int RV;
     int RV;
-    MovingAverageFilter* filter = moving_average_filter_init(10);
+    MovingAverageFilter* filter = moving_average_filter_init(6);
     //MovingAverageFilter* filter_hi = moving_average_filter_init(10);
     //MovingAverageFilter* filter_hi = moving_average_filter_init(10);
-    MovingAverageFilter* filter_v = moving_average_filter_init(10);
+    MovingAverageFilter* filter_v = moving_average_filter_init(6);
     rt_thread_delay(1000);
     rt_thread_delay(1000);
     while(1)
     while(1)
     {
     {
         #if PCB_V1 == 0
         #if PCB_V1 == 0
         rt_uint16_t _24v_current_int = moving_average_filter_update(filter,Read_Real_Current());
         rt_uint16_t _24v_current_int = moving_average_filter_update(filter,Read_Real_Current());
-        if(_24v_current_int-2430>0)
+        if(_24v_current_int-2400>0)
         {
         {
             sprintf(device_status.power,"%.2f",(float)(_24v_current_int-2400)/0.4);
             sprintf(device_status.power,"%.2f",(float)(_24v_current_int-2400)/0.4);
         }else {
         }else {
@@ -223,31 +223,6 @@ static void Power_ReadCheck(void *parameter)
         sprintf(device_status.power,"%.2f",(float)(moving_average_filter_update(filter, (float)Read_Real_Current()/100*2.5))+20.0);
         sprintf(device_status.power,"%.2f",(float)(moving_average_filter_update(filter, (float)Read_Real_Current()/100*2.5))+20.0);
         #endif
         #endif
         //LOG_I("负载电流:%s,加热电流:%s",device_status.power,device_status.heat_power);
         //LOG_I("负载电流:%s,加热电流:%s",device_status.power,device_status.heat_power);
-        if (Read_Real_Voltage()/100<12)
-        {
-            //关闭外设
-            ctr_photo(OFF); //关闭相机供电
-            ctr_led(OFF);   //关闭补光灯
-            ctr_Heat(OFF);  //关闭加热
-            ctr_Cold(OFF);  //关闭制冷
-            #if Color_EN == 0
-            ctr_cangmen_down(OFF);  //关闭下仓门输出(转盘)
-            ctr_cangmen_up(OFF);    //关闭上仓门输出(散热)
-            #endif
-        }
-        if(atof(device_status.voltage)<22.0)    //小于22.0V,并且持续10S,欠压
-        {
-            bat_cnt++;
-        }else if(atof(device_status.voltage)>=24.0)    //大于24.0V,解除欠压
-        {
-            bat_cnt = 0;
-            device_status.C01 &= ~(1<<4);
-            device_status.bat_status = 0; //解除欠压
-        #if MATCH_DEVICE == 0
-            ctr_router(ON);               //打开路由器供电
-        #endif
-            ctr_photo(ON);                //打开相机供电
-        }
         //
         //
         if(device_status.dtype==3)
         if(device_status.dtype==3)
         {
         {
@@ -263,36 +238,8 @@ static void Power_ReadCheck(void *parameter)
                     device_status.heattem = 25;
                     device_status.heattem = 25;
                 }
                 }
             }
             }
-            //雨控
-            if(Read_Rain_Voltage()>250&&device_status.selfcheck_ws==0)
-            {
-                device_status.C01 |= (1<<5);
-                device_status.rain_status = 1;
-                ctr_lamp(OFF,1);
-                ctr_lamp(OFF,2);
-                ctr_lamp(OFF,3);
-                rain_cnt = 0;
-            }
-            else {
-                rain_cnt++;
-                //雨控消抖,1分钟
-                if(rain_cnt%10==0)
-                    LOG_D("rain_cnt:%d-value:%d",rain_cnt,Read_Rain_Voltage());
-                if(rain_cnt==600&&Read_Rain_Voltage()<250)
-                {
-                    rain_cnt = 0;
-                    device_status.rain_status = 0;
-                    device_status.lamp = 0;
-                    device_status.C01 &= ~(1<<5);
-                }
-            }
-        }
-        if(bat_cnt>=15){  //持续10s
-            bat_cnt = 0;
-            device_status.C01 |= (1<<4);
-            device_status.bat_status = 1; //欠压
-        }
 
 
+        }
         //rt_sprintf(device_status.voltage,"%d.%02d",filter_voltage()/100,filter_voltage()%100);
         //rt_sprintf(device_status.voltage,"%d.%02d",filter_voltage()/100,filter_voltage()%100);
         rt_uint16_t in_voltage_int = moving_average_filter_update(filter_v,Read_Real_Voltage());
         rt_uint16_t in_voltage_int = moving_average_filter_update(filter_v,Read_Real_Voltage());
         sprintf(device_status.voltage,"%d.%02d",in_voltage_int/100,in_voltage_int%100);
         sprintf(device_status.voltage,"%d.%02d",in_voltage_int/100,in_voltage_int%100);