|
|
@ -1,6 +1,7 @@ |
|
|
|
package iflytop.app.hardware.driver; |
|
|
|
|
|
|
|
import com.fasterxml.jackson.databind.node.ObjectNode; |
|
|
|
import iflytop.app.config.ActionOvertimeConstant; |
|
|
|
import iflytop.app.hardware.channel.A8kCanBusConnection; |
|
|
|
import iflytop.app.hardware.channel.A8kCanBusService; |
|
|
|
import iflytop.app.hardware.type.*; |
|
|
@ -15,7 +16,7 @@ import org.springframework.stereotype.Component; |
|
|
|
@RequiredArgsConstructor |
|
|
|
public class LeisaiServoDriver { |
|
|
|
final private A8kCanBusService canBus; |
|
|
|
static public final Integer actionOvertime = 10000; |
|
|
|
private final ActionOvertimeConstant actionOvertimeConstant; |
|
|
|
|
|
|
|
public void moduleStop(LeisaiServoMId id) throws HardwareException { |
|
|
|
log.info("moduleStop called with id: {}", id); |
|
|
@ -64,6 +65,29 @@ public class LeisaiServoDriver { |
|
|
|
canBus.moduleSetReg(id.mid, regindex.regIndex, val); |
|
|
|
} |
|
|
|
|
|
|
|
// ====== ===== ====== ===== ====== ===== Block ====== ===== ====== ===== ====== ===== |
|
|
|
public void moveToBlock(LeisaiServoMId id, LeisaiServoSpeedLevel speedLevel, Integer pos) throws HardwareException { |
|
|
|
log.info("moveToBlock called with id: {}, speedLevel: {}, pos: {}", id, speedLevel, pos); |
|
|
|
canBus.callcmd(id.mid, CmdId.leisai_servo_move_to, speedLevel.ordinal(), pos); |
|
|
|
waitForMod(id, actionOvertimeConstant.get(id.mid, CmdId.leisai_servo_move_to)); |
|
|
|
} |
|
|
|
|
|
|
|
public void moveByBlock(LeisaiServoMId id, LeisaiServoSpeedLevel speedLevel, Integer dpos) throws HardwareException { |
|
|
|
log.info("moveByBlock called with id: {}, speedLevel: {}, dpos: {}", id, speedLevel, dpos); |
|
|
|
canBus.callcmd(id.mid, CmdId.leisai_servo_move_by, speedLevel.ordinal(), dpos); |
|
|
|
waitForMod(id, actionOvertimeConstant.get(id.mid, CmdId.leisai_servo_move_by)); |
|
|
|
} |
|
|
|
|
|
|
|
public void moveToZeroBlock(LeisaiServoMId id) throws HardwareException { |
|
|
|
log.info("moveToZeroBlock called with id: {}", id); |
|
|
|
canBus.callcmd(id.mid, CmdId.leisai_servo_move_to_zero); |
|
|
|
waitForMod(id, actionOvertimeConstant.get(id.mid, CmdId.leisai_servo_move_to_zero)); |
|
|
|
} |
|
|
|
|
|
|
|
public void waitForMod(LeisaiServoMId id, Integer overtime) throws HardwareException { |
|
|
|
canBus.waitForMod(id.mid, overtime); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public Integer getReg(LeisaiServoMId id, LeisaiRegIndex regindex) throws HardwareException { |
|
|
|
log.info("getReg called with id: {}, regindex: {}", id, regindex); |
|
|
|