Browse Source

fix:增加全部电机使能 失能 停止

master
王梦远 2 months ago
parent
commit
2817f08ea1
  1. 22
      src/main/java/com/iflytop/sgs/app/cmd/debug/step/DebugDisabledAllMotorCommand.java
  2. 23
      src/main/java/com/iflytop/sgs/app/cmd/debug/step/DebugEnableAllMotorCommand.java
  3. 25
      src/main/java/com/iflytop/sgs/app/cmd/debug/step/DebugStopAllMotorCommand.java
  4. 19
      src/main/java/com/iflytop/sgs/app/service/device/StepCommandService.java
  5. 2
      src/main/java/com/iflytop/sgs/app/ws/client/DeviceEmergencyStopConfig.java
  6. 90
      src/main/java/com/iflytop/sgs/common/cmd/DeviceCommandGenerator.java
  7. 2
      src/main/java/com/iflytop/sgs/common/enums/cmd/CmdAction.java
  8. 2
      src/main/java/com/iflytop/sgs/common/enums/cmd/CmdDevice.java

22
src/main/java/com/iflytop/sgs/app/cmd/debug/step/DebugDisabledAllMotorCommand.java

@ -2,8 +2,10 @@ package com.iflytop.sgs.app.cmd.debug.step;
import com.iflytop.sgs.app.core.BaseCommandHandler;
import com.iflytop.sgs.app.model.dto.CmdDTO;
import com.iflytop.sgs.app.service.device.StepCommandService;
import com.iflytop.sgs.app.service.device.DeviceCommandService;
import com.iflytop.sgs.common.annotation.CommandDebugMapping;
import com.iflytop.sgs.common.cmd.DeviceCommandBundle;
import com.iflytop.sgs.common.cmd.DeviceCommandGenerator;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -18,13 +20,27 @@ import java.util.concurrent.CompletableFuture;
@RequiredArgsConstructor
@CommandDebugMapping("debug_disabled_all_motor")
public class DebugDisabledAllMotorCommand extends BaseCommandHandler {
private final StepCommandService stepCommandService;
private final DeviceCommandService deviceCommandService;
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) throws Exception {
return runAsync(() -> {
//stepCommandService.disabilityAll();
//门电机
DeviceCommandBundle doorDisableDeviceCommandBundle = DeviceCommandGenerator.doorDisable();
deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), doorDisableDeviceCommandBundle);
//x轴
DeviceCommandBundle xDisableDeviceCommandBundle = DeviceCommandGenerator.transferXDisable();
deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), xDisableDeviceCommandBundle);
//z轴
DeviceCommandBundle yDisableDeviceCommandBundle = DeviceCommandGenerator.transferZDisable();
deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), yDisableDeviceCommandBundle);
//机械臂
DeviceCommandBundle liquidMotorDisableDeviceCommandBundle = DeviceCommandGenerator.liquidMotorDisable();
deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidMotorDisableDeviceCommandBundle);
//蠕动泵
DeviceCommandBundle liquidPumpDisableDeviceCommandBundle = DeviceCommandGenerator.liquidPumpDisable();
deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidPumpDisableDeviceCommandBundle);
});
}
}

23
src/main/java/com/iflytop/sgs/app/cmd/debug/step/DebugEnableAllMotorCommand.java

@ -2,8 +2,10 @@ package com.iflytop.sgs.app.cmd.debug.step;
import com.iflytop.sgs.app.core.BaseCommandHandler;
import com.iflytop.sgs.app.model.dto.CmdDTO;
import com.iflytop.sgs.app.service.device.StepCommandService;
import com.iflytop.sgs.app.service.device.DeviceCommandService;
import com.iflytop.sgs.common.annotation.CommandDebugMapping;
import com.iflytop.sgs.common.cmd.DeviceCommandBundle;
import com.iflytop.sgs.common.cmd.DeviceCommandGenerator;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -18,13 +20,26 @@ import java.util.concurrent.CompletableFuture;
@RequiredArgsConstructor
@CommandDebugMapping("debug_enable_all_motor")
public class DebugEnableAllMotorCommand extends BaseCommandHandler {
private final StepCommandService stepCommandService;
private final DeviceCommandService deviceCommandService;
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) throws Exception {
return runAsync(() -> {
//stepCommandService.enableAll();
//门电机
DeviceCommandBundle doorEnableDeviceCommandBundle = DeviceCommandGenerator.doorEnable();
deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), doorEnableDeviceCommandBundle);
//x轴
DeviceCommandBundle xEnableDeviceCommandBundle = DeviceCommandGenerator.transferXEnable();
deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), xEnableDeviceCommandBundle);
//z轴
DeviceCommandBundle yEnableDeviceCommandBundle = DeviceCommandGenerator.transferZEnable();
deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), yEnableDeviceCommandBundle);
//机械臂
DeviceCommandBundle liquidMotorEnableDeviceCommandBundle = DeviceCommandGenerator.liquidMotorEnable();
deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidMotorEnableDeviceCommandBundle);
//蠕动泵
DeviceCommandBundle liquidPumpEnableDeviceCommandBundle = DeviceCommandGenerator.liquidPumpEnable();
deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidPumpEnableDeviceCommandBundle);
});
}
}

