26 changed files with 1264 additions and 937 deletions
-
9src/main/java/a8k/extapi_controler/pagecontrol/ExtApiTabConfig.java
-
82src/main/java/a8k/hardware/A8kCanBusService.java
-
2src/main/java/a8k/hardware/type/regindex/RegIndex.java
-
6src/main/java/a8k/service/app/appctrl/mainflowctrl/action/DO_START.java
-
4src/main/java/a8k/service/app/appctrl/mainflowctrl/action/SEQ1_ENTER_TUBEHOLDER_AND_SCAN.java
-
4src/main/java/a8k/service/app/appctrl/mainflowctrl/action/SEQ2_SWITCH_TO_THE_NEXT_TUBE.java
-
8src/main/java/a8k/service/app/appctrl/mainflowctrl/action/SEQ4_PRE_PROCESS.java
-
4src/main/java/a8k/service/app/appctrl/mainflowctrl/action/SEQ7_EJECT_TUBEHOLDER.java
-
91src/main/java/a8k/service/app/devicedriver/basectrl/MiniServoControler.java
-
27src/main/java/a8k/service/app/devicedriver/basectrl/TubeTransportControler.java
-
18src/main/java/a8k/service/app/devicedriver/basectrl/type/MiniServoMid.java
-
23src/main/java/a8k/service/app/devicedriver/basectrl/type/MiniServoRegIndex.java
-
4src/main/java/a8k/service/app/devicedriver/calibration/PositionCalibration.java
-
56src/main/java/a8k/service/app/devicedriver/calibration/TubePreProcesPosCalibration.java
-
43src/main/java/a8k/service/app/devicedriver/calibration/TubeScanPosCalibration.java
-
10src/main/java/a8k/service/app/devicedriver/commonctrl/HardwareCommonCtrl.java
-
10src/main/java/a8k/service/app/devicedriver/ctrl/DeviceInitCtrlService.java
-
62src/main/java/a8k/service/app/devicedriver/ctrl/TubePreProcesControler.java
-
16src/main/java/a8k/service/app/devicedriver/ctrl/TubeScanerControler.java
-
186src/main/java/a8k/service/app/devicedriver/pos/TubePreProcesPosMgr.java
-
4src/main/java/a8k/service/app/devicedriver/pos/TubeScanPosMgr.java
-
8src/main/java/a8k/service/app/devicedriver/testscript/TestScript.java
@ -0,0 +1,91 @@ |
|||||
|
package a8k.service.app.devicedriver.basectrl; |
||||
|
|
||||
|
import a8k.hardware.A8kCanBusService; |
||||
|
import a8k.hardware.type.a8kcanprotocol.A8kEcode; |
||||
|
import a8k.hardware.type.a8kcanprotocol.CmdId; |
||||
|
import a8k.hardware.type.a8kcanprotocol.MId; |
||||
|
import a8k.hardware.type.regindex.RegIndex; |
||||
|
import a8k.service.app.devicedriver.basectrl.type.MiniServoMid; |
||||
|
import a8k.type.ecode.HardwareError; |
||||
|
import a8k.type.exception.AppException; |
||||
|
import jakarta.annotation.Resource; |
||||
|
|
||||
|
public class MiniServoControler { |
||||
|
@Resource |
||||
|
A8kCanBusService canBus; |
||||
|
|
||||
|
|
||||
|
public void miniServoEnable(MiniServoMid id, int enable) throws AppException { |
||||
|
canBus.callcmd(id.mid, CmdId.mini_servo_enable, enable); |
||||
|
} |
||||
|
|
||||
|
public int miniServoReadPos(MiniServoMid id) throws AppException { |
||||
|
var packet = canBus.callcmd(id.mid, CmdId.mini_servo_read_pos); |
||||
|
return packet.getContentI32(0); |
||||
|
} |
||||
|
|
||||
|
public void miniServoActiveCfg(MiniServoMid id) throws AppException { |
||||
|
canBus.callcmd(id.mid, CmdId.mini_servo_active_cfg); |
||||
|
} |
||||
|
|
||||
|
public void miniServoStop(MiniServoMid id) throws AppException { |
||||
|
canBus.callcmd(id.mid, CmdId.mini_servo_stop); |
||||
|
} |
||||
|
|
||||
|
public void miniServoSetMidPoint(MiniServoMid id) throws AppException { |
||||
|
canBus.callcmd(id.mid, CmdId.mini_servo_set_mid_point); |
||||
|
} |
||||
|
|
||||
|
public int miniServoReadIoState(MiniServoMid id) throws AppException { |
||||
|
var packet = canBus.callcmd(id.mid, CmdId.mini_servo_read_io_state); |
||||
|
return packet.getContentI32(0); |
||||
|
} |
||||
|
|
||||
|
public void miniServoMoveTo(MiniServoMid id, int pos) throws AppException { |
||||
|
canBus.callcmd(id.mid, CmdId.mini_servo_move_to, pos); |
||||
|
} |
||||
|
|
||||
|
public void miniServoMoveToBlock(MiniServoMid id, int pos, Integer actionOvertime) throws AppException { |
||||
|
miniServoMoveTo(id, pos); |
||||
|
canBus.waitForMod(id.mid, actionOvertime); |
||||
|
} |
||||
|
|
||||
|
public void miniServoRotate(MiniServoMid id, int direction) throws AppException { |
||||
|
canBus.callcmd(id.mid, CmdId.mini_servo_rotate, direction); |
||||
|
} |
||||
|
|
||||
|
public void miniServoRotateBlock(MiniServoMid id, int direction, Integer actionOvertime) throws AppException { |
||||
|
miniServoRotate(id, direction); |
||||
|
canBus.waitForMod(id.mid, actionOvertime); |
||||
|
} |
||||
|
|
||||
|
public void miniServoRotateWithTorque(MiniServoMid id, int torque) throws AppException { |
||||
|
canBus.callcmd(id.mid, CmdId.mini_servo_rotate_with_torque, torque); |
||||
|
} |
||||
|
|
||||
|
public void miniServoRotateWithTorqueBlock(MiniServoMid id, int torque, Integer actionOvertime) throws AppException { |
||||
|
miniServoRotateWithTorque(id, torque); |
||||
|
miniServoWaitIsNotMove(id, actionOvertime); |
||||
|
} |
||||
|
|
||||
|
// kmini_servo_set_cur_pos |
||||
|
public void miniServoSetCurPos(MiniServoMid id, Integer pos) throws AppException { |
||||
|
canBus.callcmdOvertime(id.mid, CmdId.mini_servo_set_cur_pos, 5000, pos); |
||||
|
} |
||||
|
|
||||
|
public void miniServoWaitIsNotMove(MiniServoMid id, int acitionOvertime) throws AppException { |
||||
|
long startedAt = System.currentTimeMillis(); |
||||
|
do { |
||||
|
var isMove = canBus.moduleGetReg(id.mid, RegIndex.kreg_mini_servo_is_move); |
||||
|
if (isMove != 0) { |
||||
|
break; |
||||
|
} |
||||
|
long now = System.currentTimeMillis(); |
||||
|
if (now - startedAt > acitionOvertime) { |
||||
|
throw AppException.of(new HardwareError(A8kEcode.LOW_ERROR_OVERTIME, id.mid, null)); |
||||
|
} |
||||
|
|
||||
|
} while (true); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,18 @@ |
|||||
|
package a8k.service.app.devicedriver.basectrl.type; |
||||
|
|
||||
|
import a8k.hardware.type.a8kcanprotocol.MId; |
||||
|
|
||||
|
public enum MiniServoMid { |
||||
|
ShakeModGripperYSV( MId.ShakeModGripperYSV),// |
||||
|
ShakeModGripperSV( MId.ShakeModGripperSV),// |
||||
|
ShakeModTubeScanerClampingSV( MId.ShakeModTubeScanerClampingSV),// |
||||
|
ShakeModTubeScanerRotateSV( MId.ShakeModTubeScanerRotateSV),// |
||||
|
; |
||||
|
|
||||
|
final public MId mid; |
||||
|
|
||||
|
MiniServoMid(MId mid) { |
||||
|
this.mid = mid; |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,23 @@ |
|||||
|
package a8k.service.app.devicedriver.basectrl.type; |
||||
|
|
||||
|
import a8k.hardware.type.regindex.RegIndex; |
||||
|
|
||||
|
public enum MiniServoRegIndex { |
||||
|
kreg_module_version(RegIndex.kreg_module_version), // 模块版本 |
||||
|
kreg_module_type(RegIndex.kreg_module_type), // 模块类型 |
||||
|
kreg_module_status(RegIndex.kreg_module_status), // 0idle,1busy,2error |
||||
|
kreg_module_errorcode(RegIndex.kreg_module_errorcode), // inited_flag |
||||
|
kreg_extboard_resetflag(RegIndex.kreg_extboard_resetflag), |
||||
|
|
||||
|
kreg_mini_servo_pos(RegIndex.kreg_mini_servo_pos), // 位置 |
||||
|
kreg_mini_servo_limit_velocity(RegIndex.kreg_mini_servo_limit_velocity), // 限制速度 |
||||
|
kreg_mini_servo_limit_torque(RegIndex.kreg_mini_servo_limit_torque), // 限制扭矩 |
||||
|
kreg_mini_servo_protective_torque(RegIndex.kreg_mini_servo_protective_torque), // 保护扭矩 |
||||
|
kreg_mini_servo_is_move(RegIndex.kreg_mini_servo_is_move), // 是否在运动 |
||||
|
; |
||||
|
public final RegIndex regIndex; |
||||
|
|
||||
|
MiniServoRegIndex(RegIndex regIndex) { |
||||
|
this.regIndex = regIndex; |
||||
|
} |
||||
|
} |
@ -0,0 +1,56 @@ |
|||||
|
package a8k.service.app.devicedriver.calibration; |
||||
|
|
||||
|
import a8k.extapi_controler.pagecontrol.ExtApiTabConfig; |
||||
|
import a8k.extapi_controler.utils.ExtApiFn; |
||||
|
import a8k.extapi_controler.utils.ExtApiTab; |
||||
|
import a8k.hardware.A8kCanBusService; |
||||
|
import a8k.hardware.type.a8kcanprotocol.MId; |
||||
|
import a8k.service.app.devicedriver.basectrl.MiniServoControler; |
||||
|
import a8k.service.app.devicedriver.basectrl.type.MiniServoMid; |
||||
|
import a8k.service.app.devicedriver.pos.TubePreProcesPosMgr; |
||||
|
import a8k.type.exception.AppException; |
||||
|
import jakarta.annotation.Resource; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
@ExtApiTab(cfg = ExtApiTabConfig.TubeScanPosCalibration) |
||||
|
@Component |
||||
|
public class TubePreProcesPosCalibration { |
||||
|
|
||||
|
@Resource |
||||
|
TubePreProcesPosMgr tubePreProcesPosMgr; |
||||
|
|
||||
|
@Resource |
||||
|
A8kCanBusService canBus; |
||||
|
@Resource |
||||
|
MiniServoControler miniServoControler; |
||||
|
|
||||
|
//基础工具 |
||||
|
@ExtApiFn(name = "归零", group = "测试工具", order = 11) |
||||
|
public void deviceReset() throws AppException { |
||||
|
enableModule(); |
||||
|
canBus.stepMotorEasyMoveToZeroBlock(MId.FeedingModXM, 15000); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
@ExtApiFn(name = "使能相关模块", group = "测试工具", order = 12) |
||||
|
public void enableModule() throws AppException { |
||||
|
miniServoControler.miniServoEnable(MiniServoMid.ShakeModGripperSV, 1); |
||||
|
miniServoControler.miniServoEnable(MiniServoMid.ShakeModGripperYSV, 1); |
||||
|
canBus.stepMotorEnable(MId.ShakeModClampingM, 1); |
||||
|
canBus.stepMotorEnable(MId.ShakeModGripperZM, 1); |
||||
|
canBus.stepMotorEnable(MId.ShakeModShakeM, 1); |
||||
|
} |
||||
|
|
||||
|
@ExtApiFn(name = "失能相关模块", group = "测试工具", order = 13) |
||||
|
public void disableModule() throws AppException { |
||||
|
canBus.stepMotorEnable(MId.FeedingModInfeedM, 0); |
||||
|
canBus.stepMotorEnable(MId.FeedingModOutfeedM, 0); |
||||
|
canBus.stepMotorEnable(MId.FeedingModXM, 0); |
||||
|
miniServoControler.miniServoEnable(MiniServoMid.ShakeModTubeScanerClampingSV, 0); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
//标定和校准 |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,186 @@ |
|||||
|
package a8k.service.app.devicedriver.pos; |
||||
|
|
||||
|
import a8k.service.db.LowerDeviceParameterDBService; |
||||
|
import a8k.service.db.utils.PosParameterReader; |
||||
|
import jakarta.annotation.PostConstruct; |
||||
|
import jakarta.annotation.Resource; |
||||
|
import org.slf4j.Logger; |
||||
|
import org.slf4j.LoggerFactory; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
@Component |
||||
|
public class TubePreProcesPosMgr { |
||||
|
static final Logger logger = LoggerFactory.getLogger(TubeScanPosMgr.class); |
||||
|
|
||||
|
public enum POS { |
||||
|
GripperServoOpenPos("抓手张开位置"),// |
||||
|
GripperServoClosePos("抓手闭合位置"),// |
||||
|
GripperServoTakeCapPos("抓手取试管位置"),// |
||||
|
YServoTakeTubePos("取试管位置"),// |
||||
|
YServoShakePos("摇匀位置"),// |
||||
|
YServoZeroYPos("待机位"),// |
||||
|
ZMotorTakeHTubePos("取高试管位置"),// |
||||
|
ZMotorTakeSTubePos("取低试管位置"),// |
||||
|
ZMotorJudgeHTubeCapPos("高试管帽有无判断位"),// |
||||
|
ZMotorJudgeSTubeCapPos("低试管帽有无判断位"),// |
||||
|
ZMotorShakeTubePos("摇匀放置位置"),// |
||||
|
ZMotorTakeCapPos("取试管帽位"),// |
||||
|
ShakeClampMotorClampPos("试管夹紧位"),// |
||||
|
ShakeClampMotorReleasePos("摇匀臂"),// |
||||
|
; |
||||
|
public final String chName; |
||||
|
|
||||
|
POS(String chName) { |
||||
|
this.chName = chName; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
; |
||||
|
|
||||
|
@Resource |
||||
|
LowerDeviceParameterDBService lowerDeviceParameterDBService; |
||||
|
|
||||
|
PosParameterReader posReader = null; |
||||
|
Integer nowParaVersion = 0; |
||||
|
|
||||
|
@PostConstruct |
||||
|
void initialize() { |
||||
|
posReader = lowerDeviceParameterDBService.getReader(this.getClass()); |
||||
|
Integer paraVersion = posReader.getVersion(); |
||||
|
if (!nowParaVersion.equals(paraVersion)) { |
||||
|
logger.info("init param"); |
||||
|
posReader.setVersion(nowParaVersion); |
||||
|
posReader.updatePos(POS.GripperServoOpenPos, 450); |
||||
|
posReader.updatePos(POS.GripperServoClosePos, 310); |
||||
|
posReader.updatePos(POS.GripperServoTakeCapPos, 355); |
||||
|
posReader.updatePos(POS.YServoTakeTubePos, 3080); |
||||
|
posReader.updatePos(POS.YServoShakePos, 2130); |
||||
|
posReader.updatePos(POS.YServoZeroYPos, 300); |
||||
|
posReader.updatePos(POS.ZMotorTakeHTubePos, 739); |
||||
|
posReader.updatePos(POS.ZMotorTakeSTubePos, 983); |
||||
|
posReader.updatePos(POS.ZMotorJudgeHTubeCapPos, 591); |
||||
|
posReader.updatePos(POS.ZMotorJudgeSTubeCapPos, 867); |
||||
|
posReader.updatePos(POS.ZMotorShakeTubePos, 835); |
||||
|
posReader.updatePos(POS.ZMotorTakeCapPos, 835); |
||||
|
posReader.updatePos(POS.ShakeClampMotorClampPos, 10); |
||||
|
posReader.updatePos(POS.ShakeClampMotorReleasePos, 90); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
public Integer getParam(POS pos) { |
||||
|
return posReader.getPos(pos, Integer.class); |
||||
|
} |
||||
|
|
||||
|
public Integer getGripperServoOpenPos() { |
||||
|
return getParam(POS.GripperServoOpenPos); |
||||
|
} |
||||
|
|
||||
|
public void setGripperServoOpenPos(Integer value) { |
||||
|
posReader.updatePos(POS.GripperServoOpenPos, value); |
||||
|
} |
||||
|
|
||||
|
public Integer getGripperServoClosePos() { |
||||
|
return getParam(POS.GripperServoClosePos); |
||||
|
} |
||||
|
|
||||
|
public void setGripperServoClosePos(Integer value) { |
||||
|
posReader.updatePos(POS.GripperServoClosePos, value); |
||||
|
} |
||||
|
|
||||
|
public Integer getGripperServoTakeCapPos() { |
||||
|
return getParam(POS.GripperServoTakeCapPos); |
||||
|
} |
||||
|
|
||||
|
public void setGripperServoTakeCapPos(Integer value) { |
||||
|
posReader.updatePos(POS.GripperServoTakeCapPos, value); |
||||
|
} |
||||
|
|
||||
|
public Integer getYServoTakeTubePos() { |
||||
|
return getParam(POS.YServoTakeTubePos); |
||||
|
} |
||||
|
|
||||
|
public void setYServoTakeTubePos(Integer value) { |
||||
|
posReader.updatePos(POS.YServoTakeTubePos, value); |
||||
|
} |
||||
|
|
||||
|
public Integer getYServoShakePos() { |
||||
|
return getParam(POS.YServoShakePos); |
||||
|
} |
||||
|
|
||||
|
public void setYServoShakePos(Integer value) { |
||||
|
posReader.updatePos(POS.YServoShakePos, value); |
||||
|
} |
||||
|
|
||||
|
public Integer getYServoZeroYPos() { |
||||
|
return getParam(POS.YServoZeroYPos); |
||||
|
} |
||||
|
|
||||
|
public void setYServoZeroYPos(Integer value) { |
||||
|
posReader.updatePos(POS.YServoZeroYPos, value); |
||||
|
} |
||||
|
|
||||
|
public Integer getZMotorTakeHTubePos() { |
||||
|
return getParam(POS.ZMotorTakeHTubePos); |
||||
|
} |
||||
|
|
||||
|
public void setZMotorTakeHTubePos(Integer value) { |
||||
|
posReader.updatePos(POS.ZMotorTakeHTubePos, value); |
||||
|
} |
||||
|
|
||||
|
public Integer getZMotorTakeSTubePos() { |
||||
|
return getParam(POS.ZMotorTakeSTubePos); |
||||
|
} |
||||
|
|
||||
|
public void setZMotorTakeSTubePos(Integer value) { |
||||
|
posReader.updatePos(POS.ZMotorTakeSTubePos, value); |
||||
|
} |
||||
|
|
||||
|
public Integer getZMotorJudgeHTubeCapPos() { |
||||
|
return getParam(POS.ZMotorJudgeHTubeCapPos); |
||||
|
} |
||||
|
|
||||
|
public void setZMotorJudgeHTubeCapPos(Integer value) { |
||||
|
posReader.updatePos(POS.ZMotorJudgeHTubeCapPos, value); |
||||
|
} |
||||
|
|
||||
|
public Integer getZMotorJudgeSTubeCapPos() { |
||||
|
return getParam(POS.ZMotorJudgeSTubeCapPos); |
||||
|
} |
||||
|
|
||||
|
public void setZMotorJudgeSTubeCapPos(Integer value) { |
||||
|
posReader.updatePos(POS.ZMotorJudgeSTubeCapPos, value); |
||||
|
} |
||||
|
|
||||
|
public Integer getZMotorShakeTubePos() { |
||||
|
return getParam(POS.ZMotorShakeTubePos); |
||||
|
} |
||||
|
|
||||
|
public void setZMotorShakeTubePos(Integer value) { |
||||
|
posReader.updatePos(POS.ZMotorShakeTubePos, value); |
||||
|
} |
||||
|
|
||||
|
public Integer getZMotorTakeCapPos() { |
||||
|
return getParam(POS.ZMotorTakeCapPos); |
||||
|
} |
||||
|
|
||||
|
public void setZMotorTakeCapPos(Integer value) { |
||||
|
posReader.updatePos(POS.ZMotorTakeCapPos, value); |
||||
|
} |
||||
|
|
||||
|
public Integer getShakeClampMotorClampPos() { |
||||
|
return getParam(POS.ShakeClampMotorClampPos); |
||||
|
} |
||||
|
|
||||
|
public void setShakeClampMotorClampPos(Integer value) { |
||||
|
posReader.updatePos(POS.ShakeClampMotorClampPos, value); |
||||
|
} |
||||
|
|
||||
|
public Integer getShakeClampMotorReleasePos() { |
||||
|
return getParam(POS.ShakeClampMotorReleasePos); |
||||
|
} |
||||
|
|
||||
|
public void setShakeClampMotorReleasePos(Integer value) { |
||||
|
posReader.updatePos(POS.ShakeClampMotorReleasePos, value); |
||||
|
} |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue