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

BIN
Application_cbd_apm32f1/.settings/.rtmenus


+ 47 - 598
Application_cbd_apm32f1/applications/control.c

@@ -113,45 +113,7 @@ void ctr_turnv5(void)
 }
 
 /*************************吸虫塔*********************************/
-//吸虫电机
-uint8_t ctr_Motor_xichong(uint8_t status_ws)
-{
-    rt_pin_mode(MOTOR1_CTR_PIN, PIN_MODE_OUTPUT);
-    if(status_ws==ON)
-    {
-        rt_pin_write(MOTOR1_CTR_PIN,ON);
-    }
-    else {
-        rt_pin_write(MOTOR1_CTR_PIN, OFF);
-    }
-    return 0;
-}
 
-uint8_t ctr_Camera_Power(uint8_t status_ws)
-{
-    rt_pin_mode(MOTOR1_CTR_PIN, PIN_MODE_OUTPUT);
-    if(status_ws==ON)
-    {
-        rt_pin_write(MOTOR1_CTR_PIN,ON);
-    }
-    else {
-        rt_pin_write(MOTOR1_CTR_PIN, OFF);
-    }
-    return 0;
-}
-//吸附电机
-uint8_t ctr_Motor_xifu(uint8_t status_ws)
-{
-    rt_pin_mode(MOTOR2_CTR_PIN, PIN_MODE_OUTPUT);
-    if(status_ws==ON)
-    {
-        rt_pin_write(MOTOR2_CTR_PIN,ON);
-    }
-    else {
-        rt_pin_write(MOTOR2_CTR_PIN, OFF);
-    }
-    return 0;
-}
 //清扫-卷带电机
 void ctr_JD_Clear(uint8_t shake_sw)
 {
@@ -193,7 +155,6 @@ void WorkTask_XCT(void)
 {
     while(device_status.work_status==1&&device_status.ds==1)
     {
-
         ctr_Motor_xifu(ON);
         //打开相机供电
         ctr_Camera_Power(ON);
@@ -504,6 +465,14 @@ uint8_t ctr_shake(uint8_t status_shake,uint16_t shake_sec)
     HMI_WRITE("sysTest.switchDrop.val=%d",OFF);
     return status_shake;
 }
+
+//步进电机驱动器电源
+void ctr_Motor_Driver_Power(uint8_t status_ws)
+{
+    rt_pin_mode(SHAKE_SW, PIN_MODE_OUTPUT);
+    rt_pin_write(SHAKE_SW, status_ws);
+}
+
 //补光
 uint8_t ctr_led(uint8_t status_led)
 {
@@ -733,81 +702,7 @@ void ctr_Petroleum_jelly(rt_uint32_t delay)
     pwm_off(3,0);
     device_status.fsl_sw = 0;
 }
-//1.0转仓
-void turnzp(void)
-{
-    static uint16_t turn_timeout = 0;
-//    rt_pin_mode(CLEAR_R, PIN_MODE_OUTPUT);
-//    rt_pin_mode(CLEAR_L, PIN_MODE_OUTPUT);
-    rt_pin_mode(CLEAR_R_LIMIT,PIN_MODE_INPUT);
-//    rt_pin_write(CLEAR_R,OFF);
-//    rt_pin_write(CLEAR_L,OFF);
-    while(rt_pin_read(CLEAR_R_LIMIT)==0)
-    {
 
-        rt_thread_delay(20);
-        while(rt_pin_read(CLEAR_R_LIMIT)==0)
-        {
-//            rt_pin_write(CLEAR_R,ON);
-//            rt_pin_write(CLEAR_L,OFF);
-            Motor_Juandai(ON);
-            rt_thread_delay(50);
-            turn_timeout++;
-            if(turn_timeout==600)
-            {
-                LOG_E("检测不到限位,电机强制停止");
-                char *ctr_zp_limit_warn =makeJson_Warn("电流不足/限位超时","转盘电机");
-                DTU_Write("%s",ctr_zp_limit_warn);
-                rt_free(ctr_zp_limit_warn);
-                break;
-            }
-        }
-        break;
-    }
-    while(rt_pin_read(CLEAR_R_LIMIT)==1)
-    {
-        rt_thread_delay(20);
-        while(rt_pin_read(CLEAR_R_LIMIT)==1)
-        {
-//            rt_pin_write(CLEAR_R,ON);
-//            rt_pin_write(CLEAR_L,OFF);
-            Motor_Juandai(ON);
-            rt_thread_delay(50);
-            turn_timeout++;
-            if(turn_timeout==600)
-            {
-                LOG_E("检测不到离开限位,电机或者限位开关异常,电机强制停止");
-                char *ctr_zp_limit_warn =makeJson_Warn("检测不到离开限位,电机未启动或者限位开关故障","转盘电机");
-                DTU_Write("%s",ctr_zp_limit_warn);
-                rt_free(ctr_zp_limit_warn);
-                break;
-            }
-        }
-        break;
-    }
-    while(rt_pin_read(CLEAR_R_LIMIT)==0)
-    {
-
-        rt_thread_delay(20);
-        if(rt_pin_read(CLEAR_R_LIMIT)==0)
-        {
-//            rt_pin_write(CLEAR_R,OFF);
-//            rt_pin_write(CLEAR_L,OFF);
-            Motor_Juandai(OFF);
-            break;
-        }
-        else {
-            break;
-        }
-    }
-    Motor_Juandai(OFF);
-//    rt_pin_write(CLEAR_R,OFF);
-//    rt_pin_write(CLEAR_L,OFF);
-    turn_timeout = 0;
-    HMI_WRITE("cangWei.rotateFlag.val=%d",0);
-    HMI_WRITE("sysTest.switchClear.val=%d",0);
-    rt_thread_delay(1000);
-}
 //清扫-常闭型限位开关
 //新结构使用推杆电机做清扫
 uint8_t ctr_clear(uint16_t status_clear)
@@ -1332,91 +1227,18 @@ void SunTest(void)
 /*上电初始化*/
 void ResetInit(void)
 {
-    if(device_status.dtype==7)
-    {
-        ctr_Motor_Driver(0, 0, 0, 0);
-        //关闭电磁阀
-        ctr_shake(OFF, 0);
-        //关闭加热
-        ctr_Heat(OFF);
-        //关闭制冷
-        ctr_Cold(OFF);
-        //关闭补光灯
-        ctr_led(OFF);
-        //转盘复位
-        if(device_status.run_sta==0)
-            ctr_turn(0, 0);
-    }
-    if(device_status.version_type!=6&&device_status.version_type!=7)
-    {
-        device_status.work_done = 1;
-           //1.打开路由器供电
-           if(device_status.power_status==1)
-           {
-#if   MATCH_DEVICE ==0
-               ctr_router(ON);
-#endif
-               ctr_RTU_DTU(ON);
-               //2.打开相机供电
-               ctr_photo(ON);
-           }
-           //3.关闭镇流器
-           ctr_lamp(OFF,1);
-           //4.关闭震动电机
-           ctr_shake(OFF, 0);
-           //5.关闭加热
-           ctr_Heat(OFF);
-           //6.关闭补光灯
-           ctr_led(OFF);
-           if(device_status.bat_status==1||atoi(device_status.fuse_voltage)<1)
-           {
-               LOG_W("欠压!");
-               return;
-           }
-           //7.关闭上仓门
-           device_status.ctr_up_motor = 2;
-//           while(device_status.ctr_up_motor!=0)
-//           {
-//               LOG_I("关闭上仓门...");
-//               rt_thread_delay(100);
-//           }
-           //8.关闭下仓门
-           device_status.ctr_down_motor = 2;
-           while(device_status.ctr_down_motor!=0)
-           {
-               LOG_I("关闭下仓门....");
-               rt_thread_delay(100);
-           }
-           //9.清扫
-           if(device_status.bat_status == 1 || device_status.temp_status == 1|| device_status.rain_status==1)
-           {
-               LOG_W("异常退出!!!\n");
-               return;
-           }
-
-           if(device_status.version_type==4||device_status.version_type==41)
-           {
-               device_status.clear_status=1;
-               while(device_status.clear_status==1){
-                   rt_thread_delay(1000);
-               }
-           }
-    }
-    else {
-        if(device_status.power_status==1)
-        {
-            //1.打开路由器供电
-#if   MATCH_DEVICE ==0
-               ctr_router(ON);
-#endif
-            ctr_RTU_DTU(ON);
-            //2.打开相机供电
-            ctr_photo(ON);
-        }
-        //5.关闭加热
-        //6.关闭补光灯
-        ctr_led(OFF);
-    }
+    ctr_router(ON);
+    ctr_RTU_DTU(ON);
+    ctr_Heat(OFF);
+    ctr_Cold(OFF);
+    ctr_led(OFF);
+    ctr_shake(OFF, 0);
+    ctr_photo(ON);
+    //关闭上仓门
+    device_status.ctr_up_motor = 2;
+    //关闭光栅触发
+    //关闭风机
+    //86电机复位
 }
 /*三色光源*/
 void Led_Check(uint8_t tp)
@@ -1590,417 +1412,45 @@ void WorkCheck(void)
 }
 
 
-#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
 void WorkTask(void)
 {
-    static int clt_time = 0; //收集时间差秒数
+    static rt_uint32_t clt_time = 0; //收集时间差秒数
     static int heat_time = 0;
     LOG_I("工作状态:%d",device_status.work_status);
     LOG_I("开关机状态:%d",device_status.ds);
-    while(device_status.work_status==1&&device_status.temp_status==0&&device_status.bat_status==0&&device_status.rain_status==0&&device_status.ds==1&&device_status.clear_status==0)
+    while(device_status.work_status==1&&
+            device_status.temp_status==0&&
+            device_status.bat_status==0&&
+            device_status.rain_status==0&&
+            device_status.ds==1)
     {
         device_status.work_done = 0;
         if(clt_time==0)
         {
+            pin_guangshan_bind();
             DTU_Write("workstart.mp3");
-            if(device_status.debug_ws==1)
-            {
-                time_t stamp=time(RT_NULL);
-                static struct tm tm;
-                gmtime_r(&stamp, &tm);
-                rt_sprintf(device_status.stamp,"%04d%02d%02d%02d%02d%02d",tm.tm_year+1900,tm.tm_mon+1,tm.tm_mday,tm.tm_hour,tm.tm_min,tm.tm_sec);
-                char* debug_str = makeJson_Warn("Work start!", device_status.stamp);
-                DTU_Write(debug_str);
-                rt_free(debug_str);
-            }
+            //重置光栅
+            rt_pin_write(CTR_GS_RESET, OFF);  //光栅重置功能
+            rt_thread_delay(200);
+            rt_pin_write(CTR_GS_RESET, ON);
+            rt_thread_delay(200);
+            rt_pin_write(CTR_GS_RESET, OFF);
+            rt_thread_delay(200);
+            rt_pin_write(CTR_GS_RESET, ON);
         }
+        clt_time++;
         //1.打开灯管
-        #if LAMP_EN == 1
-        if(device_status.lamp_status==1&&device_status.sun_status==0)   //光控状态不亮灯
-        {
-            ctr_lamp(ON,1);
-            ctr_lamp(OFF,2);
-            ctr_lamp(OFF,3);
-        }
-        else if (device_status.lamp1_status==1&&device_status.sun_status==0) {
-            ctr_lamp(OFF,1);
-            ctr_lamp(ON,2);
-            ctr_lamp(OFF,3);
-        }
-        else if (device_status.lamp2_status==1&&device_status.sun_status==0) {
-            ctr_lamp(OFF,1);
-            ctr_lamp(OFF,2);
-            ctr_lamp(ON,3);
-        }
-        #else
-            ctr_lamp(ON,1);
-        #endif
         LOG_I("打开灯管!!!");
-        if(device_status.version_type!=5)
-        {
-            rt_thread_delay(1000);  //待灯管启动再往下执行,否则会触发电机过流
-            //2.打开上仓门
-            LOG_I("打开上仓门!!!");
-            device_status.ctr_up_motor = 1;
-            //3.收集
-            clt_time = device_status.clt_time * 60;
-
-            while(clt_time!=1)
-            {
-                #if 0//LAMP_EN == 0
-                    ctr_Fan_IN(ON);
-                #endif
-                clt_time --;
-                rt_thread_delay(1000);
-                #if 0//LAMP_EN == 0
-                    if(clt_time%30==0)
-                    ctr_Fan_PUT(OFF);
-                #endif
-                rt_kprintf("正在收集.....剩余时间:%d分-%d秒\n",device_status.clt_time,clt_time);
-                //如果触发异常
-                if(device_status.bat_status == 1 || device_status.temp_status == 1|| device_status.rain_status==1)
-                {
-                    ctr_lamp(OFF,1);
-                    #if LAMP_EN == 1
-                    ctr_lamp(OFF,2);
-                    ctr_lamp(OFF,3);
-                    #endif
-                    #if 0//LAMP_EN == 0
-                    ctr_Fan_IN(OFF);
-                    #endif
-                    rt_kprintf("异常退出!!!\n");
-                    break;
-                }
-                if(device_status.timeSwitch==0&&device_status.sun_status==1)
-                {
-                    ctr_lamp(OFF,1);
-                    #if LAMP_EN == 1
-                    ctr_lamp(OFF,2);
-                    ctr_lamp(OFF,3);
-                    #endif
-                    #if 0//LAMP_EN == 0
-                    ctr_Fan_IN(OFF);
-                    #endif
-                    rt_kprintf("异常退出!!!\n");
-                    break;
-                }
-            }
-            clt_time = 1;
-            if(device_status.bat_status == 1 || device_status.temp_status == 1|| device_status.rain_status==1)
-            {
-                ctr_lamp(OFF,1);
-                #if LAMP_EN == 1
-                ctr_lamp(OFF,2);
-                ctr_lamp(OFF,3);
-                #endif
-                #if 0//LAMP_EN == 0
-                ctr_Fan_IN(OFF);
-                #endif
-                rt_kprintf("异常退出!!!\n");
-                break;
-            }
-            if(device_status.timeSwitch==0&&device_status.sun_status==1)
-            {
-                ctr_lamp(OFF,1);
-                #if LAMP_EN == 1
-                ctr_lamp(OFF,2);
-                ctr_lamp(OFF,3);
-                #endif
-                #if 0//LAMP_EN == 0
-                ctr_Fan_IN(OFF);
-                #endif
-                rt_kprintf("异常退出!!!\n");
-                break;
-            }
-            #if 0//LAMP_EN == 0
-            ctr_Fan_IN(OFF);
-            #endif
-            //4.关闭上仓门
-            device_status.ctr_up_motor = 2;
-            rt_kprintf("关闭上仓门!!!\n");
-            while(device_status.ctr_up_motor!=0)
-            {
-                rt_thread_delay(100);
-                LOG_I("等待上仓门关闭!!!");
-            }
-            //5.加热
-            if(device_status.heat_sw==0)
-            {
-                calorstat(device_status.heattime*60);
-            }
-            else {
-                heat_time = device_status.heattime * 60;
-                while(heat_time!=0)
-                {
-                    heat_time--;
-                    LOG_I("正在加热状态!!!");
-                    rt_thread_delay(1000);
-                }
-            }
-            #if TG_MODULE == 0
-            //6.打开下仓门
-            if(device_status.rain_status==0)
-            {
-                device_status.ctr_down_motor =1;
-            }
-            else {
-                device_status.ctr_down_motor = 2;
-                device_status.ctr_up_motor = 2;
-            }
-
-            //待下仓门完全打开
-            while(device_status.ctr_down_motor!=0)
-            {
-                rt_thread_delay(100);
-                rt_kprintf("等待下仓门打开!!!\n");
-            }
-            rt_thread_delay(3000);
-            //关闭下仓门
-            device_status.ctr_down_motor = 2;
-            while(device_status.ctr_down_motor!=0)
-            {
-                rt_thread_delay(100);
-                rt_kprintf("等待下仓门关闭!!!\n");
-            }
-            //2022-04-12add:
-             LOG_I("打开上仓门!!!");
-             device_status.ctr_up_motor = 1;
-            #else
-            //打开下仓门
-             ctr_cangmen_down(OPEN);
-             while(1)
-             {
-                 if(rt_pin_read(CTR_UPC_LIMIT)==0)  break;
-                 rt_thread_delay(50);
-             }
-             ctr_cangmen_down(OFF);
-            #endif
-
-            if(device_status.version_type==4||device_status.version_type==41)
-            {
-                //震动
-                ctr_shake(ON, device_status.shake_sec);
-                //补光&&拍照
-                LOG_I("拍照!!!");
-                device_status.photo_ws = 1;
-            }
-#if TG_MODULE == 1
-            while(device_status.photo_ws == 1)
-            {
-                rt_thread_delay(1000);
-                LOG_I("等待拍照完成...");
-            }
-            while(device_status.clear_status==1)
-            {
-                rt_thread_delay(1000);
-                LOG_I("等待清扫完成...");
-            }
-            device_status.ctr_down_motor =1;
-            //待下仓门完全打开
-            while(device_status.ctr_down_motor!=0)
-            {
-                rt_thread_delay(100);
-                rt_kprintf("等待下仓门打开!!!\n");
-            }
-            rt_thread_delay(2000);
-            device_status.photo_ws = 1;
-            //关闭下仓门
-            device_status.ctr_down_motor = 2;
-            device_status.ctr_up_motor = 1; //打开上仓门
-#endif
-        }
+        ctr_lamp(ON,1);
+        //2.打开上仓门
+        device_status.ctr_up_motor = 1;
+        //3.打开补光灯
+        ctr_led(ON);
+        //4.打开相机
+        ctr_photo(ON);
+        //5.打开光栅、重置光栅
+        rt_thread_delay(10000);
    }
 
     if(device_status.bat_status == 1 || device_status.temp_status == 1 || device_status.rain_status==1 || device_status.ds==0)
@@ -2012,9 +1462,6 @@ void WorkTask(void)
     if(device_status.work_done==0&&device_status.work_status==0)
     {
         DTU_Write("workdone");
-        if (device_status.version_type==1) {
-            turnzp();  //2024-03-21 :开机不再转仓
-        }
         ResetInit();
         clt_time = 0;
     }
@@ -2082,6 +1529,8 @@ static void Work_Loop_thread_entry(void *parameter)
     rt_thread_delay(1000);
     ResetInit();
     rt_pin_mode(CTR_UPC_LIMIT, PIN_MODE_INPUT);
+    rt_pin_mode(CTR_GS_RESET, PIN_MODE_OUTPUT);  //光栅触发接口
+    rt_pin_write(CTR_GS_RESET, ON);
     while(1)
     {
         if(device_status.dtype==3)

+ 5 - 25
Application_cbd_apm32f1/applications/control.h

@@ -15,29 +15,12 @@
 #include <rtdevice.h>
 //定制相关//////////////////////////////////////////////////////
 
-
-#define LAMP_EN          0             //李新3灯管:0关闭,1打开
-#define PCB_V1           0             //1-旧PCB,0-新PCB(模块化)
-#define MATCH_DEVICE     0             //比赛设备
+#define PCB_V1           1             //1-旧PCB,0-新PCB(模块化)
 #define SENSOR_EN        1             //温湿度:0关闭,1打开
 #define UART_TEST_EN     0             ///串口测试0-关闭,1-启用
-#define TG_MODULE        0             //推杆电机结构模块化控制
-#if MATCH_DEVICE == 1
-#define LAMP_CURRENT    600
-#else
+
 #define LAMP_CURRENT    400
-#endif
-////////////////////////////////////////////////////////////////
-#if LAMP_EN == 1
-    #define VERSION_HK          "1.(3ledV9).41(HK)"      //4.0海康-三色光源
-    #define VERSION_HK_2000W    "1.3led.40(2000W)"       //水稻
-#else
-    #define VERSION_HK          "2.5.41(HK)"            //4.0海康-1200W
-    #define VERSION_HK_2000W    "2.24.4(2000W)"         //4.0水稻
-#endif
 
-#define VERSION_ZP          "1.45.1(ZP)"            //1.0转盘
-#define VERSION_GK          "1.41.1(GK)"            //1.0高空
 #define VERSION_V5          "2.0.5(HK)"             //5.0
 
 extern rt_event_t event_485_play;
@@ -226,7 +209,7 @@ typedef struct  _packed
 //上仓门电机限位
 #define CTR_UPC_LIMIT GET_PIN(B,9)
 //下仓门电机限位
-#define CTR_DWO_LIMIT GET_PIN(B,5)
+#define CTR_GS_RESET GET_PIN(B,5)
 #define CTR_DWC_LIMIT GET_PIN(B,8)
 //雨控电机限位,控制排水和落虫
 
@@ -242,9 +225,6 @@ typedef struct  _packed
 
 #define PB1_TIM3_CH 4   //pwm3
 
-#define MOTOR1_CTR_PIN GET_PIN(C,9)        //吸虫电机IO
-#define MOTOR2_CTR_PIN GET_PIN(B,2)        //吸附电机IO
-
 #define MOTOR_CR_PIN GET_PIN(C,7)
 #define MOTOR_CL_PIN GET_PIN(C,8)
 
@@ -255,8 +235,8 @@ uint8_t ctr_Motor_xichong(uint8_t status_ws);
 uint8_t ctr_Motor_xifu(uint8_t status_ws);
 uint8_t ctr_Camera_Power(uint8_t status_ws);
 /*****************************5.0测报灯******************************/
-#define GUANG_SHAN GET_PIN(C,13)       //光栅
-#define MOTOR_86   GET_PIN(B,9)        //85电机限位
+#define GUANG_SHAN GET_PIN(B,9)       //光栅
+#define MOTOR_86   GET_PIN(B,8)       //85电机限位
 void ctr_Motor_Driver_Power(uint8_t status_ws);
 /*****************************孢子仪**********************************/
 //制冷

+ 4 - 72
Application_cbd_apm32f1/applications/dtu_uart2.c

@@ -965,57 +965,11 @@ char * makeJson()
         return NULL;
     }
     memset(device_status.driver,0,sizeof(device_status.driver));
-    if(device_status.version_type==1)
+    if(device_status.version_type==5)
     {
-        rt_sprintf(device_status.driver,"%s-%s",VERSION_ZP,device_status.driver_4g);
-    }
-    else if (device_status.version_type==4) {
-        rt_sprintf(device_status.driver,"%s-%s",VERSION_HK_2000W,device_status.driver_4g);
-    }
-    else if (device_status.version_type==41) {
-        rt_sprintf(device_status.driver,"%s-%s",VERSION_HK,device_status.driver_4g);
-    }
-    else if (device_status.version_type==11) {
-        rt_sprintf(device_status.driver,"%s-%s",VERSION_GK,device_status.driver_4g);
-    }
-    else if (device_status.version_type==5) {
         rt_sprintf(device_status.driver,"%s-%s",VERSION_V5,device_status.driver_4g);
-        cJSON_AddStringToObject(pJsonRoot, "DEVICE_SERIAL_NUMBER", device_status.imei);
-        cJSON_AddStringToObject(pJsonRoot, "VERSION", device_status.driver);
-        cJSON_AddStringToObject(pJsonRoot, "SIGNAL", device_status.csq);
-        cJSON_AddStringToObject(pJsonRoot, "SIM", device_status.iccid);
-        static char iso8601_time[32];  // 确保缓冲区足够大以容纳时间字符串
-        get_iso8601_utc_time(iso8601_time, sizeof(iso8601_time),24);
-        cJSON_AddStringToObject(pJsonRoot, "UPDATE_DATE", iso8601_time);
-        cJSON_AddStringToObject(pJsonRoot, "STATUS", "STATUS_ONLINE");
-        cJSON_AddStringToObject(pJsonRoot, "STATUS_DESCRIPTION","设备运行正常");
-        cJSON_AddStringToObject(pJsonRoot, "LOCATION","113.0,34.0");
-        static char iso8601_time_s[32];  // 确保缓冲区足够大以容纳时间字符串
-        get_iso8601_utc_time(iso8601_time_s, sizeof(iso8601_time_s),device_status.startBar);
-        cJSON_AddStringToObject(pJsonRoot, "START_TIME",iso8601_time_s);
-        get_iso8601_utc_time(iso8601_time_s, sizeof(iso8601_time_s),device_status.stopBar);
-        cJSON_AddStringToObject(pJsonRoot, "END_TIME",iso8601_time_s);
-
-        cJSON_AddNumberToObject(pJsonRoot, "CONTRIL", !device_status.timeSwitch);
-        cJSON_AddNumberToObject(pJsonRoot, "TT", device_status.sunBar);
-        cJSON_AddNumberToObject(pJsonRoot, "WS", device_status.work_status);
-        cJSON_AddNumberToObject(pJsonRoot, "TPS", device_status.tpl);
-        cJSON_AddNumberToObject(pJsonRoot, "RPS", device_status.rain_status);
-        cJSON_AddNumberToObject(pJsonRoot, "LPS", device_status.sun_status);
-        cJSON_AddNumberToObject(pJsonRoot, "TEMPERATURE", 20.2);
-        cJSON_AddNumberToObject(pJsonRoot, "HUMIDITY", 60.2);
-        char *p = cJSON_PrintUnformatted(pJsonRoot);
-        if(NULL == p)
-        {
-            cJSON_Delete(pJsonRoot);
-            rt_kprintf("cJSON_Delete NULL!!!\n");
-            return NULL;
-        }
-        cJSON_Delete(pJsonRoot);
-        return p;
     }
 
-
     cJSON * pSubJson = NULL;
     pSubJson = cJSON_CreateObject();
     if(NULL==pSubJson)
@@ -1046,27 +1000,8 @@ char * makeJson()
     rt_sprintf(utos, "%d",device_status.dtype);
     cJSON_AddStringToObject(pSubJson,"dtype",utos);
     //类型细分
-    if(device_status.version_type==4)          //水稻
-    {
-        rt_sprintf(utos,"4");
-        cJSON_AddStringToObject(pSubJson,"vtype",utos);
-    }
-    else if (device_status.version_type==1) {   //1.0
-        rt_sprintf(utos,"1");
-        cJSON_AddStringToObject(pSubJson,"vtype",utos);
-    }
-    else if (device_status.version_type==11) {  //高空
-        rt_sprintf(utos,"11");
-        cJSON_AddStringToObject(pSubJson,"vtype",utos);
-    }
-    else if (device_status.version_type==5) {   //5.0
-        rt_sprintf(utos,"5");
-        cJSON_AddStringToObject(pSubJson,"vtype",utos);
-    }
-    else if (device_status.version_type==6) {   //吸虫塔
-        rt_sprintf(utos,"6");
-        cJSON_AddStringToObject(pSubJson,"vtype",utos);
-    }
+    cJSON_AddStringToObject(pSubJson,"vtype","5");
+
     if(device_status.version_type!=6&&device_status.dtype!=7)
     {
         //光控定时
@@ -1228,10 +1163,7 @@ char * makeJson()
     cJSON_AddStringToObject(pSubJson,"dat_f",utos);
     //信号强度
     cJSON_AddStringToObject(pSubJson,"csq",device_status.csq);
-    #if 0
-    //太阳能板电压
-    cJSON_AddStringToObject(pSubJson,"cv",device_status.voltage_sun);
-    #endif
+
     char *p = cJSON_PrintUnformatted(pJsonRoot);
     if(NULL == p)
     {

+ 8 - 158
Application_cbd_apm32f1/applications/hmi.c

@@ -1119,96 +1119,7 @@ static void HMI_Decode(void)
     else if (strstr(rx_buffer,"DebugDisable")!=NULL) {
         Debug_log_OFF();
     }
-    //高空
-    else if (strstr(rx_buffer,"SwversionV11")!=NULL)
-    {
-        device_status.dtype = 3;
-        if(device_status.version_type != 11)
-        {
-            device_status.version_type = 11;
-            sprintf(device_status.driver, "%s",VERSION_GK);
-            ef_set_env_blob("version_type",&device_status.version_type,sizeof(device_status.version_type));        //版本类型
-            ef_set_env_blob("dtype",&device_status.dtype,sizeof(device_status.dtype));        //版本类型
-            MA_save();
-        }
-        else {
-
-        }
-    }
-    //1.0
-    else if (strstr(rx_buffer,"SwversionV1")!=NULL)
-    {
-        if(device_status.version_type != 1)
-        {
-            device_status.dtype = 3;
-            device_status.version_type = 1;
-            sprintf(device_status.driver, "%s",VERSION_ZP);
-            ef_set_env_blob("version_type",&device_status.version_type,sizeof(device_status.version_type));        //版本类型
-            ef_set_env_blob("dtype",&device_status.dtype,sizeof(device_status.dtype));        //版本类型
-            MA_save();
-        }
-        else {
-
-        }
-    }
-    //4.0
-    else if (strstr(rx_buffer,"SwversionV41")!=NULL) {
-        device_status.dtype = 3;
-        if(device_status.version_type != 41)
-        {
-            device_status.dtype = 3;
-            device_status.version_type = 41;
-            sprintf(device_status.driver, "%s",VERSION_HK);
-            ef_set_env_blob("version_type",&device_status.version_type,sizeof(device_status.version_type));        //版本类型
-            ef_set_env_blob("dtype",&device_status.dtype,sizeof(device_status.dtype));        //版本类型+
-            DTU_Write("SwversionV41");
-            MA_save();
-        }
-        else {
-
-        }
-    }
-    //水稻
-    else if (strstr(rx_buffer,"SwversionV4")!=NULL) {
-        device_status.dtype = 3;
-        if(device_status.version_type != 4)
-        {
-            device_status.version_type = 4;
-            sprintf(device_status.driver, "%s",VERSION_HK_2000W);
-            ef_set_env_blob("version_type",&device_status.version_type,sizeof(device_status.version_type));        //版本类型
-            ef_set_env_blob("dtype",&device_status.dtype,sizeof(device_status.dtype));        //版本类型
-            DTU_Write("SwversionV4");
-            MA_save();
-        }
-        else {
-
-        }
-    }
-    //5.0测报灯
-    else if (strstr(rx_buffer,"SwversionV5")!=NULL) {
-        device_status.dtype = 3;
-        if(device_status.version_type!=5)
-        {
-            device_status.version_type = 5;
-            sprintf(device_status.driver, "%s",VERSION_V5);
-            ef_set_env_blob("version_type",&device_status.version_type,sizeof(device_status.version_type));        //版本类型
-            ef_set_env_blob("dtype",&device_status.dtype,sizeof(device_status.dtype));        //版本类型
-            MA_save();
-        }
-    }
 
-    else if (strstr(rx_buffer,"putTest.switchFAN_PU=1")!=NULL) {
-        ctr_Fan_PUT(ON);
-    }
-    else if (strstr(rx_buffer,"putTest.switchFAN_PU=0")!=NULL) {
-        ctr_Fan_PUT(OFF);
-    }
-    else if (strstr(rx_buffer,"putTest.switchFAN_IN=1")!=NULL) {
-        ctr_Fan_IN(ON);
-    }
-    else if (strstr(rx_buffer,"putTest.switchFAN_IN=0")!=NULL) {
-        ctr_Fan_IN(OFF);
-    }
     else if(strstr(rx_buffer,"DisplayPower")!=RT_NULL)
     {
         HMI_WRITE("sysTest.sysTest_power.txt=\"%s\"",device_status.power);
@@ -1814,7 +1725,7 @@ void Check_ParamConfig(void)
         device_status.iSave=FLASH_FLAG;
         /*设备类型,7孢子仪,3测报灯,默认设置测报灯*/
         device_status.dtype = 3;
-        device_status.version_type = 4; //4.0
+        device_status.version_type = 5; //4.0
         device_status.Power_Type = 0;   //0-交流供电;1-直流供电
         device_status.clt_time = 10;    //收集时间
         device_status.heattime = 10;    //加热时间
@@ -1843,7 +1754,7 @@ void Check_ParamConfig(void)
         device_status.cul_time = 1;
         device_status.run_sta = 0;
         device_status.handle_bugger = 0;    //默认排虫
-        sprintf(device_status.driver, "%s",VERSION_HK);
+        sprintf(device_status.driver, "%s",VERSION_V5);
         sprintf(device_status.deviceId,"0");
         rt_sprintf(device_status.tempture, "-15");
         rt_sprintf(device_status.humidity, "31");
@@ -1950,48 +1861,9 @@ void Check_ParamConfig(void)
         if(device_status.heatvalue==0) device_status.heatvalue = 100;
 
         /*设备类型,7孢子仪,3测报灯,默认设置测报灯*/
-        if(device_status.dtype!=7)
-        {
-            device_status.dtype = 3;
-        }
-        else {
-            device_status.version_type = 7;
-        }
-        if(device_status.version_type==0)
-        {
-            app_partion_backup();   //固件备份至df_area
-            device_status.version_type = 41;
-            rt_sprintf(device_status.driver, "%s",VERSION_HK);
-            ef_set_env_blob("version_type",&device_status.version_type,sizeof(device_status.version_type));
-        }
-        else if(device_status.version_type==1)
-        {
-            rt_sprintf(device_status.driver, "%s",VERSION_ZP);
-        }
-        else if (device_status.version_type==11)
-        {
-            rt_sprintf(device_status.driver, "%s",VERSION_GK);
-        }
-        else if (device_status.version_type==4)
-        {
-            rt_sprintf(device_status.driver, "%s",VERSION_HK_2000W);
-        }
-        else if (device_status.version_type==41) {
-            rt_sprintf(device_status.driver, "%s",VERSION_HK);
-        }
-        else if (device_status.version_type==5) {
-            rt_sprintf(device_status.driver, "%s",VERSION_V5);
-        }
-        /*定制三色光源*/
-        #if LAMP_EN == 1
-            if(device_status.sunBar%3!=0)
-            {
-                device_status.sunBar = 3;
-            }
-//            device_status.timeSwitch = 1;
-//            device_status.startBar = 20;
-//            device_status.stopBar = 23;
-        #endif
+        device_status.version_type = 5;
+        rt_sprintf(device_status.driver, "%s",VERSION_V5);
+
         LOG_I("SOFTWARE VERSION:%s-imei:%s--iccid:%s",device_status.driver,device_status.imei,device_status.iccid);
         LOG_I("read flash paramconfis:%d-%s-%s",device_status.version_type,device_status.driver_bl,device_status.driver_compile);
         LOG_I("开机次数:%d",device_status.rebootcnt);
@@ -2051,7 +1923,7 @@ void Check_ParamConfig(void)
         mb_master_samlpe();
 #endif
         thread_485_play();
-#if ROBOT_EN == 0
+
         uint16_t connect_num=0;
         //等待联网,
         while(atoi(device_status.net)==1)
@@ -2067,29 +1939,12 @@ void Check_ParamConfig(void)
             connect_num++;
             LOG_I("联网中......%d",connect_num);
             //超时时间为3分钟
-            #if MATCH_DEVICE == 1
-            if(connect_num==60) //180
-            {
-                device_status.timeSwitch = 1;
-                LOG_W("Time not set:%04d-%02d-%02d %02d:%02d:%02d",tm.tm_year+1900,tm.tm_mon+1,tm.tm_mday,tm.tm_hour,tm.tm_min,tm.tm_sec);
-                #if 0
-                set_date(2020, 1, 1);
-                set_time(0, 0, 0);
-                #endif
-                break;
-            }
-            #else
-            if(connect_num==10) //180
+            if(connect_num==180) //180
             {
                 device_status.timeSwitch = 0;
                 LOG_W("Time not set:%04d-%02d-%02d %02d:%02d:%02d",tm.tm_year+1900,tm.tm_mon+1,tm.tm_mday,tm.tm_hour,tm.tm_min,tm.tm_sec);
-                #if 0
-                set_date(2020, 1, 1);
-                set_time(0, 0, 0);
-                #endif
                 break;
             }
-            #endif
         }
         connect_num = 0;
         while(atoi(device_status.net)==0)
@@ -2102,17 +1957,12 @@ void Check_ParamConfig(void)
             if(connect_num>5) break;
         }
 
-        if(device_status.version_type==6) device_status.timeSwitch = 1; //吸虫塔,只有时控
-
         DTU_Write("%s",makeJson_Warn("turnon", "device_stm32"));
         rt_thread_delay(1000);
         dtu_send_data_start();
         Workstatus_check();
         Work_Loop_Task();
-#if MATCH_DEVICE == 1
-        //device_status.selfcheck_ws = 3;
-#endif
-#endif
+
     }
 }
 void ResetParamDefault(void)