|
|
@ -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,51 +295,67 @@ 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[] {}); |
|
|
|
return this.callcmd(moduleId, cmdId, new Integer[]{}); |
|
|
|
} |
|
|
|
|
|
|
|
public A8kPacket callcmd(Integer moduleId, Integer cmdId, Integer p0) throws HardwareException { |
|
|
|
return this.callcmd(moduleId, cmdId, new Integer[] { p0 }); |
|
|
|
return this.callcmd(moduleId, cmdId, new Integer[]{p0}); |
|
|
|
} |
|
|
|
|
|
|
|
public A8kPacket callcmd(Integer moduleId, Integer cmdId, Integer p0, Integer p1) throws HardwareException { |
|
|
|
return this.callcmd(moduleId, cmdId, new Integer[] { p0, p1 }); |
|
|
|
return this.callcmd(moduleId, cmdId, new Integer[]{p0, p1}); |
|
|
|
} |
|
|
|
|
|
|
|
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) 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 { |
|
|
|
return this.callcmd(moduleId, cmdId, new Integer[] { p0, p1, p2, p3 }); |
|
|
|
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 { |
|
|
|
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 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 { |
|
|
|
this.callblockcmd(moduleId, cmdId, new Integer[] { p0, p1, p2 }, acitionOvertime); |
|
|
|
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 { |
|
|
|
this.callblockcmd(moduleId, cmdId, new Integer[] { p0, p1 }, acitionOvertime); |
|
|
|
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 { |
|
|
|
this.callblockcmd(moduleId, cmdId, new Integer[] { p0 }, acitionOvertime); |
|
|
|
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 { |
|
|
|
this.callblockcmd(moduleId, cmdId, new Integer[] {}, acitionOvertime); |
|
|
|
public void callblockcmd(Integer moduleId, Integer cmdId, Integer acitionOvertime) throws HardwareException, InterruptedException { |
|
|
|
this.callblockcmd(moduleId, cmdId, new Integer[]{}, acitionOvertime); |
|
|
|
} |
|
|
|
|
|
|
|
// TODO |
|
|
@ -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); |
|
|
|
|
|
|
@ -385,7 +399,7 @@ public class A8kCanBusService { |
|
|
|
|
|
|
|
long startedAt = System.currentTimeMillis(); |
|
|
|
do { |
|
|
|
var pack = this.callcmd(moduleId, CmdId.kmodule_get_status, new Integer[] {}); |
|
|
|
var pack = this.callcmd(moduleId, CmdId.kmodule_get_status, new Integer[]{}); |
|
|
|
var status = pack.getContentI32(0); |
|
|
|
if (0 == status) { |
|
|
|
break; |
|
|
@ -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); |
|
|
|