From 9d4bcd759583a2f6597646f0da4bc66eec472fa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=87=A4=E5=90=89?= Date: Mon, 5 May 2025 11:47:30 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=AE=BE=E5=A4=87=E5=91=BD?= =?UTF-8?q?=E5=90=8D=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gd/common/cmd/DeviceCommandGenerator.java | 72 +++++++++--------- .../com/iflytop/gd/common/enums/cmd/CmdDevice.java | 28 +++---- .../hardware/command/handlers/AcidPumpHandler.java | 16 ++-- .../gd/hardware/command/handlers/DoorHandler.java | 2 +- .../gd/hardware/command/handlers/FanHandler.java | 12 +-- .../gd/hardware/command/handlers/HBotHandler.java | 6 +- .../drivers/DIDriver/InputDetectDriver.java | 88 +++++++++++----------- 7 files changed, 112 insertions(+), 112 deletions(-) diff --git a/src/main/java/com/iflytop/gd/common/cmd/DeviceCommandGenerator.java b/src/main/java/com/iflytop/gd/common/cmd/DeviceCommandGenerator.java index 607964d..1493031 100644 --- a/src/main/java/com/iflytop/gd/common/cmd/DeviceCommandGenerator.java +++ b/src/main/java/com/iflytop/gd/common/cmd/DeviceCommandGenerator.java @@ -567,7 +567,7 @@ public class DeviceCommandGenerator { DeviceCommandParams params = new DeviceCommandParams(); params.setCurrent(current); params.setSpeed(speed); - return setInfoCmd(CmdDevice.acid_pump1, CmdAction.set, params, "加液泵1 设置参数"); + return setInfoCmd(CmdDevice.acid_pump_1, CmdAction.set, params, "加液泵1 设置参数"); } /** @@ -580,7 +580,7 @@ public class DeviceCommandGenerator { DeviceCommandParams params = new DeviceCommandParams(); params.setCurrent(current); params.setSpeed(speed); - return setInfoCmd(CmdDevice.acid_pump2, CmdAction.set, params, "加液泵2 设置参数"); + return setInfoCmd(CmdDevice.acid_pump_2, CmdAction.set, params, "加液泵2 设置参数"); } /** @@ -593,7 +593,7 @@ public class DeviceCommandGenerator { DeviceCommandParams params = new DeviceCommandParams(); params.setCurrent(current); params.setSpeed(speed); - return setInfoCmd(CmdDevice.acid_pump3, CmdAction.set, params, "加液泵3 设置参数"); + return setInfoCmd(CmdDevice.acid_pump_3, CmdAction.set, params, "加液泵3 设置参数"); } /** @@ -606,7 +606,7 @@ public class DeviceCommandGenerator { DeviceCommandParams params = new DeviceCommandParams(); params.setCurrent(current); params.setSpeed(speed); - return setInfoCmd(CmdDevice.acid_pump4, CmdAction.set, params, "加液泵4 设置参数"); + return setInfoCmd(CmdDevice.acid_pump_4, CmdAction.set, params, "加液泵4 设置参数"); } /** @@ -619,7 +619,7 @@ public class DeviceCommandGenerator { DeviceCommandParams params = new DeviceCommandParams(); params.setCurrent(current); params.setSpeed(speed); - return setInfoCmd(CmdDevice.acid_pump5, CmdAction.set, params, "加液泵5 设置参数"); + return setInfoCmd(CmdDevice.acid_pump_5, CmdAction.set, params, "加液泵5 设置参数"); } /** @@ -632,7 +632,7 @@ public class DeviceCommandGenerator { DeviceCommandParams params = new DeviceCommandParams(); params.setCurrent(current); params.setSpeed(speed); - return setInfoCmd(CmdDevice.acid_pump6, CmdAction.set, params, "加液泵6 设置参数"); + return setInfoCmd(CmdDevice.acid_pump_6, CmdAction.set, params, "加液泵6 设置参数"); } /** @@ -645,7 +645,7 @@ public class DeviceCommandGenerator { DeviceCommandParams params = new DeviceCommandParams(); params.setCurrent(current); params.setSpeed(speed); - return setInfoCmd(CmdDevice.acid_pump7, CmdAction.set, params, "加液泵7 设置参数"); + return setInfoCmd(CmdDevice.acid_pump_7, CmdAction.set, params, "加液泵7 设置参数"); } /** @@ -658,7 +658,7 @@ public class DeviceCommandGenerator { DeviceCommandParams params = new DeviceCommandParams(); params.setCurrent(current); params.setSpeed(speed); - return setInfoCmd(CmdDevice.acid_pump8, CmdAction.set, params, "加液泵8 设置参数"); + return setInfoCmd(CmdDevice.acid_pump_8, CmdAction.set, params, "加液泵8 设置参数"); } /** @@ -671,7 +671,7 @@ public class DeviceCommandGenerator { DeviceCommandParams params = new DeviceCommandParams(); params.setDirection(direction); params.setVolume(volume); - return setInfoCmd(CmdDevice.acid_pump1, CmdAction.move, params, "加液泵1 移动"); + return setInfoCmd(CmdDevice.acid_pump_1, CmdAction.move, params, "加液泵1 移动"); } /** @@ -681,7 +681,7 @@ public class DeviceCommandGenerator { DeviceCommandParams params = new DeviceCommandParams(); params.setDirection(direction); params.setVolume(volume); - return setInfoCmd(CmdDevice.acid_pump2, CmdAction.move, params, "加液泵2 移动"); + return setInfoCmd(CmdDevice.acid_pump_2, CmdAction.move, params, "加液泵2 移动"); } /** @@ -691,7 +691,7 @@ public class DeviceCommandGenerator { DeviceCommandParams params = new DeviceCommandParams(); params.setDirection(direction); params.setVolume(volume); - return setInfoCmd(CmdDevice.acid_pump3, CmdAction.move, params, "加液泵3 移动"); + return setInfoCmd(CmdDevice.acid_pump_3, CmdAction.move, params, "加液泵3 移动"); } /** @@ -701,7 +701,7 @@ public class DeviceCommandGenerator { DeviceCommandParams params = new DeviceCommandParams(); params.setDirection(direction); params.setVolume(volume); - return setInfoCmd(CmdDevice.acid_pump4, CmdAction.move, params, "加液泵4 移动"); + return setInfoCmd(CmdDevice.acid_pump_4, CmdAction.move, params, "加液泵4 移动"); } /** @@ -711,7 +711,7 @@ public class DeviceCommandGenerator { DeviceCommandParams params = new DeviceCommandParams(); params.setDirection(direction); params.setVolume(volume); - return setInfoCmd(CmdDevice.acid_pump5, CmdAction.move, params, "加液泵5 移动"); + return setInfoCmd(CmdDevice.acid_pump_5, CmdAction.move, params, "加液泵5 移动"); } /** @@ -721,7 +721,7 @@ public class DeviceCommandGenerator { DeviceCommandParams params = new DeviceCommandParams(); params.setDirection(direction); params.setVolume(volume); - return setInfoCmd(CmdDevice.acid_pump6, CmdAction.move, params, "加液泵6 移动"); + return setInfoCmd(CmdDevice.acid_pump_6, CmdAction.move, params, "加液泵6 移动"); } /** @@ -731,7 +731,7 @@ public class DeviceCommandGenerator { DeviceCommandParams params = new DeviceCommandParams(); params.setDirection(direction); params.setVolume(volume); - return setInfoCmd(CmdDevice.acid_pump7, CmdAction.move, params, "加液泵7 移动"); + return setInfoCmd(CmdDevice.acid_pump_7, CmdAction.move, params, "加液泵7 移动"); } /** @@ -741,63 +741,63 @@ public class DeviceCommandGenerator { DeviceCommandParams params = new DeviceCommandParams(); params.setDirection(direction); params.setVolume(volume); - return setInfoCmd(CmdDevice.acid_pump8, CmdAction.move, params, "加液泵8 移动"); + return setInfoCmd(CmdDevice.acid_pump_8, CmdAction.move, params, "加液泵8 移动"); } /** * 加液泵 泵1停止 */ public static DeviceCommand acidPump1Stop() { - return setInfoCmd(CmdDevice.acid_pump1, CmdAction.stop, null, "加液泵1 停止"); + return setInfoCmd(CmdDevice.acid_pump_1, CmdAction.stop, null, "加液泵1 停止"); } /** * 加液泵 泵2停止 */ public static DeviceCommand acidPump2Stop() { - return setInfoCmd(CmdDevice.acid_pump2, CmdAction.stop, null, "加液泵2 停止"); + return setInfoCmd(CmdDevice.acid_pump_2, CmdAction.stop, null, "加液泵2 停止"); } /** * 加液泵 泵3停止 */ public static DeviceCommand acidPump3Stop() { - return setInfoCmd(CmdDevice.acid_pump3, CmdAction.stop, null, "加液泵3 停止"); + return setInfoCmd(CmdDevice.acid_pump_3, CmdAction.stop, null, "加液泵3 停止"); } /** * 加液泵 泵4停止 */ public static DeviceCommand acidPump4Stop() { - return setInfoCmd(CmdDevice.acid_pump4, CmdAction.stop, null, "加液泵4 停止"); + return setInfoCmd(CmdDevice.acid_pump_4, CmdAction.stop, null, "加液泵4 停止"); } /** * 加液泵 泵5停止 */ public static DeviceCommand acidPump5Stop() { - return setInfoCmd(CmdDevice.acid_pump5, CmdAction.stop, null, "加液泵5 停止"); + return setInfoCmd(CmdDevice.acid_pump_5, CmdAction.stop, null, "加液泵5 停止"); } /** * 加液泵 泵6停止 */ public static DeviceCommand acidPump6Stop() { - return setInfoCmd(CmdDevice.acid_pump6, CmdAction.stop, null, "加液泵6 停止"); + return setInfoCmd(CmdDevice.acid_pump_6, CmdAction.stop, null, "加液泵6 停止"); } /** * 加液泵 泵7停止 */ public static DeviceCommand acidPump7Stop() { - return setInfoCmd(CmdDevice.acid_pump7, CmdAction.stop, null, "加液泵7 停止"); + return setInfoCmd(CmdDevice.acid_pump_7, CmdAction.stop, null, "加液泵7 停止"); } /** * 加液泵 泵8停止 */ public static DeviceCommand acidPump8Stop() { - return setInfoCmd(CmdDevice.acid_pump8, CmdAction.stop, null, "加液泵8 停止"); + return setInfoCmd(CmdDevice.acid_pump_8, CmdAction.stop, null, "加液泵8 停止"); } @@ -835,84 +835,84 @@ public class DeviceCommandGenerator { * 风扇 1打开 */ public static DeviceCommand fan1Open() { - return controlCmd(CmdDevice.fan1, CmdAction.open, null, "风扇1 打开"); + return controlCmd(CmdDevice.fan_1, CmdAction.open, null, "风扇1 打开"); } /** * 风扇 2打开 */ public static DeviceCommand fan2Open() { - return controlCmd(CmdDevice.fan2, CmdAction.open, null, "风扇2 打开"); + return controlCmd(CmdDevice.fan_2, CmdAction.open, null, "风扇2 打开"); } /** * 风扇 3打开 */ public static DeviceCommand fan3Open() { - return controlCmd(CmdDevice.fan3, CmdAction.open, null, "风扇3 打开"); + return controlCmd(CmdDevice.fan_3, CmdAction.open, null, "风扇3 打开"); } /** * 风扇 4打开 */ public static DeviceCommand fan4Open() { - return controlCmd(CmdDevice.fan4, CmdAction.open, null, "风扇4 打开"); + return controlCmd(CmdDevice.fan_4, CmdAction.open, null, "风扇4 打开"); } /** * 风扇 5打开 */ public static DeviceCommand fan5Open() { - return controlCmd(CmdDevice.fan5, CmdAction.open, null, "风扇5 打开"); + return controlCmd(CmdDevice.fan_5, CmdAction.open, null, "风扇5 打开"); } /** * 风扇 6打开 */ public static DeviceCommand fan6Open() { - return controlCmd(CmdDevice.fan6, CmdAction.open, null, "风扇6 打开"); + return controlCmd(CmdDevice.fan_6, CmdAction.open, null, "风扇6 打开"); } /** * 风扇 1关闭 */ public static DeviceCommand fan1Close() { - return controlCmd(CmdDevice.fan1, CmdAction.close, null, "风扇1 关闭"); + return controlCmd(CmdDevice.fan_1, CmdAction.close, null, "风扇1 关闭"); } /** * 风扇 2关闭 */ public static DeviceCommand fan2Close() { - return controlCmd(CmdDevice.fan2, CmdAction.close, null, "风扇2 关闭"); + return controlCmd(CmdDevice.fan_2, CmdAction.close, null, "风扇2 关闭"); } /** * 风扇 3关闭 */ public static DeviceCommand fan3Close() { - return controlCmd(CmdDevice.fan3, CmdAction.close, null, "风扇3 关闭"); + return controlCmd(CmdDevice.fan_3, CmdAction.close, null, "风扇3 关闭"); } /** * 风扇 4关闭 */ public static DeviceCommand fan4Close() { - return controlCmd(CmdDevice.fan4, CmdAction.close, null, "风扇4 关闭"); + return controlCmd(CmdDevice.fan_4, CmdAction.close, null, "风扇4 关闭"); } /** * 风扇 5关闭 */ public static DeviceCommand fan5Close() { - return controlCmd(CmdDevice.fan5, CmdAction.close, null, "风扇5 关闭"); + return controlCmd(CmdDevice.fan_5, CmdAction.close, null, "风扇5 关闭"); } /** * 风扇 6关闭 */ public static DeviceCommand fan6Close() { - return controlCmd(CmdDevice.fan6, CmdAction.close, null, "风扇6 关闭"); + return controlCmd(CmdDevice.fan_6, CmdAction.close, null, "风扇6 关闭"); } /** diff --git a/src/main/java/com/iflytop/gd/common/enums/cmd/CmdDevice.java b/src/main/java/com/iflytop/gd/common/enums/cmd/CmdDevice.java index 061f23c..4bb6f45 100644 --- a/src/main/java/com/iflytop/gd/common/enums/cmd/CmdDevice.java +++ b/src/main/java/com/iflytop/gd/common/enums/cmd/CmdDevice.java @@ -14,21 +14,21 @@ public enum CmdDevice { heater_motor_4, heater_motor_5, heater_motor_6, - acid_pump1, - acid_pump2, - acid_pump3, - acid_pump4, - acid_pump5, - acid_pump6, - acid_pump7, - acid_pump8, + acid_pump_1, + acid_pump_2, + acid_pump_3, + acid_pump_4, + acid_pump_5, + acid_pump_6, + acid_pump_7, + acid_pump_8, claw, - fan1, - fan2, - fan3, - fan4, - fan5, - fan6, + fan_1, + fan_2, + fan_3, + fan_4, + fan_5, + fan_6, water_pump_power, ventilator_power, heat_rod_1, diff --git a/src/main/java/com/iflytop/gd/hardware/command/handlers/AcidPumpHandler.java b/src/main/java/com/iflytop/gd/hardware/command/handlers/AcidPumpHandler.java index ae3d1b3..d64d2f4 100644 --- a/src/main/java/com/iflytop/gd/hardware/command/handlers/AcidPumpHandler.java +++ b/src/main/java/com/iflytop/gd/hardware/command/handlers/AcidPumpHandler.java @@ -22,14 +22,14 @@ public class AcidPumpHandler extends CommandHandler { private final AcidPumpDriver acidPumpDriver_; private final Map stepMotorMIdMap_ = Map.ofEntries( - Map.entry(CmdDevice.acid_pump1, StepMotorMId.ACID_PUMP_1_MOTOR_MID), - Map.entry(CmdDevice.acid_pump2, StepMotorMId.ACID_PUMP_2_MOTOR_MID), - Map.entry(CmdDevice.acid_pump3, StepMotorMId.ACID_PUMP_3_MOTOR_MID), - Map.entry(CmdDevice.acid_pump4, StepMotorMId.ACID_PUMP_4_MOTOR_MID), - Map.entry(CmdDevice.acid_pump5, StepMotorMId.ACID_PUMP_5_MOTOR_MID), - Map.entry(CmdDevice.acid_pump6, StepMotorMId.ACID_PUMP_6_MOTOR_MID), - Map.entry(CmdDevice.acid_pump7, StepMotorMId.ACID_PUMP_7_MOTOR_MID), - Map.entry(CmdDevice.acid_pump8, StepMotorMId.ACID_PUMP_8_MOTOR_MID) + Map.entry(CmdDevice.acid_pump_1, StepMotorMId.ACID_PUMP_1_MOTOR_MID), + Map.entry(CmdDevice.acid_pump_2, StepMotorMId.ACID_PUMP_2_MOTOR_MID), + Map.entry(CmdDevice.acid_pump_3, StepMotorMId.ACID_PUMP_3_MOTOR_MID), + Map.entry(CmdDevice.acid_pump_4, StepMotorMId.ACID_PUMP_4_MOTOR_MID), + Map.entry(CmdDevice.acid_pump_5, StepMotorMId.ACID_PUMP_5_MOTOR_MID), + Map.entry(CmdDevice.acid_pump_6, StepMotorMId.ACID_PUMP_6_MOTOR_MID), + Map.entry(CmdDevice.acid_pump_7, StepMotorMId.ACID_PUMP_7_MOTOR_MID), + Map.entry(CmdDevice.acid_pump_8, StepMotorMId.ACID_PUMP_8_MOTOR_MID) ); private final Map supportCmdDeviceMIdMap = stepMotorMIdMap_.entrySet().stream(). collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().mid)); diff --git a/src/main/java/com/iflytop/gd/hardware/command/handlers/DoorHandler.java b/src/main/java/com/iflytop/gd/hardware/command/handlers/DoorHandler.java index c069fe3..4b269cf 100644 --- a/src/main/java/com/iflytop/gd/hardware/command/handlers/DoorHandler.java +++ b/src/main/java/com/iflytop/gd/hardware/command/handlers/DoorHandler.java @@ -24,7 +24,7 @@ public class DoorHandler extends CommandHandler { private final DoorDriver doorDriver_; private final Map stepMotorMIdMap_ = Map.ofEntries( - Map.entry(CmdDevice.door, StepMotorMId.DOOR_MOTOR_MID) + Map.entry(CmdDevice.door_motor, StepMotorMId.DOOR_MOTOR_MID) ); private final Map supportCmdDeviceMIdMap = stepMotorMIdMap_.entrySet().stream(). collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().mid)); diff --git a/src/main/java/com/iflytop/gd/hardware/command/handlers/FanHandler.java b/src/main/java/com/iflytop/gd/hardware/command/handlers/FanHandler.java index ab9dfa8..f70676c 100644 --- a/src/main/java/com/iflytop/gd/hardware/command/handlers/FanHandler.java +++ b/src/main/java/com/iflytop/gd/hardware/command/handlers/FanHandler.java @@ -24,12 +24,12 @@ import java.util.stream.Collectors; public class FanHandler extends CommandHandler { private final FanDriver fanDriver_; private final Map supportCmdDeviceIOOutputMap = Map.ofEntries( - Map.entry(CmdDevice.fan1, OutputIOMId.DO_FAN1), - Map.entry(CmdDevice.fan2, OutputIOMId.DO_FAN2), - Map.entry(CmdDevice.fan3, OutputIOMId.DO_FAN3), - Map.entry(CmdDevice.fan4, OutputIOMId.DO_FAN4), - Map.entry(CmdDevice.fan5, OutputIOMId.DO_FAN5), - Map.entry(CmdDevice.fan6, OutputIOMId.DO_FAN6) + Map.entry(CmdDevice.fan_1, OutputIOMId.DO_FAN1), + Map.entry(CmdDevice.fan_2, OutputIOMId.DO_FAN2), + Map.entry(CmdDevice.fan_3, OutputIOMId.DO_FAN3), + Map.entry(CmdDevice.fan_4, OutputIOMId.DO_FAN4), + Map.entry(CmdDevice.fan_5, OutputIOMId.DO_FAN5), + Map.entry(CmdDevice.fan_6, OutputIOMId.DO_FAN6) ); private final Map supportCmdDeviceMIdMap = supportCmdDeviceIOOutputMap.entrySet().stream() diff --git a/src/main/java/com/iflytop/gd/hardware/command/handlers/HBotHandler.java b/src/main/java/com/iflytop/gd/hardware/command/handlers/HBotHandler.java index 7022826..0b33e8f 100644 --- a/src/main/java/com/iflytop/gd/hardware/command/handlers/HBotHandler.java +++ b/src/main/java/com/iflytop/gd/hardware/command/handlers/HBotHandler.java @@ -22,9 +22,9 @@ public class HBotHandler extends CommandHandler { private final HBotDriver hBotDriver_; private final Map stepMotorMIdMap_ = Map.ofEntries( - Map.entry(CmdDevice.hbot_x, StepMotorMId.HBOT_X_MOTOR_MID), - Map.entry(CmdDevice.hbot_y, StepMotorMId.HBOT_Y_MOTOR_MID), - Map.entry(CmdDevice.hbot_z, StepMotorMId.HBOT_Z_MOTOR_MID) + Map.entry(CmdDevice.gantry_x, StepMotorMId.HBOT_X_MOTOR_MID), + Map.entry(CmdDevice.gantry_y, StepMotorMId.HBOT_Y_MOTOR_MID), + Map.entry(CmdDevice.gantry_z, StepMotorMId.HBOT_Z_MOTOR_MID) ); private final Map supportCmdDeviceMIdMap = stepMotorMIdMap_.entrySet().stream(). collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().mid)); diff --git a/src/main/java/com/iflytop/gd/hardware/drivers/DIDriver/InputDetectDriver.java b/src/main/java/com/iflytop/gd/hardware/drivers/DIDriver/InputDetectDriver.java index a1cbf7b..f6b4dd5 100644 --- a/src/main/java/com/iflytop/gd/hardware/drivers/DIDriver/InputDetectDriver.java +++ b/src/main/java/com/iflytop/gd/hardware/drivers/DIDriver/InputDetectDriver.java @@ -1,44 +1,44 @@ -package com.iflytop.gd.hardware.drivers.DIDriver; - -import com.iflytop.gd.hardware.comm.can.A8kCanBusService; -import com.iflytop.gd.hardware.exception.HardwareException; -import com.iflytop.gd.hardware.type.ModuleType; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -@Slf4j -@Component -@RequiredArgsConstructor -public class InputDetectDriver { - - private final A8kCanBusService a8kCanBusService; - - public Boolean getIOState(InputIOId ioid) throws HardwareException { - while (true) { - Boolean firstReadIO = priGetIOState(ioid); - Boolean secondReadIO = priGetIOState(ioid); - if (firstReadIO == secondReadIO) { - if (ioid.mirror) { - return !firstReadIO; - } - return firstReadIO; - } else { - log.warn("getIOState {} not match, retry", ioid); - } - } - } - - - private Boolean priGetIOState(InputIOId ioid) throws HardwareException { - if (ioid.mtype == ModuleType.Board) { - return a8kCanBusService.callcmd(ioid.mid, CmdId.extboard_read_inio, ioid.ioIndex).getContentI32(0) != 0; - } else if (ioid.mtype == ModuleType.TMCStepMotor) { - return a8kCanBusService.callcmd(ioid.mid, CmdId.step_motor_read_io_state, ioid.ioIndex).getContentI32(0) != 0; - } else if (ioid.mtype == ModuleType.MiniServo) { - return a8kCanBusService.callcmd(ioid.mid, CmdId.mini_servo_read_io_state, ioid.ioIndex).getContentI32(0) != 0; - } else { - throw new HardwareException(new AECodeError(String.format("IOID MODULE TYPE %s NOT SUPPORT", ioid.mtype))); - } - } -} +//package com.iflytop.gd.hardware.drivers.DIDriver; +// +//import com.iflytop.gd.hardware.comm.can.A8kCanBusService; +//import com.iflytop.gd.hardware.exception.HardwareException; +//import com.iflytop.gd.hardware.type.ModuleType; +//import lombok.RequiredArgsConstructor; +//import lombok.extern.slf4j.Slf4j; +//import org.springframework.stereotype.Component; +// +//@Slf4j +//@Component +//@RequiredArgsConstructor +//public class InputDetectDriver { +// +// private final A8kCanBusService a8kCanBusService; +// +// public Boolean getIOState(InputIOId ioid) throws HardwareException { +// while (true) { +// Boolean firstReadIO = priGetIOState(ioid); +// Boolean secondReadIO = priGetIOState(ioid); +// if (firstReadIO == secondReadIO) { +// if (ioid.mirror) { +// return !firstReadIO; +// } +// return firstReadIO; +// } else { +// log.warn("getIOState {} not match, retry", ioid); +// } +// } +// } +// +// +// private Boolean priGetIOState(InputIOId ioid) throws HardwareException { +// if (ioid.mtype == ModuleType.Board) { +// return a8kCanBusService.callcmd(ioid.mid, CmdId.extboard_read_inio, ioid.ioIndex).getContentI32(0) != 0; +// } else if (ioid.mtype == ModuleType.TMCStepMotor) { +// return a8kCanBusService.callcmd(ioid.mid, CmdId.step_motor_read_io_state, ioid.ioIndex).getContentI32(0) != 0; +// } else if (ioid.mtype == ModuleType.MiniServo) { +// return a8kCanBusService.callcmd(ioid.mid, CmdId.mini_servo_read_io_state, ioid.ioIndex).getContentI32(0) != 0; +// } else { +// throw new HardwareException(new AECodeError(String.format("IOID MODULE TYPE %s NOT SUPPORT", ioid.mtype))); +// } +// } +//}