mirror of
https://github.com/luoyan35714/OPC_Client.git
synced 2026-03-30 00:00:02 +08:00
Add the Utgard resources
This commit is contained in:
@@ -1,10 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src/main/resources"/>
|
||||
<classpathentry kind="src" path="src/main/java"/>
|
||||
<classpathentry kind="lib" path="lib/org.openscada.opc.dcom_1.1.0.v20130529.jar"/>
|
||||
<classpathentry kind="lib" path="lib/org.openscada.opc.lib_1.1.0.v20130529.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
|
||||
<classpathentry including="**/*.java" kind="src" path="src/main/resources"/>
|
||||
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
|
||||
@@ -4,27 +4,6 @@
|
||||
<groupId>com.freud.opc</groupId>
|
||||
<artifactId>OPC_Client_Utgard</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<build>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src</directory>
|
||||
<excludes>
|
||||
<exclude>**/*.java</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.0</version>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
@@ -37,6 +16,18 @@
|
||||
<artifactId>j-interop</artifactId>
|
||||
<version>2.0.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.openscada.opc.dcom</groupId>
|
||||
<artifactId>org.openscada.opc.dcom</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.openscada.utgard</groupId>
|
||||
<artifactId>org.openscada.opc.lib</artifactId>
|
||||
<version>1.1.0.v20130529</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -44,7 +44,6 @@ public class OPCTest4 {
|
||||
access.addItem("Random.Real5", new DataCallback() {
|
||||
private int i;
|
||||
|
||||
@Override
|
||||
public void changed(Item item, ItemState itemstate) {
|
||||
System.out.println("[" + (++i) + "],ItemName:[" + item.getId()
|
||||
+ "],value:" + itemstate.getValue());
|
||||
|
||||
@@ -45,7 +45,6 @@ public class OPCTest5 {
|
||||
|
||||
private int count;
|
||||
|
||||
@Override
|
||||
public void changed(Item item, ItemState itemstate) {
|
||||
System.out.println("[" + (++count) + "],ItemName:["
|
||||
+ item.getId() + "],value:" + itemstate.getValue());
|
||||
|
||||
@@ -47,7 +47,6 @@ public class OPCTest6 {
|
||||
access.addItem("Random.Real5", new DataCallback() {
|
||||
private int i;
|
||||
|
||||
@Override
|
||||
public void changed(Item item, ItemState itemstate) {
|
||||
System.out.println("[" + (++i) + "],ItemName:[" + item.getId()
|
||||
+ "],value:" + itemstate.getValue());
|
||||
|
||||
@@ -1,10 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src/main/java"/>
|
||||
<classpathentry kind="src" path="src/main/resources"/>
|
||||
<classpathentry kind="lib" path="lib/org.openscada.opc.dcom_1.1.0.v20130529.jar"/>
|
||||
<classpathentry kind="lib" path="lib/org.openscada.opc.lib_1.1.0.v20130529.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
|
||||
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry including="**/*.java" kind="src" path="src/main/resources"/>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
<name>OPC_Client_Utgard_Performance</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
<project>org.openscada.opc.dcom</project>
|
||||
<project>org.openscada.opc.lib</project>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -4,28 +4,8 @@
|
||||
<groupId>com.freud.opc</groupId>
|
||||
<artifactId>OPC_Client_Utgard_Performance</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<build>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.0</version>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.16</version>
|
||||
</dependency>
|
||||
-->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
@@ -42,6 +22,18 @@
|
||||
<artifactId>j-interop</artifactId>
|
||||
<version>2.0.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.openscada.opc.dcom</groupId>
|
||||
<artifactId>org.openscada.opc.dcom</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.openscada.utgard</groupId>
|
||||
<artifactId>org.openscada.opc.lib</artifactId>
|
||||
<version>1.1.0.v20130529</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -47,8 +47,8 @@ public class SyncPerfTest {
|
||||
OPCGroupStateMgt group = server.addGroup("", true, 1000, 1234, 0, 0.0f,
|
||||
1033);
|
||||
|
||||
//group.getSyncIO().read(source, serverHandles)
|
||||
|
||||
// group.getSyncIO().read(source, serverHandles)
|
||||
|
||||
OPCITEMDEF item = new OPCITEMDEF();
|
||||
|
||||
item.setActive(true);
|
||||
@@ -57,18 +57,13 @@ public class SyncPerfTest {
|
||||
|
||||
group.attach(new IOPCDataCallback() {
|
||||
|
||||
@Override
|
||||
public void writeComplete(int arg0, int arg1, int arg2,
|
||||
ResultSet<Integer> arg3) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readComplete(int arg0, int arg1, int arg2, int arg3,
|
||||
KeyedResultSet<Integer, ValueData> arg4) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dataChange(int arg0, int arg1, int arg2, int arg3,
|
||||
KeyedResultSet<Integer, ValueData> items) {
|
||||
for (KeyedResult<Integer, ValueData> item : items) {
|
||||
@@ -76,8 +71,6 @@ public class SyncPerfTest {
|
||||
+ item.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelComplete(int arg0, int arg1) {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
package com.freud.opc.utgard.perf;
|
||||
|
||||
import static com.freud.opc.utgard.perf.config.ConfigReader.config;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.openscada.opc.dcom.common.KeyedResult;
|
||||
import org.openscada.opc.dcom.common.KeyedResultSet;
|
||||
import org.openscada.opc.dcom.common.ResultSet;
|
||||
import org.openscada.opc.dcom.da.IOPCDataCallback;
|
||||
import org.openscada.opc.dcom.da.OPCDATASOURCE;
|
||||
import org.openscada.opc.dcom.da.ValueData;
|
||||
import org.openscada.opc.dcom.da.impl.OPCAsyncIO2;
|
||||
import org.openscada.opc.lib.common.NotConnectedException;
|
||||
import org.openscada.opc.lib.da.Group;
|
||||
import org.openscada.opc.lib.da.Item;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
|
||||
public class AsyncMultiThreadTest {
|
||||
|
||||
private static final int count = 50;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
for (int i = 1; i <= count; i++) {
|
||||
new Thread(new AsyncMulti(i)).start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class AsyncMulti implements Runnable {
|
||||
|
||||
private static Logger LOGGER = Logger.getLogger(AsyncMulti.class);
|
||||
|
||||
private static final int NUMBER = 4000;
|
||||
private int count_number;
|
||||
|
||||
private static long start;
|
||||
private static long read;
|
||||
private static long end;
|
||||
|
||||
public AsyncMulti(int count_number) {
|
||||
this.count_number = count_number;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
start = System.currentTimeMillis();
|
||||
|
||||
LOGGER.info("Step-" + count_number * NUMBER + " site:");
|
||||
LOGGER.info("StartDate[" + new Date() + "],CurrentMillis:" + start);
|
||||
|
||||
Server server = new Server(config(),
|
||||
Executors.newScheduledThreadPool(4));
|
||||
|
||||
server.connect();
|
||||
|
||||
final Group group = server.addGroup("Group-" + count_number);
|
||||
group.setActive(true);
|
||||
Item[] items = new Item[NUMBER];
|
||||
|
||||
for (int i = (count_number - 1) * NUMBER; i < count_number * NUMBER; i++) {
|
||||
items[i % NUMBER] = group.addItem("Random.Int" + i);
|
||||
}
|
||||
|
||||
read = System.currentTimeMillis();
|
||||
group.attach(new IOPCDataCallback() {
|
||||
|
||||
public void writeComplete(int arg0, int arg1, int arg2,
|
||||
ResultSet<Integer> arg3) {
|
||||
}
|
||||
|
||||
public void readComplete(int arg0, int arg1, int arg2,
|
||||
int arg3, KeyedResultSet<Integer, ValueData> arg4) {
|
||||
}
|
||||
|
||||
public void dataChange(int arg0, int arg1, int arg2, int arg3,
|
||||
KeyedResultSet<Integer, ValueData> result) {
|
||||
int i = 0;
|
||||
for (final KeyedResult<Integer, ValueData> entry : result) {
|
||||
i++;
|
||||
}
|
||||
|
||||
if (i == NUMBER) {
|
||||
end = System.currentTimeMillis();
|
||||
LOGGER.info("Total Use[" + (end - start)
|
||||
+ "] and Async Read[" + (end - read) + "]");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void cancelComplete(int arg0, int arg1) {
|
||||
}
|
||||
});
|
||||
|
||||
final OPCAsyncIO2 async20 = group.getAsyncIO20();
|
||||
if (async20 == null) {
|
||||
throw new NotConnectedException();
|
||||
}
|
||||
|
||||
group.getAsyncIO20().refresh(OPCDATASOURCE.OPC_DS_CACHE, 0);
|
||||
|
||||
group.setActive(false);
|
||||
|
||||
Thread.sleep(3000);
|
||||
|
||||
group.clear();
|
||||
group.remove();
|
||||
|
||||
server.disconnect();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,7 +3,6 @@ package com.freud.opc.utgard.perf;
|
||||
import static com.freud.opc.utgard.perf.config.ConfigReader.config;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
@@ -16,18 +15,19 @@ import org.openscada.opc.dcom.da.ValueData;
|
||||
import org.openscada.opc.dcom.da.impl.OPCAsyncIO2;
|
||||
import org.openscada.opc.lib.common.NotConnectedException;
|
||||
import org.openscada.opc.lib.da.Group;
|
||||
import org.openscada.opc.lib.da.Item;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
|
||||
public class AsyncOPCPerfTest {
|
||||
|
||||
private static Logger LOGGER = Logger.getLogger(AsyncOPCPerfTest.class);
|
||||
|
||||
private static final int NUMBER = 10;
|
||||
private static final int count = 1;
|
||||
public static long start;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
private static final int count = 4000;
|
||||
private static long start;
|
||||
private static long read;
|
||||
private static long end;
|
||||
|
||||
private static void testSteps(final int count) throws Exception {
|
||||
start = System.currentTimeMillis();
|
||||
|
||||
LOGGER.info("Step-" + count + "W:");
|
||||
@@ -38,62 +38,61 @@ public class AsyncOPCPerfTest {
|
||||
|
||||
server.connect();
|
||||
|
||||
Group group = server.addGroup("Freud");
|
||||
// AsyncResult result = group.getAsyncIO20().read(transactionId,
|
||||
// serverHandles);
|
||||
Group group = server.addGroup("Group");
|
||||
group.setActive(true);
|
||||
Item[] items = new Item[count];
|
||||
|
||||
group.addItem("Read Error.Int1");
|
||||
group.addItem("Random.Int1");
|
||||
|
||||
OPCAsyncIO2 async20 = group.getAsyncIO20();
|
||||
|
||||
if (async20 == null)
|
||||
throw new NotConnectedException();
|
||||
async20.refresh(OPCDATASOURCE.OPC_DS_DEVICE, 0);
|
||||
for (int i = 1; i <= count; i++) {
|
||||
items[i - 1] = group.addItem("Random.Int" + i);
|
||||
}
|
||||
|
||||
read = System.currentTimeMillis();
|
||||
group.attach(new IOPCDataCallback() {
|
||||
|
||||
@Override
|
||||
public void writeComplete(int arg0, int arg1, int arg2,
|
||||
ResultSet<Integer> arg3) {
|
||||
System.out.println("Write Complete");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readComplete(int arg0, int arg1, int arg2, int arg3,
|
||||
KeyedResultSet<Integer, ValueData> arg4) {
|
||||
System.out.println("Read Complete");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dataChange(int arg0, int arg1, int arg2, int arg3,
|
||||
KeyedResultSet<Integer, ValueData> arg4) {
|
||||
Iterator<KeyedResult<Integer, ValueData>> ite = arg4.iterator();
|
||||
KeyedResultSet<Integer, ValueData> result) {
|
||||
int i = 0;
|
||||
while (ite.hasNext()) {
|
||||
KeyedResult<Integer, ValueData> value = ite.next();
|
||||
System.out.println((++i) + "-" + value.getKey() + "--"
|
||||
+ value.getValue().getValue());
|
||||
for (final KeyedResult<Integer, ValueData> entry : result) {
|
||||
i++;
|
||||
}
|
||||
|
||||
if (i == count) {
|
||||
end = System.currentTimeMillis();
|
||||
LOGGER.info("Total Use[" + (end - start)
|
||||
+ "] and Async Read[" + (end - read) + "]");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelComplete(int arg0, int arg1) {
|
||||
System.out.println("Cancel Complete");
|
||||
}
|
||||
});
|
||||
|
||||
// AccessBase access = new SyncAccess(server, 1000);
|
||||
//
|
||||
// int limit = count * NUMBER;
|
||||
// for (int i = 0; i < limit; i++) {
|
||||
// access.addItem("Random.Real" + i, new DataCallBackListener(limit));
|
||||
// }
|
||||
//
|
||||
// access.bind();
|
||||
Thread.sleep(100000);
|
||||
// access.unbind();
|
||||
final OPCAsyncIO2 async20 = group.getAsyncIO20();
|
||||
if (async20 == null) {
|
||||
throw new NotConnectedException();
|
||||
}
|
||||
|
||||
server.dispose();
|
||||
group.getAsyncIO20().refresh(OPCDATASOURCE.OPC_DS_CACHE, 0);
|
||||
|
||||
group.setActive(false);
|
||||
|
||||
Thread.sleep(3000);
|
||||
|
||||
group.clear();
|
||||
group.remove();
|
||||
|
||||
server.disconnect();
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
testSteps(count);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.freud.opc.utgard.perf;
|
||||
import static com.freud.opc.utgard.perf.config.ConfigReader.config;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
@@ -11,16 +10,14 @@ import org.openscada.opc.dcom.common.KeyedResultSet;
|
||||
import org.openscada.opc.dcom.common.ResultSet;
|
||||
import org.openscada.opc.dcom.da.IOPCDataCallback;
|
||||
import org.openscada.opc.dcom.da.ValueData;
|
||||
import org.openscada.opc.lib.da.Async20Access;
|
||||
import org.openscada.opc.lib.da.Group;
|
||||
import org.openscada.opc.lib.da.Item;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
|
||||
public class PublishOPCPerfTest {
|
||||
|
||||
private static Logger LOGGER = Logger.getLogger(PublishOPCPerfTest.class);
|
||||
|
||||
private static final int NUMBER = 10000;
|
||||
//private static final int NUMBER = 10000;
|
||||
private static final int WAN_NUMBER = 1;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
@@ -42,27 +39,23 @@ public class PublishOPCPerfTest {
|
||||
|
||||
Group group = server.addGroup("Group");
|
||||
|
||||
Map<String, Item> map = group.addItems("Random.int" + 1);
|
||||
//Map<String, Item> map = group.addItems("Random.int" + 1);
|
||||
|
||||
group.attach(new IOPCDataCallback() {
|
||||
|
||||
@Override
|
||||
public void writeComplete(int i, int j, int k,
|
||||
ResultSet<Integer> resultset) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readComplete(int i, int j, int k, int l,
|
||||
KeyedResultSet<Integer, ValueData> keyedresultset) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dataChange(int i, int j, int k, int l,
|
||||
KeyedResultSet<Integer, ValueData> keyedresultset) {
|
||||
System.out.println("DataChanged");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelComplete(int i, int j) {
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
package com.freud.opc.utgard.perf;
|
||||
|
||||
import static com.freud.opc.utgard.perf.config.ConfigReader.config;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.openscada.opc.dcom.common.KeyedResultSet;
|
||||
import org.openscada.opc.dcom.common.ResultSet;
|
||||
import org.openscada.opc.dcom.da.IOPCDataCallback;
|
||||
import org.openscada.opc.dcom.da.ValueData;
|
||||
import org.openscada.opc.lib.da.Group;
|
||||
import org.openscada.opc.lib.da.Item;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
|
||||
public class Test {
|
||||
private static Logger LOGGER = Logger.getLogger(Test.class);
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
LOGGER.info("Step-" + 10 + "W:");
|
||||
LOGGER.info("StartDate[" + new Date() + "],CurrentMillis:" + start);
|
||||
|
||||
Server server = new Server(config(),
|
||||
Executors.newSingleThreadScheduledExecutor());
|
||||
|
||||
server.connect();
|
||||
|
||||
Group group = server.addGroup();
|
||||
Item item = group.addItem("Random.int4");
|
||||
|
||||
group.setActive(true);
|
||||
group.setActive(true, item);
|
||||
|
||||
group.attach(new IOPCDataCallback() {
|
||||
|
||||
@Override
|
||||
public void writeComplete(int i, int j, int k,
|
||||
ResultSet<Integer> resultset) {
|
||||
System.out.println("Write Complete");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readComplete(int i, int j, int k, int l,
|
||||
KeyedResultSet<Integer, ValueData> keyedresultset) {
|
||||
System.out.println("Read Complete");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dataChange(int i, int j, int k, int l,
|
||||
KeyedResultSet<Integer, ValueData> keyedresultset) {
|
||||
System.out.println("Data change");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelComplete(int i, int j) {
|
||||
System.out.println("Cancel Complete");
|
||||
}
|
||||
});
|
||||
|
||||
Thread.sleep(10 * 1000);
|
||||
|
||||
server.disconnect();
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package com.freud.opc.utgard.perf.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.openscada.opc.lib.da.DataCallback;
|
||||
import org.openscada.opc.lib.da.Item;
|
||||
import org.openscada.opc.lib.da.ItemState;
|
||||
|
||||
import com.freud.opc.utgard.perf.AsyncOPCPerfTest;
|
||||
|
||||
public class DataCallBackListener implements DataCallback {
|
||||
|
||||
private static Logger LOGGER = Logger.getLogger(DataCallBackListener.class);
|
||||
|
||||
private static List<String> items = new ArrayList<String>();
|
||||
|
||||
private int size;
|
||||
|
||||
public DataCallBackListener(int size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changed(Item item, ItemState is) {
|
||||
LOGGER.info("Item:[" + item.getId() + "], Value:[" + is.getValue()
|
||||
+ "]");
|
||||
items.add(item.getId());
|
||||
if (items.size() == size) {
|
||||
long end = System.currentTimeMillis();
|
||||
LOGGER.info("EndDate[" + new Date() + "],CurrentMillis:" + end);
|
||||
LOGGER.info("Total Spend:[" + (end - AsyncOPCPerfTest.start) + "]");
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,101 @@
|
||||
2014-12-09 10:18:20,882-[TS] INFO main com.freud.opc.utgard.perf.Test - Step-10W:
|
||||
2014-12-09 10:18:20,885-[TS] INFO main com.freud.opc.utgard.perf.Test - StartDate[Tue Dec 09 10:18:20 CST 2014],CurrentMillis:1418091500881
|
||||
2014-12-09 10:18:38,649-[TS] INFO main com.freud.opc.utgard.perf.Test - Step-10W:
|
||||
2014-12-09 10:18:38,651-[TS] INFO main com.freud.opc.utgard.perf.Test - StartDate[Tue Dec 09 10:18:38 CST 2014],CurrentMillis:1418091518648
|
||||
2014-12-09 10:19:05,380-[TS] INFO main com.freud.opc.utgard.perf.Test - Step-10W:
|
||||
2014-12-09 10:19:05,382-[TS] INFO main com.freud.opc.utgard.perf.Test - StartDate[Tue Dec 09 10:19:05 CST 2014],CurrentMillis:1418091545379
|
||||
2014-12-09 10:21:34,695-[TS] INFO main com.freud.opc.utgard.perf.Test - Step-10W:
|
||||
2014-12-09 10:21:34,698-[TS] INFO main com.freud.opc.utgard.perf.Test - StartDate[Tue Dec 09 10:21:34 CST 2014],CurrentMillis:1418091694695
|
||||
2014-12-09 10:23:48,822-[TS] INFO main com.freud.opc.utgard.perf.Test - Step-10W:
|
||||
2014-12-09 10:23:48,824-[TS] INFO main com.freud.opc.utgard.perf.Test - StartDate[Tue Dec 09 10:23:48 CST 2014],CurrentMillis:1418091828821
|
||||
2014-12-09 10:27:05,952-[TS] INFO main com.freud.opc.utgard.perf.Test - Step-10W:
|
||||
2014-12-09 10:27:05,955-[TS] INFO main com.freud.opc.utgard.perf.Test - StartDate[Tue Dec 09 10:27:05 CST 2014],CurrentMillis:1418092025952
|
||||
2014-12-10 17:39:43,078-[TS] INFO Thread-0 com.freud.opc.utgard.perf.AsyncMulti - Step-4000 site:
|
||||
2014-12-10 17:39:43,078-[TS] INFO Thread-1 com.freud.opc.utgard.perf.AsyncMulti - Step-8000 site:
|
||||
2014-12-10 17:39:43,079-[TS] INFO Thread-3 com.freud.opc.utgard.perf.AsyncMulti - Step-16000 site:
|
||||
2014-12-10 17:39:43,081-[TS] INFO Thread-0 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383078
|
||||
2014-12-10 17:39:43,082-[TS] INFO Thread-1 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383078
|
||||
2014-12-10 17:39:43,085-[TS] INFO Thread-3 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383078
|
||||
2014-12-10 17:39:43,086-[TS] INFO Thread-4 com.freud.opc.utgard.perf.AsyncMulti - Step-20000 site:
|
||||
2014-12-10 17:39:43,086-[TS] INFO Thread-4 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383086
|
||||
2014-12-10 17:39:43,086-[TS] INFO Thread-5 com.freud.opc.utgard.perf.AsyncMulti - Step-24000 site:
|
||||
2014-12-10 17:39:43,087-[TS] INFO Thread-5 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383086
|
||||
2014-12-10 17:39:43,087-[TS] INFO Thread-7 com.freud.opc.utgard.perf.AsyncMulti - Step-32000 site:
|
||||
2014-12-10 17:39:43,087-[TS] INFO Thread-7 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383087
|
||||
2014-12-10 17:39:43,088-[TS] INFO Thread-8 com.freud.opc.utgard.perf.AsyncMulti - Step-36000 site:
|
||||
2014-12-10 17:39:43,088-[TS] INFO Thread-8 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383088
|
||||
2014-12-10 17:39:43,088-[TS] INFO Thread-9 com.freud.opc.utgard.perf.AsyncMulti - Step-40000 site:
|
||||
2014-12-10 17:39:43,088-[TS] INFO Thread-9 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383088
|
||||
2014-12-10 17:39:43,089-[TS] INFO Thread-2 com.freud.opc.utgard.perf.AsyncMulti - Step-12000 site:
|
||||
2014-12-10 17:39:43,089-[TS] INFO Thread-6 com.freud.opc.utgard.perf.AsyncMulti - Step-28000 site:
|
||||
2014-12-10 17:39:43,089-[TS] INFO Thread-10 com.freud.opc.utgard.perf.AsyncMulti - Step-44000 site:
|
||||
2014-12-10 17:39:43,089-[TS] INFO Thread-14 com.freud.opc.utgard.perf.AsyncMulti - Step-60000 site:
|
||||
2014-12-10 17:39:43,090-[TS] INFO Thread-18 com.freud.opc.utgard.perf.AsyncMulti - Step-76000 site:
|
||||
2014-12-10 17:39:43,090-[TS] INFO Thread-22 com.freud.opc.utgard.perf.AsyncMulti - Step-92000 site:
|
||||
2014-12-10 17:39:43,090-[TS] INFO Thread-26 com.freud.opc.utgard.perf.AsyncMulti - Step-108000 site:
|
||||
2014-12-10 17:39:43,090-[TS] INFO Thread-30 com.freud.opc.utgard.perf.AsyncMulti - Step-124000 site:
|
||||
2014-12-10 17:39:43,090-[TS] INFO Thread-34 com.freud.opc.utgard.perf.AsyncMulti - Step-140000 site:
|
||||
2014-12-10 17:39:43,090-[TS] INFO Thread-38 com.freud.opc.utgard.perf.AsyncMulti - Step-156000 site:
|
||||
2014-12-10 17:39:43,090-[TS] INFO Thread-42 com.freud.opc.utgard.perf.AsyncMulti - Step-172000 site:
|
||||
2014-12-10 17:39:43,090-[TS] INFO Thread-46 com.freud.opc.utgard.perf.AsyncMulti - Step-188000 site:
|
||||
2014-12-10 17:39:43,092-[TS] INFO Thread-46 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383090
|
||||
2014-12-10 17:39:43,092-[TS] INFO Thread-42 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383090
|
||||
2014-12-10 17:39:43,092-[TS] INFO Thread-38 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383090
|
||||
2014-12-10 17:39:43,092-[TS] INFO Thread-34 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383090
|
||||
2014-12-10 17:39:43,092-[TS] INFO Thread-30 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383090
|
||||
2014-12-10 17:39:43,092-[TS] INFO Thread-26 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383090
|
||||
2014-12-10 17:39:43,093-[TS] INFO Thread-22 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383090
|
||||
2014-12-10 17:39:43,093-[TS] INFO Thread-18 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383090
|
||||
2014-12-10 17:39:43,093-[TS] INFO Thread-14 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383090
|
||||
2014-12-10 17:39:43,093-[TS] INFO Thread-11 com.freud.opc.utgard.perf.AsyncMulti - Step-48000 site:
|
||||
2014-12-10 17:39:43,093-[TS] INFO Thread-10 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383093
|
||||
2014-12-10 17:39:43,093-[TS] INFO Thread-11 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383093
|
||||
2014-12-10 17:39:43,096-[TS] INFO Thread-12 com.freud.opc.utgard.perf.AsyncMulti - Step-52000 site:
|
||||
2014-12-10 17:39:43,096-[TS] INFO Thread-49 com.freud.opc.utgard.perf.AsyncMulti - Step-200000 site:
|
||||
2014-12-10 17:39:43,096-[TS] INFO Thread-47 com.freud.opc.utgard.perf.AsyncMulti - Step-192000 site:
|
||||
2014-12-10 17:39:43,096-[TS] INFO Thread-44 com.freud.opc.utgard.perf.AsyncMulti - Step-180000 site:
|
||||
2014-12-10 17:39:43,096-[TS] INFO Thread-41 com.freud.opc.utgard.perf.AsyncMulti - Step-168000 site:
|
||||
2014-12-10 17:39:43,096-[TS] INFO Thread-39 com.freud.opc.utgard.perf.AsyncMulti - Step-160000 site:
|
||||
2014-12-10 17:39:43,096-[TS] INFO Thread-36 com.freud.opc.utgard.perf.AsyncMulti - Step-148000 site:
|
||||
2014-12-10 17:39:43,096-[TS] INFO Thread-33 com.freud.opc.utgard.perf.AsyncMulti - Step-136000 site:
|
||||
2014-12-10 17:39:43,096-[TS] INFO Thread-31 com.freud.opc.utgard.perf.AsyncMulti - Step-128000 site:
|
||||
2014-12-10 17:39:43,096-[TS] INFO Thread-28 com.freud.opc.utgard.perf.AsyncMulti - Step-116000 site:
|
||||
2014-12-10 17:39:43,096-[TS] INFO Thread-25 com.freud.opc.utgard.perf.AsyncMulti - Step-104000 site:
|
||||
2014-12-10 17:39:43,096-[TS] INFO Thread-23 com.freud.opc.utgard.perf.AsyncMulti - Step-96000 site:
|
||||
2014-12-10 17:39:43,096-[TS] INFO Thread-20 com.freud.opc.utgard.perf.AsyncMulti - Step-84000 site:
|
||||
2014-12-10 17:39:43,096-[TS] INFO Thread-17 com.freud.opc.utgard.perf.AsyncMulti - Step-72000 site:
|
||||
2014-12-10 17:39:43,096-[TS] INFO Thread-15 com.freud.opc.utgard.perf.AsyncMulti - Step-64000 site:
|
||||
2014-12-10 17:39:43,096-[TS] INFO Thread-45 com.freud.opc.utgard.perf.AsyncMulti - Step-184000 site:
|
||||
2014-12-10 17:39:43,096-[TS] INFO Thread-48 com.freud.opc.utgard.perf.AsyncMulti - Step-196000 site:
|
||||
2014-12-10 17:39:43,096-[TS] INFO Thread-13 com.freud.opc.utgard.perf.AsyncMulti - Step-56000 site:
|
||||
2014-12-10 17:39:43,096-[TS] INFO Thread-6 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383096
|
||||
2014-12-10 17:39:43,097-[TS] INFO Thread-13 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383096
|
||||
2014-12-10 17:39:43,096-[TS] INFO Thread-16 com.freud.opc.utgard.perf.AsyncMulti - Step-68000 site:
|
||||
2014-12-10 17:39:43,097-[TS] INFO Thread-16 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383096
|
||||
2014-12-10 17:39:43,096-[TS] INFO Thread-19 com.freud.opc.utgard.perf.AsyncMulti - Step-80000 site:
|
||||
2014-12-10 17:39:43,097-[TS] INFO Thread-19 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383096
|
||||
2014-12-10 17:39:43,096-[TS] INFO Thread-21 com.freud.opc.utgard.perf.AsyncMulti - Step-88000 site:
|
||||
2014-12-10 17:39:43,097-[TS] INFO Thread-21 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383096
|
||||
2014-12-10 17:39:43,096-[TS] INFO Thread-24 com.freud.opc.utgard.perf.AsyncMulti - Step-100000 site:
|
||||
2014-12-10 17:39:43,097-[TS] INFO Thread-24 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383096
|
||||
2014-12-10 17:39:43,096-[TS] INFO Thread-27 com.freud.opc.utgard.perf.AsyncMulti - Step-112000 site:
|
||||
2014-12-10 17:39:43,098-[TS] INFO Thread-27 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383096
|
||||
2014-12-10 17:39:43,096-[TS] INFO Thread-29 com.freud.opc.utgard.perf.AsyncMulti - Step-120000 site:
|
||||
2014-12-10 17:39:43,098-[TS] INFO Thread-29 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383096
|
||||
2014-12-10 17:39:43,096-[TS] INFO Thread-32 com.freud.opc.utgard.perf.AsyncMulti - Step-132000 site:
|
||||
2014-12-10 17:39:43,098-[TS] INFO Thread-32 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383096
|
||||
2014-12-10 17:39:43,099-[TS] INFO Thread-48 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383096
|
||||
2014-12-10 17:39:43,096-[TS] INFO Thread-35 com.freud.opc.utgard.perf.AsyncMulti - Step-144000 site:
|
||||
2014-12-10 17:39:43,099-[TS] INFO Thread-35 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383096
|
||||
2014-12-10 17:39:43,096-[TS] INFO Thread-37 com.freud.opc.utgard.perf.AsyncMulti - Step-152000 site:
|
||||
2014-12-10 17:39:43,099-[TS] INFO Thread-37 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383096
|
||||
2014-12-10 17:39:43,099-[TS] INFO Thread-45 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383096
|
||||
2014-12-10 17:39:43,096-[TS] INFO Thread-40 com.freud.opc.utgard.perf.AsyncMulti - Step-164000 site:
|
||||
2014-12-10 17:39:43,100-[TS] INFO Thread-40 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383096
|
||||
2014-12-10 17:39:43,100-[TS] INFO Thread-15 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383096
|
||||
2014-12-10 17:39:43,096-[TS] INFO Thread-43 com.freud.opc.utgard.perf.AsyncMulti - Step-176000 site:
|
||||
2014-12-10 17:39:43,100-[TS] INFO Thread-43 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383096
|
||||
2014-12-10 17:39:43,101-[TS] INFO Thread-17 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383096
|
||||
2014-12-10 17:39:43,101-[TS] INFO Thread-20 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383096
|
||||
2014-12-10 17:39:43,101-[TS] INFO Thread-23 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383096
|
||||
2014-12-10 17:39:43,102-[TS] INFO Thread-25 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383096
|
||||
2014-12-10 17:39:43,102-[TS] INFO Thread-28 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383096
|
||||
2014-12-10 17:39:43,098-[TS] INFO Thread-2 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383096
|
||||
2014-12-10 17:39:43,102-[TS] INFO Thread-31 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383096
|
||||
2014-12-10 17:39:43,102-[TS] INFO Thread-33 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383096
|
||||
2014-12-10 17:39:43,103-[TS] INFO Thread-36 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383096
|
||||
2014-12-10 17:39:43,103-[TS] INFO Thread-39 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383096
|
||||
2014-12-10 17:39:43,104-[TS] INFO Thread-41 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383096
|
||||
2014-12-10 17:39:43,104-[TS] INFO Thread-44 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383096
|
||||
2014-12-10 17:39:43,104-[TS] INFO Thread-47 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383096
|
||||
2014-12-10 17:39:43,105-[TS] INFO Thread-49 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383096
|
||||
2014-12-10 17:39:43,106-[TS] INFO Thread-12 com.freud.opc.utgard.perf.AsyncMulti - StartDate[Wed Dec 10 17:39:43 CST 2014],CurrentMillis:1418204383096
|
||||
|
||||
|
||||
12
OPC_Client_Utgard_Performance/utgard_result.log.2014-12-09
Normal file
12
OPC_Client_Utgard_Performance/utgard_result.log.2014-12-09
Normal file
@@ -0,0 +1,12 @@
|
||||
2014-12-09 10:18:20,882-[TS] INFO main com.freud.opc.utgard.perf.Test - Step-10W:
|
||||
2014-12-09 10:18:20,885-[TS] INFO main com.freud.opc.utgard.perf.Test - StartDate[Tue Dec 09 10:18:20 CST 2014],CurrentMillis:1418091500881
|
||||
2014-12-09 10:18:38,649-[TS] INFO main com.freud.opc.utgard.perf.Test - Step-10W:
|
||||
2014-12-09 10:18:38,651-[TS] INFO main com.freud.opc.utgard.perf.Test - StartDate[Tue Dec 09 10:18:38 CST 2014],CurrentMillis:1418091518648
|
||||
2014-12-09 10:19:05,380-[TS] INFO main com.freud.opc.utgard.perf.Test - Step-10W:
|
||||
2014-12-09 10:19:05,382-[TS] INFO main com.freud.opc.utgard.perf.Test - StartDate[Tue Dec 09 10:19:05 CST 2014],CurrentMillis:1418091545379
|
||||
2014-12-09 10:21:34,695-[TS] INFO main com.freud.opc.utgard.perf.Test - Step-10W:
|
||||
2014-12-09 10:21:34,698-[TS] INFO main com.freud.opc.utgard.perf.Test - StartDate[Tue Dec 09 10:21:34 CST 2014],CurrentMillis:1418091694695
|
||||
2014-12-09 10:23:48,822-[TS] INFO main com.freud.opc.utgard.perf.Test - Step-10W:
|
||||
2014-12-09 10:23:48,824-[TS] INFO main com.freud.opc.utgard.perf.Test - StartDate[Tue Dec 09 10:23:48 CST 2014],CurrentMillis:1418091828821
|
||||
2014-12-09 10:27:05,952-[TS] INFO main com.freud.opc.utgard.perf.Test - Step-10W:
|
||||
2014-12-09 10:27:05,955-[TS] INFO main com.freud.opc.utgard.perf.Test - StartDate[Tue Dec 09 10:27:05 CST 2014],CurrentMillis:1418092025952
|
||||
16
org.openscada.opc.dcom.test/.classpath
Normal file
16
org.openscada.opc.dcom.test/.classpath
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
1
org.openscada.opc.dcom.test/.gitignore
vendored
Normal file
1
org.openscada.opc.dcom.test/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
bin/
|
||||
46
org.openscada.opc.dcom.test/.project
Normal file
46
org.openscada.opc.dcom.test/.project
Normal file
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>org.openscada.opc.dcom.test</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.babel.editor.rbeBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.babel.editor.rbeNature</nature>
|
||||
<nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
165
org.openscada.opc.dcom.test/LICENSE
Normal file
165
org.openscada.opc.dcom.test/LICENSE
Normal file
@@ -0,0 +1,165 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
||||
31
org.openscada.opc.dcom.test/pom.xml
Normal file
31
org.openscada.opc.dcom.test/pom.xml
Normal file
@@ -0,0 +1,31 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.openscada.opc.dcom.test</groupId>
|
||||
<artifactId>org.openscada.opc.dcom.test</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<version>1.7.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.kohsuke.jinterop</groupId>
|
||||
<artifactId>j-interop</artifactId>
|
||||
<version>2.0.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openscada.opc.dcom</groupId>
|
||||
<artifactId>org.openscada.opc.dcom</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2009 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.common;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class FiletimeTest1
|
||||
{
|
||||
public static void main ( final String[] args )
|
||||
{
|
||||
FILETIME ft = new FILETIME ( 29949427, 2139800608 );
|
||||
System.out.println ( String.format ( "%s, %tc", ft, ft.asCalendar () ) );
|
||||
|
||||
ft = new FILETIME ( 29949427, -2145016688 );
|
||||
System.out.println ( String.format ( "%s, %tc", ft, ft.asCalendar () ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test ()
|
||||
{
|
||||
assertEquals ( "Thu Aug 14 11:52:43 CEST 2008", new FILETIME ( 29949427, 2139800608 ) );
|
||||
assertEquals ( "Thu Aug 14 11:52:44 CEST 2008", new FILETIME ( 29949427, -2145016688 ) );
|
||||
}
|
||||
|
||||
protected void assertEquals ( final String expected, final FILETIME actual )
|
||||
{
|
||||
Assert.assertEquals ( expected, String.format ( "%tc", actual.asCalendar () ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test2 ()
|
||||
{
|
||||
FILETIME last = null;
|
||||
for ( int i = 0; i < 10000; i++ )
|
||||
{
|
||||
final FILETIME ft = new FILETIME ( 29949427 + i, 2139800608 + i );
|
||||
Assert.assertEquals ( ft.asBigDecimalCalendar (), ft.asCalendar () );
|
||||
|
||||
if ( last != null )
|
||||
{
|
||||
Assert.assertTrue ( last.asCalendar ().before ( ft.asCalendar () ) );
|
||||
}
|
||||
|
||||
last = ft;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test3a ()
|
||||
{
|
||||
for ( int i = 0; i < 10000; i++ )
|
||||
{
|
||||
final FILETIME ft = new FILETIME ( 29949427 + i, 2139800608 + i );
|
||||
ft.asCalendar ();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test3b ()
|
||||
{
|
||||
for ( int i = 0; i < 10000; i++ )
|
||||
{
|
||||
final FILETIME ft = new FILETIME ( 29949427 + i, 2139800608 + i );
|
||||
ft.asBigDecimalCalendar ();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2009 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.da;
|
||||
|
||||
import org.openscada.opc.dcom.common.KeyedResult;
|
||||
import org.openscada.opc.dcom.common.KeyedResultSet;
|
||||
import org.openscada.opc.dcom.common.ResultSet;
|
||||
|
||||
public class DumpDataCallback implements IOPCDataCallback
|
||||
{
|
||||
|
||||
public void cancelComplete ( final int transactionId, final int serverGroupHandle )
|
||||
{
|
||||
System.out.println ( String.format ( "cancelComplete: %08X, Group: %08X", transactionId, serverGroupHandle ) );
|
||||
}
|
||||
|
||||
public void dataChange ( final int transactionId, final int serverGroupHandle, final int masterQuality, final int masterErrorCode, final KeyedResultSet<Integer, ValueData> result )
|
||||
{
|
||||
System.out.println ( String.format ( "dataChange: %d, Group: %08X, MasterQ: %d, Error: %d", transactionId, serverGroupHandle, masterQuality, masterErrorCode ) );
|
||||
|
||||
for ( final KeyedResult<Integer, ValueData> entry : result )
|
||||
{
|
||||
System.out.println ( String.format ( "%08X - Error: %08X, Quality: %d, %Tc - %s", entry.getKey (), entry.getErrorCode (), entry.getValue ().getQuality (), entry.getValue ().getTimestamp (), entry.getValue ().getValue ().toString () ) );
|
||||
}
|
||||
}
|
||||
|
||||
public void readComplete ( final int transactionId, final int serverGroupHandle, final int masterQuality, final int masterErrorCode, final KeyedResultSet<Integer, ValueData> result )
|
||||
{
|
||||
System.out.println ( String.format ( "readComplete: %d, Group: %08X, MasterQ: %d, Error: %d", transactionId, serverGroupHandle, masterQuality, masterErrorCode ) );
|
||||
|
||||
for ( final KeyedResult<Integer, ValueData> entry : result )
|
||||
{
|
||||
System.out.println ( String.format ( "%08X - Error: %08X, Quality: %d, %Tc - %s", entry.getKey (), entry.getErrorCode (), entry.getValue ().getQuality (), entry.getValue ().getTimestamp (), entry.getValue ().getValue ().toString () ) );
|
||||
}
|
||||
}
|
||||
|
||||
public void writeComplete ( final int transactionId, final int serverGroupHandle, final int masterErrorCode, final ResultSet<Integer> result )
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2009 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.da;
|
||||
|
||||
|
||||
public class IconicsSimulationServerConfiguration implements TestConfiguration
|
||||
{
|
||||
|
||||
public String getCLSID ()
|
||||
{
|
||||
return "A879768A-7387-11D4-B0D8-009027242C59";
|
||||
}
|
||||
|
||||
public String getProgId ()
|
||||
{
|
||||
return "ICONICS.SimulatorOPCDA.2";
|
||||
}
|
||||
|
||||
public String[] getReadItems ()
|
||||
{
|
||||
return new String[] { "Logical._BOOL" };
|
||||
}
|
||||
|
||||
public WriteTest[] getWriteItems ()
|
||||
{
|
||||
return new WriteTest[]{};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2009 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.da;
|
||||
|
||||
import org.jinterop.dcom.core.JIVariant;
|
||||
|
||||
public class MatrikonSimulationServerConfiguration implements TestConfiguration
|
||||
{
|
||||
|
||||
public String getCLSID ()
|
||||
{
|
||||
return "F8582CF2-88FB-11D0-B850-00C0F0104305";
|
||||
}
|
||||
|
||||
public String getProgId ()
|
||||
{
|
||||
return "Matrikon.OPC.Simulation.1";
|
||||
}
|
||||
|
||||
public String[] getReadItems ()
|
||||
{
|
||||
return new String[] { "Saw-toothed Waves.Int2", "Saw-toothed Waves.Int4" };
|
||||
}
|
||||
|
||||
public WriteTest[] getWriteItems ()
|
||||
{
|
||||
return new WriteTest[] { new WriteTest ( "Write Only.Int2", new JIVariant ( (short)1202, false ) ), new WriteTest ( "Write Only.Int4", new JIVariant ( 1202, false ) ) };
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2009 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.da;
|
||||
|
||||
public class SoftingDemoServerConfiguration implements TestConfiguration
|
||||
{
|
||||
|
||||
public String getCLSID ()
|
||||
{
|
||||
return "2E565242-B238-11D3-842D-0008C779D775";
|
||||
}
|
||||
|
||||
public String getProgId ()
|
||||
{
|
||||
return "Softing.OPCToolboxDemo_ServerDA.1";
|
||||
}
|
||||
|
||||
public String[] getReadItems ()
|
||||
{
|
||||
return new String[] { "increment.I2", "increment.I4" };
|
||||
}
|
||||
|
||||
public WriteTest[] getWriteItems ()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,475 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2009 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.da;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.jinterop.dcom.common.JISystem;
|
||||
import org.jinterop.dcom.core.IJIComObject;
|
||||
import org.jinterop.dcom.core.JIComServer;
|
||||
import org.jinterop.dcom.core.JIProgId;
|
||||
import org.jinterop.dcom.core.JISession;
|
||||
import org.jinterop.dcom.core.JIVariant;
|
||||
import org.openscada.opc.dcom.common.EventHandler;
|
||||
import org.openscada.opc.dcom.common.KeyedResult;
|
||||
import org.openscada.opc.dcom.common.KeyedResultSet;
|
||||
import org.openscada.opc.dcom.common.Result;
|
||||
import org.openscada.opc.dcom.common.ResultSet;
|
||||
import org.openscada.opc.dcom.common.impl.OPCCommon;
|
||||
import org.openscada.opc.dcom.da.impl.OPCBrowseServerAddressSpace;
|
||||
import org.openscada.opc.dcom.da.impl.OPCGroupStateMgt;
|
||||
import org.openscada.opc.dcom.da.impl.OPCItemIO;
|
||||
import org.openscada.opc.dcom.da.impl.OPCItemMgt;
|
||||
import org.openscada.opc.dcom.da.impl.OPCItemProperties;
|
||||
import org.openscada.opc.dcom.da.impl.OPCServer;
|
||||
import org.openscada.opc.dcom.da.impl.OPCSyncIO;
|
||||
|
||||
public class Test1
|
||||
{
|
||||
private static JISession _session = null;
|
||||
|
||||
public static void showError ( final OPCCommon common, final int errorCode ) throws JIException
|
||||
{
|
||||
System.out.println ( String.format ( "Error (%X): '%s'", errorCode, common.getErrorString ( errorCode, 1033 ) ) );
|
||||
}
|
||||
|
||||
public static void showError ( final OPCServer server, final int errorCode ) throws JIException
|
||||
{
|
||||
showError ( server.getCommon (), errorCode );
|
||||
}
|
||||
|
||||
public static void showAccessPaths ( final OPCBrowseServerAddressSpace browser, final String id ) throws IllegalArgumentException, UnknownHostException, JIException
|
||||
{
|
||||
for ( final String i : browser.browseAccessPaths ( id ).asCollection () )
|
||||
{
|
||||
System.out.println ( "AccessPath Entry: " + i );
|
||||
}
|
||||
}
|
||||
|
||||
public static void browseTree ( final OPCBrowseServerAddressSpace browser ) throws IllegalArgumentException, UnknownHostException, JIException
|
||||
{
|
||||
System.out.println ( "Showing hierarchial address space" );
|
||||
System.out.println ( String.format ( "Organization: %s", browser.queryOrganization () ) );
|
||||
|
||||
if ( !browser.queryOrganization ().equals ( OPCNAMESPACETYPE.OPC_NS_HIERARCHIAL ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
browser.changePosition ( null, OPCBROWSEDIRECTION.OPC_BROWSE_TO );
|
||||
browseTree ( browser, 0 );
|
||||
}
|
||||
|
||||
protected static void browseTree ( final OPCBrowseServerAddressSpace browser, final int level ) throws JIException, IllegalArgumentException, UnknownHostException
|
||||
{
|
||||
final StringBuilder indent = new StringBuilder ( level );
|
||||
for ( int i = 0; i < level; i++ )
|
||||
{
|
||||
indent.append ( '\t' );
|
||||
}
|
||||
for ( final String item : browser.browse ( OPCBROWSETYPE.OPC_LEAF, "", 0, JIVariant.VT_EMPTY ).asCollection () )
|
||||
{
|
||||
System.out.println ( indent + "Leaf: " + item );
|
||||
System.out.println ( indent + "\tName: " + browser.getItemID ( item ) );
|
||||
}
|
||||
|
||||
for ( final String item : browser.browse ( OPCBROWSETYPE.OPC_BRANCH, "", 0, JIVariant.VT_EMPTY ).asCollection () )
|
||||
{
|
||||
System.out.println ( indent + "Branch: " + item );
|
||||
browser.changePosition ( item, OPCBROWSEDIRECTION.OPC_BROWSE_DOWN );
|
||||
browseTree ( browser, level + 1 );
|
||||
browser.changePosition ( null, OPCBROWSEDIRECTION.OPC_BROWSE_UP );
|
||||
}
|
||||
}
|
||||
|
||||
public static void browseFlat ( final OPCBrowseServerAddressSpace browser ) throws JIException, IllegalArgumentException, UnknownHostException
|
||||
{
|
||||
System.out.println ( String.format ( "Organization: %s", browser.queryOrganization () ) );
|
||||
browser.changePosition ( null, OPCBROWSEDIRECTION.OPC_BROWSE_TO );
|
||||
|
||||
System.out.println ( "Showing flat address space" );
|
||||
for ( final String id : browser.browse ( OPCBROWSETYPE.OPC_FLAT, "", 0, JIVariant.VT_EMPTY ).asCollection () )
|
||||
{
|
||||
System.out.println ( "Item: " + id );
|
||||
//showAccessPaths ( browser, id );
|
||||
}
|
||||
}
|
||||
|
||||
public static void dumpGroupState ( final OPCGroupStateMgt group ) throws JIException
|
||||
{
|
||||
final OPCGroupState state = group.getState ();
|
||||
|
||||
System.out.println ( "Name: " + state.getName () );
|
||||
System.out.println ( "Active: " + state.isActive () );
|
||||
System.out.println ( "Update Rate: " + state.getUpdateRate () );
|
||||
System.out.println ( "Time Bias: " + state.getTimeBias () );
|
||||
System.out.println ( "Percent Deadband: " + state.getPercentDeadband () );
|
||||
System.out.println ( "Locale ID: " + state.getLocaleID () );
|
||||
System.out.println ( "Client Handle: " + state.getClientHandle () );
|
||||
System.out.println ( "Server Handle: " + state.getServerHandle () );
|
||||
}
|
||||
|
||||
public static void dumpItemProperties2 ( final OPCItemProperties itemProperties, final String itemID, final int... ids ) throws JIException
|
||||
{
|
||||
final KeyedResultSet<Integer, JIVariant> values = itemProperties.getItemProperties ( itemID, ids );
|
||||
for ( final KeyedResult<Integer, JIVariant> entry : values )
|
||||
{
|
||||
System.out.println ( String.format ( "ID: %d, Value: %s, Error Code: %08x", entry.getKey (), entry.getValue ().toString (), entry.getErrorCode () ) );
|
||||
}
|
||||
}
|
||||
|
||||
public static void dumpItemPropertiesLookup ( final OPCItemProperties itemProperties, final String itemID, final int... ids ) throws JIException
|
||||
{
|
||||
final KeyedResultSet<Integer, String> values = itemProperties.lookupItemIDs ( itemID, ids );
|
||||
for ( final KeyedResult<Integer, String> entry : values )
|
||||
{
|
||||
System.out.println ( String.format ( "ID: %d, Item ID: %s, Error Code: %08x", entry.getKey (), entry.getValue (), entry.getErrorCode () ) );
|
||||
}
|
||||
}
|
||||
|
||||
public static void dumpItemProperties ( final OPCItemProperties itemProperties, final String itemID ) throws JIException
|
||||
{
|
||||
final Collection<PropertyDescription> properties = itemProperties.queryAvailableProperties ( itemID );
|
||||
final int[] ids = new int[properties.size ()];
|
||||
|
||||
System.out.println ( String.format ( "Item Properties for '%s' (count:%d)", itemID, properties.size () ) );
|
||||
int i = 0;
|
||||
for ( final PropertyDescription pd : properties )
|
||||
{
|
||||
ids[i] = pd.getId ();
|
||||
System.out.println ( "ID: " + pd.getId () );
|
||||
System.out.println ( "Description: " + pd.getDescription () );
|
||||
System.out.println ( "Variable Type: " + pd.getVarType () );
|
||||
i++;
|
||||
}
|
||||
|
||||
System.out.println ( "Lookup" );
|
||||
dumpItemPropertiesLookup ( itemProperties, itemID, ids );
|
||||
|
||||
System.out.println ( "Query" );
|
||||
dumpItemProperties2 ( itemProperties, itemID, ids );
|
||||
}
|
||||
|
||||
public static void queryItems ( final OPCItemIO itemIO, final String... items ) throws JIException
|
||||
{
|
||||
final List<IORequest> requests = new LinkedList<IORequest> ();
|
||||
for ( final String item : items )
|
||||
{
|
||||
requests.add ( new IORequest ( item, 0 ) );
|
||||
}
|
||||
itemIO.read ( requests.toArray ( new IORequest[0] ) );
|
||||
}
|
||||
|
||||
public static boolean dumpOPCITEMRESULT ( final KeyedResultSet<OPCITEMDEF, OPCITEMRESULT> result )
|
||||
{
|
||||
int failed = 0;
|
||||
for ( final KeyedResult<OPCITEMDEF, OPCITEMRESULT> resultEntry : result )
|
||||
{
|
||||
System.out.println ( "==================================" );
|
||||
System.out.println ( String.format ( "Item: '%s' ", resultEntry.getKey ().getItemID () ) );
|
||||
|
||||
System.out.println ( String.format ( "Error Code: %08x", resultEntry.getErrorCode () ) );
|
||||
if ( !resultEntry.isFailed () )
|
||||
{
|
||||
System.out.println ( String.format ( "Server Handle: %08X", resultEntry.getValue ().getServerHandle () ) );
|
||||
System.out.println ( String.format ( "Data Type: %d", resultEntry.getValue ().getCanonicalDataType () ) );
|
||||
System.out.println ( String.format ( "Access Rights: %d", resultEntry.getValue ().getAccessRights () ) );
|
||||
System.out.println ( String.format ( "Reserved: %d", resultEntry.getValue ().getReserved () ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
failed++;
|
||||
}
|
||||
}
|
||||
return failed == 0;
|
||||
}
|
||||
|
||||
public static void writeItems ( final OPCServer server, final OPCGroupStateMgt group, final WriteTest... writeTests ) throws IllegalArgumentException, UnknownHostException, JIException
|
||||
{
|
||||
System.out.println ( "Write items" );
|
||||
|
||||
final OPCItemMgt itemManagement = group.getItemManagement ();
|
||||
final OPCITEMDEF[] defs = new OPCITEMDEF[writeTests.length];
|
||||
for ( int i = 0; i < writeTests.length; i++ )
|
||||
{
|
||||
final OPCITEMDEF def = new OPCITEMDEF ();
|
||||
def.setActive ( true );
|
||||
def.setItemID ( writeTests[i].getItemID () );
|
||||
//def.setRequestedDataType ( (short)writeTests[i].getValue ().getType () );
|
||||
defs[i] = def;
|
||||
|
||||
System.out.println ( String.format ( "%s <= (%d) %s", writeTests[i].getItemID (), writeTests[i].getValue ().getType (), writeTests[i].getValue ().toString () ) );
|
||||
}
|
||||
|
||||
System.out.println ( "Add to group" );
|
||||
final KeyedResultSet<OPCITEMDEF, OPCITEMRESULT> result = itemManagement.add ( defs );
|
||||
final WriteRequest[] writeRequests = new WriteRequest[writeTests.length];
|
||||
final Integer[] serverHandles = new Integer[writeTests.length];
|
||||
for ( int i = 0; i < writeTests.length; i++ )
|
||||
{
|
||||
if ( result.get ( i ).getErrorCode () != 0 )
|
||||
{
|
||||
throw new JIException ( result.get ( i ).getErrorCode () );
|
||||
}
|
||||
|
||||
writeRequests[i] = new WriteRequest ( result.get ( i ).getValue ().getServerHandle (), writeTests[i].getValue () );
|
||||
serverHandles[i] = writeRequests[i].getServerHandle ();
|
||||
|
||||
System.out.println ( String.format ( "Item: %s, VT: %d", writeTests[i].getItemID (), result.get ( i ).getValue ().getCanonicalDataType () ) );
|
||||
}
|
||||
|
||||
System.out.println ( "Perform write" );
|
||||
final OPCSyncIO syncIO = group.getSyncIO ();
|
||||
final ResultSet<WriteRequest> writeResults = syncIO.write ( writeRequests );
|
||||
for ( int i = 0; i < writeTests.length; i++ )
|
||||
{
|
||||
final Result<WriteRequest> writeResult = writeResults.get ( i );
|
||||
System.out.println ( String.format ( "ItemID: %s, ErrorCode: %08X", writeTests[i].getItemID (), writeResult.getErrorCode () ) );
|
||||
if ( writeResult.getErrorCode () != 0 )
|
||||
{
|
||||
showError ( server, writeResult.getErrorCode () );
|
||||
}
|
||||
}
|
||||
|
||||
// finally remove them again
|
||||
System.out.println ( "Remove from group" );
|
||||
itemManagement.remove ( serverHandles );
|
||||
|
||||
System.out.println ( "Write items...complete" );
|
||||
}
|
||||
|
||||
public static void testItems ( final OPCServer server, final OPCGroupStateMgt group, final String... itemIDs ) throws IllegalArgumentException, UnknownHostException, JIException
|
||||
{
|
||||
final OPCItemMgt itemManagement = group.getItemManagement ();
|
||||
final List<OPCITEMDEF> items = new ArrayList<OPCITEMDEF> ( itemIDs.length );
|
||||
for ( final String id : itemIDs )
|
||||
{
|
||||
final OPCITEMDEF item = new OPCITEMDEF ();
|
||||
item.setItemID ( id );
|
||||
item.setClientHandle ( new Random ().nextInt () );
|
||||
items.add ( item );
|
||||
}
|
||||
|
||||
final OPCITEMDEF[] itemArray = items.toArray ( new OPCITEMDEF[0] );
|
||||
|
||||
System.out.println ( "Validate" );
|
||||
KeyedResultSet<OPCITEMDEF, OPCITEMRESULT> result = itemManagement.validate ( itemArray );
|
||||
if ( !dumpOPCITEMRESULT ( result ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// now add them to the group
|
||||
System.out.println ( "Add" );
|
||||
result = itemManagement.add ( itemArray );
|
||||
if ( !dumpOPCITEMRESULT ( result ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// get the server handle array
|
||||
final Integer[] serverHandles = new Integer[itemArray.length];
|
||||
for ( int i = 0; i < itemArray.length; i++ )
|
||||
{
|
||||
serverHandles[i] = new Integer ( result.get ( i ).getValue ().getServerHandle () );
|
||||
}
|
||||
|
||||
// set them active
|
||||
System.out.println ( "Activate" );
|
||||
final ResultSet<Integer> resultSet = itemManagement.setActiveState ( true, serverHandles );
|
||||
for ( final Result<Integer> resultEntry : resultSet )
|
||||
{
|
||||
System.out.println ( String.format ( "Item: %08X, Error: %08X", resultEntry.getValue (), resultEntry.getErrorCode () ) );
|
||||
}
|
||||
|
||||
// set client handles
|
||||
System.out.println ( "Set client handles" );
|
||||
final Integer[] clientHandles = new Integer[serverHandles.length];
|
||||
for ( int i = 0; i < serverHandles.length; i++ )
|
||||
{
|
||||
clientHandles[i] = i;
|
||||
}
|
||||
itemManagement.setClientHandles ( serverHandles, clientHandles );
|
||||
|
||||
System.out.println ( "Create async IO 2.0 object" );
|
||||
// OPCAsyncIO2 asyncIO2 = group.getAsyncIO2 ();
|
||||
// connect handler
|
||||
|
||||
System.out.println ( "attach" );
|
||||
final EventHandler eventHandler = group.attach ( new DumpDataCallback () );
|
||||
/*
|
||||
System.out.println ( "attach..enable" );
|
||||
asyncIO2.setEnable ( true );
|
||||
System.out.println ( "attach..refresh" );
|
||||
asyncIO2.refresh ( (short)1, 1 );
|
||||
*/
|
||||
// sleep
|
||||
try
|
||||
{
|
||||
System.out.println ( "Waiting..." );
|
||||
Thread.sleep ( 10 * 1000 );
|
||||
}
|
||||
catch ( final InterruptedException e )
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace ();
|
||||
}
|
||||
|
||||
eventHandler.detach ();
|
||||
|
||||
// sync IO - read
|
||||
final OPCSyncIO syncIO = group.getSyncIO ();
|
||||
final KeyedResultSet<Integer, OPCITEMSTATE> itemState = syncIO.read ( OPCDATASOURCE.OPC_DS_DEVICE, serverHandles );
|
||||
for ( final KeyedResult<Integer, OPCITEMSTATE> itemStateEntry : itemState )
|
||||
{
|
||||
final int errorCode = itemStateEntry.getErrorCode ();
|
||||
System.out.println ( String.format ( "Server ID: %08X, Value: %s, Timestamp: %d/%d (%Tc), Quality: %d, Error: %08X", itemStateEntry.getKey (), itemStateEntry.getValue ().getValue (), itemStateEntry.getValue ().getTimestamp ().getHigh (), itemStateEntry.getValue ().getTimestamp ().getLow (), itemStateEntry.getValue ().getTimestamp ().asCalendar (), itemStateEntry.getValue ().getQuality (), errorCode ) );
|
||||
if ( errorCode != 0 )
|
||||
{
|
||||
showError ( server, errorCode );
|
||||
}
|
||||
}
|
||||
|
||||
// set them inactive
|
||||
System.out.println ( "In-Active" );
|
||||
itemManagement.setActiveState ( false, serverHandles );
|
||||
|
||||
// finally remove them again
|
||||
System.out.println ( "Remove" );
|
||||
itemManagement.remove ( serverHandles );
|
||||
}
|
||||
|
||||
public static void dumpServerStatus ( final OPCServer server ) throws JIException
|
||||
{
|
||||
final OPCSERVERSTATUS status = server.getStatus ();
|
||||
|
||||
System.out.println ( "===== SERVER STATUS ======" );
|
||||
System.out.println ( "State: " + status.getServerState ().toString () );
|
||||
System.out.println ( "Vendor: " + status.getVendorInfo () );
|
||||
System.out.println ( String.format ( "Version: %d.%d.%d", status.getMajorVersion (), status.getMinorVersion (), status.getBuildNumber () ) );
|
||||
System.out.println ( "Groups: " + status.getGroupCount () );
|
||||
System.out.println ( "Bandwidth: " + status.getBandWidth () );
|
||||
System.out.println ( String.format ( "Start Time: %tc", status.getStartTime ().asCalendar () ) );
|
||||
System.out.println ( String.format ( "Current Time: %tc", status.getCurrentTime ().asCalendar () ) );
|
||||
System.out.println ( String.format ( "Last Update Time: %tc", status.getLastUpdateTime ().asCalendar () ) );
|
||||
System.out.println ( "===== SERVER STATUS ======" );
|
||||
}
|
||||
|
||||
public static void enumerateGroups ( final OPCServer server, final OPCENUMSCOPE scope ) throws IllegalArgumentException, UnknownHostException, JIException
|
||||
{
|
||||
System.out.println ( "Enum Groups: " + scope.toString () );
|
||||
|
||||
for ( final String group : server.getGroups ( scope ).asCollection () )
|
||||
{
|
||||
System.out.println ( "Group: " + group );
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings ( "unused" )
|
||||
public static void main ( final String[] args ) throws IllegalArgumentException, UnknownHostException, JIException
|
||||
{
|
||||
final TestConfiguration configuration = new MatrikonSimulationServerConfiguration ();
|
||||
|
||||
OPCServer server = null;
|
||||
try
|
||||
{
|
||||
JISystem.setAutoRegisteration ( true );
|
||||
|
||||
_session = JISession.createSession ( args[1], args[2], args[3] );
|
||||
// OPCServer server = new OPCServer ( "127.0.0.1", JIProgId.valueOf
|
||||
// ( session, "Matrikon.OPC.Simulation.1" ),
|
||||
// session );
|
||||
|
||||
//JIComServer comServer = new JIComServer ( JIClsid.valueOf ( configuration.getCLSID () ), args[0], _session );
|
||||
final JIComServer comServer = new JIComServer ( JIProgId.valueOf ( configuration.getProgId () ), args[0], _session );
|
||||
|
||||
final IJIComObject serverObject = comServer.createInstance ();
|
||||
server = new OPCServer ( serverObject );
|
||||
dumpServerStatus ( server );
|
||||
|
||||
/*
|
||||
OPCCommon common = server.getCommon ();
|
||||
common.setLocaleID ( 1033 );
|
||||
System.out.println ( String.format ( "LCID: %d", common.getLocaleID () ) );
|
||||
common.setClientName ( "test" );
|
||||
for ( Integer i : common.queryAvailableLocaleIDs () )
|
||||
{
|
||||
System.out.println ( String.format ( "Available LCID: %d", i ) );
|
||||
}
|
||||
*/
|
||||
|
||||
final OPCBrowseServerAddressSpace serverBrowser = server.getBrowser ();
|
||||
browseFlat ( serverBrowser );
|
||||
/*
|
||||
browseTree ( serverBrowser );
|
||||
*/
|
||||
|
||||
final OPCGroupStateMgt group = server.addGroup ( "test", true, 100, 1234, 60, 0.0f, 1033 );
|
||||
/*
|
||||
group.setName ( "test2" );
|
||||
OPCGroupStateMgt group2 = group.clone ( "test" );
|
||||
group = server.getGroupByName ( "test2" );
|
||||
group.setState ( null, false, null, null, null, null );
|
||||
group.setState ( null, true, null, null, null, null );
|
||||
dumpGroupState ( group );
|
||||
dumpGroupState ( group2 );
|
||||
*/
|
||||
testItems ( server, group, configuration.getReadItems () );
|
||||
if ( configuration.getWriteItems () != null )
|
||||
{
|
||||
writeItems ( server, group, configuration.getWriteItems () );
|
||||
}
|
||||
|
||||
final OPCItemProperties itemProperties = server.getItemPropertiesService ();
|
||||
//dumpItemProperties ( itemProperties, "Saw-toothed Waves.Int" );
|
||||
|
||||
final OPCItemIO itemIO = server.getItemIOService ();
|
||||
//queryItems ( itemIO, "Saw-toothed Waves.Int" );
|
||||
|
||||
enumerateGroups ( server, OPCENUMSCOPE.OPC_ENUM_PUBLIC );
|
||||
enumerateGroups ( server, OPCENUMSCOPE.OPC_ENUM_PRIVATE );
|
||||
enumerateGroups ( server, OPCENUMSCOPE.OPC_ENUM_ALL );
|
||||
|
||||
// clean up
|
||||
server.removeGroup ( group, true );
|
||||
//server.removeGroup ( group2, true );
|
||||
|
||||
}
|
||||
catch ( final JIException e )
|
||||
{
|
||||
e.printStackTrace ();
|
||||
showError ( server, e.getErrorCode () );
|
||||
}
|
||||
finally
|
||||
{
|
||||
if ( _session != null )
|
||||
{
|
||||
JISession.destroySession ( _session );
|
||||
}
|
||||
_session = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2009 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.da;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.jinterop.dcom.common.JISystem;
|
||||
import org.jinterop.dcom.core.IJIComObject;
|
||||
import org.jinterop.dcom.core.JIComServer;
|
||||
import org.jinterop.dcom.core.JIProgId;
|
||||
import org.jinterop.dcom.core.JISession;
|
||||
import org.openscada.opc.dcom.common.EventHandler;
|
||||
import org.openscada.opc.dcom.common.KeyedResult;
|
||||
import org.openscada.opc.dcom.common.KeyedResultSet;
|
||||
import org.openscada.opc.dcom.common.Result;
|
||||
import org.openscada.opc.dcom.common.ResultSet;
|
||||
import org.openscada.opc.dcom.common.impl.OPCCommon;
|
||||
import org.openscada.opc.dcom.da.impl.OPCAsyncIO2;
|
||||
import org.openscada.opc.dcom.da.impl.OPCGroupStateMgt;
|
||||
import org.openscada.opc.dcom.da.impl.OPCItemMgt;
|
||||
import org.openscada.opc.dcom.da.impl.OPCServer;
|
||||
import org.openscada.opc.dcom.da.impl.OPCAsyncIO2.AsyncResult;
|
||||
|
||||
public class Test2
|
||||
{
|
||||
private static JISession _session = null;
|
||||
|
||||
public static void showError ( final OPCCommon common, final int errorCode ) throws JIException
|
||||
{
|
||||
System.out.println ( String.format ( "Error (%X): '%s'", errorCode, common.getErrorString ( errorCode, 1033 ) ) );
|
||||
}
|
||||
|
||||
public static void showError ( final OPCServer server, final int errorCode ) throws JIException
|
||||
{
|
||||
showError ( server.getCommon (), errorCode );
|
||||
}
|
||||
|
||||
public static boolean dumpOPCITEMRESULT ( final KeyedResultSet<OPCITEMDEF, OPCITEMRESULT> result )
|
||||
{
|
||||
int failed = 0;
|
||||
for ( final KeyedResult<OPCITEMDEF, OPCITEMRESULT> resultEntry : result )
|
||||
{
|
||||
System.out.println ( "==================================" );
|
||||
System.out.println ( String.format ( "Item: '%s' ", resultEntry.getKey ().getItemID () ) );
|
||||
|
||||
System.out.println ( String.format ( "Error Code: %08x", resultEntry.getErrorCode () ) );
|
||||
if ( !resultEntry.isFailed () )
|
||||
{
|
||||
System.out.println ( String.format ( "Server Handle: %08X", resultEntry.getValue ().getServerHandle () ) );
|
||||
System.out.println ( String.format ( "Data Type: %d", resultEntry.getValue ().getCanonicalDataType () ) );
|
||||
System.out.println ( String.format ( "Access Rights: %d", resultEntry.getValue ().getAccessRights () ) );
|
||||
System.out.println ( String.format ( "Reserved: %d", resultEntry.getValue ().getReserved () ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
failed++;
|
||||
}
|
||||
}
|
||||
return failed == 0;
|
||||
}
|
||||
|
||||
public static void testItems ( final OPCServer server, final OPCGroupStateMgt group, final String... itemIDs ) throws IllegalArgumentException, UnknownHostException, JIException
|
||||
{
|
||||
final OPCItemMgt itemManagement = group.getItemManagement ();
|
||||
final List<OPCITEMDEF> items = new ArrayList<OPCITEMDEF> ( itemIDs.length );
|
||||
for ( final String id : itemIDs )
|
||||
{
|
||||
final OPCITEMDEF item = new OPCITEMDEF ();
|
||||
item.setItemID ( id );
|
||||
item.setClientHandle ( new Random ().nextInt () );
|
||||
items.add ( item );
|
||||
}
|
||||
|
||||
final OPCITEMDEF[] itemArray = items.toArray ( new OPCITEMDEF[0] );
|
||||
|
||||
System.out.println ( "Validate" );
|
||||
KeyedResultSet<OPCITEMDEF, OPCITEMRESULT> result = itemManagement.validate ( itemArray );
|
||||
if ( !dumpOPCITEMRESULT ( result ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// now add them to the group
|
||||
System.out.println ( "Add" );
|
||||
result = itemManagement.add ( itemArray );
|
||||
if ( !dumpOPCITEMRESULT ( result ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// get the server handle array
|
||||
final Integer[] serverHandles = new Integer[itemArray.length];
|
||||
for ( int i = 0; i < itemArray.length; i++ )
|
||||
{
|
||||
serverHandles[i] = new Integer ( result.get ( i ).getValue ().getServerHandle () );
|
||||
}
|
||||
|
||||
// set them active
|
||||
System.out.println ( "Activate" );
|
||||
final ResultSet<Integer> resultSet = itemManagement.setActiveState ( true, serverHandles );
|
||||
for ( final Result<Integer> resultEntry : resultSet )
|
||||
{
|
||||
System.out.println ( String.format ( "Item: %08X, Error: %08X", resultEntry.getValue (), resultEntry.getErrorCode () ) );
|
||||
}
|
||||
|
||||
// set client handles
|
||||
System.out.println ( "Set client handles" );
|
||||
final Integer[] clientHandles = new Integer[serverHandles.length];
|
||||
for ( int i = 0; i < serverHandles.length; i++ )
|
||||
{
|
||||
clientHandles[i] = i;
|
||||
}
|
||||
itemManagement.setClientHandles ( serverHandles, clientHandles );
|
||||
|
||||
System.out.println ( "Create async IO 2.0 object" );
|
||||
final OPCAsyncIO2 asyncIO2 = group.getAsyncIO2 ();
|
||||
|
||||
// connect handler
|
||||
System.out.println ( "attach" );
|
||||
final EventHandler eventHandler = group.attach ( new DumpDataCallback () );
|
||||
|
||||
System.out.println ( "attach..enable" );
|
||||
asyncIO2.setEnable ( true );
|
||||
|
||||
System.out.println ( "attach..refresh" );
|
||||
final int cancelId = asyncIO2.refresh ( OPCDATASOURCE.OPC_DS_DEVICE, 1 );
|
||||
System.out.println ( "Cancel ID: " + cancelId );
|
||||
|
||||
System.out.println ( "attach..read" );
|
||||
final AsyncResult asyncResult = asyncIO2.read ( 2, serverHandles );
|
||||
System.out.println ( String.format ( "attach..read..cancelId: %08X", asyncResult.getCancelId () ) );
|
||||
|
||||
// sleep
|
||||
try
|
||||
{
|
||||
System.out.println ( "Waiting..." );
|
||||
Thread.sleep ( 10 * 1000 );
|
||||
}
|
||||
catch ( final InterruptedException e )
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace ();
|
||||
}
|
||||
|
||||
System.out.println ( "Detaching" );
|
||||
eventHandler.detach ();
|
||||
|
||||
// set them inactive
|
||||
System.out.println ( "In-Active" );
|
||||
itemManagement.setActiveState ( false, serverHandles );
|
||||
|
||||
// finally remove them again
|
||||
System.out.println ( "Remove" );
|
||||
itemManagement.remove ( serverHandles );
|
||||
}
|
||||
|
||||
public static void main ( final String[] args ) throws IllegalArgumentException, UnknownHostException, JIException
|
||||
{
|
||||
final TestConfiguration configuration = new MatrikonSimulationServerConfiguration ();
|
||||
|
||||
OPCServer server = null;
|
||||
try
|
||||
{
|
||||
JISystem.setAutoRegisteration ( true );
|
||||
|
||||
_session = JISession.createSession ( args[1], args[2], args[3] );
|
||||
|
||||
//JIComServer comServer = new JIComServer ( JIClsid.valueOf ( configuration.getCLSID () ), args[0], _session );
|
||||
final JIComServer comServer = new JIComServer ( JIProgId.valueOf ( configuration.getProgId () ), args[0], _session );
|
||||
|
||||
final IJIComObject serverObject = comServer.createInstance ();
|
||||
server = new OPCServer ( serverObject );
|
||||
|
||||
final OPCGroupStateMgt group = server.addGroup ( "test", true, 100, 1234, 60, 0.0f, 1033 );
|
||||
|
||||
testItems ( server, group, configuration.getReadItems () );
|
||||
server.removeGroup ( group, true );
|
||||
}
|
||||
catch ( final JIException e )
|
||||
{
|
||||
e.printStackTrace ();
|
||||
showError ( server, e.getErrorCode () );
|
||||
}
|
||||
finally
|
||||
{
|
||||
if ( _session != null )
|
||||
{
|
||||
JISession.destroySession ( _session );
|
||||
}
|
||||
_session = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2009 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.da;
|
||||
|
||||
public interface TestConfiguration
|
||||
{
|
||||
public String getCLSID ();
|
||||
|
||||
public String getProgId ();
|
||||
|
||||
public String[] getReadItems ();
|
||||
|
||||
public WriteTest[] getWriteItems ();
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2009 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.da;
|
||||
|
||||
import org.jinterop.dcom.core.JIVariant;
|
||||
|
||||
public class WriteTest
|
||||
{
|
||||
private String _itemID = "";
|
||||
|
||||
private JIVariant _value = JIVariant.EMPTY ();
|
||||
|
||||
public WriteTest ( final String itemID, final JIVariant value )
|
||||
{
|
||||
super ();
|
||||
this._itemID = itemID;
|
||||
this._value = value;
|
||||
}
|
||||
|
||||
public String getItemID ()
|
||||
{
|
||||
return this._itemID;
|
||||
}
|
||||
|
||||
public void setItemID ( final String itemID )
|
||||
{
|
||||
this._itemID = itemID;
|
||||
}
|
||||
|
||||
public JIVariant getValue ()
|
||||
{
|
||||
return this._value;
|
||||
}
|
||||
|
||||
public void setValue ( final JIVariant value )
|
||||
{
|
||||
this._value = value;
|
||||
}
|
||||
}
|
||||
16
org.openscada.opc.dcom/.classpath
Normal file
16
org.openscada.opc.dcom/.classpath
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
2
org.openscada.opc.dcom/.gitignore
vendored
Normal file
2
org.openscada.opc.dcom/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
bin/
|
||||
/target
|
||||
46
org.openscada.opc.dcom/.project
Normal file
46
org.openscada.opc.dcom/.project
Normal file
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>org.openscada.opc.dcom</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.babel.editor.rbeBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.babel.editor.rbeNature</nature>
|
||||
<nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
1
org.openscada.opc.dcom/build.properties
Normal file
1
org.openscada.opc.dcom/build.properties
Normal file
@@ -0,0 +1 @@
|
||||
source.. = src
|
||||
26
org.openscada.opc.dcom/pom.xml
Normal file
26
org.openscada.opc.dcom/pom.xml
Normal file
@@ -0,0 +1,26 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.openscada.opc.dcom</groupId>
|
||||
<artifactId>org.openscada.opc.dcom</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<version>1.7.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.kohsuke.jinterop</groupId>
|
||||
<artifactId>j-interop</artifactId>
|
||||
<version>2.0.5</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.common;
|
||||
|
||||
public interface Categories
|
||||
{
|
||||
public static final String OPCDAServer10 = "63D5F430-CFE4-11d1-B2C8-0060083BA1FB";
|
||||
|
||||
public static final String OPCDAServer20 = "63D5F432-CFE4-11d1-B2C8-0060083BA1FB";
|
||||
|
||||
public static final String OPCDAServer30 = "CC603642-66D7-48f1-B69A-B625E73652D7";
|
||||
|
||||
public static final String XMLDAServer10 = "3098EDA4-A006-48b2-A27F-247453959408";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.common;
|
||||
|
||||
public interface Constants
|
||||
{
|
||||
public static final String IConnectionPointContainer_IID = "B196B284-BAB4-101A-B69C-00AA00341D07";
|
||||
|
||||
public static final String IConnectionPoint_IID = "B196B286-BAB4-101A-B69C-00AA00341D07";
|
||||
|
||||
public static final String IOPCCommon_IID = "F31DFDE2-07B6-11D2-B2D8-0060083BA1FB";
|
||||
|
||||
public static final String IEnumString_IID = "00000101-0000-0000-C000-000000000046";
|
||||
|
||||
public static final String IEnumGUID_IID = "0002E000-0000-0000-C000-000000000046";
|
||||
|
||||
public static final int S_OK = 0;
|
||||
|
||||
public static final int S_FALSE = 1;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.common;
|
||||
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.jinterop.dcom.core.IJIComObject;
|
||||
|
||||
public interface EventHandler
|
||||
{
|
||||
public String getIdentifier ();
|
||||
|
||||
public IJIComObject getObject ();
|
||||
|
||||
public void detach () throws JIException;
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.common;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Calendar;
|
||||
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.jinterop.dcom.core.JIStruct;
|
||||
|
||||
public class FILETIME
|
||||
{
|
||||
private int high = 0;
|
||||
|
||||
private int low = 0;
|
||||
|
||||
public FILETIME ()
|
||||
{
|
||||
}
|
||||
|
||||
public FILETIME ( final FILETIME arg0 )
|
||||
{
|
||||
this.high = arg0.high;
|
||||
this.low = arg0.low;
|
||||
}
|
||||
|
||||
public FILETIME ( final int high, final int low )
|
||||
{
|
||||
this.high = high;
|
||||
this.low = low;
|
||||
}
|
||||
|
||||
public int getHigh ()
|
||||
{
|
||||
return this.high;
|
||||
}
|
||||
|
||||
public void setHigh ( final int high )
|
||||
{
|
||||
this.high = high;
|
||||
}
|
||||
|
||||
public int getLow ()
|
||||
{
|
||||
return this.low;
|
||||
}
|
||||
|
||||
public void setLow ( final int low )
|
||||
{
|
||||
this.low = low;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode ()
|
||||
{
|
||||
final int PRIME = 31;
|
||||
int result = 1;
|
||||
result = PRIME * result + this.high;
|
||||
result = PRIME * result + this.low;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals ( final Object obj )
|
||||
{
|
||||
if ( this == obj )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if ( obj == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ( getClass () != obj.getClass () )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
final FILETIME other = (FILETIME)obj;
|
||||
if ( this.high != other.high )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ( this.low != other.low )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static JIStruct getStruct () throws JIException
|
||||
{
|
||||
final JIStruct struct = new JIStruct ();
|
||||
|
||||
struct.addMember ( Integer.class );
|
||||
struct.addMember ( Integer.class );
|
||||
|
||||
return struct;
|
||||
}
|
||||
|
||||
public static FILETIME fromStruct ( final JIStruct struct )
|
||||
{
|
||||
final FILETIME ft = new FILETIME ();
|
||||
|
||||
ft.setLow ( (Integer)struct.getMember ( 0 ) );
|
||||
ft.setHigh ( (Integer)struct.getMember ( 1 ) );
|
||||
|
||||
return ft;
|
||||
}
|
||||
|
||||
public Calendar asCalendar ()
|
||||
{
|
||||
final Calendar c = Calendar.getInstance ();
|
||||
|
||||
/*
|
||||
* The following "strange" stuff is needed since we miss a ulong type
|
||||
*/
|
||||
long i = 0xFFFFFFFFL & this.high;
|
||||
i = i << 32;
|
||||
long j = 0xFFFFFFFFFFFFFFFFL & i;
|
||||
|
||||
i = 0xFFFFFFFFL & this.low;
|
||||
j += i;
|
||||
j /= 10000L;
|
||||
j -= 11644473600000L;
|
||||
|
||||
c.setTimeInMillis ( j );
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
public Calendar asBigDecimalCalendar ()
|
||||
{
|
||||
final Calendar c = Calendar.getInstance ();
|
||||
|
||||
/*
|
||||
* The following "strange" stuff is needed since we miss a ulong type
|
||||
*/
|
||||
long i = 0xFFFFFFFFL & this.high;
|
||||
i = i << 32;
|
||||
BigDecimal d1 = new BigDecimal ( 0xFFFFFFFFFFFFFFFFL & i );
|
||||
|
||||
i = 0xFFFFFFFFL & this.low;
|
||||
d1 = d1.add ( new BigDecimal ( i ) );
|
||||
d1 = d1.divide ( new BigDecimal ( 10000L ) );
|
||||
d1 = d1.subtract ( new BigDecimal ( 11644473600000L ) );
|
||||
|
||||
c.setTimeInMillis ( d1.longValue () );
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString ()
|
||||
{
|
||||
return String.format ( "%s/%s", this.high, this.low );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.common;
|
||||
|
||||
public class KeyedResult<K, V> extends Result<V>
|
||||
{
|
||||
private K key;
|
||||
|
||||
public KeyedResult ()
|
||||
{
|
||||
super ();
|
||||
}
|
||||
|
||||
public KeyedResult ( final K key, final V value, final int errorCode )
|
||||
{
|
||||
super ( value, errorCode );
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public K getKey ()
|
||||
{
|
||||
return this.key;
|
||||
}
|
||||
|
||||
public void setKey ( final K key )
|
||||
{
|
||||
this.key = key;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2012 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class KeyedResultSet<K, V> extends ArrayList<KeyedResult<K, V>>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public KeyedResultSet ()
|
||||
{
|
||||
super ();
|
||||
}
|
||||
|
||||
public KeyedResultSet ( final int size )
|
||||
{
|
||||
super ( size ); // me
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
*
|
||||
* Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
* Copyright (C) 2013 Jens Reimann (ctron@dentrassi.de)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.common;
|
||||
|
||||
public class Result<T>
|
||||
{
|
||||
private T value;
|
||||
|
||||
private int errorCode;
|
||||
|
||||
public Result ()
|
||||
{
|
||||
}
|
||||
|
||||
public Result ( final T value, final int errorCode )
|
||||
{
|
||||
this.value = value;
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
public int getErrorCode ()
|
||||
{
|
||||
return this.errorCode;
|
||||
}
|
||||
|
||||
public void setErrorCode ( final int errorCode )
|
||||
{
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
public T getValue ()
|
||||
{
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public void setValue ( final T value )
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public boolean isFailed ()
|
||||
{
|
||||
return this.errorCode != 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ResultSet<T> extends ArrayList<Result<T>>
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 6392417310208978252L;
|
||||
|
||||
public ResultSet ()
|
||||
{
|
||||
super ();
|
||||
}
|
||||
|
||||
public ResultSet ( final int size )
|
||||
{
|
||||
super ( size ); // me
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
*
|
||||
* Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
* Copyright (C) 2013 Jens Reimann (ctron@dentrassi.de)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.common.impl;
|
||||
|
||||
import org.jinterop.dcom.core.IJIComObject;
|
||||
|
||||
public class BaseCOMObject
|
||||
{
|
||||
private IJIComObject comObject = null;
|
||||
|
||||
/**
|
||||
* Create a new base COM object
|
||||
*
|
||||
* @param comObject
|
||||
* The COM object to wrap but be addRef'ed
|
||||
*/
|
||||
public BaseCOMObject ( final IJIComObject comObject )
|
||||
{
|
||||
this.comObject = comObject;
|
||||
}
|
||||
|
||||
protected synchronized IJIComObject getCOMObject ()
|
||||
{
|
||||
return this.comObject;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.common.impl;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.jinterop.dcom.core.IJIComObject;
|
||||
import org.jinterop.dcom.core.JIArray;
|
||||
import org.jinterop.dcom.core.JICallBuilder;
|
||||
import org.jinterop.dcom.core.JIFlags;
|
||||
|
||||
import rpc.core.UUID;
|
||||
|
||||
public class EnumGUID extends BaseCOMObject
|
||||
{
|
||||
public static final int DEFAULT_BATCH_SIZE = Integer.getInteger ( "openscada.dcom.enum-batch-size", 10 );
|
||||
|
||||
public EnumGUID ( final IJIComObject enumStringObject ) throws IllegalArgumentException, UnknownHostException, JIException
|
||||
{
|
||||
super ( enumStringObject.queryInterface ( org.openscada.opc.dcom.common.Constants.IEnumGUID_IID ) );
|
||||
}
|
||||
|
||||
public int next ( final List<UUID> list, final int num ) throws JIException
|
||||
{
|
||||
if ( num <= 0 )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 0 );
|
||||
|
||||
callObject.addInParamAsInt ( num, JIFlags.FLAG_NULL );
|
||||
callObject.addInParamAsInt ( num, JIFlags.FLAG_NULL );
|
||||
callObject.addOutParamAsObject ( new JIArray ( UUID.class, null, 1, true, true ), JIFlags.FLAG_NULL );
|
||||
callObject.addOutParamAsType ( Integer.class, JIFlags.FLAG_NULL );
|
||||
|
||||
Object[] result = Helper.callRespectSFALSE ( getCOMObject (), callObject );
|
||||
|
||||
UUID[] resultData = (UUID[]) ( (JIArray)result[0] ).getArrayInstance ();
|
||||
Integer cnt = (Integer)result[1];
|
||||
|
||||
for ( int i = 0; i < cnt; i++ )
|
||||
{
|
||||
list.add ( resultData[i] );
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
public Collection<UUID> next ( final int num ) throws JIException
|
||||
{
|
||||
List<UUID> list = new ArrayList<UUID> ( num );
|
||||
next ( list, num );
|
||||
return list;
|
||||
}
|
||||
|
||||
public void skip ( final int num ) throws JIException
|
||||
{
|
||||
if ( num <= 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 1 );
|
||||
|
||||
callObject.addInParamAsInt ( num, JIFlags.FLAG_NULL );
|
||||
|
||||
getCOMObject ().call ( callObject );
|
||||
}
|
||||
|
||||
public void reset () throws JIException
|
||||
{
|
||||
JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 2 );
|
||||
|
||||
getCOMObject ().call ( callObject );
|
||||
}
|
||||
|
||||
public EnumGUID cloneObject () throws JIException, IllegalArgumentException, UnknownHostException
|
||||
{
|
||||
JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 3 );
|
||||
|
||||
callObject.addOutParamAsType ( IJIComObject.class, JIFlags.FLAG_NULL );
|
||||
|
||||
Object[] result = getCOMObject ().call ( callObject );
|
||||
|
||||
IJIComObject object = (IJIComObject)result[0];
|
||||
|
||||
return new EnumGUID ( object );
|
||||
}
|
||||
|
||||
public Collection<UUID> asCollection ( final int batchSize ) throws JIException
|
||||
{
|
||||
reset ();
|
||||
|
||||
List<UUID> data = new ArrayList<UUID> ();
|
||||
int i = 0;
|
||||
do
|
||||
{
|
||||
i = next ( data, batchSize );
|
||||
} while ( i == batchSize );
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public Collection<UUID> asCollection () throws JIException
|
||||
{
|
||||
return asCollection ( DEFAULT_BATCH_SIZE );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.common.impl;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.jinterop.dcom.core.IJIComObject;
|
||||
import org.jinterop.dcom.core.JIArray;
|
||||
import org.jinterop.dcom.core.JICallBuilder;
|
||||
import org.jinterop.dcom.core.JIFlags;
|
||||
import org.jinterop.dcom.core.JIString;
|
||||
|
||||
public class EnumString extends BaseCOMObject
|
||||
{
|
||||
public static final int DEFAULT_BATCH_SIZE = Integer.getInteger ( "openscada.dcom.enum-batch-size", 10 );
|
||||
|
||||
public EnumString ( final IJIComObject enumStringObject ) throws IllegalArgumentException, UnknownHostException, JIException
|
||||
{
|
||||
super ( enumStringObject.queryInterface ( org.openscada.opc.dcom.common.Constants.IEnumString_IID ) );
|
||||
}
|
||||
|
||||
public int next ( final List<String> list, final int num ) throws JIException
|
||||
{
|
||||
if ( num <= 0 )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 0 );
|
||||
|
||||
callObject.addInParamAsInt ( num, JIFlags.FLAG_NULL );
|
||||
//callObject.addInParamAsInt ( num, JIFlags.FLAG_NULL );
|
||||
//callObject.addOutParamAsObject ( new JIArray ( new JIPointer ( new JIString (
|
||||
// JIFlags.FLAG_REPRESENTATION_STRING_LPWSTR ) ), null, 1, true, true ), JIFlags.FLAG_NULL );
|
||||
callObject.addOutParamAsObject ( new JIArray ( new JIString ( JIFlags.FLAG_REPRESENTATION_STRING_LPWSTR ), null, 1, true, true ), JIFlags.FLAG_NULL );
|
||||
callObject.addOutParamAsType ( Integer.class, JIFlags.FLAG_NULL );
|
||||
|
||||
Object[] result = Helper.callRespectSFALSE ( getCOMObject (), callObject );
|
||||
|
||||
//JIPointer[] resultData = (JIPointer[]) ( (JIArray) ( result[0] ) ).getArrayInstance ();
|
||||
JIString[] resultData = (JIString[]) ( (JIArray)result[0] ).getArrayInstance ();
|
||||
Integer cnt = (Integer)result[1];
|
||||
|
||||
for ( int i = 0; i < cnt; i++ )
|
||||
{
|
||||
//list.add ( ( (JIString)resultData[i].getReferent () ).getString () );
|
||||
list.add ( resultData[i].getString () );
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
public Collection<String> next ( final int num ) throws JIException
|
||||
{
|
||||
List<String> list = new ArrayList<String> ( num );
|
||||
next ( list, num );
|
||||
return list;
|
||||
}
|
||||
|
||||
public void skip ( final int num ) throws JIException
|
||||
{
|
||||
if ( num <= 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 1 );
|
||||
|
||||
callObject.addInParamAsInt ( num, JIFlags.FLAG_NULL );
|
||||
|
||||
getCOMObject ().call ( callObject );
|
||||
}
|
||||
|
||||
public void reset () throws JIException
|
||||
{
|
||||
JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 2 );
|
||||
|
||||
getCOMObject ().call ( callObject );
|
||||
}
|
||||
|
||||
public EnumString cloneObject () throws JIException, IllegalArgumentException, UnknownHostException
|
||||
{
|
||||
JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 3 );
|
||||
|
||||
callObject.addOutParamAsType ( IJIComObject.class, JIFlags.FLAG_NULL );
|
||||
|
||||
Object[] result = getCOMObject ().call ( callObject );
|
||||
|
||||
IJIComObject object = (IJIComObject)result[0];
|
||||
return new EnumString ( object );
|
||||
}
|
||||
|
||||
public Collection<String> asCollection ( final int batchSize ) throws JIException
|
||||
{
|
||||
reset ();
|
||||
|
||||
List<String> data = new ArrayList<String> ();
|
||||
int i = 0;
|
||||
do
|
||||
{
|
||||
i = next ( data, batchSize );
|
||||
} while ( i == batchSize );
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public Collection<String> asCollection () throws JIException
|
||||
{
|
||||
return asCollection ( DEFAULT_BATCH_SIZE );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.common.impl;
|
||||
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.jinterop.dcom.core.IJIComObject;
|
||||
import org.jinterop.dcom.core.JIFrameworkHelper;
|
||||
import org.openscada.opc.dcom.common.EventHandler;
|
||||
|
||||
public class EventHandlerImpl implements EventHandler
|
||||
{
|
||||
private String identifier = null;
|
||||
|
||||
private IJIComObject object = null;
|
||||
|
||||
public String getIdentifier ()
|
||||
{
|
||||
return this.identifier;
|
||||
}
|
||||
|
||||
public synchronized IJIComObject getObject ()
|
||||
{
|
||||
return this.object;
|
||||
}
|
||||
|
||||
public synchronized void setInfo ( final IJIComObject object, final String identifier )
|
||||
{
|
||||
this.object = object;
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
public synchronized void detach () throws JIException
|
||||
{
|
||||
if ( this.object != null && this.identifier != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
JIFrameworkHelper.detachEventHandler ( this.object, this.identifier );
|
||||
}
|
||||
finally
|
||||
{
|
||||
this.object = null;
|
||||
this.identifier = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.common.impl;
|
||||
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.jinterop.dcom.core.IJIComObject;
|
||||
import org.jinterop.dcom.core.JICallBuilder;
|
||||
import org.jinterop.dcom.core.JIFlags;
|
||||
import org.jinterop.dcom.core.JIVariant;
|
||||
|
||||
public class Helper
|
||||
{
|
||||
/**
|
||||
* Make the COM call but do not treat S_FALSE as error condition for the whole call
|
||||
* @param object the object to make to call on
|
||||
* @param callObject the call object
|
||||
* @return the result of the call
|
||||
* @throws JIException
|
||||
*/
|
||||
public static Object[] callRespectSFALSE ( final IJIComObject object, final JICallBuilder callObject ) throws JIException
|
||||
{
|
||||
try
|
||||
{
|
||||
return object.call ( callObject );
|
||||
}
|
||||
catch ( JIException e )
|
||||
{
|
||||
if ( e.getErrorCode () != org.openscada.opc.dcom.common.Constants.S_FALSE )
|
||||
{
|
||||
throw e;
|
||||
}
|
||||
return callObject.getResultsInCaseOfException ();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform some fixes on the variant when writing it to OPC items. This method
|
||||
* only changes control information on the variant and not the value itself!
|
||||
* @param value the value to fix
|
||||
* @return the fixed value
|
||||
* @throws JIException In case something goes wrong
|
||||
*/
|
||||
public static JIVariant fixVariant ( final JIVariant value ) throws JIException
|
||||
{
|
||||
if ( value.isArray () )
|
||||
{
|
||||
if ( value.getObjectAsArray ().getArrayInstance () instanceof Boolean[] )
|
||||
{
|
||||
value.setFlag ( JIFlags.FLAG_REPRESENTATION_VARIANT_BOOL );
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.common.impl;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.jinterop.dcom.core.IJIComObject;
|
||||
import org.jinterop.dcom.core.JIArray;
|
||||
import org.jinterop.dcom.core.JICallBuilder;
|
||||
import org.jinterop.dcom.core.JIFlags;
|
||||
import org.jinterop.dcom.core.JIPointer;
|
||||
import org.jinterop.dcom.core.JIString;
|
||||
|
||||
public class OPCCommon extends BaseCOMObject
|
||||
{
|
||||
public OPCCommon ( final IJIComObject opcObject ) throws IllegalArgumentException, UnknownHostException, JIException
|
||||
{
|
||||
super ( opcObject.queryInterface ( org.openscada.opc.dcom.common.Constants.IOPCCommon_IID ) );
|
||||
}
|
||||
|
||||
public void setLocaleID ( final int localeID ) throws JIException
|
||||
{
|
||||
JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 0 );
|
||||
|
||||
callObject.addInParamAsInt ( localeID, JIFlags.FLAG_NULL );
|
||||
|
||||
getCOMObject ().call ( callObject );
|
||||
}
|
||||
|
||||
public int getLocaleID () throws JIException
|
||||
{
|
||||
JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 1 );
|
||||
|
||||
callObject.addOutParamAsObject ( Integer.class, JIFlags.FLAG_NULL );
|
||||
|
||||
Object[] result = getCOMObject ().call ( callObject );
|
||||
return (Integer)result[0];
|
||||
}
|
||||
|
||||
public String getErrorString ( final int errorCode, final int localeID ) throws JIException
|
||||
{
|
||||
JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 3 );
|
||||
|
||||
callObject.addInParamAsInt ( errorCode, JIFlags.FLAG_NULL );
|
||||
callObject.addInParamAsInt ( localeID, JIFlags.FLAG_NULL );
|
||||
callObject.addOutParamAsObject ( new JIPointer ( new JIString ( JIFlags.FLAG_REPRESENTATION_STRING_LPWSTR ) ), JIFlags.FLAG_NULL );
|
||||
|
||||
Object[] result = getCOMObject ().call ( callObject );
|
||||
return ( (JIString) ( (JIPointer)result[0] ).getReferent () ).getString ();
|
||||
}
|
||||
|
||||
public void setClientName ( final String clientName ) throws JIException
|
||||
{
|
||||
JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 4 );
|
||||
|
||||
callObject.addInParamAsString ( clientName, JIFlags.FLAG_REPRESENTATION_STRING_LPWSTR );
|
||||
|
||||
getCOMObject ().call ( callObject );
|
||||
}
|
||||
|
||||
public Collection<Integer> queryAvailableLocaleIDs () throws JIException
|
||||
{
|
||||
JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 2 );
|
||||
|
||||
callObject.addOutParamAsType ( Integer.class, JIFlags.FLAG_NULL );
|
||||
callObject.addOutParamAsObject ( new JIPointer ( new JIArray ( Integer.class, null, 1, true ) ), JIFlags.FLAG_NULL );
|
||||
|
||||
Object[] result = getCOMObject ().call ( callObject );
|
||||
|
||||
JIArray resultArray = (JIArray) ( (JIPointer)result[1] ).getReferent ();
|
||||
Integer[] intArray = (Integer[])resultArray.getArrayInstance ();
|
||||
|
||||
return Arrays.asList ( intArray );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.da;
|
||||
|
||||
public interface Constants extends org.openscada.opc.dcom.common.Constants
|
||||
{
|
||||
public static final String IOPCServer_IID = "39C13A4D-011E-11D0-9675-0020AFD8ADB3";
|
||||
|
||||
public static final String IOPCGroupStateMgt_IID = "39C13A50-011E-11D0-9675-0020AFD8ADB3";
|
||||
|
||||
public static final String IOPCBrowse_IID = "39227004-A18F-4B57-8B0A-5235670F4468";
|
||||
|
||||
public static final String IOPCBrowseServerAddressSpace_IID = "39C13A4F-011E-11D0-9675-0020AFD8ADB3";
|
||||
|
||||
public static final String IOPCItemMgt_IID = "39C13A54-011E-11D0-9675-0020AFD8ADB3";
|
||||
|
||||
public static final String IOPCItemProperties_IID = "39C13A72-011E-11D0-9675-0020AFD8ADB3";
|
||||
|
||||
public static final String IOPCItemIO_IID = "85C0B427-2893-4CBC-BD78-E5FC5146F08F";
|
||||
|
||||
public static final String IOPCDataCallback_IID = "39C13A70-011E-11D0-9675-0020AFD8ADB3";
|
||||
|
||||
public static final String IOPCAsyncIO2_IID = "39C13A71-011E-11D0-9675-0020AFD8ADB3";
|
||||
|
||||
public static final String IOPCSyncIO_IID = "39C13A52-011E-11D0-9675-0020AFD8ADB3";
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.da;
|
||||
|
||||
import org.openscada.opc.dcom.common.KeyedResultSet;
|
||||
import org.openscada.opc.dcom.common.ResultSet;
|
||||
|
||||
public interface IOPCDataCallback
|
||||
{
|
||||
public void dataChange ( int transactionId, int serverGroupHandle, int masterQuality, int masterErrorCode, KeyedResultSet<Integer, ValueData> result );
|
||||
|
||||
public void readComplete ( int transactionId, int serverGroupHandle, int masterQuality, int masterErrorCode, KeyedResultSet<Integer, ValueData> result );
|
||||
|
||||
public void writeComplete ( int transactionId, int serverGroupHandle, int masterErrorCode, ResultSet<Integer> result );
|
||||
|
||||
public void cancelComplete ( int transactionId, int serverGroupHandle );
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
*
|
||||
* Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
* Copyright (C) 2013 Jens Reimann (ctron@dentrassi.de)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.da;
|
||||
|
||||
public class IORequest
|
||||
{
|
||||
private String itemID;
|
||||
|
||||
private int maxAge;
|
||||
|
||||
public IORequest ( final String itemID, final int maxAge )
|
||||
{
|
||||
this.itemID = itemID;
|
||||
this.maxAge = maxAge;
|
||||
}
|
||||
|
||||
public String getItemID ()
|
||||
{
|
||||
return this.itemID;
|
||||
}
|
||||
|
||||
public void setItemID ( final String itemID )
|
||||
{
|
||||
this.itemID = itemID;
|
||||
}
|
||||
|
||||
public int getMaxAge ()
|
||||
{
|
||||
return this.maxAge;
|
||||
}
|
||||
|
||||
public void setMaxAge ( final int maxAge )
|
||||
{
|
||||
this.maxAge = maxAge;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.da;
|
||||
|
||||
public enum OPCBROWSEDIRECTION
|
||||
{
|
||||
OPC_BROWSE_UP ( 1 ),
|
||||
OPC_BROWSE_DOWN ( 2 ),
|
||||
OPC_BROWSE_TO ( 3 ),
|
||||
OPC_BROWSE_UNKNOWN ( 0 );
|
||||
|
||||
private int _id;
|
||||
|
||||
private OPCBROWSEDIRECTION ( final int id )
|
||||
{
|
||||
this._id = id;
|
||||
}
|
||||
|
||||
public int id ()
|
||||
{
|
||||
return this._id;
|
||||
}
|
||||
|
||||
public static OPCBROWSEDIRECTION fromID ( final int id )
|
||||
{
|
||||
switch ( id )
|
||||
{
|
||||
case 1:
|
||||
return OPC_BROWSE_UP;
|
||||
case 2:
|
||||
return OPC_BROWSE_DOWN;
|
||||
case 3:
|
||||
return OPC_BROWSE_TO;
|
||||
default:
|
||||
return OPC_BROWSE_UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.da;
|
||||
|
||||
public enum OPCBROWSETYPE
|
||||
{
|
||||
OPC_BRANCH ( 1 ),
|
||||
OPC_LEAF ( 2 ),
|
||||
OPC_FLAT ( 3 ),
|
||||
OPC_UNKNOWN ( 0 );
|
||||
|
||||
private int _id;
|
||||
|
||||
private OPCBROWSETYPE ( final int id )
|
||||
{
|
||||
this._id = id;
|
||||
}
|
||||
|
||||
public int id ()
|
||||
{
|
||||
return this._id;
|
||||
}
|
||||
|
||||
public static OPCBROWSETYPE fromID ( final int id )
|
||||
{
|
||||
switch ( id )
|
||||
{
|
||||
case 1:
|
||||
return OPC_BRANCH;
|
||||
case 2:
|
||||
return OPC_LEAF;
|
||||
case 3:
|
||||
return OPC_FLAT;
|
||||
default:
|
||||
return OPC_UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.da;
|
||||
|
||||
public enum OPCDATASOURCE
|
||||
{
|
||||
OPC_DS_CACHE ( 1 ),
|
||||
OPC_DS_DEVICE ( 2 ),
|
||||
OPC_DS_UNKNOWN ( 0 );
|
||||
|
||||
private int _id;
|
||||
|
||||
private OPCDATASOURCE ( final int id )
|
||||
{
|
||||
this._id = id;
|
||||
}
|
||||
|
||||
public int id ()
|
||||
{
|
||||
return this._id;
|
||||
}
|
||||
|
||||
public static OPCDATASOURCE fromID ( final int id )
|
||||
{
|
||||
switch ( id )
|
||||
{
|
||||
case 1:
|
||||
return OPC_DS_CACHE;
|
||||
case 2:
|
||||
return OPC_DS_DEVICE;
|
||||
default:
|
||||
return OPC_DS_UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.da;
|
||||
|
||||
public enum OPCENUMSCOPE
|
||||
{
|
||||
OPC_ENUM_PRIVATE_CONNECTIONS ( 1 ),
|
||||
OPC_ENUM_PUBLIC_CONNECTIONS ( 2 ),
|
||||
OPC_ENUM_ALL_CONNECTIONS ( 3 ),
|
||||
OPC_ENUM_PRIVATE ( 4 ),
|
||||
OPC_ENUM_PUBLIC ( 5 ),
|
||||
OPC_ENUM_ALL ( 6 ),
|
||||
OPC_ENUM_UNKNOWN ( 0 );
|
||||
|
||||
private int _id;
|
||||
|
||||
private OPCENUMSCOPE ( final int id )
|
||||
{
|
||||
this._id = id;
|
||||
}
|
||||
|
||||
public int id ()
|
||||
{
|
||||
return this._id;
|
||||
}
|
||||
|
||||
public static OPCENUMSCOPE fromID ( final int id )
|
||||
{
|
||||
switch ( id )
|
||||
{
|
||||
case 1:
|
||||
return OPC_ENUM_PRIVATE_CONNECTIONS;
|
||||
case 2:
|
||||
return OPC_ENUM_PUBLIC_CONNECTIONS;
|
||||
case 3:
|
||||
return OPC_ENUM_ALL_CONNECTIONS;
|
||||
case 4:
|
||||
return OPC_ENUM_PRIVATE;
|
||||
case 5:
|
||||
return OPC_ENUM_PUBLIC;
|
||||
case 6:
|
||||
return OPC_ENUM_ALL;
|
||||
default:
|
||||
return OPC_ENUM_UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.da;
|
||||
|
||||
public class OPCGroupState
|
||||
{
|
||||
private int _updateRate = 1000;
|
||||
|
||||
private boolean _active = true;
|
||||
|
||||
private String _name = "";
|
||||
|
||||
private int _timeBias = 0;
|
||||
|
||||
private float _percentDeadband = 0.0f;
|
||||
|
||||
private int _localeID = 0;
|
||||
|
||||
private int _clientHandle = 0;
|
||||
|
||||
private int _serverHandle = 0;
|
||||
|
||||
public boolean isActive ()
|
||||
{
|
||||
return this._active;
|
||||
}
|
||||
|
||||
public void setActive ( final boolean active )
|
||||
{
|
||||
this._active = active;
|
||||
}
|
||||
|
||||
public int getClientHandle ()
|
||||
{
|
||||
return this._clientHandle;
|
||||
}
|
||||
|
||||
public void setClientHandle ( final int clientHandle )
|
||||
{
|
||||
this._clientHandle = clientHandle;
|
||||
}
|
||||
|
||||
public int getLocaleID ()
|
||||
{
|
||||
return this._localeID;
|
||||
}
|
||||
|
||||
public void setLocaleID ( final int localeID )
|
||||
{
|
||||
this._localeID = localeID;
|
||||
}
|
||||
|
||||
public String getName ()
|
||||
{
|
||||
return this._name;
|
||||
}
|
||||
|
||||
public void setName ( final String name )
|
||||
{
|
||||
this._name = name;
|
||||
}
|
||||
|
||||
public float getPercentDeadband ()
|
||||
{
|
||||
return this._percentDeadband;
|
||||
}
|
||||
|
||||
public void setPercentDeadband ( final float percentDeadband )
|
||||
{
|
||||
this._percentDeadband = percentDeadband;
|
||||
}
|
||||
|
||||
public int getServerHandle ()
|
||||
{
|
||||
return this._serverHandle;
|
||||
}
|
||||
|
||||
public void setServerHandle ( final int serverHandle )
|
||||
{
|
||||
this._serverHandle = serverHandle;
|
||||
}
|
||||
|
||||
public int getTimeBias ()
|
||||
{
|
||||
return this._timeBias;
|
||||
}
|
||||
|
||||
public void setTimeBias ( final int timeBias )
|
||||
{
|
||||
this._timeBias = timeBias;
|
||||
}
|
||||
|
||||
public int getUpdateRate ()
|
||||
{
|
||||
return this._updateRate;
|
||||
}
|
||||
|
||||
public void setUpdateRate ( final int updateRate )
|
||||
{
|
||||
this._updateRate = updateRate;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2012 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.da;
|
||||
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.jinterop.dcom.core.JIFlags;
|
||||
import org.jinterop.dcom.core.JIPointer;
|
||||
import org.jinterop.dcom.core.JIString;
|
||||
import org.jinterop.dcom.core.JIStruct;
|
||||
import org.jinterop.dcom.core.JIVariant;
|
||||
|
||||
public class OPCITEMDEF
|
||||
{
|
||||
private String accessPath = "";
|
||||
|
||||
private String itemID = "";
|
||||
|
||||
private boolean active = true;
|
||||
|
||||
private int clientHandle;
|
||||
|
||||
private short requestedDataType = JIVariant.VT_EMPTY;
|
||||
|
||||
private short reserved;
|
||||
|
||||
public String getAccessPath ()
|
||||
{
|
||||
return this.accessPath;
|
||||
}
|
||||
|
||||
public void setAccessPath ( final String accessPath )
|
||||
{
|
||||
this.accessPath = accessPath;
|
||||
}
|
||||
|
||||
public int getClientHandle ()
|
||||
{
|
||||
return this.clientHandle;
|
||||
}
|
||||
|
||||
public void setClientHandle ( final int clientHandle )
|
||||
{
|
||||
this.clientHandle = clientHandle;
|
||||
}
|
||||
|
||||
public boolean isActive ()
|
||||
{
|
||||
return this.active;
|
||||
}
|
||||
|
||||
public void setActive ( final boolean active )
|
||||
{
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
public String getItemID ()
|
||||
{
|
||||
return this.itemID;
|
||||
}
|
||||
|
||||
public void setItemID ( final String itemID )
|
||||
{
|
||||
this.itemID = itemID;
|
||||
}
|
||||
|
||||
public short getRequestedDataType ()
|
||||
{
|
||||
return this.requestedDataType;
|
||||
}
|
||||
|
||||
public void setRequestedDataType ( final short requestedDataType )
|
||||
{
|
||||
this.requestedDataType = requestedDataType;
|
||||
}
|
||||
|
||||
public short getReserved ()
|
||||
{
|
||||
return this.reserved;
|
||||
}
|
||||
|
||||
public void setReserved ( final short reserved )
|
||||
{
|
||||
this.reserved = reserved;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert to structure to a J-Interop structure
|
||||
*
|
||||
* @return the j-interop structe
|
||||
* @throws JIException
|
||||
*/
|
||||
public JIStruct toStruct () throws JIException
|
||||
{
|
||||
final JIStruct struct = new JIStruct ();
|
||||
struct.addMember ( new JIString ( getAccessPath (), JIFlags.FLAG_REPRESENTATION_STRING_LPWSTR ) );
|
||||
struct.addMember ( new JIString ( getItemID (), JIFlags.FLAG_REPRESENTATION_STRING_LPWSTR ) );
|
||||
struct.addMember ( new Integer ( isActive () ? 1 : 0 ) );
|
||||
struct.addMember ( Integer.valueOf ( getClientHandle () ) );
|
||||
|
||||
struct.addMember ( Integer.valueOf ( 0 ) ); // blob size
|
||||
struct.addMember ( new JIPointer ( null ) ); // blob
|
||||
|
||||
struct.addMember ( Short.valueOf ( getRequestedDataType () ) );
|
||||
struct.addMember ( Short.valueOf ( getReserved () ) );
|
||||
return struct;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.da;
|
||||
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.jinterop.dcom.core.JIArray;
|
||||
import org.jinterop.dcom.core.JIPointer;
|
||||
import org.jinterop.dcom.core.JIStruct;
|
||||
import org.jinterop.dcom.core.JIVariant;
|
||||
|
||||
public class OPCITEMRESULT
|
||||
{
|
||||
private int _serverHandle = 0;
|
||||
|
||||
private short _canonicalDataType = JIVariant.VT_EMPTY;
|
||||
|
||||
private short _reserved = 0;
|
||||
|
||||
private int _accessRights = 0;
|
||||
|
||||
public int getAccessRights ()
|
||||
{
|
||||
return this._accessRights;
|
||||
}
|
||||
|
||||
public void setAccessRights ( final int accessRights )
|
||||
{
|
||||
this._accessRights = accessRights;
|
||||
}
|
||||
|
||||
public short getCanonicalDataType ()
|
||||
{
|
||||
return this._canonicalDataType;
|
||||
}
|
||||
|
||||
public void setCanonicalDataType ( final short canonicalDataType )
|
||||
{
|
||||
this._canonicalDataType = canonicalDataType;
|
||||
}
|
||||
|
||||
public short getReserved ()
|
||||
{
|
||||
return this._reserved;
|
||||
}
|
||||
|
||||
public void setReserved ( final short reserved )
|
||||
{
|
||||
this._reserved = reserved;
|
||||
}
|
||||
|
||||
public int getServerHandle ()
|
||||
{
|
||||
return this._serverHandle;
|
||||
}
|
||||
|
||||
public void setServerHandle ( final int serverHandle )
|
||||
{
|
||||
this._serverHandle = serverHandle;
|
||||
}
|
||||
|
||||
public static JIStruct getStruct () throws JIException
|
||||
{
|
||||
JIStruct struct = new JIStruct ();
|
||||
|
||||
struct.addMember ( Integer.class ); // Server handle
|
||||
struct.addMember ( Short.class ); // data type
|
||||
struct.addMember ( Short.class ); // reserved
|
||||
struct.addMember ( Integer.class ); // access rights
|
||||
struct.addMember ( Integer.class ); // blob size
|
||||
// grab the normally unused byte array
|
||||
struct.addMember ( new JIPointer ( new JIArray ( Byte.class, null, 1, true, false ) ) );
|
||||
|
||||
return struct;
|
||||
}
|
||||
|
||||
public static OPCITEMRESULT fromStruct ( final JIStruct struct )
|
||||
{
|
||||
OPCITEMRESULT result = new OPCITEMRESULT ();
|
||||
|
||||
result.setServerHandle ( new Integer ( (Integer)struct.getMember ( 0 ) ) );
|
||||
result.setCanonicalDataType ( new Short ( (Short)struct.getMember ( 1 ) ) );
|
||||
result.setReserved ( new Short ( (Short)struct.getMember ( 2 ) ) );
|
||||
result.setAccessRights ( new Integer ( (Integer)struct.getMember ( 3 ) ) );
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.da;
|
||||
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.jinterop.dcom.core.JIStruct;
|
||||
import org.jinterop.dcom.core.JIVariant;
|
||||
import org.openscada.opc.dcom.common.FILETIME;
|
||||
|
||||
public class OPCITEMSTATE
|
||||
{
|
||||
private int _clientHandle = 0;
|
||||
|
||||
private FILETIME _timestamp = null;
|
||||
|
||||
private short _quality = 0;
|
||||
|
||||
private short _reserved = 0;
|
||||
|
||||
private JIVariant _value = null;
|
||||
|
||||
public int getClientHandle ()
|
||||
{
|
||||
return this._clientHandle;
|
||||
}
|
||||
|
||||
public void setClientHandle ( final int clientHandle )
|
||||
{
|
||||
this._clientHandle = clientHandle;
|
||||
}
|
||||
|
||||
public short getQuality ()
|
||||
{
|
||||
return this._quality;
|
||||
}
|
||||
|
||||
public void setQuality ( final short quality )
|
||||
{
|
||||
this._quality = quality;
|
||||
}
|
||||
|
||||
public short getReserved ()
|
||||
{
|
||||
return this._reserved;
|
||||
}
|
||||
|
||||
public void setReserved ( final short reserved )
|
||||
{
|
||||
this._reserved = reserved;
|
||||
}
|
||||
|
||||
public FILETIME getTimestamp ()
|
||||
{
|
||||
return this._timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp ( final FILETIME timestamp )
|
||||
{
|
||||
this._timestamp = timestamp;
|
||||
}
|
||||
|
||||
public JIVariant getValue ()
|
||||
{
|
||||
return this._value;
|
||||
}
|
||||
|
||||
public void setValue ( final JIVariant value )
|
||||
{
|
||||
this._value = value;
|
||||
}
|
||||
|
||||
public static JIStruct getStruct () throws JIException
|
||||
{
|
||||
JIStruct struct = new JIStruct ();
|
||||
|
||||
struct.addMember ( Integer.class );
|
||||
struct.addMember ( FILETIME.getStruct () );
|
||||
struct.addMember ( Short.class );
|
||||
struct.addMember ( Short.class );
|
||||
struct.addMember ( JIVariant.class );
|
||||
|
||||
return struct;
|
||||
}
|
||||
|
||||
public static OPCITEMSTATE fromStruct ( final JIStruct struct )
|
||||
{
|
||||
OPCITEMSTATE itemState = new OPCITEMSTATE ();
|
||||
|
||||
itemState.setClientHandle ( (Integer)struct.getMember ( 0 ) );
|
||||
itemState.setTimestamp ( FILETIME.fromStruct ( (JIStruct)struct.getMember ( 1 ) ) );
|
||||
itemState.setQuality ( (Short)struct.getMember ( 2 ) );
|
||||
itemState.setReserved ( (Short)struct.getMember ( 3 ) );
|
||||
itemState.setValue ( (JIVariant)struct.getMember ( 4 ) );
|
||||
|
||||
return itemState;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.da;
|
||||
|
||||
public enum OPCNAMESPACETYPE
|
||||
{
|
||||
OPC_NS_HIERARCHIAL ( 1 ),
|
||||
OPC_NS_FLAT ( 2 ),
|
||||
OPC_NS_UNKNOWN ( 0 );
|
||||
|
||||
private int _id;
|
||||
|
||||
private OPCNAMESPACETYPE ( final int id )
|
||||
{
|
||||
this._id = id;
|
||||
}
|
||||
|
||||
public int id ()
|
||||
{
|
||||
return this._id;
|
||||
}
|
||||
|
||||
public static OPCNAMESPACETYPE fromID ( final int id )
|
||||
{
|
||||
switch ( id )
|
||||
{
|
||||
case 1:
|
||||
return OPC_NS_HIERARCHIAL;
|
||||
case 2:
|
||||
return OPC_NS_FLAT;
|
||||
default:
|
||||
return OPC_NS_UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.da;
|
||||
|
||||
public enum OPCSERVERSTATE
|
||||
{
|
||||
OPC_STATUS_RUNNING ( 1 ),
|
||||
OPC_STATUS_FAILED ( 2 ),
|
||||
OPC_STATUS_NOCONFIG ( 3 ),
|
||||
OPC_STATUS_SUSPENDED ( 4 ),
|
||||
OPC_STATUS_TEST ( 5 ),
|
||||
OPC_STATUS_COMM_FAULT ( 6 ),
|
||||
OPC_STATUS_UNKNOWN ( 0 );
|
||||
|
||||
private int _id;
|
||||
|
||||
private OPCSERVERSTATE ( final int id )
|
||||
{
|
||||
this._id = id;
|
||||
}
|
||||
|
||||
public int id ()
|
||||
{
|
||||
return this._id;
|
||||
}
|
||||
|
||||
public static OPCSERVERSTATE fromID ( final int id )
|
||||
{
|
||||
switch ( id )
|
||||
{
|
||||
case 1:
|
||||
return OPC_STATUS_RUNNING;
|
||||
case 2:
|
||||
return OPC_STATUS_FAILED;
|
||||
case 3:
|
||||
return OPC_STATUS_NOCONFIG;
|
||||
case 4:
|
||||
return OPC_STATUS_SUSPENDED;
|
||||
case 5:
|
||||
return OPC_STATUS_TEST;
|
||||
case 6:
|
||||
return OPC_STATUS_COMM_FAULT;
|
||||
default:
|
||||
return OPC_STATUS_UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.da;
|
||||
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.jinterop.dcom.core.JIFlags;
|
||||
import org.jinterop.dcom.core.JIPointer;
|
||||
import org.jinterop.dcom.core.JIString;
|
||||
import org.jinterop.dcom.core.JIStruct;
|
||||
import org.openscada.opc.dcom.common.FILETIME;
|
||||
|
||||
public class OPCSERVERSTATUS
|
||||
{
|
||||
private FILETIME _startTime = null;
|
||||
|
||||
private FILETIME _currentTime = null;
|
||||
|
||||
private FILETIME _lastUpdateTime = null;
|
||||
|
||||
private OPCSERVERSTATE _serverState = null;
|
||||
|
||||
private int _groupCount = -1;
|
||||
|
||||
private int _bandWidth = -1;
|
||||
|
||||
private short _majorVersion = -1;
|
||||
|
||||
private short _minorVersion = -1;
|
||||
|
||||
private short _buildNumber = -1;
|
||||
|
||||
private short _reserved = 0;
|
||||
|
||||
private String _vendorInfo = null;
|
||||
|
||||
public int getBandWidth ()
|
||||
{
|
||||
return this._bandWidth;
|
||||
}
|
||||
|
||||
public void setBandWidth ( final int bandWidth )
|
||||
{
|
||||
this._bandWidth = bandWidth;
|
||||
}
|
||||
|
||||
public short getBuildNumber ()
|
||||
{
|
||||
return this._buildNumber;
|
||||
}
|
||||
|
||||
public void setBuildNumber ( final short buildNumber )
|
||||
{
|
||||
this._buildNumber = buildNumber;
|
||||
}
|
||||
|
||||
public FILETIME getCurrentTime ()
|
||||
{
|
||||
return this._currentTime;
|
||||
}
|
||||
|
||||
public void setCurrentTime ( final FILETIME currentTime )
|
||||
{
|
||||
this._currentTime = currentTime;
|
||||
}
|
||||
|
||||
public int getGroupCount ()
|
||||
{
|
||||
return this._groupCount;
|
||||
}
|
||||
|
||||
public void setGroupCount ( final int groupCount )
|
||||
{
|
||||
this._groupCount = groupCount;
|
||||
}
|
||||
|
||||
public FILETIME getLastUpdateTime ()
|
||||
{
|
||||
return this._lastUpdateTime;
|
||||
}
|
||||
|
||||
public void setLastUpdateTime ( final FILETIME lastUpdateTime )
|
||||
{
|
||||
this._lastUpdateTime = lastUpdateTime;
|
||||
}
|
||||
|
||||
public short getMajorVersion ()
|
||||
{
|
||||
return this._majorVersion;
|
||||
}
|
||||
|
||||
public void setMajorVersion ( final short majorVersion )
|
||||
{
|
||||
this._majorVersion = majorVersion;
|
||||
}
|
||||
|
||||
public short getMinorVersion ()
|
||||
{
|
||||
return this._minorVersion;
|
||||
}
|
||||
|
||||
public void setMinorVersion ( final short minorVersion )
|
||||
{
|
||||
this._minorVersion = minorVersion;
|
||||
}
|
||||
|
||||
public short getReserved ()
|
||||
{
|
||||
return this._reserved;
|
||||
}
|
||||
|
||||
public void setReserved ( final short reserved )
|
||||
{
|
||||
this._reserved = reserved;
|
||||
}
|
||||
|
||||
public FILETIME getStartTime ()
|
||||
{
|
||||
return this._startTime;
|
||||
}
|
||||
|
||||
public void setStartTime ( final FILETIME startTime )
|
||||
{
|
||||
this._startTime = startTime;
|
||||
}
|
||||
|
||||
public String getVendorInfo ()
|
||||
{
|
||||
return this._vendorInfo;
|
||||
}
|
||||
|
||||
public void setVendorInfo ( final String vendorInfo )
|
||||
{
|
||||
this._vendorInfo = vendorInfo;
|
||||
}
|
||||
|
||||
public OPCSERVERSTATE getServerState ()
|
||||
{
|
||||
return this._serverState;
|
||||
}
|
||||
|
||||
public void setServerState ( final OPCSERVERSTATE dwServerState )
|
||||
{
|
||||
this._serverState = dwServerState;
|
||||
}
|
||||
|
||||
public static JIStruct getStruct () throws JIException
|
||||
{
|
||||
JIStruct struct = new JIStruct ();
|
||||
|
||||
struct.addMember ( FILETIME.getStruct () );
|
||||
struct.addMember ( FILETIME.getStruct () );
|
||||
struct.addMember ( FILETIME.getStruct () );
|
||||
struct.addMember ( Short.class ); // enum: OPCSERVERSTATE
|
||||
struct.addMember ( Integer.class );
|
||||
struct.addMember ( Integer.class );
|
||||
struct.addMember ( Short.class );
|
||||
struct.addMember ( Short.class );
|
||||
struct.addMember ( Short.class );
|
||||
struct.addMember ( Short.class );
|
||||
struct.addMember ( new JIPointer ( new JIString ( JIFlags.FLAG_REPRESENTATION_STRING_LPWSTR ) ) );
|
||||
|
||||
return struct;
|
||||
}
|
||||
|
||||
public static OPCSERVERSTATUS fromStruct ( final JIStruct struct )
|
||||
{
|
||||
OPCSERVERSTATUS status = new OPCSERVERSTATUS ();
|
||||
|
||||
status._startTime = FILETIME.fromStruct ( (JIStruct)struct.getMember ( 0 ) );
|
||||
status._currentTime = FILETIME.fromStruct ( (JIStruct)struct.getMember ( 1 ) );
|
||||
status._lastUpdateTime = FILETIME.fromStruct ( (JIStruct)struct.getMember ( 2 ) );
|
||||
|
||||
status._serverState = OPCSERVERSTATE.fromID ( (Short)struct.getMember ( 3 ) );
|
||||
status._groupCount = (Integer)struct.getMember ( 4 );
|
||||
status._bandWidth = (Integer)struct.getMember ( 5 );
|
||||
status._majorVersion = (Short)struct.getMember ( 6 );
|
||||
status._minorVersion = (Short)struct.getMember ( 7 );
|
||||
status._buildNumber = (Short)struct.getMember ( 8 );
|
||||
status._reserved = (Short)struct.getMember ( 9 );
|
||||
status._vendorInfo = ( (JIString) ( (JIPointer)struct.getMember ( 10 ) ).getReferent () ).getString ();
|
||||
|
||||
return status;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.da;
|
||||
|
||||
public class PropertyDescription
|
||||
{
|
||||
private int _id = -1;
|
||||
|
||||
private String _description = "";
|
||||
|
||||
private short _varType = 0;
|
||||
|
||||
public String getDescription ()
|
||||
{
|
||||
return this._description;
|
||||
}
|
||||
|
||||
public void setDescription ( final String description )
|
||||
{
|
||||
this._description = description;
|
||||
}
|
||||
|
||||
public int getId ()
|
||||
{
|
||||
return this._id;
|
||||
}
|
||||
|
||||
public void setId ( final int id )
|
||||
{
|
||||
this._id = id;
|
||||
}
|
||||
|
||||
public short getVarType ()
|
||||
{
|
||||
return this._varType;
|
||||
}
|
||||
|
||||
public void setVarType ( final short varType )
|
||||
{
|
||||
this._varType = varType;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
*
|
||||
* Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
* Copyright (C) 2013 Jens Reimann (ctron@dentrassi.de)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.da;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
import org.jinterop.dcom.core.JIVariant;
|
||||
|
||||
public class ValueData
|
||||
{
|
||||
private JIVariant value;
|
||||
|
||||
private short quality;
|
||||
|
||||
private Calendar timestamp;
|
||||
|
||||
public short getQuality ()
|
||||
{
|
||||
return this.quality;
|
||||
}
|
||||
|
||||
public void setQuality ( final short quality )
|
||||
{
|
||||
this.quality = quality;
|
||||
}
|
||||
|
||||
public Calendar getTimestamp ()
|
||||
{
|
||||
return this.timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp ( final Calendar timestamp )
|
||||
{
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
public JIVariant getValue ()
|
||||
{
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public void setValue ( final JIVariant value )
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
*
|
||||
* Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
* Copyright (C) 2013 Jens Reimann (ctron@dentrassi.de)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.da;
|
||||
|
||||
import org.jinterop.dcom.core.JIVariant;
|
||||
|
||||
/**
|
||||
* Data for a write request to the server
|
||||
*
|
||||
* @author Jens Reimann <jens.reimann@th4-systems.com>
|
||||
*/
|
||||
public class WriteRequest
|
||||
{
|
||||
private int serverHandle = 0;
|
||||
|
||||
private JIVariant value = JIVariant.EMPTY ();
|
||||
|
||||
public WriteRequest ()
|
||||
{
|
||||
}
|
||||
|
||||
public WriteRequest ( final WriteRequest request )
|
||||
{
|
||||
this.serverHandle = request.serverHandle;
|
||||
this.value = request.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new write request with pre-fille data
|
||||
*
|
||||
* @param serverHandle
|
||||
* the server handle of the item to write to
|
||||
* @param value
|
||||
* the value to write.
|
||||
*/
|
||||
public WriteRequest ( final int serverHandle, final JIVariant value )
|
||||
{
|
||||
this.serverHandle = serverHandle;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getServerHandle ()
|
||||
{
|
||||
return this.serverHandle;
|
||||
}
|
||||
|
||||
public void setServerHandle ( final int serverHandle )
|
||||
{
|
||||
this.serverHandle = serverHandle;
|
||||
}
|
||||
|
||||
public JIVariant getValue ()
|
||||
{
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public void setValue ( final JIVariant value )
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
*
|
||||
* Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
* Copyright (C) 2013 Jens Reimann (ctron@dentrassi.de)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.da.impl;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.jinterop.dcom.core.IJIComObject;
|
||||
import org.jinterop.dcom.core.JIArray;
|
||||
import org.jinterop.dcom.core.JICallBuilder;
|
||||
import org.jinterop.dcom.core.JIFlags;
|
||||
import org.jinterop.dcom.core.JIPointer;
|
||||
import org.openscada.opc.dcom.common.Result;
|
||||
import org.openscada.opc.dcom.common.ResultSet;
|
||||
import org.openscada.opc.dcom.common.impl.BaseCOMObject;
|
||||
import org.openscada.opc.dcom.da.Constants;
|
||||
import org.openscada.opc.dcom.da.OPCDATASOURCE;
|
||||
|
||||
public class OPCAsyncIO2 extends BaseCOMObject
|
||||
{
|
||||
public class AsyncResult
|
||||
{
|
||||
private final ResultSet<Integer> result;
|
||||
|
||||
private final Integer cancelId;
|
||||
|
||||
public AsyncResult ()
|
||||
{
|
||||
super ();
|
||||
this.result = new ResultSet<Integer> ();
|
||||
this.cancelId = null;
|
||||
}
|
||||
|
||||
public AsyncResult ( final ResultSet<Integer> result, final Integer cancelId )
|
||||
{
|
||||
super ();
|
||||
this.result = result;
|
||||
this.cancelId = cancelId;
|
||||
}
|
||||
|
||||
public Integer getCancelId ()
|
||||
{
|
||||
return this.cancelId;
|
||||
}
|
||||
|
||||
public ResultSet<Integer> getResult ()
|
||||
{
|
||||
return this.result;
|
||||
}
|
||||
}
|
||||
|
||||
public OPCAsyncIO2 ( final IJIComObject opcAsyncIO2 ) throws IllegalArgumentException, UnknownHostException, JIException
|
||||
{
|
||||
super ( opcAsyncIO2.queryInterface ( Constants.IOPCAsyncIO2_IID ) );
|
||||
}
|
||||
|
||||
public void setEnable ( final boolean state ) throws JIException
|
||||
{
|
||||
final JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 4 );
|
||||
|
||||
callObject.addInParamAsInt ( state ? 1 : 0, JIFlags.FLAG_NULL );
|
||||
|
||||
getCOMObject ().call ( callObject );
|
||||
}
|
||||
|
||||
public int refresh ( final OPCDATASOURCE dataSource, final int transactionID ) throws JIException
|
||||
{
|
||||
final JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 2 );
|
||||
|
||||
callObject.addInParamAsShort ( (short)dataSource.id (), JIFlags.FLAG_NULL );
|
||||
callObject.addInParamAsInt ( transactionID, JIFlags.FLAG_NULL );
|
||||
callObject.addOutParamAsType ( Integer.class, JIFlags.FLAG_NULL );
|
||||
|
||||
final Object result[] = getCOMObject ().call ( callObject );
|
||||
|
||||
return (Integer)result[0];
|
||||
}
|
||||
|
||||
public void cancel ( final int cancelId ) throws JIException
|
||||
{
|
||||
final JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 3 );
|
||||
|
||||
callObject.addInParamAsInt ( cancelId, JIFlags.FLAG_NULL );
|
||||
|
||||
getCOMObject ().call ( callObject );
|
||||
}
|
||||
|
||||
public AsyncResult read ( final int transactionId, final Integer... serverHandles ) throws JIException
|
||||
{
|
||||
if ( serverHandles == null || serverHandles.length == 0 )
|
||||
{
|
||||
return new AsyncResult ();
|
||||
}
|
||||
|
||||
final JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 0 );
|
||||
|
||||
callObject.addInParamAsInt ( serverHandles.length, JIFlags.FLAG_NULL );
|
||||
callObject.addInParamAsArray ( new JIArray ( serverHandles, true ), JIFlags.FLAG_NULL );
|
||||
callObject.addInParamAsInt ( transactionId, JIFlags.FLAG_NULL );
|
||||
|
||||
callObject.addOutParamAsType ( Integer.class, JIFlags.FLAG_NULL );
|
||||
callObject.addOutParamAsObject ( new JIPointer ( new JIArray ( Integer.class, null, 1, true ) ), JIFlags.FLAG_NULL );
|
||||
|
||||
final Object[] result = getCOMObject ().call ( callObject );
|
||||
|
||||
final Integer cancelId = (Integer)result[0];
|
||||
final Integer[] errorCodes = (Integer[]) ( (JIArray) ( (JIPointer)result[1] ).getReferent () ).getArrayInstance ();
|
||||
|
||||
final ResultSet<Integer> resultSet = new ResultSet<Integer> ();
|
||||
|
||||
for ( int i = 0; i < serverHandles.length; i++ )
|
||||
{
|
||||
resultSet.add ( new Result<Integer> ( serverHandles[i], errorCodes[i] ) );
|
||||
}
|
||||
|
||||
return new AsyncResult ( resultSet, cancelId );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.da.impl;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.jinterop.dcom.core.IJIComObject;
|
||||
import org.openscada.opc.dcom.common.impl.BaseCOMObject;
|
||||
import org.openscada.opc.dcom.da.Constants;
|
||||
|
||||
public class OPCBrowse extends BaseCOMObject
|
||||
{
|
||||
public OPCBrowse ( final IJIComObject opcServer ) throws IllegalArgumentException, UnknownHostException, JIException
|
||||
{
|
||||
super ( opcServer.queryInterface ( Constants.IOPCBrowse_IID ) );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.da.impl;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.jinterop.dcom.core.IJIComObject;
|
||||
import org.jinterop.dcom.core.JICallBuilder;
|
||||
import org.jinterop.dcom.core.JIFlags;
|
||||
import org.jinterop.dcom.core.JIPointer;
|
||||
import org.jinterop.dcom.core.JIString;
|
||||
import org.openscada.opc.dcom.common.impl.BaseCOMObject;
|
||||
import org.openscada.opc.dcom.common.impl.EnumString;
|
||||
import org.openscada.opc.dcom.common.impl.Helper;
|
||||
import org.openscada.opc.dcom.da.Constants;
|
||||
import org.openscada.opc.dcom.da.OPCBROWSEDIRECTION;
|
||||
import org.openscada.opc.dcom.da.OPCBROWSETYPE;
|
||||
import org.openscada.opc.dcom.da.OPCNAMESPACETYPE;
|
||||
|
||||
/**
|
||||
* Implementation for <code>IOPCBrowseServerAddressSpace</code>
|
||||
* @author Jens Reimann <jens.reimann@th4-systems.com>
|
||||
*
|
||||
*/
|
||||
public class OPCBrowseServerAddressSpace extends BaseCOMObject
|
||||
{
|
||||
public OPCBrowseServerAddressSpace ( final IJIComObject opcServer ) throws IllegalArgumentException, UnknownHostException, JIException
|
||||
{
|
||||
super ( opcServer.queryInterface ( Constants.IOPCBrowseServerAddressSpace_IID ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the information how the namespace is organized
|
||||
* @return the organization of the namespace
|
||||
* @throws JIException
|
||||
*/
|
||||
public OPCNAMESPACETYPE queryOrganization () throws JIException
|
||||
{
|
||||
JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 0 );
|
||||
|
||||
callObject.addOutParamAsType ( Short.class, JIFlags.FLAG_NULL );
|
||||
|
||||
Object result[] = getCOMObject ().call ( callObject );
|
||||
|
||||
return OPCNAMESPACETYPE.fromID ( (Short)result[0] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Direct the browser to another position
|
||||
*
|
||||
* Depending on the <em>direction</em> the new position will be set based on the provided
|
||||
* position information. If the direction is {@link OPCBROWSEDIRECTION#OPC_BROWSE_TO} then
|
||||
* the <em>position</em> is the item to go to. If the direction is {@link OPCBROWSEDIRECTION#OPC_BROWSE_DOWN}
|
||||
* the browser will descent into the tree down (not to) the branch item in <em>position</em>.
|
||||
* Passing {@link OPCBROWSEDIRECTION#OPC_BROWSE_UP} won't need a <em>position</em> (pass <code>null</code>)
|
||||
* and will ascent in the tree one level.
|
||||
*
|
||||
* Passing {@link OPCBROWSEDIRECTION#OPC_BROWSE_TO} and <code>null</code> as position will
|
||||
* go to the first root entry of the namespace.
|
||||
*
|
||||
* @param position The item position reference for the direction
|
||||
* @param direction The direction to go based on the position
|
||||
* @throws JIException
|
||||
*/
|
||||
public void changePosition ( final String position, final OPCBROWSEDIRECTION direction ) throws JIException
|
||||
{
|
||||
JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 1 );
|
||||
|
||||
callObject.addInParamAsShort ( (short)direction.id (), JIFlags.FLAG_NULL );
|
||||
callObject.addInParamAsString ( position, JIFlags.FLAG_REPRESENTATION_STRING_LPWSTR );
|
||||
|
||||
getCOMObject ().call ( callObject );
|
||||
|
||||
}
|
||||
|
||||
public EnumString browse ( final OPCBROWSETYPE browseType, final String filterCriteria, final int accessRights, final int dataType ) throws JIException, IllegalArgumentException, UnknownHostException
|
||||
{
|
||||
JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 2 );
|
||||
|
||||
callObject.addInParamAsShort ( (short)browseType.id (), JIFlags.FLAG_NULL );
|
||||
callObject.addInParamAsString ( filterCriteria, JIFlags.FLAG_REPRESENTATION_STRING_LPWSTR );
|
||||
callObject.addInParamAsShort ( (short)dataType, JIFlags.FLAG_NULL );
|
||||
callObject.addInParamAsInt ( accessRights, JIFlags.FLAG_NULL );
|
||||
callObject.addOutParamAsType ( IJIComObject.class, JIFlags.FLAG_NULL );
|
||||
|
||||
Object result[] = Helper.callRespectSFALSE ( getCOMObject (), callObject );
|
||||
|
||||
return new EnumString ( (IJIComObject)result[0] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the possible access paths for an item
|
||||
* @param itemID the item to query
|
||||
* @return A string enumerator for the possible access paths
|
||||
* @throws JIException
|
||||
* @throws IllegalArgumentException
|
||||
* @throws UnknownHostException
|
||||
*/
|
||||
public EnumString browseAccessPaths ( final String itemID ) throws JIException, IllegalArgumentException, UnknownHostException
|
||||
{
|
||||
JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 4 );
|
||||
|
||||
callObject.addInParamAsString ( itemID, JIFlags.FLAG_REPRESENTATION_STRING_LPWSTR );
|
||||
callObject.addOutParamAsType ( IJIComObject.class, JIFlags.FLAG_NULL );
|
||||
|
||||
Object[] result = Helper.callRespectSFALSE ( getCOMObject (), callObject );
|
||||
|
||||
return new EnumString ( (IJIComObject)result[0] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the complete item id from an item at the local position.
|
||||
*
|
||||
* Browsing a hierarchical namespace the browse method will return items based on the
|
||||
* local level in the namespace. So actually only the last part of the item ID hierarchy
|
||||
* is returned. In order to convert this to the full item ID one can use this method. It
|
||||
* will only work if the browser is still at the position in question.
|
||||
*
|
||||
* @param item the local item
|
||||
* @return the complete item ID
|
||||
* @throws JIException
|
||||
*/
|
||||
public String getItemID ( final String item ) throws JIException
|
||||
{
|
||||
JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 3 );
|
||||
|
||||
callObject.addInParamAsString ( item, JIFlags.FLAG_REPRESENTATION_STRING_LPWSTR );
|
||||
callObject.addOutParamAsObject ( new JIPointer ( new JIString ( JIFlags.FLAG_REPRESENTATION_STRING_LPWSTR ) ), JIFlags.FLAG_NULL );
|
||||
|
||||
Object[] result = getCOMObject ().call ( callObject );
|
||||
|
||||
return ( (JIString) ( (JIPointer)result[0] ).getReferent () ).getString ();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,259 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
*
|
||||
* Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
* Copyright (C) 2013 Jens Reimann (ctron@dentrassi.de)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.da.impl;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.jinterop.dcom.core.JIArray;
|
||||
import org.jinterop.dcom.core.JIFlags;
|
||||
import org.jinterop.dcom.core.JILocalCoClass;
|
||||
import org.jinterop.dcom.core.JILocalInterfaceDefinition;
|
||||
import org.jinterop.dcom.core.JILocalMethodDescriptor;
|
||||
import org.jinterop.dcom.core.JILocalParamsDescriptor;
|
||||
import org.jinterop.dcom.core.JIStruct;
|
||||
import org.jinterop.dcom.core.JIVariant;
|
||||
import org.openscada.opc.dcom.common.FILETIME;
|
||||
import org.openscada.opc.dcom.common.KeyedResult;
|
||||
import org.openscada.opc.dcom.common.KeyedResultSet;
|
||||
import org.openscada.opc.dcom.common.Result;
|
||||
import org.openscada.opc.dcom.common.ResultSet;
|
||||
import org.openscada.opc.dcom.common.impl.EventHandlerImpl;
|
||||
import org.openscada.opc.dcom.da.Constants;
|
||||
import org.openscada.opc.dcom.da.IOPCDataCallback;
|
||||
import org.openscada.opc.dcom.da.ValueData;
|
||||
|
||||
public class OPCDataCallback extends EventHandlerImpl
|
||||
{
|
||||
private IOPCDataCallback callback = null;
|
||||
|
||||
private JILocalCoClass coClass = null;
|
||||
|
||||
public OPCDataCallback ()
|
||||
{
|
||||
super ();
|
||||
}
|
||||
|
||||
public Object[] OnDataChange ( final int transactionId, final int serverGroupHandle, final int masterQuality, final int masterErrorCode, final int count, final JIArray clientHandles, final JIArray values, final JIArray qualities, final JIArray timestamps, final JIArray errors )
|
||||
{
|
||||
final IOPCDataCallback callback = this.callback;
|
||||
if ( callback == null )
|
||||
{
|
||||
return new Object[] { org.openscada.opc.dcom.common.Constants.S_OK };
|
||||
}
|
||||
|
||||
// get arrays for more readable code later ;-)
|
||||
final Integer[] errorCodes = (Integer[])errors.getArrayInstance ();
|
||||
final Integer[] itemHandles = (Integer[])clientHandles.getArrayInstance ();
|
||||
final Short[] qualitiesArray = (Short[])qualities.getArrayInstance ();
|
||||
final JIVariant[] valuesArray = (JIVariant[])values.getArrayInstance ();
|
||||
final JIStruct[] timestampArray = (JIStruct[])timestamps.getArrayInstance ();
|
||||
|
||||
// create result data
|
||||
final KeyedResultSet<Integer, ValueData> result = new KeyedResultSet<Integer, ValueData> ();
|
||||
for ( int i = 0; i < count; i++ )
|
||||
{
|
||||
final ValueData vd = new ValueData ();
|
||||
vd.setQuality ( qualitiesArray[i] );
|
||||
vd.setTimestamp ( FILETIME.fromStruct ( timestampArray[i] ).asCalendar () );
|
||||
vd.setValue ( valuesArray[i] );
|
||||
result.add ( new KeyedResult<Integer, ValueData> ( itemHandles[i], vd, errorCodes[i] ) );
|
||||
}
|
||||
|
||||
// fire event
|
||||
try
|
||||
{
|
||||
callback.dataChange ( transactionId, serverGroupHandle, masterQuality, masterErrorCode, result );
|
||||
}
|
||||
catch ( final Throwable e )
|
||||
{
|
||||
e.printStackTrace ();
|
||||
}
|
||||
|
||||
// The client must always return S_OK
|
||||
return new Object[] { org.openscada.opc.dcom.common.Constants.S_OK };
|
||||
}
|
||||
|
||||
public synchronized Object[] OnReadComplete ( final int transactionId, final int serverGroupHandle, final int masterQuality, final int masterErrorCode, final int count, final JIArray clientHandles, final JIArray values, final JIArray qualities, final JIArray timestamps, final JIArray errors )
|
||||
{
|
||||
if ( this.callback == null )
|
||||
{
|
||||
return new Object[] { org.openscada.opc.dcom.common.Constants.S_OK };
|
||||
}
|
||||
|
||||
// get arrays for more readable code later ;-)
|
||||
final Integer[] errorCodes = (Integer[])errors.getArrayInstance ();
|
||||
final Integer[] itemHandles = (Integer[])clientHandles.getArrayInstance ();
|
||||
final Short[] qualitiesArray = (Short[])qualities.getArrayInstance ();
|
||||
final JIVariant[] valuesArray = (JIVariant[])values.getArrayInstance ();
|
||||
final JIStruct[] timestampArray = (JIStruct[])timestamps.getArrayInstance ();
|
||||
|
||||
// create result data
|
||||
final KeyedResultSet<Integer, ValueData> result = new KeyedResultSet<Integer, ValueData> ();
|
||||
for ( int i = 0; i < count; i++ )
|
||||
{
|
||||
final ValueData vd = new ValueData ();
|
||||
vd.setQuality ( qualitiesArray[i] );
|
||||
vd.setTimestamp ( FILETIME.fromStruct ( timestampArray[i] ).asCalendar () );
|
||||
vd.setValue ( valuesArray[i] );
|
||||
result.add ( new KeyedResult<Integer, ValueData> ( itemHandles[i], vd, errorCodes[i] ) );
|
||||
}
|
||||
|
||||
// fire event
|
||||
try
|
||||
{
|
||||
this.callback.readComplete ( transactionId, serverGroupHandle, masterQuality, masterErrorCode, result );
|
||||
}
|
||||
catch ( final Throwable e )
|
||||
{
|
||||
e.printStackTrace ();
|
||||
}
|
||||
|
||||
// The client must always return S_OK
|
||||
return new Object[] { org.openscada.opc.dcom.common.Constants.S_OK };
|
||||
}
|
||||
|
||||
public synchronized Object[] OnWriteComplete ( final int transactionId, final int serverGroupHandle, final int masterErrorCode, final int count, final JIArray clientHandles, final JIArray errors )
|
||||
{
|
||||
if ( this.callback == null )
|
||||
{
|
||||
return new Object[] { org.openscada.opc.dcom.common.Constants.S_OK };
|
||||
}
|
||||
|
||||
// get arrays for more readable code later ;-)
|
||||
final Integer[] errorCodes = (Integer[])errors.getArrayInstance ();
|
||||
final Integer[] itemHandles = (Integer[])clientHandles.getArrayInstance ();
|
||||
|
||||
// create result data
|
||||
final ResultSet<Integer> result = new ResultSet<Integer> ();
|
||||
for ( int i = 0; i < count; i++ )
|
||||
{
|
||||
result.add ( new Result<Integer> ( itemHandles[i], errorCodes[i] ) );
|
||||
}
|
||||
|
||||
// fire event
|
||||
try
|
||||
{
|
||||
this.callback.writeComplete ( transactionId, serverGroupHandle, masterErrorCode, result );
|
||||
}
|
||||
catch ( final Throwable e )
|
||||
{
|
||||
e.printStackTrace ();
|
||||
}
|
||||
|
||||
// The client must always return S_OK
|
||||
return new Object[] { org.openscada.opc.dcom.common.Constants.S_OK };
|
||||
}
|
||||
|
||||
public synchronized Object[] OnCancelComplete ( final int transactionId, final int serverGroupHandle )
|
||||
{
|
||||
if ( this.callback == null )
|
||||
{
|
||||
return new Object[] { org.openscada.opc.dcom.common.Constants.S_OK };
|
||||
}
|
||||
|
||||
this.callback.cancelComplete ( transactionId, serverGroupHandle );
|
||||
|
||||
// The client must always return S_OK
|
||||
return new Object[] { org.openscada.opc.dcom.common.Constants.S_OK };
|
||||
}
|
||||
|
||||
public synchronized JILocalCoClass getCoClass () throws JIException
|
||||
{
|
||||
if ( this.coClass != null )
|
||||
{
|
||||
return this.coClass;
|
||||
}
|
||||
|
||||
this.coClass = new JILocalCoClass ( new JILocalInterfaceDefinition ( Constants.IOPCDataCallback_IID, false ), this, false );
|
||||
|
||||
JILocalParamsDescriptor params;
|
||||
JILocalMethodDescriptor method;
|
||||
|
||||
// OnDataChange
|
||||
params = new JILocalParamsDescriptor ();
|
||||
params.addInParamAsType ( Integer.class, JIFlags.FLAG_NULL ); // trans id
|
||||
params.addInParamAsType ( Integer.class, JIFlags.FLAG_NULL ); // group handle
|
||||
params.addInParamAsType ( Integer.class, JIFlags.FLAG_NULL ); // master quality
|
||||
params.addInParamAsType ( Integer.class, JIFlags.FLAG_NULL ); // master error
|
||||
params.addInParamAsType ( Integer.class, JIFlags.FLAG_NULL ); // count
|
||||
params.addInParamAsObject ( new JIArray ( Integer.class, null, 1, true ), JIFlags.FLAG_NULL ); // item handles
|
||||
params.addInParamAsObject ( new JIArray ( JIVariant.class, null, 1, true ), JIFlags.FLAG_NULL ); // values
|
||||
params.addInParamAsObject ( new JIArray ( Short.class, null, 1, true ), JIFlags.FLAG_NULL ); // qualities
|
||||
params.addInParamAsObject ( new JIArray ( FILETIME.getStruct (), null, 1, true ), JIFlags.FLAG_NULL ); // timestamps
|
||||
params.addInParamAsObject ( new JIArray ( Integer.class, null, 1, true ), JIFlags.FLAG_NULL ); // errors
|
||||
|
||||
method = new JILocalMethodDescriptor ( "OnDataChange", params );
|
||||
this.coClass.getInterfaceDefinition ().addMethodDescriptor ( method );
|
||||
|
||||
// OnReadComplete
|
||||
params = new JILocalParamsDescriptor ();
|
||||
params.addInParamAsType ( Integer.class, JIFlags.FLAG_NULL );
|
||||
params.addInParamAsType ( Integer.class, JIFlags.FLAG_NULL );
|
||||
params.addInParamAsType ( Integer.class, JIFlags.FLAG_NULL );
|
||||
params.addInParamAsType ( Integer.class, JIFlags.FLAG_NULL );
|
||||
params.addInParamAsType ( Integer.class, JIFlags.FLAG_NULL );
|
||||
params.addInParamAsObject ( new JIArray ( Integer.class, null, 1, true ), JIFlags.FLAG_NULL );
|
||||
params.addInParamAsObject ( new JIArray ( JIVariant.class, null, 1, true ), JIFlags.FLAG_NULL );
|
||||
params.addInParamAsObject ( new JIArray ( Short.class, null, 1, true ), JIFlags.FLAG_NULL );
|
||||
params.addInParamAsObject ( new JIArray ( FILETIME.getStruct (), null, 1, true ), JIFlags.FLAG_NULL );
|
||||
params.addInParamAsObject ( new JIArray ( Integer.class, null, 1, true ), JIFlags.FLAG_NULL );
|
||||
method = new JILocalMethodDescriptor ( "OnReadComplete", params );
|
||||
this.coClass.getInterfaceDefinition ().addMethodDescriptor ( method );
|
||||
|
||||
// OnWriteComplete
|
||||
params = new JILocalParamsDescriptor ();
|
||||
params.addInParamAsType ( Integer.class, JIFlags.FLAG_NULL );
|
||||
params.addInParamAsType ( Integer.class, JIFlags.FLAG_NULL );
|
||||
params.addInParamAsType ( Integer.class, JIFlags.FLAG_NULL );
|
||||
params.addInParamAsType ( Integer.class, JIFlags.FLAG_NULL );
|
||||
params.addInParamAsObject ( new JIArray ( Integer.class, null, 1, true ), JIFlags.FLAG_NULL );
|
||||
params.addInParamAsObject ( new JIArray ( Integer.class, null, 1, true ), JIFlags.FLAG_NULL );
|
||||
method = new JILocalMethodDescriptor ( "OnWriteComplete", params );
|
||||
this.coClass.getInterfaceDefinition ().addMethodDescriptor ( method );
|
||||
|
||||
// OnCancelComplete
|
||||
params = new JILocalParamsDescriptor ();
|
||||
params.addInParamAsType ( Integer.class, JIFlags.FLAG_NULL );
|
||||
params.addInParamAsType ( Integer.class, JIFlags.FLAG_NULL );
|
||||
method = new JILocalMethodDescriptor ( "OnCancelComplete", params );
|
||||
this.coClass.getInterfaceDefinition ().addMethodDescriptor ( method );
|
||||
|
||||
// Add supported event interfaces
|
||||
final List<String> eventInterfaces = new LinkedList<String> ();
|
||||
eventInterfaces.add ( Constants.IOPCDataCallback_IID );
|
||||
this.coClass.setSupportedEventInterfaces ( eventInterfaces );
|
||||
|
||||
return this.coClass;
|
||||
}
|
||||
|
||||
public void setCallback ( final IOPCDataCallback callback )
|
||||
{
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
public IOPCDataCallback getCallback ()
|
||||
{
|
||||
return this.callback;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,218 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.da.impl;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.jinterop.dcom.core.IJIComObject;
|
||||
import org.jinterop.dcom.core.JICallBuilder;
|
||||
import org.jinterop.dcom.core.JIFlags;
|
||||
import org.jinterop.dcom.core.JIFrameworkHelper;
|
||||
import org.jinterop.dcom.core.JIPointer;
|
||||
import org.jinterop.dcom.core.JIString;
|
||||
import org.jinterop.dcom.impls.JIObjectFactory;
|
||||
import org.openscada.opc.dcom.common.EventHandler;
|
||||
import org.openscada.opc.dcom.common.impl.BaseCOMObject;
|
||||
import org.openscada.opc.dcom.da.Constants;
|
||||
import org.openscada.opc.dcom.da.IOPCDataCallback;
|
||||
import org.openscada.opc.dcom.da.OPCGroupState;
|
||||
|
||||
/**
|
||||
* Implementation of <code>IOPCGroupStateMgt</code>
|
||||
*
|
||||
* @author Jens Reimann <jens.reimann@th4-systems.com>
|
||||
*/
|
||||
public class OPCGroupStateMgt extends BaseCOMObject
|
||||
{
|
||||
public OPCGroupStateMgt ( final IJIComObject opcGroup ) throws IllegalArgumentException, UnknownHostException, JIException
|
||||
{
|
||||
super ( opcGroup.queryInterface ( Constants.IOPCGroupStateMgt_IID ) );
|
||||
}
|
||||
|
||||
public OPCGroupState getState () throws JIException
|
||||
{
|
||||
final JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 0 );
|
||||
|
||||
callObject.addOutParamAsType ( Integer.class, JIFlags.FLAG_NULL );
|
||||
callObject.addOutParamAsType ( Boolean.class, JIFlags.FLAG_NULL );
|
||||
callObject.addOutParamAsObject ( new JIPointer ( new JIString ( JIFlags.FLAG_REPRESENTATION_STRING_LPWSTR ) ), JIFlags.FLAG_NULL );
|
||||
callObject.addOutParamAsType ( Integer.class, JIFlags.FLAG_NULL );
|
||||
callObject.addOutParamAsType ( Float.class, JIFlags.FLAG_NULL );
|
||||
callObject.addOutParamAsType ( Integer.class, JIFlags.FLAG_NULL );
|
||||
callObject.addOutParamAsType ( Integer.class, JIFlags.FLAG_NULL );
|
||||
callObject.addOutParamAsType ( Integer.class, JIFlags.FLAG_NULL );
|
||||
|
||||
final Object result[] = getCOMObject ().call ( callObject );
|
||||
|
||||
final OPCGroupState state = new OPCGroupState ();
|
||||
state.setUpdateRate ( (Integer)result[0] );
|
||||
state.setActive ( (Boolean)result[1] );
|
||||
state.setName ( ( (JIString) ( (JIPointer)result[2] ).getReferent () ).getString () );
|
||||
state.setTimeBias ( (Integer)result[3] );
|
||||
state.setPercentDeadband ( (Float)result[4] );
|
||||
state.setLocaleID ( (Integer)result[5] );
|
||||
state.setClientHandle ( (Integer)result[6] );
|
||||
state.setServerHandle ( (Integer)result[7] );
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the group state Leaving any of the parameters <code>null</code> will keep the current value untouched.
|
||||
*
|
||||
* @param requestedUpdateRate
|
||||
* the requested update rate
|
||||
* @param active
|
||||
* Flag if the group is active or not
|
||||
* @param timeBias
|
||||
* The time bias
|
||||
* @param percentDeadband
|
||||
* the deadband percent
|
||||
* @param localeID
|
||||
* the locale ID
|
||||
* @param clientHandle
|
||||
* the client handle
|
||||
* @return the granted update rate
|
||||
* @throws JIException
|
||||
*/
|
||||
public int setState ( final Integer requestedUpdateRate, final Boolean active, final Integer timeBias, final Float percentDeadband, final Integer localeID, final Integer clientHandle ) throws JIException
|
||||
{
|
||||
final JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 1 );
|
||||
|
||||
callObject.addInParamAsPointer ( new JIPointer ( requestedUpdateRate ), JIFlags.FLAG_NULL );
|
||||
if ( active != null )
|
||||
{
|
||||
callObject.addInParamAsPointer ( new JIPointer ( Integer.valueOf ( active.booleanValue () ? 1 : 0 ) ), JIFlags.FLAG_NULL );
|
||||
}
|
||||
else
|
||||
{
|
||||
callObject.addInParamAsPointer ( new JIPointer ( null ), JIFlags.FLAG_NULL );
|
||||
}
|
||||
callObject.addInParamAsPointer ( new JIPointer ( timeBias ), JIFlags.FLAG_NULL );
|
||||
callObject.addInParamAsPointer ( new JIPointer ( percentDeadband ), JIFlags.FLAG_NULL );
|
||||
callObject.addInParamAsPointer ( new JIPointer ( localeID ), JIFlags.FLAG_NULL );
|
||||
callObject.addInParamAsPointer ( new JIPointer ( clientHandle ), JIFlags.FLAG_NULL );
|
||||
|
||||
callObject.addOutParamAsType ( Integer.class, JIFlags.FLAG_NULL );
|
||||
|
||||
final Object[] result = getCOMObject ().call ( callObject );
|
||||
|
||||
return (Integer)result[0];
|
||||
}
|
||||
|
||||
public OPCItemMgt getItemManagement () throws JIException
|
||||
{
|
||||
return new OPCItemMgt ( getCOMObject () );
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename to group
|
||||
*
|
||||
* @param name
|
||||
* the new name
|
||||
* @throws JIException
|
||||
*/
|
||||
public void setName ( final String name ) throws JIException
|
||||
{
|
||||
final JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 2 );
|
||||
|
||||
callObject.addInParamAsString ( name, JIFlags.FLAG_REPRESENTATION_STRING_LPWSTR );
|
||||
|
||||
getCOMObject ().call ( callObject );
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone the group
|
||||
*
|
||||
* @param name
|
||||
* the name of the cloned group
|
||||
* @return The cloned group
|
||||
* @throws JIException
|
||||
* @throws UnknownHostException
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
public OPCGroupStateMgt clone ( final String name ) throws JIException, IllegalArgumentException, UnknownHostException
|
||||
{
|
||||
final JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 3 );
|
||||
|
||||
callObject.addInParamAsString ( name, JIFlags.FLAG_REPRESENTATION_STRING_LPWSTR );
|
||||
callObject.addInParamAsUUID ( Constants.IOPCGroupStateMgt_IID, JIFlags.FLAG_NULL );
|
||||
callObject.addOutParamAsType ( IJIComObject.class, JIFlags.FLAG_NULL );
|
||||
|
||||
final Object[] result = getCOMObject ().call ( callObject );
|
||||
return new OPCGroupStateMgt ( (IJIComObject)result[0] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach a new callback to the group
|
||||
*
|
||||
* @param callback
|
||||
* The callback to attach
|
||||
* @return The event handler information
|
||||
* @throws JIException
|
||||
*/
|
||||
public EventHandler attach ( final IOPCDataCallback callback ) throws JIException
|
||||
{
|
||||
final OPCDataCallback callbackObject = new OPCDataCallback ();
|
||||
|
||||
callbackObject.setCallback ( callback );
|
||||
|
||||
// sync the callback object so that no calls get through the callback
|
||||
// until the callback information is set
|
||||
// If happens in some cases that the callback is triggered before
|
||||
// the method attachEventHandler returns.
|
||||
synchronized ( callbackObject )
|
||||
{
|
||||
final String id = JIFrameworkHelper.attachEventHandler ( getCOMObject (), Constants.IOPCDataCallback_IID, JIObjectFactory.buildObject ( getCOMObject ().getAssociatedSession (), callbackObject.getCoClass () ) );
|
||||
|
||||
callbackObject.setInfo ( getCOMObject (), id );
|
||||
}
|
||||
return callbackObject;
|
||||
}
|
||||
|
||||
public OPCAsyncIO2 getAsyncIO2 ()
|
||||
{
|
||||
try
|
||||
{
|
||||
return new OPCAsyncIO2 ( getCOMObject () );
|
||||
}
|
||||
catch ( final Exception e )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public OPCSyncIO getSyncIO ()
|
||||
{
|
||||
try
|
||||
{
|
||||
return new OPCSyncIO ( getCOMObject () );
|
||||
}
|
||||
catch ( final Exception e )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.da.impl;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.jinterop.dcom.core.IJIComObject;
|
||||
import org.jinterop.dcom.core.JIArray;
|
||||
import org.jinterop.dcom.core.JICallBuilder;
|
||||
import org.jinterop.dcom.core.JIFlags;
|
||||
import org.jinterop.dcom.core.JIPointer;
|
||||
import org.jinterop.dcom.core.JIString;
|
||||
import org.jinterop.dcom.core.JIVariant;
|
||||
import org.openscada.opc.dcom.common.FILETIME;
|
||||
import org.openscada.opc.dcom.common.impl.BaseCOMObject;
|
||||
import org.openscada.opc.dcom.da.Constants;
|
||||
import org.openscada.opc.dcom.da.IORequest;
|
||||
|
||||
public class OPCItemIO extends BaseCOMObject
|
||||
{
|
||||
public OPCItemIO ( final IJIComObject opcItemIO ) throws IllegalArgumentException, UnknownHostException, JIException
|
||||
{
|
||||
super ( opcItemIO.queryInterface ( Constants.IOPCItemIO_IID ) );
|
||||
}
|
||||
|
||||
public void read ( final IORequest[] requests ) throws JIException
|
||||
{
|
||||
if ( requests.length == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 0 );
|
||||
|
||||
JIString itemIDs[] = new JIString[requests.length];
|
||||
Integer maxAges[] = new Integer[requests.length];
|
||||
for ( int i = 0; i < requests.length; i++ )
|
||||
{
|
||||
itemIDs[i] = new JIString ( requests[i].getItemID (), JIFlags.FLAG_REPRESENTATION_STRING_LPWSTR );
|
||||
maxAges[i] = new Integer ( requests[i].getMaxAge () );
|
||||
}
|
||||
|
||||
callObject.addInParamAsInt ( requests.length, JIFlags.FLAG_NULL );
|
||||
callObject.addInParamAsArray ( new JIArray ( itemIDs, true ), JIFlags.FLAG_NULL );
|
||||
callObject.addInParamAsArray ( new JIArray ( maxAges, true ), JIFlags.FLAG_NULL );
|
||||
|
||||
callObject.addOutParamAsObject ( new JIPointer ( new JIArray ( JIVariant.class, null, 1, true ) ), JIFlags.FLAG_NULL );
|
||||
callObject.addOutParamAsObject ( new JIPointer ( new JIArray ( Integer.class, null, 1, true ) ), JIFlags.FLAG_NULL );
|
||||
callObject.addOutParamAsObject ( new JIPointer ( new JIArray ( FILETIME.getStruct (), null, 1, true ) ), JIFlags.FLAG_NULL );
|
||||
callObject.addOutParamAsObject ( new JIPointer ( new JIArray ( Integer.class, null, 1, true ) ), JIFlags.FLAG_NULL );
|
||||
|
||||
getCOMObject ().call ( callObject );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2012 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.da.impl;
|
||||
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.jinterop.dcom.core.IJIComObject;
|
||||
import org.jinterop.dcom.core.JIArray;
|
||||
import org.jinterop.dcom.core.JICallBuilder;
|
||||
import org.jinterop.dcom.core.JIFlags;
|
||||
import org.jinterop.dcom.core.JIPointer;
|
||||
import org.jinterop.dcom.core.JIStruct;
|
||||
import org.openscada.opc.dcom.common.KeyedResult;
|
||||
import org.openscada.opc.dcom.common.KeyedResultSet;
|
||||
import org.openscada.opc.dcom.common.Result;
|
||||
import org.openscada.opc.dcom.common.ResultSet;
|
||||
import org.openscada.opc.dcom.common.impl.BaseCOMObject;
|
||||
import org.openscada.opc.dcom.common.impl.Helper;
|
||||
import org.openscada.opc.dcom.da.Constants;
|
||||
import org.openscada.opc.dcom.da.OPCITEMDEF;
|
||||
import org.openscada.opc.dcom.da.OPCITEMRESULT;
|
||||
|
||||
public class OPCItemMgt extends BaseCOMObject
|
||||
{
|
||||
public OPCItemMgt ( final IJIComObject opcGroup ) throws JIException
|
||||
{
|
||||
super ( opcGroup.queryInterface ( Constants.IOPCItemMgt_IID ) );
|
||||
}
|
||||
|
||||
public KeyedResultSet<OPCITEMDEF, OPCITEMRESULT> validate ( final OPCITEMDEF... items ) throws JIException
|
||||
{
|
||||
if ( items.length == 0 )
|
||||
{
|
||||
return new KeyedResultSet<OPCITEMDEF, OPCITEMRESULT> ();
|
||||
}
|
||||
|
||||
final JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 1 );
|
||||
|
||||
final JIStruct struct[] = new JIStruct[items.length];
|
||||
for ( int i = 0; i < items.length; i++ )
|
||||
{
|
||||
struct[i] = items[i].toStruct ();
|
||||
}
|
||||
final JIArray itemArray = new JIArray ( struct, true );
|
||||
|
||||
callObject.addInParamAsInt ( items.length, JIFlags.FLAG_NULL );
|
||||
callObject.addInParamAsArray ( itemArray, JIFlags.FLAG_NULL );
|
||||
callObject.addInParamAsInt ( 0, JIFlags.FLAG_NULL ); // don't update blobs
|
||||
callObject.addOutParamAsObject ( new JIPointer ( new JIArray ( OPCITEMRESULT.getStruct (), null, 1, true ) ), JIFlags.FLAG_NULL );
|
||||
callObject.addOutParamAsObject ( new JIPointer ( new JIArray ( Integer.class, null, 1, true ) ), JIFlags.FLAG_NULL );
|
||||
|
||||
final Object result[] = Helper.callRespectSFALSE ( getCOMObject (), callObject );
|
||||
|
||||
final JIStruct[] results = (JIStruct[]) ( (JIArray) ( (JIPointer)result[0] ).getReferent () ).getArrayInstance ();
|
||||
final Integer[] errorCodes = (Integer[]) ( (JIArray) ( (JIPointer)result[1] ).getReferent () ).getArrayInstance ();
|
||||
|
||||
final KeyedResultSet<OPCITEMDEF, OPCITEMRESULT> resultList = new KeyedResultSet<OPCITEMDEF, OPCITEMRESULT> ( items.length );
|
||||
for ( int i = 0; i < items.length; i++ )
|
||||
{
|
||||
final OPCITEMRESULT itemResult = OPCITEMRESULT.fromStruct ( results[i] );
|
||||
final KeyedResult<OPCITEMDEF, OPCITEMRESULT> resultEntry = new KeyedResult<OPCITEMDEF, OPCITEMRESULT> ( items[i], itemResult, errorCodes[i] );
|
||||
resultList.add ( resultEntry );
|
||||
}
|
||||
|
||||
return resultList;
|
||||
}
|
||||
|
||||
public KeyedResultSet<OPCITEMDEF, OPCITEMRESULT> add ( final OPCITEMDEF... items ) throws JIException
|
||||
{
|
||||
if ( items.length == 0 )
|
||||
{
|
||||
return new KeyedResultSet<OPCITEMDEF, OPCITEMRESULT> ();
|
||||
}
|
||||
|
||||
final JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 0 );
|
||||
|
||||
final JIStruct struct[] = new JIStruct[items.length];
|
||||
for ( int i = 0; i < items.length; i++ )
|
||||
{
|
||||
struct[i] = items[i].toStruct ();
|
||||
}
|
||||
final JIArray itemArray = new JIArray ( struct, true );
|
||||
|
||||
callObject.addInParamAsInt ( items.length, JIFlags.FLAG_NULL );
|
||||
callObject.addInParamAsArray ( itemArray, JIFlags.FLAG_NULL );
|
||||
|
||||
/*
|
||||
callObject.addOutParamAsObject ( new JIPointer ( new JIArray ( OPCITEMRESULT.getStruct (), null, 1, true ) ),
|
||||
JIFlags.FLAG_NULL );
|
||||
callObject.addOutParamAsObject ( new JIPointer ( new JIArray ( Integer.class, null, 1, true ) ),
|
||||
JIFlags.FLAG_NULL );
|
||||
*/
|
||||
callObject.addOutParamAsObject ( new JIPointer ( new JIArray ( OPCITEMRESULT.getStruct (), null, 1, true ) ), JIFlags.FLAG_NULL );
|
||||
callObject.addOutParamAsObject ( new JIPointer ( new JIArray ( Integer.class, null, 1, true ) ), JIFlags.FLAG_NULL );
|
||||
|
||||
final Object result[] = Helper.callRespectSFALSE ( getCOMObject (), callObject );
|
||||
|
||||
final JIStruct[] results = (JIStruct[]) ( (JIArray) ( (JIPointer)result[0] ).getReferent () ).getArrayInstance ();
|
||||
final Integer[] errorCodes = (Integer[]) ( (JIArray) ( (JIPointer)result[1] ).getReferent () ).getArrayInstance ();
|
||||
|
||||
final KeyedResultSet<OPCITEMDEF, OPCITEMRESULT> resultList = new KeyedResultSet<OPCITEMDEF, OPCITEMRESULT> ( items.length );
|
||||
for ( int i = 0; i < items.length; i++ )
|
||||
{
|
||||
final OPCITEMRESULT itemResult = OPCITEMRESULT.fromStruct ( results[i] );
|
||||
final KeyedResult<OPCITEMDEF, OPCITEMRESULT> resultEntry = new KeyedResult<OPCITEMDEF, OPCITEMRESULT> ( items[i], itemResult, errorCodes[i] );
|
||||
resultList.add ( resultEntry );
|
||||
}
|
||||
|
||||
return resultList;
|
||||
}
|
||||
|
||||
public ResultSet<Integer> remove ( final Integer... serverHandles ) throws JIException
|
||||
{
|
||||
if ( serverHandles.length == 0 )
|
||||
{
|
||||
return new ResultSet<Integer> ();
|
||||
}
|
||||
|
||||
final JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 2 );
|
||||
|
||||
callObject.addInParamAsInt ( serverHandles.length, JIFlags.FLAG_NULL );
|
||||
callObject.addInParamAsArray ( new JIArray ( serverHandles, true ), JIFlags.FLAG_NULL );
|
||||
callObject.addOutParamAsObject ( new JIPointer ( new JIArray ( Integer.class, null, 1, true ) ), JIFlags.FLAG_NULL );
|
||||
|
||||
final Object result[] = Helper.callRespectSFALSE ( getCOMObject (), callObject );
|
||||
|
||||
final Integer[] errorCodes = (Integer[]) ( (JIArray) ( (JIPointer)result[0] ).getReferent () ).getArrayInstance ();
|
||||
final ResultSet<Integer> results = new ResultSet<Integer> ( serverHandles.length );
|
||||
for ( int i = 0; i < serverHandles.length; i++ )
|
||||
{
|
||||
results.add ( new Result<Integer> ( serverHandles[i], errorCodes[i] ) );
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
public ResultSet<Integer> setActiveState ( final boolean state, final Integer... items ) throws JIException
|
||||
{
|
||||
if ( items.length == 0 )
|
||||
{
|
||||
return new ResultSet<Integer> ();
|
||||
}
|
||||
|
||||
final JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 3 );
|
||||
|
||||
callObject.addInParamAsInt ( items.length, JIFlags.FLAG_NULL );
|
||||
callObject.addInParamAsArray ( new JIArray ( items, true ), JIFlags.FLAG_NULL );
|
||||
callObject.addInParamAsInt ( state ? 1 : 0, JIFlags.FLAG_NULL );
|
||||
callObject.addOutParamAsObject ( new JIPointer ( new JIArray ( Integer.class, null, 1, true ) ), JIFlags.FLAG_NULL );
|
||||
|
||||
final Object[] result = Helper.callRespectSFALSE ( getCOMObject (), callObject );
|
||||
|
||||
final Integer[] errorCodes = (Integer[]) ( (JIArray) ( (JIPointer)result[0] ).getReferent () ).getArrayInstance ();
|
||||
final ResultSet<Integer> results = new ResultSet<Integer> ( items.length );
|
||||
for ( int i = 0; i < items.length; i++ )
|
||||
{
|
||||
results.add ( new Result<Integer> ( items[i], errorCodes[i] ) );
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
public ResultSet<Integer> setClientHandles ( final Integer[] serverHandles, final Integer[] clientHandles ) throws JIException
|
||||
{
|
||||
if ( serverHandles.length != clientHandles.length )
|
||||
{
|
||||
throw new JIException ( 0, "Array sizes don't match" );
|
||||
}
|
||||
if ( serverHandles.length == 0 )
|
||||
{
|
||||
return new ResultSet<Integer> ();
|
||||
}
|
||||
|
||||
final JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 4 );
|
||||
|
||||
callObject.addInParamAsInt ( serverHandles.length, JIFlags.FLAG_NULL );
|
||||
callObject.addInParamAsArray ( new JIArray ( serverHandles, true ), JIFlags.FLAG_NULL );
|
||||
callObject.addInParamAsArray ( new JIArray ( clientHandles, true ), JIFlags.FLAG_NULL );
|
||||
callObject.addOutParamAsObject ( new JIPointer ( new JIArray ( Integer.class, null, 1, true ) ), JIFlags.FLAG_NULL );
|
||||
|
||||
final Object[] result = Helper.callRespectSFALSE ( getCOMObject (), callObject );
|
||||
|
||||
final Integer[] errorCodes = (Integer[]) ( (JIArray) ( (JIPointer)result[0] ).getReferent () ).getArrayInstance ();
|
||||
final ResultSet<Integer> results = new ResultSet<Integer> ( serverHandles.length );
|
||||
for ( int i = 0; i < serverHandles.length; i++ )
|
||||
{
|
||||
results.add ( new Result<Integer> ( serverHandles[i], errorCodes[i] ) );
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.da.impl;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.jinterop.dcom.core.IJIComObject;
|
||||
import org.jinterop.dcom.core.JIArray;
|
||||
import org.jinterop.dcom.core.JICallBuilder;
|
||||
import org.jinterop.dcom.core.JIFlags;
|
||||
import org.jinterop.dcom.core.JIPointer;
|
||||
import org.jinterop.dcom.core.JIString;
|
||||
import org.jinterop.dcom.core.JIVariant;
|
||||
import org.openscada.opc.dcom.common.KeyedResult;
|
||||
import org.openscada.opc.dcom.common.KeyedResultSet;
|
||||
import org.openscada.opc.dcom.common.impl.BaseCOMObject;
|
||||
import org.openscada.opc.dcom.common.impl.Helper;
|
||||
import org.openscada.opc.dcom.da.Constants;
|
||||
import org.openscada.opc.dcom.da.PropertyDescription;
|
||||
|
||||
public class OPCItemProperties extends BaseCOMObject
|
||||
{
|
||||
public OPCItemProperties ( final IJIComObject opcItemProperties ) throws IllegalArgumentException, UnknownHostException, JIException
|
||||
{
|
||||
super ( opcItemProperties.queryInterface ( Constants.IOPCItemProperties_IID ) );
|
||||
}
|
||||
|
||||
public Collection<PropertyDescription> queryAvailableProperties ( final String itemID ) throws JIException
|
||||
{
|
||||
JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 0 );
|
||||
|
||||
callObject.addInParamAsString ( itemID, JIFlags.FLAG_REPRESENTATION_STRING_LPWSTR );
|
||||
|
||||
callObject.addOutParamAsType ( Integer.class, JIFlags.FLAG_NULL );
|
||||
|
||||
callObject.addOutParamAsObject ( new JIPointer ( new JIArray ( Integer.class, null, 1, true ) ), JIFlags.FLAG_NULL );
|
||||
callObject.addOutParamAsObject ( new JIPointer ( new JIArray ( new JIString ( JIFlags.FLAG_REPRESENTATION_STRING_BSTR ), null, 1, true ) ), JIFlags.FLAG_NULL );
|
||||
callObject.addOutParamAsObject ( new JIPointer ( new JIArray ( Short.class, null, 1, true ) ), JIFlags.FLAG_NULL );
|
||||
|
||||
Object result[] = getCOMObject ().call ( callObject );
|
||||
|
||||
List<PropertyDescription> properties = new LinkedList<PropertyDescription> ();
|
||||
|
||||
int len = (Integer)result[0];
|
||||
Integer[] ids = (Integer[]) ( (JIArray) ( (JIPointer)result[1] ).getReferent () ).getArrayInstance ();
|
||||
JIString[] descriptions = (JIString[]) ( (JIArray) ( (JIPointer)result[2] ).getReferent () ).getArrayInstance ();
|
||||
Short[] variableTypes = (Short[]) ( (JIArray) ( (JIPointer)result[3] ).getReferent () ).getArrayInstance ();
|
||||
|
||||
for ( int i = 0; i < len; i++ )
|
||||
{
|
||||
PropertyDescription pd = new PropertyDescription ();
|
||||
pd.setId ( ids[i] );
|
||||
pd.setDescription ( descriptions[i].getString () );
|
||||
pd.setVarType ( variableTypes[i] );
|
||||
properties.add ( pd );
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
|
||||
public KeyedResultSet<Integer, JIVariant> getItemProperties ( final String itemID, final int... properties ) throws JIException
|
||||
{
|
||||
if ( properties.length == 0 )
|
||||
{
|
||||
return new KeyedResultSet<Integer, JIVariant> ();
|
||||
}
|
||||
|
||||
Integer[] ids = new Integer[properties.length];
|
||||
for ( int i = 0; i < properties.length; i++ )
|
||||
{
|
||||
ids[i] = properties[i];
|
||||
}
|
||||
|
||||
JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 1 );
|
||||
|
||||
callObject.addInParamAsString ( itemID, JIFlags.FLAG_REPRESENTATION_STRING_LPWSTR );
|
||||
callObject.addInParamAsInt ( properties.length, JIFlags.FLAG_NULL );
|
||||
callObject.addInParamAsArray ( new JIArray ( ids, true ), JIFlags.FLAG_NULL );
|
||||
|
||||
callObject.addOutParamAsObject ( new JIPointer ( new JIArray ( JIVariant.class, null, 1, true ) ), JIFlags.FLAG_NULL );
|
||||
callObject.addOutParamAsObject ( new JIPointer ( new JIArray ( Integer.class, null, 1, true ) ), JIFlags.FLAG_NULL );
|
||||
|
||||
Object result[] = Helper.callRespectSFALSE ( getCOMObject (), callObject );
|
||||
|
||||
JIVariant[] values = (JIVariant[]) ( (JIArray) ( (JIPointer)result[0] ).getReferent () ).getArrayInstance ();
|
||||
Integer[] errorCodes = (Integer[]) ( (JIArray) ( (JIPointer)result[1] ).getReferent () ).getArrayInstance ();
|
||||
|
||||
KeyedResultSet<Integer, JIVariant> results = new KeyedResultSet<Integer, JIVariant> ();
|
||||
for ( int i = 0; i < properties.length; i++ )
|
||||
{
|
||||
results.add ( new KeyedResult<Integer, JIVariant> ( properties[i], values[i], errorCodes[i] ) );
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
public KeyedResultSet<Integer, String> lookupItemIDs ( final String itemID, final int... properties ) throws JIException
|
||||
{
|
||||
if ( properties.length == 0 )
|
||||
{
|
||||
return new KeyedResultSet<Integer, String> ();
|
||||
}
|
||||
|
||||
Integer[] ids = new Integer[properties.length];
|
||||
for ( int i = 0; i < properties.length; i++ )
|
||||
{
|
||||
ids[i] = properties[i];
|
||||
}
|
||||
|
||||
JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 2 );
|
||||
|
||||
callObject.addInParamAsString ( itemID, JIFlags.FLAG_REPRESENTATION_STRING_LPWSTR );
|
||||
callObject.addInParamAsInt ( properties.length, JIFlags.FLAG_NULL );
|
||||
callObject.addInParamAsArray ( new JIArray ( ids, true ), JIFlags.FLAG_NULL );
|
||||
|
||||
callObject.addOutParamAsObject ( new JIPointer ( new JIArray ( new JIPointer ( new JIString ( JIFlags.FLAG_REPRESENTATION_STRING_LPWSTR ) ), null, 1, true ) ), JIFlags.FLAG_NULL );
|
||||
callObject.addOutParamAsObject ( new JIPointer ( new JIArray ( Integer.class, null, 1, true ) ), JIFlags.FLAG_NULL );
|
||||
|
||||
Object result[] = Helper.callRespectSFALSE ( getCOMObject (), callObject );
|
||||
|
||||
JIPointer[] itemIDs = (JIPointer[]) ( (JIArray) ( (JIPointer)result[0] ).getReferent () ).getArrayInstance ();
|
||||
Integer[] errorCodes = (Integer[]) ( (JIArray) ( (JIPointer)result[1] ).getReferent () ).getArrayInstance ();
|
||||
|
||||
KeyedResultSet<Integer, String> results = new KeyedResultSet<Integer, String> ();
|
||||
|
||||
for ( int i = 0; i < properties.length; i++ )
|
||||
{
|
||||
results.add ( new KeyedResult<Integer, String> ( properties[i], ( (JIString)itemIDs[i].getReferent () ).getString (), errorCodes[i] ) );
|
||||
}
|
||||
return results;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,191 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.da.impl;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.jinterop.dcom.core.IJIComObject;
|
||||
import org.jinterop.dcom.core.JICallBuilder;
|
||||
import org.jinterop.dcom.core.JIFlags;
|
||||
import org.jinterop.dcom.core.JIPointer;
|
||||
import org.jinterop.dcom.core.JIStruct;
|
||||
import org.openscada.opc.dcom.common.impl.BaseCOMObject;
|
||||
import org.openscada.opc.dcom.common.impl.EnumString;
|
||||
import org.openscada.opc.dcom.common.impl.Helper;
|
||||
import org.openscada.opc.dcom.common.impl.OPCCommon;
|
||||
import org.openscada.opc.dcom.da.Constants;
|
||||
import org.openscada.opc.dcom.da.OPCENUMSCOPE;
|
||||
import org.openscada.opc.dcom.da.OPCSERVERSTATUS;
|
||||
|
||||
public class OPCServer extends BaseCOMObject
|
||||
{
|
||||
public OPCServer ( final IJIComObject opcServer ) throws IllegalArgumentException, UnknownHostException, JIException
|
||||
{
|
||||
super ( opcServer.queryInterface ( Constants.IOPCServer_IID ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the current server status
|
||||
* @return the current server status
|
||||
* @throws JIException
|
||||
*/
|
||||
public OPCSERVERSTATUS getStatus () throws JIException
|
||||
{
|
||||
JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 3 );
|
||||
|
||||
callObject.addOutParamAsObject ( new JIPointer ( OPCSERVERSTATUS.getStruct () ), JIFlags.FLAG_NULL );
|
||||
|
||||
Object[] result = getCOMObject ().call ( callObject );
|
||||
|
||||
return OPCSERVERSTATUS.fromStruct ( (JIStruct) ( (JIPointer)result[0] ).getReferent () );
|
||||
}
|
||||
|
||||
public OPCGroupStateMgt addGroup ( final String name, final boolean active, final int updateRate, final int clientHandle, final Integer timeBias, final Float percentDeadband, final int localeID ) throws JIException, IllegalArgumentException, UnknownHostException
|
||||
{
|
||||
JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 0 );
|
||||
|
||||
callObject.addInParamAsString ( name, JIFlags.FLAG_REPRESENTATION_STRING_LPWSTR );
|
||||
callObject.addInParamAsInt ( active ? 1 : 0, JIFlags.FLAG_NULL );
|
||||
callObject.addInParamAsInt ( updateRate, JIFlags.FLAG_NULL );
|
||||
callObject.addInParamAsInt ( clientHandle, JIFlags.FLAG_NULL );
|
||||
callObject.addInParamAsPointer ( new JIPointer ( timeBias ), JIFlags.FLAG_NULL );
|
||||
callObject.addInParamAsPointer ( new JIPointer ( percentDeadband ), JIFlags.FLAG_NULL );
|
||||
callObject.addInParamAsInt ( localeID, JIFlags.FLAG_NULL );
|
||||
callObject.addOutParamAsType ( Integer.class, JIFlags.FLAG_NULL );
|
||||
callObject.addOutParamAsType ( Integer.class, JIFlags.FLAG_NULL );
|
||||
callObject.addInParamAsUUID ( Constants.IOPCGroupStateMgt_IID, JIFlags.FLAG_NULL );
|
||||
callObject.addOutParamAsType ( IJIComObject.class, JIFlags.FLAG_NULL );
|
||||
|
||||
Object[] result = getCOMObject ().call ( callObject );
|
||||
|
||||
return new OPCGroupStateMgt ( (IJIComObject)result[2] );
|
||||
}
|
||||
|
||||
public void removeGroup ( final int serverHandle, final boolean force ) throws JIException
|
||||
{
|
||||
JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 4 );
|
||||
|
||||
callObject.addInParamAsInt ( serverHandle, JIFlags.FLAG_NULL );
|
||||
callObject.addInParamAsInt ( force ? 1 : 0, JIFlags.FLAG_NULL );
|
||||
|
||||
getCOMObject ().call ( callObject );
|
||||
}
|
||||
|
||||
public void removeGroup ( final OPCGroupStateMgt group, final boolean force ) throws JIException
|
||||
{
|
||||
removeGroup ( group.getState ().getServerHandle (), force );
|
||||
}
|
||||
|
||||
public OPCGroupStateMgt getGroupByName ( final String name ) throws JIException, IllegalArgumentException, UnknownHostException
|
||||
{
|
||||
JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 2 );
|
||||
|
||||
callObject.addInParamAsString ( name, JIFlags.FLAG_REPRESENTATION_STRING_LPWSTR );
|
||||
callObject.addInParamAsUUID ( Constants.IOPCGroupStateMgt_IID, JIFlags.FLAG_NULL );
|
||||
callObject.addOutParamAsType ( IJIComObject.class, JIFlags.FLAG_NULL );
|
||||
|
||||
Object[] result = getCOMObject ().call ( callObject );
|
||||
|
||||
return new OPCGroupStateMgt ( (IJIComObject)result[0] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the groups
|
||||
* @param scope The scope to get
|
||||
* @return A string enumerator with the groups
|
||||
* @throws JIException
|
||||
* @throws IllegalArgumentException
|
||||
* @throws UnknownHostException
|
||||
*/
|
||||
public EnumString getGroups ( final OPCENUMSCOPE scope ) throws JIException, IllegalArgumentException, UnknownHostException
|
||||
{
|
||||
JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 5 );
|
||||
|
||||
callObject.addInParamAsShort ( (short)scope.id (), JIFlags.FLAG_NULL );
|
||||
callObject.addInParamAsUUID ( org.openscada.opc.dcom.common.Constants.IEnumString_IID, JIFlags.FLAG_NULL );
|
||||
callObject.addOutParamAsType ( IJIComObject.class, JIFlags.FLAG_NULL );
|
||||
|
||||
Object[] result = Helper.callRespectSFALSE ( getCOMObject (), callObject );
|
||||
|
||||
return new EnumString ( (IJIComObject)result[0] );
|
||||
}
|
||||
|
||||
public OPCItemProperties getItemPropertiesService ()
|
||||
{
|
||||
try
|
||||
{
|
||||
return new OPCItemProperties ( getCOMObject () );
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public OPCItemIO getItemIOService ()
|
||||
{
|
||||
try
|
||||
{
|
||||
return new OPCItemIO ( getCOMObject () );
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the browser object (<code>IOPCBrowseServerAddressSpace</code>) from the server instance
|
||||
* @return the browser object
|
||||
*/
|
||||
public OPCBrowseServerAddressSpace getBrowser ()
|
||||
{
|
||||
try
|
||||
{
|
||||
return new OPCBrowseServerAddressSpace ( getCOMObject () );
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the common interface if supported
|
||||
* @return the common interface or <code>null</code> if it is not supported
|
||||
*/
|
||||
public OPCCommon getCommon ()
|
||||
{
|
||||
try
|
||||
{
|
||||
return new OPCCommon ( getCOMObject () );
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.da.impl;
|
||||
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.jinterop.dcom.core.IJIComObject;
|
||||
import org.jinterop.dcom.core.JIArray;
|
||||
import org.jinterop.dcom.core.JICallBuilder;
|
||||
import org.jinterop.dcom.core.JIFlags;
|
||||
import org.jinterop.dcom.core.JIPointer;
|
||||
import org.jinterop.dcom.core.JIStruct;
|
||||
import org.jinterop.dcom.core.JIVariant;
|
||||
import org.openscada.opc.dcom.common.KeyedResult;
|
||||
import org.openscada.opc.dcom.common.KeyedResultSet;
|
||||
import org.openscada.opc.dcom.common.Result;
|
||||
import org.openscada.opc.dcom.common.ResultSet;
|
||||
import org.openscada.opc.dcom.common.impl.BaseCOMObject;
|
||||
import org.openscada.opc.dcom.common.impl.Helper;
|
||||
import org.openscada.opc.dcom.da.Constants;
|
||||
import org.openscada.opc.dcom.da.OPCDATASOURCE;
|
||||
import org.openscada.opc.dcom.da.OPCITEMSTATE;
|
||||
import org.openscada.opc.dcom.da.WriteRequest;
|
||||
|
||||
public class OPCSyncIO extends BaseCOMObject
|
||||
{
|
||||
public OPCSyncIO ( final IJIComObject opcSyncIO ) throws JIException
|
||||
{
|
||||
super ( opcSyncIO.queryInterface ( Constants.IOPCSyncIO_IID ) );
|
||||
}
|
||||
|
||||
public KeyedResultSet<Integer, OPCITEMSTATE> read ( final OPCDATASOURCE source, final Integer... serverHandles ) throws JIException
|
||||
{
|
||||
if ( serverHandles == null || serverHandles.length == 0 )
|
||||
{
|
||||
return new KeyedResultSet<Integer, OPCITEMSTATE> ();
|
||||
}
|
||||
|
||||
JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 0 );
|
||||
|
||||
callObject.addInParamAsShort ( (short)source.id (), JIFlags.FLAG_NULL );
|
||||
callObject.addInParamAsInt ( serverHandles.length, JIFlags.FLAG_NULL );
|
||||
callObject.addInParamAsArray ( new JIArray ( serverHandles, true ), JIFlags.FLAG_NULL );
|
||||
|
||||
callObject.addOutParamAsObject ( new JIPointer ( new JIArray ( OPCITEMSTATE.getStruct (), null, 1, true ) ), JIFlags.FLAG_NULL );
|
||||
callObject.addOutParamAsObject ( new JIPointer ( new JIArray ( Integer.class, null, 1, true ) ), JIFlags.FLAG_NULL );
|
||||
|
||||
Object result[] = Helper.callRespectSFALSE ( getCOMObject (), callObject );
|
||||
|
||||
KeyedResultSet<Integer, OPCITEMSTATE> results = new KeyedResultSet<Integer, OPCITEMSTATE> ();
|
||||
JIStruct[] states = (JIStruct[]) ( (JIArray) ( (JIPointer)result[0] ).getReferent () ).getArrayInstance ();
|
||||
Integer[] errorCodes = (Integer[]) ( (JIArray) ( (JIPointer)result[1] ).getReferent () ).getArrayInstance ();
|
||||
|
||||
for ( int i = 0; i < serverHandles.length; i++ )
|
||||
{
|
||||
results.add ( new KeyedResult<Integer, OPCITEMSTATE> ( serverHandles[i], OPCITEMSTATE.fromStruct ( states[i] ), errorCodes[i] ) );
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
public ResultSet<WriteRequest> write ( final WriteRequest... requests ) throws JIException
|
||||
{
|
||||
if ( requests.length == 0 )
|
||||
{
|
||||
return new ResultSet<WriteRequest> ();
|
||||
}
|
||||
|
||||
Integer[] items = new Integer[requests.length];
|
||||
JIVariant[] values = new JIVariant[requests.length];
|
||||
for ( int i = 0; i < requests.length; i++ )
|
||||
{
|
||||
items[i] = requests[i].getServerHandle ();
|
||||
values[i] = Helper.fixVariant ( requests[i].getValue () );
|
||||
}
|
||||
|
||||
JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 1 );
|
||||
|
||||
callObject.addInParamAsInt ( requests.length, JIFlags.FLAG_NULL );
|
||||
callObject.addInParamAsArray ( new JIArray ( items, true ), JIFlags.FLAG_NULL );
|
||||
callObject.addInParamAsArray ( new JIArray ( values, true ), JIFlags.FLAG_NULL );
|
||||
callObject.addOutParamAsObject ( new JIPointer ( new JIArray ( Integer.class, null, 1, true ) ), JIFlags.FLAG_NULL );
|
||||
|
||||
Object result[] = Helper.callRespectSFALSE ( getCOMObject (), callObject );
|
||||
|
||||
Integer[] errorCodes = (Integer[]) ( (JIArray) ( (JIPointer)result[0] ).getReferent () ).getArrayInstance ();
|
||||
|
||||
ResultSet<WriteRequest> results = new ResultSet<WriteRequest> ();
|
||||
for ( int i = 0; i < requests.length; i++ )
|
||||
{
|
||||
results.add ( new Result<WriteRequest> ( requests[i], errorCodes[i] ) );
|
||||
}
|
||||
return results;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.list;
|
||||
|
||||
/**
|
||||
* Details about an OPC server class
|
||||
* @author Jens Reimann <jens.reimann@th4-systems.com>
|
||||
* @since 0.1.8
|
||||
*/
|
||||
public class ClassDetails
|
||||
{
|
||||
private String _clsId;
|
||||
|
||||
private String _progId;
|
||||
|
||||
private String _description;
|
||||
|
||||
public String getClsId ()
|
||||
{
|
||||
return this._clsId;
|
||||
}
|
||||
|
||||
public void setClsId ( final String clsId )
|
||||
{
|
||||
this._clsId = clsId;
|
||||
}
|
||||
|
||||
public String getDescription ()
|
||||
{
|
||||
return this._description;
|
||||
}
|
||||
|
||||
public void setDescription ( final String description )
|
||||
{
|
||||
this._description = description;
|
||||
}
|
||||
|
||||
public String getProgId ()
|
||||
{
|
||||
return this._progId;
|
||||
}
|
||||
|
||||
public void setProgId ( final String progId )
|
||||
{
|
||||
this._progId = progId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.list;
|
||||
|
||||
public interface Constants extends org.openscada.opc.dcom.common.Constants
|
||||
{
|
||||
public static final String IOPCServerList_IID = "13486D50-4821-11D2-A494-3CB306C10000";
|
||||
|
||||
public static final String OPCServerList_CLSID = "13486D51-4821-11D2-A494-3CB306C10000";
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* OpenSCADA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 3
|
||||
* only, as published by the Free Software Foundation.
|
||||
*
|
||||
* OpenSCADA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License version 3 for more details
|
||||
* (a copy is included in the LICENSE file that accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* version 3 along with OpenSCADA. If not, see
|
||||
* <http://opensource.org/licenses/lgpl-3.0.html> for a copy of the LGPLv3 License.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.dcom.list.impl;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.jinterop.dcom.core.IJIComObject;
|
||||
import org.jinterop.dcom.core.JIArray;
|
||||
import org.jinterop.dcom.core.JICallBuilder;
|
||||
import org.jinterop.dcom.core.JIClsid;
|
||||
import org.jinterop.dcom.core.JIFlags;
|
||||
import org.jinterop.dcom.core.JIPointer;
|
||||
import org.jinterop.dcom.core.JIString;
|
||||
import org.openscada.opc.dcom.common.impl.BaseCOMObject;
|
||||
import org.openscada.opc.dcom.common.impl.EnumGUID;
|
||||
import org.openscada.opc.dcom.common.impl.Helper;
|
||||
import org.openscada.opc.dcom.list.ClassDetails;
|
||||
import org.openscada.opc.dcom.list.Constants;
|
||||
|
||||
import rpc.core.UUID;
|
||||
|
||||
/**
|
||||
* This class implements the IOPCServerList (aka OPCEnum) service.
|
||||
* @author Jens Reimann <jens.reimann@th4-systems.com>
|
||||
*
|
||||
*/
|
||||
public class OPCServerList extends BaseCOMObject
|
||||
{
|
||||
public OPCServerList ( final IJIComObject listObject ) throws JIException
|
||||
{
|
||||
super ( listObject.queryInterface ( Constants.IOPCServerList_IID ) );
|
||||
}
|
||||
|
||||
public JIClsid getCLSIDFromProgID ( final String progId ) throws JIException
|
||||
{
|
||||
JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 2 );
|
||||
|
||||
callObject.addInParamAsString ( progId, JIFlags.FLAG_REPRESENTATION_STRING_LPWSTR );
|
||||
callObject.addOutParamAsType ( UUID.class, JIFlags.FLAG_NULL );
|
||||
|
||||
try
|
||||
{
|
||||
Object[] result = getCOMObject ().call ( callObject );
|
||||
return JIClsid.valueOf ( ( (UUID)result[0] ).toString () );
|
||||
}
|
||||
catch ( JIException e )
|
||||
{
|
||||
if ( e.getErrorCode () == 0x800401F3 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return details about a serve class
|
||||
* @param clsId A server class
|
||||
* @throws JIException
|
||||
*/
|
||||
public ClassDetails getClassDetails ( final JIClsid clsId ) throws JIException
|
||||
{
|
||||
if ( clsId == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 1 );
|
||||
|
||||
callObject.addInParamAsUUID ( clsId.getCLSID (), JIFlags.FLAG_NULL );
|
||||
|
||||
callObject.addOutParamAsObject ( new JIPointer ( new JIString ( JIFlags.FLAG_REPRESENTATION_STRING_LPWSTR ) ), JIFlags.FLAG_NULL );
|
||||
callObject.addOutParamAsObject ( new JIPointer ( new JIString ( JIFlags.FLAG_REPRESENTATION_STRING_LPWSTR ) ), JIFlags.FLAG_NULL );
|
||||
|
||||
Object[] result = Helper.callRespectSFALSE ( getCOMObject (), callObject );
|
||||
|
||||
ClassDetails cd = new ClassDetails ();
|
||||
cd.setClsId ( clsId.getCLSID () );
|
||||
cd.setProgId ( ( (JIString) ( (JIPointer)result[0] ).getReferent () ).getString () );
|
||||
cd.setDescription ( ( (JIString) ( (JIPointer)result[1] ).getReferent () ).getString () );
|
||||
|
||||
return cd;
|
||||
}
|
||||
|
||||
/*
|
||||
HRESULT EnumClassesOfCategories(
|
||||
[in] ULONG cImplemented,
|
||||
[in,size_is(cImplemented)] CATID rgcatidImpl[],
|
||||
[in] ULONG cRequired,
|
||||
[in,size_is(cRequired)] CATID rgcatidReq[],
|
||||
[out] IEnumGUID ** ppenumClsid
|
||||
);
|
||||
*/
|
||||
|
||||
public EnumGUID enumClassesOfCategories ( final String[] implemented, final String[] required ) throws IllegalArgumentException, UnknownHostException, JIException
|
||||
{
|
||||
UUID[] u1 = new UUID[implemented.length];
|
||||
UUID[] u2 = new UUID[required.length];
|
||||
|
||||
for ( int i = 0; i < implemented.length; i++ )
|
||||
{
|
||||
u1[i] = new UUID ( implemented[i] );
|
||||
}
|
||||
|
||||
for ( int i = 0; i < required.length; i++ )
|
||||
{
|
||||
u2[i] = new UUID ( required[i] );
|
||||
}
|
||||
|
||||
return enumClassesOfCategories ( u1, u2 );
|
||||
}
|
||||
|
||||
public EnumGUID enumClassesOfCategories ( final UUID[] implemented, final UUID[] required ) throws IllegalArgumentException, UnknownHostException, JIException
|
||||
{
|
||||
// ** CALL
|
||||
JICallBuilder callObject = new JICallBuilder ( true );
|
||||
callObject.setOpnum ( 0 );
|
||||
|
||||
// ** IN
|
||||
callObject.addInParamAsInt ( implemented.length, JIFlags.FLAG_NULL );
|
||||
if ( implemented.length == 0 )
|
||||
{
|
||||
callObject.addInParamAsPointer ( new JIPointer ( null ), JIFlags.FLAG_NULL );
|
||||
}
|
||||
else
|
||||
{
|
||||
callObject.addInParamAsArray ( new JIArray ( implemented, true ), JIFlags.FLAG_NULL );
|
||||
}
|
||||
|
||||
callObject.addInParamAsInt ( required.length, JIFlags.FLAG_NULL );
|
||||
if ( required.length == 0 )
|
||||
{
|
||||
callObject.addInParamAsPointer ( new JIPointer ( null ), JIFlags.FLAG_NULL );
|
||||
}
|
||||
else
|
||||
{
|
||||
callObject.addInParamAsArray ( new JIArray ( required, true ), JIFlags.FLAG_NULL );
|
||||
}
|
||||
|
||||
// ** OUT
|
||||
callObject.addOutParamAsType ( IJIComObject.class, JIFlags.FLAG_NULL );
|
||||
|
||||
// ** RESULT
|
||||
Object result[] = Helper.callRespectSFALSE ( getCOMObject (), callObject );
|
||||
|
||||
return new EnumGUID ( (IJIComObject)result[0] );
|
||||
}
|
||||
}
|
||||
13
org.openscada.opc.dcom/src/progIdVsClsidDB.properties
Normal file
13
org.openscada.opc.dcom/src/progIdVsClsidDB.properties
Normal file
@@ -0,0 +1,13 @@
|
||||
#progId Vs ClsidDB
|
||||
#Tue Nov 28 21:56:16 IST 2006
|
||||
Word.Application=000209ff-0000-0000-c000-000000000046
|
||||
TestCOM123.TestServer2=92a065a9-106a-4cc3-8d67-43e3a1e73df3
|
||||
SYSINFO.SysInfo=6fba474b-43ac-11ce-9a0e-00aa0062bb4c
|
||||
ADODB.Connection=00000514-0000-0010-8000-00aa006d2ea4
|
||||
TestJavaServer.TestServer2=617d5a31-a3bf-440f-a58f-1f57f6ac7527
|
||||
TestJavaServer.TestServer1=56bad610-0fcb-418a-b25e-174159a4adce
|
||||
InternetExplorer.Application=0002df01-0000-0000-c000-000000000046
|
||||
Excel.Application=00024500-0000-0000-c000-000000000046
|
||||
StdCollection.VBCollection=4b738074-ea47-11d2-b25a-00105a022091
|
||||
WbemScripting.SWbemLocator=76a64158-cb41-11d1-8b02-00600806d9b6
|
||||
PowerPoint.Application=91493441-5a91-11cf-8700-00aa0060263b
|
||||
15
org.openscada.opc.lib.test/.classpath
Normal file
15
org.openscada.opc.lib.test/.classpath
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
1
org.openscada.opc.lib.test/.gitignore
vendored
Normal file
1
org.openscada.opc.lib.test/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
bin/
|
||||
46
org.openscada.opc.lib.test/.project
Normal file
46
org.openscada.opc.lib.test/.project
Normal file
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>org.openscada.opc.lib.test</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.babel.editor.rbeBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.babel.editor.rbeNature</nature>
|
||||
<nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
165
org.openscada.opc.lib.test/LICENSE
Normal file
165
org.openscada.opc.lib.test/LICENSE
Normal file
@@ -0,0 +1,165 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
||||
37
org.openscada.opc.lib.test/pom.xml
Normal file
37
org.openscada.opc.lib.test/pom.xml
Normal file
@@ -0,0 +1,37 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.openscada.opc.lib.test</groupId>
|
||||
<artifactId>org.openscada.opc.lib.test</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<version>1.7.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.kohsuke.jinterop</groupId>
|
||||
<artifactId>j-interop</artifactId>
|
||||
<version>2.0.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openscada.opc.dcom</groupId>
|
||||
<artifactId>org.openscada.opc.dcom</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openscada.utgard</groupId>
|
||||
<artifactId>org.openscada.opc.lib</artifactId>
|
||||
<version>1.1.0.v20130529</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2009 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.lib;
|
||||
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.openscada.opc.lib.da.DataCallback;
|
||||
import org.openscada.opc.lib.da.Item;
|
||||
import org.openscada.opc.lib.da.ItemState;
|
||||
|
||||
public class DataCallbackDumper implements DataCallback
|
||||
{
|
||||
|
||||
public void changed ( final Item item, final ItemState itemState )
|
||||
{
|
||||
System.out.println ( String.format ( "Item: %s, Value: %s, Timestamp: %tc, Quality: %d", item.getId (), itemState.getValue (), itemState.getTimestamp (), itemState.getQuality () ) );
|
||||
|
||||
try
|
||||
{
|
||||
VariantDumper.dumpValue ( "\t", itemState.getValue () );
|
||||
}
|
||||
catch ( final JIException e )
|
||||
{
|
||||
e.printStackTrace ();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2009 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.lib;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.openscada.opc.lib.common.ConnectionInformation;
|
||||
import org.openscada.opc.lib.da.Group;
|
||||
import org.openscada.opc.lib.da.Item;
|
||||
import org.openscada.opc.lib.da.ItemState;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
import org.openscada.opc.lib.da.browser.Branch;
|
||||
import org.openscada.opc.lib.da.browser.Leaf;
|
||||
|
||||
public class OPCTest1
|
||||
{
|
||||
public static void dumpItemState ( final Item item, final ItemState state )
|
||||
{
|
||||
System.out.println ( String.format ( "Item: %s, Value: %s, Timestamp: %tc, Quality: %d", item.getId (), state.getValue (), state.getTimestamp (), state.getQuality () ) );
|
||||
}
|
||||
|
||||
public static void dumpTree ( final Branch branch, final int level )
|
||||
{
|
||||
final StringBuilder sb = new StringBuilder ();
|
||||
for ( int i = 0; i < level; i++ )
|
||||
{
|
||||
sb.append ( " " );
|
||||
}
|
||||
final String indent = sb.toString ();
|
||||
|
||||
for ( final Leaf leaf : branch.getLeaves () )
|
||||
{
|
||||
System.out.println ( indent + "Leaf: " + leaf.getName () + " [" + leaf.getItemId () + "]" );
|
||||
}
|
||||
for ( final Branch subBranch : branch.getBranches () )
|
||||
{
|
||||
System.out.println ( indent + "Branch: " + subBranch.getName () );
|
||||
dumpTree ( subBranch, level + 1 );
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings ( "unused" )
|
||||
public static void main ( final String[] args ) throws Throwable
|
||||
{
|
||||
// create connection information
|
||||
final ConnectionInformation ci = new ConnectionInformation ();
|
||||
ci.setHost ( args[0] );
|
||||
ci.setDomain ( args[1] );
|
||||
ci.setUser ( args[2] );
|
||||
ci.setPassword ( args[3] );
|
||||
ci.setClsid ( args[4] );
|
||||
|
||||
// create a new server
|
||||
final Server server = new Server ( ci, Executors.newSingleThreadScheduledExecutor () );
|
||||
try
|
||||
{
|
||||
// connect to server
|
||||
server.connect ();
|
||||
|
||||
// browse
|
||||
dumpTree ( server.getTreeBrowser ().browse (), 0 );
|
||||
|
||||
// add sync reader
|
||||
|
||||
// Add a new group
|
||||
Group group = server.addGroup ( "test" );
|
||||
// group is initially active ... just for demonstration
|
||||
group.setActive ( true );
|
||||
|
||||
// We already have our group ... just for demonstration
|
||||
group = server.findGroup ( "test" );
|
||||
|
||||
// Add a new item to the group
|
||||
final Item item = group.addItem ( "Saw-toothed Waves.Int2" );
|
||||
// Items are initially active ... just for demonstration
|
||||
item.setActive ( true );
|
||||
|
||||
// Add some more items ... including one that is already existing
|
||||
final Map<String, Item> items = group.addItems ( "Saw-toothed Waves.Int2", "Saw-toothed Waves.Int4" );
|
||||
|
||||
// sync-read some values
|
||||
for ( int i = 0; i < 10; i++ )
|
||||
{
|
||||
Thread.sleep ( 100 );
|
||||
dumpItemState ( item, item.read ( false ) );
|
||||
}
|
||||
}
|
||||
catch ( final JIException e )
|
||||
{
|
||||
System.out.println ( String.format ( "%08X: %s", e.getErrorCode (), server.getErrorMessage ( e.getErrorCode () ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2009 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.lib;
|
||||
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.openscada.opc.lib.common.ConnectionInformation;
|
||||
import org.openscada.opc.lib.da.AccessBase;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
import org.openscada.opc.lib.da.SyncAccess;
|
||||
|
||||
/**
|
||||
* Another test showing the "Access" interface with the SyncAccess implementation.
|
||||
* @author Jens Reimann <jens.reimann@th4-systems.com>
|
||||
*
|
||||
*/
|
||||
public class OPCTest2
|
||||
{
|
||||
public static void main ( final String[] args ) throws Throwable
|
||||
{
|
||||
// create connection information
|
||||
final ConnectionInformation ci = new ConnectionInformation ();
|
||||
ci.setHost ( args[0] );
|
||||
ci.setDomain ( args[1] );
|
||||
ci.setUser ( args[2] );
|
||||
ci.setPassword ( args[3] );
|
||||
ci.setClsid ( args[4] );
|
||||
|
||||
String itemId = "Saw-toothed Waves.Int2";
|
||||
if ( args.length >= 6 )
|
||||
{
|
||||
itemId = args[5];
|
||||
}
|
||||
|
||||
// create a new server
|
||||
final Server server = new Server ( ci, Executors.newSingleThreadScheduledExecutor () );
|
||||
try
|
||||
{
|
||||
// connect to server
|
||||
server.connect ();
|
||||
|
||||
// add sync access
|
||||
|
||||
final AccessBase access = new SyncAccess ( server, 100 );
|
||||
access.addItem ( itemId, new DataCallbackDumper () );
|
||||
|
||||
// start reading
|
||||
access.bind ();
|
||||
|
||||
// wait a little bit
|
||||
Thread.sleep ( 10 * 1000 );
|
||||
|
||||
// stop reading
|
||||
access.unbind ();
|
||||
}
|
||||
catch ( final JIException e )
|
||||
{
|
||||
System.out.println ( String.format ( "%08X: %s", e.getErrorCode (), server.getErrorMessage ( e.getErrorCode () ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2009 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.lib;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.openscada.opc.lib.common.ConnectionInformation;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
import org.openscada.opc.lib.da.browser.BaseBrowser;
|
||||
import org.openscada.opc.lib.da.browser.Branch;
|
||||
import org.openscada.opc.lib.da.browser.Leaf;
|
||||
import org.openscada.opc.lib.da.browser.TreeBrowser;
|
||||
|
||||
/**
|
||||
* Another test showing the browser interfaces
|
||||
* @author Jens Reimann <jens.reimann@th4-systems.com>
|
||||
*
|
||||
*/
|
||||
public class OPCTest3
|
||||
{
|
||||
|
||||
private static void dumpLeaf ( final String prefix, final Leaf leaf )
|
||||
{
|
||||
System.out.println ( prefix + "Leaf: " + leaf.getName () + " [" + leaf.getItemId () + "]" );
|
||||
}
|
||||
|
||||
private static void dumpBranch ( final String prefix, final Branch branch )
|
||||
{
|
||||
System.out.println ( prefix + "Branch: " + branch.getName () );
|
||||
}
|
||||
|
||||
public static void dumpTree ( final Branch branch, final int level )
|
||||
{
|
||||
final StringBuilder sb = new StringBuilder ();
|
||||
for ( int i = 0; i < level; i++ )
|
||||
{
|
||||
sb.append ( " " );
|
||||
}
|
||||
final String indent = sb.toString ();
|
||||
|
||||
for ( final Leaf leaf : branch.getLeaves () )
|
||||
{
|
||||
dumpLeaf ( indent, leaf );
|
||||
}
|
||||
for ( final Branch subBranch : branch.getBranches () )
|
||||
{
|
||||
dumpBranch ( indent, subBranch );
|
||||
dumpTree ( subBranch, level + 1 );
|
||||
}
|
||||
}
|
||||
|
||||
public static void main ( final String[] args ) throws Throwable
|
||||
{
|
||||
// create connection information
|
||||
final ConnectionInformation ci = new ConnectionInformation ();
|
||||
ci.setHost ( args[0] );
|
||||
ci.setDomain ( args[1] );
|
||||
ci.setUser ( args[2] );
|
||||
ci.setPassword ( args[3] );
|
||||
ci.setClsid ( args[4] );
|
||||
|
||||
// create a new server
|
||||
final Server server = new Server ( ci, Executors.newSingleThreadScheduledExecutor () );
|
||||
try
|
||||
{
|
||||
// connect to server
|
||||
server.connect ();
|
||||
|
||||
// browse flat
|
||||
final BaseBrowser flatBrowser = server.getFlatBrowser ();
|
||||
if ( flatBrowser != null )
|
||||
{
|
||||
for ( final String item : server.getFlatBrowser ().browse ( "" ) )
|
||||
{
|
||||
System.out.println ( item );
|
||||
}
|
||||
}
|
||||
|
||||
// browse tree
|
||||
final TreeBrowser treeBrowser = server.getTreeBrowser ();
|
||||
if ( treeBrowser != null )
|
||||
{
|
||||
dumpTree ( treeBrowser.browse (), 0 );
|
||||
}
|
||||
|
||||
// browse tree manually
|
||||
browseTree ( "", treeBrowser, new Branch () );
|
||||
}
|
||||
catch ( final JIException e )
|
||||
{
|
||||
e.printStackTrace ();
|
||||
System.out.println ( String.format ( "%08X: %s", e.getErrorCode (), server.getErrorMessage ( e.getErrorCode () ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
private static void browseTree ( final String prefix, final TreeBrowser treeBrowser, final Branch branch ) throws IllegalArgumentException, UnknownHostException, JIException
|
||||
{
|
||||
treeBrowser.fillLeaves ( branch );
|
||||
treeBrowser.fillBranches ( branch );
|
||||
|
||||
for ( final Leaf leaf : branch.getLeaves () )
|
||||
{
|
||||
dumpLeaf ( "M - " + prefix + " ", leaf );
|
||||
}
|
||||
for ( final Branch subBranch : branch.getBranches () )
|
||||
{
|
||||
dumpBranch ( "M - " + prefix + " ", subBranch );
|
||||
browseTree ( prefix + " ", treeBrowser, subBranch );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2009 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.lib;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.openscada.opc.lib.common.ConnectionInformation;
|
||||
import org.openscada.opc.lib.da.AccessBase;
|
||||
import org.openscada.opc.lib.da.Async20Access;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Another test showing the "Access" interface with the Async20Access implementation.
|
||||
* @author Jens Reimann <jens.reimann@th4-systems.com>
|
||||
*
|
||||
*/
|
||||
public class OPCTest4
|
||||
{
|
||||
private static Logger _log = LoggerFactory.getLogger ( OPCTest4.class );
|
||||
|
||||
public static void main ( final String[] args ) throws Throwable
|
||||
{
|
||||
// create connection information
|
||||
final ConnectionInformation ci = new ConnectionInformation ();
|
||||
ci.setHost ( args[0] );
|
||||
ci.setDomain ( args[1] );
|
||||
ci.setUser ( args[2] );
|
||||
ci.setPassword ( args[3] );
|
||||
ci.setClsid ( args[4] );
|
||||
|
||||
final Set<String> items = new HashSet<String> ();
|
||||
for ( int i = 5; i < args.length; i++ )
|
||||
{
|
||||
items.add ( args[i] );
|
||||
}
|
||||
if ( items.isEmpty () )
|
||||
{
|
||||
items.add ( "Saw-toothed Waves.Int2" );
|
||||
}
|
||||
|
||||
// create a new server
|
||||
final Server server = new Server ( ci, Executors.newSingleThreadScheduledExecutor () );
|
||||
try
|
||||
{
|
||||
// connect to server
|
||||
server.connect ();
|
||||
|
||||
// add sync access
|
||||
final AccessBase access = new Async20Access ( server, 100, false );
|
||||
for ( final String itemId : items )
|
||||
{
|
||||
access.addItem ( itemId, new DataCallbackDumper () );
|
||||
}
|
||||
|
||||
// start reading
|
||||
access.bind ();
|
||||
|
||||
// wait a little bit
|
||||
_log.info ( "Sleep for some seconds to give events a chance..." );
|
||||
Thread.sleep ( 10 * 1000 );
|
||||
_log.info ( "Returned from sleep" );
|
||||
|
||||
// stop reading
|
||||
access.unbind ();
|
||||
}
|
||||
catch ( final JIException e )
|
||||
{
|
||||
System.out.println ( String.format ( "%08X: %s", e.getErrorCode (), server.getErrorMessage ( e.getErrorCode () ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2009 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.lib;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.openscada.opc.lib.common.ConnectionInformation;
|
||||
import org.openscada.opc.lib.da.Async20Access;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
|
||||
/**
|
||||
* Another test showing the "Access" interface with
|
||||
* the Async20Access implementation. Testing two connections at the same time.
|
||||
*
|
||||
* @author Jens Reimann <jens.reimann@th4-systems.com>
|
||||
*/
|
||||
public class OPCTest5
|
||||
{
|
||||
public static void main ( final String[] args ) throws Throwable
|
||||
{
|
||||
// create connection information
|
||||
final ConnectionInformation baseInfo = new ConnectionInformation ();
|
||||
baseInfo.setHost ( args[0] );
|
||||
baseInfo.setDomain ( args[1] );
|
||||
baseInfo.setUser ( args[2] );
|
||||
baseInfo.setPassword ( args[3] );
|
||||
|
||||
final List<OPCTestInfo> testInfo = new LinkedList<OPCTestInfo> ();
|
||||
int i = 0;
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
while ( args.length > i * 2 + 4 )
|
||||
{
|
||||
final ConnectionInformation ci = new ConnectionInformation ( baseInfo );
|
||||
ci.setClsid ( args[i * 2 + 4] );
|
||||
final OPCTestInfo ti = new OPCTestInfo ();
|
||||
ti._info = ci;
|
||||
ti._itemId = args[i * 2 + 5];
|
||||
ti._server = new Server ( ci, Executors.newSingleThreadScheduledExecutor () );
|
||||
|
||||
ti._server.connect ();
|
||||
ti._access = new Async20Access ( ti._server, 100, false );
|
||||
ti._access.addItem ( ti._itemId, new DataCallbackDumper () );
|
||||
ti._access.bind ();
|
||||
|
||||
testInfo.add ( ti );
|
||||
i++;
|
||||
}
|
||||
|
||||
// wait a little bit
|
||||
Thread.sleep ( 10 * 1000 );
|
||||
}
|
||||
catch ( final JIException e )
|
||||
{
|
||||
System.out.println ( String.format ( "%08X", e.getErrorCode () ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2009 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.lib;
|
||||
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.openscada.opc.lib.common.ConnectionInformation;
|
||||
import org.openscada.opc.lib.da.AccessBase;
|
||||
import org.openscada.opc.lib.da.AutoReconnectController;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
import org.openscada.opc.lib.da.SyncAccess;
|
||||
|
||||
/**
|
||||
* Another test showing the "Access" interface with the SyncAccess implementation
|
||||
* including the AutoReconnectController which should re-establish the connection
|
||||
* if it breaks.
|
||||
* @author Jens Reimann <jens.reimann@th4-systems.com>
|
||||
*
|
||||
*/
|
||||
public class OPCTest6
|
||||
{
|
||||
public static void main ( final String[] args ) throws Throwable
|
||||
{
|
||||
// create connection information
|
||||
final ConnectionInformation ci = new ConnectionInformation ();
|
||||
ci.setHost ( args[0] );
|
||||
ci.setDomain ( args[1] );
|
||||
ci.setUser ( args[2] );
|
||||
ci.setPassword ( args[3] );
|
||||
ci.setClsid ( args[4] );
|
||||
|
||||
String itemId = "Saw-toothed Waves.Int2";
|
||||
if ( args.length >= 6 )
|
||||
{
|
||||
itemId = args[5];
|
||||
}
|
||||
|
||||
// create a new server
|
||||
final Server server = new Server ( ci, Executors.newSingleThreadScheduledExecutor () );
|
||||
final AutoReconnectController autoReconnectController = new AutoReconnectController ( server );
|
||||
try
|
||||
{
|
||||
// connect to server
|
||||
autoReconnectController.connect ();
|
||||
|
||||
// add sync access
|
||||
|
||||
final AccessBase access = new SyncAccess ( server, 100 );
|
||||
access.addItem ( itemId, new DataCallbackDumper () );
|
||||
|
||||
// start reading
|
||||
access.bind ();
|
||||
|
||||
// run forever
|
||||
final boolean running = true;
|
||||
while ( running )
|
||||
{
|
||||
Thread.sleep ( 10 * 1000 );
|
||||
}
|
||||
|
||||
/*
|
||||
// stop reading
|
||||
access.unbind ();
|
||||
|
||||
// disconnect
|
||||
autoReconnectController.disconnect ();
|
||||
*/
|
||||
}
|
||||
catch ( final JIException e )
|
||||
{
|
||||
System.out.println ( String.format ( "%08X: %s", e.getErrorCode (), server.getErrorMessage ( e.getErrorCode () ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2009 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.lib;
|
||||
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.jinterop.dcom.core.JIArray;
|
||||
import org.jinterop.dcom.core.JIFlags;
|
||||
import org.jinterop.dcom.core.JIString;
|
||||
import org.jinterop.dcom.core.JIVariant;
|
||||
import org.openscada.opc.lib.common.ConnectionInformation;
|
||||
import org.openscada.opc.lib.da.Group;
|
||||
import org.openscada.opc.lib.da.Item;
|
||||
import org.openscada.opc.lib.da.ItemState;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
|
||||
/**
|
||||
* A sample that reads an item and writes back the result. You will need a
|
||||
* read/write item for this to work.
|
||||
* @author Jens Reimann <jens.reimann@th4-systems.com>
|
||||
*
|
||||
*/
|
||||
public class OPCTest7
|
||||
{
|
||||
@SuppressWarnings ( "unused" )
|
||||
public static void main ( final String[] args ) throws Throwable
|
||||
{
|
||||
// create connection information
|
||||
final ConnectionInformation ci = new ConnectionInformation ();
|
||||
ci.setHost ( args[0] );
|
||||
ci.setDomain ( args[1] );
|
||||
ci.setUser ( args[2] );
|
||||
ci.setPassword ( args[3] );
|
||||
ci.setClsid ( args[4] );
|
||||
|
||||
final String itemName = args[5];
|
||||
|
||||
// create a new server
|
||||
final Server server = new Server ( ci, Executors.newSingleThreadScheduledExecutor () );
|
||||
try
|
||||
{
|
||||
// connect to server
|
||||
server.connect ();
|
||||
|
||||
// Add a new group
|
||||
final Group group = server.addGroup ( "test" );
|
||||
|
||||
// Add a new item to the group
|
||||
final Item item = group.addItem ( itemName );
|
||||
|
||||
final JIString[] sdata = new JIString[] { new JIString ( "ab", JIFlags.FLAG_REPRESENTATION_STRING_BSTR ), new JIString ( "cd", JIFlags.FLAG_REPRESENTATION_STRING_BSTR ), new JIString ( "ef", JIFlags.FLAG_REPRESENTATION_STRING_BSTR ) };
|
||||
final Double[] ddata = new Double[] { 1.1, 2.2, 3.3 };
|
||||
final Boolean[] bdata = new Boolean[] { true, false, true, false };
|
||||
final Integer[] idata = new Integer[] { 1202, 1203, 1204 };
|
||||
final Long[] ldata = new Long[] { 12020001L, 12030001L, 12040001L };
|
||||
final Float[] fdata = new Float[] { 1.1f, 1.2f, 1.3f };
|
||||
final Byte[] bydata = new Byte[] { 1, 2, 3 };
|
||||
final Character[] cdata = new Character[] { 'A', 'B', 'C' };
|
||||
|
||||
final JIArray array = new JIArray ( ddata, true );
|
||||
final JIVariant value = new JIVariant ( array );
|
||||
|
||||
System.out.println ( "============= PHASE 1 ============= " );
|
||||
|
||||
// dump the value
|
||||
VariantDumper.dumpValue ( value );
|
||||
|
||||
System.out.println ( "============= PHASE 2 ============= " );
|
||||
|
||||
// now write it to the item
|
||||
item.write ( value );
|
||||
Thread.sleep ( 2500 );
|
||||
|
||||
System.out.println ( "============= PHASE 3 ============= " );
|
||||
|
||||
// now read the value back and dump it
|
||||
final ItemState itemState = item.read ( true );
|
||||
VariantDumper.dumpValue ( itemState.getValue () );
|
||||
|
||||
System.out.println ( "============= PHASE 4 ============= " );
|
||||
|
||||
// and write the value just read in
|
||||
item.write ( itemState.getValue () );
|
||||
|
||||
System.out.println ( "============= COMPLETE ============= " );
|
||||
}
|
||||
catch ( final JIException e )
|
||||
{
|
||||
System.out.println ( String.format ( "%08X: %s", e.getErrorCode (), server.getErrorMessage ( e.getErrorCode () ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2009 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.lib;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.openscada.opc.dcom.list.ClassDetails;
|
||||
import org.openscada.opc.lib.list.Categories;
|
||||
import org.openscada.opc.lib.list.Category;
|
||||
import org.openscada.opc.lib.list.ServerList;
|
||||
|
||||
/**
|
||||
* A sample that queries the server browser interface
|
||||
* @author Jens Reimann <jens.reimann@th4-systems.com>
|
||||
*
|
||||
*/
|
||||
public class OPCTest8
|
||||
{
|
||||
protected static void showDetails ( final ServerList serverList, final String clsid ) throws JIException
|
||||
{
|
||||
final ClassDetails cd = serverList.getDetails ( clsid );
|
||||
if ( cd != null )
|
||||
{
|
||||
System.out.println ( cd.getProgId () + " = " + cd.getDescription () );
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println ( "unknown" );
|
||||
}
|
||||
}
|
||||
|
||||
public static void main ( final String[] args ) throws Throwable
|
||||
{
|
||||
final ServerList serverList = new ServerList ( args[0], args[2], args[3], args[1] );
|
||||
|
||||
final String cls = serverList.getClsIdFromProgId ( "Matrikon.OPC.Simulation.1" );
|
||||
System.out.println ( "Matrikon OPC Simulation Server: " + cls );
|
||||
showDetails ( serverList, cls );
|
||||
|
||||
final Collection<ClassDetails> detailsList = serverList.listServersWithDetails ( new Category[] { Categories.OPCDAServer20 }, new Category[] {} );
|
||||
|
||||
for ( final ClassDetails details : detailsList )
|
||||
{
|
||||
System.out.println ( String.format ( "Found: %s", details.getClsId () ) );
|
||||
System.out.println ( String.format ( "\tProgID: %s", details.getProgId () ) );
|
||||
System.out.println ( String.format ( "\tDescription: %s", details.getDescription () ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2009 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.lib;
|
||||
|
||||
import org.openscada.opc.lib.common.ConnectionInformation;
|
||||
import org.openscada.opc.lib.da.AccessBase;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
|
||||
class OPCTestInfo
|
||||
{
|
||||
ConnectionInformation _info = null;
|
||||
|
||||
String _itemId = null;
|
||||
|
||||
Server _server = null;
|
||||
|
||||
AccessBase _access = null;
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* This file is part of the OpenSCADA project
|
||||
* Copyright (C) 2006-2009 TH4 SYSTEMS GmbH (http://th4-systems.com)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
package org.openscada.opc.lib;
|
||||
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.jinterop.dcom.core.JIArray;
|
||||
import org.jinterop.dcom.core.JIFlags;
|
||||
import org.jinterop.dcom.core.JIString;
|
||||
import org.jinterop.dcom.core.JIVariant;
|
||||
|
||||
public class VariantDumper
|
||||
{
|
||||
|
||||
static protected void dumpArray ( final String prefix, final JIArray array ) throws JIException
|
||||
{
|
||||
System.out.println ( prefix + String.format ( "IsConformant: %s, IsVarying: %s", array.isConformant () ? "yes" : "no", array.isVarying () ? "yes" : "no" ) );
|
||||
System.out.println ( prefix + String.format ( "Dimensions: %d", array.getDimensions () ) );
|
||||
for ( int i = 0; i < array.getDimensions (); i++ )
|
||||
{
|
||||
System.out.println ( prefix + String.format ( "Dimension #%d: Upper Bound: %d", i, array.getUpperBounds ()[i] ) );
|
||||
}
|
||||
|
||||
final Object o = array.getArrayInstance ();
|
||||
System.out.println ( prefix + "Array Instance: " + o.getClass () );
|
||||
final Object[] a = (Object[])o;
|
||||
System.out.println ( prefix + "Array Size: " + a.length );
|
||||
|
||||
for ( final Object value : a )
|
||||
{
|
||||
dumpValue ( prefix + "\t", value );
|
||||
}
|
||||
}
|
||||
|
||||
static public void dumpValue ( final Object value ) throws JIException
|
||||
{
|
||||
dumpValue ( "", value );
|
||||
}
|
||||
|
||||
static protected void dumpValue ( final String prefix, final Object value ) throws JIException
|
||||
{
|
||||
if ( value instanceof JIVariant )
|
||||
{
|
||||
System.out.println ( prefix + "JIVariant" );
|
||||
final JIVariant variant = (JIVariant)value;
|
||||
System.out.println ( prefix + String.format ( "IsArray: %s, IsByRef: %s, IsNull: %s", variant.isArray () ? "yes" : "no", variant.isByRefFlagSet () ? "yes" : "no", variant.isNull () ? "yes" : "no" ) );
|
||||
|
||||
if ( variant.isArray () )
|
||||
{
|
||||
dumpArray ( prefix, variant.getObjectAsArray () );
|
||||
}
|
||||
else
|
||||
{
|
||||
dumpValue ( prefix + "\t", variant.getObject () );
|
||||
}
|
||||
}
|
||||
else if ( value instanceof JIString )
|
||||
{
|
||||
final JIString string = (JIString)value;
|
||||
|
||||
String strType;
|
||||
switch ( string.getType () )
|
||||
{
|
||||
case JIFlags.FLAG_REPRESENTATION_STRING_BSTR:
|
||||
strType = "BSTR";
|
||||
break;
|
||||
case JIFlags.FLAG_REPRESENTATION_STRING_LPCTSTR:
|
||||
strType = "LPCSTR";
|
||||
break;
|
||||
case JIFlags.FLAG_REPRESENTATION_STRING_LPWSTR:
|
||||
strType = "LPWSTR";
|
||||
break;
|
||||
default:
|
||||
strType = "unknown";
|
||||
break;
|
||||
}
|
||||
System.out.println ( prefix + String.format ( "JIString: '%s' (%s)", string.getString (), strType ) );
|
||||
}
|
||||
else if ( value instanceof Double )
|
||||
{
|
||||
System.out.println ( prefix + "Double: " + value );
|
||||
}
|
||||
else if ( value instanceof Float )
|
||||
{
|
||||
System.out.println ( prefix + "Float: " + value );
|
||||
}
|
||||
else if ( value instanceof Byte )
|
||||
{
|
||||
System.out.println ( prefix + "Byte: " + value );
|
||||
}
|
||||
else if ( value instanceof Character )
|
||||
{
|
||||
System.out.println ( prefix + "Character: " + value );
|
||||
}
|
||||
else if ( value instanceof Integer )
|
||||
{
|
||||
System.out.println ( prefix + "Integer: " + value );
|
||||
}
|
||||
else if ( value instanceof Short )
|
||||
{
|
||||
System.out.println ( prefix + "Short: " + value );
|
||||
}
|
||||
else if ( value instanceof Long )
|
||||
{
|
||||
System.out.println ( prefix + "Long: " + value );
|
||||
}
|
||||
else if ( value instanceof Boolean )
|
||||
{
|
||||
System.out.println ( prefix + "Boolean: " + value );
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
System.out.println ( prefix + String.format ( "Unknown value type (%s): %s", value.getClass (), value.toString () ) );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
16
org.openscada.opc.lib/.classpath
Normal file
16
org.openscada.opc.lib/.classpath
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/org.openscada.opc.dcom"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
2
org.openscada.opc.lib/.gitignore
vendored
Normal file
2
org.openscada.opc.lib/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
bin/
|
||||
/target
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user