Browse Source

update

storage-in-realtime
zhaohe 12 months ago
parent
commit
7daa234377
  1. 10
      appsrc/service/app/add_liquid_service.cpp
  2. 11
      appsrc/service/app/air_leak_detect_test.cpp
  3. 2
      appsrc/service/app/drain_liquid_service.cpp
  4. 6
      appsrc/service/hardware/device_io_ctrl_service.cpp
  5. 2
      appsrc/service/hardware/disinfectant_weight_update_service.cpp
  6. 2
      appsrc/service/hardware/disinfectant_weight_update_service.hpp

10
appsrc/service/app/add_liquid_service.cpp

@ -22,7 +22,9 @@ void AddLiquidService::initialize() {
void AddLiquidService::start(int stopatg) { void AddLiquidService::start(int stopatg) {
lock_guard<recursive_mutex> lock(lock_); lock_guard<recursive_mutex> lock(lock_);
auto nowstate = m_ds->getDeviceState();
auto nowstate = m_ds->getDeviceState();
if (nowstate != DeviceState::Idle) { if (nowstate != DeviceState::Idle) {
logger->warn("start add liquid fail, device state is not idle"); logger->warn("start add liquid fail, device state is not idle");
THROW_APP_EXCEPTION(getDeviceBusyReason(nowstate), ""); THROW_APP_EXCEPTION(getDeviceBusyReason(nowstate), "");
@ -32,10 +34,6 @@ void AddLiquidService::start(int stopatg) {
THROW_APP_EXCEPTION(err::kappe_exception_flag_is_setted, ""); THROW_APP_EXCEPTION(err::kappe_exception_flag_is_setted, "");
} }
if (DS->getDeviceState() != DeviceState::Idle) {
THROW_APP_EXCEPTION(err::kappe_state_is_busy, "");
}
if (zsteady_clock().gets() < SENSOR_PREHEART_TIME_S) { if (zsteady_clock().gets() < SENSOR_PREHEART_TIME_S) {
THROW_APP_EXCEPTION(err::kappe_sensor_is_pre_hearting, ""); THROW_APP_EXCEPTION(err::kappe_sensor_is_pre_hearting, "");
} }
@ -67,6 +65,7 @@ void AddLiquidService::start(int stopatg) {
} }
m_workstate = kaddingLiquid; m_workstate = kaddingLiquid;
DS->setDeviceState(DeviceState::AddingLiquid);
m_thread.reset(new Thread("addLiquid", [this, stopatg]() { m_thread.reset(new Thread("addLiquid", [this, stopatg]() {
ThisThread thisThread; ThisThread thisThread;
bool errorflag = false; bool errorflag = false;
@ -83,6 +82,7 @@ void AddLiquidService::start(int stopatg) {
GET_SERVICE(IflytopFrontEndService)->sendPrompt("加液完成"); GET_SERVICE(IflytopFrontEndService)->sendPrompt("加液完成");
} }
m_workstate = kidle; m_workstate = kidle;
DS->setDeviceState(DeviceState::Idle);
})); }));
// //
logger->info("start add liquid success"); logger->info("start add liquid success");

11
appsrc/service/app/air_leak_detect_test.cpp

@ -14,12 +14,18 @@ void AirLeakDetectTest::initialize() {
REG_EXTFN_VOID(stop, void()); REG_EXTFN_VOID(stop, void());
REG_EXTFN_VOID(getState, void()); REG_EXTFN_VOID(getState, void());
REG_EXTFN_VOID(getServiceConfig, void()); REG_EXTFN_VOID(getServiceConfig, void());
} }
void AirLeakDetectTest::start() { void AirLeakDetectTest::start() {
logger->info("AirLeakDetectTest start"); logger->info("AirLeakDetectTest start");
auto nowstate = m_ds->getDeviceState();
if (nowstate != DeviceState::Idle) {
logger->warn("start add liquid fail, device state is not idle");
THROW_APP_EXCEPTION(getDeviceBusyReason(nowstate), "");
}
m_workstate = kinitDevice; m_workstate = kinitDevice;
DS->setDeviceState(DeviceState::AirLeakDetectTesting);
m_thread.reset(new Thread("AirLeakDetectTestThread", [this]() { m_thread.reset(new Thread("AirLeakDetectTestThread", [this]() {
try { try {
airLeakDetectTestThread(); airLeakDetectTestThread();
@ -35,6 +41,7 @@ void AirLeakDetectTest::start() {
} }
m_workstate = kidle; m_workstate = kidle;
DS->setDeviceState(DeviceState::Idle);
})); }));
} }
void AirLeakDetectTest::stop() { void AirLeakDetectTest::stop() {
@ -105,6 +112,6 @@ void AirLeakDetectTest::getServiceConfig(shared_ptr<MsgProcessContext> cxt) {
cfg["pressureMax"] = 8.0; cfg["pressureMax"] = 8.0;
cfg["show"] = true; cfg["show"] = true;
cfg["updatePeriod"] = 300; cfg["updatePeriod"] = 300;
cxt->rely = cfg;
cxt->rely = cfg;
} }
} }

2
appsrc/service/app/drain_liquid_service.cpp

@ -51,6 +51,7 @@ void DrainLiquidService::start() {
} }
m_workstate = kwork; m_workstate = kwork;
DS->setDeviceState(DeviceState::DrainingLiquid);
m_thread.reset(new Thread("drainLiquid", [this]() { m_thread.reset(new Thread("drainLiquid", [this]() {
try { try {
workThread(); workThread();
@ -59,6 +60,7 @@ void DrainLiquidService::start() {
DS->setAppExceptionFlag(e); DS->setAppExceptionFlag(e);
} }
m_workstate = kidle; m_workstate = kidle;
DS->setDeviceState(DeviceState::Idle);
})); }));
} }
DrainLiquidService::state_t DrainLiquidService::getWorkstate() { return m_workstate; } DrainLiquidService::state_t DrainLiquidService::getWorkstate() { return m_workstate; }

6
appsrc/service/hardware/device_io_ctrl_service.cpp

@ -256,7 +256,7 @@ int DeviceIoControlService::AC_close() {
return 0; return 0;
} }
float DeviceIoControlService::AC_readEI() { float DeviceIoControlService::AC_readEI() {
logger->info(" AC_readEI");
// logger->info(" AC_readEI");
if (!isInTestMode()) return CAN_MASTER->airCompressorReadEI(GET_BOARDID()) / 1000.0; if (!isInTestMode()) return CAN_MASTER->airCompressorReadEI(GET_BOARDID()) / 1000.0;
return 0; return 0;
} }
@ -276,12 +276,12 @@ int DeviceIoControlService::Heater_close() {
return 0; return 0;
} }
float DeviceIoControlService::Heater_readEI() { float DeviceIoControlService::Heater_readEI() {
logger->info(" Heater_readEI");
// logger->info(" Heater_readEI");
if (!isInTestMode()) return CAN_MASTER->heaterReadEI(GET_BOARDID()) / 1000.0; if (!isInTestMode()) return CAN_MASTER->heaterReadEI(GET_BOARDID()) / 1000.0;
return 0; return 0;
} }
float DeviceIoControlService::Heater_readTemperature() { float DeviceIoControlService::Heater_readTemperature() {
logger->info(" Heater_readTemperature");
// logger->info(" Heater_readTemperature");
if (!isInTestMode()) return CAN_MASTER->heaterReadTemperature(GET_BOARDID()) / 10.0; if (!isInTestMode()) return CAN_MASTER->heaterReadTemperature(GET_BOARDID()) / 10.0;
return 0; return 0;
} }

2
appsrc/service/hardware/disinfectant_weight_update_service.cpp

@ -47,6 +47,6 @@ void DisinfectantWeightUpdateService::updateWeightThread() {
logger->error("updateWeightThread error: {}", e.what()); logger->error("updateWeightThread error: {}", e.what());
DS->setAppExceptionFlag(e); DS->setAppExceptionFlag(e);
} }
usleep(500);
usleep(1000*1000);
} }
} }

2
appsrc/service/hardware/disinfectant_weight_update_service.hpp

@ -38,7 +38,7 @@ class DisinfectantWeightUpdateService : public enable_shared_from_this<Disinfect
unique_ptr<Thread> updateThread; unique_ptr<Thread> updateThread;
shared_ptr<DeviceIoControlService> deviceIoControlService; shared_ptr<DeviceIoControlService> deviceIoControlService;
MovingAverageFilter filter = {10};
MovingAverageFilter filter = {5};
float weightCache = 0; float weightCache = 0;
public: public:

Loading…
Cancel
Save