state_mini.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. /*
  2. * state_mini.h
  3. *
  4. * Created on: 2026年6月29日
  5. * Author: dell
  6. */
  7. #ifndef __STATE_MINI_H
  8. #define __STATE_MINI_H
  9. #include "user_heater.h"
  10. #define MAX_DATA_BUF_SIZE 36
  11. #define SystemChecking 0
  12. #define SystemOK 1
  13. #define SystemError 2
  14. #define SKIP_CHECK_CARDINSERT (1 << 0) //开始检测插卡正确
  15. #define SKIP_CHECK_CARDREMOVE (1 << 1) //运行过程中检测插卡拔卡
  16. #define SKIP_HEATONCHECK_OK (1 << 2) //跳过加热,不管加热状态
  17. #define SKIP_SAMPLIGHT_ACC (1 << 3) //上报加速
  18. #define SKIP_SCANQRCODE (1 << 4) //上报加速
  19. #define SKIP_FARSTRUN (1 << 5) //上报加速
  20. #define SKIP_SLAVEDATASCOP (1 << 6) //从模块datascop上报
  21. #define HEAT_OFF 0x00 //关加热
  22. #define HEAT_ON 0x01 //开加热
  23. #define HEAT_STOP 0x02 //停止加热
  24. #define FAN_ON 0x02 //启用风扇
  25. #define sampleTotalTimes 181
  26. typedef enum StatusWord
  27. {
  28. // 所有板卡准备自检,包含通道预加热
  29. SW_Read_To_Board_Selftest = 0,
  30. // 准备和PC握手
  31. // SW_Ready_To_Shake_On = 0,
  32. // 故障
  33. SW_Fault = 1,
  34. // 获取温度,两通道通道加热
  35. SW_Switch_On_Pre_Heat = 8,
  36. // 快速停止
  37. SW_Quick_stop = 30,
  38. // 等温度稳定后
  39. SW_Target_reached = 10,
  40. // 等待扫码
  41. SW_Scan_Qrcode = 12,
  42. // 插卡,通道检测
  43. SW_Chip_Id = 14,
  44. // 条码信息匹配,下发
  45. SW_Qrcode_publish = 16,
  46. // 采样,30min定时
  47. SW_Sample_timeout = 18,
  48. // 计算,阈值范围,所有孔的结果(阴阳性、无效)
  49. // 结果上传&数据上传
  50. SW_result_report = 25,
  51. SW_move_card = 26, //拔卡,进入下一次流程循环
  52. SW_SystemError
  53. } StatusWord_t;
  54. // pc Controlword commands
  55. typedef enum Controlword
  56. {
  57. Board_Selftest_cmd,
  58. Hand_Shake_cmd,
  59. Scan_ready_Qrcode_cmd,
  60. Scan_Qrcode_cmd,
  61. Pre_Heat_cmd,
  62. Target_reached_cmd,
  63. Chip_Id_cmd,
  64. Qrcode_publish_cmd,
  65. Sample_timeout_cmd,
  66. result_report_cmd,
  67. result_move_card
  68. } Controlword_t;
  69. //故障码
  70. enum ERROR_CODE
  71. {
  72. ERROR_HEAT_INSERT_CARD = 101, //温度稳定前插卡
  73. ERROR_NO_QRCODE = 102, //未扫码就插卡
  74. ERROR_SAMP_MOVE_CARD = 103, //检测中拔卡
  75. ERROR_SENSOR_SELF_CHECK= 104, //光电自检失败
  76. ERROR_HEAT_SELF_CHECK= 105, //加热自检失败
  77. ERROR_MCU_LINK_TIMEOUT = 106, //mcut通讯超时
  78. ERROR_PRE_HEAT_TIMEOUT = 107, //预热超时
  79. ERROR_HEAT_TIMEOUT = 108, //加热超时
  80. ERROR_MOTOR_FIALED = 109, //电机
  81. ERROR_TUPE_MOVE = 110, //检测过程中拔试管
  82. ERROR_TUPE_EXIST = 111, //检测过程中拔试管
  83. ERROR_HEATFUC_EER = 112, //加热模块无反应
  84. ERROR_TEMPSENSOR_EER = 113, //温度传感器异常
  85. };
  86. typedef struct inner_action_flags_t
  87. {
  88. uint8_t selftest_allowed : 1;
  89. uint8_t scan_qrcode_allowed : 1;
  90. uint8_t pre_heat_enabled : 1;
  91. uint8_t target_reached : 1;
  92. uint8_t check_chipid_enabled : 1;
  93. uint8_t qrcode_info_applied : 1;
  94. } inner_action_flags_t;
  95. typedef struct
  96. {
  97. uint8_t Devicenum; //设备编号
  98. char card_num[10]; //卡盒编号
  99. uint8_t hole1_item; //孔1检测项目
  100. uint8_t hole1_item_result; //孔1检测项目结果
  101. uint8_t hole1_result; //孔1检测结果
  102. uint8_t hole1_Tt[2]; //孔1 Tt
  103. uint8_t hole2_item; //孔2检测项目
  104. uint8_t hole2_item_result; //孔2检测项目结果
  105. uint8_t hole2_result; //孔2检测结果
  106. uint8_t hole2_Tt[2] ; //孔2 Tt
  107. uint8_t hole3_item; //孔3检测项目
  108. uint8_t hole3_item_result; //孔3检测项目结果
  109. uint8_t hole3_result; //孔3检测结果
  110. uint8_t hole3_Tt[2]; //孔3 Tt
  111. uint8_t hole4_item; //孔4检测项目
  112. uint8_t hole4_item_result; //孔4检测项目结果
  113. uint8_t hole4_result; //孔4检测结果
  114. uint8_t hole4_Tt[2]; //孔4 Tt
  115. uint8_t hole5_item; //孔5检测项目
  116. uint8_t hole5_item_result; //孔5检测项目结果
  117. uint8_t hole5_result; //孔5检测结果
  118. uint8_t hole5_Tt[2]; //孔5 Tt
  119. uint8_t hole6_item; //孔6检测项目
  120. uint8_t hole6_item_result; //孔6检测项目结果
  121. uint8_t hole6_result; //孔6检测结果
  122. uint8_t hole6_Tt[2]; //孔6 Tt
  123. uint8_t hole7_item; //孔7检测项目
  124. uint8_t hole7_item_result; //孔7检测项目结果
  125. uint8_t hole7_result; //孔7检测结果
  126. uint8_t hole7_Tt[2]; //孔7 Tt
  127. uint8_t hole8_item; //孔8检测项目
  128. uint8_t hole8_item_result; //孔8检测项目结果
  129. uint8_t hole8_result; //孔8检测结果
  130. uint8_t hole8_Tt[2]; //孔8 Tt
  131. uint8_t hole9_item; //孔9检测项目
  132. uint8_t hole9_item_result; //孔9检测项目结果
  133. uint8_t hole9_result; //孔9检测结果
  134. uint8_t hole9_Tt[2]; //孔9 Tt
  135. uint8_t hole10_item; //孔10检测项目
  136. uint8_t hole10_item_result; //孔10检测项目结果
  137. uint8_t hole10_result; //孔10检测结果
  138. uint8_t hole10_Tt[2]; //孔10 Tt
  139. }test_result_struct;
  140. typedef struct str_error_info
  141. {
  142. uint8_t id; //板卡id
  143. uint8_t error_code; //错误码
  144. char SN[10];
  145. uint8_t error_report; //错误码
  146. } str_error_info_t;
  147. typedef struct str_hole_info
  148. {
  149. uint8_t item;
  150. uint8_t TtMax[2];
  151. uint8_t TtMin[2];
  152. } str_hole_info_t;
  153. //str_hole_info_t hole1,hole2,hole3,hole4,hole5,hole6,hole7,hole8,hole9,hole10;
  154. typedef struct str_card_param_info
  155. {
  156. char pid[10];
  157. uint8_t temp[2];
  158. struct str_hole_info hole_info[10];
  159. } str_card_param_info_t;
  160. typedef struct
  161. {
  162. uint8_t id; //设备编号
  163. uint8_t heat_state; //串口控制加热状态
  164. uint8_t temp_stable_sta; //串口控制加热状态
  165. float heater_temp; //加热体温度
  166. uint8_t fan_state; //风扇状态
  167. float heater_independent_temp;
  168. }heat_ctrl_struct;
  169. typedef struct //由于flash_write是按4字节写入,所以本结构体内部都按4字节定义和对齐
  170. {
  171. float presetTempVal; //拉升温度
  172. uint32_t presetTempTime; //拉升保持时间
  173. float setTempVal; //设定温度
  174. float holdTemp; //稳定温度
  175. float tempOffset; //温度补偿
  176. uint32_t preHeatTime; //上电预热时间,min
  177. float readyTemp; //就绪温度
  178. uint32_t log_level; //日志等级
  179. uint32_t skip_CheckOrRun; //插入光变化检测
  180. float adjtemp; //调整温度
  181. }CFG_PARAM_STRUCT;
  182. typedef struct ProcessStateMachine
  183. {
  184. StatusWord_t state;
  185. inner_action_flags_t flags;
  186. float DataBufRDR[MAX_DATA_BUF_SIZE][10];
  187. uint32_t DataSendHeader; //串口超时
  188. uint32_t DataSendLast; //串口超时
  189. unsigned int sendconter;
  190. unsigned int updateresult;
  191. unsigned int cursendok;
  192. unsigned int sendTime ;
  193. unsigned int sampleStart;
  194. unsigned int sampleTimes;
  195. unsigned int heat_timeout; //加热超时
  196. unsigned int scan_qrcode_done;
  197. unsigned int statusword;
  198. unsigned int controlword;
  199. str_card_param_info_t card_param_info;
  200. } ProcessStateMachine_t;
  201. void resend_error_update(void);
  202. void re_send_state(void);
  203. uint32_t get_master_st(float *temp,unsigned int *st);
  204. uint32_t get_slave_st(float *temp,unsigned int *st);
  205. void updateAmplifState(uint8_t newset);
  206. void updateLysisState(uint8_t newset);
  207. void updateData_next(unsigned int recdex,unsigned char * part);
  208. void clean_reult_next(unsigned char * part);
  209. uint8_t error_set(uint8_t error);
  210. void error_clear(void);
  211. void usr_state_machine(ProcessStateMachine_t *sts, heat_ctrl_def *heater);
  212. void resetSampleData(ProcessStateMachine_t *psm);
  213. #endif