public virtual void OnDataChange(int dwTransid, int hGroup, int hrMasterquality, int hrMastererror, int dwCount, int[] phClientItems, object[] pvValues, short[] pwQualities, OpcRcw.Da.FILETIME[] pftTimeStamps, int[] pErrors) { for (int i = 0; i < dwCount; i++) { object[] objArray; OPCItem item = this.items[phClientItems[i]]; if (pvValues[i] is Array) { Array array = (Array)pvValues[i]; objArray = new object[array.Length]; for (int j = 0; j < array.Length; j++) { objArray[j] = array.GetValue(j); } } else { objArray = new object[] { pvValues[i] }; } if (this.OnDataChanged != null) { this.OnDataChanged(this, new DataChangedEventArgs(this.parent.ServerName, this.groupName, item.ItemName, objArray)); } } }
public OPCItem AddItem(string itemName, string opcItemName, int clientHandler, bool isActive) { OPCItem item = new OPCItem(this, itemName, opcItemName, clientHandler, isActive); this.AddItem(item); this.items.Add(item); return(item); }
public OPCItem this[string itemName] { get { OPCItem item = null; if (this.dictItemName.ContainsKey(itemName)) { item = this.dictItemName[itemName]; } return(item); } }
public OPCItem this[int clientHandler] { get { OPCItem item = null; if (this.dictItemIndex.ContainsKey(clientHandler)) { item = this.dictItemIndex[clientHandler]; } return(item); } }
private bool AddItem(OPCItem item) { bool flag = true; OPCITEMDEF[] pItemArray = new OPCITEMDEF[1]; pItemArray[0].szAccessPath = ""; pItemArray[0].szItemID = item.OPCItemName; pItemArray[0].bActive = item.IsActive ? 1 : 0; pItemArray[0].hClient = item.ClientHandler; pItemArray[0].dwBlobSize = 0; pItemArray[0].pBlob = IntPtr.Zero; pItemArray[0].vtRequestedDataType = 0; IntPtr zero = IntPtr.Zero; IntPtr ppErrors = IntPtr.Zero; try { ((IOPCItemMgt)this.group).AddItems(1, pItemArray, out zero, out ppErrors); int[] destination = new int[1]; Marshal.Copy(ppErrors, destination, 0, 1); if (destination[0] == 0) { OPCITEMRESULT opcitemresult = (OPCITEMRESULT)Marshal.PtrToStructure(zero, typeof(OPCITEMRESULT)); item.ServerHandler = opcitemresult.hServer; return(flag); } flag = false; throw new Exception("在组中添加项不成功,原因:" + this.parent.GetLastError(destination[0])); } finally { if (zero != IntPtr.Zero) { Marshal.FreeCoTaskMem(zero); zero = IntPtr.Zero; } if (ppErrors != IntPtr.Zero) { Marshal.FreeCoTaskMem(ppErrors); ppErrors = IntPtr.Zero; } } return(flag); }
protected void AddItem(string itemName, OPCItem item) { this.dictItemName.Add(itemName, item); }
internal void Add(OPCItem item) { this.AddItem(item.ItemName, item); this.dictItemIndex.Add(item.ClientHandler, item); }
private bool AddItem(OPCItem item) { bool flag = true; OPCITEMDEF[] pItemArray = new OPCITEMDEF[1]; pItemArray[0].szAccessPath = ""; pItemArray[0].szItemID = item.OPCItemName; pItemArray[0].bActive = item.IsActive ? 1 : 0; pItemArray[0].hClient = item.ClientHandler; pItemArray[0].dwBlobSize = 0; pItemArray[0].pBlob = IntPtr.Zero; pItemArray[0].vtRequestedDataType = 0; IntPtr zero = IntPtr.Zero; IntPtr ppErrors = IntPtr.Zero; try { ((IOPCItemMgt) this.group).AddItems(1, pItemArray, out zero, out ppErrors); int[] destination = new int[1]; Marshal.Copy(ppErrors, destination, 0, 1); if (destination[0] == 0) { OPCITEMRESULT opcitemresult = (OPCITEMRESULT) Marshal.PtrToStructure(zero, typeof(OPCITEMRESULT)); item.ServerHandler = opcitemresult.hServer; return flag; } flag = false; throw new Exception("在组中添加项不成功,原因:" + this.parent.GetLastError(destination[0])); } finally { if (zero != IntPtr.Zero) { Marshal.FreeCoTaskMem(zero); zero = IntPtr.Zero; } if (ppErrors != IntPtr.Zero) { Marshal.FreeCoTaskMem(ppErrors); ppErrors = IntPtr.Zero; } } return flag; }
public OPCItem AddItem(string itemName, string opcItemName, int clientHandler, bool isActive) { OPCItem item = new OPCItem(this, itemName, opcItemName, clientHandler, isActive); this.AddItem(item); this.items.Add(item); return item; }