想用C#读取wincc的变量 上边是VB中引用CCHMIRuntime 想知道在C#中怎么才能实现
æƒ?ç”?C#è??å•?winccçš„å??é‡? ä?‹è??æ??VBä??å??ç”?CCHMIRuntime æƒ?çŸ,é?“åœ?C#ä??å?‚ä??æ‰?èƒ?å??ç??
Dim HMIRuntime
Set HMIRuntime=CreateObject( CCHMIRuntime.HMIRuntime )
g_DataSourceName = HMIRuntime.Tags( @DatasourceNameRT ).Read
------è??å†?æ??æ?ˆ--------------------------------------------------------
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.Da.Server server in servers)