control.h 7.5 KB

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