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

+ 15 - 4
Application_cbd_apm32f1/applications/beep.c

@@ -185,17 +185,28 @@ void pwm_motor86_enable(rt_uint32_t freq)
 {
     beep_set(freq,freq/2);
 }
-void stop_motor_86(void)
+void stop_motor_86()
 {
-    LOG_W("stop_motor_86!");
-    rt_pwm_disable(pwm_device, BEEP_PWM_CH);
+    int pin_state = rt_pin_read(MOTOR_86);
+    LOG_W("stop_motor_86: %d", pin_state);
+    if(pin_state==1)
+    {
+        timer_motor_stop();
+        rt_pwm_disable(pwm_device, BEEP_PWM_CH);
+    }
+
 }
 
 void pin_motor_86_bind(void)
 {
+    pin_motor_86_unbind();
+    LOG_W("pin_motor_86_bind!");
+    // 首先检查引脚状态
+    int pin_state = rt_pin_read(MOTOR_86);
+    LOG_W("MOTOR_86 pin state: %d", pin_state);
     rt_pin_mode(MOTOR_86, PIN_MODE_INPUT);
     /* 绑定中断,下降沿模式,回调函数名为 */
-    rt_pin_attach_irq(MOTOR_86, PIN_IRQ_MODE_FALLING, stop_motor_86, RT_NULL);
+    rt_pin_attach_irq(MOTOR_86, PIN_IRQ_MODE_RISING_FALLING, stop_motor_86, RT_NULL);
     /* 使能中断 */
     rt_pin_irq_enable(MOTOR_86, PIN_IRQ_ENABLE);
 }

+ 29 - 241
Application_cbd_apm32f1/applications/control.c

@@ -35,10 +35,13 @@
 //设备状态表结构体
 Device_Status_typedef device_status;
 
-rt_thread_t tid_workloop = RT_NULL;
 
-rt_timer_t timer_shibie = RT_NULL;
 
+//定时器
+rt_timer_t timer_shibie = RT_NULL;
+rt_timer_t timer_motor = RT_NULL;
+//线程
+rt_thread_t tid_workloop = RT_NULL;
 rt_thread_t tid_heat = RT_NULL;
 rt_thread_t tid_485_play = RT_NULL;
 
@@ -435,134 +438,7 @@ uint8_t ctr_led(uint8_t status_led)
     }
     return status_led;
 }
