11 changed files with 389 additions and 3 deletions
-
33src/main/java/com/iflytop/gd/app/cmd/CapLiftingOriginCommand.java
-
43src/main/java/com/iflytop/gd/app/cmd/DualRobotJointOriginCommand.java
-
54src/main/java/com/iflytop/gd/app/cmd/GantryXOriginCommand.java
-
43src/main/java/com/iflytop/gd/app/cmd/TrayLiftingOriginCommand.java
-
37src/main/java/com/iflytop/gd/app/controller/SelfTestController.java
-
3src/main/java/com/iflytop/gd/app/core/device/DeviceState.java
-
49src/main/java/com/iflytop/gd/app/core/device/SelfTestState.java
-
6src/main/java/com/iflytop/gd/app/core/listener/DeviceStateListener.java
-
98src/main/java/com/iflytop/gd/app/service/DeviceCommandUtilService.java
-
10src/main/java/com/iflytop/gd/app/service/DeviceStateService.java
-
16src/main/java/com/iflytop/gd/app/service/SelfTestService.java
@ -0,0 +1,33 @@ |
|||
package com.iflytop.gd.app.cmd; |
|||
|
|||
import com.iflytop.gd.app.core.BaseCommandHandler; |
|||
import com.iflytop.gd.app.model.dto.CmdDTO; |
|||
import com.iflytop.gd.app.service.DeviceCommandUtilService; |
|||
import com.iflytop.gd.app.service.SelfTestService; |
|||
import com.iflytop.gd.common.annotation.CommandMapping; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.concurrent.CompletableFuture; |
|||
|
|||
/** |
|||
* 拍子升降回原点 |
|||
*/ |
|||
@Slf4j |
|||
@Component |
|||
@RequiredArgsConstructor |
|||
@CommandMapping("cap_lifting_origin")//业务指令注解 |
|||
public class CapLiftingOriginCommand extends BaseCommandHandler { |
|||
private final DeviceCommandUtilService deviceCommandUtilService; |
|||
private final SelfTestService selfTestService; |
|||
|
|||
@Override |
|||
public CompletableFuture<Void> handle(CmdDTO cmdDTO) { |
|||
return runAsync(() -> { |
|||
deviceCommandUtilService.trayMotorOrigin(cmdDTO.getCommandId(), cmdDTO.getCommand()); |
|||
selfTestService.getSelfTestState().setCapLiftingOrigin(true); |
|||
}); |
|||
} |
|||
} |
|||
|
@ -0,0 +1,43 @@ |
|||
package com.iflytop.gd.app.cmd; |
|||
|
|||
import com.iflytop.gd.app.core.BaseCommandHandler; |
|||
import com.iflytop.gd.app.model.dto.CmdDTO; |
|||
import com.iflytop.gd.app.service.DeviceCommandUtilService; |
|||
import com.iflytop.gd.app.service.SelfTestService; |
|||
import com.iflytop.gd.common.annotation.CommandMapping; |
|||
import com.iflytop.gd.common.enums.cmd.CmdAxis; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.concurrent.CompletableFuture; |
|||
|
|||
/** |
|||
* 指定加液机械臂回原点 |
|||
*/ |
|||
@Slf4j |
|||
@Component |
|||
@RequiredArgsConstructor |
|||
@CommandMapping("dual_robot_joint_origin")//业务指令注解 |
|||
public class DualRobotJointOriginCommand extends BaseCommandHandler { |
|||
private final DeviceCommandUtilService deviceCommandUtilService; |
|||
private final SelfTestService selfTestService; |
|||
|
|||
@Override |
|||
public CompletableFuture<Void> handle(CmdDTO cmdDTO) { |
|||
Boolean joint1 = cmdDTO.getBooleanParam("joint1"); |
|||
Boolean joint2 = cmdDTO.getBooleanParam("joint1"); |
|||
return runAsync(() -> { |
|||
|
|||
if(joint1){ |
|||
deviceCommandUtilService.dualRobotOrigin(cmdDTO.getCommandId(), cmdDTO.getCommand(), CmdAxis.joint1); |
|||
selfTestService.getSelfTestState().setDualRobotJoint1Origin(true); |
|||
} |
|||
if(joint2){ |
|||
deviceCommandUtilService.dualRobotOrigin(cmdDTO.getCommandId(), cmdDTO.getCommand(), CmdAxis.joint2); |
|||
selfTestService.getSelfTestState().setDualRobotJoint2Origin(true); |
|||
} |
|||
}); |
|||
} |
|||
} |
|||
|
@ -0,0 +1,54 @@ |
|||
package com.iflytop.gd.app.cmd; |
|||
|
|||
import com.iflytop.gd.app.core.BaseCommandHandler; |
|||
import com.iflytop.gd.app.model.dto.CmdDTO; |
|||
import com.iflytop.gd.app.service.DeviceCommandUtilService; |
|||
import com.iflytop.gd.app.service.DevicePositionService; |
|||
import com.iflytop.gd.app.service.SelfTestService; |
|||
import com.iflytop.gd.common.annotation.CommandMapping; |
|||
import com.iflytop.gd.common.cmd.CommandFuture; |
|||
import com.iflytop.gd.common.cmd.DeviceCommandBundle; |
|||
import com.iflytop.gd.common.cmd.DeviceCommandGenerator; |
|||
import com.iflytop.gd.common.enums.data.DevicePositionCode; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
import java.util.concurrent.CompletableFuture; |
|||
|
|||
/** |
|||
* 龙门架机械臂指定轴回原点 |
|||
*/ |
|||
@Slf4j |
|||
@Component |
|||
@RequiredArgsConstructor |
|||
@CommandMapping("gantry_origin")//业务指令注解 |
|||
public class GantryXOriginCommand extends BaseCommandHandler { |
|||
private final DeviceCommandUtilService deviceCommandUtilService; |
|||
private final SelfTestService selfTestService; |
|||
|
|||
@Override |
|||
public CompletableFuture<Void> handle(CmdDTO cmdDTO) { |
|||
return runAsync(() -> { |
|||
Boolean x = cmdDTO.getBooleanParam("x"); |
|||
Boolean y = cmdDTO.getBooleanParam("y"); |
|||
Boolean z = cmdDTO.getBooleanParam("z"); |
|||
if (x) { |
|||
deviceCommandUtilService.gantryXMoveOrigin(cmdDTO.getCommandId(), cmdDTO.getCommand()); |
|||
selfTestService.getSelfTestState().setGantryXOrigin(true); |
|||
} |
|||
if (y) { |
|||
deviceCommandUtilService.gantryYMoveOrigin(cmdDTO.getCommandId(), cmdDTO.getCommand()); |
|||
selfTestService.getSelfTestState().setGantryYOrigin(true); |
|||
} |
|||
|
|||
if (z) { |
|||
deviceCommandUtilService.gantryZMoveOrigin(cmdDTO.getCommandId(), cmdDTO.getCommand()); |
|||
selfTestService.getSelfTestState().setGantryZOrigin(true); |
|||
} |
|||
}); |
|||
} |
|||
} |
|||
|
@ -0,0 +1,43 @@ |
|||
package com.iflytop.gd.app.cmd; |
|||
|
|||
import com.iflytop.gd.app.core.BaseCommandHandler; |
|||
import com.iflytop.gd.app.model.dto.CmdDTO; |
|||
import com.iflytop.gd.app.service.DeviceCommandUtilService; |
|||
import com.iflytop.gd.app.service.SelfTestService; |
|||
import com.iflytop.gd.common.annotation.CommandMapping; |
|||
import com.iflytop.gd.common.enums.HeatModuleCode; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.concurrent.CompletableFuture; |
|||
|
|||
/** |
|||
* 托盘升降回原点 |
|||
*/ |
|||
@Slf4j |
|||
@Component |
|||
@RequiredArgsConstructor |
|||
@CommandMapping("tray_lifting_origin")//业务指令注解 |
|||
public class TrayLiftingOriginCommand extends BaseCommandHandler { |
|||
private final DeviceCommandUtilService deviceCommandUtilService; |
|||
private final SelfTestService selfTestService; |
|||
|
|||
@Override |
|||
public CompletableFuture<Void> handle(CmdDTO cmdDTO) { |
|||
String heatId = cmdDTO.getStringParam("heatId"); |
|||
HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId); |
|||
return runAsync(() -> { |
|||
deviceCommandUtilService.heaterMotorMoveOrigin(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleId); |
|||
switch (heatModuleId) { |
|||
case heat_module_01 -> selfTestService.getSelfTestState().setTrayLifting01Origin(true); |
|||
case heat_module_02 -> selfTestService.getSelfTestState().setTrayLifting02Origin(true); |
|||
case heat_module_03 -> selfTestService.getSelfTestState().setTrayLifting03Origin(true); |
|||
case heat_module_04 -> selfTestService.getSelfTestState().setTrayLifting04Origin(true); |
|||
case heat_module_05 -> selfTestService.getSelfTestState().setTrayLifting05Origin(true); |
|||
case heat_module_06 -> selfTestService.getSelfTestState().setTrayLifting06Origin(true); |
|||
} |
|||
}); |
|||
} |
|||
} |
|||
|
@ -0,0 +1,37 @@ |
|||
package com.iflytop.gd.app.controller; |
|||
|
|||
import com.iflytop.gd.app.core.device.SelfTestState; |
|||
import com.iflytop.gd.app.service.DeviceStateService; |
|||
import com.iflytop.gd.app.service.SelfTestService; |
|||
import com.iflytop.gd.common.result.Result; |
|||
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.GetMapping; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
@Tag(name = "自检") |
|||
@RestController |
|||
@RequestMapping("/api/self-test") |
|||
@RequiredArgsConstructor |
|||
@Slf4j |
|||
public class SelfTestController { |
|||
private final SelfTestService selfTestService; |
|||
private final DeviceStateService deviceStateService; |
|||
|
|||
@Operation(summary = "获取自检状态") |
|||
@GetMapping("/status") |
|||
public Result<SelfTestState> getSelfTestStatus() { |
|||
return Result.success(selfTestService.getSelfTestState()); |
|||
} |
|||
|
|||
@Operation(summary = "自检完毕") |
|||
@PostMapping("/finish") |
|||
public Result<?> selfTestFinish() { |
|||
deviceStateService.setSelfTest(true); |
|||
return Result.success(); |
|||
} |
|||
} |
@ -0,0 +1,49 @@ |
|||
package com.iflytop.gd.app.core.device; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
@Schema(description = "自检状态") |
|||
@Data |
|||
public class SelfTestState { |
|||
@Schema(description = "龙门架机械臂x轴是否在原点") |
|||
private boolean gantryXOrigin = false; |
|||
|
|||
@Schema(description = "龙门架机械臂y轴是否在原点") |
|||
private boolean gantryYOrigin = false; |
|||
|
|||
@Schema(description = "龙门架机械臂z轴是否在原点") |
|||
private boolean gantryZOrigin = false; |
|||
|
|||
@Schema(description = "龙门架机械臂夹爪是否在原点") |
|||
private boolean clawOrigin = false; |
|||
|
|||
@Schema(description = "加液机械臂01是否在原点") |
|||
private boolean dualRobotJoint1Origin = false; |
|||
|
|||
@Schema(description = "加液机械臂02是否在原点") |
|||
private boolean dualRobotJoint2Origin = false; |
|||
|
|||
@Schema(description = "拍子升降是否在原点") |
|||
private boolean capLiftingOrigin = false; |
|||
|
|||
@Schema(description = "加热模块01托盘升降是否在原点") |
|||
private boolean trayLifting01Origin = false; |
|||
|
|||
@Schema(description = "加热模块02托盘升降是否在原点") |
|||
private boolean trayLifting02Origin = false; |
|||
|
|||
@Schema(description = "加热模块03托盘升降是否在原点") |
|||
private boolean trayLifting03Origin = false; |
|||
|
|||
@Schema(description = "加热模块04托盘升降是否在原点") |
|||
private boolean trayLifting04Origin = false; |
|||
|
|||
@Schema(description = "加热模块05托盘升降是否在原点") |
|||
private boolean trayLifting05Origin = false; |
|||
|
|||
@Schema(description = "加热模块06托盘升降是否在原点") |
|||
private boolean trayLifting06Origin = false; |
|||
|
|||
|
|||
} |
@ -0,0 +1,16 @@ |
|||
package com.iflytop.gd.app.service; |
|||
|
|||
import com.iflytop.gd.app.core.device.SelfTestState; |
|||
import lombok.Getter; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Slf4j |
|||
@Service |
|||
@RequiredArgsConstructor |
|||
public class SelfTestService { |
|||
@Getter |
|||
private final SelfTestState selfTestState = new SelfTestState(); |
|||
|
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue