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.

128 lines
3.1 KiB

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. };
  52. class DisinfectionPrinterTask {
  53. public:
  54. list<shared_ptr<StateSnapshot>> stateSnapshotList; // 状态快照I
  55. int disinfectantUsage; // 消毒剂使用量
  56. zsystem_tp start_tp;
  57. zsystem_tp complete_tp;
  58. bool stoped_by_usr = false;
  59. };
  60. class DisinfectionContext {
  61. public:
  62. string m_disinfectionID;
  63. disinfection_state_t m_state = kstate_idle;
  64. zsteady_tp m_lastComputeDvalueTp;
  65. zsteady_tp m_lastlogTp;
  66. zsteady_tp disinfection_start_steady_tp;
  67. int m_remaintime = 0;
  68. float m_targetLoglevel = 0;
  69. float m_nowLoglevel = 0;
  70. float dvalue = 0;
  71. int injection_pump_speed;
  72. bool injection_pump_speed_changed = false;
  73. int pre_heat_time_s = 0;
  74. int stoped_gs = 0;
  75. int continued_gs = 0;
  76. int stoped_satur = 0;
  77. int continued_satur = 0;
  78. int stoped_humi = 0;
  79. int continued_humi = 0;
  80. shared_ptr<DisinfectionLogger> csvlogger;
  81. bool isDisinfectionTakeBreak; // 消毒工作中是否暂停工作
  82. /*******************************************************************************
  83. * *
  84. *******************************************************************************/
  85. int32_t h2o2[MAX_H2O2_SENSOR_NUM]; // ppm
  86. int32_t humid[MAX_H2O2_SENSOR_NUM]; // %RH
  87. int32_t temp[MAX_H2O2_SENSOR_NUM]; // °C
  88. int32_t saturation[MAX_H2O2_SENSOR_NUM]; // %RS
  89. int min_h2o2;
  90. int max_h2o2;
  91. int max_humid;
  92. int max_saturation;
  93. /*******************************************************************************
  94. * *
  95. *******************************************************************************/
  96. list<shared_ptr<StateSnapshot>> stateSnapshotList; // 状态快照I
  97. int beforeDisinfectantVolume_g; // 消毒前消毒剂量
  98. int afterDisinfectantVolume_g; // 消毒后消毒剂量
  99. zsystem_tp disinfection_start_tp;
  100. zsystem_tp disinfection_complete_tp;
  101. bool stoped_by_usr = false;
  102. };
  103. } // namespace iflytop