|
|
@ -1,9 +1,9 @@ |
|
|
|
package a8k.service.hardware; |
|
|
|
|
|
|
|
import a8k.appbean.*; |
|
|
|
import a8k.canbus.protocol.A8kEcode; |
|
|
|
import a8k.canbus.protocol.IOId; |
|
|
|
import a8k.canbus.protocol.MId; |
|
|
|
import a8k.appbean.HardwareException; |
|
|
|
import a8k.appbean.ecode.AppRet; |
|
|
|
import a8k.canbus.A8kCanBusService; |
|
|
|
import a8k.utils.*; |
|
|
@ -12,6 +12,8 @@ import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
@Component |
|
|
|
@HardwareService(name = "反应板条搬移服务") |
|
|
@ -26,7 +28,7 @@ public class ReactionPlatesTransmitCtrlService implements HardwareCtrlModule { |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "动作超时时间", group = "基础参数") |
|
|
|
public Integer getActionOvertime() { |
|
|
|
return hpReader.getInteger("actionOvertime", 5000); |
|
|
|
return hpReader.getInteger("actionOvertime", 10000); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "板夹仓通道0位置", group = "板夹仓参数") |
|
|
@ -55,17 +57,17 @@ public class ReactionPlatesTransmitCtrlService implements HardwareCtrlModule { |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "仓位0入板位置", group = "转盘参数") |
|
|
|
public Integer getTurntablePushPos0() { |
|
|
|
return hpReader.getInteger("TurntablePushPos0", 0); |
|
|
|
return hpReader.getInteger("TurntablePushPos0", 1650); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "仓位0出板位置", group = "转盘参数") |
|
|
|
public Integer getTurntablePullPos0() { |
|
|
|
return hpReader.getInteger("TurntablePullPos0", 0); |
|
|
|
return hpReader.getInteger("TurntablePullPos0", 1650 + 18000); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "仓位0点滴位", group = "转盘参数") |
|
|
|
public Integer getTurntableDropLiquidPos0() { |
|
|
|
return hpReader.getInteger("TurntableDropLiquidPos0", 0); |
|
|
|
return hpReader.getInteger("TurntableDropLiquidPos0", 1650 + 8950); |
|
|
|
} |
|
|
|
|
|
|
|
public Integer getTurntablePosSpacing() { |
|
|
@ -77,17 +79,17 @@ public class ReactionPlatesTransmitCtrlService implements HardwareCtrlModule { |
|
|
|
*/ |
|
|
|
@HardwareServiceParam(name = "拉板目标位置", group = "光学模组参数") |
|
|
|
public Integer getPullerTargetPos() { |
|
|
|
return hpReader.getInteger("PullerTargetPos", 0); |
|
|
|
return hpReader.getInteger("PullerTargetPos", 1147); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "丢板坐标", group = "光学模组参数") |
|
|
|
public Integer getPlateDropPos() { |
|
|
|
return hpReader.getInteger("PlateDropPos", 0); |
|
|
|
return hpReader.getInteger("PlateDropPos", -349); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "扫描待机位", group = "光学模组参数") |
|
|
|
public Integer getOptScanScandbyPos() { |
|
|
|
return hpReader.getInteger("OptScanScandbyPos", 0); |
|
|
|
return hpReader.getInteger("OptScanScandbyPos", 580); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -122,11 +124,6 @@ public class ReactionPlatesTransmitCtrlService implements HardwareCtrlModule { |
|
|
|
=======================================================================================*/ |
|
|
|
|
|
|
|
private void checkBeforeMoveTrunable() throws HardwareException { |
|
|
|
//试管平移通道是否有障碍 |
|
|
|
if (canBus.getIOState(IOId.THChInterPPS) || canBus.getIOState(IOId.THChOuterPPS)) { |
|
|
|
logger.error("THChInterPPS or THChOuterPPS is trigger"); |
|
|
|
throw new HardwareException(A8kEcode.TubeXChannelIsNotEmpty); |
|
|
|
} |
|
|
|
//板夹仓卡板检测 |
|
|
|
if (canBus.getIOState(IOId.PlateBoxPlateStuckPPS)) { |
|
|
|
logger.error("PlateBoxPlateStuckPPS is trigger"); |
|
|
@ -146,6 +143,14 @@ public class ReactionPlatesTransmitCtrlService implements HardwareCtrlModule { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void checkBeforeMovePlateBox() throws HardwareException { |
|
|
|
if (!canBus.getIOState(IOId.PusherMZeroPPS)) { |
|
|
|
logger.error("PusherM is not in zero pos "); |
|
|
|
throw new HardwareException(A8kEcode.PusherMInitPosError); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* ======================================================================================= |
|
|
|
基础操作 |
|
|
|
=======================================================================================*/ |
|
|
@ -174,42 +179,45 @@ public class ReactionPlatesTransmitCtrlService implements HardwareCtrlModule { |
|
|
|
@HardwareServiceAction(name = "电机归零", group = "基础操作") |
|
|
|
@Override |
|
|
|
public void modGroupMoveToZero() throws HardwareException, InterruptedException { |
|
|
|
checkBeforeMoveTrunable(); |
|
|
|
//光学模组初始化 |
|
|
|
canBus.stepMotorEasyMoveToZeroBlock(MId.OptModPullM, getActionOvertime()); |
|
|
|
canBus.stepMotorEasyMoveToZeroBlock(MId.OptModScannerM, getActionOvertime()); |
|
|
|
|
|
|
|
//板夹仓初始化 |
|
|
|
checkBeforeMovePlateBox(); |
|
|
|
canBus.stepMotorEasyMoveToZeroBlock(MId.PlatesBoxPusherM, getActionOvertime()); |
|
|
|
canBus.stepMotorEasyMoveToZeroBlock(MId.PlatesBoxYM, getActionOvertime()); |
|
|
|
//光学模组初始化 |
|
|
|
canBus.stepMotorEasyMoveToZeroBlock(MId.OptModPullM, getActionOvertime()); |
|
|
|
canBus.stepMotorEasyMoveToZeroBlock(MId.OptModScannerM, getActionOvertime()); |
|
|
|
|
|
|
|
//转盘归零 |
|
|
|
checkBeforeMoveTrunable(); |
|
|
|
canBus.stepMotorEasyMoveToZeroBlock(MId.IncubatorRotateCtrlM, getActionOvertime()); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceAction(name = "电机快速归零", group = "基础操作") |
|
|
|
@Override |
|
|
|
public void modGroupMoveToZeroQuick() throws HardwareException, InterruptedException { |
|
|
|
//试管平移通道是否有障碍 |
|
|
|
checkBeforeMoveTrunable(); |
|
|
|
//光学模组初始化 |
|
|
|
canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.OptModPullM, getActionOvertime()); |
|
|
|
canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.OptModScannerM, getActionOvertime()); |
|
|
|
|
|
|
|
//板夹仓初始化 |
|
|
|
checkBeforeMovePlateBox(); |
|
|
|
canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.PlatesBoxPusherM, getActionOvertime()); |
|
|
|
canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.PlatesBoxYM, getActionOvertime()); |
|
|
|
//光学模组初始化 |
|
|
|
canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.OptModPullM, getActionOvertime()); |
|
|
|
canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.OptModScannerM, getActionOvertime()); |
|
|
|
|
|
|
|
//转盘归零 |
|
|
|
checkBeforeMoveTrunable(); |
|
|
|
canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.IncubatorRotateCtrlM, getActionOvertime()); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceAction(name = "转盘移动到推板位", group = "基础操作") |
|
|
|
@HardwareServiceAction(name = "转盘移动到推板位", group = "单步操作") |
|
|
|
public void trunableMoveToPushPos(Integer index) throws HardwareException, InterruptedException { |
|
|
|
checkBeforeMoveTrunable(); |
|
|
|
canBus.stepMotorEasyMoveToBlock(MId.IncubatorRotateCtrlM,// |
|
|
|
getTurntablePushPos0() + index * getTurntablePosSpacing(), getActionOvertime()); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceAction(name = "转盘移动到出板位", group = "基础操作") |
|
|
|
@HardwareServiceAction(name = "转盘移动到出板位", group = "单步操作") |
|
|
|
public void trunableMoveToPullPos(Integer index) throws HardwareException, InterruptedException { |
|
|
|
checkBeforeMoveTrunable(); |
|
|
|
canBus.stepMotorEasyMoveToBlock(MId.IncubatorRotateCtrlM,// |
|
|
@ -217,148 +225,74 @@ public class ReactionPlatesTransmitCtrlService implements HardwareCtrlModule { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceAction(name = "转盘移动到滴定位", group = "基础操作") |
|
|
|
@HardwareServiceAction(name = "转盘移动到滴定位", group = "单步操作") |
|
|
|
public void trunableMoveToDropLiquidPos(Integer index) throws HardwareException, InterruptedException { |
|
|
|
checkBeforeMoveTrunable(); |
|
|
|
canBus.stepMotorEasyMoveToBlock(MId.IncubatorRotateCtrlM,// |
|
|
|
getTurntableDropLiquidPos0() + index * getTurntablePosSpacing(), getActionOvertime()); |
|
|
|
} |
|
|
|
|
|
|
|
/* ======================================================================================= |
|
|
|
板夹仓操作 |
|
|
|
=======================================================================================*/ |
|
|
|
void pushReactionPlate(int plateBoxChannelNum, int turntablePosIndex) { |
|
|
|
/* |
|
|
|
1. 控制转盘移动到第turntablePosIndex个位置 |
|
|
|
2. 控制板夹仓平移到第boxChannelNum个仓位 |
|
|
|
3. 推出板 |
|
|
|
3.1 板推出后检查推板电机终点电机是否触发,如果没有触发,则说明卡板,上报硬件异常 |
|
|
|
4. 板夹推杆回到零点,并执行一次归零动作。 |
|
|
|
5. 板夹仓平移电机,移动零点,并执行一次归零动作,归零后向后相对移动1mm,保证零点触发。 |
|
|
|
|
|
|
|
推板 使用模块 CardWarehouseScanerModule |
|
|
|
指令: kplate_code_scaner_push_card_and_scan(参数为扫码结束位置,相当于指令moveTo参数) |
|
|
|
相关寄存器: |
|
|
|
kreg_plate_code_scaner_scan_start_pos (每次扫码前需要设置该参数) |
|
|
|
kreg_plate_code_scaner_code_judgment_threshold (扫码前设置,该数值为1,0码判定阈值) |
|
|
|
kreg_plate_code_scaner_item (扫码完成读取) |
|
|
|
kreg_plate_code_scaner_lot (扫码完成读取) |
|
|
|
kreg_plate_code_scaner_code_legal (扫码完成读取) |
|
|
|
*/ |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 读取 推板时的扫码结果LotId |
|
|
|
*/ |
|
|
|
int plateScanerReadlateLot() { |
|
|
|
return 0; |
|
|
|
@HardwareServiceAction(name = "推板", group = "单步操作") |
|
|
|
public AppRet<PlateInfo> pushPlate(PlateBoxCh PBCh, IncubatorPos turntablePosIndex) throws HardwareException, InterruptedException { |
|
|
|
trunableMoveToPushPos(turntablePosIndex.off); |
|
|
|
canBus.stepMotorEasyMoveToBlock(MId.PlatesBoxYM, getPBCh0Pos() + PBCh.off * getPBChSpacing(), getActionOvertime()); |
|
|
|
canBus.plateCodeScanerPushCardAndScanBlock(MId.PlatesBoxScanner, getPusherEndPos(), 10000); |
|
|
|
canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.PlatesBoxPusherM, getActionOvertime()); |
|
|
|
canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.PlatesBoxYM, getActionOvertime()); |
|
|
|
return AppRet.success(canBus.plateCodeScannerReadCode(MId.PlatesBoxScanner)); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 读取 推板时的扫码结果ItermId |
|
|
|
*/ |
|
|
|
int plateScanerReadPlateIterm() { |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 读取 推板时的扫码结果合法性 |
|
|
|
*/ |
|
|
|
boolean plateScanerReadPlateIsLegal() { |
|
|
|
return false; |
|
|
|
@HardwareServiceAction(name = "拉板", group = "单步操作") |
|
|
|
public void pullPlate(IncubatorPos turntablePosIndex) throws HardwareException, InterruptedException { |
|
|
|
trunableMoveToPullPos(turntablePosIndex.off); |
|
|
|
canBus.stepMotorEasyMoveToBlock(MId.OptModScannerM, getOptScanScandbyPos(), getActionOvertime()); |
|
|
|
canBus.stepMotorEasyMoveToBlock(MId.OptModPullM, getPullerTargetPos(), getActionOvertime()); |
|
|
|
canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.OptModPullM, getActionOvertime()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Integer[] plateScanerReadRawData() { |
|
|
|
/* |
|
|
|
后续实现效果, |
|
|
|
网页端执行完推板后,点击读取,网页端弹出一个页面, |
|
|
|
页面上有一条曲线 |
|
|
|
有曲线的最大值和最小值 |
|
|
|
且参考下面代码打上参考线 |
|
|
|
for (int i = 0; i < 15; i++) { |
|
|
|
plot2d->addRefLine(i * 12 + 6 ); |
|
|
|
} |
|
|
|
*/ |
|
|
|
return null; |
|
|
|
@HardwareServiceAction(name = "丢板", group = "单步操作") |
|
|
|
public void dropPlate() throws HardwareException, InterruptedException { |
|
|
|
canBus.stepMotorEasyMoveToBlock(MId.OptModScannerM, getPlateDropPos(), getActionOvertime()); |
|
|
|
canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.OptModScannerM, getActionOvertime()); |
|
|
|
canBus.stepMotorEasyMoveToBlock(MId.OptModScannerM, getOptScanScandbyPos(), getActionOvertime()); |
|
|
|
} |
|
|
|
|
|
|
|
/* ======================================================================================= |
|
|
|
光学模组部分操作 |
|
|
|
=======================================================================================*/ |
|
|
|
|
|
|
|
void pullReactionPlate(int turntablePosIndex) { |
|
|
|
/* |
|
|
|
1.检查当前钩爪出口光电是否触发,如果没有触发,直接报 电机位置异常 |
|
|
|
2.移动转盘 |
|
|
|
3.移动光学模组到丢板的位置 |
|
|
|
4.移动光学模组到待机位置 |
|
|
|
5.钩爪勾取反应板到指定位置 |
|
|
|
6.钩爪动作完成时,检查钩爪零点光电是否触发,如果没有触发报电机阻转异常 |
|
|
|
*/ |
|
|
|
} |
|
|
|
|
|
|
|
void dropThePlate() { |
|
|
|
/* |
|
|
|
光学模组电机移动丢板 |
|
|
|
*/ |
|
|
|
@HardwareServiceAction(name = "显示板夹扫码原始曲线", group = "辅助调试") |
|
|
|
public AppRet<A8kScanCurve> readPlateScanCurve() throws HardwareException, InterruptedException { |
|
|
|
List<Integer> scanDataCurve = canBus.plateCodeScanerReadRawResult(MId.PlatesBoxScanner); |
|
|
|
List<Integer> refLine = new ArrayList<>(); |
|
|
|
for (int i = 0; i < 15; i++) { |
|
|
|
refLine.add(i * 12 + 6); |
|
|
|
} |
|
|
|
return AppRet.success(new A8kScanCurve(scanDataCurve, refLine)); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* ======================================================================================= |
|
|
|
转盘操作 |
|
|
|
=======================================================================================*/ |
|
|
|
|
|
|
|
|
|
|
|
AppRet deviceStateCheck() { |
|
|
|
return AppRet.success(); |
|
|
|
@HardwareServiceAction(name = "读取<转盘>位置", group = "位置测量") |
|
|
|
public AppRet<Integer> readTrunablePos() throws HardwareException, InterruptedException { |
|
|
|
return AppRet.success(canBus.stepMotorReadPos(MId.IncubatorRotateCtrlM)); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 移动转盘到入口位置 |
|
|
|
* @param turntablePos 第几个仓位 |
|
|
|
*/ |
|
|
|
AppRet moveTurntableToEnterPos(int turntablePos) throws HardwareException { |
|
|
|
/* |
|
|
|
注意事项: |
|
|
|
1.移动前检查,出转盘钩爪电机光电是否触发(两个光电必须触发一个才能执行动作),否则直接抛出 电机位置异常错误 |
|
|
|
2.移动前检测,入转盘钩爪零点光电是否触发。 |
|
|
|
3.移动前检查,入转盘卡板光电是否触发。 |
|
|
|
*/ |
|
|
|
|
|
|
|
if (canBus.getIOState(IOId.PlateBoxPlateStuckPPS) || !canBus.getIOState(IOId.PullerMZeroPPS) || !canBus.getIOState(IOId.PusherMZeroPPS)) { |
|
|
|
return AppRet.fail(A8kEcode.PlateStuckDetectorSensorTrigger); |
|
|
|
} |
|
|
|
return AppRet.success(); |
|
|
|
@HardwareServiceAction(name = "通过归零读取<板夹仓>位置", group = "位置测量") |
|
|
|
public AppRet<Integer> readPlatesBoxYMPosByMoveToZero() throws HardwareException, InterruptedException { |
|
|
|
return AppRet.success(canBus.stepMotorReadPosByMoveToZeroBlock(MId.PlatesBoxYM, getActionOvertime())); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 移动转盘到出口位置 |
|
|
|
* @param turntablePos 第几个仓位 |
|
|
|
*/ |
|
|
|
void moveTurntableToExitPos(int turntablePos) { |
|
|
|
/* |
|
|
|
moveTurntableToEnterPos |
|
|
|
*/ |
|
|
|
@HardwareServiceAction(name = "通过归零读取<推杆>位置", group = "位置测量") |
|
|
|
public AppRet<Integer> readPlatesBoxPusherMPosByMoveToZero() throws HardwareException, InterruptedException { |
|
|
|
return AppRet.success(canBus.stepMotorReadPosByMoveToZeroBlock(MId.PlatesBoxPusherM, getActionOvertime())); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 移动转盘到点滴位置 |
|
|
|
* @param turntablePos 第几个仓位 |
|
|
|
*/ |
|
|
|
void moveTurntableToDropLiquidPos(int turntablePos) { |
|
|
|
/* |
|
|
|
同moveTurntableToEnterPos |
|
|
|
*/ |
|
|
|
@HardwareServiceAction(name = "通过归零读取<拉杆>位置", group = "位置测量") |
|
|
|
public AppRet<Integer> readOptModPullMPosByMoveToZero() throws HardwareException, InterruptedException { |
|
|
|
return AppRet.success(canBus.stepMotorReadPosByMoveToZeroBlock(MId.OptModPullM, getActionOvertime())); |
|
|
|
} |
|
|
|
|
|
|
|
void emptyTurntable() { |
|
|
|
/* |
|
|
|
清空转盘 |
|
|
|
*/ |
|
|
|
@HardwareServiceAction(name = "通过归零读取<光学模组扫描器>位置", group = "位置测量") |
|
|
|
public AppRet<Integer> readOptModScannerMPosByMoveToZero() throws HardwareException, InterruptedException { |
|
|
|
return AppRet.success(canBus.stepMotorReadPosByMoveToZeroBlock(MId.OptModScannerM, getActionOvertime())); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |