|
|
@@ -33,6 +33,32 @@ rt_thread_t tid_workloop = RT_NULL;
|
|
|
rt_thread_t tid_wkstc = RT_NULL;
|
|
|
|
|
|
/*************************吸虫塔*********************************/
|
|
|
+//吸虫电机
|
|
|
+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_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()
|
|
|
{
|
|
|
@@ -81,22 +107,30 @@ void ctr_JD_Clear()
|
|
|
//工作任务流程
|
|
|
void WorkTask_XCT(void)
|
|
|
{
|
|
|
- uint32_t photo_fre = 0;
|
|
|
- photo_fre = device_status.dattim * 60;
|
|
|
- //ctr_Motor_xichong(ON);
|
|
|
- //ctr_Motor_xifu(ON);
|
|
|
- while(photo_fre!=0)
|
|
|
+ if(device_status.work_status==1)
|
|
|
{
|
|
|
- photo_fre --;
|
|
|
- rt_thread_delay(1000);
|
|
|
- rt_kprintf("收集中,等待开始拍照:%d\n",photo_fre);
|
|
|
+ ctr_Motor_xichong(ON);
|
|
|
+ ctr_Motor_xifu(ON);
|
|
|
+ uint32_t photo_fre = 0;
|
|
|
+ photo_fre = device_status.dattim * 60;
|
|
|
+ while(photo_fre!=0)
|
|
|
+ {
|
|
|
+ photo_fre --;
|
|
|
+ rt_thread_delay(1000);
|
|
|
+ rt_kprintf("收集中,等待开始拍照:%d\n",photo_fre);
|
|
|
+ }
|
|
|
+ //卷带
|
|
|
+ ctr_JD_Clear();
|
|
|
+ //拍照
|
|
|
+ HK_TakePhoto();
|
|
|
+ //卷带
|
|
|
+ ctr_JD_Clear();
|
|
|
+ //震动
|
|
|
+ Motor_shake(ON, device_status.shake_sec);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ rt_kprintf("不在工作时间,未工作!!!\n");
|
|
|
}
|
|
|
- //卷带
|
|
|
- ctr_JD_Clear();
|
|
|
- //震动
|
|
|
- Motor_shake(ON, device_status.shake_sec);
|
|
|
- //拍照
|
|
|
- HK_TakePhoto();
|
|
|
}
|
|
|
/**********************************************************************/
|
|
|
/*光控*/
|
|
|
@@ -647,7 +681,6 @@ void HardWare_Init(uint8_t boot)
|
|
|
HMI_WRITE("hardcheck.checktip.txt=\"12V供电已关闭!!!\"");
|
|
|
rt_thread_delay(1000);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
//拍照
|
|
|
void HK_TakePhoto(void)
|
|
|
@@ -656,7 +689,7 @@ void HK_TakePhoto(void)
|
|
|
ctr_led(ON);
|
|
|
DTU_Write("takephoto.mp3");
|
|
|
//延时
|
|
|
- rt_thread_delay(1000*10);
|
|
|
+ rt_thread_delay(1000*15);
|
|
|
rt_kprintf("\n测试拍照!\n");
|
|
|
char *takephotojson = makeJson_takephoto();
|
|
|
DTU_Write("%s",takephotojson);
|
|
|
@@ -763,7 +796,7 @@ void ResetInit(void)
|
|
|
//出厂前自检 0-开机自检 1-屏幕或指令下发手动自检
|
|
|
void HardWare_Check(uint8_t boot)
|
|
|
{
|
|
|
- if(boot==0)
|
|
|
+ if(boot==0&&device_status.version_type!=6)
|
|
|
{
|
|
|
//停止所有动作 -完成
|
|
|
HardWare_Init(boot);
|
|
|
@@ -934,6 +967,7 @@ void WorkTask(void)
|
|
|
{
|
|
|
ctr_router(ON); //打开路由器供电
|
|
|
static int clt_time = 0; //收集时间差秒数
|
|
|
+ static uint16_t controltime = 6;
|
|
|
rt_kprintf("工作状态:%d\n",device_status.work_status);
|
|
|
rt_kprintf("开关机状态:%d\n",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)
|
|
|
@@ -943,88 +977,110 @@ void WorkTask(void)
|
|
|
//1.打开灯管
|
|
|
ctr_lamp(ON);
|
|
|
rt_kprintf("打开灯管!!!\n");
|
|
|
- rt_thread_delay(5000); //待灯管启动再往下执行,否则会触发电机过流
|
|
|
- //2.打开上仓门
|
|
|
- rt_kprintf("打开上仓门!!!\n");
|
|
|
- device_status.ctr_up_motor = 1;
|
|
|
- //3.收集
|
|
|
- clt_time = device_status.clt_time * 60;
|
|
|
- while(clt_time!=1)
|
|
|
+ if(device_status.version_type!=5)
|
|
|
{
|
|
|
- clt_time --;
|
|
|
- rt_thread_delay(1000);
|
|
|
- rt_kprintf("正在收集.....剩余时间:%d分-%d秒\n",device_status.clt_time,clt_time);
|
|
|
- //如果触发异常
|
|
|
+ rt_thread_delay(5000); //待灯管启动再往下执行,否则会触发电机过流
|
|
|
+ //2.打开上仓门
|
|
|
+ rt_kprintf("打开上仓门!!!\n");
|
|
|
+ device_status.ctr_up_motor = 1;
|
|
|
+ //3.收集
|
|
|
+ clt_time = device_status.clt_time * 60;
|
|
|
+ while(clt_time!=1)
|
|
|
+ {
|
|
|
+ clt_time --;
|
|
|
+ rt_thread_delay(1000);
|
|
|
+ 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);
|
|
|
+ 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);
|
|
|
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);
|
|
|
- rt_kprintf("异常退出!!!\n");
|
|
|
- break;
|
|
|
- }
|
|
|
- //4.关闭上仓门
|
|
|
- device_status.ctr_up_motor = 2;
|
|
|
- rt_kprintf("关闭上仓门!!!\n");
|
|
|
+ //4.关闭上仓门
|
|
|
+ device_status.ctr_up_motor = 2;
|
|
|
+ rt_kprintf("关闭上仓门!!!\n");
|
|
|
// while(device_status.ctr_up_motor!=0)
|
|
|
// {
|
|
|
// rt_thread_delay(100);
|
|
|
// rt_kprintf("等待上仓门关闭!!!\n");
|
|
|
// }
|
|
|
- //5.加热
|
|
|
- rt_kprintf("加热!!!\n");
|
|
|
- calorstat(device_status.heattime*60);
|
|
|
- //6.打开下仓门
|
|
|
- if(device_status.rain_status==0)
|
|
|
- {
|
|
|
- device_status.ctr_down_motor =1;
|
|
|
- }
|
|
|
- //待下仓门完全打开
|
|
|
- while(device_status.ctr_down_motor!=0)
|
|
|
- {
|
|
|
- rt_thread_delay(100);
|
|
|
- rt_kprintf("等待下仓门打开!!!\n");
|
|
|
+ //5.加热
|
|
|
+ rt_kprintf("加热!!!\n");
|
|
|
+ calorstat(device_status.heattime*60);
|
|
|
+ //6.打开下仓门
|
|
|
+ if(device_status.rain_status==0)
|
|
|
+ {
|
|
|
+ device_status.ctr_down_motor =1;
|
|
|
+ }
|
|
|
+ //待下仓门完全打开
|
|
|
+ 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");
|
|
|
+ }
|
|
|
+ if(device_status.version_type==4)
|
|
|
+ {
|
|
|
+ //震动
|
|
|
+ ctr_shake(ON, 1);
|
|
|
+ //补光&&拍照
|
|
|
+ rt_kprintf("拍照!!!\n");
|
|
|
+ HK_TakePhoto();
|
|
|
+ //清扫
|
|
|
+ if(ctr_clear(1200)==0)
|
|
|
+ ctr_TG_Clear(350);
|
|
|
+ //清扫失效则使用震动
|
|
|
+ //ctr_shake(ON, 100);
|
|
|
+ }
|
|
|
}
|
|
|
- rt_thread_delay(3000);
|
|
|
- //关闭下仓门
|
|
|
- device_status.ctr_down_motor = 2;
|
|
|
- while(device_status.ctr_down_motor!=0)
|
|
|
- {
|
|
|
- rt_thread_delay(100);
|
|
|
- rt_kprintf("等待下仓门关闭!!!\n");
|
|
|
+ else {
|
|
|
+ //打开补光
|
|
|
+ ctr_led(ON);
|
|
|
+ rt_kprintf("打开补光!!!\n");
|
|
|
+ rt_pin_mode(CLEAR_L_LIMIT,PIN_MODE_INPUT);
|
|
|
+ //2.翻转清虫
|
|
|
+ if (rt_pin_read(CLEAR_L_LIMIT)==0) //判断是否有触发信号
|
|
|
+ {
|
|
|
+ while(controltime!=0)
|
|
|
+ {
|
|
|
+ controltime--;
|
|
|
+ rt_thread_delay(1000);
|
|
|
+ rt_kprintf("延时中:%d\n",controltime);
|
|
|
+ }
|
|
|
+ controltime = 6;
|
|
|
+ turnzp(); //翻转
|
|
|
+ rt_kprintf("翻转清虫!!!\n");
|
|
|
+ }
|
|
|
}
|
|
|
- if(device_status.version_type==4)
|
|
|
+ }
|
|
|
+ if(device_status.bat_status == 1 || device_status.temp_status == 1|| device_status.rain_status==1||device_status.ds==0)
|
|
|
{
|
|
|
- //震动
|
|
|
- ctr_shake(ON, 1);
|
|
|
- //补光&&拍照
|
|
|
- rt_kprintf("拍照!!!\n");
|
|
|
- HK_TakePhoto();
|
|
|
- //清扫
|
|
|
- if(ctr_clear(1200)==0)
|
|
|
- ctr_TG_Clear(350);
|
|
|
- //清扫失效则使用震动
|
|
|
- //ctr_shake(ON, 100);
|
|
|
+ rt_kprintf("-------------------not work--------------------\n");
|
|
|
+ device_status.work_status = 0;
|
|
|
}
|
|
|
- }
|
|
|
- if(device_status.bat_status == 1 || device_status.temp_status == 1|| device_status.rain_status==1||device_status.ds==0)
|
|
|
- {
|
|
|
- rt_kprintf("-------------------not work--------------------\n");
|
|
|
- device_status.work_status = 0;
|
|
|
- }
|
|
|
//工作结束
|
|
|
if(device_status.work_done==0&&device_status.work_status==0)
|
|
|
{
|
|
|
DTU_Write("workdone");
|
|
|
ResetInit();
|
|
|
}
|
|
|
- rt_kprintf("***not work-device status:%d\n",device_status.ds);
|
|
|
+ rt_kprintf("***not work-device status:%d\n",device_status.ds);
|
|
|
}
|
|
|
/* 入口函数-工作状态检测 */
|
|
|
static void Work_status_thread_entry(void *parameter)
|