日期:2014-05-17 浏览次数:21245 次
object HMIRuntime = null;
System.Type oType = System.Type.GetTypeFromProgID("CCHMIRuntime.HMIRuntime");
HMIRuntime = System.Activator.CreateInstance(oType);
System.Reflection.MethodInfo mi = oType.GetMethod("Tags");
object tags = mi.Invoke(HMIRuntime, new object[] { "@DatasourceNameRT" });
...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Opc;
using Opc.Da;
using OpcCom;
using System.IO;
namespace ConsoleApplication1
{
class Program
{
public static Opc.Da.Server m_server = null;//定义数据存取服务器
public static Opc.Da.Subscription subscription = null;//定义组对象(订阅者)
public static Opc.Da.SubscriptionState state = null;//定义组(订阅者)状态,相当于OPC规范中组的参数
public static Opc.IDiscovery m_discovery = new ServerEnumerator();//定义枚举基于COM服务器的接口,用来搜索所有的此类服务器。
static void Main(string[] args)
{
//StreamWriter dr = new StreamWriter(@"E:\test.txt",true, System.Text.Encoding.GetEncoding("GB2312"));
//string str = DateTime.Now.ToString();
//dr.WriteLine(str);
//dr.Flush();
//dr.Close();
//return;
StreamWriter dr = new StreamWriter(@"E:\system.log", true, System.Text.Encoding.GetEncoding("GB2312"));
try
{
Opc.Server[] servers = m_discovery.GetAvailableServers(Specification.COM_DA_20, "192.168.1.5", null);
if (servers != null)
{
foreach (Opc