|
|
@ -35,9 +35,9 @@ public class DeviceCommandGenerator { |
|
|
|
/** |
|
|
|
* 控制三通阀 |
|
|
|
*/ |
|
|
|
public static DeviceCommand threeWayValveControl(String action, String description) { |
|
|
|
public static DeviceCommand threeWayValveControl(String action, String commandName) { |
|
|
|
// 调用中层 controlCmd 时,直接用方法注释固定描述"控制三通阀" |
|
|
|
return controlCmd("three_way_valve", action, null, description != null ? description : "控制三通阀"); |
|
|
|
return controlCmd("three_way_valve", action, null, commandName != null ? commandName : "控制三通阀"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -57,8 +57,8 @@ public class DeviceCommandGenerator { |
|
|
|
/** |
|
|
|
* 控制清洗阀 |
|
|
|
*/ |
|
|
|
public static DeviceCommand washValveControl(String action, String description) { |
|
|
|
return controlCmd("wash_valve", action, null, description != null ? description : "控制清洗阀"); |
|
|
|
public static DeviceCommand washValveControl(String action, String commandName) { |
|
|
|
return controlCmd("wash_valve", action, null, commandName != null ? commandName : "控制清洗阀"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -78,8 +78,8 @@ public class DeviceCommandGenerator { |
|
|
|
/** |
|
|
|
* 控制喷嘴阀 |
|
|
|
*/ |
|
|
|
public static DeviceCommand nozzleValveControl(String action, String description) { |
|
|
|
return controlCmd("nozzle_valve", action, null, description != null ? description : "控制喷嘴阀"); |
|
|
|
public static DeviceCommand nozzleValveControl(String action, String commandName) { |
|
|
|
return controlCmd("nozzle_valve", action, null, commandName != null ? commandName : "控制喷嘴阀"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -99,8 +99,8 @@ public class DeviceCommandGenerator { |
|
|
|
/** |
|
|
|
* 控制除湿阀 |
|
|
|
*/ |
|
|
|
public static DeviceCommand dehumidifierValveControl(String action, String description) { |
|
|
|
return controlCmd("dehumidifier_valve", action, null, description != null ? description : "控制除湿阀"); |
|
|
|
public static DeviceCommand dehumidifierValveControl(String action, String commandName) { |
|
|
|
return controlCmd("dehumidifier_valve", action, null, commandName != null ? commandName : "控制除湿阀"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -120,8 +120,8 @@ public class DeviceCommandGenerator { |
|
|
|
/** |
|
|
|
* 控制照明灯板 |
|
|
|
*/ |
|
|
|
public static DeviceCommand lightingPanelControl(String action, String description) { |
|
|
|
return controlCmd("lighting_panel", action, null, description != null ? description : "控制照明灯板"); |
|
|
|
public static DeviceCommand lightingPanelControl(String action, String commandName) { |
|
|
|
return controlCmd("lighting_panel", action, null, commandName != null ? commandName : "控制照明灯板"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -358,22 +358,22 @@ public class DeviceCommandGenerator { |
|
|
|
/** |
|
|
|
* 移动x轴到指定位置 |
|
|
|
*/ |
|
|
|
private static DeviceCommand motorXPositionSet(Double position, Double speed, String description) { |
|
|
|
return controlMotorCmd("x", "move", null, "forward", position, speed, description); |
|
|
|
private static DeviceCommand motorXPositionSet(Double position, Double speed, String commandName) { |
|
|
|
return controlMotorCmd("x", "move", null, "forward", position, speed, commandName); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 移动y轴到指定位置 |
|
|
|
*/ |
|
|
|
private static DeviceCommand motorYPositionSet(Double position, Double speed, String description) { |
|
|
|
return controlMotorCmd("y", "move", null, "forward", position, speed, description); |
|
|
|
private static DeviceCommand motorYPositionSet(Double position, Double speed, String commandName) { |
|
|
|
return controlMotorCmd("y", "move", null, "forward", position, speed, commandName); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 移动z轴到指定位置 |
|
|
|
*/ |
|
|
|
private static DeviceCommand motorZPositionSet(Double position, Double speed, String description) { |
|
|
|
return controlMotorCmd("z", "move", null, "forward", position, speed, description); |
|
|
|
private static DeviceCommand motorZPositionSet(Double position, Double speed, String commandName) { |
|
|
|
return controlMotorCmd("z", "move", null, "forward", position, speed, commandName); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -463,16 +463,16 @@ public class DeviceCommandGenerator { |
|
|
|
/** |
|
|
|
* 控制设备电机 |
|
|
|
*/ |
|
|
|
public static DeviceCommand controlMotorCmd(String device, String action, Double current, String direction, Double position, Double speed, String description) { |
|
|
|
if (description == null) { |
|
|
|
description = "控制设备电机"; |
|
|
|
public static DeviceCommand controlMotorCmd(String device, String action, Double current, String direction, Double position, Double speed, String commandName) { |
|
|
|
if (commandName == null) { |
|
|
|
commandName = "控制设备电机"; |
|
|
|
} |
|
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
|
params.put("current", current); |
|
|
|
params.put("direction", direction); |
|
|
|
params.put("position", position); |
|
|
|
params.put("speed", speed); |
|
|
|
return deviceCmd("controlMotorCmd", device, action, params, description); |
|
|
|
return deviceCmd("controlMotorCmd", device, action, params, commandName); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -485,21 +485,21 @@ public class DeviceCommandGenerator { |
|
|
|
/** |
|
|
|
* 设备控制指令包装 |
|
|
|
*/ |
|
|
|
private static DeviceCommand controlCmd(String device, String action, Map<String, Object> params, String description) { |
|
|
|
return deviceCmd("controlCmd", device, action, params, description); |
|
|
|
private static DeviceCommand controlCmd(String device, String action, Map<String, Object> params, String commandName) { |
|
|
|
return deviceCmd("controlCmd", device, action, params, commandName); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取设备信息指令包装 |
|
|
|
*/ |
|
|
|
private static DeviceCommand getInfoCmd(String device, String description) { |
|
|
|
return deviceCmd("getInfoCmd", device, "get", null, description); |
|
|
|
private static DeviceCommand getInfoCmd(String device, String commandName) { |
|
|
|
return deviceCmd("getInfoCmd", device, "get", null, commandName); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 设备指令包装 |
|
|
|
*/ |
|
|
|
private static DeviceCommand deviceCmd(String code, String device, String action, Map<String, Object> params, String description) { |
|
|
|
private static DeviceCommand deviceCmd(String code, String device, String action, Map<String, Object> params, String commandName) { |
|
|
|
int cmdId = CyclicNumberGenerator.getInstance().generateNumber(); |
|
|
|
DeviceCommand cmdToDevice = new DeviceCommand(); |
|
|
|
cmdToDevice.setCommandId(cmdId); |
|
|
@ -507,7 +507,7 @@ public class DeviceCommandGenerator { |
|
|
|
cmdToDevice.setTargetDevice(device); |
|
|
|
cmdToDevice.setAction(action); |
|
|
|
cmdToDevice.setParams(params); |
|
|
|
cmdToDevice.setDescription(description); |
|
|
|
cmdToDevice.setCommandName(commandName); |
|
|
|
return cmdToDevice; |
|
|
|
} |
|
|
|
} |