9 changed files with 219 additions and 69 deletions
-
4src/main/java/com/iflytop/gd/common/result/ResultCode.java
-
14src/main/java/com/iflytop/gd/system/constants/DistanceUnit.java
-
46src/main/java/com/iflytop/gd/system/devices/BaseStepStepMotor.java
-
21src/main/java/com/iflytop/gd/system/devices/LiquidFillingArm.java
-
153src/main/java/com/iflytop/gd/system/devices/StandardStepMotor.java
-
10src/main/java/com/iflytop/gd/system/devices/StepMotor.java
-
22src/main/java/com/iflytop/gd/system/devices/TransportationArm.java
-
9src/main/java/com/iflytop/gd/system/models/LiquidFillingArm.java
-
9src/main/java/com/iflytop/gd/system/models/TubeTransportationArm.java
@ -1,5 +1,17 @@ |
|||
package com.iflytop.gd.system.constants; |
|||
|
|||
public enum DistanceUnit { |
|||
MM, CM |
|||
MM, CM; |
|||
|
|||
public Integer toMM(Integer value) { |
|||
if (this == MM) { |
|||
return value; |
|||
} |
|||
|
|||
if (this == CM) { |
|||
return value * 10; |
|||
} |
|||
|
|||
return value; |
|||
} |
|||
} |
@ -1,46 +0,0 @@ |
|||
package com.iflytop.gd.system.devices; |
|||
|
|||
import com.iflytop.gd.infrastructure.drivers.CmdId; |
|||
import com.iflytop.gd.infrastructure.drivers.ModuleId; |
|||
import com.iflytop.gd.system.constants.DistanceUnit; |
|||
import com.iflytop.gd.system.constants.SpeedUnit; |
|||
import com.iflytop.gd.system.drivers.CommandBus; |
|||
import com.iflytop.gd.system.exceptions.CommandExecTimeoutException; |
|||
import com.iflytop.gd.system.exceptions.HardwareErrorException; |
|||
import com.iflytop.gd.system.models.DataPacket; |
|||
|
|||
import java.io.IOException; |
|||
import java.util.concurrent.TimeUnit; |
|||
|
|||
public abstract class BaseStepStepMotor implements StepMotor { |
|||
protected final ModuleId moduleId; |
|||
protected final CommandBus commandBus; |
|||
protected final Integer DEFAULT_COMMAND_EXEC_TIMEOUT_SECONDS = 10; |
|||
|
|||
protected BaseStepStepMotor(ModuleId moduleId, CommandBus commandBus) { |
|||
this.moduleId = moduleId; |
|||
this.commandBus = commandBus; |
|||
} |
|||
|
|||
|
|||
@Override |
|||
public void easyMoveTo(Integer value, DistanceUnit unit) { |
|||
DataPacket commandDataPacket = DataPacket.createCommandDataPacket(moduleId.index, CmdId.step_motor_easy_move_to.index, value); |
|||
try { |
|||
commandBus.waitForCommandExec(commandDataPacket, DEFAULT_COMMAND_EXEC_TIMEOUT_SECONDS, TimeUnit.SECONDS); |
|||
} catch (CommandExecTimeoutException e) { |
|||
throw new RuntimeException(e); |
|||
} catch (HardwareErrorException e) { |
|||
throw new RuntimeException(e); |
|||
} catch (IOException e) { |
|||
throw new RuntimeException(e); |
|||
} catch (InterruptedException e) { |
|||
throw new RuntimeException(e); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public void easyMoveBy(Integer value, DistanceUnit unit) { |
|||
|
|||
} |
|||
} |
@ -0,0 +1,21 @@ |
|||
package com.iflytop.gd.system.devices; |
|||
|
|||
|
|||
import com.iflytop.gd.infrastructure.drivers.ModuleId; |
|||
import com.iflytop.gd.system.drivers.CommandBus; |
|||
import jakarta.annotation.Resource; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* 液体加注机械臂 |
|||
*/ |
|||
@Component |
|||
public class LiquidFillingArm { |
|||
private final StepMotor largeArmMotor; |
|||
private final StepMotor smallArmMotor; |
|||
|
|||
public LiquidFillingArm(CommandBus commandBus) { |
|||
this.largeArmMotor = new StandardStepMotor(ModuleId.DualRobotAxis1M, commandBus); |
|||
this.smallArmMotor = new StandardStepMotor(ModuleId.DualRobotAxis2M, commandBus); |
|||
} |
|||
} |
@ -0,0 +1,153 @@ |
|||
package com.iflytop.gd.system.devices; |
|||
|
|||
import com.iflytop.gd.infrastructure.drivers.CmdId; |
|||
import com.iflytop.gd.infrastructure.drivers.ModuleId; |
|||
import com.iflytop.gd.system.constants.DistanceUnit; |
|||
import com.iflytop.gd.system.constants.RotationDirection; |
|||
import com.iflytop.gd.system.drivers.CommandBus; |
|||
import com.iflytop.gd.system.exceptions.CommandExecTimeoutException; |
|||
import com.iflytop.gd.system.exceptions.HardwareErrorException; |
|||
import com.iflytop.gd.system.models.DataPacket; |
|||
|
|||
import java.io.IOException; |
|||
import java.util.concurrent.TimeUnit; |
|||
|
|||
public class StandardStepMotor implements StepMotor { |
|||
protected final ModuleId moduleId; |
|||
protected final CommandBus commandBus; |
|||
protected final Integer DEFAULT_COMMAND_EXEC_TIMEOUT_SECONDS = 10; |
|||
|
|||
protected StandardStepMotor(ModuleId moduleId, CommandBus commandBus) { |
|||
this.moduleId = moduleId; |
|||
this.commandBus = commandBus; |
|||
} |
|||
|
|||
|
|||
@Override |
|||
public void easyMoveTo(Integer value, DistanceUnit unit) throws HardwareErrorException, CommandExecTimeoutException, IOException, InterruptedException { |
|||
DataPacket commandDataPacket = DataPacket.createCommandDataPacket(moduleId.index, CmdId.step_motor_easy_move_to.index, unit.toMM(value)); |
|||
commandBus.waitForCommandExec(commandDataPacket, DEFAULT_COMMAND_EXEC_TIMEOUT_SECONDS, TimeUnit.SECONDS); |
|||
} |
|||
|
|||
@Override |
|||
public void easyMoveBy(Integer value, DistanceUnit unit) throws HardwareErrorException, CommandExecTimeoutException, IOException, InterruptedException { |
|||
DataPacket commandDataPacket = DataPacket.createCommandDataPacket(moduleId.index, CmdId.step_motor_easy_move_by.index, unit.toMM(value)); |
|||
commandBus.waitForCommandExec(commandDataPacket, DEFAULT_COMMAND_EXEC_TIMEOUT_SECONDS, TimeUnit.SECONDS); |
|||
} |
|||
|
|||
@Override |
|||
public void easyMoveToZero() throws HardwareErrorException, CommandExecTimeoutException, IOException, InterruptedException { |
|||
DataPacket commandDataPacket = DataPacket.createCommandDataPacket(moduleId.index, CmdId.step_motor_easy_move_to_zero.index); |
|||
commandBus.waitForCommandExec(commandDataPacket, DEFAULT_COMMAND_EXEC_TIMEOUT_SECONDS, TimeUnit.SECONDS); |
|||
} |
|||
|
|||
@Override |
|||
public void setCurrentPosition(Integer value) { |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void easyMoveToZeroPointQuick() { |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void easyMoveToEndPoint() { |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void enable() { |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public Integer readPosition() { |
|||
return 0; |
|||
} |
|||
|
|||
@Override |
|||
public Integer readEncoderPosition() { |
|||
return 0; |
|||
} |
|||
|
|||
@Override |
|||
public void easyRotate(RotationDirection direction) { |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void easyMoveByBlock() { |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void easyMoveToBlock() { |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void easyMoveToZeroBlock() { |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void readPositionByMoveToZeroBlock() { |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void easyMoveToZeroPointQuickBlock() { |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void stop() { |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void moveByBlock() { |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void moveTOBlock() { |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void rotate() { |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public Boolean readIOState() { |
|||
return null; |
|||
} |
|||
|
|||
@Override |
|||
public void easyReciprocatingMotion() { |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void easyReciprocatingMotionBlock() { |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public Boolean isReturnToZero() { |
|||
return null; |
|||
} |
|||
|
|||
@Override |
|||
public void setReg() { |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public Integer readReg() { |
|||
return 0; |
|||
} |
|||
} |
@ -0,0 +1,22 @@ |
|||
package com.iflytop.gd.system.devices; |
|||
|
|||
import com.iflytop.gd.infrastructure.drivers.ModuleId; |
|||
import com.iflytop.gd.system.drivers.CommandBus; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* 试管转移机械臂 |
|||
*/ |
|||
@Component |
|||
public class TransportationArm { |
|||
|
|||
private StepMotor xDimMotor; |
|||
private StepMotor yDimMotor; |
|||
private StepMotor zDimMotor; |
|||
|
|||
public TransportationArm(CommandBus commandBus) { |
|||
this.xDimMotor = new StandardStepMotor(ModuleId.HBotXM, commandBus); |
|||
this.yDimMotor = new StandardStepMotor(ModuleId.HBotYM, commandBus); |
|||
this.zDimMotor = new StandardStepMotor(ModuleId.HBotZM, commandBus); |
|||
} |
|||
} |
@ -1,9 +0,0 @@ |
|||
package com.iflytop.gd.system.models; |
|||
|
|||
|
|||
/** |
|||
* 液体加注机械臂 |
|||
*/ |
|||
public interface LiquidFillingArm { |
|||
|
|||
} |
@ -1,9 +0,0 @@ |
|||
package com.iflytop.gd.system.models; |
|||
|
|||
/** |
|||
* 试管转移机械臂 |
|||
*/ |
|||
public interface TubeTransportationArm { |
|||
|
|||
|
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue