|
@@ -14,17 +14,20 @@
|
|
|
#include "easyflash.h"
|
|
#include "easyflash.h"
|
|
|
#include "stdio.h"
|
|
#include "stdio.h"
|
|
|
#include "sound.h"
|
|
#include "sound.h"
|
|
|
-#define DBG_TAG "control.c"
|
|
|
|
|
-#define DBG_LVL LOG_LVL_INFO
|
|
|
|
|
#include "dtu_uart2.h"
|
|
#include "dtu_uart2.h"
|
|
|
#include "sht30_collect.h"
|
|
#include "sht30_collect.h"
|
|
|
|
|
+#define DBG_ENABLE
|
|
|
|
|
+#define DBG_COLOR
|
|
|
|
|
+#define DBG_TAG "control"
|
|
|
|
|
+#define DBG_LEVEL DBG_LOG
|
|
|
|
|
+#include <rtdbg.h> //must after of DBG_LVL, DBG_TAG or other options
|
|
|
//工作检测
|
|
//工作检测
|
|
|
-#define WORK_CHECK_THREAD_PRIORITY 23 //线程优先级
|
|
|
|
|
-#define WORK_CHECK_THREAD_STACK_SIZE 512 //栈大小
|
|
|
|
|
-#define WORK_CHECK_THREAD_TIMESLICE 5 //时间片
|
|
|
|
|
|
|
+#define WORK_CHECK_THREAD_PRIORITY 23 //线程优先级
|
|
|
|
|
+#define WORK_CHECK_THREAD_STACK_SIZE 1024 //栈大小
|
|
|
|
|
+#define WORK_CHECK_THREAD_TIMESLICE 5 //时间片
|
|
|
//工作流程
|
|
//工作流程
|
|
|
#define WORK_LOOP_THREAD_PRIORITY 12 //线程优先级
|
|
#define WORK_LOOP_THREAD_PRIORITY 12 //线程优先级
|
|
|
-#define WORK_LOOP_THREAD_STACK_SIZE 512 //栈大小
|
|
|
|
|
|
|
+#define WORK_LOOP_THREAD_STACK_SIZE 1024 //栈大小
|
|
|
#define WORK_LOOP_THREAD_TIMESLICE 5 //时间片
|
|
#define WORK_LOOP_THREAD_TIMESLICE 5 //时间片
|
|
|
|
|
|
|
|
#define PWM_EN 1 //0关闭,1-打开
|
|
#define PWM_EN 1 //0关闭,1-打开
|
|
@@ -72,60 +75,78 @@ void ctr_Motor_Robot(uint8_t status_ws)
|
|
|
rt_pin_mode(Motor_Direction_Ctr, PIN_MODE_OUTPUT);
|
|
rt_pin_mode(Motor_Direction_Ctr, PIN_MODE_OUTPUT);
|
|
|
rt_pin_write(Motor_Power,OFF);
|
|
rt_pin_write(Motor_Power,OFF);
|
|
|
rt_pin_write(Motor_Direction_Ctr,ON);
|
|
rt_pin_write(Motor_Direction_Ctr,ON);
|
|
|
|
|
+ rt_pin_mode(CLEAR_R, PIN_MODE_OUTPUT);
|
|
|
|
|
+ rt_pin_mode(CLEAR_L, PIN_MODE_OUTPUT);
|
|
|
if(status_ws == ON)
|
|
if(status_ws == ON)
|
|
|
{
|
|
{
|
|
|
//检测按键状态
|
|
//检测按键状态
|
|
|
while(rt_pin_read(Motor_Direction_Button)==1)
|
|
while(rt_pin_read(Motor_Direction_Button)==1)
|
|
|
{
|
|
{
|
|
|
- while(rt_pin_read(LIMIT_CLOSE)==1)
|
|
|
|
|
|
|
+ if(rt_pin_read(LIMIT_CLOSE)==1)
|
|
|
{
|
|
{
|
|
|
rt_pin_write(Motor_Direction_Ctr,ON);
|
|
rt_pin_write(Motor_Direction_Ctr,ON);
|
|
|
close_timeout++;
|
|
close_timeout++;
|
|
|
//打开电机驱动器电源,默认关闭
|
|
//打开电机驱动器电源,默认关闭
|
|
|
rt_pin_write(Motor_Power,ON);
|
|
rt_pin_write(Motor_Power,ON);
|
|
|
- if(close_timeout==1)
|
|
|
|
|
|
|
+ if(close_timeout==2)
|
|
|
{
|
|
{
|
|
|
|
|
+ rt_pin_write(CLEAR_R,ON);
|
|
|
|
|
+ rt_pin_write(CLEAR_L,OFF);
|
|
|
rt_pin_write(Motor_Power,OFF);
|
|
rt_pin_write(Motor_Power,OFF);
|
|
|
- rt_thread_delay(50);
|
|
|
|
|
|
|
+ rt_thread_delay(20);
|
|
|
rt_pin_write(Motor_Power,ON);
|
|
rt_pin_write(Motor_Power,ON);
|
|
|
}
|
|
}
|
|
|
- rt_thread_delay(50);
|
|
|
|
|
|
|
+ rt_thread_delay(20);
|
|
|
if(close_timeout>500)
|
|
if(close_timeout>500)
|
|
|
{
|
|
{
|
|
|
- close_timeout = 500;
|
|
|
|
|
|
|
+ close_timeout = 600;
|
|
|
rt_pin_write(Motor_Power,OFF);
|
|
rt_pin_write(Motor_Power,OFF);
|
|
|
|
|
+ rt_pin_write(CLEAR_R,OFF);
|
|
|
|
|
+ rt_pin_write(CLEAR_L,OFF);
|
|
|
}
|
|
}
|
|
|
- ctr_led(ON);
|
|
|
|
|
}
|
|
}
|
|
|
- if(rt_pin_read(LIMIT_CLOSE)==0)
|
|
|
|
|
|
|
+ else
|
|
|
{
|
|
{
|
|
|
|
|
+ close_timeout = 0;
|
|
|
rt_pin_write(Motor_Power,OFF); //关闭驱动器电源
|
|
rt_pin_write(Motor_Power,OFF); //关闭驱动器电源
|
|
|
|
|
+ rt_pin_write(CLEAR_R,OFF);
|
|
|
|
|
+ rt_pin_write(CLEAR_L,OFF);
|
|
|
}
|
|
}
|
|
|
- rt_thread_delay(50);
|
|
|
|
|
- open_timeout = 0;
|
|
|
|
|
|
|
+ rt_thread_delay(20);
|
|
|
}
|
|
}
|
|
|
rt_pin_write(Motor_Power,OFF);
|
|
rt_pin_write(Motor_Power,OFF);
|
|
|
rt_thread_delay(1000*2);
|
|
rt_thread_delay(1000*2);
|
|
|
while(rt_pin_read(Motor_Direction_Button)==0)
|
|
while(rt_pin_read(Motor_Direction_Button)==0)
|
|
|
{
|
|
{
|
|
|
- while(rt_pin_read(LIMIT_OPEN)==1)
|
|
|
|
|
|
|
+ if(rt_pin_read(LIMIT_OPEN)==1)
|
|
|
{
|
|
{
|
|
|
open_timeout ++;
|
|
open_timeout ++;
|
|
|
//打开电机驱动器电源,默认关闭
|
|
//打开电机驱动器电源,默认关闭
|
|
|
|
|
+ if(open_timeout==2){
|
|
|
|
|
+ rt_pin_write(CLEAR_R,OFF);
|
|
|
|
|
+ rt_pin_write(CLEAR_L,ON);
|
|
|
|
|
+ }
|
|
|
rt_pin_write(Motor_Power,ON);
|
|
rt_pin_write(Motor_Power,ON);
|
|
|
rt_pin_write(Motor_Direction_Ctr,OFF);
|
|
rt_pin_write(Motor_Direction_Ctr,OFF);
|
|
|
if(open_timeout>500)
|
|
if(open_timeout>500)
|
|
|
{
|
|
{
|
|
|
- open_timeout = 500;
|
|
|
|
|
|
|
+ open_timeout = 600;
|
|
|
rt_pin_write(Motor_Power,OFF);
|
|
rt_pin_write(Motor_Power,OFF);
|
|
|
|
|
+ rt_pin_write(CLEAR_R,OFF);
|
|
|
|
|
+ rt_pin_write(CLEAR_L,OFF);
|
|
|
}
|
|
}
|
|
|
- rt_thread_delay(50);
|
|
|
|
|
|
|
+ rt_thread_delay(20);
|
|
|
}
|
|
}
|
|
|
if(rt_pin_read(LIMIT_OPEN)==0)
|
|
if(rt_pin_read(LIMIT_OPEN)==0)
|
|
|
- rt_pin_write(Motor_Power,OFF);
|
|
|
|
|
- rt_thread_delay(50);
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ open_timeout = 0;
|
|
|
|
|
+ rt_pin_write(Motor_Power,OFF);
|
|
|
|
|
+ rt_pin_write(CLEAR_R,OFF);
|
|
|
|
|
+ rt_pin_write(CLEAR_L,OFF);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ rt_thread_delay(20);
|
|
|
close_timeout = 0;
|
|
close_timeout = 0;
|
|
|
- ctr_led(ON);
|
|
|
|
|
}
|
|
}
|
|
|
open_timeout = 0;
|
|
open_timeout = 0;
|
|
|
close_timeout = 0;
|
|
close_timeout = 0;
|
|
@@ -263,13 +284,74 @@ uint8_t ctr_Heat(uint8_t status_heat)
|
|
|
rt_pin_write(Heat_Pin,status_heat);
|
|
rt_pin_write(Heat_Pin,status_heat);
|
|
|
return status_heat;
|
|
return status_heat;
|
|
|
}
|
|
}
|
|
|
|
|
+/*制冷*/
|
|
|
|
|
+uint8_t ctr_Cold(uint8_t status_cold)
|
|
|
|
|
+{
|
|
|
|
|
+ device_status.cold_status = status_cold;
|
|
|
|
|
+ rt_pin_mode(Cold_Pin, PIN_MODE_OUTPUT);
|
|
|
|
|
+ rt_pin_write(Cold_Pin,status_cold);
|
|
|
|
|
+ return status_cold;
|
|
|
|
|
+}
|
|
|
/*相机供电*/
|
|
/*相机供电*/
|
|
|
void ctr_photo(uint8_t status_photo)
|
|
void ctr_photo(uint8_t 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);
|
|
|
}
|
|
}
|
|
|
-/*采集风机/上仓门*/
|
|
|
|
|
|
|
+/*************************************************
|
|
|
|
|
+Function: ctr_Cool_Fan
|
|
|
|
|
+Description: 散热风机的开关
|
|
|
|
|
+Calls:
|
|
|
|
|
+Table Accessed: // 被访问的表(此项仅对于牵扯到数据库操作的程序)
|
|
|
|
|
+Table Updated: // 被修改的表(此项仅对于牵扯到数据库操作的程序)
|
|
|
|
|
+Input: ON-开,OFF-关
|
|
|
|
|
+Output: NULL
|
|
|
|
|
+Return: ON-开,OFF-关
|
|
|
|
|
+Others: NULL
|
|
|
|
|
+*************************************************/
|
|
|
|
|
+uint8_t ctr_Cool_Fan(uint8_t status_cool)
|
|
|
|
|
+{
|
|
|
|
|
+ device_status.cool_fan_status = status_cool;
|
|
|
|
|
+ rt_pin_mode(Cool_Fan_L, PIN_MODE_OUTPUT);
|
|
|
|
|
+ rt_pin_mode(Cool_Fan_R, PIN_MODE_OUTPUT);
|
|
|
|
|
+ if(status_cool==OFF)
|
|
|
|
|
+ {
|
|
|
|
|
+ rt_pin_write(Cool_Fan_L,OFF);
|
|
|
|
|
+ rt_pin_write(Cool_Fan_R,OFF);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(status_cool==ON)
|
|
|
|
|
+ {
|
|
|
|
|
+ rt_pin_write(Cool_Fan_L,ON);
|
|
|
|
|
+ rt_pin_write(Cool_Fan_R,OFF);
|
|
|
|
|
+ }
|
|
|
|
|
+ return device_status.cool_fan_status;
|
|
|
|
|
+}
|
|
|
|
|
+/*************************************************
|
|
|
|
|
+Function: ctr_Collect_Fan
|
|
|
|
|
+Description: 采集风机的开关
|
|
|
|
|
+Calls:
|
|
|
|
|
+Table Accessed: // 被访问的表(此项仅对于牵扯到数据库操作的程序)
|
|
|
|
|
+Table Updated: // 被修改的表(此项仅对于牵扯到数据库操作的程序)
|
|
|
|
|
+Input: ON-开,OFF-关
|
|
|
|
|
+Output: NULL
|
|
|
|
|
+Return: ON-开,OFF-关
|
|
|
|
|
+Others: NULL
|
|
|
|
|
+*************************************************/
|
|
|
|
|
+uint8_t ctr_Collect_Fan(uint8_t status_collect)
|
|
|
|
|
+{
|
|
|
|
|
+ device_status.collect_fan_status = status_collect;
|
|
|
|
|
+ rt_pin_mode(Collect_Fan, PIN_MODE_OUTPUT);
|
|
|
|
|
+ if(status_collect==OFF)
|
|
|
|
|
+ {
|
|
|
|
|
+ rt_pin_write(Collect_Fan,OFF);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(status_collect==ON)
|
|
|
|
|
+ {
|
|
|
|
|
+ rt_pin_write(Collect_Fan,ON);
|
|
|
|
|
+ }
|
|
|
|
|
+ return device_status.collect_fan_status;
|
|
|
|
|
+}
|
|
|
|
|
+/*上仓门*/
|
|
|
uint8_t ctr_cangmen_up(uint8_t status_up)
|
|
uint8_t ctr_cangmen_up(uint8_t status_up)
|
|
|
{
|
|
{
|
|
|
rt_pin_mode(Collect_fan_R, PIN_MODE_OUTPUT);
|
|
rt_pin_mode(Collect_fan_R, PIN_MODE_OUTPUT);
|
|
@@ -387,7 +469,8 @@ uint8_t ctr_shake(uint8_t status_shake,uint16_t shake_sec)
|
|
|
if(status_shake==ON&&device_status.shake_ws==1)
|
|
if(status_shake==ON&&device_status.shake_ws==1)
|
|
|
{
|
|
{
|
|
|
rt_pin_write(SHAKE_SW,ON);
|
|
rt_pin_write(SHAKE_SW,ON);
|
|
|
- rt_thread_delay(shake_sec*100);
|
|
|
|
|
|
|
+ if(device_status.dtype==3) rt_thread_delay(shake_sec*100);
|
|
|
|
|
+ if(device_status.dtype==7) rt_thread_delay(shake_sec*1000);
|
|
|
rt_pin_write(SHAKE_SW,OFF);
|
|
rt_pin_write(SHAKE_SW,OFF);
|
|
|
HMI_WRITE("cangWei.switchShake.val=%d",0);
|
|
HMI_WRITE("cangWei.switchShake.val=%d",0);
|
|
|
}
|
|
}
|
|
@@ -396,6 +479,8 @@ uint8_t ctr_shake(uint8_t status_shake,uint16_t shake_sec)
|
|
|
rt_pin_write(SHAKE_SW,OFF);
|
|
rt_pin_write(SHAKE_SW,OFF);
|
|
|
HMI_WRITE("cangWei.switchShake.val=%d",0);
|
|
HMI_WRITE("cangWei.switchShake.val=%d",0);
|
|
|
}
|
|
}
|
|
|
|
|
+ if(device_status.dtype==7)
|
|
|
|
|
+ HMI_WRITE("sysTest.switchDrop.val=%d",OFF);
|
|
|
return status_shake;
|
|
return status_shake;
|
|
|
}
|
|
}
|
|
|
//补光
|
|
//补光
|
|
@@ -420,7 +505,165 @@ uint8_t ctr_led(uint8_t status_led)
|
|
|
}
|
|
}
|
|
|
return 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)
|
|
|
|
|
+{
|
|
|
|
|
+ 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);
|
|
|
|
|
+ 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);
|
|
|
|
|
+ char *turn_warn ="limit timeout!!!";
|
|
|
|
|
+ DTU_Write(makeJson_Warn(turn_warn, "ERR"));
|
|
|
|
|
+ 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);
|
|
|
|
|
+ rt_thread_delay(10);
|
|
|
|
|
+ turn_cnt ++;
|
|
|
|
|
+ if(turn_cnt==5000)
|
|
|
|
|
+ {
|
|
|
|
|
+ turn_cnt = 0;
|
|
|
|
|
+ rt_pin_write(TURN_ZP_R, OFF);
|
|
|
|
|
+ rt_pin_write(TURN_ZP_L, OFF);
|
|
|
|
|
+ char *turn_warn ="turn timrout!!!";
|
|
|
|
|
+ DTU_Write(makeJson_Warn(turn_warn, "ERR"));
|
|
|
|
|
+ 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);
|
|
|
|
|
+ rt_thread_delay(10);
|
|
|
|
|
+ turn_cnt ++;
|
|
|
|
|
+ if(turn_cnt==5000)
|
|
|
|
|
+ {
|
|
|
|
|
+ turn_cnt = 0;
|
|
|
|
|
+ rt_pin_write(TURN_ZP_R, OFF);
|
|
|
|
|
+ rt_pin_write(TURN_ZP_L, OFF);
|
|
|
|
|
+ char *turn_warn ="turn timrout!!!";
|
|
|
|
|
+ DTU_Write(makeJson_Warn(turn_warn, "ERR"));
|
|
|
|
|
+ rt_free(turn_warn);
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ turn_cnt = 0;
|
|
|
|
|
+ rt_pin_write(TURN_ZP_R, OFF);
|
|
|
|
|
+ rt_pin_write(TURN_ZP_L, OFF);
|
|
|
|
|
+ HMI_WRITE("cangWei.rotateFlag.val=0");
|
|
|
|
|
+}
|
|
|
|
|
+/*************************************************
|
|
|
|
|
+Function: ctr_Motor_Driver
|
|
|
|
|
+Description: 步进电机驱动
|
|
|
|
|
+Calls:
|
|
|
|
|
+Table Accessed: // 被访问的表(此项仅对于牵扯到数据库操作的程序)
|
|
|
|
|
+Table Updated: // 被修改的表(此项仅对于牵扯到数据库操作的程序)
|
|
|
|
|
+Input: 50000000
|
|
|
|
|
+Output: NULL
|
|
|
|
|
+Return: shake_sec
|
|
|
|
|
+Others: NULL
|
|
|
|
|
+*************************************************/
|
|
|
|
|
+void ctr_Motor_Driver(uint8_t EN,uint8_t DIR,rt_uint32_t pwm,rt_uint32_t time_out)
|
|
|
|
|
+{
|
|
|
|
|
+ beep_init();
|
|
|
|
|
+ rt_pin_mode(Motor_Power, PIN_MODE_OUTPUT);
|
|
|
|
|
+ rt_pin_mode(LIMIT_UP, PIN_MODE_INPUT);
|
|
|
|
|
+ rt_pin_mode(LIMIT_DOWN, PIN_MODE_INPUT);
|
|
|
|
|
+ rt_pin_mode(Motor_EN, PIN_MODE_OUTPUT);
|
|
|
|
|
+ rt_pin_mode(Motor_DIR, PIN_MODE_OUTPUT);
|
|
|
|
|
+ if(EN==2)
|
|
|
|
|
+ {
|
|
|
|
|
+ rt_pin_write(Motor_EN, 0);
|
|
|
|
|
+ rt_pin_write(HK_TAKE, 0); //使能步进电机2
|
|
|
|
|
+ }
|
|
|
|
|
+ else if(EN==0)
|
|
|
|
|
+ {
|
|
|
|
|
+ rt_pin_write(Motor_Power,0);
|
|
|
|
|
+ }
|
|
|
|
|
+ else{
|
|
|
|
|
+ rt_pin_write(Motor_EN, EN);
|
|
|
|
|
+ rt_pin_write(Motor_Power,1);
|
|
|
|
|
+ }
|
|
|
|
|
+ rt_pin_write(Motor_DIR, DIR);
|
|
|
|
|
+ beep_set(pwm, pwm/2); //200kzh - 50%
|
|
|
|
|
+ while(DIR==1&&rt_pin_read(LIMIT_DOWN)==1)
|
|
|
|
|
+ {
|
|
|
|
|
+ if(time_out==0)
|
|
|
|
|
+ {
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ rt_thread_delay(50);
|
|
|
|
|
+ time_out --;
|
|
|
|
|
+ }
|
|
|
|
|
+ while(DIR==0&&rt_pin_read(LIMIT_UP)==1)
|
|
|
|
|
+ {
|
|
|
|
|
+ if(time_out==0)
|
|
|
|
|
+ {
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ rt_thread_delay(50);
|
|
|
|
|
+ time_out --;
|
|
|
|
|
+ }
|
|
|
|
|
+ rt_pin_write(Motor_EN, OFF);
|
|
|
|
|
+ rt_pin_write(HK_TAKE,OFF); //双电机此处ON
|
|
|
|
|
+ beep_set(0, 0); //200kzh - 50%
|
|
|
|
|
+}
|
|
|
|
|
+/*************************************************
|
|
|
|
|
+Function: ctr_Petroleum_jelly
|
|
|
|
|
+Description: 涂凡士林
|
|
|
|
|
+Calls:
|
|
|
|
|
+Table Accessed: // 被访问的表(此项仅对于牵扯到数据库操作的程序)
|
|
|
|
|
+Table Updated: // 被修改的表(此项仅对于牵扯到数据库操作的程序)
|
|
|
|
|
+Input: NULL
|
|
|
|
|
+Output: NULL
|
|
|
|
|
+Return: NULL
|
|
|
|
|
+Others: NULL
|
|
|
|
|
+*************************************************/
|
|
|
|
|
+void ctr_Petroleum_jelly(rt_uint32_t delay)
|
|
|
|
|
+{
|
|
|
|
|
+ beep_init();
|
|
|
|
|
+ pwm_on(2,50000);
|
|
|
|
|
+ rt_thread_delay(delay*1000);
|
|
|
|
|
+ pwm_off(2,0);
|
|
|
|
|
+ rt_thread_delay(1000);
|
|
|
|
|
+ pwm_on(3, 50000);
|
|
|
|
|
+ rt_thread_delay(delay*1000);
|
|
|
|
|
+ pwm_off(3,0);
|
|
|
|
|
+ device_status.fsl_sw = 0;
|
|
|
|
|
+}
|
|
|
|
|
+//1.0转仓
|
|
|
void turnzp(void)
|
|
void turnzp(void)
|
|
|
{
|
|
{
|
|
|
static uint16_t turn_timeout = 0;
|
|
static uint16_t turn_timeout = 0;
|
|
@@ -887,61 +1130,24 @@ void HardWare_Init(uint8_t boot)
|
|
|
//关闭上仓门
|
|
//关闭上仓门
|
|
|
ctr_cangmen_up(OFF);
|
|
ctr_cangmen_up(OFF);
|
|
|
|
|
|
|
|
- if(boot==1)
|
|
|
|
|
- {
|
|
|
|
|
- HMI_WRITE("hardcheck.checktip.txt=\"上仓门电机已停止!!!\"");
|
|
|
|
|
- rt_thread_delay(1000);
|
|
|
|
|
- }
|
|
|
|
|
//关闭下仓门电机
|
|
//关闭下仓门电机
|
|
|
ctr_cangmen_down(OFF);
|
|
ctr_cangmen_down(OFF);
|
|
|
- if(boot==1)
|
|
|
|
|
- {
|
|
|
|
|
- HMI_WRITE("hardcheck.checktip.txt=\"下仓门电机已停止!!!\"");
|
|
|
|
|
- rt_thread_delay(1000);
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
//关闭镇流器
|
|
//关闭镇流器
|
|
|
ctr_lamp(OFF,1);
|
|
ctr_lamp(OFF,1);
|
|
|
- if(boot==1)
|
|
|
|
|
- {
|
|
|
|
|
- HMI_WRITE("hardcheck.checktip.txt=\"镇流器已关闭!!!\"");
|
|
|
|
|
- rt_thread_delay(1000);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
//关闭震动电机
|
|
//关闭震动电机
|
|
|
ctr_shake(OFF,0);
|
|
ctr_shake(OFF,0);
|
|
|
- if(boot==1)
|
|
|
|
|
- {
|
|
|
|
|
- HMI_WRITE("hardcheck.checktip.txt=\"震动电机已关闭!!!\"");
|
|
|
|
|
- rt_thread_delay(1000);
|
|
|
|
|
- }
|
|
|
|
|
- //关闭清扫电机
|
|
|
|
|
|
|
|
|
|
- if(boot==1)
|
|
|
|
|
- {
|
|
|
|
|
- HMI_WRITE("hardcheck.checktip.txt=\"清扫电机已关闭!!!\"");
|
|
|
|
|
- rt_thread_delay(1000);
|
|
|
|
|
- }
|
|
|
|
|
//关闭加热
|
|
//关闭加热
|
|
|
ctr_Heat(OFF);
|
|
ctr_Heat(OFF);
|
|
|
- if(boot==1)
|
|
|
|
|
- {
|
|
|
|
|
- HMI_WRITE("hardcheck.checktip.txt=\"加热带已关闭!!!\"");
|
|
|
|
|
- rt_thread_delay(1000);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
//关闭补光灯
|
|
//关闭补光灯
|
|
|
ctr_led(OFF);
|
|
ctr_led(OFF);
|
|
|
- if(boot==1)
|
|
|
|
|
- {
|
|
|
|
|
- HMI_WRITE("hardcheck.checktip.txt=\"补光灯已关闭!!!\"");
|
|
|
|
|
- rt_thread_delay(1000);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
//关闭12V供电(海康相机,RTU)
|
|
//关闭12V供电(海康相机,RTU)
|
|
|
ctr_photo(OFF);
|
|
ctr_photo(OFF);
|
|
|
- if(boot==1)
|
|
|
|
|
- {
|
|
|
|
|
- HMI_WRITE("hardcheck.checktip.txt=\"12V供电已关闭!!!\"");
|
|
|
|
|
- rt_thread_delay(1000);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
//拍照
|
|
//拍照
|
|
|
void HK_TakePhoto(void)
|
|
void HK_TakePhoto(void)
|
|
@@ -1016,27 +1222,27 @@ void ResetInit(void)
|
|
|
ctr_led(OFF);
|
|
ctr_led(OFF);
|
|
|
if(device_status.bat_status==1||atoi(device_status.fuse_voltage)<1)
|
|
if(device_status.bat_status==1||atoi(device_status.fuse_voltage)<1)
|
|
|
{
|
|
{
|
|
|
- rt_kprintf("欠压!!!\n");
|
|
|
|
|
|
|
+ LOG_W("欠压!");
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
//7.关闭上仓门
|
|
//7.关闭上仓门
|
|
|
device_status.ctr_up_motor = 2;
|
|
device_status.ctr_up_motor = 2;
|
|
|
while(device_status.ctr_up_motor!=0)
|
|
while(device_status.ctr_up_motor!=0)
|
|
|
{
|
|
{
|
|
|
- rt_kprintf("关闭上仓门...\n");
|
|
|
|
|
|
|
+ LOG_I("关闭上仓门...");
|
|
|
rt_thread_delay(100);
|
|
rt_thread_delay(100);
|
|
|
}
|
|
}
|
|
|
//8.关闭下仓门
|
|
//8.关闭下仓门
|
|
|
device_status.ctr_down_motor = 2;
|
|
device_status.ctr_down_motor = 2;
|
|
|
while(device_status.ctr_down_motor!=0)
|
|
while(device_status.ctr_down_motor!=0)
|
|
|
{
|
|
{
|
|
|
- rt_kprintf("关闭下仓门....\n");
|
|
|
|
|
|
|
+ LOG_I("关闭下仓门....");
|
|
|
rt_thread_delay(100);
|
|
rt_thread_delay(100);
|
|
|
}
|
|
}
|
|
|
//9.清扫
|
|
//9.清扫
|
|
|
if(device_status.bat_status == 1 || device_status.temp_status == 1|| device_status.rain_status==1)
|
|
if(device_status.bat_status == 1 || device_status.temp_status == 1|| device_status.rain_status==1)
|
|
|
{
|
|
{
|
|
|
- rt_kprintf("异常退出!!!\n");
|
|
|
|
|
|
|
+ LOG_W("异常退出!!!\n");
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
#if LAMP_EN == 0
|
|
#if LAMP_EN == 0
|
|
@@ -1045,8 +1251,6 @@ void ResetInit(void)
|
|
|
#endif
|
|
#endif
|
|
|
if(device_status.version_type==4||device_status.version_type==41)
|
|
if(device_status.version_type==4||device_status.version_type==41)
|
|
|
{
|
|
{
|
|
|
-// if(ctr_clear(650)==0)
|
|
|
|
|
-// ctr_TG_Clear(400);
|
|
|
|
|
device_status.clear_status=1;
|
|
device_status.clear_status=1;
|
|
|
}
|
|
}
|
|
|
else if (device_status.version_type==1) {
|
|
else if (device_status.version_type==1) {
|
|
@@ -1097,11 +1301,11 @@ void WorkCheck(void)
|
|
|
//工作模式检测(RTC时间正常,1-时控/0-光控)(RTC时间异常强行使用光控)
|
|
//工作模式检测(RTC时间正常,1-时控/0-光控)(RTC时间异常强行使用光控)
|
|
|
if(device_status.timeSwitch==1)
|
|
if(device_status.timeSwitch==1)
|
|
|
{
|
|
{
|
|
|
- rt_kprintf("***************时控*****************\n");
|
|
|
|
|
|
|
+ LOG_I("***********时控*****************");
|
|
|
//如果开始和结束是同一天
|
|
//如果开始和结束是同一天
|
|
|
if(device_status.startBar<device_status.stopBar)
|
|
if(device_status.startBar<device_status.stopBar)
|
|
|
{
|
|
{
|
|
|
- rt_kprintf("开始和结束是同一天");
|
|
|
|
|
|
|
+ LOG_I("开始和结束是同一天");
|
|
|
time_t now;
|
|
time_t now;
|
|
|
time(&now);
|
|
time(&now);
|
|
|
static struct tm nowtime; //现在
|
|
static struct tm nowtime; //现在
|
|
@@ -1120,22 +1324,22 @@ void WorkCheck(void)
|
|
|
endtime.tm_hour = device_status.stopBar-8;
|
|
endtime.tm_hour = device_status.stopBar-8;
|
|
|
endtime.tm_min = 0;
|
|
endtime.tm_min = 0;
|
|
|
endtime.tm_sec = 0;
|
|
endtime.tm_sec = 0;
|
|
|
- rt_kprintf("***工作结束在当天:现在时间:%d-开始时间:%d-结束时间:%d***\n",mktime(&nowtime),mktime(&starttime),mktime(&endtime));
|
|
|
|
|
|
|
+ LOG_I("***工作结束在当天:现在时间:%d-开始时间:%d-结束时间:%d***",mktime(&nowtime),mktime(&starttime),mktime(&endtime));
|
|
|
//如果当前时间大于开始时间且小于结束时间,且没有开始工作
|
|
//如果当前时间大于开始时间且小于结束时间,且没有开始工作
|
|
|
if((difftime(mktime(&nowtime), mktime(&starttime)) >=0) && (difftime(mktime(&nowtime),mktime(&endtime))<0))
|
|
if((difftime(mktime(&nowtime), mktime(&starttime)) >=0) && (difftime(mktime(&nowtime),mktime(&endtime))<0))
|
|
|
{
|
|
{
|
|
|
- rt_kprintf("当前时间大于开始时间,小于结束时间,工作中!!!\n");
|
|
|
|
|
|
|
+ LOG_I("当前时间大于开始时间,小于结束时间,工作中!!!");
|
|
|
device_status.work_status = 1;
|
|
device_status.work_status = 1;
|
|
|
}
|
|
}
|
|
|
//如果当前时间小于开始时间
|
|
//如果当前时间小于开始时间
|
|
|
else if(difftime(mktime(&nowtime),mktime(&starttime))<0)
|
|
else if(difftime(mktime(&nowtime),mktime(&starttime))<0)
|
|
|
{
|
|
{
|
|
|
- rt_kprintf("当前时间小于开始时间,不工作!!!-%d-%d\n",mktime(&nowtime),mktime(&starttime));
|
|
|
|
|
|
|
+ LOG_I("当前时间小于开始时间,不工作!!!-%d-%d",mktime(&nowtime),mktime(&starttime));
|
|
|
device_status.work_status = 0;
|
|
device_status.work_status = 0;
|
|
|
}
|
|
}
|
|
|
//当前时间大于结束时间
|
|
//当前时间大于结束时间
|
|
|
else {
|
|
else {
|
|
|
- rt_kprintf("当前时间大于结束时间,不工作!!!-%d-%d\n",mktime(&nowtime),mktime(&starttime));
|
|
|
|
|
|
|
+ LOG_I("当前时间大于结束时间,不工作!!!-%d-%d",mktime(&nowtime),mktime(&starttime));
|
|
|
device_status.work_status = 0;
|
|
device_status.work_status = 0;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -1159,7 +1363,7 @@ void WorkCheck(void)
|
|
|
endtime.tm_hour = device_status.stopBar-8;
|
|
endtime.tm_hour = device_status.stopBar-8;
|
|
|
endtime.tm_min = 0;
|
|
endtime.tm_min = 0;
|
|
|
endtime.tm_sec = 0;
|
|
endtime.tm_sec = 0;
|
|
|
- rt_kprintf("工作结束在第二天:现在时间:%d-开始时间:%d-结束时间:%d!!!\n",mktime(&nowtime),mktime(&starttime),mktime(&endtime));
|
|
|
|
|
|
|
+ LOG_I("工作结束在第二天:现在时间:%d-开始时间:%d-结束时间:%d!!!",mktime(&nowtime),mktime(&starttime),mktime(&endtime));
|
|
|
//如果当前时间大于开始时间,且没有开始工作 ,注意时间戳日期加1
|
|
//如果当前时间大于开始时间,且没有开始工作 ,注意时间戳日期加1
|
|
|
if((difftime(mktime(&nowtime), mktime(&starttime)) > 0 ))
|
|
if((difftime(mktime(&nowtime), mktime(&starttime)) > 0 ))
|
|
|
{
|
|
{
|
|
@@ -1169,7 +1373,7 @@ void WorkCheck(void)
|
|
|
endtime.tm_min = 0;
|
|
endtime.tm_min = 0;
|
|
|
endtime.tm_sec = 0;
|
|
endtime.tm_sec = 0;
|
|
|
device_status.work_status = 1;
|
|
device_status.work_status = 1;
|
|
|
- rt_kprintf("当前前时间大于开始时间,且没有开始工作\n");
|
|
|
|
|
|
|
+ LOG_I("当前前时间大于开始时间,且没有开始工作");
|
|
|
}
|
|
}
|
|
|
//当前时间小于开始时间
|
|
//当前时间小于开始时间
|
|
|
else if ((difftime(mktime(&nowtime), mktime(&starttime)) < 0))
|
|
else if ((difftime(mktime(&nowtime), mktime(&starttime)) < 0))
|
|
@@ -1182,12 +1386,12 @@ void WorkCheck(void)
|
|
|
//如果当前时间戳小于结束时间戳
|
|
//如果当前时间戳小于结束时间戳
|
|
|
if(difftime(mktime(&nowtime),mktime(&endtime)) < 0)
|
|
if(difftime(mktime(&nowtime),mktime(&endtime)) < 0)
|
|
|
{
|
|
{
|
|
|
- rt_kprintf("当前时间大于开始时间,且没有开始工作,当前时间小于结束时间的情况:计算工作时间:从当前时间工作第二天的结束时间\n");
|
|
|
|
|
|
|
+ LOG_I("当前时间大于开始时间,且没有开始工作,当前时间小于结束时间的情况:计算工作时间:从当前时间工作第二天的结束时间");
|
|
|
device_status.work_status = 1;
|
|
device_status.work_status = 1;
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
- rt_kprintf("当前时间小于开始时间,且没有开始工作,不是重启引起的,即还没到开始时间!!!\n");
|
|
|
|
|
|
|
+ LOG_I("当前时间小于开始时间,且没有开始工作,不是重启引起的,即还没到开始时间");
|
|
|
device_status.work_status = 0; //不在工作时间,待机
|
|
device_status.work_status = 0; //不在工作时间,待机
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1196,7 +1400,7 @@ void WorkCheck(void)
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
- rt_kprintf("光控定时模式!!!\n");
|
|
|
|
|
|
|
+ LOG_I("光控定时模式!");
|
|
|
/*
|
|
/*
|
|
|
time_t now;
|
|
time_t now;
|
|
|
time(&now);
|
|
time(&now);
|
|
@@ -1219,25 +1423,25 @@ void WorkCheck(void)
|
|
|
device_status.lamp_status = 1;
|
|
device_status.lamp_status = 1;
|
|
|
device_status.lamp1_status = 0;
|
|
device_status.lamp1_status = 0;
|
|
|
device_status.lamp2_status = 0;
|
|
device_status.lamp2_status = 0;
|
|
|
- rt_kprintf("光控定时,计时中:光源1计数:%d\n",device_status.light_over_tim);
|
|
|
|
|
|
|
+ LOG_I("光控定时,计时中:光源1计数:%d",device_status.light_over_tim);
|
|
|
}
|
|
}
|
|
|
else if (device_status.light_over_tim<device_status.light_over_tim-6*3600&&device_status.light_over_tim>3*3600) {
|
|
else if (device_status.light_over_tim<device_status.light_over_tim-6*3600&&device_status.light_over_tim>3*3600) {
|
|
|
device_status.work_status = 1;
|
|
device_status.work_status = 1;
|
|
|
device_status.lamp_status = 0;
|
|
device_status.lamp_status = 0;
|
|
|
device_status.lamp1_status = 1;
|
|
device_status.lamp1_status = 1;
|
|
|
device_status.lamp2_status = 0;
|
|
device_status.lamp2_status = 0;
|
|
|
- rt_kprintf("光控定时,计时中:光源2计数:%d\n",device_status.light_over_tim);
|
|
|
|
|
|
|
+ LOG_I("光控定时,计时中:光源2计数:%d",device_status.light_over_tim);
|
|
|
}
|
|
}
|
|
|
else if (device_status.light_over_tim<3*3600) {
|
|
else if (device_status.light_over_tim<3*3600) {
|
|
|
device_status.work_status = 1;
|
|
device_status.work_status = 1;
|
|
|
device_status.lamp_status = 0;
|
|
device_status.lamp_status = 0;
|
|
|
device_status.lamp1_status = 0;
|
|
device_status.lamp1_status = 0;
|
|
|
device_status.lamp2_status = 1;
|
|
device_status.lamp2_status = 1;
|
|
|
- rt_kprintf("光控定时,计时中:光源3计数:%d\n",device_status.light_over_tim);
|
|
|
|
|
|
|
+ LOG_I("光控定时,计时中:光源3计数:%d",device_status.light_over_tim);
|
|
|
}
|
|
}
|
|
|
#else
|
|
#else
|
|
|
device_status.work_status = 1;;
|
|
device_status.work_status = 1;;
|
|
|
- rt_kprintf("光控定时,计时中>>>>>>>>>:%d\n",device_status.light_over_tim);
|
|
|
|
|
|
|
+ LOG_I("光控定时,计时中>>>>>>>>>:%d",device_status.light_over_tim);
|
|
|
#endif
|
|
#endif
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
@@ -1252,12 +1456,12 @@ void WorkCheck(void)
|
|
|
}
|
|
}
|
|
|
device_status.work_status = 0;
|
|
device_status.work_status = 0;
|
|
|
if(device_status.light_over_tim==0&&device_status.sun_status==1) device_status.light_over_tim = device_status.sunBar * 3600;
|
|
if(device_status.light_over_tim==0&&device_status.sun_status==1) device_status.light_over_tim = device_status.sunBar * 3600;
|
|
|
- rt_kprintf("光控中,白天:%d!!!\n",device_status.sun_status);
|
|
|
|
|
|
|
+ LOG_I("光控中,白天:%d!!!",device_status.sun_status);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
rt_thread_delay(1000);
|
|
rt_thread_delay(1000);
|
|
|
}
|
|
}
|
|
|
- rt_kprintf("雨控状态,温控状态,电压状态:\n%d\n%d\n%d\n",device_status.rain_status,device_status.temp_status,device_status.bat_status);
|
|
|
|
|
|
|
+ LOG_I("雨控状态,温控状态,电压状态:%d-%d-%d",device_status.rain_status,device_status.temp_status,device_status.bat_status);
|
|
|
device_status.work_status = 0;
|
|
device_status.work_status = 0;
|
|
|
rt_thread_delay(1000);
|
|
rt_thread_delay(1000);
|
|
|
}
|
|
}
|
|
@@ -1269,8 +1473,8 @@ void WorkTask(void)
|
|
|
static int clt_time = 0; //收集时间差秒数
|
|
static int clt_time = 0; //收集时间差秒数
|
|
|
static int heat_time = 0;
|
|
static int heat_time = 0;
|
|
|
static uint16_t controltime = 6;
|
|
static uint16_t controltime = 6;
|
|
|
- rt_kprintf("工作状态:%d\n",device_status.work_status);
|
|
|
|
|
- rt_kprintf("开关机状态:%d\n",device_status.ds);
|
|
|
|
|
|
|
+ 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)
|
|
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;
|
|
device_status.work_done = 0;
|
|
@@ -1391,12 +1595,18 @@ void WorkTask(void)
|
|
|
// rt_kprintf("等待上仓门关闭!!!\n");
|
|
// rt_kprintf("等待上仓门关闭!!!\n");
|
|
|
// }
|
|
// }
|
|
|
//5.加热
|
|
//5.加热
|
|
|
- heat_time = device_status.heattime * 60;
|
|
|
|
|
- while(heat_time!=0)
|
|
|
|
|
|
|
+ if(device_status.heat_ws==1)
|
|
|
{
|
|
{
|
|
|
- heat_time--;
|
|
|
|
|
- rt_kprintf("正在加热状态!!!\n");
|
|
|
|
|
- rt_thread_delay(1000);
|
|
|
|
|
|
|
+ calorstat(device_status.heattime*60);
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ heat_time = device_status.heattime * 60;
|
|
|
|
|
+ while(heat_time!=0)
|
|
|
|
|
+ {
|
|
|
|
|
+ heat_time--;
|
|
|
|
|
+ LOG_I("正在加热状态!!!");
|
|
|
|
|
+ rt_thread_delay(1000);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
//6.打开下仓门
|
|
//6.打开下仓门
|
|
|
if(device_status.rain_status==0)
|
|
if(device_status.rain_status==0)
|
|
@@ -1485,17 +1695,6 @@ static void Work_status_thread_entry(void *parameter)
|
|
|
rt_thread_delay(1000);
|
|
rt_thread_delay(1000);
|
|
|
rt_kprintf("开机光控检测:%d\n",sun_status_num);
|
|
rt_kprintf("开机光控检测:%d\n",sun_status_num);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- /*//2022-02-26-remove
|
|
|
|
|
- time_t now;
|
|
|
|
|
- time(&now);
|
|
|
|
|
- static struct tm nowstamp;
|
|
|
|
|
- nowstamp =*localtime(&now);
|
|
|
|
|
- nowstamp.tm_hour = nowstamp.tm_hour - 8;
|
|
|
|
|
- static rt_uint32_t nowstamp_num = 0;
|
|
|
|
|
- nowstamp_num = mktime(&nowstamp);
|
|
|
|
|
- ////2022-02-26-remove
|
|
|
|
|
- */
|
|
|
|
|
device_status.light_over_tim = device_status.sunBar * 3600;
|
|
device_status.light_over_tim = device_status.sunBar * 3600;
|
|
|
device_status.test_flag = 0;
|
|
device_status.test_flag = 0;
|
|
|
}
|
|
}
|
|
@@ -1525,19 +1724,9 @@ static void Work_Loop_thread_entry(void *parameter)
|
|
|
/*入口函数清扫*/
|
|
/*入口函数清扫*/
|
|
|
static void Control_Clear_thread_entry(void *parameter)
|
|
static void Control_Clear_thread_entry(void *parameter)
|
|
|
{
|
|
{
|
|
|
- #if ROBOT_EN == 1
|
|
|
|
|
- //磁悬浮供电
|
|
|
|
|
- //监测磁悬浮限位位置
|
|
|
|
|
- //根据位置确定是否 按下按钮
|
|
|
|
|
- rt_pin_mode(EMS_Dir, PIN_MODE_OUTPUT);
|
|
|
|
|
- rt_pin_write(EMS_Dir, 0);
|
|
|
|
|
- rt_thread_delay(50);
|
|
|
|
|
- rt_pin_write(EMS_Dir, 1);
|
|
|
|
|
- #endif
|
|
|
|
|
while(1)
|
|
while(1)
|
|
|
{
|
|
{
|
|
|
#if ROBOT_EN ==1
|
|
#if ROBOT_EN ==1
|
|
|
- ctr_led(ON);
|
|
|
|
|
ctr_Motor_Robot(ON);
|
|
ctr_Motor_Robot(ON);
|
|
|
#else
|
|
#else
|
|
|
if(device_status.clear_status==1)
|
|
if(device_status.clear_status==1)
|
|
@@ -1552,15 +1741,62 @@ static void Control_Clear_thread_entry(void *parameter)
|
|
|
/*入口函数加热*/
|
|
/*入口函数加热*/
|
|
|
static void Control_Heat_thread_entry(void *parameter)
|
|
static void Control_Heat_thread_entry(void *parameter)
|
|
|
{
|
|
{
|
|
|
|
|
+
|
|
|
|
|
+ #if ROBOT_EN == 1
|
|
|
|
|
+ static uint8_t key_on = 0;
|
|
|
|
|
+ #else
|
|
|
|
|
+ while(device_status.work_status==0)
|
|
|
|
|
+ {
|
|
|
|
|
+ rt_thread_delay(1000);
|
|
|
|
|
+ }
|
|
|
|
|
+ #endif
|
|
|
while(1)
|
|
while(1)
|
|
|
{
|
|
{
|
|
|
- if(device_status.work_status==1)
|
|
|
|
|
|
|
+ #if ROBOT_EN == 1
|
|
|
|
|
+ //磁悬浮供电
|
|
|
|
|
+ //监测磁悬浮限位位置
|
|
|
|
|
+ //根据位置确定是否 按下按钮
|
|
|
|
|
+ LOG_D("Read 磁悬浮:%d",device_status.heattem);
|
|
|
|
|
+ //等待10S
|
|
|
|
|
+ if(device_status.heattem<35&&Read_Real_Voltage()/100>12) //磁悬浮处于关闭状态
|
|
|
|
|
+ {
|
|
|
|
|
+ key_on = 0;
|
|
|
|
|
+ //发送触摸按钮信号
|
|
|
|
|
+ rt_pin_mode(EMS_Dir, PIN_MODE_OUTPUT);
|
|
|
|
|
+ rt_pin_write(EMS_Dir, 0);
|
|
|
|
|
+ rt_thread_delay(50);
|
|
|
|
|
+ rt_pin_write(EMS_Dir, 1);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(device_status.heattem>50)
|
|
|
|
|
+ {
|
|
|
|
|
+ key_on = 1;
|
|
|
|
|
+ rt_thread_delay(1000);
|
|
|
|
|
+ LOG_D("Read 磁悬浮已打开:%d",device_status.heattem);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //磁悬浮供电
|
|
|
|
|
+ //监测磁悬浮限位位置
|
|
|
|
|
+ //根据位置确定是否 按下按钮+
|
|
|
|
|
+ if(Read_Real_Voltage()/100<12&&key_on==1)
|
|
|
{
|
|
{
|
|
|
|
|
+ key_on = 0;
|
|
|
|
|
+ rt_pin_mode(EMS_Dir, PIN_MODE_OUTPUT);
|
|
|
|
|
+ rt_pin_write(EMS_Dir, 0);
|
|
|
|
|
+ rt_thread_delay(50);
|
|
|
|
|
+ rt_pin_write(EMS_Dir, 1);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ #else
|
|
|
|
|
+ if(device_status.work_status==1&&device_status.heat_ws==0)
|
|
|
|
|
+ {
|
|
|
|
|
+ rt_thread_delay(10000);
|
|
|
calorstat(device_status.heattime*60);
|
|
calorstat(device_status.heattime*60);
|
|
|
}
|
|
}
|
|
|
- else {
|
|
|
|
|
- rt_kprintf("not calorstat!\n");
|
|
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ LOG_I("Not calorstat!");
|
|
|
}
|
|
}
|
|
|
|
|
+ #endif
|
|
|
rt_thread_delay(1000);
|
|
rt_thread_delay(1000);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -1585,7 +1821,7 @@ int Control_heat(void)
|
|
|
/* 创建线程*/
|
|
/* 创建线程*/
|
|
|
tid_heat = rt_thread_create("Control_Heat_thread_entry",
|
|
tid_heat = rt_thread_create("Control_Heat_thread_entry",
|
|
|
Control_Heat_thread_entry, RT_NULL,
|
|
Control_Heat_thread_entry, RT_NULL,
|
|
|
- 512, //2048
|
|
|
|
|
|
|
+ 1024, //2048
|
|
|
25, //23
|
|
25, //23
|
|
|
WORK_CHECK_THREAD_TIMESLICE); //5
|
|
WORK_CHECK_THREAD_TIMESLICE); //5
|
|
|
if(tid_heat!=RT_NULL)
|
|
if(tid_heat!=RT_NULL)
|