5 changed files with 96 additions and 48 deletions
-
3src/configs/gconfig.hpp
-
33src/service/disinfection_ctl_service.cpp
-
38src/service/disinfection_ctl_service.hpp
-
54src/utils/dvalue_computer.cpp
-
16src/utils/dvalue_computer.hpp
@ -0,0 +1,54 @@ |
|||
#include "dvalue_computer.hpp"
|
|||
|
|||
#include <cmath>
|
|||
|
|||
#include "zservice_container/zservice_container.hpp"
|
|||
using namespace iflytop; |
|||
using namespace std; |
|||
|
|||
static bool zfeq(float a, float b, float eps = 0.01) { |
|||
if (fabs(a - b) < eps) { |
|||
return true; |
|||
} |
|||
return false; |
|||
} |
|||
|
|||
void DValueComputer::initialize() { |
|||
/**
|
|||
* @brief |
|||
*/ |
|||
|
|||
m_config = GET_SERVICE(GConfig); |
|||
} |
|||
|
|||
float DValueComputer::computeDValue(float h2o2ppm) { |
|||
/**
|
|||
* @brief |
|||
* |
|||
* D值的计算公式是根据美国竞品的数据记录计算得来的 |
|||
* |
|||
* 浓度小于150时,y=-0.5269X+97.868 |
|||
* 浓度大于150时,y=-0.1405X+40.369 |
|||
*/ |
|||
|
|||
if (zfeq(h2o2ppm, 0)) { |
|||
return -1; |
|||
} |
|||
|
|||
float dvalue = 0; |
|||
|
|||
if (h2o2ppm < 150) { |
|||
//
|
|||
dvalue = -0.5251 * h2o2ppm * m_config->get_dvalueCoefficient() + 98.154; |
|||
} else if (h2o2ppm >= 150 && h2o2ppm < 240) { |
|||
//
|
|||
dvalue = -0.125 * h2o2ppm * m_config->get_dvalueCoefficient() + 38.913; |
|||
} else if (h2o2ppm >= 240) { |
|||
//
|
|||
dvalue = -0.00596 * h2o2ppm * m_config->get_dvalueCoefficient() + 10.3434; |
|||
} |
|||
if (dvalue < 2) { |
|||
dvalue = 2; |
|||
} |
|||
return dvalue; |
|||
} |
@ -0,0 +1,16 @@ |
|||
|
|||
#pragma once
|
|||
#include <stdio.h>
|
|||
|
|||
#include "configs/gconfig.hpp"
|
|||
namespace iflytop { |
|||
|
|||
class DValueComputer { |
|||
ENABLE_LOGGER(DValueComputer); |
|||
shared_ptr<GConfig> m_config; |
|||
|
|||
public: |
|||
void initialize(); |
|||
float computeDValue(float h2o2ppm); |
|||
}; |
|||
} // namespace iflytop
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue