|
|
@ -1,501 +0,0 @@ |
|
|
|
package com.iflytop.gd.common.device; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
/** |
|
|
|
* 生成给设备发送的指令 |
|
|
|
*/ |
|
|
|
public class DeviceCommandGenerator { |
|
|
|
|
|
|
|
/** |
|
|
|
* 全部关闭三通阀 |
|
|
|
*/ |
|
|
|
public static DeviceCommand threeWayValveCloseAll() { |
|
|
|
// 上层方法直接取方法注释“全部关闭三通阀” |
|
|
|
return threeWayValveControl("close_all", "全部关闭三通阀"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 打开三通阀喷嘴管路 |
|
|
|
*/ |
|
|
|
public static DeviceCommand threeWayValveOpenSyringePipeline() { |
|
|
|
return threeWayValveControl("open_syringe", "打开三通阀喷嘴管路"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 打开三通阀注射器管路 |
|
|
|
*/ |
|
|
|
public static DeviceCommand threeWayValveOpenNozzlePipeline() { |
|
|
|
return threeWayValveControl("open_nozzle", "打开三通阀注射器管路"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 控制三通阀 |
|
|
|
*/ |
|
|
|
public static DeviceCommand threeWayValveControl(String action, String commandName) { |
|
|
|
// 调用中层 controlCmd 时,直接用方法注释固定描述"控制三通阀" |
|
|
|
return controlCmd("three_way_valve", action, null, commandName != null ? commandName : "控制三通阀"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 关闭清洗阀 |
|
|
|
*/ |
|
|
|
public static DeviceCommand washValveClose() { |
|
|
|
return washValveControl("close", "关闭清洗阀"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 开启清洗阀 |
|
|
|
*/ |
|
|
|
public static DeviceCommand washValveOpen() { |
|
|
|
return washValveControl("open", "开启清洗阀"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 控制清洗阀 |
|
|
|
*/ |
|
|
|
public static DeviceCommand washValveControl(String action, String commandName) { |
|
|
|
return controlCmd("wash_valve", action, null, commandName != null ? commandName : "控制清洗阀"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 关闭喷嘴阀 |
|
|
|
*/ |
|
|
|
public static DeviceCommand nozzleValveClose() { |
|
|
|
return nozzleValveControl("close", "关闭喷嘴阀"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 开启喷嘴阀 |
|
|
|
*/ |
|
|
|
public static DeviceCommand nozzleValveOpen() { |
|
|
|
return nozzleValveControl("open", "开启喷嘴阀"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 控制喷嘴阀 |
|
|
|
*/ |
|
|
|
public static DeviceCommand nozzleValveControl(String action, String commandName) { |
|
|
|
return controlCmd("nozzle_valve", action, null, commandName != null ? commandName : "控制喷嘴阀"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 关闭除湿阀 |
|
|
|
*/ |
|
|
|
public static DeviceCommand dehumidifierValveClose() { |
|
|
|
return dehumidifierValveControl("close", "关闭除湿阀"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 开启除湿阀 |
|
|
|
*/ |
|
|
|
public static DeviceCommand dehumidifierValveOpen() { |
|
|
|
return dehumidifierValveControl("open", "开启除湿阀"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 控制除湿阀 |
|
|
|
*/ |
|
|
|
public static DeviceCommand dehumidifierValveControl(String action, String commandName) { |
|
|
|
return controlCmd("dehumidifier_valve", action, null, commandName != null ? commandName : "控制除湿阀"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 关闭照明灯板 |
|
|
|
*/ |
|
|
|
public static DeviceCommand lightingPanelClose() { |
|
|
|
return controlCmd("lighting_panel", "close", null, "关闭照明灯板"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 打开照明灯板 |
|
|
|
*/ |
|
|
|
public static DeviceCommand lightingPanelOpen() { |
|
|
|
return controlCmd("lighting_panel", "open", null, "打开照明灯板"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 控制照明灯板 |
|
|
|
*/ |
|
|
|
public static DeviceCommand lightingPanelControl(String action, String commandName) { |
|
|
|
return controlCmd("lighting_panel", action, null, commandName != null ? commandName : "控制照明灯板"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 关闭激光 |
|
|
|
*/ |
|
|
|
public static DeviceCommand laserControlClose() { |
|
|
|
return laserControl("close", null); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 打开激光 |
|
|
|
* |
|
|
|
* @param power 功率[0-100] |
|
|
|
*/ |
|
|
|
public static DeviceCommand laserControlOpen(Double power) { |
|
|
|
return laserControl("open", power); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 控制激光 |
|
|
|
* |
|
|
|
* @param power 功率[0-100] |
|
|
|
*/ |
|
|
|
public static DeviceCommand laserControl(String action, Double power) { |
|
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
|
params.put("power", power); |
|
|
|
return controlCmd("laser", action, params, "控制激光"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 关闭高压 |
|
|
|
*/ |
|
|
|
public static DeviceCommand highVoltageClose() { |
|
|
|
return highVoltageControl("close", null); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 开启高压 |
|
|
|
*/ |
|
|
|
public static DeviceCommand highVoltageOpen(Double voltage) { |
|
|
|
return highVoltageControl("open", voltage); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 控制高压 |
|
|
|
*/ |
|
|
|
public static DeviceCommand highVoltageControl(String action, Double voltage) { |
|
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
|
params.put("voltage", voltage); |
|
|
|
return controlCmd("high_voltage", action, params, "控制高压"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 停止推动注射泵 |
|
|
|
*/ |
|
|
|
public static DeviceCommand syringePumpStop() { |
|
|
|
return controlCmd("syringe_pump", "stop", null, "停止推动注射泵"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 推动移动注射泵 |
|
|
|
* |
|
|
|
* @param speed 是指注射泵每分钟注射多少微升(volume 最低0.1) |
|
|
|
*/ |
|
|
|
public static DeviceCommand syringePumpStart(String direction, Double speed) { |
|
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
|
params.put("direction", direction); |
|
|
|
params.put("speed", speed); |
|
|
|
return controlCmd("syringe_pump", "move", params, "推动移动注射泵"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 推动移动注射泵 |
|
|
|
* |
|
|
|
* @param speed 是指注射泵每分钟注射多少微升(volume 最低0.1) |
|
|
|
*/ |
|
|
|
public static DeviceCommand syringePumpForward(Double speed) { |
|
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
|
params.put("direction", "forward"); |
|
|
|
params.put("speed", speed); |
|
|
|
return controlCmd("syringe_pump", "move", params, "推动移动注射泵"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 注射泵流速设置 |
|
|
|
*/ |
|
|
|
public static DeviceCommand syringePumpVolumeSet(Double speed) { |
|
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
|
params.put("speed", speed); |
|
|
|
return controlCmd("syringe_pump", "set", params, "注射泵流速设置"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 控制注射泵 |
|
|
|
*/ |
|
|
|
public static DeviceCommand syringePumpControl(String action, String forward, Double volume) { |
|
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
|
params.put("current", forward); |
|
|
|
params.put("volume", volume); |
|
|
|
return controlCmd("syringe_pump", action, params, "控制注射泵"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取设备当前湿度 |
|
|
|
*/ |
|
|
|
public static DeviceCommand humidityGet() { |
|
|
|
return getInfoCmd("humidity", "获取设备当前湿度"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取设备当前温度 |
|
|
|
*/ |
|
|
|
public static DeviceCommand temperatureGet() { |
|
|
|
return getInfoCmd("temperature", "获取设备当前温度"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 推入玻片托盘 |
|
|
|
*/ |
|
|
|
public static DeviceCommand slideTrayIn(Double position, Double speed) { |
|
|
|
return motorYPositionSet(position, speed, "推入玻片托盘"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 推出玻片托盘 |
|
|
|
*/ |
|
|
|
public static DeviceCommand slideTrayOut(Double position, Double speed) { |
|
|
|
return motorYPositionSet(position, speed, "推出玻片托盘"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获得电机XYZ相对原点坐标 |
|
|
|
*/ |
|
|
|
public static DeviceCommand motorXyzPositionGet() { |
|
|
|
return getInfoCmd("xyz", "获得电机XYZ相对原点坐标"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* x轴停止移动 |
|
|
|
*/ |
|
|
|
public static DeviceCommand motorXStop() { |
|
|
|
return controlMotorCmd("x", "stop", null, null, null, null, "x轴停止移动"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* y轴停止移动 |
|
|
|
*/ |
|
|
|
public static DeviceCommand motorYStop() { |
|
|
|
return controlMotorCmd("y", "stop", null, null, null, null, "y轴停止移动"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* z轴停止移动 |
|
|
|
*/ |
|
|
|
public static DeviceCommand motorZStop() { |
|
|
|
return controlMotorCmd("z", "stop", null, null, null, null, "z轴停止移动"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* x轴回原点 |
|
|
|
*/ |
|
|
|
public static DeviceCommand motorXOrigin() { |
|
|
|
return controlMotorCmd("x", "origin", null, null, null, null, "x轴回原点"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* y轴回原点 |
|
|
|
*/ |
|
|
|
public static DeviceCommand motorYOrigin() { |
|
|
|
return controlMotorCmd("y", "origin", null, null, null, null, "y轴回原点"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* z轴回原点 |
|
|
|
*/ |
|
|
|
public static DeviceCommand motorZOrigin() { |
|
|
|
return controlMotorCmd("z", "origin", null, null, null, null, "z轴回原点"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 移动x轴到指定位置 |
|
|
|
*/ |
|
|
|
public static DeviceCommand motorXPositionSet(Double position) { |
|
|
|
return motorXPositionSet(position, null, "移动x轴到指定位置"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 移动y轴到指定位置 |
|
|
|
*/ |
|
|
|
public static DeviceCommand motorYPositionSet(Double position) { |
|
|
|
return motorYPositionSet(position, null, "移动y轴到指定位置"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 移动z轴到指定位置 |
|
|
|
*/ |
|
|
|
public static DeviceCommand motorZPositionSet(Double position) { |
|
|
|
return motorZPositionSet(position, null, "移动z轴到指定位置"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 移动x轴到指定位置 |
|
|
|
*/ |
|
|
|
public static DeviceCommand motorXPositionSet(Double position, Double speed) { |
|
|
|
return motorXPositionSet(position, speed, "移动x轴到指定位置"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 移动y轴到指定位置 |
|
|
|
*/ |
|
|
|
public static DeviceCommand motorYPositionSet(Double position, Double speed) { |
|
|
|
return motorYPositionSet(position, speed, "移动y轴到指定位置"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 移动z轴到指定位置 |
|
|
|
*/ |
|
|
|
public static DeviceCommand motorZPositionSet(Double position, Double speed) { |
|
|
|
return motorZPositionSet(position, speed, "移动z轴到指定位置"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 移动x轴到指定位置 |
|
|
|
*/ |
|
|
|
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 commandName) { |
|
|
|
return controlMotorCmd("y", "move", null, "forward", position, speed, commandName); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 移动z轴到指定位置 |
|
|
|
*/ |
|
|
|
private static DeviceCommand motorZPositionSet(Double position, Double speed, String commandName) { |
|
|
|
return controlMotorCmd("z", "move", null, "forward", position, speed, commandName); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* x电机方向设置 |
|
|
|
*/ |
|
|
|
public static DeviceCommand motorXDirectionSet(String direction) { |
|
|
|
return controlMotorCmd("x", "set", null, direction, null, null, "x电机方向设置"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* y电机方向设置 |
|
|
|
*/ |
|
|
|
public static DeviceCommand motorYDirectionSet(String direction) { |
|
|
|
return controlMotorCmd("y", "set", null, direction, null, null, "y电机方向设置"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* z电机方向设置 |
|
|
|
*/ |
|
|
|
public static DeviceCommand motorZDirectionSet(String direction) { |
|
|
|
return controlMotorCmd("z", "set", null, direction, null, null, "z电机方向设置"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* x轴电机电流设置 |
|
|
|
*/ |
|
|
|
public static DeviceCommand motorXCurrentSet(Double current) { |
|
|
|
return controlMotorCmd("x", "set", current, null, null, null, "x轴电机电流设置"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* y轴电机电流设置 |
|
|
|
*/ |
|
|
|
public static DeviceCommand motorYCurrentSet(Double current) { |
|
|
|
return controlMotorCmd("y", "set", current, null, null, null, "y轴电机电流设置"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* z轴电机电流设置 |
|
|
|
*/ |
|
|
|
public static DeviceCommand motorZCurrentSet(Double current) { |
|
|
|
return controlMotorCmd("z", "set", current, null, null, null, "z轴电机电流设置"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* x轴电机速度设置 |
|
|
|
*/ |
|
|
|
public static DeviceCommand motorXSpeedSet(Double speed) { |
|
|
|
return controlMotorCmd("x", "set", null, null, null, speed, "x轴电机速度设置"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* y轴电机速度设置 |
|
|
|
*/ |
|
|
|
public static DeviceCommand motorYSpeedSet(Double speed) { |
|
|
|
return controlMotorCmd("y", "set", null, null, null, speed, "y轴电机速度设置"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* z轴电机速度设置 |
|
|
|
*/ |
|
|
|
public static DeviceCommand motorZSpeedSet(Double speed) { |
|
|
|
return controlMotorCmd("z", "set", null, null, null, speed, "z轴电机速度设置"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* x轴电机控制 |
|
|
|
*/ |
|
|
|
public static DeviceCommand motorX(String action, Double current, String direction, Double position, Double speed) { |
|
|
|
return controlMotorCmd("x", action, current, direction, position, speed, "x轴电机控制"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* y轴电机控制 |
|
|
|
*/ |
|
|
|
public static DeviceCommand motorY(String action, Double current, String direction, Double position, Double speed) { |
|
|
|
return controlMotorCmd("y", action, current, direction, position, speed, "y轴电机控制"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* z轴电机控制 |
|
|
|
*/ |
|
|
|
public static DeviceCommand motorZ(String action, Double current, String direction, Double position, Double speed) { |
|
|
|
return controlMotorCmd("z", action, current, direction, position, speed, "z轴电机控制"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 控制设备电机 |
|
|
|
*/ |
|
|
|
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, commandName); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取设备整体状态 |
|
|
|
*/ |
|
|
|
public static DeviceCommand overallDeviceStatusGet() { |
|
|
|
return getInfoCmd("device", "获取设备整体状态"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 设备控制指令包装 |
|
|
|
*/ |
|
|
|
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 commandName) { |
|
|
|
return deviceCmd("getInfoCmd", device, "get", null, commandName); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 设备指令包装 |
|
|
|
*/ |
|
|
|
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.setCmdId(cmdId); |
|
|
|
cmdToDevice.setCmdCode(code); |
|
|
|
cmdToDevice.setDevice(device); |
|
|
|
cmdToDevice.setAction(action); |
|
|
|
cmdToDevice.setParam(params); |
|
|
|
cmdToDevice.setCmdName(commandName); |
|
|
|
return cmdToDevice; |
|
|
|
} |
|
|
|
} |
|
|
|
|