sige 1 year ago
parent
commit
1d275eb39f
  1. 2
      pom.xml
  2. 2
      src/main/java/a8k/a8k_can_protocol/A8kPacket.java
  3. 2
      src/main/java/a8k/appbean/HardwareException.java
  4. 2
      src/main/java/a8k/base_hardware/A8kCanBusService.java
  5. 5
      src/main/java/a8k/controller/SamplesPreProcessModuleCtrlController.java
  6. 4
      src/main/java/a8k/controller/TmpTestController.java
  7. 105
      src/main/java/a8k/service/hardware/SamplesPreProcessModuleCtrlService.java

2
pom.xml

@ -20,7 +20,7 @@
<dependency> <dependency>
<groupId>com.iflytop</groupId> <groupId>com.iflytop</groupId>
<artifactId>uf</artifactId> <artifactId>uf</artifactId>
<version>0.0.63</version>
<version>0.0.64</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.jetbrains</groupId> <groupId>org.jetbrains</groupId>

2
src/main/java/a8k/a8k_can_protocol/A8kPacket.java

@ -35,7 +35,7 @@ public class A8kPacket {
public static final int PACKET_TYPE_ERROR_ACK = 2; public static final int PACKET_TYPE_ERROR_ACK = 2;
public static final int PACKET_TYPE_EVENT = 3; public static final int PACKET_TYPE_EVENT = 3;
public static final int CMD_OVERTIME = 100;
public static final int CMD_OVERTIME = 1000;
public A8kPacket(byte[] cmd) { public A8kPacket(byte[] cmd) {
raw = new byte[cmd.length]; raw = new byte[cmd.length];

2
src/main/java/a8k/appbean/HardwareException.java

@ -15,6 +15,8 @@ public class HardwareException extends Exception {
public HardwareException(int moduleId, int HardwareErrorCode) { public HardwareException(int moduleId, int HardwareErrorCode) {
super(String.format("Module ID %s has error code %s", ModuleId.ModuleId2Name(moduleId), Errorcode.toString(HardwareErrorCode))); super(String.format("Module ID %s has error code %s", ModuleId.ModuleId2Name(moduleId), Errorcode.toString(HardwareErrorCode)));
this.moduleId = moduleId;
this.errorCode = HardwareErrorCode;
} }
int getModuleId() { int getModuleId() {

2
src/main/java/a8k/base_hardware/A8kCanBusService.java

@ -64,7 +64,7 @@ public class A8kCanBusService {
int packetIndex = 0;// int packetIndex = 0;//
// 调试标志位 // 调试标志位
boolean debugFlag = false;//
boolean debugFlag = true;//
// websocket自动重连时间 // websocket自动重连时间
Timer autoConnectTimer = new Timer();// Timer autoConnectTimer = new Timer();//

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

@ -9,6 +9,8 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import java.lang.reflect.InvocationTargetException;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@Controller @Controller
@ -20,7 +22,8 @@ public class SamplesPreProcessModuleCtrlController extends UfApiControllerBase {
@PostMapping("/api/sample-pre-process-module-ctrl/execute-service-method") @PostMapping("/api/sample-pre-process-module-ctrl/execute-service-method")
@ResponseBody @ResponseBody
public UfApiResponse executeServiceMethod( @RequestBody Map<String,Object> params ) throws NoSuchMethodException {
public UfApiResponse executeServiceMethod( @RequestBody Map<String,Object> params )
throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
Object service = this.samplesPreProcessModuleCtrlService; Object service = this.samplesPreProcessModuleCtrlService;
String methodName = (String)params.get("method"); String methodName = (String)params.get("method");
List<Object> methodArgs = (List<Object>)params.get("params"); List<Object> methodArgs = (List<Object>)params.get("params");

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

@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import java.lang.reflect.InvocationTargetException;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -33,7 +34,8 @@ public class TmpTestController {
@PostMapping("/api/tmp-test/execute-service-method") @PostMapping("/api/tmp-test/execute-service-method")
@ResponseBody @ResponseBody
public String executeServiceMethod(@RequestBody Map<String, Object> params) throws NoSuchMethodException {
public String executeServiceMethod(@RequestBody Map<String, Object> params)
throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
Object service = this.motorTubeRackMoveCtrlService; Object service = this.motorTubeRackMoveCtrlService;
String methodName = (String) params.get("method"); String methodName = (String) params.get("method");
List<Object> methodArgs = (List<Object>) params.get("params"); List<Object> methodArgs = (List<Object>) params.get("params");

105
src/main/java/a8k/service/hardware/SamplesPreProcessModuleCtrlService.java

@ -8,6 +8,7 @@ import a8k.appbean.HardwareException;
import a8k.base_hardware.A8kCanBusService; import a8k.base_hardware.A8kCanBusService;
import a8k.service.db.dao.A8kTubeInfoDao; import a8k.service.db.dao.A8kTubeInfoDao;
import a8k.service.db.dao.SamplesPreProcessModuleCtrlParamsService; import a8k.service.db.dao.SamplesPreProcessModuleCtrlParamsService;
import com.iflytop.uf.util.UfCommon;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -104,6 +105,17 @@ public class SamplesPreProcessModuleCtrlService {
); );
} }
/**
* 使能模组
*/
public void stop() throws HardwareException {
this.a8kCanBusService.callcmd(ModuleId.ShakeModShakeM, CmdId.kstep_motor_stop);
this.a8kCanBusService.callcmd(ModuleId.ShakeModClampingM, CmdId.kstep_motor_stop);
this.a8kCanBusService.callcmd(ModuleId.ShakeModClampingM, CmdId.kstep_motor_stop);
this.a8kCanBusService.callcmd(ModuleId.ShakeModGripperYM, CmdId.kmini_servo_stop);
this.a8kCanBusService.callcmd(ModuleId.ShakeModGripperSV, CmdId.kmini_servo_stop);
}
@ -118,11 +130,11 @@ public class SamplesPreProcessModuleCtrlService {
* @param tubeType TubeType_HighBlood,TubeType_ShortBlood,TubeType_Mini,TubeType_MiniBlood,TubeType_BulletTube1P5,TubeType_BulletTube0P5 * @param tubeType TubeType_HighBlood,TubeType_ShortBlood,TubeType_Mini,TubeType_MiniBlood,TubeType_BulletTube1P5,TubeType_BulletTube0P5
* @param judgeCapExist 是否判断试管帽子存在与否 * @param judgeCapExist 是否判断试管帽子存在与否
*/ */
public AppErrorCode takeTube(String tubeType,boolean judgeCapExist) throws HardwareException, InterruptedException {
public AppErrorCode takeTube(String tubeType, Boolean judgeCapExist) throws HardwareException, InterruptedException {
var params = this.samplesPreProcessModuleCtrlParamsService; var params = this.samplesPreProcessModuleCtrlParamsService;
this.a8kCanBusService.callblockcmd( this.a8kCanBusService.callblockcmd(
ModuleId.ShakeModGripperYM, ModuleId.ShakeModGripperYM,
CmdId.kstep_motor_easy_move_to,
CmdId.kmini_servo_move_to,
params.getHorizontalMotor_takeCapPos(), params.getHorizontalMotor_takeCapPos(),
params.getActionOvertime() params.getActionOvertime()
); );
@ -140,16 +152,18 @@ public class SamplesPreProcessModuleCtrlService {
); );
if ( judgeCapExist ) { if ( judgeCapExist ) {
this.a8kCanBusService.callblockcmd(
ModuleId.ShakeModClampingM,
this.a8kCanBusService.callcmd(
ModuleId.ShakeModGripperSV,
CmdId.kmini_servo_rotate_with_torque, CmdId.kmini_servo_rotate_with_torque,
params.getGripperServo_takeCapTorque(),
params.getActionOvertime()
params.getGripperServo_takeCapTorque()
); );
UfCommon.delay(3000);
this.a8kCanBusService.callcmd( this.a8kCanBusService.callcmd(
ModuleId.ShakeModGripperSV, ModuleId.ShakeModGripperSV,
CmdId.kmini_servo_stop
CmdId.kmini_servo_stop,
1
); );
UfCommon.delay(1000);
var pos = this.a8kCanBusService.callcmd( var pos = this.a8kCanBusService.callcmd(
ModuleId.ShakeModGripperSV, ModuleId.ShakeModGripperSV,
CmdId.kmini_servo_read_pos CmdId.kmini_servo_read_pos
@ -159,12 +173,12 @@ public class SamplesPreProcessModuleCtrlService {
} }
} }
this.a8kCanBusService.callblockcmd(
this.a8kCanBusService.callcmd(
ModuleId.ShakeModGripperSV, ModuleId.ShakeModGripperSV,
CmdId.kmini_servo_rotate_with_torque, CmdId.kmini_servo_rotate_with_torque,
params.getGripperServo_takeCapTorque(),
params.getActionOvertime()
params.getGripperServo_takeCapTorque()
); );
UfCommon.delay(3000);
this.a8kCanBusService.callblockcmd( this.a8kCanBusService.callblockcmd(
ModuleId.ShakeModGripperZM, ModuleId.ShakeModGripperZM,
@ -181,6 +195,20 @@ public class SamplesPreProcessModuleCtrlService {
); );
this.a8kCanBusService.callblockcmd( this.a8kCanBusService.callblockcmd(
ModuleId.ShakeModShakeM,
CmdId.kstep_motor_easy_move_to,
params.getShakeMotor_standbyPos(),
params.getActionOvertime()
);
this.a8kCanBusService.callblockcmd(
ModuleId.ShakeModClampingM,
CmdId.kstep_motor_easy_move_to,
params.getTubeClampMotor_standbyPos(),
params.getActionOvertime()
);
this.a8kCanBusService.callblockcmd(
ModuleId.ShakeModGripperZM, ModuleId.ShakeModGripperZM,
CmdId.kstep_motor_easy_move_to, CmdId.kstep_motor_easy_move_to,
params.getZMotor_placeShakeHeight(), params.getZMotor_placeShakeHeight(),
@ -189,7 +217,7 @@ public class SamplesPreProcessModuleCtrlService {
this.a8kCanBusService.callblockcmd( this.a8kCanBusService.callblockcmd(
ModuleId.ShakeModGripperSV, ModuleId.ShakeModGripperSV,
CmdId.kstep_motor_easy_move_to,
CmdId.kmini_servo_move_to,
params.getGripperServo_standbyPos(), params.getGripperServo_standbyPos(),
params.getActionOvertime() params.getActionOvertime()
); );
@ -203,7 +231,7 @@ public class SamplesPreProcessModuleCtrlService {
this.a8kCanBusService.callblockcmd( this.a8kCanBusService.callblockcmd(
ModuleId.ShakeModGripperYM, ModuleId.ShakeModGripperYM,
CmdId.kstep_motor_easy_move_to,
CmdId.kmini_servo_move_to,
params.getHorizontalMotor_standbyPos(), params.getHorizontalMotor_standbyPos(),
params.getActionOvertime() params.getActionOvertime()
); );
@ -227,14 +255,14 @@ public class SamplesPreProcessModuleCtrlService {
var params = this.samplesPreProcessModuleCtrlParamsService; var params = this.samplesPreProcessModuleCtrlParamsService;
this.a8kCanBusService.callblockcmd( this.a8kCanBusService.callblockcmd(
ModuleId.ShakeModGripperYM, ModuleId.ShakeModGripperYM,
CmdId.kstep_motor_easy_move_to,
CmdId.kmini_servo_move_to,
params.getHorizontalMotor_takePushCapPos(), params.getHorizontalMotor_takePushCapPos(),
params.getActionOvertime() params.getActionOvertime()
); );
this.a8kCanBusService.callblockcmd( this.a8kCanBusService.callblockcmd(
ModuleId.ShakeModGripperSV, ModuleId.ShakeModGripperSV,
CmdId.kstep_motor_easy_move_to,
CmdId.kmini_servo_move_to,
params.getGripperServo_standbyPos(), params.getGripperServo_standbyPos(),
params.getActionOvertime() params.getActionOvertime()
); );
@ -253,7 +281,7 @@ public class SamplesPreProcessModuleCtrlService {
this.a8kCanBusService.callblockcmd( this.a8kCanBusService.callblockcmd(
ModuleId.ShakeModGripperSV, ModuleId.ShakeModGripperSV,
CmdId.kstep_motor_easy_move_to,
CmdId.kmini_servo_move_to,
params.getGripperServo_standbyPos(), params.getGripperServo_standbyPos(),
params.getActionOvertime() params.getActionOvertime()
); );
@ -267,7 +295,7 @@ public class SamplesPreProcessModuleCtrlService {
this.a8kCanBusService.callblockcmd( this.a8kCanBusService.callblockcmd(
ModuleId.ShakeModGripperYM, ModuleId.ShakeModGripperYM,
CmdId.kstep_motor_easy_move_to,
CmdId.kmini_servo_move_to,
params.getHorizontalMotor_standbyPos(), params.getHorizontalMotor_standbyPos(),
params.getActionOvertime() params.getActionOvertime()
); );
@ -281,14 +309,14 @@ public class SamplesPreProcessModuleCtrlService {
var params = this.samplesPreProcessModuleCtrlParamsService; var params = this.samplesPreProcessModuleCtrlParamsService;
this.a8kCanBusService.callblockcmd( this.a8kCanBusService.callblockcmd(
ModuleId.ShakeModGripperYM, ModuleId.ShakeModGripperYM,
CmdId.kstep_motor_easy_move_to,
CmdId.kmini_servo_move_to,
params.getHorizontalMotor_takePushCapPos(), params.getHorizontalMotor_takePushCapPos(),
params.getActionOvertime() params.getActionOvertime()
); );
this.a8kCanBusService.callblockcmd( this.a8kCanBusService.callblockcmd(
ModuleId.ShakeModGripperSV, ModuleId.ShakeModGripperSV,
CmdId.kstep_motor_easy_move_to,
CmdId.kmini_servo_move_to,
params.getGripperServo_standbyPos(), params.getGripperServo_standbyPos(),
params.getActionOvertime() params.getActionOvertime()
); );
@ -307,7 +335,7 @@ public class SamplesPreProcessModuleCtrlService {
this.a8kCanBusService.callblockcmd( this.a8kCanBusService.callblockcmd(
ModuleId.ShakeModGripperSV, ModuleId.ShakeModGripperSV,
CmdId.kstep_motor_easy_move_to,
CmdId.kmini_servo_move_to,
params.getGripperServo_standbyPos(), params.getGripperServo_standbyPos(),
params.getActionOvertime() params.getActionOvertime()
); );
@ -319,9 +347,46 @@ public class SamplesPreProcessModuleCtrlService {
params.getActionOvertime() params.getActionOvertime()
); );
// 前后移至试管架取试管位置
this.a8kCanBusService.callblockcmd( this.a8kCanBusService.callblockcmd(
ModuleId.ShakeModGripperYM, ModuleId.ShakeModGripperYM,
CmdId.kmini_servo_move_to,
params.getHorizontalMotor_takeCapPos(),
params.getActionOvertime()
);
// 升降放入试管至试管架
var motorUdTubePutPos = params.getZMotor_ShortBloodTakeCapHeight();
if ( tubeTypeValue.equals(A8kTubeType.HighBlood) ) {
motorUdTubePutPos = params.getZMotor_HighBloodTakeCapHeight();
}
this.a8kCanBusService.callblockcmd(
ModuleId.ShakeModGripperZM,
CmdId.kstep_motor_easy_move_to, CmdId.kstep_motor_easy_move_to,
motorUdTubePutPos,
params.getActionOvertime()
);
// 夹爪张开
this.a8kCanBusService.callblockcmd(
ModuleId.ShakeModGripperSV,
CmdId.kmini_servo_move_to,
params.getGripperServo_standbyPos(),
params.getActionOvertime()
);
// 升降电机复位
this.a8kCanBusService.callblockcmd(
ModuleId.ShakeModGripperZM,
CmdId.kstep_motor_easy_move_to,
0,
params.getActionOvertime()
);
// 前后电机复位
this.a8kCanBusService.callblockcmd(
ModuleId.ShakeModGripperYM,
CmdId.kmini_servo_move_to,
params.getHorizontalMotor_standbyPos(), params.getHorizontalMotor_standbyPos(),
params.getActionOvertime() params.getActionOvertime()
); );
@ -338,7 +403,7 @@ public class SamplesPreProcessModuleCtrlService {
* @param times 摇匀次数 * @param times 摇匀次数
* @param shakeDegree 摇匀角度 * @param shakeDegree 摇匀角度
*/ */
public void ShakeTube(String tubeType, int times, int shakeDegree) throws HardwareException, InterruptedException {
public void ShakeTube(String tubeType, Integer times, Integer shakeDegree) throws HardwareException, InterruptedException {
var params = this.samplesPreProcessModuleCtrlParamsService; var params = this.samplesPreProcessModuleCtrlParamsService;
var standByPos = params.getShakeMotor_standbyPos(); var standByPos = params.getShakeMotor_standbyPos();
var startPos = standByPos - shakeDegree/2; var startPos = standByPos - shakeDegree/2;

Loading…
Cancel
Save