|
|
@ -40,9 +40,9 @@ public class A8kCanBusConnection extends WebSocketClient { |
|
|
|
|
|
|
|
|
|
|
|
static class ProcessContext { |
|
|
|
BlockingQueue<A8kPacket> receiptQueue = new LinkedBlockingQueue<>(); // |
|
|
|
int waitingReceiptIndex = 0;// |
|
|
|
Map<MId, CmdId> txcmdcache = new HashMap<>(); |
|
|
|
BlockingQueue<A8kPacket> receiptQueue = new LinkedBlockingQueue<>(); // |
|
|
|
A8kPacket cmdPacket; |
|
|
|
Map<MId, CmdId> txcmdcache = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
public A8kPacket getReceipt(int overtime) { |
|
|
@ -61,17 +61,21 @@ public class A8kCanBusConnection extends WebSocketClient { |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
synchronized void pushReceipt(A8kPacket packet) { |
|
|
|
if (waitingReceiptIndex >= 0 && waitingReceiptIndex == packet.getPacketIndex()) { |
|
|
|
// log.debug("pushReceipt:| {}", packet); |
|
|
|
receiptQueue.add(packet); |
|
|
|
waitingReceiptIndex = -1; |
|
|
|
synchronized void pushReceipt(A8kPacket receipt) { |
|
|
|
if (this.cmdPacket != null |
|
|
|
&& this.cmdPacket.getPacketIndex() == receipt.getPacketIndex() |
|
|
|
&& this.cmdPacket.getModuleId() == receipt.getModuleId() |
|
|
|
&& this.cmdPacket.getCmdId() == receipt.getCmdId() |
|
|
|
) { |
|
|
|
// log.debug("pushReceipt:| {}", receipt); |
|
|
|
receiptQueue.add(receipt); |
|
|
|
this.cmdPacket = null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
synchronized void setWaitingReceiptIndex(int index) { |
|
|
|
synchronized void setWaitingReceiptIndex(A8kPacket cmdPacket) { |
|
|
|
receiptQueue.clear(); |
|
|
|
waitingReceiptIndex = index; |
|
|
|
this.cmdPacket = cmdPacket; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -148,6 +152,7 @@ public class A8kCanBusConnection extends WebSocketClient { |
|
|
|
MId.valueOf(getStatusPacket.getModuleId()), CmdId.valueOf(getStatusPacket.getCmdId()))); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// |
|
|
|
// PRIVATE |
|
|
|
// |
|
|
@ -173,7 +178,6 @@ public class A8kCanBusConnection extends WebSocketClient { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private A8kPacket autoReSend(A8kPacket pack, int overtime) throws AppException { |
|
|
|
if (firstCall) { |
|
|
|
firstCall = false; |
|
|
@ -192,17 +196,6 @@ public class A8kCanBusConnection extends WebSocketClient { |
|
|
|
OS.hsleep(50); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.error("send cmd {} {} fail, retry {}", pack, pack.toByteString(), i); |
|
|
|
} |
|
|
|
throw AppException.of(new AEHardwareError(A8kEcode.LOW_ERROR_OVERTIME, MId.valueOf(pack.getModuleId()), CmdId.valueOf(pack.getCmdId()))); |
|
|
@ -236,7 +229,7 @@ public class A8kCanBusConnection extends WebSocketClient { |
|
|
|
//set waiting receipt index |
|
|
|
pack.setPacketIndex(packetIndex); |
|
|
|
context.storageTxLastCmd(pack); |
|
|
|
context.setWaitingReceiptIndex(packetIndex); |
|
|
|
context.setWaitingReceiptIndex(pack); |
|
|
|
|
|
|
|
// TX packet |
|
|
|
String txpacket = pack.toByteString(); |
|
|
|