|
@@ -3,6 +3,8 @@ package com.gzlh.bus;
|
|
import cn.hutool.core.thread.ThreadUtil;
|
|
import cn.hutool.core.thread.ThreadUtil;
|
|
import cn.hutool.core.util.NumberUtil;
|
|
import cn.hutool.core.util.NumberUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
+import cn.hutool.extra.spring.SpringUtil;
|
|
|
|
+import com.gzlh.config.dto.SerialSetting;
|
|
import com.gzlh.device.capture.factory.CaptureFactory;
|
|
import com.gzlh.device.capture.factory.CaptureFactory;
|
|
import com.gzlh.device.capture.properties.CapturePropertiesConfig;
|
|
import com.gzlh.device.capture.properties.CapturePropertiesConfig;
|
|
import com.gzlh.config.ModuleEnum;
|
|
import com.gzlh.config.ModuleEnum;
|
|
@@ -11,7 +13,7 @@ import com.gzlh.config.dto.EventDTO;
|
|
import com.gzlh.device.infrared.config.RedPropertiesConfig;
|
|
import com.gzlh.device.infrared.config.RedPropertiesConfig;
|
|
import com.gzlh.device.infrared.factory.RedFactory;
|
|
import com.gzlh.device.infrared.factory.RedFactory;
|
|
import com.gzlh.device.led.factory.LedFactory;
|
|
import com.gzlh.device.led.factory.LedFactory;
|
|
-import com.gzlh.device.led.properties.LedPropertiesConfig;
|
|
|
|
|
|
+import com.gzlh.device.plc.handler.PLCHadnler;
|
|
import com.gzlh.device.weighbridge.config.WeighbridgePropertiesConfig;
|
|
import com.gzlh.device.weighbridge.config.WeighbridgePropertiesConfig;
|
|
import com.gzlh.device.weighbridge.factory.WeighbridgeFactory;
|
|
import com.gzlh.device.weighbridge.factory.WeighbridgeFactory;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -20,37 +22,29 @@ import java.util.List;
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
public class EventThread implements Runnable{
|
|
public class EventThread implements Runnable{
|
|
- private List<EventDTO> eventDTOList;
|
|
|
|
private String eventName;
|
|
private String eventName;
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
public EventThread(String eventName) {
|
|
public EventThread(String eventName) {
|
|
this.eventName=eventName;
|
|
this.eventName=eventName;
|
|
}
|
|
}
|
|
|
|
|
|
- public void setEventDTOList(List<EventDTO> eventDTOList) {
|
|
|
|
- this.eventDTOList = eventDTOList;
|
|
|
|
- }
|
|
|
|
- public void setEventName(String eventName) {
|
|
|
|
- this.eventName = eventName;
|
|
|
|
- }
|
|
|
|
/**
|
|
/**
|
|
* 处理事件
|
|
* 处理事件
|
|
*
|
|
*
|
|
* @param eventName 服务.事件名 比如led.ready
|
|
* @param eventName 服务.事件名 比如led.ready
|
|
*/
|
|
*/
|
|
public void handlerEvent(String eventName) {
|
|
public void handlerEvent(String eventName) {
|
|
|
|
+ SerialSetting serialSetting=EventConfig.serialSetting;
|
|
LedFactory ledFactory= SystemObject.ledFactory;
|
|
LedFactory ledFactory= SystemObject.ledFactory;
|
|
RedFactory redFactory=SystemObject.redFactory;
|
|
RedFactory redFactory=SystemObject.redFactory;
|
|
WeighbridgeFactory weighbridgeFactory=SystemObject.weighbridgeFactory;
|
|
WeighbridgeFactory weighbridgeFactory=SystemObject.weighbridgeFactory;
|
|
WeighbridgePropertiesConfig weighbridgePropertiesConfig=SystemObject.weighbridgePropertiesConfig;
|
|
WeighbridgePropertiesConfig weighbridgePropertiesConfig=SystemObject.weighbridgePropertiesConfig;
|
|
RedPropertiesConfig redPropertiesConfig=SystemObject.redPropertiesConfig;
|
|
RedPropertiesConfig redPropertiesConfig=SystemObject.redPropertiesConfig;
|
|
- LedPropertiesConfig ledPropertiesConfig=SystemObject.ledPropertiesConfig;
|
|
|
|
|
|
+ PLCHadnler plcHadnler= SpringUtil.getBean(PLCHadnler.class);
|
|
CaptureFactory captureFactory=SystemObject.captureFactory;
|
|
CaptureFactory captureFactory=SystemObject.captureFactory;
|
|
CapturePropertiesConfig capturePropertiesConfig=SystemObject.capturePropertiesConfig;
|
|
CapturePropertiesConfig capturePropertiesConfig=SystemObject.capturePropertiesConfig;
|
|
log.info("event:{}", eventName);
|
|
log.info("event:{}", eventName);
|
|
- eventDTOList.stream().filter(eventDTO -> StrUtil.equals(eventName, eventDTO.getName()))
|
|
|
|
|
|
+ EventConfig.eventDTOList.stream().filter(eventDTO -> StrUtil.equals(eventName, eventDTO.getName()))
|
|
.findFirst().ifPresent(eventDTO -> {
|
|
.findFirst().ifPresent(eventDTO -> {
|
|
List<String> actionList = eventDTO.getActionList().getAction();
|
|
List<String> actionList = eventDTO.getActionList().getAction();
|
|
//依次执行动作
|
|
//依次执行动作
|
|
@@ -62,14 +56,17 @@ public class EventThread implements Runnable{
|
|
redFactory.handler(redPropertiesConfig.getBrand()).handlerAction(command);
|
|
redFactory.handler(redPropertiesConfig.getBrand()).handlerAction(command);
|
|
} else if (StrUtil.equals(module, ModuleEnum.LED_MODULE.getModuleEn())) {
|
|
} else if (StrUtil.equals(module, ModuleEnum.LED_MODULE.getModuleEn())) {
|
|
//动作属于led
|
|
//动作属于led
|
|
- ledFactory.handler(ledPropertiesConfig.getBrand()).handlerAction(command);
|
|
|
|
|
|
+ ledFactory.handler(serialSetting.getLed().getBrand()).handlerAction(command);
|
|
} else if (StrUtil.equals(module, ModuleEnum.WEIGHBRIDGE_MODULE.getModuleEn())) {
|
|
} else if (StrUtil.equals(module, ModuleEnum.WEIGHBRIDGE_MODULE.getModuleEn())) {
|
|
//动作属于地磅
|
|
//动作属于地磅
|
|
weighbridgeFactory.handler(weighbridgePropertiesConfig.getBrand()).handlerAction(command);
|
|
weighbridgeFactory.handler(weighbridgePropertiesConfig.getBrand()).handlerAction(command);
|
|
}else if (StrUtil.equals(module, ModuleEnum.CAPTURE_MODULE.getModuleEn())) {
|
|
}else if (StrUtil.equals(module, ModuleEnum.CAPTURE_MODULE.getModuleEn())) {
|
|
//动作属于抓拍单元--车牌识别
|
|
//动作属于抓拍单元--车牌识别
|
|
captureFactory.handler(capturePropertiesConfig.getBrand()).handlerAction(command);
|
|
captureFactory.handler(capturePropertiesConfig.getBrand()).handlerAction(command);
|
|
- } else if (StrUtil.equals(module, ModuleEnum.CENTER_MODULE.getModuleEn())) {
|
|
|
|
|
|
+ }else if (StrUtil.equals(module, ModuleEnum.PLC_MODULE.getModuleEn())) {
|
|
|
|
+ //动作属于plc
|
|
|
|
+ plcHadnler.handlerAction(command);
|
|
|
|
+ } else if (StrUtil.equals(module, ModuleEnum.CENTER_MODULE.getModuleEn())) {
|
|
//动作属于中心总线
|
|
//动作属于中心总线
|
|
handlerAction(command);
|
|
handlerAction(command);
|
|
}
|
|
}
|