25
src/main/java/com/iflytop/sgs/app/cmd/debug/step/DebugStopAllMotorCommand.java

@ -2,8 +2,12 @@ package com.iflytop.sgs.app.cmd.debug.step;
import com.iflytop.sgs.app.core.BaseCommandHandler;
import com.iflytop.sgs.app.model.dto.CmdDTO;
import com.iflytop.sgs.app.service.device.StepCommandService;
import com.iflytop.sgs.app.service.device.DeviceCommandService;
import com.iflytop.sgs.common.annotation.CommandDebugMapping;
import com.iflytop.sgs.common.cmd.CommandFuture;
import com.iflytop.sgs.common.cmd.DeviceCommandBundle;
import com.iflytop.sgs.common.cmd.DeviceCommandGenerator;
import com.iflytop.sgs.common.utils.CommandUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -18,12 +22,27 @@ import java.util.concurrent.CompletableFuture;
@RequiredArgsConstructor
@CommandDebugMapping("debug_stop_all_motor")
public class DebugStopAllMotorCommand extends BaseCommandHandler {
private final StepCommandService stepCommandService;
private final DeviceCommandService deviceCommandService;
@Override
public CompletableFuture<Void> handle(CmdDTO cmdDTO) throws Exception {
return runAsync(() -> {
//stepCommandService.stopAll();
//门电机
DeviceCommandBundle doorStopDeviceCommandBundle = DeviceCommandGenerator.doorStop();
deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), doorStopDeviceCommandBundle);
//x轴
DeviceCommandBundle xStopDeviceCommandBundle = DeviceCommandGenerator.transferXStop();
deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), xStopDeviceCommandBundle);
//z轴
DeviceCommandBundle yStopDeviceCommandBundle = DeviceCommandGenerator.transferZStop();
deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), yStopDeviceCommandBundle);
//机械臂
DeviceCommandBundle liquidMotorStopDeviceCommandBundle = DeviceCommandGenerator.liquidMotorStop();
deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidMotorStopDeviceCommandBundle);
//蠕动泵
DeviceCommandBundle liquidPumpStopDeviceCommandBundle = DeviceCommandGenerator.liquidPumpStop();
deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidPumpStopDeviceCommandBundle);
});
}
}

19
src/main/java/com/iflytop/sgs/app/service/device/StepCommandService.java

@ -1,19 +0,0 @@
package com.iflytop.sgs.app.service.device;
import com.iflytop.sgs.app.model.bo.Point3D;
import com.iflytop.sgs.app.service.device.module.TransferModuleService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
/**
* 单步运动调试服务
*/
@Service
@RequiredArgsConstructor
public class StepCommandService {
private final TransferModuleService transferModuleService;
public void gantryToPoint3D(Point3D point3D) throws Exception {
transferModuleService.transferMove(point3D);
}
}

2
src/main/java/com/iflytop/sgs/app/ws/client/DeviceEmergencyStopConfig.java

