Browse Source

recode AppRetName

tags/v0
zhaohe 1 year ago
parent
commit
bf58591a9a
  1. 8
      src/main/java/a8k/appbean/ecode/AppRet.java
  2. 5
      src/main/java/a8k/controller/TmpTestController.java
  3. 32
      src/main/java/a8k/service/ctrl_service/DeviceInitializationCtrlService.java
  4. 14
      src/main/java/a8k/service/hardware/CommonHardwareOpeartion.java

8
src/main/java/a8k/appbean/ecode/AppEcode.java → src/main/java/a8k/appbean/ecode/AppRet.java

@ -5,24 +5,24 @@ import a8k.a8k_can_protocol.MId;
import a8k.a8k_can_protocol.A8kEcode;
import a8k.appbean.HardwareException;
public class AppEcode {
public class AppRet {
public A8kEcode errorCode;
public MId mid;
public CmdId cmd;
public AppEcode(A8kEcode errorCode, MId mid) {
public AppRet(A8kEcode errorCode, MId mid) {
this.errorCode = errorCode;
this.mid = mid;
this.cmd = CmdId.NotSet;
}
public AppEcode(A8kEcode errorCode) {
public AppRet(A8kEcode errorCode) {
this.errorCode = errorCode;
this.mid = MId.NotSet;
this.cmd = CmdId.NotSet;
}
public AppEcode(HardwareException e) {
public AppRet(HardwareException e) {
this.errorCode = e.getErrorCode();
this.mid = e.getModuleId();
}

5
src/main/java/a8k/controller/TmpTestController.java

@ -3,7 +3,7 @@ package a8k.controller;
import a8k.a8k_can_protocol.CmdId;
import a8k.a8k_can_protocol.MId;
import a8k.appbean.HardwareException;
import a8k.appbean.ecode.AppEcode;
import a8k.appbean.ecode.AppRet;
import a8k.base_hardware.A8kCanBusService;
import a8k.service.A8kDebugTaskExecutorService;
import a8k.service.ctrl_service.DeviceInitializationCtrlService;
@ -16,7 +16,6 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Map;
@ -64,7 +63,7 @@ public class TmpTestController {
@PostMapping("/api/zhaohe_test/initialize_device")
@ResponseBody
public AppEcode initialize_device() {
public AppRet initialize_device() {
return deviceInitializationCtrlService.initializeDevice();
// return "OK";
}

32
src/main/java/a8k/service/ctrl_service/DeviceInitializationCtrlService.java

@ -4,7 +4,7 @@ import a8k.a8k_can_protocol.A8kEcode;
import a8k.a8k_can_protocol.IOId;
import a8k.a8k_can_protocol.MId;
import a8k.appbean.HardwareException;
import a8k.appbean.ecode.AppEcode;
import a8k.appbean.ecode.AppRet;
import a8k.base_hardware.A8kCanBusService;
import a8k.service.db.dao.SamplesPreProcessModuleCtrlParamsService;
import a8k.service.hardware.CommonHardwareOpeartion;
@ -35,7 +35,7 @@ public class DeviceInitializationCtrlService {
@PostMapping("/api/DeviceInitializationCtrlService/initializeDevice")
@ResponseBody
public AppEcode initializeDevice() {
public AppRet initializeDevice() {
logger.info("Initializing device ...");
boolean initSuc = false;
try {
@ -47,7 +47,7 @@ public class DeviceInitializationCtrlService {
* 清空耗材
*/
AppEcode ecode;
AppRet ecode;
//硬件光电初始化
ecode = hardwareStaticInit();
if (!ecode.isOk()) {
@ -88,11 +88,11 @@ public class DeviceInitializationCtrlService {
}
}
return new AppEcode(A8kEcode.Success);
return new AppRet(A8kEcode.Success);
}
private AppEcode hardwareStaticInit() throws HardwareException, InterruptedException {
private AppRet hardwareStaticInit() throws HardwareException, InterruptedException {
/*
* 硬件初始化:
* 1.使能所有舵机
@ -109,49 +109,49 @@ public class DeviceInitializationCtrlService {
// 试管夹紧电机打开一点好方便有试管夹住的时突然断电时将试管取出
canBus.stepMotorEasyMoveBy(MId.ShakeModClampingM, 2);
canBus.waitForMod(MId.ShakeModClampingM, actionOvertime);
return new AppEcode(A8kEcode.Success);
return new AppRet(A8kEcode.Success);
}
private AppEcode checkDeviceState() throws HardwareException {
private AppRet checkDeviceState() throws HardwareException {
//试管平移通道是否有障碍
if (canBus.getIOState(IOId.THChInterPPS) || canBus.getIOState(IOId.THChOuterPPS)) {
logger.warn("THChInterPPS or THChOuterPPS is trigger");
return new AppEcode(A8kEcode.PlateStuckDetectorSensorTrigger);
return new AppRet(A8kEcode.PlateStuckDetectorSensorTrigger);
}
//板夹仓盖子是否盖上
if (!canBus.getIOState(IOId.PlateBoxCoverClosurePPS)) {
logger.warn("PlateBoxCoverClosure is open");
return new AppEcode(A8kEcode.PlateBoxNotCover);
return new AppRet(A8kEcode.PlateBoxNotCover);
}
//板夹仓卡板检测
if (canBus.getIOState(IOId.PlateBoxPlateStuckPPS)) {
logger.warn("PlateBoxPlateStuckPPS is trigger");
return new AppEcode(A8kEcode.PlateStuckDetectorSensorTrigger);
return new AppRet(A8kEcode.PlateStuckDetectorSensorTrigger);
}
//检查钩板电机是否处于终点位置
if (!canBus.getIOState(IOId.PullerMZeroPPS)) {
logger.warn("PullerM is not in zero pos");
return new AppEcode(A8kEcode.PullerMInitPosError);
return new AppRet(A8kEcode.PullerMInitPosError);
}
//检查板夹仓光电是否处于起点位置
if (!canBus.getIOState(IOId.PusherMZeroPPS)) {
logger.warn("PusherM is not in zero pos");
return new AppEcode(A8kEcode.PusherMInitPosError);
return new AppRet(A8kEcode.PusherMInitPosError);
}
//板夹仓光电
if (canBus.getIOState(IOId.RecycleBinOverflowPPS)) {
logger.warn("RecycleBinOverflow is trigger");
return new AppEcode(A8kEcode.RecycleBinOverflow);
return new AppRet(A8kEcode.RecycleBinOverflow);
}
return new AppEcode(A8kEcode.Success);
return new AppRet(A8kEcode.Success);
}
private AppEcode moveMotorToZero() throws HardwareException, InterruptedException {
private AppRet moveMotorToZero() throws HardwareException, InterruptedException {
//进出料初始化
// canBus.stepMotorEasyMoveToZero(MId.FeedingModInfeedM);
@ -204,7 +204,7 @@ public class DeviceInitializationCtrlService {
//canBus.waitForMod(MId.ShakeModGripperZM, actionOvertime);
return new AppEcode(A8kEcode.Success);
return new AppRet(A8kEcode.Success);
}

14
src/main/java/a8k/service/hardware/CommonHardwareOpeartion.java

@ -3,7 +3,7 @@ package a8k.service.hardware;
import a8k.a8k_can_protocol.A8kEcode;
import a8k.a8k_can_protocol.MId;
import a8k.appbean.HardwareException;
import a8k.appbean.ecode.AppEcode;
import a8k.appbean.ecode.AppRet;
import a8k.base_hardware.A8kCanBusService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Controller;
@ -19,24 +19,24 @@ public class CommonHardwareOpeartion {
@PostMapping("/api/CommonHardwareOpeartion/enableAllMotorNoExcep")
@ResponseBody
public AppEcode enableAllMotorNoExcep() {
public AppRet enableAllMotorNoExcep() {
try {
enableAllMotor();
} catch (HardwareException e) {
return new AppEcode(e);
return new AppRet(e);
}
return new AppEcode(A8kEcode.Success);
return new AppRet(A8kEcode.Success);
}
@PostMapping("/api/CommonHardwareOpeartion/disableAllMotorNoExcep")
@ResponseBody
public AppEcode disableAllMotorNoExcep() {
public AppRet disableAllMotorNoExcep() {
try {
enableAllMotor();
} catch (HardwareException e) {
return new AppEcode(e);
return new AppRet(e);
}
return new AppEcode(A8kEcode.Success);
return new AppRet(A8kEcode.Success);
}
public void enableAllMotor(Boolean enable) throws HardwareException {

Loading…
Cancel
Save