13 changed files with 824 additions and 96 deletions
-
6src/main/java/com/iflytop/colortitration/app/common/command/DeviceCommand.java
-
19src/main/java/com/iflytop/colortitration/app/common/command/DeviceCommandBundle.java
-
700src/main/java/com/iflytop/colortitration/app/common/command/DeviceCommandGenerator.java
-
11src/main/java/com/iflytop/colortitration/common/cmd/DeviceCommandParams.java
-
22src/main/java/com/iflytop/colortitration/common/command/DeviceCommandParams.java
-
9src/main/java/com/iflytop/colortitration/common/enums/Action.java
-
36src/main/java/com/iflytop/colortitration/common/enums/command/Action.java
-
7src/main/java/com/iflytop/colortitration/common/enums/command/Device.java
-
5src/main/java/com/iflytop/colortitration/common/enums/command/MotorDirection.java
-
5src/main/java/com/iflytop/colortitration/common/enums/command/TricolorLightColor.java
-
2src/main/java/com/iflytop/colortitration/common/handler/DeviceTypeHandler.java
-
2src/main/java/com/iflytop/colortitration/common/model/entity/Pump.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; |
|
||||
|
|
||||
} |
|
||||
|
|
@ -1,11 +1,709 @@ |
|||||
package com.iflytop.colortitration.app.common.command; |
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 { |
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; |
||||
|
} |
||||
} |
} |
@ -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; |
|
||||
} |
|
@ -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; |
||||
|
} |
@ -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 |
|
||||
} |
|
@ -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(); |
||||
|
} |
||||
|
} |
@ -0,0 +1,5 @@ |
|||||
|
package com.iflytop.colortitration.common.enums.command; |
||||
|
|
||||
|
public enum MotorDirection { |
||||
|
forward, backward |
||||
|
} |
@ -0,0 +1,5 @@ |
|||||
|
package com.iflytop.colortitration.common.enums.command; |
||||
|
|
||||
|
public enum TricolorLightColor { |
||||
|
red, green, blue |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue