control.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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 "stdio.h"
  15. #include <rtdevice.h>
  16. //定制相关//////////////////////////////////////////////////////
  17. #define SENSOR_EN 0 //温湿度:0关闭,1打开
  18. #define RPS_EN 1 //雨控检测:0关闭,1打开
  19. #define ROBOT_EN 0 //定时重启:0关闭,1打开
  20. ////////////////////////////////////////////////////////////////
  21. #define VERSION "3.9.6"
  22. extern rt_event_t event_485_play;
  23. /*********************************************************************/
  24. typedef struct _packed
  25. {
  26. uint8_t iSave; //存储标志位
  27. uint8_t dtype; //设备类型?7-孢子仪,3-测报灯
  28. /*孢子仪*/
  29. uint8_t run_sta; //转盘的位置:0原始;1收集;2培养;3拍照;4凡士林,其他-测试
  30. uint8_t cul_time; //培养时间
  31. uint8_t stay_time; //已培养时间
  32. uint8_t pre_temp; //培养仓温度
  33. uint8_t box_temp; //箱体温度
  34. uint8_t auto_test_sw; //一键测试 0-关 1-开
  35. uint8_t cold_status; //制冷状态 0-关 1-开
  36. uint8_t cold_sw; //制冷开关 0-关 1-开
  37. uint8_t wind_sw; //风机开关 0-关 1-开
  38. uint8_t collect_fan_status; //采集状态 0-关 1-开
  39. uint8_t autotakepic; //对焦拍照 0-关 1-开
  40. uint8_t develop_flag; //是否进入培养模式
  41. uint8_t cool_fan_status; //散热风机状态 0-停止 1-打开
  42. uint8_t fsl_sw; //凡士林开关:0-关,1-开
  43. /*测报灯*/
  44. uint8_t heat_sw; //加热开关
  45. uint8_t photo_ws; //拍照
  46. uint8_t power_status; //电源
  47. uint8_t sun_test; //光控测测试标志位
  48. uint8_t heat_status; //加热状态 0-关 1-开
  49. uint8_t lamp_status; //灯管1状态 0-关 1-开
  50. uint8_t lamp1_status; //灯管2状态 0-关 1-开
  51. uint8_t lamp2_status; //灯管3状态 0-关 1-开
  52. uint8_t up_status; //上仓门状态 0-停止 1-打开 2-关闭
  53. uint8_t down_status; //下仓门状态 0-停止 1-打开 2-关闭
  54. uint8_t clear_status; //清扫状态 0-停止 1-开始
  55. uint8_t shake_ws; //震动 0-关 1-开
  56. uint8_t heatvalue; //加热设定温度
  57. uint8_t ctr_up_motor; //上仓门, 1打开,0关闭
  58. uint8_t ctr_down_motor; //下仓门, 1打开,0关闭
  59. uint8_t rain_status; //雨控 0-正常 1-欠压
  60. uint8_t temp_status; //温控 0-正常 1-温控
  61. uint8_t sun_status; //光控 0-正常 1-光控
  62. uint8_t lamp; //灯管状态 0-正常 1-异常
  63. uint8_t ds; //设备状态 0-关机 1-开机
  64. uint8_t work_status; //工作状态 0-待机 1-工作
  65. uint8_t work_done; //工作结束 1-正常 0-工作已结束
  66. uint8_t bat_status; //电压状态 0-正常 1-欠压
  67. uint8_t heattime; //加热时间
  68. uint8_t heat_time_min; //实时加热时间
  69. uint8_t clt_time; //收集时间
  70. uint8_t vol; //音量
  71. uint8_t refresh_num; //DTU数据刷新时间
  72. uint8_t refresh_timeout; //刷新超时时间
  73. uint8_t sunBar; //光控定时时间
  74. uint8_t startBar; //时控开始时间
  75. uint8_t stopBar; //时控结束时间
  76. uint8_t tph; //高温保护
  77. int8_t tpl; //低温保护
  78. uint8_t timeSwitch; //模式0光控,1时控
  79. uint8_t link_sta; //有线接入状态:0-未接入,1已接入
  80. uint8_t heattem; //加热仓温度(实时)
  81. uint8_t hmi_fresh; //是否启动屏幕
  82. uint8_t update_flag; //是否启动升级
  83. uint8_t photo_type; //相机类型,0-USB,1-海康,2-大华
  84. uint8_t version_type; //版本类型,1-转盘,4-海康,41-水稻,11-高空,48-4800
  85. uint8_t stop_in_bootloader; //进入bootloader模式 1
  86. uint8_t account_status; //卡状态
  87. uint8_t test_flag; //测试标志
  88. uint8_t sensor_485_sta; //485传感器
  89. uint8_t yc_ct; //诱虫次数
  90. uint8_t all_ycct; //诱虫计数
  91. uint8_t gaoya_count; //高压计数
  92. uint8_t InsectSpecies; //昆虫种类
  93. uint8_t Power_Type; //供电类型
  94. uint8_t camera_sta; //拍照报警
  95. uint8_t led_sta; //补光灯报警
  96. uint8_t selfcheck_ws; //自检
  97. uint8_t collt_box_sta; //收虫仓状态
  98. uint8_t camsta; //拍照报警,0正常,1异常
  99. uint8_t heat_sta; //加热报警0-正常,1-异常
  100. uint8_t gps_inuse;
  101. uint8_t gps_view;
  102. uint8_t sleep_mode; //省电模式:0-关 1-开,> 1 超时时间
  103. uint8_t rtu_status;
  104. uint8_t hmi_status;
  105. uint16_t dattim; //数据上传间隔
  106. uint16_t shake_sec; //震动时间
  107. uint16_t thsp; //息屏时间
  108. uint16_t C01; //故障码
  109. rt_uint32_t num_updata; //
  110. rt_uint32_t rebootcnt; //启动次数
  111. rt_uint32_t light_over_tim; //光控定时差秒数,镇流器的结束时间
  112. rt_uint32_t data_plan; //流量套餐
  113. rt_uint32_t expiry_date; //到期时间
  114. int passWord; //初始密码
  115. double process;
  116. long photo_stamp; //采集时间戳
  117. const char *coll_time[10];
  118. char mqttcfg1[64]; //
  119. char mqttcfg2[64]; //
  120. char csq[8]; //信号强度
  121. char net[8]; //网络
  122. char sim[8]; //SIM卡
  123. char gps[8]; //定位状态
  124. char gps_state[8]; //定位类型
  125. char tempture[12]; //温度
  126. char humidity[12]; //湿度
  127. char driver[64]; //版本
  128. char driver_4g[64]; //4g版本
  129. char driver_bl[64]; //BL版本
  130. char driver_compile[64]; //BL编译时间
  131. char project[32]; //project,用于判断升级
  132. char lng[32]; //经度
  133. char lat[32]; //纬度
  134. char stamp[32]; //系统时间
  135. char fuse_voltage[32]; //保险丝电压
  136. char iccid[32]; //SIM卡ICCID
  137. char imei[32]; //IMEI,唯一ID
  138. char link_ip[32];
  139. char json_w_clock[128]; //修改时间
  140. char json_w_reset[128]; //
  141. char json_w_platform[128]; //
  142. char power[8]; //功率
  143. char heat_power[8]; //加热功率
  144. char voltage[6]; //电池电压
  145. char deviceId[32]; //bdh-设备编码
  146. char voltage_sun[8]; //太阳能板电压
  147. char cpu_temp[8];
  148. char qianming[128];
  149. char photolink[128]; //图片地址
  150. }Device_Status_typedef;
  151. /************************************************/
  152. #define ON 1
  153. #define OFF 0
  154. #define LED0_PIN GET_PIN(B, 3)
  155. #define Beep GET_PIN(B, 4)
  156. #define OPEN 0x02
  157. #define CLOSE 0x03
  158. /****************************性诱3.0********************************/
  159. //光控
  160. #define LIGHT_PIN GET_PIN(C,0)
  161. //雨控
  162. #define RAIN_PIN GET_PIN(C,1)
  163. //屏幕供电5V
  164. #define POWER_5V GET_PIN(C,9)
  165. //补光5V
  166. #define LED_5V GET_PIN(A,15)
  167. //高压12V
  168. #define GAOYA_12V GET_PIN(B,11)
  169. //路由器12V
  170. #define FourFaith_12V GET_PIN(B,10)
  171. //RTU12V
  172. #define RTU_12V GET_PIN(A,8)
  173. #define DC_M1 GET_PIN(C,8)
  174. #define DC_M2 GET_PIN(C,7)
  175. #define SIGNAL_GuangShan GET_PIN(B,5)
  176. #define SIGNAL_INPUT_KEY GET_PIN(A,11)
  177. #define SIGNAL_OUTPUT_LED GET_PIN(A,12)
  178. #define RAIN_POWER GET_PIN(B,8)
  179. #define LIMIT_FB GET_PIN(B,9)
  180. /***************************************************************/
  181. void ctr_hmi_5v(uint8_t sw); //5V电源[串口屏幕]
  182. uint8_t ctr_led(uint8_t status_led); //补光灯
  183. void ctr_router(uint8_t status_router); //路由器
  184. void turnzp(void); //转仓
  185. void Hk_Take_io(void); //触发拍照
  186. void HK_TakePhoto(void); //拍照
  187. void ctr_RTU_12V(uint8_t sw);
  188. void ResetInit(void); //上电复位
  189. void ctr_clear(void);
  190. /*****************************************************/
  191. /***************************************************/
  192. //线程
  193. int Workstatus_check(void);
  194. int Work_Loop_Task(void);
  195. int Check_Self(void);
  196. int Check_gaoya(void);
  197. int thread_485_play(void);
  198. int thread_delete_workloop(void);
  199. int thread_restart_workloop(void);
  200. #endif /* APPLICATIONS_INC_CONTROL_H_ */