mirror of
https://github.com/luoyan35714/OPC_Client.git
synced 2026-04-18 00:01:30 +08:00
change the encode from gbk to utf-8
This commit is contained in:
@@ -17,7 +17,7 @@ import org.openscada.opc.dcom.da.OPCSERVERSTATUS;
|
||||
import org.openscada.opc.dcom.da.impl.OPCServer;
|
||||
|
||||
/**
|
||||
* »ñÈ¡ServerµÄStatusÐÅÏ¢ ÖÐÎÄ
|
||||
* 获取Server的Status信息 中文
|
||||
*
|
||||
* @author Freud
|
||||
*
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.openscada.opc.dcom.da.impl.OPCBrowseServerAddressSpace;
|
||||
import org.openscada.opc.dcom.da.impl.OPCServer;
|
||||
|
||||
/**
|
||||
* 遍历OPC连接下的所有Group和Item
|
||||
* 遍历OPC连接下的所有Group和Item
|
||||
*
|
||||
* @author Freud
|
||||
*
|
||||
@@ -34,7 +34,7 @@ public class DCOMTest2 {
|
||||
JISystem.setAutoRegisteration(true);
|
||||
|
||||
/**
|
||||
* Session获取
|
||||
* Session获取
|
||||
*/
|
||||
JISession _session = JISession.createSession(
|
||||
getEntryValue(CONFIG_DOMAIN), getEntryValue(CONFIG_USERNAME),
|
||||
@@ -50,19 +50,19 @@ public class DCOMTest2 {
|
||||
final OPCBrowseServerAddressSpace serverBrowser = server.getBrowser();
|
||||
|
||||
/**
|
||||
* Flat形式获取所有Item信息
|
||||
* Flat形式获取所有Item信息
|
||||
*/
|
||||
browseFlat(serverBrowser);
|
||||
|
||||
/**
|
||||
* 获取所有的Group和Item信息
|
||||
* 获取所有的Group和Item信息
|
||||
*/
|
||||
browseTree(serverBrowser);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tree形式获取所有Group和Item的信息
|
||||
* Tree形式获取所有Group和Item的信息
|
||||
*/
|
||||
private static void browseTree(final OPCBrowseServerAddressSpace browser)
|
||||
throws IllegalArgumentException, UnknownHostException, JIException {
|
||||
@@ -108,7 +108,7 @@ public class DCOMTest2 {
|
||||
}
|
||||
|
||||
/**
|
||||
* Flat形式获取Item的信息
|
||||
* Flat形式获取Item的信息
|
||||
*/
|
||||
private static void browseFlat(final OPCBrowseServerAddressSpace browser)
|
||||
throws JIException, IllegalArgumentException, UnknownHostException {
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.openscada.opc.dcom.da.impl.OPCGroupStateMgt;
|
||||
import org.openscada.opc.dcom.da.impl.OPCServer;
|
||||
|
||||
/**
|
||||
* 通过Scope遍历OPC连接下的所有Group信息
|
||||
* 通过Scope遍历OPC连接下的所有Group信息
|
||||
*
|
||||
* @author Freud
|
||||
*
|
||||
@@ -31,7 +31,7 @@ public class DCOMTest3 {
|
||||
JISystem.setAutoRegisteration(true);
|
||||
|
||||
/**
|
||||
* Session获取
|
||||
* Session获取
|
||||
*/
|
||||
JISession _session = JISession.createSession(
|
||||
getEntryValue(CONFIG_DOMAIN), getEntryValue(CONFIG_USERNAME),
|
||||
@@ -46,7 +46,7 @@ public class DCOMTest3 {
|
||||
OPCServer server = new OPCServer(serverObject);
|
||||
|
||||
/**
|
||||
* 添加一个Group的信息
|
||||
* 添加一个Group的信息
|
||||
*/
|
||||
OPCGroupStateMgt group = server.addGroup("test", true, 100, 1234, 60,
|
||||
0.0f, 1033);
|
||||
@@ -60,7 +60,7 @@ public class DCOMTest3 {
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过Scope查找并遍历Groups的信息
|
||||
* 通过Scope查找并遍历Groups的信息
|
||||
*
|
||||
* @param server
|
||||
* @param scope
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.openscada.opc.dcom.da.impl.OPCServer;
|
||||
import org.openscada.opc.dcom.da.impl.OPCSyncIO;
|
||||
|
||||
/**
|
||||
* 同步读取Item
|
||||
* 同步读取Item
|
||||
*
|
||||
* @author Freud
|
||||
*
|
||||
@@ -45,7 +45,7 @@ public class DCOMTest4 {
|
||||
JISystem.setAutoRegisteration(true);
|
||||
|
||||
/**
|
||||
* Session获取
|
||||
* Session获取
|
||||
*/
|
||||
JISession _session = JISession.createSession(
|
||||
getEntryValue(CONFIG_DOMAIN), getEntryValue(CONFIG_USERNAME),
|
||||
@@ -60,7 +60,7 @@ public class DCOMTest4 {
|
||||
OPCServer server = new OPCServer(serverObject);
|
||||
|
||||
/**
|
||||
* 添加一个Group的信息
|
||||
* 添加一个Group的信息
|
||||
*/
|
||||
OPCGroupStateMgt group = server.addGroup("test", true, 100, 1234, 60,
|
||||
0.0f, 1033);
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.openscada.opc.dcom.da.impl.OPCItemProperties;
|
||||
import org.openscada.opc.dcom.da.impl.OPCServer;
|
||||
|
||||
/**
|
||||
* 获取指定Item的Properties
|
||||
* 获取指定Item的Properties
|
||||
*
|
||||
* @author Freud
|
||||
*
|
||||
@@ -38,7 +38,7 @@ public class DCOMTest5 {
|
||||
JISystem.setAutoRegisteration(true);
|
||||
|
||||
/**
|
||||
* Session获取
|
||||
* Session获取
|
||||
*/
|
||||
JISession _session = JISession.createSession(
|
||||
getEntryValue(CONFIG_DOMAIN), getEntryValue(CONFIG_USERNAME),
|
||||
@@ -53,7 +53,7 @@ public class DCOMTest5 {
|
||||
OPCServer server = new OPCServer(serverObject);
|
||||
|
||||
/**
|
||||
* 添加一个Group的信息
|
||||
* 添加一个Group的信息
|
||||
*/
|
||||
OPCGroupStateMgt group = server.addGroup("test", true, 100, 1234, 60,
|
||||
0.0f, 1033);
|
||||
|
||||
@@ -19,7 +19,7 @@ import org.openscada.opc.dcom.da.impl.OPCItemIO;
|
||||
import org.openscada.opc.dcom.da.impl.OPCServer;
|
||||
|
||||
/**
|
||||
* Query指定的Item
|
||||
* Query指定的Item
|
||||
*
|
||||
* @author Freud
|
||||
*
|
||||
@@ -30,7 +30,7 @@ public class DCOMTest6 {
|
||||
JISystem.setAutoRegisteration(true);
|
||||
|
||||
/**
|
||||
* Session获取
|
||||
* Session获取
|
||||
*/
|
||||
JISession _session = JISession.createSession(
|
||||
getEntryValue(CONFIG_DOMAIN), getEntryValue(CONFIG_USERNAME),
|
||||
@@ -45,7 +45,7 @@ public class DCOMTest6 {
|
||||
OPCServer server = new OPCServer(serverObject);
|
||||
|
||||
/**
|
||||
* 添加一个Group的信息
|
||||
* 添加一个Group的信息
|
||||
*/
|
||||
OPCGroupStateMgt group = server.addGroup("test", true, 100, 1234, 60,
|
||||
0.0f, 1033);
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.openscada.opc.dcom.da.impl.OPCItemMgt;
|
||||
import org.openscada.opc.dcom.da.impl.OPCServer;
|
||||
|
||||
/**
|
||||
* 异步读取Item
|
||||
* 异步读取Item
|
||||
*
|
||||
* @author Freud
|
||||
*
|
||||
@@ -46,7 +46,7 @@ public class DCOMTest7 {
|
||||
JISystem.setAutoRegisteration(true);
|
||||
|
||||
/**
|
||||
* Session获取
|
||||
* Session获取
|
||||
*/
|
||||
JISession _session = JISession.createSession(
|
||||
getEntryValue(CONFIG_DOMAIN), getEntryValue(CONFIG_USERNAME),
|
||||
@@ -61,7 +61,7 @@ public class DCOMTest7 {
|
||||
OPCServer server = new OPCServer(serverObject);
|
||||
|
||||
/**
|
||||
* 添加一个Group的信息
|
||||
* 添加一个Group的信息
|
||||
*/
|
||||
OPCGroupStateMgt group = server.addGroup("test", true, 100, 1234, 60,
|
||||
0.0f, 1033);
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.util.Properties;
|
||||
import org.openscada.opc.lib.common.ConnectionInformation;
|
||||
|
||||
/**
|
||||
* 配置文件工具类
|
||||
* 配置文件工具类
|
||||
*
|
||||
* @author Freud
|
||||
*
|
||||
@@ -26,7 +26,7 @@ public final class BaseConfiguration {
|
||||
private final static String CONFIG_FILE_NAME = "config.properties";
|
||||
|
||||
/**
|
||||
* 加载配置文件
|
||||
* 加载配置文件
|
||||
*/
|
||||
static {
|
||||
ci = new ConnectionInformation();
|
||||
@@ -40,7 +40,7 @@ public final class BaseConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过名字获得配置的值
|
||||
* 通过名字获得配置的值
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
@@ -50,7 +50,7 @@ public final class BaseConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得包含ClsId的连接信息
|
||||
* 获得包含ClsId的连接信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@@ -62,7 +62,7 @@ public final class BaseConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得包含ProgId的连接信息
|
||||
* 获得包含ProgId的连接信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@@ -74,7 +74,7 @@ public final class BaseConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得基础的连接信息
|
||||
* 获得基础的连接信息
|
||||
*/
|
||||
private static void getConnectionInfomation() {
|
||||
ci.setHost(prop.getProperty(CONFIG_HOST));
|
||||
|
||||
@@ -29,16 +29,16 @@ public class OPCTest2 {
|
||||
|
||||
server.connect();
|
||||
|
||||
/** 获得OPC连接下所有的Group和Item */
|
||||
/** 获得OPC连接下所有的Group和Item */
|
||||
dumpTree(server.getTreeBrowser().browse(), 0);
|
||||
/** 获得OPC下所有的Item */
|
||||
/** 获得OPC下所有的Item */
|
||||
dumpFlat(server.getFlatBrowser());
|
||||
|
||||
server.disconnect();
|
||||
}
|
||||
|
||||
/**
|
||||
* 遍历Flat结构的所有Item值
|
||||
* 遍历Flat结构的所有Item值
|
||||
*
|
||||
* @param browser
|
||||
* @throws IllegalArgumentException
|
||||
@@ -53,7 +53,7 @@ public class OPCTest2 {
|
||||
}
|
||||
|
||||
/**
|
||||
* 遍历Tree结构
|
||||
* 遍历Tree结构
|
||||
*
|
||||
* @param branch
|
||||
* @param level
|
||||
@@ -78,7 +78,7 @@ public class OPCTest2 {
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印Item
|
||||
* 打印Item
|
||||
*
|
||||
* @param leaf
|
||||
*/
|
||||
@@ -88,7 +88,7 @@ public class OPCTest2 {
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印Group
|
||||
* 打印Group
|
||||
*
|
||||
* @param branch
|
||||
*/
|
||||
|
||||
@@ -12,7 +12,7 @@ import org.openscada.opc.lib.da.Server;
|
||||
import com.freud.opc.utgard.BaseConfiguration;
|
||||
|
||||
/**
|
||||
* ͬ²½¶Áȡij¸öµãλµÄÖµ
|
||||
* 同步读取某个点位的值
|
||||
*
|
||||
* @author Freud
|
||||
*
|
||||
|
||||
@@ -12,17 +12,17 @@ import org.openscada.opc.lib.da.SyncAccess;
|
||||
import com.freud.opc.utgard.BaseConfiguration;
|
||||
|
||||
/**
|
||||
* 同步Access,读取某个点的变化值
|
||||
* 异步读取点位的信息,读取某个点的变化值
|
||||
*
|
||||
* @author Freud
|
||||
*
|
||||
*/
|
||||
public class OPCTest4 {
|
||||
|
||||
/** 间隔时间 */
|
||||
/** 间隔时间 */
|
||||
private static final int PERIOD = 100;
|
||||
|
||||
/** 休眠时间 */
|
||||
/** 休眠时间 */
|
||||
private static final int SLEEP = 2000;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
@@ -34,12 +34,12 @@ public class OPCTest4 {
|
||||
server.connect();
|
||||
|
||||
/**
|
||||
* 其中100单位为毫秒,为每次从OPC获取刷新的间隔时间
|
||||
* 其中100单位为毫秒,为每次从OPC获取刷新的间隔时间
|
||||
*/
|
||||
AccessBase access = new SyncAccess(server, PERIOD);
|
||||
|
||||
/**
|
||||
* 定时每隔间隔时间获取一次值
|
||||
* 定时每隔间隔时间获取一次值
|
||||
*/
|
||||
access.addItem("Random.Real5", new DataCallback() {
|
||||
private int i;
|
||||
@@ -50,12 +50,12 @@ public class OPCTest4 {
|
||||
}
|
||||
});
|
||||
|
||||
/** 开始监听 */
|
||||
/** 开始监听 */
|
||||
access.bind();
|
||||
|
||||
/** 当前线程休眠时间单位:毫秒 */
|
||||
/** 当前线程休眠时间单位:毫秒 */
|
||||
Thread.sleep(SLEEP);
|
||||
/** 监听 结束 */
|
||||
/** 监听 结束 */
|
||||
access.unbind();
|
||||
|
||||
server.dispose();
|
||||
|
||||
@@ -12,17 +12,17 @@ import org.openscada.opc.lib.da.Server;
|
||||
import com.freud.opc.utgard.BaseConfiguration;
|
||||
|
||||
/**
|
||||
* 异步Access,订阅读取点位的值,并且只有值有变化的时候才会触发CallBack函数
|
||||
* 异步Access,订阅读取点位的值,并且只有值有变化的时候才会触发CallBack函数
|
||||
*
|
||||
* @author Freud
|
||||
*
|
||||
*/
|
||||
public class OPCTest5 {
|
||||
|
||||
/** 间隔时间 */
|
||||
/** 间隔时间 */
|
||||
private static final int PERIOD = 100;
|
||||
|
||||
/** 休眠时间 */
|
||||
/** 休眠时间 */
|
||||
private static final int SLEEP = 2000;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
@@ -34,12 +34,12 @@ public class OPCTest5 {
|
||||
server.connect();
|
||||
|
||||
/**
|
||||
* 其中100单位为毫秒,为每次从OPC获取刷新的间隔时间
|
||||
* 其中100单位为毫秒,为每次从OPC获取刷新的间隔时间
|
||||
*/
|
||||
AccessBase access = new Async20Access(server, PERIOD, false);
|
||||
|
||||
/**
|
||||
* 只有Item的值有变化的时候才会触发CallBack函数
|
||||
* 只有Item的值有变化的时候才会触发CallBack函数
|
||||
*/
|
||||
access.addItem("Random.Real5", new DataCallback() {
|
||||
|
||||
@@ -51,12 +51,12 @@ public class OPCTest5 {
|
||||
}
|
||||
});
|
||||
|
||||
/** 开始监听 */
|
||||
/** 开始监听 */
|
||||
access.bind();
|
||||
|
||||
/** 当前线程休眠时间单位:毫秒 */
|
||||
/** 当前线程休眠时间单位:毫秒 */
|
||||
Thread.sleep(SLEEP);
|
||||
/** 监听 结束 */
|
||||
/** 监听 结束 */
|
||||
access.unbind();
|
||||
|
||||
server.dispose();
|
||||
|
||||
@@ -13,17 +13,17 @@ import org.openscada.opc.lib.da.SyncAccess;
|
||||
import com.freud.opc.utgard.BaseConfiguration;
|
||||
|
||||
/**
|
||||
* 如果Connection Break掉了,会自动重新连接
|
||||
* 如果Connection Break掉了,会自动重新连接
|
||||
*
|
||||
* @author Freud
|
||||
*
|
||||
*/
|
||||
public class OPCTest6 {
|
||||
|
||||
/** 间隔时间 */
|
||||
/** 间隔时间 */
|
||||
private static final int PERIOD = 100;
|
||||
|
||||
/** 休眠时间 */
|
||||
/** 休眠时间 */
|
||||
private static final int SLEEP = 2000;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
@@ -37,12 +37,12 @@ public class OPCTest6 {
|
||||
controller.connect();
|
||||
|
||||
/**
|
||||
* 其中100单位为毫秒,为每次从OPC获取刷新的间隔时间
|
||||
* 其中100单位为毫秒,为每次从OPC获取刷新的间隔时间
|
||||
*/
|
||||
AccessBase access = new SyncAccess(server, PERIOD);
|
||||
|
||||
/**
|
||||
* 定时每隔间隔时间获取一次值
|
||||
* 定时每隔间隔时间获取一次值
|
||||
*/
|
||||
access.addItem("Random.Real5", new DataCallback() {
|
||||
private int i;
|
||||
@@ -53,12 +53,12 @@ public class OPCTest6 {
|
||||
}
|
||||
});
|
||||
|
||||
/** 开始监听 */
|
||||
/** 开始监听 */
|
||||
access.bind();
|
||||
|
||||
/** 当前线程休眠时间单位:毫秒 */
|
||||
/** 当前线程休眠时间单位:毫秒 */
|
||||
Thread.sleep(SLEEP);
|
||||
/** 监听结束 */
|
||||
/** 监听结束 */
|
||||
access.unbind();
|
||||
|
||||
controller.disconnect();
|
||||
|
||||
@@ -12,7 +12,7 @@ import org.openscada.opc.lib.da.Server;
|
||||
import com.freud.opc.utgard.BaseConfiguration;
|
||||
|
||||
/**
|
||||
* 同步写入某个点位的值
|
||||
* 同步写入某个点位的值
|
||||
*
|
||||
* @author Freud
|
||||
*
|
||||
@@ -30,16 +30,16 @@ public class OPCTest7 {
|
||||
Group group = server.addGroup();
|
||||
Item item = group.addItem("Square Waves.Real4");
|
||||
|
||||
/** 构造写入数据 */
|
||||
/** 构造写入数据 */
|
||||
final Float[] integerData = new Float[] { 1202f, 1203f, 1204f };
|
||||
final JIArray array = new JIArray(integerData, false);
|
||||
final JIVariant value = new JIVariant(array);
|
||||
|
||||
/** 同步写入 */
|
||||
/** 同步写入 */
|
||||
item.write(value);
|
||||
Thread.sleep(2000);
|
||||
|
||||
/** Dump出item的值 */
|
||||
/** Dump出item的值 */
|
||||
dumpItem(item);
|
||||
|
||||
server.dispose();
|
||||
|
||||
@@ -11,7 +11,7 @@ import org.openscada.opc.lib.da.Server;
|
||||
import com.freud.opc.utgard.BaseConfiguration;
|
||||
|
||||
/**
|
||||
* 异步写入
|
||||
* 异步写入
|
||||
*
|
||||
* @author Freud
|
||||
*
|
||||
@@ -27,18 +27,18 @@ public class OPCTest8 {
|
||||
|
||||
server.connect();
|
||||
|
||||
/** 构造写入数据 */
|
||||
/** 构造写入数据 */
|
||||
final Float[] integerData = new Float[] { 1202f, 1203f, 1204f };
|
||||
final JIArray array = new JIArray(integerData, false);
|
||||
final JIVariant value = new JIVariant(array);
|
||||
|
||||
final Item item = server.addGroup().addItem("Square Waves.Real4");
|
||||
|
||||
/** 同步写入 */
|
||||
/** 同步写入 */
|
||||
item.write(value);
|
||||
Thread.sleep(2000);
|
||||
|
||||
/** Dump出item的值 */
|
||||
/** Dump出item的值 */
|
||||
dumpItem(item);
|
||||
|
||||
server.dispose();
|
||||
|
||||
Reference in New Issue
Block a user