You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

142 lines
3.8 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. //
  2. // Created by zwsd
  3. //
  4. #pragma once
  5. #include <fstream>
  6. #include <iostream>
  7. #include <list>
  8. #include <map>
  9. #include <memory>
  10. #include <mutex>
  11. #include <set>
  12. #include <sstream>
  13. #include <string>
  14. #include <vector>
  15. #include "configs/project_setting.hpp"
  16. #include "iflytop/core/components/timeutils.hpp"
  17. /**
  18. * @brief
  19. *
  20. * service: DisinfectionCtrlService
  21. *
  22. * :
  23. * :
  24. * :
  25. * :
  26. *
  27. */
  28. namespace iflytop {
  29. using namespace std;
  30. using namespace core;
  31. class DisinfectionLogger;
  32. typedef enum {
  33. kstate_idle = 0, // 空闲
  34. kstate_preheat = 1, // 预热
  35. kstate_disinfection = 2, // 消毒中-工作
  36. kstate_degradation = 4, // 降解中
  37. kstate_finished = 5, // 结束
  38. kstate_dehumidification_before_disinfection = 6, // 消毒前除湿
  39. kstate_dehumidification_after_disinfection = 7, // 消毒后除湿
  40. } disinfection_state_t;
  41. class StateSnapshot {
  42. public:
  43. disinfection_state_t state;
  44. zsystem_tp time;
  45. int32_t h2o2[MAX_H2O2_SENSOR_NUM]; // ppm
  46. int32_t humid[MAX_H2O2_SENSOR_NUM]; // %RH
  47. int32_t temp[MAX_H2O2_SENSOR_NUM]; // °C
  48. int32_t saturation[MAX_H2O2_SENSOR_NUM]; // %RS
  49. int min_h2o2;
  50. int max_h2o2;
  51. int max_humid;
  52. int max_saturation;
  53. float dloglevel;
  54. };
  55. class DisinfectionPrinterTask {
  56. public:
  57. string disinfection_id;
  58. string usr;
  59. vector<shared_ptr<StateSnapshot>> stateSnapshotList; // 状态快照I
  60. int disinfectantUsage; // 消毒剂使用量
  61. zsystem_tp start_tp;
  62. zsystem_tp complete_tp;
  63. int targetLog;
  64. int actualLog;
  65. int disinfectantVolume; // g
  66. };
  67. class DisinfectionContext {
  68. public:
  69. string m_disinfectionID;
  70. disinfection_state_t m_state = kstate_idle;
  71. zsteady_tp start_steady_tp;
  72. zsystem_tp start_tp;
  73. zsystem_tp complete_tp;
  74. /**
  75. * @brief
  76. */
  77. int pre_heat_time_s = 0; // 预热时间
  78. int stoped_gs = 0; // 停止H2O2浓度
  79. int continued_gs = 0; // 继续H2O2浓度
  80. int stoped_satur = 0; // 停止饱和度
  81. int continued_satur = 0; // 继续饱和度
  82. int stoped_humi = 0; // 停止湿度
  83. int continued_humi = 0; // 继续湿度
  84. int injection_pump_speed;
  85. bool injection_pump_speed_changed = false;
  86. float cfg_targetLoglevel = 0;
  87. /**
  88. * @brief
  89. */
  90. zsteady_tp state_last_compute_dvalue_tp; // 上次计算dvalue时间
  91. zsteady_tp state_lastlog_tp; // 上次日志时间
  92. int state_remaintime = 0;
  93. float state_now_loglevel = 0;
  94. float state_dvalue = 0;
  95. bool state_is_disinfection_take_break; // 消毒工作中是否暂停工作
  96. /*******************************************************************************
  97. * *
  98. *******************************************************************************/
  99. int32_t h2o2[MAX_H2O2_SENSOR_NUM]; // ppm
  100. int32_t humid[MAX_H2O2_SENSOR_NUM]; // %RH
  101. int32_t temp[MAX_H2O2_SENSOR_NUM]; // °C
  102. int32_t saturation[MAX_H2O2_SENSOR_NUM]; // %RS
  103. int min_h2o2;
  104. int max_h2o2;
  105. int max_humid;
  106. int max_saturation;
  107. /*******************************************************************************
  108. * *
  109. *******************************************************************************/
  110. shared_ptr<DisinfectionLogger> csvlogger; // 日志记录器
  111. vector<shared_ptr<StateSnapshot>> stateSnapshotList; // 状态快照I
  112. int beforeDisinfectantVolume_g; // 消毒前消毒剂量
  113. int afterDisinfectantVolume_g; // 消毒后消毒剂量
  114. bool firstLog;
  115. };
  116. } // namespace iflytop