Exemple #1
0
 protected void AddItem(string itemName, OPCItem item)
 {
     this.dictItemName.Add(itemName, item);
 }
Exemple #2
0
 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;
 }
Exemple #3
0
 internal void Add(OPCItem item)
 {
     this.AddItem(item.ItemName, item);
     this.dictItemIndex.Add(item.ClientHandler, item);
 }
Exemple #4
0
 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;
 }