|
@@ -1,18 +1,12 @@
|
|
|
package com.judong.chuanyiserver.util;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.judong.chuanyiserver.config.OpcAsyncTask;
|
|
|
+import com.judong.chuanyiserver.opc.OpcAsyncTask;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.jinterop.dcom.core.JIVariant;
|
|
|
import org.junit.Test;
|
|
|
import org.junit.runner.RunWith;
|
|
|
-import org.openscada.opc.dcom.list.ClassDetails;
|
|
|
-import org.openscada.opc.dcom.list.impl.OPCServerList;
|
|
|
import org.openscada.opc.lib.common.ConnectionInformation;
|
|
|
import org.openscada.opc.lib.da.*;
|
|
|
-import org.openscada.opc.lib.list.Categories;
|
|
|
-import org.openscada.opc.lib.list.Category;
|
|
|
-import org.openscada.opc.lib.list.ServerList;
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
|
@@ -62,10 +56,12 @@ public class TestUtil {
|
|
|
ConnectionInformation ci = new ConnectionInformation();
|
|
|
Server server = null;
|
|
|
try {
|
|
|
- ci.setHost("192.168.1.99");
|
|
|
+// ci.setHost("192.168.1.99");
|
|
|
+ ci.setHost("192.168.0.7");
|
|
|
ci.setDomain("");
|
|
|
ci.setUser("administrator");
|
|
|
- ci.setPassword("asdf");
|
|
|
+// ci.setPassword("asdf");
|
|
|
+ ci.setPassword("jd123456");
|
|
|
ci.setClsid("7BC0CC8E-482C-47CA-ABDC-0FE7F9C6E729");
|
|
|
// ci.setClsid("3C5702A2-EB8E-11D4-83A4-00105A984CBD");
|
|
|
// ci.setClsid("75d00bbb-dda5-11d1-b944-9e614d000000");
|
|
@@ -74,17 +70,34 @@ public class TestUtil {
|
|
|
server.connect();
|
|
|
Group group = server.addGroup();
|
|
|
// Item item = group.addItem("通道 1.设备 1._System._SecondsInError");
|
|
|
-// Item item = group.addItem("通道 1.设备 1._System._SecondsInError");
|
|
|
+ Item item = group.addItem("通道 1.设备 1._System._SecondsInError");
|
|
|
|
|
|
// Item item = group.addItem("FIX.RM.LT001.F_CV");
|
|
|
- Item item = group.addItem("FIX.LT001.F_CV");
|
|
|
+// Item item = group.addItem("FIX.LT001.F_CV");
|
|
|
|
|
|
// Item item = group.addItem("@LOCALMACHINE::.内部变量.AI2");
|
|
|
// Item item = group.addItem("AI2");
|
|
|
// opcAsyncTask.read(item);
|
|
|
+ List<String> stringList=new ArrayList<>();
|
|
|
+ server.addStateListener(new ServerConnectionStateListener() {
|
|
|
+ @Override
|
|
|
+ public void connectionStateChanged(boolean connected) {
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ AccessBase access = new Async20Access(server, 500, true);
|
|
|
+ access.addItem("通道 1.设备 1._System._SecondsInError", new DataCallback() {
|
|
|
+ @Override
|
|
|
+ public void changed(Item item, ItemState itemState) {
|
|
|
+ stringList.add("1");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ access.bind();
|
|
|
+ System.err.println(stringList);
|
|
|
+ JIVariant value = item.read(true).getValue();
|
|
|
|
|
|
- Map<String, Object> value = KepOpcServerUtil.getVal(item.read(true).getValue());
|
|
|
- System.err.println(value);
|
|
|
+// Map<String, Object> value = KepOpcServerUtil.getVal(item.read(true).getValue());
|
|
|
+// System.err.println(value);
|
|
|
|
|
|
|
|
|
// dumpTree(server.getTreeBrowser().browse(), 0);
|