/* * Copyright (c) 2006-2020, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes * 2020-05-30 Administrator the first version */ #ifndef APPLICATIONS_INC_CONTROL_H_ #define APPLICATIONS_INC_CBD_CONTROL_H_ #include #include #include //定制相关////////////////////////////////////////////////////// #define LAMP_EN 0 //李新3灯管:0关闭,1打开 #define SENSOR_EN 1 //温湿度:0关闭,1打开 #define ROBOT_EN 0 //机器人 #define Color_EN 0 //定制色诱 #define BZYV2_EN 0 //孢子仪2.0 //////////////////////////////////////////////////////////////// #if LAMP_EN == 1 #define VERSION_HK "1.(3ledv6).41(HK)" //4.0海康-三色光源 #else #define VERSION_HK "1.49.41(HK)" //4.0海康-1200W #endif #define VERSION_HK_4800W "1.48.48(HK)" //4.0海康-4800W #define VERSION_HK_2000W "1.46.4(2000W)" //4.0水稻 #define VERSION_ZP "1.41.1(ZP)" //1.0转盘 #define VERSION_GK "1.38.1(GK)" //1.0高空 #define VERSION_XCT "1.13.6(HK)" //吸虫塔-海康 #define VERSION_V5 "1.2.5(HK)" //5.0 #define VERSION_Robot "1.0(robot)" //展厅机器人 #define VERSION_BZY "2.4" //孢子仪 #define CompileTime rt_sprintf(device_status.driver_compile,"%s-%s",__DATE__,__TIME__) //编译时间,每次更新代码修改 /*********************************************************************/ typedef struct { uint8_t iSave; //存储标志位 uint8_t dtype; //设备类型?7-孢子仪,3-测报灯 /*孢子仪*/ uint8_t run_sta; //转盘的位置:0原始;1收集;2培养;3拍照;4凡士林,其他-测试 uint8_t cul_time; //培养时间 uint8_t stay_time; //已培养时间 uint8_t pre_temp; //培养仓温度 uint8_t box_temp; //箱体温度 uint8_t auto_test_sw; //一键测试 0-关 1-开 uint8_t cold_status; //制冷状态 0-关 1-开 uint8_t cold_sw; //制冷开关 0-关 1-开 uint8_t wind_sw; //风机开关 0-关 1-开 uint8_t collect_fan_status; //采集状态 0-关 1-开 uint8_t autotakepic; //对焦拍照 0-关 1-开 uint8_t develop_flag; //是否进入培养模式 uint8_t cool_fan_status; //散热风机状态 0-停止 1-打开 uint8_t fsl_sw; //凡士林开关:0-关,1-开 uint8_t collecting_sh1; //采集开启1 uint8_t collecting_eh1; //采集关闭1 uint8_t collecting_sh2; //采集开启2 uint8_t collecting_eh2; //采集关闭2 uint8_t collecting_sh3; //采集开启3 uint8_t collecting_eh3; //采集关闭3 /*测报灯*/ uint8_t heat_sw; //加热开关 uint8_t photo_ws; //拍照 uint8_t power_status; //电源 uint8_t sun_test; //光控测测试标志位 uint8_t heat_status; //加热状态 0-关 1-开 uint8_t lamp_status; //灯管1状态 0-关 1-开 uint8_t lamp1_status; //灯管2状态 0-关 1-开 uint8_t lamp2_status; //灯管3状态 0-关 1-开 uint8_t up_status; //上仓门状态 0-停止 1-打开 2-关闭 uint8_t down_status; //下仓门状态 0-停止 1-打开 2-关闭 uint8_t clear_status; //清扫状态 0-停止 1-开始 uint8_t shake_ws; //震动 0-关 1-开 uint8_t heatvalue; //加热设定温度 uint8_t ctr_up_motor; //上仓门, 1打开,0关闭 uint8_t ctr_down_motor; //下仓门, 1打开,0关闭 uint8_t rain_status; //雨控 0-正常 1-欠压 uint8_t temp_status; //温控 0-正常 1-温控 uint8_t sun_status; //光控 0-正常 1-光控 uint8_t ds; //设备状态 0-关机 1-开机 uint8_t work_status; //工作状态 0-待机 1-工作 uint8_t work_done; //工作结束 1-正常 0-工作已结束 uint8_t bat_status; //电压状态 1-正常 0-欠压 uint8_t heattime; //加热时间 uint8_t heat_time_min; //实时加热时间 uint8_t clt_time; //收集时间 uint8_t vol; //音量 uint8_t refresh_num; //DTU数据刷新时间 uint8_t refresh_timeout; //刷新超时时间 uint8_t sunBar; //光控定时时间 uint8_t startBar; //时控开始时间 uint8_t stopBar; //时控结束时间 uint8_t tph; //高温保护 int8_t tpl; //低温保护 uint8_t timeSwitch; //模式0光控,1时控 uint8_t link_sta; //有线接入状态:0-未接入,1已接入 uint8_t heattem; //加热仓温度(实时) uint8_t hmi_fresh; //是否启动屏幕 uint8_t update_flag; //是否启动升级 uint8_t photo_type; //相机类型,0-USB,1-海康,2-大华 uint8_t version_type; //版本类型,1-转盘,4-海康,41-水稻,11-高空,48-4800 uint8_t stop_in_bootloader; //进入bootloader模式 1 uint8_t account_status; //卡状态 uint8_t test_flag; //测试标志 uint8_t sensor_485_sta; //485传感器 //孢子仪2.0 uint8_t step_focus; uint16_t dattim; //数据上传间隔 uint16_t shake_sec; //震动时间 uint16_t thsp; //息屏时间 rt_uint32_t num_updata; // rt_uint32_t rebootcnt; //启动次数 rt_uint32_t light_over_tim; //光控定时差秒数,镇流器的结束时间 rt_uint32_t data_plan; //流量套餐 rt_uint32_t expiry_date; //到期时间 double focus_value; int passWord; //初始密码 const char *coll_time[10]; char mqttcfg1[64]; // char mqttcfg2[64]; // char csq[8]; //信号强度 char net[8]; //网络 char sim[8]; //SIM卡 char gps[8]; //定位类型 char tempture[12]; //温度 char humidity[12]; //湿度 char driver[64]; //版本 char driver_4g[64]; //4g版本 char driver_bl[64]; //BL版本 char driver_compile[64]; //BL编译时间 char project[32]; //project,用于判断升级 char lng[32]; //经度 char lat[32]; //纬度 char stamp[32]; //系统时间 char fuse_voltage[32]; //保险丝电压 char iccid[32]; //SIM卡ICCID char imei[32]; //IMEI,唯一ID char json_w_clock[128]; //修改时间 char json_w_reset[128]; // char json_w_platform[128]; // char power[8]; //功率 char voltage[8]; //电池电压 }Device_Status_typedef; /**************滑台数据********************/ typedef struct { uint16_t xpoint; //x轴坐标 uint16_t zpoint; //y轴坐标 uint16_t xdis; //x轴坐标移动距离 uint16_t ydis; uint16_t zdis; //z轴坐标移动距离 uint16_t dxdis; //x轴坐标蛇形移动间距距离 uint16_t dzdis; //z轴坐标蛇形移动间距距离 uint8_t xdir; //x轴坐标移动方向 uint8_t ydir; uint8_t zdir; //z轴坐标移动方向 uint8_t en_slide; //z轴坐标移动方向 uint8_t zccwl_on; //z轴限位开关信号 高电平为触发限位 uint8_t xccwl_on; //x轴限位开关信号 高电平为触发限位 uint8_t pulse_period; //滑台的运动速度 1为最高 uint8_t stop_flag; //滑台停止标志位 }Device_slide_typedef; /************************************************/ #define ON 1 #define OFF 0 #define LED0_PIN GET_PIN(B, 3) #define Beep GET_PIN(B, 4) #define OPEN 0x02 #define CLOSE 0x03 /************************************************/ //光控 #define LIGHT_PIN GET_PIN(C,0) //雨控 #define RAIN_PIN GET_PIN(C,1) //加热 #define Heat_Pin GET_PIN(B,12) //采集/上仓门 #define Collect_fan_R GET_PIN(C, 5) #define Collect_fan_L GET_PIN(C, 4) //下仓门 #define C_DOWN_R GET_PIN(B,0) #define C_DOWN_L GET_PIN(B,1) //镇流器 #define LAMP_SW GET_PIN(C,9) //震动电机 #define SHAKE_SW GET_PIN(B,2) //补光 #define LED_SW GET_PIN(A,15) //清扫 #define CLEAR_R GET_PIN(C,7) #define CLEAR_L GET_PIN(C,8) //相机供电 #define PHOTO GET_PIN(A,12) //路由器供电 #define ROUTER GET_PIN(A,8) //RTU/DTU供电 #define RTU_DTU GET_PIN(B,13) //海康相机拍照 #define HK_TAKE GET_PIN(A,11) #define HK_IO GET_PIN(B,14) //备用触发拍照 //清扫限位 #define CLEAR_R_LIMIT GET_PIN(C,13) #define CLEAR_L_LIMIT GET_PIN(B,9) /*****************************4.0定制多光源*********************************/ #define LAMP_1_SW GET_PIN(B,10) #define LAMP_2_SW GET_PIN(B,11) /***************************高空测报灯*************************/ //上仓门电机限位 #define CTR_UPO_LIMIT GET_PIN(C,13) #define CTR_UPC_LIMIT GET_PIN(B,9) //下仓门电机限位 #define CTR_DWO_LIMIT GET_PIN(B,5) #define CTR_DWC_LIMIT GET_PIN(B,8) //雨控电机限位,控制排水和落虫 #define CTR_RO_LIMIT GET_PIN(B,15) #define CTR_RC_LIMIT GET_PIN(C,6) /******************************吸虫塔*********************************/ #define HK_5000W_P GET_PIN(B,12) #define ROUTER_P GET_PIN(B,10) #define LED_P GET_PIN(B,11) #define PC7_TIM3_CH 2 //pwm8 #define PC8_TIM3_CH 3 //pwm8 #define PB1_TIM3_CH 4 //pwm3 #define MOTOR1_CTR_PIN GET_PIN(C,9) //吸虫电机IO #define MOTOR2_CTR_PIN GET_PIN(B,2) //吸附电机IO #define MOTOR_CR_PIN GET_PIN(C,7) #define MOTOR_CL_PIN GET_PIN(C,8) #define MOTOR_C_LIMIT GET_PIN(C,13) //卷带限位 void ctr_JD_Clear(uint8_t shake_sw); uint8_t ctr_Motor_xichong(uint8_t status_ws); uint8_t ctr_Motor_xifu(uint8_t status_ws); uint8_t ctr_Camera_Power(uint8_t status_ws); /*****************************5.0测报灯******************************/ void ctr_turnv5(void); /*****************************孢子仪**********************************/ //制冷 #define Cold_Pin GET_PIN(B,11) //采集 #define Collect_Fan GET_PIN(B,10) //转盘 #define TURN_ZP_R GET_PIN(B,0) #define TURN_ZP_L GET_PIN(B,1) //转盘限位 #define LIMIT_0 GET_PIN(C,13) #define LIMIT_90 GET_PIN(B,9) //散热 #define Cool_Fan_R GET_PIN(C, 5) #define Cool_Fan_L GET_PIN(C, 4) //步进电机限位 #define LIMIT_UP GET_PIN(B,8) #define LIMIT_DOWN GET_PIN(B,5) //步进电机驱动 #define Motor_EN GET_PIN(B,14) #define Motor_DIR GET_PIN(B,15) void ctr_turn(uint8_t v,uint8_t sta); uint8_t ctr_Cold(uint8_t status_cold); uint8_t ctr_Cool_Fan(uint8_t status_cool); //散热风机 uint8_t ctr_Collect_Fan(uint8_t status_collect); //采集风机 void ctr_Motor_Driver(uint8_t EN,uint8_t DIR,rt_uint32_t pwm,rt_uint32_t time_out); //步进电机 void ctr_Petroleum_jelly(rt_uint32_t delay); //凡士林 /*****************************定制4.0-2000W***************************************/ #define FAN_P GET_PIN(B,10) #define FAN_I GET_PIN(B,11) uint8_t ctr_Fan_IN(uint8_t status_ws); uint8_t ctr_Fan_PUT(uint8_t status_ws); /*******************************定制展厅机器人************************************/ #define LIMIT_OPEN GET_PIN(B,8) #define LIMIT_CLOSE GET_PIN(B,5) #define Motor_Power GET_PIN(B,10) //电机驱动供电 #define Motor_Direction_Button GET_PIN(B,9) //IO输入,检测按键状态,用于控制方向 #define Motor_Direction_Ctr GET_PIN(B,15) //IO输出,控制电机运动方向 #define EMS_Dir GET_PIN(B,14) void ctr_Motor_Robot(uint8_t status_ws); /****************************定制色诱***************************************************/ #define LIMIT_RESET GET_PIN(C,13) #define LIMIT_BOARD GET_PIN(B,9) #define KEY_RESET GET_PIN(B,8) #define KEY_BACK GET_PIN(B,5) int ctr_Color_board(uint8_t forward,uint16_t time_board); /***************************************************************/ /***************************************************************/ uint8_t ctr_Heat(uint8_t status_heat); //加热 uint8_t ctr_cangmen_up(uint8_t status_up); //上仓门 uint8_t ctr_cangmen_down(uint8_t status_down); //下仓门 uint8_t ctr_lamp(uint8_t status_lamp,uint8_t lamp_num); //镇流器 uint8_t ctr_shake(uint8_t status_shake,uint16_t shake_sec); //震动 uint8_t ctr_clear(uint16_t status_clear); //清扫 void ctr_TG_Clear(uint16_t clear_timeout); //清扫2 uint8_t ctr_led(uint8_t status_led); //补光灯 void calorstat(uint16_t heat_time); //恒温 void ctr_router(uint8_t status_router); //路由器 void turnzp(void); //转仓 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 HardWare_Check(uint8_t boot); //自检 void ResetInit(void); //上电复位 void SunTest(void); //光控测试 /*****************************************************/ void WorkTask_XCT(void); /****************************************************/ void WorkCheck(void); //工作检测 void WorkTask(void); //工作任务 // /***********************孢子仪2.0****************************/ uint8_t ctr_swz(uint8_t status_swz); //z轴的电机开关控制 uint16_t ctr_xmove(uint8_t xdir,uint32_t xdis,uint8_t pulse); //x轴移动xdis um uint16_t ctr_ymove(uint8_t ydir,uint32_t ydis,uint8_t pulse); uint16_t ctr_zmove(uint8_t zdir,uint32_t zdis,uint8_t pulse); //z轴移动zdis um uint32_t ctr_photodz(uint32_t xdis,uint32_t zdis,uint32_t dzdis,uint8_t pulse); //z轴移动dzdis um void movorgxz(); //滑台归零位 void movorgy(); void slidelock(); //电机移动完毕后上锁 uint32_t ctr_photodx(uint32_t xdis,uint32_t zdis,uint32_t dxdis,uint8_t pulse);//x轴移动dxdis um void turnlimit(void); //位移兼限位开关功能 /***************************************************/ //线程 int Control_clear(void); int Workstatus_check(void); int Work_Loop_Task(void); int Control_heat(void); int slide_Fresh(void); #endif /* APPLICATIONS_INC_CONTROL_H_ */