control.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. /*
  2. * Copyright (c) 2006-2020, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2020-05-30 Administrator the first version
  9. */
  10. #ifndef APPLICATIONS_INC_CONTROL_H_
  11. #define APPLICATIONS_INC_CBD_CONTROL_H_
  12. #include <rtthread.h>
  13. #include <board.h>
  14. #include <rtdevice.h>
  15. //定制相关//////////////////////////////////////////////////////
  16. #define LAMP_EN 0 //李新3灯管:0关闭,1打开
  17. #define SENSOR_EN 0 //温湿度:0关闭,1打开
  18. #define ROBOT_EN 0 //机器人
  19. ////////////////////////////////////////////////////////////////
  20. #if LAMP_EN == 1
  21. #define VERSION_HK "1.(3ledv4).41(HK)" //4.0海康-三色光源
  22. #else
  23. #define VERSION_HK "1.46.41(HK)" //4.0海康
  24. #endif
  25. #define VERSION_HK_2000W "1.43.4(2000W)" //4.0水稻
  26. #define VERSION_ZP "1.39.1(ZP)" //1.0转盘
  27. #define VERSION_GK "1.38.1(GK)" //1.0高空
  28. #define VERSION_XCT "1.9.6(HK)" //吸虫塔-海康
  29. #define VERSION_V5 "1.2.5(HK)" //5.0
  30. #define VERSION_Robot "1.0(robot)" //展厅机器人
  31. #define CompileTime rt_sprintf(device_status.driver_compile,"%s-%s",__DATE__,__TIME__) //编译时间,每次更新代码修改
  32. /*********************************************************************/
  33. typedef struct{
  34. uint8_t iSave; //存储标志位
  35. uint8_t dtype; //设备类型
  36. uint8_t photo_ws;
  37. uint8_t power_status;
  38. uint8_t sun_test;
  39. uint8_t sensor_sta; //0-正常,1-平台获取温湿度
  40. uint8_t heat_status; //加热状态 0-关 1-开
  41. uint8_t lamp_status; //灯管1状态 0-关 1-开
  42. uint8_t lamp1_status; //灯管2状态 0-关 1-开
  43. uint8_t lamp2_status; //灯管3状态 0-关 1-开
  44. uint8_t up_status; //上仓门状态 0-停止 1-打开 2-关闭
  45. uint8_t down_status; //下仓门状态 0-停止 1-打开 2-关闭
  46. uint8_t clear_status; //清扫状态 0-停止 1-开始
  47. uint8_t shake_ws; //震动 0-关 1-开
  48. uint8_t heatvalue; //
  49. uint8_t ctr_up_motor; //上仓门, 1打开,0关闭
  50. uint8_t ctr_down_motor; //下仓门, 1打开,0关闭
  51. uint8_t rain_status; //雨控 0-正常 1-欠压
  52. uint8_t temp_status; //温控 0-正常 1-温控
  53. uint8_t sun_status; //光控 0-正常 1-光控
  54. uint8_t ds; //设备状态 0-关机 1-开机
  55. uint8_t work_status; //工作状态 0-待机 1-工作
  56. uint8_t work_done; //工作结束 1-正常 0-工作已结束
  57. uint8_t bat_status; //电压状态 1-正常 0-欠压
  58. uint8_t heattime; //加热时间
  59. uint8_t heat_time_min; //实时加热时间
  60. uint8_t clt_time; //收集时间
  61. uint8_t vol; //音量
  62. uint16_t thsp; //息屏时间
  63. uint8_t refresh_num; //DTU数据刷新时间
  64. uint8_t refresh_timeout;//刷新超时时间
  65. uint8_t sunBar; //光控定时时间
  66. uint8_t startBar; //时控开始时间
  67. uint8_t stopBar; //时控结束时间
  68. uint8_t tph; //高温保护
  69. int8_t tpl; //低温保护
  70. uint16_t shake_sec; //震动时间
  71. uint8_t timeSwitch; //模式0光控,1时控
  72. uint8_t link_sta; //有线接入状态:0-未接入,1已接入
  73. uint16_t dattim; //数据上传间隔
  74. uint8_t heattem; //加热仓温度(实时)
  75. uint8_t hmi_fresh; //是否启动屏幕
  76. uint8_t update_flag; //是否启动升级
  77. uint8_t photo_type; //相机类型,0-USB,1-海康,2-大华
  78. uint8_t version_type; //版本类型,1-转盘,4-海康,42-水稻,11-高空
  79. uint8_t stop_in_bootloader; //进入bootloader模式 1
  80. uint8_t account_status; //卡状态
  81. uint8_t test_flag; //测试标志
  82. uint8_t sensor_485_sta; //485传感器
  83. rt_uint32_t num_updata; //
  84. rt_uint32_t rebootcnt; //启动次数
  85. rt_uint32_t light_over_tim; //光控定时差秒数,镇流器的结束时间
  86. rt_uint32_t data_plan; //流量套餐
  87. rt_uint32_t expiry_date; //到期时间
  88. int passWord; //初始密码
  89. char mqttcfg1[64]; //
  90. char mqttcfg2[64]; //
  91. char csq[8]; //信号强度
  92. char net[8]; //网络
  93. char sim[8]; //SIM卡
  94. char gps[8]; //定位类型
  95. char tempture[12]; //温度
  96. char humidity[12]; //湿度
  97. char driver[64]; //版本
  98. char driver_4g[64]; //4g版本
  99. char driver_bl[64]; //BL版本
  100. char driver_compile[64]; //BL编译时间
  101. char project[32]; //project,用于判断升级
  102. char lng[32]; //经度
  103. char lat[32]; //纬度
  104. char stamp[32]; //系统时间
  105. char fuse_voltage[32]; //保险丝电压
  106. char iccid[32]; //SIM卡ICCID
  107. char imei[32]; //IMEI,唯一ID
  108. char json_w_clock[128]; //修改时间
  109. char json_w_reset[128]; //
  110. char json_w_platform[128]; //
  111. char *power; //功率
  112. char *voltage; //电池电压
  113. }Device_Status_typedef;
  114. /************************************************/
  115. #define ON 1
  116. #define OFF 0
  117. #define LED0_PIN GET_PIN(B, 3)
  118. #define Beep GET_PIN(B, 4)
  119. #define OPEN 0x02
  120. #define CLOSE 0x03
  121. /************************************************/
  122. //光控
  123. #define LIGHT_PIN GET_PIN(C,0)
  124. //雨控
  125. #define RAIN_PIN GET_PIN(C,1)
  126. //加热
  127. #define Heat_Pin GET_PIN(B, 12)
  128. //采集/上仓门
  129. #define Collect_fan_R GET_PIN(C, 5)
  130. #define Collect_fan_L GET_PIN(C, 4)
  131. //下仓门
  132. #define C_DOWN_R GET_PIN(B,0)
  133. #define C_DOWN_L GET_PIN(B,1)
  134. //镇流器
  135. #define LAMP_SW GET_PIN(C,9)
  136. //震动电机
  137. #define SHAKE_SW GET_PIN(B,2)
  138. //补光
  139. #define LED_SW GET_PIN(A,15)
  140. //清扫
  141. #define CLEAR_R GET_PIN(C,7)
  142. #define CLEAR_L GET_PIN(C,8)
  143. //相机供电
  144. #define PHOTO GET_PIN(A,12)
  145. //路由器供电
  146. #define ROUTER GET_PIN(A,8)
  147. //RTU/DTU供电
  148. #define RTU_DTU GET_PIN(B,13)
  149. //海康相机拍照
  150. #define HK_TAKE GET_PIN(A,11)
  151. #define HK_IO GET_PIN(B,14) //备用触发拍照
  152. //清扫限位
  153. #define CLEAR_R_LIMIT GET_PIN(C,13)
  154. #define CLEAR_L_LIMIT GET_PIN(B,9)
  155. /*****************************4.0定制多光源*********************************/
  156. #define LAMP_1_SW GET_PIN(B,10)
  157. #define LAMP_2_SW GET_PIN(B,11)
  158. /***************************高空测报灯*************************/
  159. //上仓门电机限位
  160. #define CTR_UPO_LIMIT GET_PIN(C,13)
  161. #define CTR_UPC_LIMIT GET_PIN(B,9)
  162. //下仓门电机限位
  163. #define CTR_DWO_LIMIT GET_PIN(B,5)
  164. #define CTR_DWC_LIMIT GET_PIN(B,8)
  165. //雨控电机限位,控制排水和落虫
  166. #define CTR_RO_LIMIT GET_PIN(B,15)
  167. #define CTR_RC_LIMIT GET_PIN(C,6)
  168. /******************************吸虫塔*********************************/
  169. #define HK_5000W_P GET_PIN(B, 12)
  170. #define ROUTER_P GET_PIN(B,10)
  171. #define LED_P GET_PIN(B,11)
  172. #define PC7_TIM3_CH 2
  173. #define PC8_TIM3_CH 3
  174. #define PB1_TIM3_CH 4
  175. #define MOTOR1_CTR_PIN GET_PIN(C,9) //吸虫电机IO
  176. #define MOTOR2_CTR_PIN GET_PIN(B,2) //吸附电机IO
  177. #define MOTOR_CR_PIN GET_PIN(C,7)
  178. #define MOTOR_CL_PIN GET_PIN(C,8)
  179. #define MOTOR_C_LIMIT GET_PIN(C,13) //卷带限位
  180. void ctr_JD_Clear(void);
  181. uint8_t ctr_Motor_xichong(uint8_t status_ws);
  182. uint8_t ctr_Motor_xifu(uint8_t status_ws);
  183. /*****************************定制4.0-2000W***************************************/
  184. #define FAN_P GET_PIN(B,10)
  185. #define FAN_I GET_PIN(B,11)
  186. uint8_t ctr_Fan_IN(uint8_t status_ws);
  187. uint8_t ctr_Fan_PUT(uint8_t status_ws);
  188. /*******************************定制展厅机器人************************************/
  189. #define LIMIT_OPEN GET_PIN(B,8)
  190. #define LIMIT_CLOSE GET_PIN(B,5)
  191. #define Motor_Power GET_PIN(B,10) //电机驱动供电
  192. #define Motor_Direction_Button GET_PIN(B,9) //IO输入,检测按键状态,用于控制方向
  193. #define Motor_Direction_Ctr GET_PIN(B,15) //IO输出,控制电机运动方向
  194. void ctr_Motor_Robot(uint8_t status_ws);
  195. /***************************************************************/
  196. /***************************************************************/
  197. uint8_t ctr_Heat(uint8_t status_heat); //加热
  198. uint8_t ctr_cangmen_up(uint8_t status_up); //上仓门
  199. uint8_t ctr_cangmen_down(uint8_t status_down); //下仓门
  200. uint8_t ctr_lamp(uint8_t status_lamp,uint8_t lamp_num); //镇流器
  201. uint8_t ctr_shake(uint8_t status_shake,uint16_t shake_sec); //震动
  202. uint8_t ctr_clear(uint16_t status_clear); //清扫
  203. void ctr_TG_Clear(uint16_t clear_timeout); //清扫2
  204. uint8_t ctr_led(uint8_t status_led); //补光灯
  205. void calorstat(uint16_t heat_time); //恒温
  206. void ctr_router(uint8_t status_router); //路由器
  207. void turnzp(void); //转仓
  208. void Hk_Take_io(void); //触发拍照
  209. void HK_TakePhoto(void); //拍照
  210. void ctr_photo(uint8_t status_photo);
  211. void ctr_RTU_DTU(uint8_t status_rtu);
  212. void ctr_DTU_Power(uint8_t DTU_Power);
  213. void HardWare_Init(uint8_t boot); //初始化
  214. void HardWare_Check(uint8_t boot); //自检
  215. void ResetInit(void); //上电复位
  216. void SunTest(void); //光控测试
  217. /*****************************************************/
  218. void WorkTask_XCT(void);
  219. /****************************************************/
  220. void WorkCheck(void); //工作检测
  221. void WorkTask(void); //工作任务
  222. //
  223. //线程
  224. int Control_clear(void);
  225. int Workstatus_check(void);
  226. int Work_Loop_Task(void);
  227. #endif /* APPLICATIONS_INC_CONTROL_H_ */