|
|
@ -21,86 +21,111 @@ import org.springframework.web.bind.annotation.*; |
|
|
|
@HardwareServiceParams(service = SamplesPreProcessModuleCtrlService.class) |
|
|
|
public class SamplesPreProcessModuleCtrlService implements HardwareCtrlModule { |
|
|
|
static Logger logger = LoggerFactory.getLogger(SamplesPreProcessModuleCtrlService.class); |
|
|
|
HardwareParamReader hpReader = new HardwareParamReader(SamplesPreProcessModuleCtrlService.class); |
|
|
|
|
|
|
|
@Resource |
|
|
|
private A8kCanBusService canBus; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private CommonHardwareOpeartion comHardwareOpear; |
|
|
|
@Autowired |
|
|
|
private CommonHardwareOpeartion commonHardwareOpeartion; |
|
|
|
|
|
|
|
final private int actionDelayTime = 0; |
|
|
|
final private Boolean debug = true; |
|
|
|
final private Boolean debug = false; |
|
|
|
|
|
|
|
// |
|
|
|
// 参数 |
|
|
|
// |
|
|
|
Boolean IntEq(Integer pos1, Integer pos2, Integer diff) { |
|
|
|
return Math.abs(pos1 - pos2) < diff; |
|
|
|
} |
|
|
|
|
|
|
|
void actionDelay() throws InterruptedException { |
|
|
|
if (actionDelayTime != 0) |
|
|
|
Thread.sleep(actionDelayTime); |
|
|
|
} |
|
|
|
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
|
|
* 参数 |
|
|
|
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "动作超时时间", group = "基础参数") |
|
|
|
public Integer getActionOvertime() { |
|
|
|
return 5000; |
|
|
|
return hpReader.getInteger("ActionOvertime", 5000); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "试管帽有无判断时间", group = "基础参数") |
|
|
|
public Integer getCapJudgeDelayTime() { |
|
|
|
return hpReader.getInteger("CapJudgeDelayTime", 300); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "抓手张开位置", group = "抓手") |
|
|
|
public Integer getGripperOpenPos() { |
|
|
|
return 150; |
|
|
|
return hpReader.getInteger("GripperOpenPos", 150); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "抓手闭合位置", group = "抓手") |
|
|
|
public Integer getGripperClosePos() { |
|
|
|
return 10; |
|
|
|
return hpReader.getInteger("GripperClosePos", 10); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "抓手取试管位置", group = "抓手") |
|
|
|
public Integer getGripperTakeCapPos() { |
|
|
|
return 55;// |
|
|
|
return hpReader.getInteger("GripperTakeCapPos", 55); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "取试管位置", group = "Y轴位置") |
|
|
|
public Integer getGripperTakeTubeYPos() { |
|
|
|
return 2735; |
|
|
|
return hpReader.getInteger("GripperTakeTubeYPos", 2750); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "摇匀位置", group = "Y轴位置") |
|
|
|
public Integer getGripperShakeYPos() { |
|
|
|
return 1828; |
|
|
|
return hpReader.getInteger("GripperShakeYPos", 1828); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "待机位", group = "Y轴位置") |
|
|
|
public Integer getGripperZeroYPos() { |
|
|
|
return 10; |
|
|
|
return hpReader.getInteger("GripperZeroYPos", 10); |
|
|
|
} |
|
|
|
|
|
|
|
// TakeTubeZ |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "取高试管位置", group = "Z轴位置") |
|
|
|
public Integer getGripperTakeHTubeZPos() { |
|
|
|
return 739; |
|
|
|
return hpReader.getInteger("GripperTakeHTubeZPos", 739); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "取低试管位置", group = "Z轴位置") |
|
|
|
public Integer getGripperTakeSTubeZPos() { |
|
|
|
return 985; |
|
|
|
return hpReader.getInteger("GripperTakeSTubeZPos", 985); |
|
|
|
} |
|
|
|
|
|
|
|
//JudgeTubeCapZ |
|
|
|
@HardwareServiceParam(name = "高试管帽有无判断位", group = "Z轴位置") |
|
|
|
public Integer getGripperJudgeHTubeCapZPos() { |
|
|
|
return 591; |
|
|
|
return hpReader.getInteger("GripperJudgeHTubeCapZPos", 591); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "低试管帽有无判断位", group = "Z轴位置") |
|
|
|
public Integer getGripperJudgeSTubeCapZPos() { |
|
|
|
return 867; |
|
|
|
return hpReader.getInteger("GripperJudgeSTubeCapZPos", 867); |
|
|
|
} |
|
|
|
|
|
|
|
//ShakeTubeZ |
|
|
|
@HardwareServiceParam(name = "摇匀放置位置", group = "Z轴位置") |
|
|
|
public Integer getGripperShakeTubeZPos() { |
|
|
|
return 835; |
|
|
|
return hpReader.getInteger("GripperShakeTubeZPos", 835); |
|
|
|
} |
|
|
|
|
|
|
|
//TakeCapZ |
|
|
|
@HardwareServiceParam(name = "取试管帽位", group = "Z轴位置") |
|
|
|
public Integer getGripperTakeCapZPos() { |
|
|
|
return 835; |
|
|
|
return hpReader.getInteger("GripperTakeCapZPos", 835); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "试管夹紧位", group = "试管夹紧模块") |
|
|
|
public Integer getShakeClampingPos() { |
|
|
|
return 10; |
|
|
|
return hpReader.getInteger("ShakeClampingPos", 10); |
|
|
|
} |
|
|
|
|
|
|
|
// |
|
|
|
@HardwareServiceParam(name = "摇匀臂", group = "试管摇匀待机位") |
|
|
|
public Integer getShakeModShakeMStandbyPos() { |
|
|
|
return 90; |
|
|
|
return hpReader.getInteger("ShakeModShakeMStandbyPos", 90); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -122,11 +147,13 @@ public class SamplesPreProcessModuleCtrlService implements HardwareCtrlModule { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceAction(name = "模组停止") |
|
|
|
@Override |
|
|
|
public void modGroupStop() throws HardwareException { |
|
|
|
comHardwareOpear.forceStopAllMOtor(); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceAction(name = "模组归零") |
|
|
|
@Override |
|
|
|
public void modGroupMoveToZero() throws HardwareException, InterruptedException { |
|
|
|
// if (!canBus.stepMotorReadIoState(MId.ShakeModGripperZM, 0)) { |
|
|
@ -152,6 +179,7 @@ public class SamplesPreProcessModuleCtrlService implements HardwareCtrlModule { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@HardwareServiceAction(name = "模组快速归零") |
|
|
|
@Override |
|
|
|
public void modGroupMoveToZeroQuick() throws HardwareException, InterruptedException { |
|
|
|
/* |
|
|
@ -172,23 +200,13 @@ public class SamplesPreProcessModuleCtrlService implements HardwareCtrlModule { |
|
|
|
modGroupMoveToZero(); |
|
|
|
} |
|
|
|
|
|
|
|
Boolean IntEq(Integer pos1, Integer pos2, Integer diff) { |
|
|
|
return Math.abs(pos1 - pos2) < diff; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void actionDelay() throws InterruptedException { |
|
|
|
if (actionDelayTime != 0) |
|
|
|
Thread.sleep(actionDelayTime); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 取试管帽,如果试管帽存在, |
|
|
|
* @param tubeType HighBlood,ShortBlood,Mini,MiniBlood,BulletTube1P5,BulletTube0P5 |
|
|
|
* @param actionDealyTime 为true时,为不带试管测试,且步骤之间有1s的动作延迟 |
|
|
|
*/ |
|
|
|
public AppRet<Boolean> takeTubeAndJudgeTubeExist(@RequestParam String tubeType) throws HardwareException, InterruptedException { |
|
|
|
@HardwareServiceAction(name = "取试管") |
|
|
|
public AppRet<Boolean> takeTubeAndJudgeTubeExist(A8kTubeType tubeType) throws HardwareException, InterruptedException { |
|
|
|
logger.info("takeTube tubeType:{}", tubeType); |
|
|
|
|
|
|
|
/* |
|
|
@ -196,6 +214,10 @@ public class SamplesPreProcessModuleCtrlService implements HardwareCtrlModule { |
|
|
|
* 1.当前摇匀模组设计到的电机是否都处于待机位 |
|
|
|
*/ |
|
|
|
|
|
|
|
if (tubeType != A8kTubeType.HighBlood && tubeType != A8kTubeType.ShortBlood) { |
|
|
|
return AppRet.fail(A8kEcode.TubeTypeNotSupport); |
|
|
|
} |
|
|
|
|
|
|
|
//Z轴在原点 |
|
|
|
if (!canBus.stepMotorReadIoState(MId.ShakeModGripperZM, 0)) { |
|
|
|
throw new HardwareException(MId.ShakeModGripperZM, A8kEcode.MNotInZeroPos); |
|
|
@ -216,7 +238,7 @@ public class SamplesPreProcessModuleCtrlService implements HardwareCtrlModule { |
|
|
|
throw new HardwareException(MId.ShakeModClampingM, A8kEcode.MNotInZeroPos); |
|
|
|
} |
|
|
|
|
|
|
|
boolean isHighBlood = A8kTubeType.HighBlood.equals(A8kTubeType.valueOf(tubeType)); |
|
|
|
boolean isHighBlood = A8kTubeType.HighBlood.equals(tubeType); |
|
|
|
boolean tubeCapExist = true; |
|
|
|
Integer gripperJudgeCapZPos = isHighBlood ? getGripperJudgeHTubeCapZPos() : getGripperJudgeSTubeCapZPos(); |
|
|
|
Integer gripperTakeTubeZPos = isHighBlood ? getGripperTakeHTubeZPos() : getGripperTakeSTubeZPos(); |
|
|
@ -263,7 +285,7 @@ public class SamplesPreProcessModuleCtrlService implements HardwareCtrlModule { |
|
|
|
//闭合夹爪检测试管帽是否存在 |
|
|
|
logger.info("闭合夹爪检测试管帽是否存在"); |
|
|
|
canBus.miniServoRotateWithTorque(MId.ShakeModGripperSV, -400); |
|
|
|
Thread.sleep(1000); |
|
|
|
Thread.sleep(getCapJudgeDelayTime()); |
|
|
|
if (IntEq(canBus.miniServoReadPos(MId.ShakeModGripperSV), getGripperClosePos(), 30)) { |
|
|
|
logger.info("试管帽不存在"); |
|
|
|
tubeCapExist = false; |
|
|
@ -351,7 +373,8 @@ public class SamplesPreProcessModuleCtrlService implements HardwareCtrlModule { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void shakeTube(@RequestParam Integer shakeDegree, @RequestParam Integer times) throws HardwareException, InterruptedException { |
|
|
|
@HardwareServiceAction(name = "摇匀") |
|
|
|
public void shakeTube(Integer shakeDegree, Integer times) throws HardwareException, InterruptedException { |
|
|
|
var standByPos = getShakeModShakeMStandbyPos(); |
|
|
|
var startPos = standByPos - shakeDegree; |
|
|
|
var endPos = standByPos + shakeDegree; |
|
|
@ -359,6 +382,7 @@ public class SamplesPreProcessModuleCtrlService implements HardwareCtrlModule { |
|
|
|
canBus.waitForMod(MId.ShakeModShakeM, getActionOvertime()); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceAction(name = "取试管帽") |
|
|
|
public void takeTubeCap() throws HardwareException, InterruptedException { |
|
|
|
//Y移动到取试管帽位置 |
|
|
|
logger.info("Y移动到取试管帽位置 && 打开夹爪"); |
|
|
@ -389,11 +413,11 @@ public class SamplesPreProcessModuleCtrlService implements HardwareCtrlModule { |
|
|
|
canBus.waitForMods(new MId[]{MId.ShakeModGripperYSV}, getActionOvertime()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 盖试管帽,并将试管移动回试管架中 |
|
|
|
*/ |
|
|
|
public void pushBackTubeCapAndTakeBakTube(String tubeType) throws HardwareException, InterruptedException { |
|
|
|
@HardwareServiceAction(name = "盖试管帽并放回试管架") |
|
|
|
public void pushBackTubeCapAndTakeBakTube(A8kTubeType tubeType) throws HardwareException, InterruptedException { |
|
|
|
//移动Y轴到取试管帽位置 |
|
|
|
logger.info("移动Y轴到取试管帽位置"); |
|
|
|
canBus.miniServoMoveTo(MId.ShakeModGripperYSV, getGripperShakeYPos()); |
|
|
@ -444,29 +468,15 @@ public class SamplesPreProcessModuleCtrlService implements HardwareCtrlModule { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 打开气溶胶风扇 |
|
|
|
*/ |
|
|
|
public void openAerosolFan() throws HardwareException { |
|
|
|
// var params = this.paramDao; |
|
|
|
// this.canBus.callcmd(MId.WbTubeFanMod.toInt(), CmdId.fan_controler_set_speed.toInt(), params.getAerosolFanLevel()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 关闭气溶胶风扇 |
|
|
|
* 气溶胶风扇控制 |
|
|
|
*/ |
|
|
|
public void closeAerosolFan() throws HardwareException { |
|
|
|
// this.canBus.callcmd(MId.WbTubeFanMod.toInt(), CmdId.fan_controler_set_speed.toInt(), 0); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceStatus(name = "A") |
|
|
|
public Integer getAerosolFanLevel() { |
|
|
|
return 123; |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceStatus(name = "B") |
|
|
|
public Boolean getBool() { |
|
|
|
return true; |
|
|
|
@HardwareServiceAction(name = "气溶胶风扇控制") |
|
|
|
public void setAeroslFanPower(Boolean enable) throws HardwareException, InterruptedException { |
|
|
|
if (enable) { |
|
|
|
canBus.fanControlerSetSpeed(MId.WbTubeFanMod, 99); |
|
|
|
} else { |
|
|
|
canBus.fanControlerSetSpeed(MId.WbTubeFanMod, 0); |
|
|
|
} |
|
|
|
} |
|
|
|
} |