汪菘 2 months ago
parent
commit
b821f7e349
  1. 5
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/AcsConfig.java
  2. 5
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/opc/DeviceOpcProtocolRunable.java
  3. 8
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/opc/TestOpcUA.java
  4. 9
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/utils/ReadUtil.java

5
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/AcsConfig.java

@ -78,6 +78,11 @@ public interface AcsConfig {
*/ */
String HASWMS = "hasWms"; String HASWMS = "hasWms";
/**
* OPC数据源URL
*/
String OPCURL = "opcUrl";
/** /**
* 是否请求wms系统 * 是否请求wms系统
*/ */

5
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/opc/DeviceOpcProtocolRunable.java

@ -345,9 +345,12 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC
} }
} }
private final static String endPointUrl = "opc.tcp://127.0.0.1:49320";
// private final static String endPointUrl = "opc.tcp://127.0.0.1:49320";
private static OpcUaClient createClient() throws Exception { private static OpcUaClient createClient() throws Exception {
ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class);
String endPointUrl = paramService.findByCode(AcsConfig.OPCURL).getValue();
//opc ua服务端地址 //opc ua服务端地址
Path securityTempDir = Paths.get(System.getProperty("java.io.tmpdir"), "security"); Path securityTempDir = Paths.get(System.getProperty("java.io.tmpdir"), "security");
Files.createDirectories(securityTempDir); Files.createDirectories(securityTempDir);

8
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/opc/TestOpcUA.java

@ -19,6 +19,9 @@ import org.eclipse.milo.opcua.stack.core.types.enumerated.TimestampsToReturn;
import org.eclipse.milo.opcua.stack.core.types.structured.MonitoredItemCreateRequest; import org.eclipse.milo.opcua.stack.core.types.structured.MonitoredItemCreateRequest;
import org.eclipse.milo.opcua.stack.core.types.structured.MonitoringParameters; import org.eclipse.milo.opcua.stack.core.types.structured.MonitoringParameters;
import org.eclipse.milo.opcua.stack.core.types.structured.ReadValueId; import org.eclipse.milo.opcua.stack.core.types.structured.ReadValueId;
import org.nl.acs.AcsConfig;
import org.nl.config.SpringContextHolder;
import org.nl.system.service.param.ISysParamService;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
@ -32,13 +35,16 @@ import java.util.concurrent.atomic.AtomicInteger;
public class TestOpcUA { public class TestOpcUA {
// private final static String endPointUrl = "opc.tcp://192.168.10.60:49320"; // private final static String endPointUrl = "opc.tcp://192.168.10.60:49320";
private final static String endPointUrl = "opc.tcp://127.0.0.1:49320"; // private final static String endPointUrl = "opc.tcp://127.0.0.1:49320";
/** /**
* 创建OPC UA客户端 * 创建OPC UA客户端
*/ */
private static OpcUaClient createClient() throws Exception { private static OpcUaClient createClient() throws Exception {
ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class);
String endPointUrl = paramService.findByCode(AcsConfig.OPCURL).getValue();
//opc ua服务端地址 //opc ua服务端地址
Path securityTempDir = Paths.get(System.getProperty("java.io.tmpdir"), "security"); Path securityTempDir = Paths.get(System.getProperty("java.io.tmpdir"), "security");
Files.createDirectories(securityTempDir); Files.createDirectories(securityTempDir);

9
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/utils/ReadUtil.java

@ -15,6 +15,7 @@ import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger;
import org.eclipse.milo.opcua.stack.core.types.enumerated.TimestampsToReturn; import org.eclipse.milo.opcua.stack.core.types.enumerated.TimestampsToReturn;
import org.jinterop.dcom.common.JIException; import org.jinterop.dcom.common.JIException;
import org.jinterop.dcom.core.JIVariant; import org.jinterop.dcom.core.JIVariant;
import org.nl.acs.AcsConfig;
import org.nl.acs.device.device_driver.standard_inspect.ItemDto; import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
import org.nl.acs.device.device_driver.standard_inspect.ItemProtocol; import org.nl.acs.device.device_driver.standard_inspect.ItemProtocol;
import org.nl.acs.opc.OpcUtl; import org.nl.acs.opc.OpcUtl;
@ -23,6 +24,7 @@ import org.nl.acs.opc.service.mapper.OpcMapper;
import org.nl.common.exception.BadRequestException; import org.nl.common.exception.BadRequestException;
import org.nl.config.SpringContextHolder; import org.nl.config.SpringContextHolder;
import org.nl.config.language.LangProcess; import org.nl.config.language.LangProcess;
import org.nl.system.service.param.ISysParamService;
import org.openscada.opc.dcom.list.ClassDetails; import org.openscada.opc.dcom.list.ClassDetails;
import org.openscada.opc.lib.common.AlreadyConnectedException; import org.openscada.opc.lib.common.AlreadyConnectedException;
import org.openscada.opc.lib.common.ConnectionInformation; import org.openscada.opc.lib.common.ConnectionInformation;
@ -44,6 +46,7 @@ import java.util.concurrent.Executors;
@Slf4j @Slf4j
public class ReadUtil { public class ReadUtil {
static OpcMapper opcMapper = SpringContextHolder.getBean("opcMapper"); static OpcMapper opcMapper = SpringContextHolder.getBean("opcMapper");
public static Server getServer(String opc_id) { public static Server getServer(String opc_id) {
@ -78,7 +81,11 @@ public class ReadUtil {
* 创建OPC UA客户端 * 创建OPC UA客户端
*/ */
private static OpcUaClient createClient() throws Exception { private static OpcUaClient createClient() throws Exception {
String endPointUrl = "opc.tcp://127.0.0.1:49320"; ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class);
String endPointUrl = paramService.findByCode(AcsConfig.OPCURL).getValue();
if (StrUtil.isEmpty(endPointUrl)){
throw new BadRequestException("opc地址未配置!");
}
//opc ua服务端地址 //opc ua服务端地址
Path securityTempDir = Paths.get(System.getProperty("java.io.tmpdir"), "security"); Path securityTempDir = Paths.get(System.getProperty("java.io.tmpdir"), "security");

Loading…
Cancel
Save