control.h 6.5 KB

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