state_mini.h 7.9 KB

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