|
@ -13,8 +13,8 @@ using namespace std; |
|
|
-通断电磁阀 3 PC7 5 |
|
|
-通断电磁阀 3 PC7 5 |
|
|
#endif
|
|
|
#endif
|
|
|
|
|
|
|
|
|
#define GPM_TO_SPEED(gpm) (gpm * 3.07)
|
|
|
|
|
|
#define SPEED_TO_GPM(speed) (speed / 3.07)
|
|
|
|
|
|
|
|
|
#define GPM_TO_SPEED(gpm) (gpm * 10)
|
|
|
|
|
|
#define SPEED_TO_GPM(speed) (speed / 10)
|
|
|
|
|
|
|
|
|
DeviceIoControlService::DeviceIoControlService() {} |
|
|
DeviceIoControlService::DeviceIoControlService() {} |
|
|
void DeviceIoControlService::initialize() { GET_TO_SERVICE(m_zcanHost); } |
|
|
void DeviceIoControlService::initialize() { GET_TO_SERVICE(m_zcanHost); } |
|
@ -164,9 +164,10 @@ void DeviceIoControlService::drainingPump_close() { |
|
|
logger->info("drainingPump_close"); |
|
|
logger->info("drainingPump_close"); |
|
|
m_zcanHost->pumpctrl_c1004(1, 100, 0, 1, 20); |
|
|
m_zcanHost->pumpctrl_c1004(1, 100, 0, 1, 20); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#define replenishingFluidsPump_GPM2RPM(gpm) (gpm / 2)
|
|
|
void DeviceIoControlService::replenishingFluidsPump_open() { |
|
|
void DeviceIoControlService::replenishingFluidsPump_open() { |
|
|
logger->info("replenishingFluidsPump_open"); |
|
|
logger->info("replenishingFluidsPump_open"); |
|
|
|
|
|
// 600g/m 300RPM
|
|
|
m_zcanHost->pumpctrl_c1004(1, 100, 300, 1, 20); |
|
|
m_zcanHost->pumpctrl_c1004(1, 100, 300, 1, 20); |
|
|
} |
|
|
} |
|
|
void DeviceIoControlService::replenishingFluidsPump_close() { |
|
|
void DeviceIoControlService::replenishingFluidsPump_close() { |
|
@ -176,7 +177,7 @@ void DeviceIoControlService::replenishingFluidsPump_close() { |
|
|
|
|
|
|
|
|
void DeviceIoControlService::replenishingFluidsPump_open_for_test(int gpm) { |
|
|
void DeviceIoControlService::replenishingFluidsPump_open_for_test(int gpm) { |
|
|
logger->info("replenishingFluidsPump_open_for_test {}", gpm); |
|
|
logger->info("replenishingFluidsPump_open_for_test {}", gpm); |
|
|
int speed = GPM_TO_SPEED(gpm); |
|
|
|
|
|
|
|
|
int speed = replenishingFluidsPump_GPM2RPM(gpm); |
|
|
if (speed > 300) { |
|
|
if (speed > 300) { |
|
|
speed = 300; |
|
|
speed = 300; |
|
|
} else if (speed < -300) { |
|
|
} else if (speed < -300) { |
|
@ -192,10 +193,10 @@ void DeviceIoControlService::replenishingFluidsPump_close_for_test() { |
|
|
* sprayLiquidPump * |
|
|
* sprayLiquidPump * |
|
|
*******************************************************************************/ |
|
|
*******************************************************************************/ |
|
|
void DeviceIoControlService::sprayLiquidPump_open(int gpm) { |
|
|
void DeviceIoControlService::sprayLiquidPump_open(int gpm) { |
|
|
logger->info("sprayLiquidPump_open"); |
|
|
|
|
|
|
|
|
logger->info("sprayLiquidPump_open {}", gpm); |
|
|
int speed = GPM_TO_SPEED(gpm); |
|
|
int speed = GPM_TO_SPEED(gpm); |
|
|
if (speed > 300) { |
|
|
|
|
|
speed = 300; |
|
|
|
|
|
|
|
|
if (speed > 400) { |
|
|
|
|
|
speed = 400; |
|
|
} else if (speed < 0) { |
|
|
} else if (speed < 0) { |
|
|
speed = 0; |
|
|
speed = 0; |
|
|
} |
|
|
} |
|
@ -207,12 +208,12 @@ void DeviceIoControlService::sprayLiquidPump_close() { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void DeviceIoControlService::sprayLiquidPump_open_for_test(int gpm) { |
|
|
void DeviceIoControlService::sprayLiquidPump_open_for_test(int gpm) { |
|
|
logger->info("sprayLiquidPump_open"); |
|
|
|
|
|
|
|
|
logger->info("sprayLiquidPump_open {}", gpm); |
|
|
int speed = GPM_TO_SPEED(gpm); |
|
|
int speed = GPM_TO_SPEED(gpm); |
|
|
if (speed > 300) { |
|
|
|
|
|
speed = 300; |
|
|
|
|
|
} else if (speed < -300) { |
|
|
|
|
|
speed = -300; |
|
|
|
|
|
|
|
|
if (speed > 400) { |
|
|
|
|
|
speed = 400; |
|
|
|
|
|
} else if (speed < -400) { |
|
|
|
|
|
speed = -400; |
|
|
} |
|
|
} |
|
|
m_zcanHost->pumpctrl_c1004(2, 100, speed, 1, 15); |
|
|
m_zcanHost->pumpctrl_c1004(2, 100, speed, 1, 15); |
|
|
} |
|
|
} |
|
@ -232,6 +233,34 @@ int DeviceIoControlService::sprayLiquidPump_getState() { // |
|
|
/*******************************************************************************
|
|
|
/*******************************************************************************
|
|
|
* SensorState * |
|
|
* SensorState * |
|
|
*******************************************************************************/ |
|
|
*******************************************************************************/ |
|
|
|
|
|
|
|
|
|
|
|
static int filter(int data) { |
|
|
|
|
|
static list<int> q; |
|
|
|
|
|
q.push_back(data); |
|
|
|
|
|
|
|
|
|
|
|
if (q.size() > 50) { |
|
|
|
|
|
q.pop_front(); |
|
|
|
|
|
} |
|
|
|
|
|
// 中值滤波
|
|
|
|
|
|
int datacache[51]; |
|
|
|
|
|
int ndata = 0; |
|
|
|
|
|
for (auto& var : q) { |
|
|
|
|
|
datacache[ndata] = var; |
|
|
|
|
|
ndata++; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < ndata; i++) { |
|
|
|
|
|
for (int j = i + 1; j < ndata; j++) { |
|
|
|
|
|
if (datacache[i] > datacache[j]) { |
|
|
|
|
|
int temp = datacache[i]; |
|
|
|
|
|
datacache[i] = datacache[j]; |
|
|
|
|
|
datacache[j] = temp; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return datacache[ndata / 2]; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
int DeviceIoControlService::getDisinfectantVolume_g() { |
|
|
int DeviceIoControlService::getDisinfectantVolume_g() { |
|
|
// kpa;
|
|
|
// kpa;
|
|
|
lock_guard<recursive_mutex> lock(lock_); |
|
|
lock_guard<recursive_mutex> lock(lock_); |
|
@ -243,6 +272,8 @@ int DeviceIoControlService::getDisinfectantVolume_g() { |
|
|
} else { |
|
|
} else { |
|
|
g -= 450; |
|
|
g -= 450; |
|
|
} |
|
|
} |
|
|
|
|
|
g = filter(g); |
|
|
|
|
|
// logger->info("g {}", g);
|
|
|
return g; |
|
|
return g; |
|
|
} |
|
|
} |
|
|
int DeviceIoControlService::getPressureSensorData(int index) { |
|
|
int DeviceIoControlService::getPressureSensorData(int index) { |
|
|