-/*************************************************
-Function:       ctr_turn
-Description:    转盘驱动
-Calls:
-Table Accessed: // 被访问的表(此项仅对于牵扯到数据库操作的程序)
-Table Updated: // 被修改的表(此项仅对于牵扯到数据库操作的程序)
-Input:          v=0(复位) v=90转90度
-Output:         NULL
-Return:         NULL
-Others:         NULL
-*************************************************/
-void ctr_turn(uint8_t v,uint8_t sta)
-{
-    DTU_Write("turn.mp3");
-    LOG_I("================v===============:%d",v);
-    rt_uint16_t turn_cnt = 0;
-    rt_pin_mode(TURN_ZP_R, PIN_MODE_OUTPUT);
-    rt_pin_mode(TURN_ZP_L, PIN_MODE_OUTPUT);
-    rt_pin_mode(LIMIT_0, PIN_MODE_INPUT);
-    rt_pin_mode(LIMIT_90, PIN_MODE_INPUT);
-    //if(v==0&&rt_pin_read(LIMIT_0)==0) return;               //如果在初始位置,则不再往下执行
-    while(rt_pin_read(LIMIT_0)==0||rt_pin_read(LIMIT_90)==0)
-    {
-        rt_pin_write(TURN_ZP_R, ON);
-        rt_pin_write(TURN_ZP_L, OFF);
-        //Motor_shake(ON,0);
-        turn_cnt ++;
-        rt_thread_delay(100);
-        if(turn_cnt==1000)
-        {
-            turn_cnt = 0;
-            rt_pin_write(TURN_ZP_R, OFF);
-            rt_pin_write(TURN_ZP_L, OFF);
-            //Motor_shake(OFF,0);
-            char *turn_warn =makeJson_Warn("未检测到限位", "转盘");
-            DTU_Write("%s",turn_warn);
-            rt_free(turn_warn);
-            break;
-        }
-    }
-    turn_cnt = 0;
-    while(v==0&&rt_pin_read(LIMIT_0)==1)
-    {
-        rt_pin_write(TURN_ZP_R, ON);
-        rt_pin_write(TURN_ZP_L, OFF);
-        Motor_shake(ON,0);
-        rt_thread_delay(200);        //10 to 100
-        turn_cnt ++;
-        if(turn_cnt==300)          //6000 to 600
-        {
-            turn_cnt = 0;
-//            rt_pin_write(TURN_ZP_R, OFF);
-//            rt_pin_write(TURN_ZP_L, OFF);
-//            char *turn_warn =makeJson_Warn("超时", "转盘复位");
-//            DTU_Write("%s",turn_warn);
-//            rt_free(turn_warn);
-            break;
-        }
-    }
-    while(v==0&&rt_pin_read(LIMIT_0)==1)
-    {
-        rt_pin_write(TURN_ZP_R, ON);
-        rt_pin_write(TURN_ZP_L, OFF);
-        //Motor_shake(ON,0);
-        rt_thread_delay(50);        //10 to 50
-        turn_cnt ++;
-        if(turn_cnt==10)          //6000 to 1200
-        {
-            turn_cnt = 0;
-            rt_pin_write(TURN_ZP_R, OFF);
-            rt_pin_write(TURN_ZP_L, OFF);
-            //Motor_shake(OFF,0);
-            char *turn_warn =makeJson_Warn("超时", "转盘复位");
-            DTU_Write("%s",turn_warn);
-            rt_free(turn_warn);
-            break;
-        }
-    }
-    turn_cnt = 0;
-    while(v==90&&rt_pin_read(LIMIT_90)==1)
-    {
-        rt_pin_write(TURN_ZP_R, ON);
-        rt_pin_write(TURN_ZP_L, OFF);
-        //Motor_shake(ON,0);
-        rt_thread_delay(200);
-        turn_cnt ++;
-        if(turn_cnt==150)
-        {
-            turn_cnt = 0;
-//            rt_pin_write(TURN_ZP_R, OFF);
-//            rt_pin_write(TURN_ZP_L, OFF);
-//            char *turn_warn =makeJson_Warn("超时", "转盘");
-//            DTU_Write(turn_warn);
-//            rt_free(turn_warn);
-            break;
-        }
-    }
-    while(v==90&&rt_pin_read(LIMIT_90)==1)
-    {
-//        rt_pin_write(TURN_ZP_R, ON);
-//        rt_pin_write(TURN_ZP_L, OFF);
-        Motor_shake(ON,0);
-        rt_thread_delay(50);
-        turn_cnt ++;
-        if(turn_cnt==10)
-        {
-            turn_cnt = 0;
-            rt_pin_write(TURN_ZP_R, OFF);
-            rt_pin_write(TURN_ZP_L, OFF);
-            //Motor_shake(OFF,0);
-            char *turn_warn =makeJson_Warn("超时", "转盘");
-            DTU_Write(turn_warn);
-            rt_free(turn_warn);
-            break;
-        }
-    }
-    if(sta!=0)
-    {
-        //保存位置
-        device_status.run_sta = sta;
-        ef_set_env_blob("run_sta", &device_status.run_sta, sizeof(device_status.run_sta));
-    }
-    turn_cnt = 0;
-    rt_pin_write(TURN_ZP_R, OFF);
-    rt_pin_write(TURN_ZP_L, OFF);
-    Motor_shake(OFF,0);
-    HMI_WRITE("cangWei.rotateFlag.val=0");
-}
+
 /*
  *
  * */
@@ -1043,38 +919,6 @@ void Hk_Take_io(void)
     rt_pin_write(HK_IO, 1);
 }
 
-//初始化所有控制驱动,关闭
-void HardWare_Init(uint8_t boot)
-{
-    Beep_Tip(200);
-    //关闭上仓门
-    ctr_cangmen_up(OFF);
-
-    if(device_status.dtype==3){
-        //关闭下仓门电机
-        ctr_cangmen_down(OFF);
-    }
-    //关闭镇流器
-    if(device_status.autotakepic==0)
-    ctr_lamp(OFF,1);
-
-    //关闭震动电机
-    ctr_shake(OFF,0);
-
-    //关闭加热
-    ctr_Heat(OFF);
-
-    //关闭补光灯
-    ctr_led(OFF);
-
-    //关闭12V供电(海康相机,RTU)
-    ctr_photo(OFF);
-
-    //关闭清扫电机驱动
-    ctr_clear(OFF);
-
-
-}
 //拍照
 void HK_TakePhoto(void)
 {
@@ -1281,29 +1125,6 @@ void pin_guangshan_bind(void)
 }
 
 
-void motor_stop(void *args)
-{
-    LOG_W("motor_stop!");
-    stop_motor_86();
-}
-
-void pin_motor_bind(void)
-{
-    LOG_W("pin_motor_bind");
-    /* PC14引脚为输入模式 */
-    rt_pin_mode(MOTOR_86, PIN_MODE_INPUT);
-    /* 绑定中断,下降沿模式,回调函数名为guanshan_on */
-    rt_pin_attach_irq(MOTOR_86, PIN_IRQ_MODE_RISING, motor_stop, RT_NULL);
-    /* 使能中断 */
-    rt_pin_irq_enable(MOTOR_86, PIN_IRQ_ENABLE);
-}
-
-void pin_motor_unbind(void)
-{
-    LOG_D("pin_motor_unbind");
-    rt_pin_detach_irq(MOTOR_86);
-}
-
 void pin_guangshan_unbind(void)
 {
     LOG_D("pin_guangshan_unbind");
@@ -1360,65 +1181,18 @@ uint16_t ctr_Motor86_move(uint32_t xdis,uint32_t pulse,uint8_t dir)
 {
     //rt_kprintf("run here1");
     LOG_W("ctr_Motor86_move:%d-%d-%d",xdis,pulse,dir);                                   //两个脉冲移动0.72度,轴方向上移动2um
-    //uint32_t limit_tm= 0;
+    uint32_t limit_tm= 0;
     rt_pin_mode(Motor_EN, PIN_MODE_OUTPUT);             //使能电机驱动引脚   PB14
     rt_pin_write(Motor_EN, ON);                         //引脚输出高使能有效
 
     rt_pin_mode(CTR_RO_LIMIT, PIN_MODE_OUTPUT);       //CCW  PB15 配置为输出模式
 
-   // rt_pin_mode(MOTOR_86, PIN_MODE_INPUT);
-
     rt_pin_write(CTR_RO_LIMIT, dir);             //CCW  置高
     rt_thread_delay(50);
     pwm_motor86_enable(pulse);
-//    while(rt_pin_read(MOTOR_86)==0)
-//    {
-//        limit_tm++;
-//        rt_thread_delay(10);
-//        if(limit_tm>=1000) break;
-//    }
-//    pwm_motor86_enable(pulse*2);
-//    while(rt_pin_read(MOTOR_86)==1){
-//        limit_tm++;
-//        rt_thread_delay(10);
-//        if(limit_tm>=1000) break;
-//    }
-//    pwm_motor86_enable(pulse);
-//    while(rt_pin_read(MOTOR_86)==0)
-//    {
-//
-//        pwm_motor86_enable(pulse);
-//        limit_tm++;
-//        rt_thread_delay(10);
-//        if(limit_tm>=1000) break;
-//    }
-//    stop_motor_86();
-//    if(dir==0)
-//    {
-//        pwm_motor86_enable(pulse*2);
-//        while(rt_pin_read(MOTOR_86)==1){
-//            limit_tm++;
-//            rt_thread_delay(10);
-//            if(limit_tm>=1000) break;
-//        }
-//    }else {
-//        rt_thread_delay(500);
-//        rt_pin_write(CTR_RO_LIMIT, !dir);             //CCW  置高
-//        rt_thread_delay(100);
-//        pwm_motor86_enable(pulse*3);
-//        while(rt_pin_read(MOTOR_86)==0){
-//            limit_tm++;
-//            rt_thread_delay(10);
-//            if(limit_tm>=1000) break;
-//        }
-//        while(rt_pin_read(MOTOR_86)==1){
-//            limit_tm++;
-//            rt_thread_delay(10);
-//            if(limit_tm>=1000) break;
-//        }
-//    }
-//    stop_motor_86();
-//    slidelock();
+    rt_thread_delay(50);
+    rt_timer_start(timer_motor);
+    //启动定时器
     return xdis;
  }
 
@@ -1472,7 +1246,7 @@ void WorkTask_CB5(void)
             //光栅检测启动
             pin_guangshan_bind();
             //电机限位检测启动
-            pin_motor_bind();
+            pin_motor_86_bind();
             rt_thread_delay(1000);
             while(rt_pin_read(GUANG_SHAN)==0)
             {
@@ -1493,7 +1267,7 @@ void WorkTask_CB5(void)
     if(device_status.work_done==0&&device_status.work_status==0)
     {
         pin_guangshan_unbind();
-        pin_motor_unbind();
+        pin_motor_86_unbind();
         //打开推杆电机,益虫放生
         DTU_Write("{\"cmd\":\"workdone\"}");
         ResetInit();
@@ -1721,19 +1495,33 @@ void timer_shibie_stop()
     LOG_W("timer_shibie_stop!");
 }
 
+void timer_motor_stop()
+{
+    rt_timer_stop(timer_motor);
+    LOG_W("timer_motor_stop!");
+}
+
 static void t_shibie_callback(void *parameter)
 {
     LOG_E("识别超时!");
     device_status.autotakepic = 10;
 }
 
+static void t_motor_callback(void *parameter)
+{
+    LOG_E("电机超时!");
+    stop_motor_86();
+}
+
 int rt_software_timer_init(void)
 {
-    //启动拍照超时定时器
+    //创建拍照超时定时器
     timer_shibie = rt_timer_create("t_shibie",t_shibie_callback,RT_NULL,15000, RT_TIMER_FLAG_ONE_SHOT|RT_TIMER_FLAG_HARD_TIMER);
-    if(timer_shibie==RT_NULL)
+    //创建电机运行超时定时器
+    timer_motor = rt_timer_create("t_motor",t_motor_callback,RT_NULL,2000, RT_TIMER_FLAG_ONE_SHOT|RT_TIMER_FLAG_HARD_TIMER);   //2S
+    if(timer_motor==RT_NULL||timer_shibie==RT_NULL)
     {
-        LOG_E("rt_timer_create t_shibie failed!");
+        LOG_E("rt_timer_create t_timer failed!");
         return RT_ERROR;
     }
     else

+ 3 - 5
Application_cbd_apm32f1/applications/control.h

@@ -37,7 +37,7 @@
     #define VERSION_HK_2000W    "2.22.4(2000W)"         //4.0水稻
 #endif
 
-#define VERSION_V5          "2.2.5(HK)"             //5.0
+#define VERSION_V5          "2.3.5(HK)"             //5.0
 
 extern rt_event_t event_485_play;
 
@@ -216,9 +216,6 @@ typedef struct  _packed
 #define CLEAR_R_LIMIT GET_PIN(C,13)
 #define CLEAR_L_LIMIT GET_PIN(B,9)
 /***************************高空测报灯*************************/
-
-//上仓门电机限位
-#define CTR_UPC_LIMIT GET_PIN(B,9)
 //下仓门电机限位
 #define CTR_DWO_LIMIT GET_PIN(B,5)
 #define CTR_DWC_LIMIT GET_PIN(B,8)
@@ -303,7 +300,7 @@ void Hk_Take_io(void);                          //触发拍照
 void HK_TakePhoto(void);                        //拍照
 void ctr_photo(uint8_t status_photo);
 void ctr_RTU_DTU(uint8_t status_rtu);
-void HardWare_Init(uint8_t boot);               //初始化
+
 void ResetInit(void);                           //上电复位
 void SunTest(void);                             //光控测试
 /*****************************************************/
@@ -315,6 +312,7 @@ void pin_motor_unbind();
 
 
 void timer_shibie_stop();
+void timer_motor_stop();
 /***********************孢子仪****************************/
 
 /***************************************************/

+ 2 - 14
Application_cbd_apm32f1/applications/dtu_uart2.c

@@ -1601,18 +1601,6 @@ int parseDtu(char *json_string)
                       rt_free(photo);
                       rt_thread_delay(2000);
                   }
-                  //{"ext": {"type": "turn"}, "cmd": "ctrl"}   转仓
-                  else if(strstr(type->valuestring,"turn")!=RT_NULL)
-                  {
-                      #if Color_EN == 0
-                      char *turn_zp = makeJson_Warn("send cmd success:turn_zp","control");
-                      DTU_Write("%s",turn_zp);
-                      rt_free(turn_zp);
-                      ctr_turn(90, 0);
-                      #else
-                      DTU_Write("黄板复位:%d",ctr_Color_board(RESET, 800));
-                      #endif
-                  }
                   //{"ext": {"type": "paichong"}, "cmd": "ctrl"}   排虫
                   else if (strstr(type->valuestring,"paichong")!=RT_NULL) {
                       char *turn_zp = makeJson_Warn("send cmd success:paichong","control");
@@ -1665,13 +1653,13 @@ int parseDtu(char *json_string)
                   else if(strstr(type->valuestring,"insect_kill")!=RT_NULL)
                   {
                       timer_shibie_stop();
-                      device_status.autotakepic = 10;
+                      device_status.autotakepic = 11;
                       LOG_W("收到害虫信号!");
                   }
                   else if(strstr(type->valuestring,"insect_save")!=RT_NULL)
                   {
                       timer_shibie_stop();
-                      device_status.autotakepic = 11;
+                      device_status.autotakepic = 10;
                       LOG_W("收到益虫信号!");
                   }
               }

+ 9 - 55
Application_cbd_apm32f1/applications/hmi.c

@@ -397,16 +397,6 @@ static void HMI_Decode(void)
         device_status.photo_ws = 1;
         #endif
     }
-    //转盘复位
-    else if (strstr(rx_buffer,"turn_init")!=NULL) {
-        LOG_I("转仓复位!");
-        ctr_turn(0,0);
-    }
-    //转盘
-    else if (strstr(rx_buffer,"turn")!=NULL) {
-        LOG_I("转仓!");
-        ctr_turn(90,0);
-    }
     //打开电磁阀
     else if (strstr(rx_buffer,"putTest.switchDrop=1")!=NULL) {
         LOG_I("开始滴液!");
@@ -542,7 +532,7 @@ static void HMI_Decode(void)
         #endif
         ctr_Motor_Driver_Power(ON);
         pin_guangshan_bind();
-        pin_motor_bind();
+        pin_motor_86_bind();
         DTU_Write("{\"cmd\":\"workstart\"}");
         USHORT dkdg[] = {0xb4f2,0xbfaa,0xb5c6,0xb9dc};
         _485_play(dkdg,4);
@@ -552,7 +542,7 @@ static void HMI_Decode(void)
     else if (strstr(rx_buffer,"putTest.switchLamp=0")!=NULL)
     {
         pin_guangshan_unbind();
-        pin_motor_unbind();
+        pin_motor_86_unbind();
         device_status.test_flag=0;
         LOG_I("Close Lamp1!");
         ctr_lamp(OFF,1);
@@ -1264,8 +1254,6 @@ static void HMI_Decode(void)
     {
         _485_play(sound122, 4);
         HMI_WRITE("sysTest.result.txt=\"益虫测试!\"");
-//        ctr_Motor_Driver_Power(ON);
-//        ctr_xmove(400,200);//旋转清虫
         device_status.autotakepic = 11;
     }else if (strstr(rx_buffer,"cc_reset")!=NULL) {
         device_status.autotakepic = 12;
@@ -1300,79 +1288,47 @@ static void Ctr_Mortor_entry(void* parameter)
         #endif
         if(device_status.ctr_up_motor==1)
         {
-            #if 0
-            if(num_up_open==200&&device_status.clear_status==0&&device_status.work_status==1)
-            {
-                motor_current = atoi(device_status.power);
-                LOG_D("上仓门待机电流:%d",motor_current);
-            }
-            //打开上仓门
-            if(num_up_open<200)
-            #endif
             ctr_cangmen_up(OPEN);
             num_up_open--;
-//            current_t[num_up_open] = atoi(device_status.power);
+
             if (num_up_open == 0)
             {
                 ctr_cangmen_up(OFF);
                 num_up_open = 200;
-
-//                bubblesort(current_t, 200);
-//                if(current_t[199]-motor_current<100&&device_status.clear_status==0&&device_status.work_status==1&&motor_current!=0&&motor_current<5000)
-//                {
-//                    LOG_E("上仓门打开电机电流不足:%d!!!",current_t[199]);
-//                    char * ctr_cm_up_warn = makeJson_Warn("电流不足,打开", "上仓门电机");
-//                    DTU_Write("%s",ctr_cm_up_warn);
-//                    rt_free(ctr_cm_up_warn);
-//                }
             }
-//            else {
-//                LOG_D("上仓门打开电流:%d",current_t[num_up_open]);
-//            }
+
         }
         else if(device_status.ctr_up_motor==2)
         {
-//            if(num_up_close==200&&device_status.clear_status==0&&device_status.work_status==1)
-//            {
-//                motor_current = atoi(device_status.power);
-//                LOG_D("上仓门待机电流:%d",motor_current);
-//            }
-//            if(num_up_close<200)
+
             ctr_cangmen_up(CLOSE);
             num_up_close --;
-//            current_t[num_up_close] = atoi(device_status.power);
             if (num_up_close == 0)
             {
                 ctr_cangmen_up(OFF);
                 num_up_close= 200;
             }
-            //LOG_D("上仓门关闭电流:%d",current_t[num_up_close]);
         }
         if (device_status.ctr_down_motor == 1)
         {
             ctr_cangmen_down(OPEN);
             num_down_open--;
-//            current_t[num_down_open] = atoi(device_status.power);
             //如果关闭仓门1S后检测不到电流增大,则判定为异常
             if (num_down_open == 0)
             {
                 ctr_cangmen_down(OFF);
                 num_down_open = 200;
             }
-//            LOG_D("下仓门打开电流:%d",current_t[num_down_open]);
         }
         else if (device_status.ctr_down_motor == 2)
         {
             ctr_cangmen_down(CLOSE);
             num_down_close--;
-//            current_t[num_down_close] = atoi(device_status.power);
-
             if (num_down_close == 0)
             {
                ctr_cangmen_down(OFF);
                num_down_close = 200;
             }
-//            LOG_D("下仓门关闭电流:%d",current_t[num_down_close]);
         }
         if(device_status.sun_test==1)
         {
@@ -1420,14 +1376,12 @@ static void Ctr_Mortor_entry(void* parameter)
         }
 
         if (device_status.autotakepic==10) {
-            //hwtimer2_pwm3_output(1,500000,1,0);
-            ctr_Motor86_move(0,50000,1);
+            ctr_Motor86_move(0,200000,1);
             device_status.autotakepic = 0;
         }
 
         else if (device_status.autotakepic==11) {
-            //hwtimer2_pwm3_output(1,500000,1,1);
-            ctr_Motor86_move(0,50000,0);
+            ctr_Motor86_move(0,200000,0);
             device_status.autotakepic = 0;
         }
         else if (device_status.autotakepic==12) {
@@ -1520,8 +1474,8 @@ void Check_ParamConfig(void)
     {
         device_status.iSave=FLASH_FLAG;
         /*设备类型,7孢子仪,3测报灯,默认设置测报灯*/
-        device_status.dtype = 3;
-        device_status.version_type = 5; //4.0
+        device_status.dtype = 8;
+        device_status.version_type = 8; //4.0
         device_status.Power_Type = 0;   //0-交流供电;1-直流供电
         device_status.clt_time = 10;    //收集时间
         device_status.heattime = 10;    //加热时间

+ 1 - 277
Application_cbd_apm32f1/applications/selfcheck.c

@@ -48,283 +48,7 @@ static void t_takephoto_callback(void *parameter)
 
 int selfcheck(uint8_t type)
 {
-    int current_i[6];
-    int current_,current_open = 0;
-    //删除workloop线程 防止自动运行干扰
-    LOG_I("删除线程workloop:%d",thread_delete_workloop());
-    //初始化硬件
-    HardWare_Init(0);
-    //关闭上仓门
-    ctr_cangmen_down(CLOSE);
-    //关闭下仓门
-    ctr_cangmen_up(CLOSE);
-    for(int c=0;c<8;c++)
-    {
-        rt_thread_delay(2000);
-        HMI_WRITE("sysSet.va0.txt=\"等待上下仓门复位完成......\"");
-        LOG_W("等待上下仓门复位完成.....%d",c);
-    }
-    ctr_cangmen_up(OFF);
-    ctr_cangmen_down(OFF);
-    /********************************************************/
-    //读取5次电流值,取平均值
-    for(int i = 0;i<5;i++)
-    {
-        current_i[i] = atoi(device_status.power);
-        rt_thread_delay(1000);
-    }
-    current_ = calculate_average(current_i,5);
-    if(current_<50||current_>3000)
-    {
-        device_status.C01 |= (1<<12);
-        HMI_WRITE("selfcheck.t13.bco=63488");
-    }
-    else
-    {
-        HMI_WRITE("selfcheck.t13.bco=2024");
-        device_status.C01 &= ~(1<<12);
-    }
-    HMI_WRITE("sysSet.va0.txt=\"待机电流:%d\"",current_);
-    LOG_W("待机电流.....%d",current_);
-    if(type==1)
-    {
-        char *readinfo =  makeJson_ReadInfo();
-        DTU_Write("%s",readinfo);
-        rt_free(readinfo);
-        rt_thread_delay(1000);
-        if(atoi(device_status.gps)==0)
-        {
-            HMI_WRITE("selfcheck.t12.bco=63488");
-            device_status.C01 |= (1<<11);
-            HMI_WRITE("sysSet.va0.txt=\"GPS无定位\"");
-        }
-        else {
-            HMI_WRITE("selfcheck.t12.bco=2024");
-            device_status.C01 &= ~(1<<11);
-        }
-        rt_thread_delay(1000);
-        if(Read_Ntc_Voltage()==0)
-        {
-            HMI_WRITE("selfcheck.t15.bco=63488");
-        }
-        else{
-            HMI_WRITE("selfcheck.t15.bco=2024");
-        }
-        rt_thread_delay(1000);
-        if(device_status.bat_status==0)
-        {
-            HMI_WRITE("selfcheck.t5.bco=2024");
-            device_status.C01 &= ~(1<<4);
-        }
-        else
-        {
-            HMI_WRITE("selfcheck.t5.bco=63488");
-            device_status.C01 |= (1<<4);
-        }
-        rt_thread_delay(1000);
-        if(Read_Rain_Voltage()==0)
-        {
-            HMI_WRITE("selfcheck.t6.bco=63488");
-            device_status.C01 |= (1<<5);
-        }
-        else
-        {
-            device_status.C01 &= ~(1<<5);
-            HMI_WRITE("selfcheck.t6.bco=2024");
-        }
-        rt_thread_delay(1000);
-        if(device_status.temp_status)
-        {
-            HMI_WRITE("selfcheck.t8.bco=63488");
-            device_status.C01 |= (1<<7);
-        }
-        else
-        {
-            device_status.C01 &= ~(1<<7);
-            HMI_WRITE("selfcheck.t8.bco=2024");
-        }
-        int sensor_light_value = 0;
-        for(int i = 0;i<3;i++)
-        {
-            sensor_light_value += Read_Light_Voltage();
-            rt_thread_delay(500);
-        }
-        if(sensor_light_value<50)
-        {
-            HMI_WRITE("selfcheck.t7.bco=63488");
-            device_status.C01 |= (1<<6);
-        }
-        else
-        {
-            device_status.C01 &= ~(1<<6);
-            HMI_WRITE("selfcheck.t7.bco=2024");
-        }
-
-        HMI_WRITE("sysSet.va0.txt=\"光控传感器采样数值:%d\"",Read_Light_Voltage());
-        rt_thread_delay(1000);
-    }
-
-    /********************************************************/
-    ctr_lamp(ON, 1);        //打开镇流器
-    rt_thread_delay(1000);
-    for(int i = 0;i<5;i++)
-    {
-        current_i[i] = atoi(device_status.power);
-        rt_thread_delay(1000);
-    }
-    ctr_lamp(OFF, 1);       //关闭镇流器
-    current_open = calculate_average(current_i,5);
-    LOG_W("待机电流:%d",current_);
-    LOG_W("镇流器开启电流:%d",current_open);
-    if(current_open-current_>100)
-    {
-        HMI_WRITE("selfcheck.t1.bco=2024");
-        device_status.C01 &= ~(1<<0);
-        HMI_WRITE("sysSet.va0.txt=\"灯管正常:%d\"",current_open);
-    }
-    else
-    {
-        HMI_WRITE("selfcheck.t1.bco=63488");
-        device_status.C01 |= (1<<0);
-        HMI_WRITE("sysSet.va0.txt=\"灯管异常:%d\"",current_open);
-    }
-    rt_thread_delay(1000);
-    /********************************************************/
-    //打开上仓门
-    ctr_cangmen_up(OPEN);
-    rt_thread_delay(1000);
-    for(int i = 0;i<5;i++)
-    {
-        current_i[i] = atoi(device_status.power);
-        rt_thread_delay(1000);
-    }
-    ctr_cangmen_up(OFF);
-    rt_thread_delay(1000);
-    current_open = calculate_average(current_i,5);
-    LOG_W("上仓门action电流:%d",current_open);
-    if(current_open-current_>100)
-    {
-        HMI_WRITE("selfcheck.t9.bco=2024");
-        device_status.C01 &= ~(1<<8);
-        HMI_WRITE("sysSet.va0.txt=\"上仓门正常:%d\"",current_open);
-    }
-    else{
-        HMI_WRITE("selfcheck.t9.bco=63488");
-        device_status.C01 |= (1<<8);
-        HMI_WRITE("sysSet.va0.txt=\"上仓门故障:%d\"",current_open);
-    }
-    rt_thread_delay(1000);
-    /********************************************************/
-    //打开下仓门
-    ctr_cangmen_down(OPEN);
-    rt_thread_delay(1000);
-    for(int i = 0;i<5;i++)
-    {
-        current_i[i] = atoi(device_status.power);
-        rt_thread_delay(1000);
-    }
-    ctr_cangmen_down(OFF);
-    rt_thread_delay(1000);
-    current_open = calculate_average(current_i,5);
-    LOG_W("下仓门action电流:%d",current_open);
-    if(current_open-current_>100)
-    {
-        HMI_WRITE("selfcheck.t10.bco=2024");
-        device_status.C01 &= ~(1<<9);
-        HMI_WRITE("sysSet.va0.txt=\"下仓门正常:%d\"",current_open);
-    }
-    else{
-        HMI_WRITE("selfcheck.t10.bco=63488");
-        device_status.C01 |= (1<<9);
-        HMI_WRITE("sysSet.va0.txt=\"下仓门故障:%d\"",current_open);
-    }
-    //开启加热
-    rt_thread_delay(1000);
-    if(type==1)
-    {
-        //
-        if(atoi(device_status.heat_power)>5000)
-        {
-            HMI_WRITE("selfcheck.t2.bco=2024");
-            device_status.C01 &= ~(1<<1);
-            HMI_WRITE("sysSet.va0.txt=\"加热正常:%d\"",atoi(device_status.heat_power));
-        }
-        else {
-            ctr_Heat(ON);
-            //持续5S钟
-            for(int i = 5;i>0;i--)
-            {
-                HMI_WRITE("sysSet.va0.txt=\"加热测试中...%d\"",i);
-                rt_thread_delay(1000);
-            }
-            LOG_I("当前温度:%d电流:%s",device_status.heatvalue,device_status.heat_power);
-            //比较当前电压、温度探头温度和开启前
-            if(atoi(device_status.heat_power)>5000)
-            {
-                HMI_WRITE("selfcheck.t2.bco=2024");
-                device_status.C01 &= ~(1<<1);
-                HMI_WRITE("sysSet.va0.txt=\"加热正常:%d\"",atoi(device_status.heat_power));
-            }
-            else
-            {
-                HMI_WRITE("selfcheck.t2.bco=63488");
-                device_status.C01 |= (1<<1);
-                HMI_WRITE("sysSet.va0.txt=\"加热故障:%d\"",atoi(device_status.heat_power));
-            }
-        }
-        ctr_Heat(OFF);
-        rt_thread_delay(1000);
-        /*********************************************************/
-        HMI_WRITE("sysSet.va0.txt=\"开始拍照\"");
-        if(device_status.camsta==0)
-        {
-            rt_timer_start(timer_takephoto);
-            HK_TakePhoto();
-            for(int i = 15;i>0;i--)
-            {
-                HMI_WRITE("sysSet.va0.txt=\"拍照中...%d\"",i);
-                rt_thread_delay(1000);
-            }
-        }else {
-            HMI_WRITE("sysSet.va0.txt=\"相机未连接\"");
-            HMI_WRITE("selfcheck.t4.bco=63488");
-            HMI_WRITE("selfcheck.t3.bco=63488");
-        }
-        rt_thread_delay(1000);
-    }
-    /*******************************************************/
-    //清扫
-    device_status.clear_status = 1;
-    rt_thread_delay(2000);
-    for(int i = 0;i<5;i++)
-    {
-        current_i[i] = atoi(device_status.power);
-        rt_thread_delay(1000);
-    }
-    current_open = calculate_average(current_i,5);
-    LOG_W("清扫action电流:%d@%d",current_open,current_);
-    rt_thread_delay(1000);
-    if(current_open-current_>=100)
-    {
-        HMI_WRITE("selfcheck.t11.bco=2024");
-        device_status.C01 &= ~(1<<10);
-        HMI_WRITE("sysSet.va0.txt=\"清扫正常:%d\"",atoi(device_status.power));
-    }
-    else
-    {
-        HMI_WRITE("selfcheck.t11.bco=63488");
-        device_status.C01 |= (1<<10);
-        HMI_WRITE("sysSet.va0.txt=\"清扫故障:%d\"",atoi(device_status.power));
-    }
-    rt_thread_delay(1000);
-    /*******************************************************/
-    HMI_WRITE("sysSet.va0.txt=\"故障码:%d\"",device_status.C01);
-    char *js = makeJson_C01_Warn(device_status.C01,1.0);
-    DTU_Write("%s",js);
-    free(js);
-    LOG_I("重启线程workloop:%d",thread_restart_workloop());
-    device_status.selfcheck_ws = 0;
-    device_status.process = 0.0;
+    return 0;
 }
 
 //int rt_software_timer_init(void)