19 changed files with 351 additions and 61 deletions
-
5src/main/java/com/iflytop/gd/debug/controller/CmdDebugController.java
-
4src/main/java/com/iflytop/gd/debug/services/cmds/DoorStopCommandHandler.java
-
42src/main/java/com/iflytop/gd/infrastructure/devices/MotorDrivenDoor.java
-
24src/main/java/com/iflytop/gd/infrastructure/devices/MotorDrivenLiquidFillingArm.java
-
38src/main/java/com/iflytop/gd/infrastructure/devices/MotorDrivenTransportationArm.java
-
2src/main/java/com/iflytop/gd/infrastructure/devices/StandardStepMotor.java
-
28src/main/java/com/iflytop/gd/infrastructure/devices/VirtualLiquidFillingArm.java
-
28src/main/java/com/iflytop/gd/infrastructure/devices/VirtualStepMotor.java
-
92src/main/java/com/iflytop/gd/infrastructure/devices/VirtualTransportationArm.java
-
9src/main/java/com/iflytop/gd/system/constants/SpeedUnit.java
-
2src/main/java/com/iflytop/gd/system/devices/Door.java
-
6src/main/java/com/iflytop/gd/system/devices/LiquidFillingArm.java
-
12src/main/java/com/iflytop/gd/system/devices/ServoMotor.java
-
2src/main/java/com/iflytop/gd/system/devices/StepMotor.java
-
10src/main/java/com/iflytop/gd/system/devices/TransportationArm.java
-
35src/main/resources/application-dev.yml
-
35src/main/resources/application-test.yml
-
36src/main/resources/application.yml
-
2src/main/resources/logback.xml
@ -1,32 +1,70 @@ |
|||||
package com.iflytop.gd.infrastructure.devices; |
package com.iflytop.gd.infrastructure.devices; |
||||
|
|
||||
|
import com.iflytop.gd.common.exception.AppException; |
||||
|
import com.iflytop.gd.common.result.ResultCode; |
||||
import com.iflytop.gd.infrastructure.drivers.ModuleId; |
import com.iflytop.gd.infrastructure.drivers.ModuleId; |
||||
|
import com.iflytop.gd.system.constants.DistanceUnit; |
||||
import com.iflytop.gd.system.devices.Door; |
import com.iflytop.gd.system.devices.Door; |
||||
import com.iflytop.gd.system.devices.StepMotor; |
import com.iflytop.gd.system.devices.StepMotor; |
||||
import com.iflytop.gd.system.drivers.CommandBus; |
import com.iflytop.gd.system.drivers.CommandBus; |
||||
|
import com.iflytop.gd.system.exceptions.CommandExecTimeoutException; |
||||
|
import com.iflytop.gd.system.exceptions.HardwareErrorException; |
||||
|
import org.springframework.context.annotation.Profile; |
||||
import org.springframework.stereotype.Component; |
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
import java.io.IOException; |
||||
|
|
||||
/** |
/** |
||||
* 步进电机驱动的门实现 |
* 步进电机驱动的门实现 |
||||
*/ |
*/ |
||||
|
@Profile("test") |
||||
@Component |
@Component |
||||
public class MotorDrivenDoor implements Door { |
public class MotorDrivenDoor implements Door { |
||||
|
|
||||
private final StepMotor doorMotor; |
private final StepMotor doorMotor; |
||||
|
|
||||
public MotorDrivenDoor(CommandBus commandBus) { |
public MotorDrivenDoor(CommandBus commandBus) { |
||||
this.doorMotor = new StandardStepMotor(ModuleId.DoorM, commandBus); |
|
||||
|
this.doorMotor = new VirtualStepMotor(ModuleId.DoorM); |
||||
} |
} |
||||
|
|
||||
@Override |
@Override |
||||
public void open() { |
public void open() { |
||||
|
|
||||
|
try { |
||||
|
doorMotor.easyMoveTo(100, DistanceUnit.MM); |
||||
|
} catch (HardwareErrorException e) { |
||||
|
throw new AppException(ResultCode.HARDWARE_ERROR); |
||||
|
} catch (CommandExecTimeoutException e) { |
||||
|
throw new AppException(ResultCode.COMMAND_EXEC_TIMEOUT); |
||||
|
} catch (IOException | InterruptedException e) { |
||||
|
throw new AppException(ResultCode.SYSTEM_ERROR); |
||||
|
} |
||||
} |
} |
||||
|
|
||||
|
|
||||
@Override |
@Override |
||||
public void close() { |
public void close() { |
||||
|
try { |
||||
|
doorMotor.easyMoveToZero(); |
||||
|
} catch (HardwareErrorException e) { |
||||
|
throw new AppException(ResultCode.HARDWARE_ERROR); |
||||
|
} catch (CommandExecTimeoutException e) { |
||||
|
throw new AppException(ResultCode.COMMAND_EXEC_TIMEOUT); |
||||
|
} catch (IOException | InterruptedException e) { |
||||
|
throw new AppException(ResultCode.SYSTEM_ERROR); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void stop() { |
||||
|
try { |
||||
|
doorMotor.stop(); |
||||
|
} catch (HardwareErrorException e) { |
||||
|
throw new AppException(ResultCode.HARDWARE_ERROR); |
||||
|
} catch (CommandExecTimeoutException e) { |
||||
|
throw new AppException(ResultCode.COMMAND_EXEC_TIMEOUT); |
||||
|
} catch (IOException | InterruptedException e) { |
||||
|
throw new AppException(ResultCode.SYSTEM_ERROR); |
||||
|
} |
||||
} |
} |
||||
|
|
||||
} |
} |
@ -1,23 +1,51 @@ |
|||||
package com.iflytop.gd.infrastructure.devices; |
package com.iflytop.gd.infrastructure.devices; |
||||
|
|
||||
import com.iflytop.gd.infrastructure.drivers.ModuleId; |
import com.iflytop.gd.infrastructure.drivers.ModuleId; |
||||
|
import com.iflytop.gd.system.constants.Dim; |
||||
|
import com.iflytop.gd.system.constants.DistanceUnit; |
||||
|
import com.iflytop.gd.system.constants.SpeedUnit; |
||||
import com.iflytop.gd.system.devices.StepMotor; |
import com.iflytop.gd.system.devices.StepMotor; |
||||
|
import com.iflytop.gd.system.devices.TransportationArm; |
||||
import com.iflytop.gd.system.drivers.CommandBus; |
import com.iflytop.gd.system.drivers.CommandBus; |
||||
|
import com.iflytop.gd.system.models.Point3D; |
||||
|
import org.springframework.context.annotation.Profile; |
||||
import org.springframework.stereotype.Component; |
import org.springframework.stereotype.Component; |
||||
|
|
||||
/** |
/** |
||||
* 试管转移机械臂 |
|
||||
|
* 电机驱动转移机械臂 |
||||
*/ |
*/ |
||||
|
@Profile("test") |
||||
@Component |
@Component |
||||
public class MotorDrivenTransportationArm { |
|
||||
|
public class MotorDrivenTransportationArm implements TransportationArm { |
||||
|
|
||||
private StepMotor xDimMotor; |
|
||||
private StepMotor yDimMotor; |
|
||||
private StepMotor zDimMotor; |
|
||||
|
private final StepMotor xDimMotor; |
||||
|
private final StepMotor yDimMotor; |
||||
|
private final StepMotor zDimMotor; |
||||
|
|
||||
public MotorDrivenTransportationArm(CommandBus commandBus) { |
public MotorDrivenTransportationArm(CommandBus commandBus) { |
||||
this.xDimMotor = new StandardStepMotor(ModuleId.HBotXM, commandBus); |
this.xDimMotor = new StandardStepMotor(ModuleId.HBotXM, commandBus); |
||||
this.yDimMotor = new StandardStepMotor(ModuleId.HBotYM, commandBus); |
this.yDimMotor = new StandardStepMotor(ModuleId.HBotYM, commandBus); |
||||
this.zDimMotor = new StandardStepMotor(ModuleId.HBotZM, commandBus); |
this.zDimMotor = new StandardStepMotor(ModuleId.HBotZM, commandBus); |
||||
} |
} |
||||
|
|
||||
|
@Override |
||||
|
public void moveTo(Dim dim, Integer distance, DistanceUnit unit) { |
||||
|
|
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void relativelyMove(Dim dim, Integer distance, DistanceUnit unit) { |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
@Override |
||||
|
public void stop(Dim dim) { |
||||
|
|
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void setSpeed(Dim dim, Integer speed, SpeedUnit unit) { |
||||
|
|
||||
|
} |
||||
} |
} |
@ -0,0 +1,28 @@ |
|||||
|
package com.iflytop.gd.infrastructure.devices; |
||||
|
|
||||
|
import com.iflytop.gd.system.constants.LiquidFillArmMotorIndex; |
||||
|
import com.iflytop.gd.system.constants.RotationDirection; |
||||
|
import com.iflytop.gd.system.constants.SpeedUnit; |
||||
|
import com.iflytop.gd.system.devices.LiquidFillingArm; |
||||
|
import com.iflytop.gd.system.models.Point3D; |
||||
|
import org.springframework.context.annotation.Profile; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
/** |
||||
|
* 虚拟加液机械臂 |
||||
|
*/ |
||||
|
@Profile("dev") |
||||
|
@Component |
||||
|
public class VirtualLiquidFillingArm implements LiquidFillingArm { |
||||
|
@Override |
||||
|
public void moveTo(Point3D point) { |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void rotateTo(LiquidFillArmMotorIndex liquidFillArmMotorIndex, Integer angle, RotationDirection direction) { |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void setRotationSpeed(Integer speed, SpeedUnit speedUnit) { |
||||
|
} |
||||
|
} |
@ -0,0 +1,92 @@ |
|||||
|
package com.iflytop.gd.infrastructure.devices; |
||||
|
|
||||
|
import com.iflytop.gd.common.exception.AppException; |
||||
|
import com.iflytop.gd.common.result.ResultCode; |
||||
|
import com.iflytop.gd.infrastructure.drivers.ModuleId; |
||||
|
import com.iflytop.gd.system.constants.Dim; |
||||
|
import com.iflytop.gd.system.constants.DistanceUnit; |
||||
|
import com.iflytop.gd.system.constants.SpeedUnit; |
||||
|
import com.iflytop.gd.system.devices.StepMotor; |
||||
|
import com.iflytop.gd.system.devices.TransportationArm; |
||||
|
import com.iflytop.gd.system.exceptions.CommandExecTimeoutException; |
||||
|
import com.iflytop.gd.system.exceptions.HardwareErrorException; |
||||
|
import com.iflytop.gd.system.models.Point3D; |
||||
|
import org.springframework.context.annotation.Profile; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
import java.io.IOException; |
||||
|
import java.util.HashMap; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 虚拟转移机械臂 |
||||
|
*/ |
||||
|
@Component |
||||
|
@Profile("dev") |
||||
|
public class VirtualTransportationArm implements TransportationArm { |
||||
|
private final StepMotor xDimMotor; |
||||
|
private final StepMotor yDimMotor; |
||||
|
private final StepMotor zDimMotor; |
||||
|
private final Map<Dim, StepMotor> stepMotors = new HashMap<Dim, StepMotor>(); |
||||
|
|
||||
|
public VirtualTransportationArm() { |
||||
|
this.xDimMotor = new VirtualStepMotor(ModuleId.HBotXM); |
||||
|
this.yDimMotor = new VirtualStepMotor(ModuleId.HBotYM); |
||||
|
this.zDimMotor = new VirtualStepMotor(ModuleId.HBotZM); |
||||
|
stepMotors.put(Dim.X, xDimMotor); |
||||
|
stepMotors.put(Dim.Y, yDimMotor); |
||||
|
stepMotors.put(Dim.Z, zDimMotor); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void moveTo(Dim dim, Integer distance, DistanceUnit unit) { |
||||
|
try { |
||||
|
stepMotors.get(dim).easyMoveTo(distance, unit); |
||||
|
} catch (HardwareErrorException e) { |
||||
|
throw new AppException(ResultCode.HARDWARE_ERROR); |
||||
|
} catch (CommandExecTimeoutException e) { |
||||
|
throw new AppException(ResultCode.COMMAND_EXEC_TIMEOUT); |
||||
|
} catch (IOException | InterruptedException e) { |
||||
|
throw new AppException(ResultCode.SYSTEM_ERROR); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void relativelyMove(Dim dim, Integer distance, DistanceUnit unit) { |
||||
|
try { |
||||
|
stepMotors.get(dim).easyMoveBy(distance, unit); |
||||
|
} catch (HardwareErrorException e) { |
||||
|
throw new AppException(ResultCode.HARDWARE_ERROR); |
||||
|
} catch (CommandExecTimeoutException e) { |
||||
|
throw new AppException(ResultCode.COMMAND_EXEC_TIMEOUT); |
||||
|
} catch (IOException | InterruptedException e) { |
||||
|
throw new AppException(ResultCode.SYSTEM_ERROR); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void stop(Dim dim) { |
||||
|
try { |
||||
|
stepMotors.get(dim).stop(); |
||||
|
} catch (HardwareErrorException e) { |
||||
|
throw new AppException(ResultCode.HARDWARE_ERROR); |
||||
|
} catch (CommandExecTimeoutException e) { |
||||
|
throw new AppException(ResultCode.COMMAND_EXEC_TIMEOUT); |
||||
|
} catch (IOException | InterruptedException e) { |
||||
|
throw new AppException(ResultCode.SYSTEM_ERROR); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void setSpeed(Dim dim, Integer speed, SpeedUnit unit) { |
||||
|
try { |
||||
|
stepMotors.get(dim).setDefaultVelocity(unit.toMM_PER_SEC(speed)); |
||||
|
} catch (HardwareErrorException e) { |
||||
|
throw new AppException(ResultCode.HARDWARE_ERROR); |
||||
|
} catch (CommandExecTimeoutException e) { |
||||
|
throw new AppException(ResultCode.COMMAND_EXEC_TIMEOUT); |
||||
|
} catch (IOException | InterruptedException e) { |
||||
|
throw new AppException(ResultCode.SYSTEM_ERROR); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,35 @@ |
|||||
|
server: |
||||
|
servlet: |
||||
|
context-path: / |
||||
|
port: 8080 |
||||
|
|
||||
|
spring: |
||||
|
application: |
||||
|
name: graphite_digestion_service |
||||
|
datasource: |
||||
|
url: jdbc:sqlite:db/app.db |
||||
|
driver-class-name: org.sqlite.JDBC |
||||
|
sql: |
||||
|
init: |
||||
|
#always embedded never |
||||
|
mode: always |
||||
|
schema-locations: classpath:/sql/init.sql |
||||
|
|
||||
|
mybatis-plus: |
||||
|
configuration: |
||||
|
# 开启 SQL 日志输出(可选) |
||||
|
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl |
||||
|
# 如果需要加载 XML 文件(自定义 SQL),可配置 mapper-locations: |
||||
|
mapper-locations: classpath*:mapper/*.xml |
||||
|
|
||||
|
#开启 SQL 打印,调试时方便查看 |
||||
|
logging: |
||||
|
level: |
||||
|
root: INFO |
||||
|
org.mybatis: DEBUG |
||||
|
|
||||
|
springdoc: |
||||
|
default-flat-param-object: true |
||||
|
|
||||
|
command_bus: |
||||
|
websocket_server_url: ws://127.0.0.1 |
@ -0,0 +1,35 @@ |
|||||
|
server: |
||||
|
servlet: |
||||
|
context-path: / |
||||
|
port: 8080 |
||||
|
|
||||
|
spring: |
||||
|
application: |
||||
|
name: graphite_digestion_service |
||||
|
datasource: |
||||
|
url: jdbc:sqlite:db/app.db |
||||
|
driver-class-name: org.sqlite.JDBC |
||||
|
sql: |
||||
|
init: |
||||
|
#always embedded never |
||||
|
mode: always |
||||
|
schema-locations: classpath:/sql/init.sql |
||||
|
|
||||
|
mybatis-plus: |
||||
|
configuration: |
||||
|
# 开启 SQL 日志输出(可选) |
||||
|
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl |
||||
|
# 如果需要加载 XML 文件(自定义 SQL),可配置 mapper-locations: |
||||
|
mapper-locations: classpath*:mapper/*.xml |
||||
|
|
||||
|
#开启 SQL 打印,调试时方便查看 |
||||
|
logging: |
||||
|
level: |
||||
|
root: INFO |
||||
|
org.mybatis: DEBUG |
||||
|
|
||||
|
springdoc: |
||||
|
default-flat-param-object: true |
||||
|
|
||||
|
command_bus: |
||||
|
websocket_server_url: ws://127.0.0.1 |
@ -1,35 +1,3 @@ |
|||||
server: |
|
||||
servlet: |
|
||||
context-path: / |
|
||||
port: 8080 |
|
||||
|
|
||||
spring: |
spring: |
||||
application: |
|
||||
name: graphite_digestion_service |
|
||||
datasource: |
|
||||
url: jdbc:sqlite:db/app.db |
|
||||
driver-class-name: org.sqlite.JDBC |
|
||||
sql: |
|
||||
init: |
|
||||
#always embedded never |
|
||||
mode: always |
|
||||
schema-locations: classpath:/sql/init.sql |
|
||||
|
|
||||
mybatis-plus: |
|
||||
configuration: |
|
||||
# 开启 SQL 日志输出(可选) |
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl |
|
||||
# 如果需要加载 XML 文件(自定义 SQL),可配置 mapper-locations: |
|
||||
mapper-locations: classpath*:mapper/*.xml |
|
||||
|
|
||||
#开启 SQL 打印,调试时方便查看 |
|
||||
logging: |
|
||||
level: |
|
||||
root: INFO |
|
||||
org.mybatis: DEBUG |
|
||||
|
|
||||
springdoc: |
|
||||
default-flat-param-object: true |
|
||||
|
|
||||
command_bus: |
|
||||
websocket_server_url: ws://127.0.0.1 |
|
||||
|
profiles: |
||||
|
active: dev |
Write
Preview
Loading…
Cancel
Save
Reference in new issue