public override void Initialize(string file) { opcServer = new OPCServer(Name); Config.Configuration config = new Config.Configuration(file); opcServer.Connect(config.ProgID, config.ServerName);// opcServer.Connect(config.ConnectionString); OPCGroup group = opcServer.AddGroup(config.GroupName, config.UpdateRate); foreach (Config.ItemInfo item in config.Items) { group.AddItem(item.ItemName, item.OpcItemName, item.ClientHandler, item.IsActive); } opcServer.Groups.DefaultGroup.OnDataChanged += new OPCGroup.DataChangedEventHandler(DefaultGroup_OnDataChanged); }
public static List <string> GetServers() { List <string> serversList = new List <string>(); OPCServer OPCServer = new OPCServer(); Array servers = (Array)OPCServer.GetOPCServers(); foreach (string s in servers) { serversList.Add(s); } return(serversList); }
public Form1() { try { InitializeComponent(); OPCServerName = "{Here comes your OPC server’s name}"; ObjOPCServer = new OPCServer(); ObjOPCServer.Connect(OPCServerName, "";); ObjOPCGroups = ObjOPCServer.OPCGroups; ObjOPCGroup = ObjOPCGroups.Add("OPCGroup1"); ObjOPCGroup.DataChange += new DIOPCGroupEvent_DataChangeEventHandler(ObjOPCGroup_DataChange); ObjOPCGroup.OPCItems.AddItem("{tag name or address (like {plc name on server}!%mw0)}", 1); ObjOPCGroup.UpdateRate = 10; ObjOPCGroup.IsActive = true; ObjOPCGroup.IsSubscribed = true; } catch (Exception e){ MessageBox.Show(e.ToString()); } }
public Form1() { try { InitializeComponent(); OPCServerName = "{Here comes your OPC server’s name}"; ObjOPCServer = new OPCServer(); ObjOPCServer.Connect(OPCServerName, ""; ); ObjOPCGroups = ObjOPCServer.OPCGroups; ObjOPCGroup = ObjOPCGroups.Add("OPCGroup1"); ObjOPCGroup.DataChange += new DIOPCGroupEvent_DataChangeEventHandler(ObjOPCGroup_DataChange); ObjOPCGroup.OPCItems.AddItem("{tag name or address (like {plc name on server}!%mw0)}", 1); ObjOPCGroup.UpdateRate = 10; ObjOPCGroup.IsActive = true; ObjOPCGroup.IsSubscribed = true; } catch (Exception e) { MessageBox.Show(e.ToString()); } }
public Branch(String Name, OPCServer Server = null, Branch Parent = null) { this._Name = Name; this._Children = new List<Branch>(); this._Leafs = new List<Leaf>(); if (Parent != null) { this._HasParent = true; this._Parent = Parent; Parent.addChildren(this); this.DataChanged += Parent.Branch_DataChanged; } else { this._HasParent = false; this._Parent = null; } if (Server != null) { this._OPCGroup = Server.OPCGroups.Add(this._Name); this._OPCGroup.UpdateRate = 200; //ms this._OPCGroup.IsActive = true; //Grupo activo this._OPCGroup.IsSubscribed = false; this._HasOPCGroup = true; } else { this._HasOPCGroup = false; this._OPCGroup = null; } this._HasChildren = false; this._HasLeafs = false; }
public Branch(String Name, OPCServer Server = null, Branch Parent = null) { this._Name = Name; this._Children = new List <Branch>(); this._Leafs = new List <Leaf>(); if (Parent != null) { this._HasParent = true; this._Parent = Parent; Parent.addChildren(this); this.DataChanged += Parent.Branch_DataChanged; } else { this._HasParent = false; this._Parent = null; } if (Server != null) { this._OPCGroup = Server.OPCGroups.Add(this._Name); this._OPCGroup.UpdateRate = 200; //ms this._OPCGroup.IsActive = true; //Grupo activo this._OPCGroup.IsSubscribed = false; this._HasOPCGroup = true; } else { this._HasOPCGroup = false; this._OPCGroup = null; } this._HasChildren = false; this._HasLeafs = false; }
public static List<string> GetServers() { List<string> serversList = new List<string>(); OPCServer OPCServer = new OPCServer(); Array servers = (Array) OPCServer.GetOPCServers(); foreach(string s in servers) serversList.Add(s); return serversList; }
public OPCClient(string serverName) { this._serverName = serverName; this._OPCServer = new OPCServer(); }