Esempio n. 1
0
        /// <summary>
        /// Fetches the specified properties for an item.
        /// </summary>
        private Opc.Da.ItemProperty[] GetProperties(
            CacheItem item,
            PropertyID[] propertyIDs,
            bool returnValues)
        {
            // check for trivial case.
            if (item == null)
            {
                return(null);
            }

            // fetch properties.
            ItemPropertyCollection properties = null;

            if (propertyIDs == null)
            {
                properties = item.GetAvailableProperties(returnValues);
            }
            else
            {
                properties = item.GetAvailableProperties(propertyIDs, returnValues);
            }

            // convert collection to array.
            return((Opc.Da.ItemProperty[])properties.ToArray(typeof(Opc.Da.ItemProperty)));
        }
Esempio n. 2
0
 private void GetProperties(System.Windows.Forms.TreeNode node)
 {
     try
     {
         Opc.Da.Server server        = this.FindServer(node);
         BrowseElement browseElement = null;
         if (node.Tag != null && node.Tag.GetType() == typeof(BrowseElement))
         {
             browseElement = (BrowseElement)node.Tag;
         }
         if (browseElement.IsItem)
         {
             node.Nodes.Clear();
             ItemIdentifier           itemIdentifier = new ItemIdentifier(browseElement.ItemPath, browseElement.ItemName);
             ItemPropertyCollection[] properties     = server.GetProperties(new ItemIdentifier[]
             {
                 itemIdentifier
             }, this.m_filters.PropertyIDs, this.m_filters.ReturnPropertyValues);
             if (properties != null)
             {
                 ItemPropertyCollection[] array = properties;
                 for (int i = 0; i < array.Length; i++)
                 {
                     ItemPropertyCollection itemPropertyCollection = array[i];
                     foreach (ItemProperty property in itemPropertyCollection)
                     {
                         this.AddItemProperty(node, property);
                     }
                     browseElement.Properties = (ItemProperty[])itemPropertyCollection.ToArray(typeof(ItemProperty));
                 }
             }
             node.Expand();
             if (this.ElementSelected != null)
             {
                 this.ElementSelected(browseElement);
             }
         }
     }
     catch (System.Exception ex)
     {
         System.Windows.Forms.MessageBox.Show(ex.Message);
     }
 }