更新
このコミットが含まれているのは:
コミット
09035cd750
3
pom.xml
3
pom.xml
@ -157,8 +157,9 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>2.5.4</version>
|
||||
|
||||
|
||||
<configuration>
|
||||
|
||||
<excludes>
|
||||
<exclude>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
|
@ -69,6 +69,9 @@ public class OperateController {
|
||||
List<CurrentSubEntity> currentSubscribeVarForVisited = uaService.getCurrentSubscribeVarForVisited(plcName);
|
||||
List<Integer> ns = new ArrayList<>();
|
||||
List<String> iden = new ArrayList<>();
|
||||
if(currentSubscribeVarForVisited == null){
|
||||
return;
|
||||
}
|
||||
for(CurrentSubEntity currentSubEntity:currentSubscribeVarForVisited){
|
||||
ns.add(currentSubEntity.getNameSpace());
|
||||
iden.add(currentSubEntity.getIdentifier());
|
||||
|
@ -168,7 +168,6 @@ public class UAService {
|
||||
return new ArrayList<>(opcUaClients.keySet());
|
||||
}
|
||||
|
||||
|
||||
private OpcUaClient createClient(PLCConfig plcConfig) throws Exception {
|
||||
//会获取系统的临时目录 可能是linux 或者 是windows
|
||||
//Path securityTempDir = Paths.get(System.getProperty("java.io.tmpdir"), "security");
|
||||
@ -216,6 +215,7 @@ public class UAService {
|
||||
endpoints = DiscoveryClient.getEndpoints(discoveryUrl).get();
|
||||
}
|
||||
|
||||
|
||||
MessageSecurityMode filterMessageMode = MessageSecurityMode.from(plcConfig.getMessageMode());
|
||||
|
||||
EndpointDescription endpoint = endpoints.stream()
|
||||
@ -1182,7 +1182,9 @@ public class UAService {
|
||||
users = user_configs.split(",");
|
||||
}
|
||||
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();
|
||||
|
||||
//只有当写入无异常的时候在录到本地json文件中去
|
||||
@ -1232,8 +1234,11 @@ public class UAService {
|
||||
logger.error(err);
|
||||
|
||||
//出现异常后把 连接给中断,,然后回收资源
|
||||
opcUaClients.get(plcName).disconnect().get();
|
||||
opcUaClients.remove(plcName);
|
||||
OpcUaClient uaClient = opcUaClients.get(plcName);
|
||||
if(uaClient!=null){
|
||||
opcUaClients.get(plcName).disconnect().get();
|
||||
opcUaClients.remove(plcName);
|
||||
}
|
||||
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() {
|
||||
}
|
||||
|
||||
}
|
読み込み中…
新しいイシューから参照
ユーザーをブロックする