更新
This commit is contained in:
parent
e0c59fcbfb
commit
09035cd750
1
pom.xml
1
pom.xml
@ -159,6 +159,7 @@
|
|||||||
<version>2.5.4</version>
|
<version>2.5.4</version>
|
||||||
|
|
||||||
<configuration>
|
<configuration>
|
||||||
|
|
||||||
<excludes>
|
<excludes>
|
||||||
<exclude>
|
<exclude>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
|
@ -69,6 +69,9 @@ public class OperateController {
|
|||||||
List<CurrentSubEntity> currentSubscribeVarForVisited = uaService.getCurrentSubscribeVarForVisited(plcName);
|
List<CurrentSubEntity> currentSubscribeVarForVisited = uaService.getCurrentSubscribeVarForVisited(plcName);
|
||||||
List<Integer> ns = new ArrayList<>();
|
List<Integer> ns = new ArrayList<>();
|
||||||
List<String> iden = new ArrayList<>();
|
List<String> iden = new ArrayList<>();
|
||||||
|
if(currentSubscribeVarForVisited == null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
for(CurrentSubEntity currentSubEntity:currentSubscribeVarForVisited){
|
for(CurrentSubEntity currentSubEntity:currentSubscribeVarForVisited){
|
||||||
ns.add(currentSubEntity.getNameSpace());
|
ns.add(currentSubEntity.getNameSpace());
|
||||||
iden.add(currentSubEntity.getIdentifier());
|
iden.add(currentSubEntity.getIdentifier());
|
||||||
|
@ -168,7 +168,6 @@ public class UAService {
|
|||||||
return new ArrayList<>(opcUaClients.keySet());
|
return new ArrayList<>(opcUaClients.keySet());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private OpcUaClient createClient(PLCConfig plcConfig) throws Exception {
|
private OpcUaClient createClient(PLCConfig plcConfig) throws Exception {
|
||||||
//会获取系统的临时目录 可能是linux 或者 是windows
|
//会获取系统的临时目录 可能是linux 或者 是windows
|
||||||
//Path securityTempDir = Paths.get(System.getProperty("java.io.tmpdir"), "security");
|
//Path securityTempDir = Paths.get(System.getProperty("java.io.tmpdir"), "security");
|
||||||
@ -216,6 +215,7 @@ public class UAService {
|
|||||||
endpoints = DiscoveryClient.getEndpoints(discoveryUrl).get();
|
endpoints = DiscoveryClient.getEndpoints(discoveryUrl).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MessageSecurityMode filterMessageMode = MessageSecurityMode.from(plcConfig.getMessageMode());
|
MessageSecurityMode filterMessageMode = MessageSecurityMode.from(plcConfig.getMessageMode());
|
||||||
|
|
||||||
EndpointDescription endpoint = endpoints.stream()
|
EndpointDescription endpoint = endpoints.stream()
|
||||||
@ -1182,7 +1182,9 @@ public class UAService {
|
|||||||
users = user_configs.split(",");
|
users = user_configs.split(",");
|
||||||
}
|
}
|
||||||
PLCConfig plcConfig = new PLCConfig(plcName, url_config, SecurityPolicy.valueOf(policy_config), users, ip,messageMode);
|
PLCConfig plcConfig = new PLCConfig(plcName, url_config, SecurityPolicy.valueOf(policy_config), users, ip,messageMode);
|
||||||
opcUaClients.put(plcName,createClient(plcConfig));
|
OpcUaClient client = createClient(plcConfig);
|
||||||
|
|
||||||
|
opcUaClients.put(plcName,client);
|
||||||
opcUaClients.get(plcName).connect().get();
|
opcUaClients.get(plcName).connect().get();
|
||||||
|
|
||||||
//只有当写入无异常的时候在录到本地json文件中去
|
//只有当写入无异常的时候在录到本地json文件中去
|
||||||
@ -1232,8 +1234,11 @@ public class UAService {
|
|||||||
logger.error(err);
|
logger.error(err);
|
||||||
|
|
||||||
//出现异常后把 连接给中断,,然后回收资源
|
//出现异常后把 连接给中断,,然后回收资源
|
||||||
opcUaClients.get(plcName).disconnect().get();
|
OpcUaClient uaClient = opcUaClients.get(plcName);
|
||||||
opcUaClients.remove(plcName);
|
if(uaClient!=null){
|
||||||
|
opcUaClients.get(plcName).disconnect().get();
|
||||||
|
opcUaClients.remove(plcName);
|
||||||
|
}
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
package com.qgs.dc;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
|
||||||
|
|
||||||
@SpringBootTest
|
|
||||||
class DcApplicationTests {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void contextLoads() {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user