diff --git a/src/main/java/com/iflytop/colortitration/app/common/command/DeviceCommand.java b/src/main/java/com/iflytop/colortitration/app/common/command/DeviceCommand.java index c345d44..cdc2201 100644 --- a/src/main/java/com/iflytop/colortitration/app/common/command/DeviceCommand.java +++ b/src/main/java/com/iflytop/colortitration/app/common/command/DeviceCommand.java @@ -1,8 +1,8 @@ package com.iflytop.colortitration.app.common.command; -import com.iflytop.colortitration.common.cmd.DeviceCommandParams; -import com.iflytop.colortitration.common.enums.Action; -import com.iflytop.colortitration.common.enums.Device; +import com.iflytop.colortitration.common.command.DeviceCommandParams; +import com.iflytop.colortitration.common.enums.command.Action; +import com.iflytop.colortitration.common.enums.command.Device; import lombok.Data; @Data diff --git a/src/main/java/com/iflytop/colortitration/app/common/command/DeviceCommandBundle.java b/src/main/java/com/iflytop/colortitration/app/common/command/DeviceCommandBundle.java deleted file mode 100644 index f9b422f..0000000 --- a/src/main/java/com/iflytop/colortitration/app/common/command/DeviceCommandBundle.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.iflytop.colortitration.app.common.command; - -import lombok.Data; - -@Data -public class DeviceCommandBundle { - - /** - * 指令名称 - */ - private String cmdName; - - /** - * 指令 - */ - private DeviceCommand deviceCommand; - -} - diff --git a/src/main/java/com/iflytop/colortitration/app/common/command/DeviceCommandGenerator.java b/src/main/java/com/iflytop/colortitration/app/common/command/DeviceCommandGenerator.java index 5a9ea8e..dabcc14 100644 --- a/src/main/java/com/iflytop/colortitration/app/common/command/DeviceCommandGenerator.java +++ b/src/main/java/com/iflytop/colortitration/app/common/command/DeviceCommandGenerator.java @@ -1,11 +1,709 @@ package com.iflytop.colortitration.app.common.command; - +import com.iflytop.colortitration.common.command.DeviceCommandParams; +import com.iflytop.colortitration.common.enums.command.Action; +import com.iflytop.colortitration.common.enums.command.Device; +import com.iflytop.colortitration.common.enums.command.MotorDirection; +import com.iflytop.colortitration.common.enums.command.TricolorLightColor; /** * 生成给设备发送的指令 */ public class DeviceCommandGenerator { + // =========================================== 三色灯 ==================================================== + + /** + * 三色灯开启 + * + * @param color red | green | blue + */ + public static DeviceCommand tricolorLightOpen(TricolorLightColor color) { + DeviceCommandParams params = new DeviceCommandParams(); + params.setColor(color); + return controlCmd(Device.TRICOLOR_LIGHT, Action.OPEN, params); + } + + /** + * 三色灯关闭 + */ + public static DeviceCommand tricolorLightClose() { + return controlCmd(Device.TRICOLOR_LIGHT, Action.CLOSE, null); + } + // =========================================== 加热棒 ==================================================== + + /** + * 加热棒 1 获取参数 + */ + public static DeviceCommand heatRod01Get() { + return controlCmd(Device.HEAT_ROD_1, Action.GET, null); + } + + /** + * 加热棒 1 打开 + */ + public static DeviceCommand heatRod01Open(Double temperature) { + return controlCmd(Device.HEAT_ROD_1, Action.OPEN, null); + } + + /** + * 加热棒 1 关闭 + */ + public static DeviceCommand heatRod01Close() { + return controlCmd(Device.HEAT_ROD_1, Action.CLOSE, null); + } + + /** + * 加热棒 2 获取参数 + */ + public static DeviceCommand heatRod02Get() { + return controlCmd(Device.HEAT_ROD_2, Action.GET, null); + } + + /** + * 加热棒 2 打开 + */ + public static DeviceCommand heatRod02Open(Double temperature) { + return controlCmd(Device.HEAT_ROD_1, Action.OPEN, null); + } + + /** + * 加热棒 2 关闭 + */ + public static DeviceCommand heatRod02Close() { + return controlCmd(Device.HEAT_ROD_1, Action.CLOSE, null); + } + + // =========================================== 夹爪 ==================================================== + + /** + * 夹爪移动 + */ + public static DeviceCommand clawMove(Double position) { + DeviceCommandParams params = new DeviceCommandParams(); + params.setPosition(position); + return controlMotorCmd(Device.CLAW, Action.MOVE, params); + } + + /** + * 夹爪停止 + */ + public static DeviceCommand clawStop() { + return controlMotorCmd(Device.CLAW, Action.STOP, null); + } + + // =========================================== 搅拌电机 ==================================================== + + /** + * 搅拌电机 1 正向旋转 + */ + public static DeviceCommand stirMotor01ForwardRotate() { + DeviceCommandParams params = new DeviceCommandParams(); + params.setDirection(MotorDirection.forward); + return controlMotorCmd(Device.STIR_MOTOR_1, Action.ROTATE, params); + } + + /** + * 搅拌电机 1 反向旋转 + */ + public static DeviceCommand stirMotor01BackwardRotate() { + DeviceCommandParams params = new DeviceCommandParams(); + params.setDirection(MotorDirection.backward); + return controlMotorCmd(Device.STIR_MOTOR_1, Action.ROTATE, params); + } + + /** + * 搅拌电机 1 停止 + */ + public static DeviceCommand stirMotor01Stop() { + return controlMotorCmd(Device.STIR_MOTOR_1, Action.STOP, null); + } + + + /** + * 搅拌电机 2 正向旋转 + */ + public static DeviceCommand stirMotor02ForwardRotate() { + DeviceCommandParams params = new DeviceCommandParams(); + params.setDirection(MotorDirection.forward); + return controlMotorCmd(Device.STIR_MOTOR_2, Action.ROTATE, params); + } + + /** + * 搅拌电机 2 反向旋转 + */ + public static DeviceCommand stirMotor02BackwardRotate() { + DeviceCommandParams params = new DeviceCommandParams(); + params.setDirection(MotorDirection.backward); + return controlMotorCmd(Device.STIR_MOTOR_2, Action.ROTATE, params); + } + + /** + * 搅拌电机 2 停止 + */ + public static DeviceCommand stirMotor02Stop() { + return controlMotorCmd(Device.STIR_MOTOR_2, Action.STOP, null); + } + + + // =========================================== 步进泵 ==================================================== + + /** + * 步进泵 1 正向旋转 + */ + public static DeviceCommand stepPump01ForwardRotate() { + DeviceCommandParams params = new DeviceCommandParams(); + params.setDirection(MotorDirection.forward); + return setInfoCmd(Device.STEP_PUMP_1, Action.ROTATE, params); + } + + /** + * 步进泵 1 反向旋转 + */ + public static DeviceCommand stepPump01BackwardRotate() { + DeviceCommandParams params = new DeviceCommandParams(); + params.setDirection(MotorDirection.backward); + return setInfoCmd(Device.STEP_PUMP_1, Action.ROTATE, params); + } + + /** + * 步进泵 1 相对移动 + */ + public static DeviceCommand stepPump01MoveBy() { + return setInfoCmd(Device.STEP_PUMP_1, Action.MOVE_BY, null); + } + + /** + * 步进泵 1 停止 + */ + public static DeviceCommand stepPump01Stop() { + return setInfoCmd(Device.STEP_PUMP_1, Action.STOP, null); + } + + + /** + * 步进泵 2 正向旋转 + */ + public static DeviceCommand stepPump02ForwardRotate() { + DeviceCommandParams params = new DeviceCommandParams(); + params.setDirection(MotorDirection.forward); + return setInfoCmd(Device.STEP_PUMP_2, Action.ROTATE, params); + } + + /** + * 步进泵 2 反向旋转 + */ + public static DeviceCommand stepPump02BackwardRotate() { + DeviceCommandParams params = new DeviceCommandParams(); + params.setDirection(MotorDirection.backward); + return setInfoCmd(Device.STEP_PUMP_2, Action.ROTATE, params); + } + + /** + * 步进泵 2 相对移动 + */ + public static DeviceCommand stepPump02MoveBy() { + return setInfoCmd(Device.STEP_PUMP_2, Action.MOVE_BY, null); + } + + /** + * 步进泵 2 停止 + */ + public static DeviceCommand stepPump02Stop() { + return setInfoCmd(Device.STEP_PUMP_2, Action.STOP, null); + } + + /** + * 步进泵 3 正向旋转 + */ + public static DeviceCommand stepPump03ForwardRotate() { + DeviceCommandParams params = new DeviceCommandParams(); + params.setDirection(MotorDirection.forward); + return setInfoCmd(Device.STEP_PUMP_3, Action.ROTATE, params); + } + + /** + * 步进泵 3 反向旋转 + */ + public static DeviceCommand stepPump03BackwardRotate() { + DeviceCommandParams params = new DeviceCommandParams(); + params.setDirection(MotorDirection.backward); + return setInfoCmd(Device.STEP_PUMP_3, Action.ROTATE, params); + } + + /** + * 步进泵 3 相对移动 + */ + public static DeviceCommand stepPump03MoveBy() { + return setInfoCmd(Device.STEP_PUMP_3, Action.MOVE_BY, null); + } + + /** + * 步进泵 3 停止 + */ + public static DeviceCommand stepPump03Stop() { + return setInfoCmd(Device.STEP_PUMP_3, Action.STOP, null); + } + // =========================================== 无刷泵 ==================================================== + + /** + * 无刷泵 1 正向旋转 + */ + public static DeviceCommand brushlessPump01ForwardRotate() { + DeviceCommandParams params = new DeviceCommandParams(); + params.setDirection(MotorDirection.forward); + return setInfoCmd(Device.BRUSHLESS_PUMP_1, Action.ROTATE, params); + } + + /** + * 无刷泵 1 反向旋转 + */ + public static DeviceCommand brushlessPump01BackwardRotate() { + DeviceCommandParams params = new DeviceCommandParams(); + params.setDirection(MotorDirection.backward); + return setInfoCmd(Device.BRUSHLESS_PUMP_1, Action.ROTATE, params); + } + + /** + * 无刷泵 1 相对移动 + */ + public static DeviceCommand brushlessPump01MoveBy() { + return setInfoCmd(Device.BRUSHLESS_PUMP_1, Action.MOVE_BY, null); + } + + /** + * 无刷泵 1 停止 + */ + public static DeviceCommand brushlessPump01Stop() { + return setInfoCmd(Device.BRUSHLESS_PUMP_1, Action.STOP, null); + } + + /** + * 无刷泵 2 正向旋转 + */ + public static DeviceCommand brushlessPump02ForwardRotate() { + DeviceCommandParams params = new DeviceCommandParams(); + params.setDirection(MotorDirection.forward); + return setInfoCmd(Device.BRUSHLESS_PUMP_2, Action.ROTATE, params); + } + + /** + * 无刷泵 2 反向旋转 + */ + public static DeviceCommand brushlessPump02BackwardRotate() { + DeviceCommandParams params = new DeviceCommandParams(); + params.setDirection(MotorDirection.backward); + return setInfoCmd(Device.BRUSHLESS_PUMP_2, Action.ROTATE, params); + } + + /** + * 无刷泵 2 相对移动 + */ + public static DeviceCommand brushlessPump02MoveBy() { + return setInfoCmd(Device.BRUSHLESS_PUMP_2, Action.MOVE_BY, null); + } + + /** + * 无刷泵 2 停止 + */ + public static DeviceCommand brushlessPump02Stop() { + return setInfoCmd(Device.BRUSHLESS_PUMP_2, Action.STOP, null); + } + + /** + * 无刷泵 3 正向旋转 + */ + public static DeviceCommand brushlessPump03ForwardRotate() { + DeviceCommandParams params = new DeviceCommandParams(); + params.setDirection(MotorDirection.forward); + return setInfoCmd(Device.BRUSHLESS_PUMP_3, Action.ROTATE, params); + } + + /** + * 无刷泵 3 反向旋转 + */ + public static DeviceCommand brushlessPump03BackwardRotate() { + DeviceCommandParams params = new DeviceCommandParams(); + params.setDirection(MotorDirection.backward); + return setInfoCmd(Device.BRUSHLESS_PUMP_3, Action.ROTATE, params); + } + + /** + * 无刷泵 3 相对移动 + */ + public static DeviceCommand brushlessPump03MoveBy() { + return setInfoCmd(Device.BRUSHLESS_PUMP_3, Action.MOVE_BY, null); + } + + /** + * 无刷泵 3 停止 + */ + public static DeviceCommand brushlessPump03Stop() { + return setInfoCmd(Device.BRUSHLESS_PUMP_3, Action.STOP, null); + } + + /** + * 无刷泵 4 正向旋转 + */ + public static DeviceCommand brushlessPump04ForwardRotate() { + DeviceCommandParams params = new DeviceCommandParams(); + params.setDirection(MotorDirection.forward); + return setInfoCmd(Device.BRUSHLESS_PUMP_4, Action.ROTATE, params); + } + + /** + * 无刷泵 4 反向旋转 + */ + public static DeviceCommand brushlessPump04BackwardRotate() { + DeviceCommandParams params = new DeviceCommandParams(); + params.setDirection(MotorDirection.backward); + return setInfoCmd(Device.BRUSHLESS_PUMP_4, Action.ROTATE, params); + } + + /** + * 无刷泵 4 相对移动 + */ + public static DeviceCommand brushlessPump04MoveBy() { + return setInfoCmd(Device.BRUSHLESS_PUMP_4, Action.MOVE_BY, null); + } + + /** + * 无刷泵 4 停止 + */ + public static DeviceCommand brushlessPump4Stop() { + return setInfoCmd(Device.BRUSHLESS_PUMP_4, Action.STOP, null); + } + + /** + * 无刷泵 5 正向旋转 + */ + public static DeviceCommand brushlessPump05ForwardRotate() { + DeviceCommandParams params = new DeviceCommandParams(); + params.setDirection(MotorDirection.forward); + return setInfoCmd(Device.BRUSHLESS_PUMP_5, Action.ROTATE, params); + } + + /** + * 无刷泵 5 反向旋转 + */ + public static DeviceCommand brushlessPump05BackwardRotate() { + DeviceCommandParams params = new DeviceCommandParams(); + params.setDirection(MotorDirection.backward); + return setInfoCmd(Device.BRUSHLESS_PUMP_5, Action.ROTATE, params); + } + + /** + * 无刷泵 5 相对移动 + */ + public static DeviceCommand brushlessPump05MoveBy() { + return setInfoCmd(Device.BRUSHLESS_PUMP_5, Action.MOVE_BY, null); + } + + /** + * 无刷泵 5 停止 + */ + public static DeviceCommand brushlessPump05Stop() { + return setInfoCmd(Device.BRUSHLESS_PUMP_5, Action.STOP, null); + } + + /** + * 无刷泵 6 正向旋转 + */ + public static DeviceCommand brushlessPump06ForwardRotate() { + DeviceCommandParams params = new DeviceCommandParams(); + params.setDirection(MotorDirection.forward); + return setInfoCmd(Device.BRUSHLESS_PUMP_6, Action.ROTATE, params); + } + + /** + * 无刷泵 6 反向旋转 + */ + public static DeviceCommand brushlessPump06BackwardRotate() { + DeviceCommandParams params = new DeviceCommandParams(); + params.setDirection(MotorDirection.backward); + return setInfoCmd(Device.BRUSHLESS_PUMP_6, Action.ROTATE, params); + } + + /** + * 无刷泵 6 相对移动 + */ + public static DeviceCommand brushlessPump06MoveBy() { + return setInfoCmd(Device.BRUSHLESS_PUMP_6, Action.MOVE_BY, null); + } + + /** + * 无刷泵 6 停止 + */ + public static DeviceCommand brushlessPump06Stop() { + return setInfoCmd(Device.BRUSHLESS_PUMP_6, Action.STOP, null); + } + + /** + * 无刷泵 7 正向旋转 + */ + public static DeviceCommand brushlessPump07ForwardRotate() { + DeviceCommandParams params = new DeviceCommandParams(); + params.setDirection(MotorDirection.forward); + return setInfoCmd(Device.BRUSHLESS_PUMP_7, Action.ROTATE, params); + } + + /** + * 无刷泵 7 反向旋转 + */ + public static DeviceCommand brushlessPump07BackwardRotate() { + DeviceCommandParams params = new DeviceCommandParams(); + params.setDirection(MotorDirection.backward); + return setInfoCmd(Device.BRUSHLESS_PUMP_7, Action.ROTATE, params); + } + + /** + * 无刷泵 7 相对移动 + */ + public static DeviceCommand brushlessPump07MoveBy() { + return setInfoCmd(Device.BRUSHLESS_PUMP_7, Action.MOVE_BY, null); + } + + /** + * 无刷泵 7 停止 + */ + public static DeviceCommand brushlessPump07Stop() { + return setInfoCmd(Device.BRUSHLESS_PUMP_7, Action.STOP, null); + } + + /** + * 无刷泵 8 正向旋转 + */ + public static DeviceCommand brushlessPump08ForwardRotate() { + DeviceCommandParams params = new DeviceCommandParams(); + params.setDirection(MotorDirection.forward); + return setInfoCmd(Device.BRUSHLESS_PUMP_8, Action.ROTATE, params); + } + + /** + * 无刷泵 8 反向旋转 + */ + public static DeviceCommand brushlessPump08BackwardRotate() { + DeviceCommandParams params = new DeviceCommandParams(); + params.setDirection(MotorDirection.backward); + return setInfoCmd(Device.BRUSHLESS_PUMP_8, Action.ROTATE, params); + } + + /** + * 无刷泵 8 相对移动 + */ + public static DeviceCommand brushlessPump08MoveBy() { + return setInfoCmd(Device.BRUSHLESS_PUMP_8, Action.MOVE_BY, null); + } + + /** + * 无刷泵 8 停止 + */ + public static DeviceCommand brushlessPump08Stop() { + return setInfoCmd(Device.BRUSHLESS_PUMP_8, Action.STOP, null); + } + + /** + * 无刷泵 9 正向旋转 + */ + public static DeviceCommand brushlessPump09ForwardRotate() { + DeviceCommandParams params = new DeviceCommandParams(); + params.setDirection(MotorDirection.forward); + return setInfoCmd(Device.BRUSHLESS_PUMP_9, Action.ROTATE, params); + } + + /** + * 无刷泵 9 反向旋转 + */ + public static DeviceCommand brushlessPump09BackwardRotate() { + DeviceCommandParams params = new DeviceCommandParams(); + params.setDirection(MotorDirection.backward); + return setInfoCmd(Device.BRUSHLESS_PUMP_9, Action.ROTATE, params); + } + + /** + * 无刷泵 9 相对移动 + */ + public static DeviceCommand brushlessPump09MoveBy() { + return setInfoCmd(Device.BRUSHLESS_PUMP_9, Action.MOVE_BY, null); + } + + /** + * 无刷泵 9 停止 + */ + public static DeviceCommand brushlessPump09Stop() { + return setInfoCmd(Device.BRUSHLESS_PUMP_9, Action.STOP, null); + } + + /** + * 无刷泵 10 正向旋转 + */ + public static DeviceCommand brushlessPump10ForwardRotate() { + DeviceCommandParams params = new DeviceCommandParams(); + params.setDirection(MotorDirection.forward); + return setInfoCmd(Device.BRUSHLESS_PUMP_10, Action.ROTATE, params); + } + + /** + * 无刷泵 10 反向旋转 + */ + public static DeviceCommand brushlessPump10BackwardRotate() { + DeviceCommandParams params = new DeviceCommandParams(); + params.setDirection(MotorDirection.backward); + return setInfoCmd(Device.BRUSHLESS_PUMP_10, Action.ROTATE, params); + } + + /** + * 无刷泵 10 相对移动 + */ + public static DeviceCommand brushlessPump10MoveBy() { + return setInfoCmd(Device.BRUSHLESS_PUMP_10, Action.MOVE_BY, null); + } + + /** + * 无刷泵 10 停止 + */ + public static DeviceCommand brushlessPump10Stop() { + return setInfoCmd(Device.BRUSHLESS_PUMP_10, Action.STOP, null); + } + // =========================================== 陶瓷泵 ==================================================== + + /** + * 陶瓷泵 1 正向旋转 + */ + public static DeviceCommand ceramicPump01ForwardRotate() { + DeviceCommandParams params = new DeviceCommandParams(); + params.setDirection(MotorDirection.forward); + return setInfoCmd(Device.CERAMIC_PUMP_1, Action.ROTATE, params); + } + + /** + * 陶瓷泵 1 反向旋转 + */ + public static DeviceCommand ceramicPump01BackwardRotate() { + DeviceCommandParams params = new DeviceCommandParams(); + params.setDirection(MotorDirection.backward); + return setInfoCmd(Device.CERAMIC_PUMP_1, Action.ROTATE, params); + } + + /** + * 陶瓷泵 1 相对移动 + */ + public static DeviceCommand ceramicPump01MoveBy() { + return setInfoCmd(Device.CERAMIC_PUMP_1, Action.MOVE_BY, null); + } + + /** + * 陶瓷泵 1 停止 + */ + public static DeviceCommand ceramicPump01Stop() { + return setInfoCmd(Device.CERAMIC_PUMP_1, Action.STOP, null); + } + + /** + * 陶瓷泵 2 正向旋转 + */ + public static DeviceCommand ceramicPump02ForwardRotate() { + DeviceCommandParams params = new DeviceCommandParams(); + params.setDirection(MotorDirection.forward); + return setInfoCmd(Device.CERAMIC_PUMP_2, Action.ROTATE, params); + } + + /** + * 陶瓷泵 2 反向旋转 + */ + public static DeviceCommand ceramicPump02BackwardRotate() { + DeviceCommandParams params = new DeviceCommandParams(); + params.setDirection(MotorDirection.backward); + return setInfoCmd(Device.CERAMIC_PUMP_2, Action.ROTATE, params); + } + + /** + * 陶瓷泵 1 相对移动 + */ + public static DeviceCommand ceramicPump02MoveBy() { + return setInfoCmd(Device.CERAMIC_PUMP_2, Action.MOVE_BY, null); + } + + /** + * 陶瓷泵 2 停止 + */ + public static DeviceCommand ceramicPump02Stop() { + return setInfoCmd(Device.CERAMIC_PUMP_2, Action.STOP, null); + } + + // =========================================== Z 轴升降电机 ==================================================== + + /** + * z轴移动 + */ + public static DeviceCommand zMove(Double position) { + DeviceCommandParams params = new DeviceCommandParams(); + params.setPosition(position); + return controlMotorCmd(Device.Z_MOTOR, Action.MOVE, params); + } + + /** + * z轴相对移动 + */ + public static DeviceCommand zMoveBy(Double position) { + DeviceCommandParams params = new DeviceCommandParams(); + params.setPosition(position); + return controlMotorCmd(Device.Z_MOTOR, Action.MOVE_BY, params); + } + + /** + * z轴回原点 + */ + public static DeviceCommand zOrigin() { + return controlMotorCmd(Device.Z_MOTOR, Action.ORIGIN, null); + } + + /** + * z轴停止 + */ + public static DeviceCommand zStop() { + return controlMotorCmd(Device.Z_MOTOR, Action.STOP, null); + } + +//===========================================PRIVATE==================================================================== + + /** + * 控制设备电机指令 + */ + private static DeviceCommand controlMotorCmd(Device device, Action action, DeviceCommandParams params) { + return deviceCmd("controlMotorCmd", device, action, params); + } + + /** + * 设置参数指令 + */ + private static DeviceCommand setInfoCmd(Device device, Action action, DeviceCommandParams params) { + return deviceCmd("setInfoCmd", device, action, params); + } + + /** + * 获取参数指令 + */ + private static DeviceCommand getInfoCmd(Device device) { + return deviceCmd("getInfoCmd", device, Action.GET, null); + } + + /** + * 设备控制指令 + */ + private static DeviceCommand controlCmd(Device device, Action action, DeviceCommandParams params) { + return deviceCmd("controlCmd", device, action, params); + } + /** + * 设备指令包装 + */ + private static DeviceCommand deviceCmd(String code, Device device, Action action, DeviceCommandParams params) { + DeviceCommand deviceCommand = new DeviceCommand(); + deviceCommand.setCmdCode(code); + deviceCommand.setDevice(device); + deviceCommand.setAction(action); + deviceCommand.setParam(params); + return deviceCommand; + } } diff --git a/src/main/java/com/iflytop/colortitration/common/cmd/DeviceCommandParams.java b/src/main/java/com/iflytop/colortitration/common/cmd/DeviceCommandParams.java deleted file mode 100644 index 1b5ef05..0000000 --- a/src/main/java/com/iflytop/colortitration/common/cmd/DeviceCommandParams.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.iflytop.colortitration.common.cmd; - - -import lombok.Data; - -@Data -public class DeviceCommandParams { - private Double x; - private Double y; - private Double z; -} diff --git a/src/main/java/com/iflytop/colortitration/common/command/DeviceCommandParams.java b/src/main/java/com/iflytop/colortitration/common/command/DeviceCommandParams.java new file mode 100644 index 0000000..b2cf810 --- /dev/null +++ b/src/main/java/com/iflytop/colortitration/common/command/DeviceCommandParams.java @@ -0,0 +1,22 @@ +package com.iflytop.colortitration.common.command; + + +import com.iflytop.colortitration.common.enums.command.MotorDirection; +import com.iflytop.colortitration.common.enums.command.TricolorLightColor; +import lombok.Data; + +@Data +public class DeviceCommandParams { + private String device; + private MotorDirection direction; + private Double position; + private Double speed; + private Double angle; + private Double volume; + private Double distance; + private Double temperature; + private TricolorLightColor color; + private Double x; + private Double y; + private Double z; +} diff --git a/src/main/java/com/iflytop/colortitration/common/enums/Action.java b/src/main/java/com/iflytop/colortitration/common/enums/Action.java deleted file mode 100644 index bc94b35..0000000 --- a/src/main/java/com/iflytop/colortitration/common/enums/Action.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.iflytop.colortitration.common.enums; - -public enum Action { - move, move_by, move_joint, move_point, origin, rotate, move_end, - - open, close, stop, start, set, get, - open_power, close_power, open_circle, close_circle, - open_heart, close_heart, open_cool, close_cool, take_photo -} diff --git a/src/main/java/com/iflytop/colortitration/common/enums/command/Action.java b/src/main/java/com/iflytop/colortitration/common/enums/command/Action.java new file mode 100644 index 0000000..95104b1 --- /dev/null +++ b/src/main/java/com/iflytop/colortitration/common/enums/command/Action.java @@ -0,0 +1,36 @@ +package com.iflytop.colortitration.common.enums.command; + +import lombok.Getter; + +/** + * 通用设备动作枚举 + */ +public enum Action { + MOVE("绝对移动"), + MOVE_BY("相对移动"), + ORIGIN("回原点"), + ROTATE("旋转"), + STOP("停止"), + OPEN("打开"), + CLOSE("关闭"), + SET("设置"), + GET("获取"), + OPEN_CLAMP("打开抱闸"), + CLOSE_CLAMP("关闭抱闸"), + ; + + /** + * 动作的中文描述 + */ + @Getter + private final String description; + + Action(String description) { + this.description = description; + } + + @Override + public String toString() { + return name(); + } +} \ No newline at end of file diff --git a/src/main/java/com/iflytop/colortitration/common/enums/Device.java b/src/main/java/com/iflytop/colortitration/common/enums/command/Device.java similarity index 90% rename from src/main/java/com/iflytop/colortitration/common/enums/Device.java rename to src/main/java/com/iflytop/colortitration/common/enums/command/Device.java index a406ce5..a875479 100644 --- a/src/main/java/com/iflytop/colortitration/common/enums/Device.java +++ b/src/main/java/com/iflytop/colortitration/common/enums/command/Device.java @@ -1,5 +1,6 @@ -package com.iflytop.colortitration.common.enums; +package com.iflytop.colortitration.common.enums.command; +import com.iflytop.colortitration.common.enums.HardwareType; import lombok.Getter; public enum Device { @@ -25,8 +26,8 @@ public enum Device { DUAL_ROBOT(HardwareType.STEPPER_MOTOR, "双轴机械臂"), HEAT_ROD_1(HardwareType.IO_DEVICE, "加热棒 1"), HEAT_ROD_2(HardwareType.IO_DEVICE, "加热棒 2"), - TRICOLOR_LIGHT(HardwareType.IO_DEVICE, "三色灯"); - + TRICOLOR_LIGHT(HardwareType.IO_DEVICE, "三色灯"), + ; /** * 设备所属硬件类型 diff --git a/src/main/java/com/iflytop/colortitration/common/enums/command/MotorDirection.java b/src/main/java/com/iflytop/colortitration/common/enums/command/MotorDirection.java new file mode 100644 index 0000000..539b9ab --- /dev/null +++ b/src/main/java/com/iflytop/colortitration/common/enums/command/MotorDirection.java @@ -0,0 +1,5 @@ +package com.iflytop.colortitration.common.enums.command; + +public enum MotorDirection { + forward, backward +} diff --git a/src/main/java/com/iflytop/colortitration/common/enums/command/TricolorLightColor.java b/src/main/java/com/iflytop/colortitration/common/enums/command/TricolorLightColor.java new file mode 100644 index 0000000..a28ad8e --- /dev/null +++ b/src/main/java/com/iflytop/colortitration/common/enums/command/TricolorLightColor.java @@ -0,0 +1,5 @@ +package com.iflytop.colortitration.common.enums.command; + +public enum TricolorLightColor { + red, green, blue +} diff --git a/src/main/java/com/iflytop/colortitration/common/handler/DeviceTypeHandler.java b/src/main/java/com/iflytop/colortitration/common/handler/DeviceTypeHandler.java index bc61ca2..89f80ef 100644 --- a/src/main/java/com/iflytop/colortitration/common/handler/DeviceTypeHandler.java +++ b/src/main/java/com/iflytop/colortitration/common/handler/DeviceTypeHandler.java @@ -1,6 +1,6 @@ package com.iflytop.colortitration.common.handler; -import com.iflytop.colortitration.common.enums.Device; +import com.iflytop.colortitration.common.enums.command.Device; import org.apache.ibatis.type.BaseTypeHandler; import org.apache.ibatis.type.JdbcType; import org.apache.ibatis.type.MappedJdbcTypes; diff --git a/src/main/java/com/iflytop/colortitration/common/model/entity/Pump.java b/src/main/java/com/iflytop/colortitration/common/model/entity/Pump.java index 60539f6..2bc7216 100644 --- a/src/main/java/com/iflytop/colortitration/common/model/entity/Pump.java +++ b/src/main/java/com/iflytop/colortitration/common/model/entity/Pump.java @@ -2,7 +2,7 @@ package com.iflytop.colortitration.common.model.entity; import com.baomidou.mybatisplus.annotation.TableName; import com.iflytop.colortitration.common.base.BaseEntity; -import com.iflytop.colortitration.common.enums.Device; +import com.iflytop.colortitration.common.enums.command.Device; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode;