control.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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. #define VERSION_HK "1.26.41(HK)" //版本
  16. #define VERSION_ZP "1.26.1(ZP)" //版本
  17. #define CompileTime "20210914"
  18. /*******************************测试任务****************************************/
  19. /*********************************************************************/
  20. /*********************************************************************/
  21. typedef struct{
  22. uint8_t iSave; //存储标志位
  23. uint8_t dtype; //设备类型
  24. uint8_t photo_ws;
  25. uint8_t power_status;
  26. uint8_t sun_test;
  27. uint8_t heat_status; //加热状态 0-关 1-开
  28. uint8_t lamp_status; //灯管状态 0-关 1-开
  29. uint8_t up_status; //上仓门状态 0-停止 1-打开 2-关闭
  30. uint8_t down_status; //下仓门状态 0-停止 1-打开 2-关闭
  31. uint8_t clear_status; //清扫状态 0-停止 1-开始
  32. uint8_t shake_ws; //震动 0-关 1-开
  33. uint8_t heatvalue;
  34. uint8_t ctr_up_motor; //上仓门, 1打开,0关闭
  35. uint8_t ctr_down_motor; //下仓门, 1打开,0关闭
  36. uint8_t rain_status; //雨控 0-正常 1-欠压
  37. uint8_t temp_status; //温控 0-正常 1-温控
  38. uint8_t sun_status; //光控 0-正常 1-光控
  39. uint8_t ds; //设备状态 0-关机 1-开机
  40. uint8_t work_status; //工作状态 0-待机 1-工作
  41. uint8_t work_done; //工作结束 1-正常 0-工作已结束
  42. uint8_t bat_status; //电压状态 1-正常 0-欠压
  43. uint8_t heattime; //加热时间
  44. uint8_t heat_time_min; //实时加热时间
  45. uint8_t clt_time; //收集时间
  46. uint8_t vol; //音量
  47. uint16_t thsp; //息屏时间
  48. uint8_t refresh_num; //DTU数据刷新时间
  49. uint8_t refresh_timeout;//刷新超时时间
  50. uint8_t sunBar; //光控定时时间
  51. uint8_t startBar; //时控开始时间
  52. uint8_t stopBar; //时控结束时间
  53. uint8_t tph; //高温保护
  54. int8_t tpl; //低温保护
  55. uint8_t shake_sec; //震动时间
  56. uint8_t timeSwitch; //模式0光控,1时控
  57. uint8_t dattim; //数据上传间隔
  58. uint8_t heattem; //加热仓温度(实时)
  59. uint8_t hmi_fresh; //是否启动屏幕
  60. uint8_t update_flag; //是否启动升级
  61. uint8_t photo_type; //相机类型,0-USB,1-海康,2-大华
  62. uint8_t version_type; //版本类型,1-转盘,4-海康
  63. uint8_t stop_in_bootloader; //进入bootloader模式 1
  64. uint8_t account_status; //卡状态
  65. rt_uint32_t num_updata; //
  66. rt_uint32_t rebootcnt; //启动次数
  67. rt_uint32_t light_over_tim; //光控定时差秒数
  68. rt_uint32_t data_plan; //流量套餐
  69. rt_uint32_t expiry_date; //到期时间
  70. int passWord; //初始密码
  71. char csq[3]; //信号强度
  72. char net[3]; //网络
  73. char sim[3]; //SIM卡
  74. char gps[3]; //定位类型
  75. char tempture[12]; //温度
  76. char humidity[12]; //湿度
  77. char driver[32]; //版本
  78. char driver_4g[32]; //4g版本
  79. char driver_bl[32]; //BL版本
  80. char driver_compile[32]; //BL编译时间
  81. char mqttcfg1[32];
  82. char mqttcfg2[128];
  83. char project[32]; //project,用于判断升级
  84. char lng[32]; //经度
  85. char lat[32]; //纬度
  86. char stamp[32]; //系统时间
  87. char fuse_voltage[32]; //保险丝电压
  88. char iccid[32]; //SIM卡ICCID
  89. char imei[32]; //IMEI,唯一ID
  90. char *power; //功率
  91. char *voltage; //电池电压
  92. }Device_Status_typedef;
  93. /**************************************/
  94. #define ON 1
  95. #define OFF 0
  96. #define LED0_PIN GET_PIN(B, 3)
  97. #define Beep GET_PIN(B, 4)
  98. #define OPEN 0x02
  99. #define CLOSE 0x03
  100. /************************************************/
  101. //光控
  102. #define LIGHT_PIN GET_PIN(C,0)
  103. //雨控
  104. #define RAIN_PIN GET_PIN(C,1)
  105. //加热
  106. #define Heat_Pin GET_PIN(B, 12)
  107. //制冷
  108. #define Cold_Pin GET_PIN(B,11)
  109. //采集/上仓门
  110. #define Collect_fan_R GET_PIN(C, 5)
  111. #define Collect_fan_L GET_PIN(C, 4)
  112. //下仓门
  113. #define C_DOWN_R GET_PIN(B,0)
  114. #define C_DOWN_L GET_PIN(B,1)
  115. //镇流器
  116. #define LAMP_SW GET_PIN(C,9)
  117. //震动电机
  118. //补光
  119. #define LED_SW GET_PIN(A,15)
  120. //清扫
  121. #define CLEAR_R GET_PIN(C,7)
  122. #define CLEAR_L GET_PIN(C,8)
  123. //相机供电
  124. #define PHOTO GET_PIN(A,12)
  125. //路由器供电
  126. #define ROUTER GET_PIN(A,8)
  127. //RTU/DTU供电
  128. #define RTU_DTU GET_PIN(B,13)
  129. //海康相机拍照
  130. #define HK_TAKE GET_PIN(A,11)
  131. //清扫限位
  132. #define CLEAR_R_LIMIT GET_PIN(C,13)
  133. #define CLEAR_L_LIMIT GET_PIN(B,9)
  134. /***************************四色LED****************************/
  135. #define YELLOW 1
  136. #define BLUE 2
  137. #define PURPLE 3
  138. #define GREEN 4
  139. #define YELLOW_ON 1
  140. #define YELLOW_OFF 0
  141. #define BLUE_ON 1
  142. #define BLUE_OFF 0
  143. #define PURPLE_ON 1
  144. #define PURPLE_OFF 0
  145. #define GREEN_ON 1
  146. #define GREEN_OFF 0
  147. #define LED_YELLOW GET_PIN(C,9)
  148. #define LED_BLUE GET_PIN(B,2)
  149. #define LED_PURPLE GET_PIN(B,10)
  150. #define LED_GREEN GET_PIN(B,11)
  151. #define SHAKE_SW GET_PIN(A,12)
  152. /***************************高空测报灯*************************/
  153. //上仓门电机限位
  154. #define CTR_UPO_LIMIT GET_PIN(C,13)
  155. #define CTR_UPC_LIMIT GET_PIN(B,9)
  156. //下仓门电机限位
  157. #define CTR_DWO_LIMIT GET_PIN(B,5)
  158. #define CTR_DWC_LIMIT GET_PIN(B,8)
  159. //雨控电机限位,控制排水和落虫
  160. #define CTR_RO_LIMIT GET_PIN(B,15)
  161. #define CTR_RC_LIMIT GET_PIN(C,6)
  162. /*****************************吸虫塔********************************/
  163. //加热>相机供电
  164. #define HK_5000W_POWER GET_PIN(B, 12)
  165. //预留24V>路由器
  166. #define Router_POWER
  167. /***************************************************************/
  168. uint8_t ctr_Heat(uint8_t status_heat); //加热
  169. uint8_t ctr_cangmen_up(uint8_t status_up); //上仓门
  170. uint8_t ctr_cangmen_down(uint8_t status_down); //下仓门
  171. uint8_t ctr_lamp(uint8_t status_lamp); //镇流器
  172. uint8_t ctr_shake(uint8_t status_shake,uint16_t shake_sec); //震动
  173. uint8_t ctr_clear(uint16_t status_clear); //清扫
  174. void ctr_TG_Clear(uint16_t clear_timeout); //清扫2
  175. void ctr_LED(uint8_t Sta_BLUE,uint8_t Sta_YELLOW,uint8_t Sta_PURPLE,uint8_t Sta_GREEN);
  176. uint8_t ctr_led(uint8_t status_led); //补光灯
  177. void calorstat(uint16_t heat_time); //恒温
  178. void ctr_router(uint8_t status_router); //路由器
  179. void turnzp(void); //转仓
  180. void Hk_Take_io(void);
  181. void HK_TakePhoto(void); //拍照
  182. void ctr_photo(uint8_t status_photo);
  183. void ctr_RTU_DTU(uint8_t status_rtu);
  184. void ctr_DTU_Power(uint8_t DTU_Power);
  185. void HardWare_Init(uint8_t boot); //初始化
  186. void HardWare_Check(uint8_t boot); //自检
  187. void ResetInit(void); //上电复位
  188. void SunTest(void); //光控测试
  189. /*****************************************************/
  190. /****************************************************/
  191. void WorkCheck(void); //工作检测
  192. void WorkTast(void); //工作任务
  193. //线程
  194. int Workstatus_check(void);
  195. int Work_Loop_Task(void);
  196. #endif /* APPLICATIONS_INC_CONTROL_H_ */