Browse Source

feat:定义常用指令

master
白凤吉 2 weeks ago
parent
commit
daf47788e4
  1. 6
      src/main/java/com/iflytop/colortitration/app/common/command/DeviceCommand.java
  2. 19
      src/main/java/com/iflytop/colortitration/app/common/command/DeviceCommandBundle.java
  3. 700
      src/main/java/com/iflytop/colortitration/app/common/command/DeviceCommandGenerator.java
  4. 11
      src/main/java/com/iflytop/colortitration/common/cmd/DeviceCommandParams.java
  5. 22
      src/main/java/com/iflytop/colortitration/common/command/DeviceCommandParams.java
  6. 9
      src/main/java/com/iflytop/colortitration/common/enums/Action.java
  7. 36
      src/main/java/com/iflytop/colortitration/common/enums/command/Action.java
  8. 7
      src/main/java/com/iflytop/colortitration/common/enums/command/Device.java
  9. 5
      src/main/java/com/iflytop/colortitration/common/enums/command/MotorDirection.java
  10. 5
      src/main/java/com/iflytop/colortitration/common/enums/command/TricolorLightColor.java
  11. 2
      src/main/java/com/iflytop/colortitration/common/handler/DeviceTypeHandler.java
  12. 2
      src/main/java/com/iflytop/colortitration/common/model/entity/Pump.java

6
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

19
src/main/java/com/iflytop/colortitration/app/common/command/DeviceCommandBundle.java

@ -1,19 +0,0 @@
package com.iflytop.colortitration.app.common.command;
import lombok.Data;
@Data
public class DeviceCommandBundle {
/**
* 指令名称
*/
private String cmdName;
/**
* 指令
*/
private DeviceCommand deviceCommand;
}

700
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;
}
}

11
src/main/java/com/iflytop/colortitration/common/cmd/DeviceCommandParams.java

@ -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;
}

22
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;
}

9
src/main/java/com/iflytop/colortitration/common/enums/Action.java

@ -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
}

36
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();
}
}

7
src/main/java/com/iflytop/colortitration/common/enums/Device.java → 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, "三色灯"),
;
/**
* 设备所属硬件类型

5
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
}

5
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
}

2
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;

2
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;

Loading…
Cancel
Save