Browse Source
Merge remote-tracking branch 'origin/master'
Merge remote-tracking branch 'origin/master'
# Conflicts: # src/main/java/com/iflytop/sgs/common/cmd/DeviceCommandParams.java # src/main/java/com/iflytop/sgs/hardware/service/GDDeviceStatusServiceImpl.javamaster
26 changed files with 450 additions and 221 deletions
-
7src/main/java/com/iflytop/sgs/app/cmd/control/CleanStartCommand.java
-
2src/main/java/com/iflytop/sgs/app/cmd/control/LiquidAddCommand.java
-
9src/main/java/com/iflytop/sgs/app/cmd/control/LiquidReduceCommand.java
-
6src/main/java/com/iflytop/sgs/app/cmd/control/MoveToFeedAreaCommand.java
-
36src/main/java/com/iflytop/sgs/app/cmd/debug/DebugBeeCloseCommand.java
-
38src/main/java/com/iflytop/sgs/app/cmd/debug/DebugBeeOpenCommand.java
-
2src/main/java/com/iflytop/sgs/app/cmd/debug/DebugHeaterStopCommand.java
-
5src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpAddCommand.java
-
7src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpReduceCommand.java
-
5src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidValveOpenThickCommand.java
-
3src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidValveOpenThinCommand.java
-
5src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidValveOpenWasteCommand.java
-
5src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidValveOpenWaterCommand.java
-
1src/main/java/com/iflytop/sgs/app/controller/DevicePointController.java
-
36src/main/java/com/iflytop/sgs/app/controller/MotorController.java
-
2src/main/java/com/iflytop/sgs/app/service/device/DeviceInitService.java
-
70src/main/java/com/iflytop/sgs/app/service/device/DeviceSensorService.java
-
32src/main/java/com/iflytop/sgs/app/service/device/DeviceStopService.java
-
4src/main/java/com/iflytop/sgs/app/ws/client/DeviceEmergencyStopConfig.java
-
4src/main/java/com/iflytop/sgs/common/cmd/DeviceCommandGenerator.java
-
4src/main/java/com/iflytop/sgs/common/enums/DeviceSensorCode.java
-
2src/main/java/com/iflytop/sgs/common/service/GDDeviceStatusService.java
-
0src/main/java/com/iflytop/sgs/hardware/service/GDDeviceStatusServiceImpl.java
@ -0,0 +1,36 @@ |
|||
package com.iflytop.sgs.app.cmd.debug; |
|||
|
|||
import com.iflytop.sgs.app.core.BaseCommandHandler; |
|||
import com.iflytop.sgs.app.model.dto.CmdDTO; |
|||
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; |
|||
|
|||
import java.util.concurrent.CompletableFuture; |
|||
|
|||
/** |
|||
* 蜂鸣器关闭 |
|||
*/ |
|||
@Slf4j |
|||
@Component |
|||
@RequiredArgsConstructor |
|||
@CommandDebugMapping("door_close") |
|||
public class DebugBeeCloseCommand extends BaseCommandHandler { |
|||
private final DeviceCommandService deviceCommandService; |
|||
|
|||
@Override |
|||
public CompletableFuture<Void> handle(CmdDTO cmdDTO) { |
|||
return runAsync(() -> { |
|||
DeviceCommandBundle beepCloseDeviceCommandBundle = DeviceCommandGenerator.beepClose(); |
|||
CommandFuture doorSetDeviceCommandSetFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), beepCloseDeviceCommandBundle); |
|||
CommandUtil.wait(doorSetDeviceCommandSetFuture); |
|||
}); |
|||
} |
|||
} |
|||
|
@ -0,0 +1,38 @@ |
|||
package com.iflytop.sgs.app.cmd.debug; |
|||
|
|||
import com.iflytop.sgs.app.core.BaseCommandHandler; |
|||
import com.iflytop.sgs.app.model.dto.CmdDTO; |
|||
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; |
|||
|
|||
import java.util.concurrent.CompletableFuture; |
|||
|
|||
/** |
|||
* 蜂鸣器打开 |
|||
*/ |
|||
@Slf4j |
|||
@Component |
|||
@RequiredArgsConstructor |
|||
@CommandDebugMapping("door_close") |
|||
public class DebugBeeOpenCommand extends BaseCommandHandler { |
|||
private final DeviceCommandService deviceCommandService; |
|||
|
|||
@Override |
|||
public CompletableFuture<Void> handle(CmdDTO cmdDTO) { |
|||
String mode = cmdDTO.getStringParam("mode"); |
|||
return runAsync(() -> { |
|||
DeviceCommandBundle beeOpenDeviceCommand = DeviceCommandGenerator.beepOpen(mode); |
|||
CommandFuture doorMoveDeviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), beeOpenDeviceCommand); |
|||
CommandUtil.wait(doorMoveDeviceCommandFuture); |
|||
|
|||
}); |
|||
} |
|||
} |
|||
|
@ -0,0 +1,36 @@ |
|||
package com.iflytop.sgs.app.controller; |
|||
|
|||
import com.iflytop.sgs.app.service.device.DeviceSensorService; |
|||
import com.iflytop.sgs.common.enums.DevicePartId; |
|||
import com.iflytop.sgs.common.result.Result; |
|||
import com.iflytop.sgs.hardware.exception.HardwareException; |
|||
import io.swagger.v3.oas.annotations.Operation; |
|||
import io.swagger.v3.oas.annotations.tags.Tag; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
/** |
|||
* 认证控制 |
|||
*/ |
|||
@Tag(name = "设备") |
|||
@RestController |
|||
@RequestMapping("/api/motor") |
|||
@RequiredArgsConstructor |
|||
@Slf4j |
|||
public class MotorController { |
|||
|
|||
private DeviceSensorService deviceSensorService; |
|||
|
|||
@Operation(summary = "获取当前电机位置") |
|||
@GetMapping("/position/{motor}") |
|||
public Result<Double> getPosition(@PathVariable String motor) { |
|||
DevicePartId devicePartId = DevicePartId.valueOf(motor); |
|||
try { |
|||
Double position = deviceSensorService.getSensorStatus(devicePartId); |
|||
return Result.success(position); |
|||
} catch (HardwareException e) { |
|||
throw new RuntimeException(e); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,70 @@ |
|||
package com.iflytop.sgs.app.service.device; |
|||
|
|||
import com.iflytop.sgs.app.model.bo.status.device.HeatModuleState; |
|||
import com.iflytop.sgs.app.model.bo.status.device.SolutionContainerState; |
|||
import com.iflytop.sgs.app.model.bo.status.device.SolutionModuleState; |
|||
import com.iflytop.sgs.common.enums.ContainerCode; |
|||
import com.iflytop.sgs.common.enums.DevicePartId; |
|||
import com.iflytop.sgs.common.enums.DeviceSensorCode; |
|||
import com.iflytop.sgs.common.enums.HeatModuleCode; |
|||
import com.iflytop.sgs.common.service.GDDeviceStatusService; |
|||
import com.iflytop.sgs.hardware.exception.HardwareException; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.scheduling.annotation.Scheduled; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Slf4j |
|||
@Service |
|||
@RequiredArgsConstructor |
|||
public class DeviceSensorService { |
|||
private final GDDeviceStatusService deviceStatusService; |
|||
private final DeviceStateService deviceStateService; |
|||
|
|||
/* |
|||
* 获取传感器状态 |
|||
* */ |
|||
public boolean getSensorStatus(DeviceSensorCode sensorCode) throws HardwareException { |
|||
return deviceStatusService.getInputState(sensorCode.name()); |
|||
} |
|||
|
|||
/* |
|||
* 获取电机位置 |
|||
* */ |
|||
public Double getSensorStatus(DevicePartId devicePartId) throws HardwareException { |
|||
return deviceStatusService.getStepMotorPostion(devicePartId.name()); |
|||
} |
|||
|
|||
@Scheduled(fixedRate = 1000) |
|||
public void deviceSensorSchedule() throws HardwareException { |
|||
HeatModuleState heat_module_01 = deviceStateService.getDeviceState().getHeatModuleByCode(HeatModuleCode.heat_module_01); |
|||
heat_module_01.setTrayStatus(this.getSensorStatus(DeviceSensorCode.HEATER_TRAY_1_EXIST)); |
|||
|
|||
HeatModuleState heat_module_02 = deviceStateService.getDeviceState().getHeatModuleByCode(HeatModuleCode.heat_module_02); |
|||
heat_module_02.setTrayStatus(this.getSensorStatus(DeviceSensorCode.HEATER_TRAY_2_EXIST)); |
|||
|
|||
HeatModuleState heat_module_03 = deviceStateService.getDeviceState().getHeatModuleByCode(HeatModuleCode.heat_module_03); |
|||
heat_module_03.setTrayStatus(this.getSensorStatus(DeviceSensorCode.HEATER_TRAY_3_EXIST)); |
|||
|
|||
HeatModuleState heat_module_04 = deviceStateService.getDeviceState().getHeatModuleByCode(HeatModuleCode.heat_module_04); |
|||
heat_module_04.setTrayStatus(this.getSensorStatus(DeviceSensorCode.HEATER_TRAY_4_EXIST)); |
|||
SolutionModuleState solutionModuleState = deviceStateService.getDeviceState().getSolutionModule(); |
|||
//todo 需要确认传感器个数以及这个传感器是否是加液传感器 |
|||
solutionModuleState.setFeedAreaTrayStatus(this.getSensorStatus(DeviceSensorCode.LIQUID_TRAY_EXIST)); |
|||
|
|||
SolutionContainerState container_01 = solutionModuleState.getContainerStateByCode(ContainerCode.container_01); |
|||
container_01.setEmpty(this.getSensorStatus(DeviceSensorCode.THIN_LOW_LEVEL)); |
|||
SolutionContainerState container_02 = solutionModuleState.getContainerStateByCode(ContainerCode.container_02); |
|||
container_02.setEmpty(this.getSensorStatus(DeviceSensorCode.THICK_LOW_LEVEL)); |
|||
SolutionContainerState container_03 = solutionModuleState.getContainerStateByCode(ContainerCode.container_03); |
|||
container_03.setEmpty(this.getSensorStatus(DeviceSensorCode.WATER_LOW_LEVEL)); |
|||
SolutionContainerState container_04 = solutionModuleState.getContainerStateByCode(ContainerCode.container_04); |
|||
container_04.setFull(this.getSensorStatus(DeviceSensorCode.WASTE_HIGH_LEVEL)); |
|||
|
|||
|
|||
} |
|||
|
|||
|
|||
} |
@ -0,0 +1,32 @@ |
|||
package com.iflytop.sgs.app.service.device; |
|||
|
|||
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.Service; |
|||
@Slf4j |
|||
@Service |
|||
@RequiredArgsConstructor |
|||
public class DeviceStopService { |
|||
private final DeviceCommandService deviceCommandService; |
|||
|
|||
|
|||
public void stopAll() { |
|||
//门电机 |
|||
DeviceCommandBundle doorStopDeviceCommandBundle = DeviceCommandGenerator.doorStop(); |
|||
deviceCommandService.sendCommand(null, null, doorStopDeviceCommandBundle); |
|||
//x轴 |
|||
DeviceCommandBundle xStopDeviceCommandBundle = DeviceCommandGenerator.transferXStop(); |
|||
deviceCommandService.sendCommand(null, null, xStopDeviceCommandBundle); |
|||
//z轴 |
|||
DeviceCommandBundle yStopDeviceCommandBundle = DeviceCommandGenerator.transferZStop(); |
|||
deviceCommandService.sendCommand(null, null, yStopDeviceCommandBundle); |
|||
//机械臂 |
|||
DeviceCommandBundle liquidMotorStopDeviceCommandBundle = DeviceCommandGenerator.liquidMotorStop(); |
|||
deviceCommandService.sendCommand(null, null, liquidMotorStopDeviceCommandBundle); |
|||
//蠕动泵 |
|||
DeviceCommandBundle liquidPumpStopDeviceCommandBundle = DeviceCommandGenerator.liquidPumpStop(); |
|||
deviceCommandService.sendCommand(null, null, liquidPumpStopDeviceCommandBundle); |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue