Browse Source

fix some bug

tags/v0
zhaohe 1 year ago
parent
commit
30b8852431
  1. 14
      src/main/java/a8k/a8k_can_protocol/A8kPacket.java
  2. 48
      src/main/java/a8k/base_hardware/A8kCanBusService.java
  3. 12
      src/main/java/a8k/service/ctrl_service/DeviceInitializationCtrlService.java
  4. 2
      src/main/java/a8k/service/hardware/CommonHardwareOpeartion.java
  5. BIN
      zhaohe_app.db

14
src/main/java/a8k/a8k_can_protocol/A8kPacket.java

@ -85,23 +85,23 @@ public class A8kPacket {
if (packetType == PACKET_TYPE_CMD) {
if (cmdId.cmdAttachType == CmdId.ATTACH_IS_INT32) {
ret = String.format("[CMD ] [%x] (%s %d :[%s])", getPacketIndex(), cmdId, getModuleId(), formatInt32ATTACH(getCmdContent()));
ret = String.format("[CMD ] index:[%d] (%s %s :i32[%s])", getPacketIndex(), cmdId, MId.valueOf(getModuleId()), formatInt32ATTACH(getCmdContent()));
} else {
ret = String.format("[CMD ] [%x] (%s %d :[%s])", getPacketIndex(), cmdId, getModuleId(), ByteArray.toByteString(getCmdContent()));
ret = String.format("[CMD ] index:[%d] (%s %s(%d) :bytes[%s])", getPacketIndex(), cmdId, MId.valueOf(getModuleId()), getModuleId(), ByteArray.toByteString(getCmdContent()));
}
} else if (packetType == PACKET_TYPE_ACK) {
if (cmdId.receiptAttachType == CmdId.ATTACH_IS_INT32) {
ret = String.format("[ACK ] [%x] (%s %d :[%s])", getPacketIndex(), cmdId, getModuleId(), formatInt32ATTACH(getCmdContent()));
ret = String.format("[ACK ] index:[%d] (%s %s(%d) :[%s])", getPacketIndex(), cmdId, MId.valueOf(getModuleId()), getModuleId(), formatInt32ATTACH(getCmdContent()));
} else {
ret = String.format("[ACK ] [%x] (%s %d :[%s])", getPacketIndex(), cmdId, getModuleId(), ByteArray.toByteString(getCmdContent()));
ret = String.format("[ACK ] index:[%d] (%s %s(%d) :[%s])", getPacketIndex(), cmdId, MId.valueOf(getModuleId()), getModuleId(), ByteArray.toByteString(getCmdContent()));
}
} else if (packetType == PACKET_TYPE_ERROR_ACK) {
ret = String.format("[EACK ] [%x] (%s %d :[%s])", getPacketIndex(), cmdId, getModuleId(), A8kEcode.toString(getContentI32(0)));
ret = String.format("[EACK ] index:[%d] (%s %s(%d) :[%s])", getPacketIndex(), cmdId, MId.valueOf(getModuleId()), getModuleId(), A8kEcode.toString(getContentI32(0)));
} else if (packetType == PACKET_TYPE_EVENT) {
if (cmdId.cmdAttachType == CmdId.ATTACH_IS_INT32) {
ret = String.format("[EVENT] [%x] (%s %d :[%s])", getPacketIndex(), cmdId, getModuleId(), formatInt32ATTACH(getCmdContent()));
ret = String.format("[EVENT] index:[%d] (%s %s(%d) :[%s])", getPacketIndex(), cmdId, MId.valueOf(getModuleId()), getModuleId(), formatInt32ATTACH(getCmdContent()));
} else {
ret = String.format("[EVENT] [%x] (%s %d :[%s])", getPacketIndex(), cmdId, getModuleId(), ByteArray.toByteString(getCmdContent()));
ret = String.format("[EVENT] index:[%d] (%s %s(%d) :[%s])", getPacketIndex(), cmdId, MId.valueOf(getModuleId()), getModuleId(), ByteArray.toByteString(getCmdContent()));
}
} else {
ret = String.format("Unknown packet type: %d", packetType);

48
src/main/java/a8k/base_hardware/A8kCanBusService.java

@ -502,7 +502,7 @@ public class A8kCanBusService {
String txpacket = pack.toByteString();
if (debugFlag && pack.getCmdId() != CmdId.module_get_status.toInt()) {
logger.info("tx:{}:({})", pack, txpacket);
logger.info("Tx:|RAW:{}| {}", txpacket, pack);
}
client.send(txpacket);
A8kPacket receipt;
@ -545,7 +545,7 @@ public class A8kCanBusService {
A8kPacket packet = new A8kPacket(rx);
if (debugFlag && packet.getCmdId() != CmdId.module_get_status.toInt()) {
logger.info("RX {}:({})", packet, rx);
logger.info("RX |RAW:{}| {}", s, packet);
}
if (packet.getPacketType() == A8kPacket.PACKET_TYPE_ACK || packet.getPacketType() == A8kPacket.PACKET_TYPE_ERROR_ACK) {
@ -562,27 +562,27 @@ public class A8kCanBusService {
}
}
}
public static void main(String[] args) {
A8kCanBusService service = new A8kCanBusService();
try {
service.init();
} catch (URISyntaxException e) {
logger.error(e.getMessage());
}
Thread thread = new Thread(() -> {
while (true) {
A8kPacket packet = null;
try {
packet = service.receiptQueue.take();
logger.info("poll receipt {}", packet);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
});
thread.start();
}
//
// public static void main(String[] args) {
// A8kCanBusService service = new A8kCanBusService();
// try {
// service.init();
// } catch (URISyntaxException e) {
// logger.error(e.getMessage());
// }
//
// Thread thread = new Thread(() -> {
// while (true) {
// A8kPacket packet = null;
// try {
// packet = service.receiptQueue.take();
// logger.info("poll receipt {}", packet);
// } catch (InterruptedException e) {
// throw new RuntimeException(e);
// }
// }
// });
// thread.start();
// }
}

12
src/main/java/a8k/service/ctrl_service/DeviceInitializationCtrlService.java

@ -64,7 +64,7 @@ public class DeviceInitializationCtrlService {
} catch (HardwareException e) {
logger.error("HardwareException %s", e);
logger.error("HardwareException ", e);
throw new RuntimeException(e);
} catch (InterruptedException e) {
logger.error("InterruptedException", e);
@ -145,12 +145,12 @@ public class DeviceInitializationCtrlService {
private AppEcode moveMotorToZero() throws HardwareException, InterruptedException {
//进出料初始化
canBus.stepMotorEasyMoveToZero(MId.FeedingModInfeedM);
canBus.waitForMod(MId.FeedingModInfeedM, actionOvertime);
// canBus.stepMotorEasyMoveToZero(MId.FeedingModInfeedM);
// canBus.waitForMod(MId.FeedingModInfeedM, actionOvertime);
canBus.stepMotorEasyMoveToZero(MId.FeedingModXM);
canBus.waitForMod(MId.FeedingModXM, actionOvertime);
canBus.stepMotorEasyMoveToZero(MId.FeedingModOutfeedM);
canBus.waitForMod(MId.FeedingModOutfeedM, actionOvertime);
// canBus.stepMotorEasyMoveToZero(MId.FeedingModOutfeedM);
// canBus.waitForMod(MId.FeedingModOutfeedM, actionOvertime);
//摇匀模组初始化
@ -183,7 +183,7 @@ public class DeviceInitializationCtrlService {
canBus.waitForMod(MId.OptModScannerM, actionOvertime);
//HBot初始化
canBus.stepMotorEasyMoveToZero(MId.HbotM);
canBus.hbotMoveToZero(MId.HbotM);
canBus.waitForMod(MId.HbotM, actionOvertime);
canBus.stepMotorEasyMoveToZero(MId.PipetteModZM);
canBus.waitForMod(MId.PipetteModZM, actionOvertime);

2
src/main/java/a8k/service/hardware/CommonHardwareOpeartion.java

@ -147,7 +147,7 @@ public class CommonHardwareOpeartion {
try {canBus.stepMotorEnable(MId.OptModScannerM, 0);} catch (HardwareException ignored) {}
//HBot初始化
try {canBus.stepMotorEnable(MId.HbotM, 0);} catch (HardwareException ignored) {}
try {canBus.hbotEnable(MId.HbotM, 0);} catch (HardwareException ignored) {}
try {canBus.stepMotorEnable(MId.PipetteModZM, 0);} catch (HardwareException ignored) {}
//转盘归零

BIN
zhaohe_app.db

Loading…
Cancel
Save