|
@@ -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)
|
|
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)
|
|
while(device_status.work_status==1&&device_status.ds==1)
|
|
|
{
|
|
{
|
|
|
-
|
|
|
|
|
ctr_Motor_xifu(ON);
|
|
ctr_Motor_xifu(ON);
|
|
|
//打开相机供电
|
|
//打开相机供电
|
|
|
ctr_Camera_Power(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);
|
|
HMI_WRITE("sysTest.switchDrop.val=%d",OFF);
|
|
|
return status_shake;
|
|
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)
|
|
uint8_t ctr_led(uint8_t status_led)
|
|
|
{
|
|
{
|
|
@@ -733,81 +702,7 @@ void ctr_Petroleum_jelly(rt_uint32_t delay)
|
|
|
pwm_off(3,0);
|
|
pwm_off(3,0);
|
|
|
device_status.fsl_sw = 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)
|
|
uint8_t ctr_clear(uint16_t status_clear)
|
|
@@ -1332,91 +1227,18 @@ void SunTest(void)
|
|
|
/*上电初始化*/
|
|
/*上电初始化*/
|
|
|
void ResetInit(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)
|
|
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
|
|
//工作任务流程s
|
|
|
void WorkTask(void)
|
|
void WorkTask(void)
|
|
|
{
|
|
{
|
|
|
- static int clt_time = 0; //收集时间差秒数
|
|
|
|
|
|
|
+ static rt_uint32_t clt_time = 0; //收集时间差秒数
|
|
|
static int heat_time = 0;
|
|
static int heat_time = 0;
|
|
|
LOG_I("工作状态:%d",device_status.work_status);
|
|
LOG_I("工作状态:%d",device_status.work_status);
|
|
|
LOG_I("开关机状态:%d",device_status.ds);
|
|
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;
|
|
device_status.work_done = 0;
|
|
|
if(clt_time==0)
|
|
if(clt_time==0)
|
|
|
{
|
|
{
|
|
|
|
|
+ pin_guangshan_bind();
|
|
|
DTU_Write("workstart.mp3");
|
|
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.打开灯管
|
|
//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("打开灯管!!!");
|
|
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)
|
|
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)
|
|
if(device_status.work_done==0&&device_status.work_status==0)
|
|
|
{
|
|
{
|
|
|
DTU_Write("workdone");
|
|
DTU_Write("workdone");
|
|
|
- if (device_status.version_type==1) {
|
|
|
|
|
- turnzp(); //2024-03-21 :开机不再转仓
|
|
|
|
|
- }
|
|
|
|
|
ResetInit();
|
|
ResetInit();
|
|
|
clt_time = 0;
|
|
clt_time = 0;
|
|
|
}
|
|
}
|
|
@@ -2082,6 +1529,8 @@ static void Work_Loop_thread_entry(void *parameter)
|
|
|
rt_thread_delay(1000);
|
|
rt_thread_delay(1000);
|
|
|
ResetInit();
|
|
ResetInit();
|
|
|
rt_pin_mode(CTR_UPC_LIMIT, PIN_MODE_INPUT);
|
|
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)
|
|
while(1)
|
|
|
{
|
|
{
|
|
|
if(device_status.dtype==3)
|
|
if(device_status.dtype==3)
|