|
|
@ -6,8 +6,7 @@ import a8k.canbus.protocol.MId; |
|
|
|
import a8k.appbean.HardwareException; |
|
|
|
import a8k.appbean.ecode.AppRet; |
|
|
|
import a8k.canbus.A8kCanBusService; |
|
|
|
import a8k.service.db.dao.ReactionPlatesTransmitCtrlParamDao; |
|
|
|
import a8k.utils.HardwareService; |
|
|
|
import a8k.utils.*; |
|
|
|
import jakarta.annotation.Resource; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
@ -15,92 +14,214 @@ import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
|
|
|
|
@Component |
|
|
|
@HardwareService(name="反应板") |
|
|
|
public class ReactionPlatesTransmitCtrlService { |
|
|
|
@HardwareService(name = "反应板条搬移服务") |
|
|
|
@HardwareServiceParams(service = ReactionPlatesTransmitCtrlService.class) |
|
|
|
public class ReactionPlatesTransmitCtrlService implements HardwareCtrlModule { |
|
|
|
static Logger logger = LoggerFactory.getLogger(ReactionPlatesTransmitCtrlService.class); |
|
|
|
HardwareParamReader hpReader = new HardwareParamReader(ReactionPlatesTransmitCtrlService.class); |
|
|
|
|
|
|
|
/* |
|
|
|
职责说明 |
|
|
|
1.仓位变化 |
|
|
|
2.推出反应板 |
|
|
|
3.反应板推出异常检测 |
|
|
|
4.反应板推出二次校准服务 |
|
|
|
*/ |
|
|
|
|
|
|
|
@Resource |
|
|
|
A8kCanBusService canBus; |
|
|
|
|
|
|
|
@Resource |
|
|
|
ReactionPlatesTransmitCtrlParamDao paramDao; |
|
|
|
@HardwareServiceParam(name = "动作超时时间", group = "基础参数") |
|
|
|
public Integer getActionOvertime() { |
|
|
|
return hpReader.getInteger("actionOvertime", 5000); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "板夹仓通道0位置", group = "板夹仓参数") |
|
|
|
public Integer getPBCh0Pos() { |
|
|
|
return hpReader.getInteger("PBCh0Pos", -17); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "板夹仓通道间距", group = "板夹仓参数") |
|
|
|
public Integer getPBChSpacing() { |
|
|
|
return hpReader.getInteger("PBChSpacing", 265); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "推杆到位坐标", group = "板夹仓参数") |
|
|
|
public Integer getPusherEndPos() { |
|
|
|
return hpReader.getInteger("PusherEndPos", 1160); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "推杆扫码开始坐标", group = "板夹仓参数") |
|
|
|
public Integer getPusherScanStartPos() { |
|
|
|
return hpReader.getInteger("PusherScanStartPos", 960); |
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
|
* 转盘相关位置 |
|
|
|
*/ |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "仓位0入板位置", group = "转盘参数") |
|
|
|
public Integer getTurntablePushPos0() { |
|
|
|
return hpReader.getInteger("TurntablePushPos0", 0); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "仓位0出板位置", group = "转盘参数") |
|
|
|
public Integer getTurntablePullPos0() { |
|
|
|
return hpReader.getInteger("TurntablePullPos0", 0); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "仓位0点滴位", group = "转盘参数") |
|
|
|
public Integer getTurntableDropLiquidPos0() { |
|
|
|
return hpReader.getInteger("TurntableDropLiquidPos0", 0); |
|
|
|
} |
|
|
|
|
|
|
|
public Integer getTurntablePosSpacing() { |
|
|
|
return 1800; |
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
|
* 光学模组相关 |
|
|
|
*/ |
|
|
|
@HardwareServiceParam(name = "拉板目标位置", group = "光学模组参数") |
|
|
|
public Integer getPullerTargetPos() { |
|
|
|
return hpReader.getInteger("PullerTargetPos", 0); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "丢板坐标", group = "光学模组参数") |
|
|
|
public Integer getPlateDropPos() { |
|
|
|
return hpReader.getInteger("PlateDropPos", 0); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "扫描待机位", group = "光学模组参数") |
|
|
|
public Integer getOptScanScandbyPos() { |
|
|
|
return hpReader.getInteger("OptScanScandbyPos", 0); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* ZERO_DPOS |
|
|
|
*/ |
|
|
|
@HardwareServiceParam(name = "推杆电机", group = "坐标偏移参数") |
|
|
|
public Integer getPlatesBoxPusherMDpos() { |
|
|
|
return hpReader.getInteger("PlatesBoxPusherMDpos", 0); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "板夹仓平移电机", group = "坐标偏移参数") |
|
|
|
public Integer getPlatesBoxYMDpos() { |
|
|
|
return hpReader.getInteger("PlatesBoxYMDpos", 0); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "光学模组拉板电机", group = "坐标偏移参数") |
|
|
|
public Integer getOptModPullMDpos() { |
|
|
|
return hpReader.getInteger("OptModPullMDpos", 0); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "光学模组扫描电机", group = "坐标偏移参数") |
|
|
|
public Integer getOptModScannerMDpos() { |
|
|
|
return hpReader.getInteger("OptModScannerMDpos", 0); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceParam(name = "转盘电机", group = "坐标偏移参数") |
|
|
|
public Integer getIncubatorRotateCtrlMDpos() { |
|
|
|
return hpReader.getInteger("IncubatorRotateCtrlMDpos", 0); |
|
|
|
} |
|
|
|
/* ======================================================================================= |
|
|
|
基础操作 |
|
|
|
Utils |
|
|
|
=======================================================================================*/ |
|
|
|
|
|
|
|
AppRet<Object> moduleReset() throws HardwareException, InterruptedException { |
|
|
|
//光电状态检查 |
|
|
|
private void checkBeforeMoveTrunable() throws HardwareException { |
|
|
|
//试管平移通道是否有障碍 |
|
|
|
if (canBus.getIOState(IOId.THChInterPPS) || canBus.getIOState(IOId.THChOuterPPS)) { |
|
|
|
logger.warn("THChInterPPS or THChOuterPPS is trigger"); |
|
|
|
return AppRet.fail(A8kEcode.TubeXChannelIsNotEmpty); |
|
|
|
logger.error("THChInterPPS or THChOuterPPS is trigger"); |
|
|
|
throw new HardwareException(A8kEcode.TubeXChannelIsNotEmpty); |
|
|
|
} |
|
|
|
//板夹仓卡板检测 |
|
|
|
if (canBus.getIOState(IOId.PlateBoxPlateStuckPPS)) { |
|
|
|
logger.warn("PlateBoxPlateStuckPPS is trigger"); |
|
|
|
return AppRet.fail(A8kEcode.PlateStuckDetectorSensorTrigger); |
|
|
|
logger.error("PlateBoxPlateStuckPPS is trigger"); |
|
|
|
throw new HardwareException(A8kEcode.PlateStuckDetectorSensorTrigger); |
|
|
|
} |
|
|
|
|
|
|
|
//检查钩板电机是否处于终点位置 |
|
|
|
if (!canBus.getIOState(IOId.PullerMZeroPPS)) { |
|
|
|
logger.warn("PullerM is not in zero pos"); |
|
|
|
return AppRet.fail(A8kEcode.PullerMInitPosError); |
|
|
|
logger.error("PullerM is not in zero pos"); |
|
|
|
throw new HardwareException(A8kEcode.PullerMInitPosError); |
|
|
|
} |
|
|
|
|
|
|
|
//检查板夹仓光电是否处于起点位置 |
|
|
|
if (!canBus.getIOState(IOId.PusherMZeroPPS)) { |
|
|
|
logger.warn("PusherM is not in zero pos"); |
|
|
|
return AppRet.fail(A8kEcode.PusherMInitPosError); |
|
|
|
logger.error("PusherM is not in zero pos"); |
|
|
|
throw new HardwareException(A8kEcode.PusherMInitPosError); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//板夹仓初始化 |
|
|
|
canBus.stepMotorEasyMoveToZero(MId.PlatesBoxYM); |
|
|
|
canBus.waitForMod(MId.PlatesBoxYM, paramDao.getActionOvertime()); |
|
|
|
canBus.stepMotorEasyMoveToZero(MId.PlatesBoxPusherM); |
|
|
|
canBus.waitForMod(MId.PlatesBoxPusherM, paramDao.getActionOvertime()); |
|
|
|
/* ======================================================================================= |
|
|
|
基础操作 |
|
|
|
=======================================================================================*/ |
|
|
|
|
|
|
|
|
|
|
|
@HardwareServiceAction(name = "模块使能", group = "基础操作") |
|
|
|
@Override |
|
|
|
public void modGroupEnable(Boolean enable) throws HardwareException, InterruptedException { |
|
|
|
canBus.stepMotorEnable(MId.PlatesBoxYM, enable ? 1 : 0); |
|
|
|
canBus.stepMotorEnable(MId.PlatesBoxPusherM, enable ? 1 : 0); |
|
|
|
canBus.stepMotorEnable(MId.OptModPullM, enable ? 1 : 0); |
|
|
|
canBus.stepMotorEnable(MId.OptModScannerM, enable ? 1 : 0); |
|
|
|
canBus.stepMotorEnable(MId.IncubatorRotateCtrlM, enable ? 1 : 0); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceAction(name = "模块停止", group = "基础操作") |
|
|
|
@Override |
|
|
|
public void modGroupStop() throws HardwareException { |
|
|
|
canBus.stepMotorStop(MId.PlatesBoxYM); |
|
|
|
canBus.stepMotorStop(MId.PlatesBoxPusherM); |
|
|
|
canBus.stepMotorStop(MId.OptModPullM); |
|
|
|
canBus.stepMotorStop(MId.OptModScannerM); |
|
|
|
canBus.stepMotorStop(MId.IncubatorRotateCtrlM); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceAction(name = "电机归零", group = "基础操作") |
|
|
|
@Override |
|
|
|
public void modGroupMoveToZero() throws HardwareException, InterruptedException { |
|
|
|
checkBeforeMoveTrunable(); |
|
|
|
|
|
|
|
//板夹仓初始化 |
|
|
|
canBus.stepMotorEasyMoveToZeroBlock(MId.PlatesBoxPusherM, getActionOvertime()); |
|
|
|
canBus.stepMotorEasyMoveToZeroBlock(MId.PlatesBoxYM, getActionOvertime()); |
|
|
|
//光学模组初始化 |
|
|
|
canBus.stepMotorEasyMoveToZero(MId.OptModPullM); |
|
|
|
canBus.waitForMod(MId.OptModPullM, paramDao.getActionOvertime()); |
|
|
|
canBus.stepMotorEasyMoveToZero(MId.OptModScannerM); |
|
|
|
canBus.waitForMod(MId.OptModScannerM, paramDao.getActionOvertime()); |
|
|
|
canBus.stepMotorEasyMoveToZeroBlock(MId.OptModPullM, getActionOvertime()); |
|
|
|
canBus.stepMotorEasyMoveToZeroBlock(MId.OptModScannerM, getActionOvertime()); |
|
|
|
//转盘归零 |
|
|
|
canBus.stepMotorEasyMoveToZeroBlock(MId.IncubatorRotateCtrlM, getActionOvertime()); |
|
|
|
} |
|
|
|
|
|
|
|
@HardwareServiceAction(name = "电机快速归零", group = "基础操作") |
|
|
|
@Override |
|
|
|
public void modGroupMoveToZeroQuick() throws HardwareException, InterruptedException { |
|
|
|
//试管平移通道是否有障碍 |
|
|
|
checkBeforeMoveTrunable(); |
|
|
|
|
|
|
|
//板夹仓初始化 |
|
|
|
canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.PlatesBoxPusherM, getActionOvertime()); |
|
|
|
canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.PlatesBoxYM, getActionOvertime()); |
|
|
|
//光学模组初始化 |
|
|
|
canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.OptModPullM, getActionOvertime()); |
|
|
|
canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.OptModScannerM, getActionOvertime()); |
|
|
|
//转盘归零 |
|
|
|
canBus.stepMotorEasyMoveToZero(MId.IncubatorRotateCtrlM); |
|
|
|
canBus.waitForMod(MId.IncubatorRotateCtrlM, paramDao.getActionOvertime()); |
|
|
|
canBus.stepMotorEasyMoveToZeroPointQuickBlock(MId.IncubatorRotateCtrlM, getActionOvertime()); |
|
|
|
} |
|
|
|
|
|
|
|
return AppRet.success(); |
|
|
|
@HardwareServiceAction(name = "转盘移动到推板位", group = "基础操作") |
|
|
|
public void trunableMoveToPushPos(Integer index) throws HardwareException, InterruptedException { |
|
|
|
checkBeforeMoveTrunable(); |
|
|
|
canBus.stepMotorEasyMoveToBlock(MId.IncubatorRotateCtrlM,// |
|
|
|
getTurntablePushPos0() + index * getTurntablePosSpacing(), getActionOvertime()); |
|
|
|
} |
|
|
|
|
|
|
|
void moduleEnable() throws HardwareException { |
|
|
|
/* |
|
|
|
模块使能 |
|
|
|
*/ |
|
|
|
canBus.stepMotorEnable(MId.PlatesBoxYM, 1); |
|
|
|
canBus.stepMotorEnable(MId.PlatesBoxPusherM, 1); |
|
|
|
canBus.stepMotorEnable(MId.OptModPullM, 1); |
|
|
|
canBus.stepMotorEnable(MId.OptModScannerM, 1); |
|
|
|
canBus.stepMotorEnable(MId.IncubatorRotateCtrlM, 1); |
|
|
|
@HardwareServiceAction(name = "转盘移动到出板位", group = "基础操作") |
|
|
|
public void trunableMoveToPullPos(Integer index) throws HardwareException, InterruptedException { |
|
|
|
checkBeforeMoveTrunable(); |
|
|
|
canBus.stepMotorEasyMoveToBlock(MId.IncubatorRotateCtrlM,// |
|
|
|
getTurntablePullPos0() + index * getTurntablePosSpacing(), getActionOvertime()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
void moduleDisable() throws HardwareException { |
|
|
|
/* |
|
|
|
模块失能 |
|
|
|
*/ |
|
|
|
canBus.stepMotorEnable(MId.PlatesBoxYM, 0); |
|
|
|
canBus.stepMotorEnable(MId.PlatesBoxPusherM, 0); |
|
|
|
canBus.stepMotorEnable(MId.OptModPullM, 0); |
|
|
|
canBus.stepMotorEnable(MId.OptModScannerM, 0); |
|
|
|
canBus.stepMotorEnable(MId.IncubatorRotateCtrlM, 0); |
|
|
|
@HardwareServiceAction(name = "转盘移动到滴定位", group = "基础操作") |
|
|
|
public void trunableMoveToDropLiquidPos(Integer index) throws HardwareException, InterruptedException { |
|
|
|
checkBeforeMoveTrunable(); |
|
|
|
canBus.stepMotorEasyMoveToBlock(MId.IncubatorRotateCtrlM,// |
|
|
|
getTurntableDropLiquidPos0() + index * getTurntablePosSpacing(), getActionOvertime()); |
|
|
|
} |
|
|
|
|
|
|
|
/* ======================================================================================= |
|
|
@ -124,8 +245,6 @@ public class ReactionPlatesTransmitCtrlService { |
|
|
|
kreg_plate_code_scaner_lot (扫码完成读取) |
|
|
|
kreg_plate_code_scaner_code_legal (扫码完成读取) |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|