diff --git a/src/main_control_service.cpp b/src/main_control_service.cpp index 073c67d..3802579 100644 --- a/src/main_control_service.cpp +++ b/src/main_control_service.cpp @@ -673,6 +673,7 @@ void MainControlService::processFrontEndMessage(weak_ptr webSocket, j processFrontEndMessage_processFormulaCmd(webSocket, cmd, receipt); processFrontEndMessage_processBehaviorRecordCmd(webSocket, cmd, receipt); processFrontEndMessage_exportData(webSocket, cmd, receipt); + processFrontEndMessage_DeviceIOControlService(webSocket, cmd, receipt); /******************************************************************************* * getState * *******************************************************************************/ @@ -756,6 +757,7 @@ void MainControlService::processFrontEndMessage_DeviceIOControlService(weak_ptr< return; } if (cmdstr == "DeviceIOControlService.AirInletProportionalValve_getState") { + // logger->info("DeviceIOControlService.AirInletProportionalValve_getState......................."); receipt["ack"][0] = m_deviceIoControlService->AirInletProportionalValve_getState(); return; } @@ -763,7 +765,6 @@ void MainControlService::processFrontEndMessage_DeviceIOControlService(weak_ptr< receipt["ack"][0] = m_deviceIoControlService->AirOutletProportionalValve_getState(); return; } - if (cmdstr == "DeviceIOControlService.AirOutletProportionalValve_setState") { m_deviceIoControlService->AirOutletProportionalValve_setState(cmd["params"][0]); return; diff --git a/src/service/device_io_control_service.cpp b/src/service/device_io_control_service.cpp index 66f56f9..c0030ec 100644 --- a/src/service/device_io_control_service.cpp +++ b/src/service/device_io_control_service.cpp @@ -101,9 +101,9 @@ void DeviceIoControlService::startScan() { })); } -void DeviceIoControlService::airCompressor_setState(bool val) { +void DeviceIoControlService::airCompressor_setState(int32_t val) { logger->info("airCompressor_setState:{}", val); - if (val) { + if (val > 0) { m_zcanHost->writeio(0, 1); usleep(500 * 100); m_zcanHost->writeio(1, 1); @@ -116,13 +116,9 @@ void DeviceIoControlService::airCompressor_setState(bool val) { int DeviceIoControlService::airCompressor_getio1() { return m_zcanHost->read_writeio_state_cache(0); } int DeviceIoControlService::airCompressor_getio2() { return m_zcanHost->read_writeio_state_cache(1); } int DeviceIoControlService::airCompressor_getcurrentValue() { return m_adc_0 * 0.00167 - 1.25; } -int DeviceIoControlService::airCompressor_channelCtrl(bool chOpen) { - m_airCompressor_channelState = chOpen; - if (chOpen) { - m_zcanHost->call(kcmd_air_compressor_ch_ctrl, 1); - } else { - m_zcanHost->call(kcmd_air_compressor_ch_ctrl, 0); - } +int DeviceIoControlService::airCompressor_channelCtrl(int32_t val) { + m_airCompressor_channelState = val; + m_zcanHost->call(kcmd_air_compressor_ch_ctrl, val); return 0; } bool DeviceIoControlService::airCompressor_getChannelState() { return m_airCompressor_channelState; } diff --git a/src/service/device_io_control_service.hpp b/src/service/device_io_control_service.hpp index 772fcab..da0ba28 100644 --- a/src/service/device_io_control_service.hpp +++ b/src/service/device_io_control_service.hpp @@ -62,7 +62,7 @@ class DeviceIoControlService : public enable_shared_from_this