Browse Source

修复GPM显示问题

master
zhaohe 1 year ago
parent
commit
bf86115daa
  1. 13
      src/service/device_io_control_service.cpp
  2. 2
      src/service/device_io_control_service_test.cpp

13
src/service/device_io_control_service.cpp

@ -12,7 +12,7 @@ using namespace iflytop;
using namespace std;
#define GPM_TO_SPEED(gpm) (gpm * 14.7)
#define SPEED_TO_GPM(speed) (speed / 14.7)
#define SPEED_TO_GPM(speed) ((speed / 14.7) + 0.5)
static inline int filter(int data) {
static list<int> q;
@ -391,8 +391,12 @@ void DeviceIoControlService::replenishingFluidsPump_close_for_test() {
/*******************************************************************************
* sprayLiquidPump *
*******************************************************************************/
static int32_t SprayLiquidPump__gpm;
void DeviceIoControlService::sprayLiquidPump_open(int gpm) {
logger->info("sprayLiquidPump_open {}", gpm);
SprayLiquidPump__gpm = gpm;
int speed = GPM_TO_SPEED(gpm);
if (speed > 400) {
speed = 400;
@ -403,6 +407,7 @@ void DeviceIoControlService::sprayLiquidPump_open(int gpm) {
}
void DeviceIoControlService::sprayLiquidPump_close() {
logger->info("sprayLiquidPump_close");
SprayLiquidPump__gpm = 0;
m_zcanHost->pumpctrl_c1004(2, 100, 0, 1, 15);
}
@ -414,15 +419,17 @@ void DeviceIoControlService::sprayLiquidPump_open_for_test(int gpm) {
} else if (speed < -400) {
speed = -400;
}
SprayLiquidPump__gpm = gpm;
m_zcanHost->pumpctrl_c1004(2, 100, speed, 1, 15);
}
void DeviceIoControlService::sprayLiquidPump_close_for_test() {
logger->info("sprayLiquidPump_close");
SprayLiquidPump__gpm = 0;
m_zcanHost->pumpctrl_c1004(2, 100, 0, 1, 15);
}
int DeviceIoControlService::sprayLiquidPump_getRPM() { return m_zcanHost->pumpctrl_c1004_get_speed_cache(2); }
int DeviceIoControlService::sprayLiquidPump_getGPM() { return SPEED_TO_GPM(sprayLiquidPump_getRPM()); }
int DeviceIoControlService::sprayLiquidPump_getRPM() { return GPM_TO_SPEED(SprayLiquidPump__gpm); }
int DeviceIoControlService::sprayLiquidPump_getGPM() { return SprayLiquidPump__gpm; }
int DeviceIoControlService::sprayLiquidPump_getState() { //
lock_guard<recursive_mutex> lock(lock_);

2
src/service/device_io_control_service_test.cpp

@ -290,7 +290,7 @@ int32_t DeviceIoControlServiceTest::DBDB__extValveCtrl(int index) {
return 0;
}
int32_t DeviceIoControlServiceTest::DBDB__extValBoardIsOnline() {
logger->info("DBDB__extValBoardIsOnline");
// logger->info("DBDB__extValBoardIsOnline");
return 1;
}
#endif
Loading…
Cancel
Save