|
@@ -28,6 +28,7 @@ import com.gzlh.device.plc.service.PLCService;
|
|
|
import com.gzlh.device.print.action.PrintCommonAction;
|
|
|
import com.gzlh.device.print.event.PrintEvent;
|
|
|
import com.gzlh.device.print.factory.PrintFactory;
|
|
|
+import com.gzlh.device.rfid.job.ElectronReadJob;
|
|
|
import com.gzlh.device.weighbridge.event.WeighbridgeEvent;
|
|
|
import com.gzlh.device.weighbridge.handler.impl.CommonWeighbridgeHandler;
|
|
|
import com.gzlh.entity.ReqBO;
|
|
@@ -106,6 +107,7 @@ public class PLCHadnler {
|
|
|
plcNettyConfig.send(packData);
|
|
|
taskService.addTask(new CheckDownTask(RandomUtil.randomNumbers(10), 200, 1));
|
|
|
} else if (StrUtil.equals(action, PLCAction.REQ_PRINT)) {
|
|
|
+
|
|
|
plcService.reqPrint();
|
|
|
} else if (StrUtil.equals(action, PLCAction.TEST_PRINT)) {
|
|
|
plcService.testPrint();
|
|
@@ -119,6 +121,18 @@ public class PLCHadnler {
|
|
|
plcService.reqTwinRightDisable();
|
|
|
} else if (StrUtil.equals(action, PLCAction.REQ_TWIN_IDLE)) {
|
|
|
plcService.reqTwinIdle();
|
|
|
+ } else if (StrUtil.equals(action, PLCAction.GATE_DOWN)) {
|
|
|
+ String downGatePoint = serialSetting.getPlc().getOut().getDownGatePoint();
|
|
|
+ String command = COMMAND_PREFIX + downGatePoint + COMMAND_ON;
|
|
|
+ // log.info("plc发送消息:{}", command);
|
|
|
+ String packData = ModbusUtils.buildRequestPacket(command);
|
|
|
+ plcNettyConfig.send(packData);
|
|
|
+ } else if (StrUtil.equals(action, PLCAction.RELEASE_GATE_DOWN)) {
|
|
|
+ String downGatePoint = serialSetting.getPlc().getOut().getDownGatePoint();
|
|
|
+ String command = COMMAND_PREFIX + downGatePoint + COMMAND_OFF;
|
|
|
+ // log.info("plc发送消息:{}", command);
|
|
|
+ String packData = ModbusUtils.buildRequestPacket(command);
|
|
|
+ plcNettyConfig.send(packData);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -196,17 +210,23 @@ public class PLCHadnler {
|
|
|
String cancelPrintPoint = status.getCancelPrint();
|
|
|
String cancelPrintPointStatus = newReverse.charAt(Integer.parseInt(cancelPrintPoint)) + "";
|
|
|
//试榜单
|
|
|
- String testPrintPoint = status.getCancelPrint();
|
|
|
+ String testPrintPoint = status.getTestPrint();
|
|
|
String testPrintPointStatus = newReverse.charAt(Integer.parseInt(testPrintPoint)) + "";
|
|
|
+ String infraredMode = status.getInfraredMode();
|
|
|
//前红外发生变化
|
|
|
if (judgePoint.equals(redPoint)) {
|
|
|
if (redPointStatus.equals("0")) {
|
|
|
log.info("前红外断开&磅上有车--->触发3秒后是否开始称重,{}", CommonWeighbridgeHandler.hsCar);
|
|
|
taskService.addTask(new CheckStartWeightTask(RandomUtil.randomNumbers(16), 3000));
|
|
|
} else if (redPointStatus.equals("1")) {
|
|
|
+ if (StrUtil.equals(infraredMode, "-1")) {
|
|
|
+ log.info("安派---前红外断开&磅上有车--->触发3秒后是否开始称重,{}", CommonWeighbridgeHandler.hsCar);
|
|
|
+ taskService.addTask(new CheckStartWeightTask(RandomUtil.randomNumbers(16), 3000));
|
|
|
+ }
|
|
|
//前红外触碰并且磅上有车===>发布车辆进入地磅事件
|
|
|
- if (reqBO != null && StrUtil.isNotEmpty(reqBO.getCarNo())) {
|
|
|
- log.info("前红外触碰");
|
|
|
+ if (reqBO == null || StrUtil.isEmpty(reqBO.getCarNo())) {
|
|
|
+ log.info("前红外触碰,读取RFID====");
|
|
|
+ ThreadUtil.execute(new ElectronReadJob());
|
|
|
//eventBus.startEvent(ModuleEnum.PLC_MODULE.getModuleEn() + "." + PLCEvent.CAR_ENTER);
|
|
|
}
|
|
|
}
|
|
@@ -221,15 +241,28 @@ public class PLCHadnler {
|
|
|
eventBus.startEvent(ModuleEnum.PLC_MODULE.getModuleEn() + "." + PLCEvent.DOWN_POINT_READ);
|
|
|
}
|
|
|
} else if (bRedPoint.equals(judgePoint)) {
|
|
|
- //车触碰到后红外&在磅上&下到位==>提醒推车
|
|
|
- if (bRedPointStatus.equals("1") && downPointStatus.equals("1") && radarPointStatus.equals("1")) {
|
|
|
- DeviceCache.setInterrupt(true);
|
|
|
- LedOptions options = new LedOptions().setLine("03").setColor("01").setShowType("00");
|
|
|
- SystemObject.ledFactory.handler(SysConfig.serialSetting.getLed().getBrand())
|
|
|
- .sendMsg("请倒车", options);
|
|
|
- } else if (bRedPointStatus.equals("0") && downPointStatus.equals("1") && radarPointStatus.equals("1")) {
|
|
|
- //倒车完成
|
|
|
- eventBus.startEvent(ModuleEnum.WEIGHBRIDGE_MODULE.getModuleEn() + "." + WeighbridgeEvent.READ);
|
|
|
+ if (StrUtil.equals(infraredMode,"-1")){
|
|
|
+ //车触碰到后红外&在磅上&下到位==>提醒推车
|
|
|
+ if (bRedPointStatus.equals("0") && downPointStatus.equals("1") && radarPointStatus.equals("1")) {
|
|
|
+ DeviceCache.setInterrupt(true);
|
|
|
+ LedOptions options = new LedOptions().setLine("03").setColor("01").setShowType("00");
|
|
|
+ SystemObject.ledFactory.handler(SysConfig.serialSetting.getLed().getBrand())
|
|
|
+ .sendMsg("超出称重位置,请倒车!", options);
|
|
|
+ } else if (bRedPointStatus.equals("1") && downPointStatus.equals("1") && radarPointStatus.equals("1")) {
|
|
|
+ //倒车完成
|
|
|
+ eventBus.startEvent(ModuleEnum.WEIGHBRIDGE_MODULE.getModuleEn() + "." + WeighbridgeEvent.READ);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ //车触碰到后红外&在磅上&下到位==>提醒推车
|
|
|
+ if (bRedPointStatus.equals("1") && downPointStatus.equals("1") && radarPointStatus.equals("1")) {
|
|
|
+ DeviceCache.setInterrupt(true);
|
|
|
+ LedOptions options = new LedOptions().setLine("03").setColor("01").setShowType("00");
|
|
|
+ SystemObject.ledFactory.handler(SysConfig.serialSetting.getLed().getBrand())
|
|
|
+ .sendMsg("超出称重位置,请倒车!", options);
|
|
|
+ } else if (bRedPointStatus.equals("0") && downPointStatus.equals("1") && radarPointStatus.equals("1")) {
|
|
|
+ //倒车完成
|
|
|
+ eventBus.startEvent(ModuleEnum.WEIGHBRIDGE_MODULE.getModuleEn() + "." + WeighbridgeEvent.READ);
|
|
|
+ }
|
|
|
}
|
|
|
} else if (judgePoint.equals(radarPoint)) {
|
|
|
if (radarPointStatus.equals("0")) {
|
|
@@ -237,13 +270,20 @@ public class PLCHadnler {
|
|
|
} else if (radarPointStatus.equals("1")) {
|
|
|
taskService.addTask(new CheckCarInTask(RandomUtil.randomNumbers(16), 200));
|
|
|
}
|
|
|
- } else if (printPointStatus.equals("1") && judgePoint.equals(printPoint)) {
|
|
|
- eventBus.startEvent(ModuleEnum.PLC_MODULE.getModuleEn() + "." + PLCEvent.START_PRINT);
|
|
|
- } else if (cancelPrintPointStatus.equals("1") && judgePoint.equals(cancelPrintPoint)) {
|
|
|
- eventBus.startEvent(ModuleEnum.PLC_MODULE.getModuleEn() + "." + PLCEvent.CANCEL_PRINT);
|
|
|
- } else if (testPrintPointStatus.equals("1") && judgePoint.equals(testPrintPoint)) {
|
|
|
- eventBus.startEvent(ModuleEnum.PLC_MODULE.getModuleEn() + "." + PLCEvent.TEST_PRINT);
|
|
|
+ } else if (testPrintPoint.equals(judgePoint)) {
|
|
|
+ if (testPrintPointStatus.equals("1")) {
|
|
|
+ eventBus.startEvent(ModuleEnum.PLC_MODULE.getModuleEn() + "." + PLCEvent.TEST_PRINT);
|
|
|
+ }
|
|
|
+ } else if (cancelPrintPoint.equals(judgePoint)) {
|
|
|
+ if (cancelPrintPointStatus.equals("1")) {
|
|
|
+ eventBus.startEvent(ModuleEnum.PLC_MODULE.getModuleEn() + "." + PLCEvent.CANCEL_PRINT);
|
|
|
+ }
|
|
|
+ } else if (printPoint.equals(judgePoint)) {
|
|
|
+ if (printPointStatus.equals("1")) {
|
|
|
+ eventBus.startEvent(ModuleEnum.PLC_MODULE.getModuleEn() + "." + PLCEvent.START_PRINT);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -409,22 +449,12 @@ public class PLCHadnler {
|
|
|
}
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
- String str = "10";
|
|
|
- String result = Integer.toBinaryString(Integer.parseInt(str, 16));
|
|
|
- System.out.println(result);
|
|
|
-// 将plc的设备信息补到8存入缓存
|
|
|
- String newPlcInfo = String.format("%8s", result).replace(" ", "0");
|
|
|
- System.out.println(newPlcInfo);
|
|
|
- String newReverse = new StringBuffer(newPlcInfo).reverse().toString();
|
|
|
- System.out.println(newReverse);
|
|
|
|
|
|
- int i = 0, j = 2, k = 4;
|
|
|
-
|
|
|
- if (i == 0 && j == 2 && k == 4) {
|
|
|
- System.out.println(1);
|
|
|
- } else if (i == 0) {
|
|
|
- System.out.println(2);
|
|
|
- }
|
|
|
+ String command = COMMAND_PREFIX + "00" + COMMAND_ON;
|
|
|
+// String command = COMMAND_PREFIX + "00" + COMMAND_OFF;
|
|
|
+ // log.info("plc发送消息:{}", command);
|
|
|
+ String packData = ModbusUtils.buildRequestPacket(command);
|
|
|
+ System.out.println(packData);
|
|
|
|
|
|
}
|
|
|
}
|