|
@@ -13,25 +13,27 @@ import com.gzlh.config.dto.SerialSetting;
|
|
|
import com.gzlh.device.capture.factory.CaptureFactory;
|
|
|
import com.gzlh.config.ModuleEnum;
|
|
|
import com.gzlh.config.SystemObject;
|
|
|
-import com.gzlh.device.electron.factory.ElectronFactory;
|
|
|
+import com.gzlh.device.rfid.factory.ElectronFactory;
|
|
|
|
|
|
import com.gzlh.device.led.factory.LedFactory;
|
|
|
+import com.gzlh.device.led.utils.LedOptions;
|
|
|
+import com.gzlh.device.plc.event.PLCEvent;
|
|
|
import com.gzlh.device.plc.handler.PLCHadnler;
|
|
|
-import com.gzlh.device.print.factory.PrintFactory;
|
|
|
import com.gzlh.device.weighbridge.factory.WeighbridgeFactory;
|
|
|
import com.gzlh.device.weighbridge.handler.impl.CommonWeighbridgeHandler;
|
|
|
-
|
|
|
+import com.gzlh.entity.CommandBO;
|
|
|
import com.gzlh.utils.DeviceCache;
|
|
|
+import com.gzlh.utils.WordHandlerUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
@Slf4j
|
|
|
-public class EventThread implements Runnable {
|
|
|
+public class EventThread implements Runnable{
|
|
|
private String eventName;
|
|
|
|
|
|
public EventThread(String eventName) {
|
|
|
- this.eventName = eventName;
|
|
|
+ this.eventName=eventName;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -40,58 +42,52 @@ public class EventThread implements Runnable {
|
|
|
* @param eventName 服务.事件名 比如led.ready
|
|
|
*/
|
|
|
public void handlerEvent(String eventName) {
|
|
|
- SerialSetting serialSetting = SysConfig.serialSetting;
|
|
|
- LedFactory ledFactory = SystemObject.ledFactory;
|
|
|
- WeighbridgeFactory weighbridgeFactory = SystemObject.weighbridgeFactory;
|
|
|
- ElectronFactory electronFactory = SystemObject.electronFactory;
|
|
|
- PrintFactory printFactory = SystemObject.printFactory;
|
|
|
- PLCHadnler plcHadnler = SpringUtil.getBean(PLCHadnler.class);
|
|
|
- CaptureFactory captureFactory = SystemObject.captureFactory;
|
|
|
- CaputreSetting caputreSetting = SysConfig.caputreSetting;
|
|
|
- log.info("event:{}", eventName);
|
|
|
+ SerialSetting serialSetting= SysConfig.serialSetting;
|
|
|
+ LedFactory ledFactory= SystemObject.ledFactory;
|
|
|
+ WeighbridgeFactory weighbridgeFactory=SystemObject.weighbridgeFactory;
|
|
|
+ ElectronFactory electronFactory= SystemObject.electronFactory;
|
|
|
+ PLCHadnler plcHadnler= SpringUtil.getBean(PLCHadnler.class);
|
|
|
+ CaptureFactory captureFactory=SystemObject.captureFactory;
|
|
|
+ CaputreSetting caputreSetting=SysConfig.caputreSetting;
|
|
|
+ // log.info("event:{}", eventName);
|
|
|
SysConfig.eventDTOList.stream().filter(eventDTO -> StrUtil.equals(eventName, eventDTO.getName()))
|
|
|
.findFirst().ifPresent(eventDTO -> {
|
|
|
- List<String> actionList = eventDTO.getActionList().getAction();
|
|
|
- //依次执行动作
|
|
|
- for (String action : actionList) {
|
|
|
- // log.info("action :{}", action);
|
|
|
- String module = StrUtil.subBefore(action, ".", true);
|
|
|
- String command = StrUtil.subAfter(action, ".", true);
|
|
|
+ List<String> actionList = eventDTO.getActionList().getAction();
|
|
|
+ //依次执行动作
|
|
|
+ for (String action:actionList) {
|
|
|
+ String module = StrUtil.subBefore(action, ".", true);
|
|
|
+ String command = StrUtil.subAfter(action, ".", true);
|
|
|
// 中断事件动作
|
|
|
- if (DeviceCache.isInterrupt()) {
|
|
|
- //停止读数
|
|
|
- CommonWeighbridgeHandler.isStart = false;
|
|
|
- DeviceCache.setInterrupt(false);
|
|
|
- break;
|
|
|
- }
|
|
|
- if (StrUtil.equals(module, ModuleEnum.INFRARED_MODULE.getModuleEn())) {
|
|
|
- //动作属于红外
|
|
|
- } else if (StrUtil.equals(module, ModuleEnum.LED_MODULE.getModuleEn())) {
|
|
|
- //动作属于led
|
|
|
- ledFactory.handler(serialSetting.getLed().getBrand()).handlerAction(command);
|
|
|
- } else if (StrUtil.equals(module, ModuleEnum.WEIGHBRIDGE_MODULE.getModuleEn())) {
|
|
|
- //动作属于地磅
|
|
|
- weighbridgeFactory.handler(serialSetting.getWeighbridge().getBrand()).handlerAction(command);
|
|
|
- } else if (StrUtil.equals(module, ModuleEnum.CAPTURE_MODULE.getModuleEn())) {
|
|
|
- //动作属于抓拍单元--车牌识别
|
|
|
- captureFactory.handler(caputreSetting.getBrand()).handlerAction(command);
|
|
|
- } else if (StrUtil.equals(module, ModuleEnum.PLC_MODULE.getModuleEn())) {
|
|
|
- //动作属于plc
|
|
|
- plcHadnler.handlerAction(command);
|
|
|
- } else if (StrUtil.equals(module, ModuleEnum.ELECTRON_MODULE.getModuleEn())) {
|
|
|
- //动作属于电子车牌
|
|
|
- electronFactory.handler(serialSetting.getElectron().getBrand()).handlerAction(command);
|
|
|
- } else if (StrUtil.equals(module, ModuleEnum.PRINT_MODULE.getModuleEn())) {
|
|
|
- //动作属于打印机
|
|
|
- printFactory.handler(serialSetting.getPrint().getBrand()).handlerAction(command);
|
|
|
- }
|
|
|
- else if (StrUtil.equals(module, ModuleEnum.CENTER_MODULE.getModuleEn())) {
|
|
|
- //动作属于中心总线
|
|
|
- handlerAction(command);
|
|
|
- }
|
|
|
- ThreadUtil.sleep(250);
|
|
|
- }
|
|
|
- });
|
|
|
+ if (DeviceCache.isInterrupt()){
|
|
|
+ //停止读数
|
|
|
+ CommonWeighbridgeHandler.isStart=false;
|
|
|
+ DeviceCache.setInterrupt(false);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (StrUtil.equals(module, ModuleEnum.INFRARED_MODULE.getModuleEn())) {
|
|
|
+ //动作属于红外
|
|
|
+ } else if (StrUtil.equals(module, ModuleEnum.LED_MODULE.getModuleEn())) {
|
|
|
+ //动作属于led
|
|
|
+ ledFactory.handler(serialSetting.getLed().getBrand()).handlerAction(command);
|
|
|
+ } else if (StrUtil.equals(module, ModuleEnum.WEIGHBRIDGE_MODULE.getModuleEn())) {
|
|
|
+ //动作属于地磅
|
|
|
+ weighbridgeFactory.handler(serialSetting.getWeighbridge().getBrand()).handlerAction(command);
|
|
|
+ }else if (StrUtil.equals(module, ModuleEnum.CAPTURE_MODULE.getModuleEn())) {
|
|
|
+ //动作属于抓拍单元--车牌识别
|
|
|
+ captureFactory.handler(caputreSetting.getBrand()).handlerAction(command);
|
|
|
+ }else if (StrUtil.equals(module, ModuleEnum.PLC_MODULE.getModuleEn())) {
|
|
|
+ //动作属于plc
|
|
|
+ plcHadnler.handlerAction(command);
|
|
|
+ }else if (StrUtil.equals(module, ModuleEnum.ELECTRON_MODULE.getModuleEn())) {
|
|
|
+ //动作属于电子车牌
|
|
|
+ electronFactory.handler(serialSetting.getElectron().getBrand()).handlerAction(command);
|
|
|
+ } else if (StrUtil.equals(module, ModuleEnum.CENTER_MODULE.getModuleEn())) {
|
|
|
+ //动作属于中心总线
|
|
|
+ handlerAction(command);
|
|
|
+ }
|
|
|
+ ThreadUtil.sleep(250);
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
}
|
|
|
|