@ -2,7 +2,6 @@ package com.iflytop.sgs.app.ws.client;
import com.iflytop.sgs.app.core.CommandPoolManager;
import com.iflytop.sgs.app.service.device.DeviceStateService;
import com.iflytop.sgs.app.service.device.StepCommandService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
@ -15,7 +14,6 @@ import java.net.URI;
@Configuration
@RequiredArgsConstructor
public class DeviceEmergencyStopConfig {
private final StepCommandService stepCommandService;
private final DeviceStateService deviceStateService;
private final CommandPoolManager commandPoolManager;

90
src/main/java/com/iflytop/sgs/common/cmd/DeviceCommandGenerator.java

@ -33,6 +33,7 @@ public class DeviceCommandGenerator {
return controlMotorCmd(CmdDevice.door_motor, CmdAction.move_by, params, "门 相对移动");
}
/**
* 停止动作
*/
@ -57,6 +58,20 @@ public class DeviceCommandGenerator {
params.setSpeed(speed);
return setInfoCmd(CmdDevice.door_motor, CmdAction.set, params, "门 设置参数");
}
/**
* 失能
*
*/
public static DeviceCommandBundle doorDisable() {
return controlMotorCmd(CmdDevice.door_motor, CmdAction.disable, null, "门 失能");
}
/**
* 使能
*
*/
public static DeviceCommandBundle doorEnable() {
return controlMotorCmd(CmdDevice.door_motor, CmdAction.enable, null, "门 使能");
}
/**
* x轴设置参数
@ -100,7 +115,20 @@ public class DeviceCommandGenerator {
return controlMotorCmd(CmdDevice.x_motor, CmdAction.origin, null, "x轴回原点");
}
/**
* z轴 失能
*
*/
public static DeviceCommandBundle transferZDisable() {
return controlMotorCmd(CmdDevice.z_motor, CmdAction.disable, null, "z轴 失能");
}
/**
* z轴 使能
*
*/
public static DeviceCommandBundle transferZEnable() {
return controlMotorCmd(CmdDevice.z_motor, CmdAction.enable, null, "z轴 使能");
}
/**
* z轴回原点
*/
@ -166,7 +194,20 @@ public class DeviceCommandGenerator {
public static DeviceCommandBundle transferXStop() {
return controlMotorCmd(CmdDevice.x_motor, CmdAction.stop, null, "x轴停止");
}
/**
* x轴 失能
*
*/
public static DeviceCommandBundle transferXDisable() {
return controlMotorCmd(CmdDevice.x_motor, CmdAction.disable, null, "x轴 失能");
}
/**
* x轴 使能
*
*/
public static DeviceCommandBundle transferXEnable() {
return controlMotorCmd(CmdDevice.x_motor, CmdAction.enable, null, "x轴 使能");
}
/**
* z轴停止
@ -203,6 +244,20 @@ public class DeviceCommandGenerator {
params.setPosition(position);
return controlCmd(CmdDevice.liquid_motor, CmdAction.move_by, params, "加液机械臂 相对移动");
}
/**
* 加液机械臂 失能
*
*/
public static DeviceCommandBundle liquidMotorDisable() {
return controlMotorCmd(CmdDevice.liquid_motor, CmdAction.disable, null, "加液机械臂 失能");
}
/**
* 加液机械臂 使能
*
*/
public static DeviceCommandBundle liquidMotorEnable() {
return controlMotorCmd(CmdDevice.liquid_motor, CmdAction.enable, null, "加液机械臂 使能");
}
/**
* 加液泵设置参数
@ -244,6 +299,20 @@ public class DeviceCommandGenerator {
return controlCmd(CmdDevice.liquid_pump, CmdAction.stop, params, "加液泵 停止");
}
/**
* 加液泵 失能
*
*/
public static DeviceCommandBundle liquidPumpDisable() {
return controlMotorCmd(CmdDevice.liquid_pump, CmdAction.disable, null, "z轴 失能");
}
/**
* 加液泵 使能
*
*/
public static DeviceCommandBundle liquidPumpEnable() {
return controlMotorCmd(CmdDevice.liquid_pump, CmdAction.enable, null, "z轴 使能");
}
/**
* 加液泵 开始旋转
*/
public static DeviceCommandBundle liquidPumpStart(CmdDirection direction) {
@ -266,10 +335,16 @@ public class DeviceCommandGenerator {
* 四路电磁控制阀关闭
*/
public static DeviceCommandBundle valveClose() {
return controlCmd(CmdDevice.liquid_valve, CmdAction.close, null, "电磁转换阀 转换");
return controlCmd(CmdDevice.liquid_valve, CmdAction.close, null, "电磁转换阀 关闭");
}
/**
* 四路电磁控制阀转获取状态
*/
public static DeviceCommandBundle getValveInfo(Integer channel) {
return controlCmd(CmdDevice.liquid_valve, CmdAction.get, null, "电磁转换阀 获取状态");
}
/**
* 风扇 1打开
*/
public static DeviceCommandBundle fan1Open() {
@ -430,17 +505,16 @@ public class DeviceCommandGenerator {
/**
* 蜂鸣器
*
* @param
*/
public static DeviceCommandBundle beepOpen() {
return controlCmd(CmdDevice.beep, CmdAction.open, null, "三色灯 开启");
return controlCmd(CmdDevice.beep, CmdAction.open, null, "蜂鸣器 开启");
}
/**
* 蜂鸣器
*/
public static DeviceCommandBundle beepClose() {
return controlCmd(CmdDevice.beep, CmdAction.close, null, "三色灯 关闭");
return controlCmd(CmdDevice.beep, CmdAction.close, null, "蜂鸣器 关闭");
}
/**
@ -462,11 +536,11 @@ public class DeviceCommandGenerator {
}
/**
* 获取托盘状态 todo 文档action是heater_tray
* 获取传感器状态
*
*/
public static DeviceCommandBundle getTrayStatus() {
return getInfoCmd(CmdDevice.sensor, "获取托盘状态");
return getInfoCmd(CmdDevice.sensor, "获取传感器状态");
}
/**

2
src/main/java/com/iflytop/sgs/common/enums/cmd/CmdAction.java

@ -6,5 +6,5 @@ public enum CmdAction {
open, close, stop, start, set, get,
open_power, close_power, open_circle, close_circle,
open_heart, close_heart, open_cool, close_cool, take_photo,
heater_tray,
enable,disable
}

2
src/main/java/com/iflytop/sgs/common/enums/cmd/CmdDevice.java

@ -15,8 +15,6 @@ public enum CmdDevice {
heat_rod_2,
heat_rod_3,
heat_rod_4,
liquid_motor_clamp,//机械臂抱闸
z_motor_clamp,//z轴抱闸
tricolor_light,//三色灯
beep,//蜂鸣器
heater_tray,//加热位托盘

Loading…
Cancel
Save