Browse Source

OPC线程同步修改

master
管理员 2 years ago
parent
commit
7fca8d0795
  1. 21
      acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceOpcProtocolRunable.java
  2. 5
      acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceOpcSynchronizeAutoRun.java
  3. 8
      acs/nladmin-system/src/main/resources/logback-spring.xml

21
acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceOpcProtocolRunable.java

@ -59,8 +59,9 @@ public class DeviceOpcProtocolRunable implements Runnable {
@Override
public void run() {
while (true) {
Server server = null;
try {
Server server = OpcServerUtl.getServerWithOutException(this.OpcServer.getOpc_host(), this.OpcServer.getCls_id(), this.OpcServer.getUser(), this.OpcServer.getPassword(), this.OpcServer.getDomain());
server = OpcServerUtl.getServerWithOutException(this.OpcServer.getOpc_host(), this.OpcServer.getCls_id(), this.OpcServer.getUser(), this.OpcServer.getPassword(), this.OpcServer.getDomain());
Group group = server.addGroup();
List<String> itemsString = new ArrayList();
Iterator it = this.protocols.iterator();
@ -178,11 +179,29 @@ public class DeviceOpcProtocolRunable implements Runnable {
}
}
} catch (Exception var30) {
if (!DeviceOpcSynchronizeAutoRun.isRun) {
System.out.println("opc线程停止2。。。");
if (server != null) {
try {
server.disconnect();
} catch (Exception var31) {
}
}
return;
}
String error_message = "设备信息同步异常";
if (!StrUtil.equals(this.message, error_message)) {
log.warn("", var30);
}
if (server != null) {
try {
server.disconnect();
} catch (Exception e) {
}
}
try {
Thread.sleep((long) (OpcConfig.synchronized_exception_wait_second * 1000));
} catch (InterruptedException e) {

5
acs/nladmin-system/src/main/java/org/nl/acs/opc/DeviceOpcSynchronizeAutoRun.java

@ -23,6 +23,8 @@ public class DeviceOpcSynchronizeAutoRun extends AbstractAutoRunnable {
@Autowired
private OpcServerManageService opcServerManageService;
public static boolean isRun = false;
@Override
public String getCode() {
return DeviceOpcSynchronizeAutoRun.class.getSimpleName();
@ -36,7 +38,7 @@ public class DeviceOpcSynchronizeAutoRun extends AbstractAutoRunnable {
@Override
public void autoRun() throws Exception {
{
isRun = true;
Map<String, OpcServerManageDto> servers = this.opcServerManageService.queryAllServerMap();
Map<String, List<List<OpcItemDto>>> pros;
do{
@ -75,6 +77,7 @@ public class DeviceOpcSynchronizeAutoRun extends AbstractAutoRunnable {
@Override
public void after() {
isRun = false;
this.executorService.shutdownNow();
this.executorService = Executors.newCachedThreadPool();
}

8
acs/nladmin-system/src/main/resources/logback-spring.xml

@ -175,6 +175,14 @@ https://juejin.cn/post/6844903775631572999
<appender-ref ref="asyncFileAppender"/>
<appender-ref ref="lokiAppender"/>
</logger>
<logger name="org.jinterop" level="ERROR" additivity="false">
<appender-ref ref="asyncFileAppender"/>
<appender-ref ref="lokiAppender"/>
</logger>
<logger name="org.openscada" level="ERROR" additivity="false">
<appender-ref ref="asyncFileAppender"/>
<appender-ref ref="lokiAppender"/>
</logger>
</springProfile>

Loading…
Cancel
Save