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.

139 lines
3.6 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. } disinfection_state_t;
  39. class StateSnapshot {
  40. public:
  41. disinfection_state_t state;
  42. zsystem_tp time;
  43. int32_t h2o2[MAX_H2O2_SENSOR_NUM]; // ppm
  44. int32_t humid[MAX_H2O2_SENSOR_NUM]; // %RH
  45. int32_t temp[MAX_H2O2_SENSOR_NUM]; // °C
  46. int32_t saturation[MAX_H2O2_SENSOR_NUM]; // %RS
  47. int min_h2o2;
  48. int max_h2o2;
  49. int max_humid;
  50. int max_saturation;
  51. float dloglevel;
  52. };
  53. class DisinfectionPrinterTask {
  54. public:
  55. string disinfection_id;
  56. string usr;
  57. vector<shared_ptr<StateSnapshot>> stateSnapshotList; // 状态快照I
  58. int disinfectantUsage; // 消毒剂使用量
  59. zsystem_tp start_tp;
  60. zsystem_tp complete_tp;
  61. int targetLog;
  62. int actualLog;
  63. int disinfectantVolume; // g
  64. };
  65. class DisinfectionContext {
  66. public:
  67. string m_disinfectionID;
  68. disinfection_state_t m_state = kstate_idle;
  69. zsteady_tp start_steady_tp;
  70. zsystem_tp start_tp;
  71. zsystem_tp complete_tp;
  72. /**
  73. * @brief
  74. */
  75. int pre_heat_time_s = 0; // 预热时间
  76. int stoped_gs = 0; // 停止H2O2浓度
  77. int continued_gs = 0; // 继续H2O2浓度
  78. int stoped_satur = 0; // 停止饱和度
  79. int continued_satur = 0; // 继续饱和度
  80. int stoped_humi = 0; // 停止湿度
  81. int continued_humi = 0; // 继续湿度
  82. int injection_pump_speed;
  83. bool injection_pump_speed_changed = false;
  84. float cfg_targetLoglevel = 0;
  85. /**
  86. * @brief
  87. */
  88. zsteady_tp state_last_compute_dvalue_tp; // 上次计算dvalue时间
  89. zsteady_tp state_lastlog_tp; // 上次日志时间
  90. int state_remaintime = 0;
  91. float state_now_loglevel = 0;
  92. float state_dvalue = 0;
  93. bool state_is_disinfection_take_break; // 消毒工作中是否暂停工作
  94. /*******************************************************************************
  95. * *
  96. *******************************************************************************/
  97. int32_t h2o2[MAX_H2O2_SENSOR_NUM]; // ppm
  98. int32_t humid[MAX_H2O2_SENSOR_NUM]; // %RH
  99. int32_t temp[MAX_H2O2_SENSOR_NUM]; // °C
  100. int32_t saturation[MAX_H2O2_SENSOR_NUM]; // %RS
  101. int min_h2o2;
  102. int max_h2o2;
  103. int max_humid;
  104. int max_saturation;
  105. /*******************************************************************************
  106. * *
  107. *******************************************************************************/
  108. shared_ptr<DisinfectionLogger> csvlogger; // 日志记录器
  109. vector<shared_ptr<StateSnapshot>> stateSnapshotList; // 状态快照I
  110. int beforeDisinfectantVolume_g; // 消毒前消毒剂量
  111. int afterDisinfectantVolume_g; // 消毒后消毒剂量
  112. bool firstLog;
  113. };
  114. } // namespace iflytop