|
@@ -11,28 +11,16 @@ import org.eclipse.milo.opcua.sdk.client.api.identity.UsernameProvider;
|
|
|
import org.eclipse.milo.opcua.sdk.client.nodes.UaNode;
|
|
|
import org.eclipse.milo.opcua.stack.client.DiscoveryClient;
|
|
|
import org.eclipse.milo.opcua.stack.core.Identifiers;
|
|
|
-import org.eclipse.milo.opcua.stack.core.Stack;
|
|
|
import org.eclipse.milo.opcua.stack.core.UaException;
|
|
|
import org.eclipse.milo.opcua.stack.core.security.SecurityPolicy;
|
|
|
import org.eclipse.milo.opcua.stack.core.types.builtin.LocalizedText;
|
|
|
-import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId;
|
|
|
import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned;
|
|
|
-import org.eclipse.milo.opcua.stack.core.types.enumerated.TimestampsToReturn;
|
|
|
import org.eclipse.milo.opcua.stack.core.types.structured.EndpointDescription;
|
|
|
-import org.jinterop.dcom.common.JIException;
|
|
|
-import org.openscada.opc.dcom.da.OPCSERVERSTATE;
|
|
|
-import org.openscada.opc.lib.da.Server;
|
|
|
-import org.openscada.opc.lib.da.browser.Branch;
|
|
|
-import org.openscada.opc.lib.da.browser.TreeBrowser;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
-import java.net.UnknownHostException;
|
|
|
import java.nio.file.Files;
|
|
|
import java.nio.file.Path;
|
|
|
import java.nio.file.Paths;
|
|
|
import java.util.ArrayList;
|
|
|
-import java.util.Collection;
|
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
@@ -60,7 +48,7 @@ public class OpcServerUaUtil {
|
|
|
log.info("无法创建安全目录: " + securityTempDir);
|
|
|
return null;
|
|
|
}
|
|
|
- KeyStoreLoader keyStoreLoader = new KeyStoreLoader();
|
|
|
+ KeyStoreLoader keyStoreLoader=new KeyStoreLoader();
|
|
|
KeyStoreLoader loader = keyStoreLoader.load(securityTempDir);
|
|
|
// 搜索OPC节点
|
|
|
List<EndpointDescription> endpoints = null;
|
|
@@ -157,8 +145,11 @@ public class OpcServerUaUtil {
|
|
|
OpcUaClient opcUaClient = null;
|
|
|
try {
|
|
|
opcUaClient = createClient(serverInformation);
|
|
|
+ if (Blank.isEmpty(opcUaClient)){
|
|
|
+ return Result.no(ResultEnum.REQUEST_TIME_OUT.getRespCode(), "客户端创建失败");
|
|
|
+ }
|
|
|
long start = System.currentTimeMillis();
|
|
|
- opcUaClient.connect();
|
|
|
+ opcUaClient.connect().get();
|
|
|
long finish = System.currentTimeMillis();
|
|
|
log.info("连接耗费时间为:" + (finish - start) + "毫秒");
|
|
|
return Result.ok(true);
|