|
|
@ -111,8 +111,7 @@ public class A8kCanBusService { |
|
|
|
client.connect(); |
|
|
|
} catch (IllegalStateException e) { |
|
|
|
} |
|
|
|
} else if (client.getReadyState().equals(ReadyState.CLOSING) |
|
|
|
|| client.getReadyState().equals(ReadyState.CLOSED)) { |
|
|
|
} else if (client.getReadyState().equals(ReadyState.CLOSING) || client.getReadyState().equals(ReadyState.CLOSED)) { |
|
|
|
client.reconnect(); |
|
|
|
} |
|
|
|
} |
|
|
@ -296,6 +295,28 @@ public class A8kCanBusService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void waitForMod(Integer moduleId, Integer acitionOvertime) throws InterruptedException, HardwareException { |
|
|
|
long startedAt = System.currentTimeMillis(); |
|
|
|
do { |
|
|
|
try { |
|
|
|
var status = getModuleStatus(moduleId); |
|
|
|
if (status == ModuleStatus.IDLE) { |
|
|
|
break; |
|
|
|
} else if (status == ModuleStatus.ERROR) { |
|
|
|
throw new HardwareException(moduleId, moduleGetError(moduleId)); |
|
|
|
} |
|
|
|
} catch (HardwareException ignored) { |
|
|
|
} |
|
|
|
long now = System.currentTimeMillis(); |
|
|
|
if (now - startedAt > acitionOvertime) { |
|
|
|
throw new HardwareException(moduleId, Errorcode.kovertime); |
|
|
|
} |
|
|
|
|
|
|
|
Thread.sleep(100); |
|
|
|
} while (true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public A8kPacket callcmd(Integer moduleId, Integer cmdId) throws HardwareException { |
|
|
|
return this.callcmd(moduleId, cmdId, new Integer[]{}); |
|
|
|
} |
|
|
@ -308,38 +329,32 @@ public class A8kCanBusService { |
|
|
|
return this.callcmd(moduleId, cmdId, new Integer[]{p0, p1}); |
|
|
|
} |
|
|
|
|
|
|
|
public A8kPacket callcmd(Integer moduleId, Integer cmdId, Integer p0, Integer p1, Integer p2) |
|
|
|
throws HardwareException { |
|
|
|
public A8kPacket callcmd(Integer moduleId, Integer cmdId, Integer p0, Integer p1, Integer p2) throws HardwareException { |
|
|
|
return this.callcmd(moduleId, cmdId, new Integer[]{p0, p1, p2}); |
|
|
|
} |
|
|
|
|
|
|
|
public A8kPacket callcmd(Integer moduleId, Integer cmdId, Integer p0, Integer p1, Integer p2, Integer p3) |
|
|
|
throws HardwareException { |
|
|
|
public A8kPacket callcmd(Integer moduleId, Integer cmdId, Integer p0, Integer p1, Integer p2, Integer p3) throws HardwareException { |
|
|
|
return this.callcmd(moduleId, cmdId, new Integer[]{p0, p1, p2, p3}); |
|
|
|
} |
|
|
|
|
|
|
|
public void callblockcmd(Integer moduleId, Integer cmdId, Integer p0, Integer p1, Integer p2, Integer p3, |
|
|
|
Integer acitionOvertime) throws HardwareException, InterruptedException { |
|
|
|
|
|
|
|
public void callblockcmd(Integer moduleId, Integer cmdId, Integer p0, Integer p1, Integer p2, Integer p3, Integer acitionOvertime) throws HardwareException, InterruptedException { |
|
|
|
this.callblockcmd(moduleId, cmdId, new Integer[]{p0, p1, p2, p3}, acitionOvertime); |
|
|
|
} |
|
|
|
|
|
|
|
public void callblockcmd(Integer moduleId, Integer cmdId, Integer p0, Integer p1, Integer p2, |
|
|
|
Integer acitionOvertime) throws HardwareException, InterruptedException { |
|
|
|
public void callblockcmd(Integer moduleId, Integer cmdId, Integer p0, Integer p1, Integer p2, Integer acitionOvertime) throws HardwareException, InterruptedException { |
|
|
|
this.callblockcmd(moduleId, cmdId, new Integer[]{p0, p1, p2}, acitionOvertime); |
|
|
|
} |
|
|
|
|
|
|
|
public void callblockcmd(Integer moduleId, Integer cmdId, Integer p0, Integer p1, Integer acitionOvertime) |
|
|
|
throws HardwareException, InterruptedException { |
|
|
|
public void callblockcmd(Integer moduleId, Integer cmdId, Integer p0, Integer p1, Integer acitionOvertime) throws HardwareException, InterruptedException { |
|
|
|
this.callblockcmd(moduleId, cmdId, new Integer[]{p0, p1}, acitionOvertime); |
|
|
|
} |
|
|
|
|
|
|
|
public void callblockcmd(Integer moduleId, Integer cmdId, Integer p0, Integer acitionOvertime) |
|
|
|
throws HardwareException, InterruptedException { |
|
|
|
public void callblockcmd(Integer moduleId, Integer cmdId, Integer p0, Integer acitionOvertime) throws HardwareException, InterruptedException { |
|
|
|
this.callblockcmd(moduleId, cmdId, new Integer[]{p0}, acitionOvertime); |
|
|
|
} |
|
|
|
|
|
|
|
public void callblockcmd(Integer moduleId, Integer cmdId, Integer acitionOvertime) |
|
|
|
throws HardwareException, InterruptedException { |
|
|
|
public void callblockcmd(Integer moduleId, Integer cmdId, Integer acitionOvertime) throws HardwareException, InterruptedException { |
|
|
|
this.callblockcmd(moduleId, cmdId, new Integer[]{}, acitionOvertime); |
|
|
|
} |
|
|
|
|
|
|
@ -374,8 +389,7 @@ public class A8kCanBusService { |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
public void callblockcmd(Integer moduleId, Integer cmdId, Integer[] params, int acitionOvertime) |
|
|
|
throws HardwareException, InterruptedException { |
|
|
|
public void callblockcmd(Integer moduleId, Integer cmdId, Integer[] params, int acitionOvertime) throws HardwareException, InterruptedException { |
|
|
|
var packet = this.packParamsToPacket(moduleId, cmdId, params); |
|
|
|
this.sendCmdAutoResend(packet, A8kPacket.CMD_OVERTIME); |
|
|
|
|
|
|
@ -458,8 +472,7 @@ public class A8kCanBusService { |
|
|
|
logger.info("RX {}:({})", packet, rx); |
|
|
|
} |
|
|
|
|
|
|
|
if (packet.getPacketType() == A8kPacket.PACKET_TYPE_ACK |
|
|
|
|| packet.getPacketType() == A8kPacket.PACKET_TYPE_ERROR_ACK) { |
|
|
|
if (packet.getPacketType() == A8kPacket.PACKET_TYPE_ACK || packet.getPacketType() == A8kPacket.PACKET_TYPE_ERROR_ACK) { |
|
|
|
if (isWaitingReceipt) { |
|
|
|
if (waitingReceiptIndex == packet.getPacketIndex()) { |
|
|
|
receiptQueue.add(packet); |
|
|
|