Example #1
0
        // Token: 0x0600035A RID: 858 RVA: 0x00009020 File Offset: 0x00008020
        public void GetDataFilterItem(Da.Server server)
        {
            this.m_filterItem = null;
            if (this.m_unfilteredItemID != null)
            {
                return;
            }
            BrowsePosition browsePosition = null;

            try
            {
                ItemIdentifier itemID        = new ItemIdentifier(this);
                BrowseFilters  browseFilters = new BrowseFilters();
                browseFilters.ElementNameFilter    = "DataFilters";
                browseFilters.BrowseFilter         = browseFilter.all;
                browseFilters.ReturnAllProperties  = false;
                browseFilters.PropertyIDs          = null;
                browseFilters.ReturnPropertyValues = false;
                BrowseElement[] array;
                if (this.m_unconvertedItemID == null)
                {
                    browseFilters.ElementNameFilter = "CPX";
                    array = server.Browse(itemID, browseFilters, out browsePosition);
                    if (array == null || array.Length == 0)
                    {
                        return;
                    }
                    if (browsePosition != null)
                    {
                        browsePosition.Dispose();
                        browsePosition = null;
                    }
                    itemID = new ItemIdentifier(array[0].ItemPath, array[0].ItemName);
                    browseFilters.ElementNameFilter = "DataFilters";
                }
                array = server.Browse(itemID, browseFilters, out browsePosition);
                if (array != null && array.Length != 0)
                {
                    this.m_filterItem = new ItemIdentifier(array[0].ItemPath, array[0].ItemName);
                }
            }
            finally
            {
                if (browsePosition != null)
                {
                    browsePosition.Dispose();
                    browsePosition = null;
                }
            }
        }
Example #2
0
 public void GetDataFilterItem(Opc.Da.Server server)
 {
     this.m_filterItem = null;
     if (this.m_unfilteredItemID == null)
     {
         BrowsePosition position = null;
         try
         {
             ItemIdentifier itemID  = new ItemIdentifier(this);
             BrowseFilters  filters = new BrowseFilters {
                 ElementNameFilter    = "DataFilters",
                 BrowseFilter         = browseFilter.all,
                 ReturnAllProperties  = false,
                 PropertyIDs          = null,
                 ReturnPropertyValues = false
             };
             BrowseElement[] elementArray = null;
             if (this.m_unconvertedItemID == null)
             {
                 filters.ElementNameFilter = "CPX";
                 elementArray = server.Browse(itemID, filters, out position);
                 if ((elementArray == null) || (elementArray.Length == 0))
                 {
                     return;
                 }
                 if (position != null)
                 {
                     position.Dispose();
                     position = null;
                 }
                 itemID = new ItemIdentifier(elementArray[0].ItemPath, elementArray[0].ItemName);
                 filters.ElementNameFilter = "DataFilters";
             }
             elementArray = server.Browse(itemID, filters, out position);
             if ((elementArray != null) && (elementArray.Length != 0))
             {
                 this.m_filterItem = new ItemIdentifier(elementArray[0].ItemPath, elementArray[0].ItemName);
             }
         }
         finally
         {
             if (position != null)
             {
                 position.Dispose();
                 position = null;
             }
         }
     }
 }
Example #3
0
        /// <summary>
        /// Fetches the set of data filters from the server.
        /// </summary>
        public ComplexItem[] GetDataFilters(Opc.Da.Server server)
        {
            // not a valid operation for data filter items.
            if (m_unfilteredItemID != null)
            {
                return(null);
            }

            // data filters not supported by the item.
            if (m_filterItem == null)
            {
                return(null);
            }

            BrowsePosition position = null;

            try
            {
                // browse any existing filter instances.
                BrowseFilters filters = new BrowseFilters();

                filters.ElementNameFilter    = null;
                filters.BrowseFilter         = browseFilter.item;
                filters.ReturnAllProperties  = false;
                filters.PropertyIDs          = CPX_PROPERTIES;
                filters.ReturnPropertyValues = true;

                BrowseElement[] elements = server.Browse(m_filterItem, filters, out position);

                // nothing found.
                if (elements == null || elements.Length == 0)
                {
                    return(new ComplexItem[0]);
                }

                // contruct an array of complex data items for each available data filter.
                ArrayList dataFilters = new ArrayList(elements.Length);

                foreach (BrowseElement element in elements)
                {
                    ComplexItem item = new ComplexItem();

                    if (item.Init(element))
                    {
                        dataFilters.Add(item);
                    }
                }

                // return the set of available data filters.
                return((ComplexItem[])dataFilters.ToArray(typeof(ComplexItem)));
            }
            finally
            {
                if (position != null)
                {
                    position.Dispose();
                    position = null;
                }
            }
        }
Example #4
0
        // Token: 0x06000355 RID: 853 RVA: 0x00008C14 File Offset: 0x00007C14
        public ComplexItem[] GetDataFilters(Da.Server server)
        {
            if (this.m_unfilteredItemID != null)
            {
                return(null);
            }
            if (this.m_filterItem == null)
            {
                return(null);
            }
            BrowsePosition browsePosition = null;

            ComplexItem[] result;
            try
            {
                BrowseFilters browseFilters = new BrowseFilters();
                browseFilters.ElementNameFilter    = null;
                browseFilters.BrowseFilter         = browseFilter.item;
                browseFilters.ReturnAllProperties  = false;
                browseFilters.PropertyIDs          = ComplexItem.CPX_PROPERTIES;
                browseFilters.ReturnPropertyValues = true;
                BrowseElement[] array = server.Browse(this.m_filterItem, browseFilters, out browsePosition);
                if (array == null || array.Length == 0)
                {
                    result = new ComplexItem[0];
                }
                else
                {
                    ArrayList arrayList = new ArrayList(array.Length);
                    foreach (BrowseElement element in array)
                    {
                        ComplexItem complexItem = new ComplexItem();
                        if (complexItem.Init(element))
                        {
                            arrayList.Add(complexItem);
                        }
                    }
                    result = (ComplexItem[])arrayList.ToArray(typeof(ComplexItem));
                }
            }
            finally
            {
                if (browsePosition != null)
                {
                    browsePosition.Dispose();
                    browsePosition = null;
                }
            }
            return(result);
        }
Example #5
0
        public ComplexItem[] GetDataFilters(Opc.Da.Server server)
        {
            ComplexItem[] itemArray;
            if (this.m_unfilteredItemID != null)
            {
                return(null);
            }
            if (this.m_filterItem == null)
            {
                return(null);
            }
            BrowsePosition position = null;

            try
            {
                BrowseFilters filters = new BrowseFilters {
                    ElementNameFilter    = null,
                    BrowseFilter         = browseFilter.item,
                    ReturnAllProperties  = false,
                    PropertyIDs          = CPX_PROPERTIES,
                    ReturnPropertyValues = true
                };
                BrowseElement[] elementArray = server.Browse(this.m_filterItem, filters, out position);
                if ((elementArray == null) || (elementArray.Length == 0))
                {
                    return(new ComplexItem[0]);
                }
                ArrayList list = new ArrayList(elementArray.Length);
                foreach (BrowseElement element in elementArray)
                {
                    ComplexItem item = new ComplexItem();
                    if (item.Init(element))
                    {
                        list.Add(item);
                    }
                }
                itemArray = (ComplexItem[])list.ToArray(typeof(ComplexItem));
            }
            finally
            {
                if (position != null)
                {
                    position.Dispose();
                    position = null;
                }
            }
            return(itemArray);
        }
Example #6
0
        // Token: 0x06000356 RID: 854 RVA: 0x00008D00 File Offset: 0x00007D00
        public ComplexItem CreateDataFilter(Da.Server server, string filterName, string filterValue)
        {
            if (this.m_unfilteredItemID != null)
            {
                return(null);
            }
            if (this.m_filterItem == null)
            {
                return(null);
            }
            BrowsePosition browsePosition = null;
            ComplexItem    result;

            try
            {
                ItemValue     itemValue     = new ItemValue(this.m_filterItem);
                StringWriter  stringWriter  = new StringWriter();
                XmlTextWriter xmlTextWriter = new XmlTextWriter(stringWriter);
                xmlTextWriter.WriteStartElement("DataFilters");
                xmlTextWriter.WriteAttributeString("Name", filterName);
                xmlTextWriter.WriteString(filterValue);
                xmlTextWriter.WriteEndElement();
                xmlTextWriter.Close();
                itemValue.Value              = stringWriter.ToString();
                itemValue.Quality            = Quality.Bad;
                itemValue.QualitySpecified   = false;
                itemValue.Timestamp          = DateTime.MinValue;
                itemValue.TimestampSpecified = false;
                IdentifiedResult[] array = server.Write(new ItemValue[]
                {
                    itemValue
                });
                if (array == null || array.Length == 0)
                {
                    throw new ApplicationException("Unexpected result from server.");
                }
                if (array[0].ResultID.Failed())
                {
                    throw new ApplicationException("Could not create new data filter.");
                }
                BrowseFilters browseFilters = new BrowseFilters();
                browseFilters.ElementNameFilter    = filterName;
                browseFilters.BrowseFilter         = browseFilter.item;
                browseFilters.ReturnAllProperties  = false;
                browseFilters.PropertyIDs          = ComplexItem.CPX_PROPERTIES;
                browseFilters.ReturnPropertyValues = true;
                BrowseElement[] array2 = server.Browse(this.m_filterItem, browseFilters, out browsePosition);
                if (array2 == null || array2.Length == 0)
                {
                    throw new ApplicationException("Could not browse to new data filter.");
                }
                ComplexItem complexItem = new ComplexItem();
                if (!complexItem.Init(array2[0]))
                {
                    throw new ApplicationException("Could not initialize to new data filter.");
                }
                result = complexItem;
            }
            finally
            {
                if (browsePosition != null)
                {
                    browsePosition.Dispose();
                    browsePosition = null;
                }
            }
            return(result);
        }
Example #7
0
        // Token: 0x06000354 RID: 852 RVA: 0x00008AA0 File Offset: 0x00007AA0
        public ComplexItem[] GetTypeConversions(Da.Server server)
        {
            if (this.m_unconvertedItemID != null || this.m_unfilteredItemID != null)
            {
                return(null);
            }
            BrowsePosition browsePosition = null;

            ComplexItem[] result;
            try
            {
                BrowseFilters browseFilters = new BrowseFilters();
                browseFilters.ElementNameFilter    = "CPX";
                browseFilters.BrowseFilter         = browseFilter.branch;
                browseFilters.ReturnAllProperties  = false;
                browseFilters.PropertyIDs          = null;
                browseFilters.ReturnPropertyValues = false;
                BrowseElement[] array = server.Browse(this, browseFilters, out browsePosition);
                if (array == null || array.Length == 0)
                {
                    result = null;
                }
                else
                {
                    if (browsePosition != null)
                    {
                        browsePosition.Dispose();
                        browsePosition = null;
                    }
                    ItemIdentifier itemID = new ItemIdentifier(array[0].ItemPath, array[0].ItemName);
                    browseFilters.ElementNameFilter    = null;
                    browseFilters.BrowseFilter         = browseFilter.item;
                    browseFilters.ReturnAllProperties  = false;
                    browseFilters.PropertyIDs          = ComplexItem.CPX_PROPERTIES;
                    browseFilters.ReturnPropertyValues = true;
                    array = server.Browse(itemID, browseFilters, out browsePosition);
                    if (array == null || array.Length == 0)
                    {
                        result = new ComplexItem[0];
                    }
                    else
                    {
                        ArrayList arrayList = new ArrayList(array.Length);
                        foreach (BrowseElement browseElement in array)
                        {
                            if (browseElement.Name != "DataFilters")
                            {
                                ComplexItem complexItem = new ComplexItem();
                                if (complexItem.Init(browseElement))
                                {
                                    complexItem.GetDataFilterItem(server);
                                    arrayList.Add(complexItem);
                                }
                            }
                        }
                        result = (ComplexItem[])arrayList.ToArray(typeof(ComplexItem));
                    }
                }
            }
            finally
            {
                if (browsePosition != null)
                {
                    browsePosition.Dispose();
                    browsePosition = null;
                }
            }
            return(result);
        }
Example #8
0
        public ComplexItem CreateDataFilter(Opc.Da.Server server, string filterName, string filterValue)
        {
            ComplexItem item2;

            if (this.m_unfilteredItemID != null)
            {
                return(null);
            }
            if (this.m_filterItem == null)
            {
                return(null);
            }
            BrowsePosition position = null;

            try
            {
                ItemValue     value2  = new ItemValue(this.m_filterItem);
                StringWriter  w       = new StringWriter();
                XmlTextWriter writer2 = new XmlTextWriter(w);
                writer2.WriteStartElement("DataFilters");
                writer2.WriteAttributeString("Name", filterName);
                writer2.WriteString(filterValue);
                writer2.WriteEndElement();
                writer2.Close();
                value2.Value              = w.ToString();
                value2.Quality            = Quality.Bad;
                value2.QualitySpecified   = false;
                value2.Timestamp          = DateTime.MinValue;
                value2.TimestampSpecified = false;
                IdentifiedResult[] resultArray = server.Write(new ItemValue[] { value2 });
                if ((resultArray == null) || (resultArray.Length == 0))
                {
                    throw new ApplicationException("Unexpected result from server.");
                }
                if (resultArray[0].ResultID.Failed())
                {
                    throw new ApplicationException("Could not create new data filter.");
                }
                BrowseFilters filters = new BrowseFilters {
                    ElementNameFilter    = filterName,
                    BrowseFilter         = browseFilter.item,
                    ReturnAllProperties  = false,
                    PropertyIDs          = CPX_PROPERTIES,
                    ReturnPropertyValues = true
                };
                BrowseElement[] elementArray = server.Browse(this.m_filterItem, filters, out position);
                if ((elementArray == null) || (elementArray.Length == 0))
                {
                    throw new ApplicationException("Could not browse to new data filter.");
                }
                ComplexItem item = new ComplexItem();
                if (!item.Init(elementArray[0]))
                {
                    throw new ApplicationException("Could not initialize to new data filter.");
                }
                item2 = item;
            }
            finally
            {
                if (position != null)
                {
                    position.Dispose();
                    position = null;
                }
            }
            return(item2);
        }
Example #9
0
        public ComplexItem[] GetTypeConversions(Opc.Da.Server server)
        {
            ComplexItem[] itemArray;
            if ((this.m_unconvertedItemID != null) || (this.m_unfilteredItemID != null))
            {
                return(null);
            }
            BrowsePosition position = null;

            try
            {
                BrowseFilters filters = new BrowseFilters {
                    ElementNameFilter    = "CPX",
                    BrowseFilter         = browseFilter.branch,
                    ReturnAllProperties  = false,
                    PropertyIDs          = null,
                    ReturnPropertyValues = false
                };
                BrowseElement[] elementArray = server.Browse(this, filters, out position);
                if ((elementArray == null) || (elementArray.Length == 0))
                {
                    return(null);
                }
                if (position != null)
                {
                    position.Dispose();
                    position = null;
                }
                ItemIdentifier itemID = new ItemIdentifier(elementArray[0].ItemPath, elementArray[0].ItemName);
                filters.ElementNameFilter    = null;
                filters.BrowseFilter         = browseFilter.item;
                filters.ReturnAllProperties  = false;
                filters.PropertyIDs          = CPX_PROPERTIES;
                filters.ReturnPropertyValues = true;
                elementArray = server.Browse(itemID, filters, out position);
                if ((elementArray == null) || (elementArray.Length == 0))
                {
                    return(new ComplexItem[0]);
                }
                ArrayList list = new ArrayList(elementArray.Length);
                foreach (BrowseElement element in elementArray)
                {
                    if (element.Name != "DataFilters")
                    {
                        ComplexItem item = new ComplexItem();
                        if (item.Init(element))
                        {
                            item.GetDataFilterItem(server);
                            list.Add(item);
                        }
                    }
                }
                itemArray = (ComplexItem[])list.ToArray(typeof(ComplexItem));
            }
            finally
            {
                if (position != null)
                {
                    position.Dispose();
                    position = null;
                }
            }
            return(itemArray);
        }
Example #10
0
        /// <summary>
        /// Fetches the item id for the data filters items.
        /// </summary>
        public void GetDataFilterItem(Opc.Da.Server server)
        {
            m_filterItem = null;

            // not a valid operation for data filter items.
            if (m_unfilteredItemID != null)
            {
                return;
            }

            BrowsePosition position = null;

            try
            {
                ItemIdentifier itemID = new ItemIdentifier(this);

                // browse any existing filter instances.
                BrowseFilters filters = new BrowseFilters();

                filters.ElementNameFilter    = CPX_DATA_FILTERS;
                filters.BrowseFilter         = browseFilter.all;
                filters.ReturnAllProperties  = false;
                filters.PropertyIDs          = null;
                filters.ReturnPropertyValues = false;

                BrowseElement[] elements = null;

                // browse for the 'CPX' branch first.
                if (m_unconvertedItemID == null)
                {
                    filters.ElementNameFilter = CPX_BRANCH;

                    elements = server.Browse(itemID, filters, out position);

                    // nothing found.
                    if (elements == null || elements.Length == 0)
                    {
                        return;
                    }

                    // release the position object.
                    if (position != null)
                    {
                        position.Dispose();
                        position = null;
                    }

                    // update the item for the next browse operation.
                    itemID = new ItemIdentifier(elements[0].ItemPath, elements[0].ItemName);

                    filters.ElementNameFilter = CPX_DATA_FILTERS;
                }

                // browse for the 'DataFilters' branch.
                elements = server.Browse(itemID, filters, out position);

                // nothing found.
                if (elements == null || elements.Length == 0)
                {
                    return;
                }

                m_filterItem = new ItemIdentifier(elements[0].ItemPath, elements[0].ItemName);
            }
            finally
            {
                if (position != null)
                {
                    position.Dispose();
                    position = null;
                }
            }
        }
Example #11
0
        /// <summary>
        /// Creates a new data filter.
        /// </summary>
        public ComplexItem CreateDataFilter(Opc.Da.Server server, string filterName, string filterValue)
        {
            // not a valid operation for data filter items.
            if (m_unfilteredItemID != null)
            {
                return(null);
            }

            // data filters not supported by the item.
            if (m_filterItem == null)
            {
                return(null);
            }

            BrowsePosition position = null;

            try
            {
                // write the desired filter to the server.
                ItemValue item = new ItemValue(m_filterItem);

                // create the filter parameters document.
                StringWriter  ostrm  = new StringWriter();
                XmlTextWriter writer = new XmlTextWriter(ostrm);

                writer.WriteStartElement("DataFilters");
                writer.WriteAttributeString("Name", filterName);
                writer.WriteString(filterValue);
                writer.WriteEndElement();

                writer.Close();

                // create the value to write.
                item.Value              = ostrm.ToString();
                item.Quality            = Quality.Bad;
                item.QualitySpecified   = false;
                item.Timestamp          = DateTime.MinValue;
                item.TimestampSpecified = false;

                // write the value.
                IdentifiedResult[] result = server.Write(new ItemValue[] { item });

                if (result == null || result.Length == 0)
                {
                    throw new ApplicationException("Unexpected result from server.");
                }

                if (result[0].ResultID.Failed())
                {
                    throw new ApplicationException("Could not create new data filter.");
                }

                // browse for new data filter item.
                BrowseFilters filters = new BrowseFilters();

                filters.ElementNameFilter    = filterName;
                filters.BrowseFilter         = browseFilter.item;
                filters.ReturnAllProperties  = false;
                filters.PropertyIDs          = CPX_PROPERTIES;
                filters.ReturnPropertyValues = true;

                BrowseElement[] elements = server.Browse(m_filterItem, filters, out position);

                // nothing found.
                if (elements == null || elements.Length == 0)
                {
                    throw new ApplicationException("Could not browse to new data filter.");
                }

                ComplexItem filterItem = new ComplexItem();

                if (!filterItem.Init(elements[0]))
                {
                    throw new ApplicationException("Could not initialize to new data filter.");
                }

                // return the new data filter.
                return(filterItem);
            }
            finally
            {
                if (position != null)
                {
                    position.Dispose();
                    position = null;
                }
            }
        }
Example #12
0
        /// <summary>
        /// Fetches the set of type conversions from the server.
        /// </summary>
        public ComplexItem[] GetTypeConversions(Opc.Da.Server server)
        {
            // only the root item can have type conversions.
            if (m_unconvertedItemID != null || m_unfilteredItemID != null)
            {
                return(null);
            }

            BrowsePosition position = null;

            try
            {
                // look for the 'CPX' branch.
                BrowseFilters filters = new BrowseFilters();

                filters.ElementNameFilter    = CPX_BRANCH;
                filters.BrowseFilter         = browseFilter.branch;
                filters.ReturnAllProperties  = false;
                filters.PropertyIDs          = null;
                filters.ReturnPropertyValues = false;

                BrowseElement[] elements = server.Browse(this, filters, out position);

                // nothing found.
                if (elements == null || elements.Length == 0)
                {
                    return(null);
                }

                // release the browse position object.
                if (position != null)
                {
                    position.Dispose();
                    position = null;
                }

                // browse for type conversions.
                ItemIdentifier itemID = new ItemIdentifier(elements[0].ItemPath, elements[0].ItemName);

                filters.ElementNameFilter    = null;
                filters.BrowseFilter         = browseFilter.item;
                filters.ReturnAllProperties  = false;
                filters.PropertyIDs          = CPX_PROPERTIES;
                filters.ReturnPropertyValues = true;

                elements = server.Browse(itemID, filters, out position);

                // nothing found.
                if (elements == null || elements.Length == 0)
                {
                    return(new ComplexItem[0]);
                }

                // contruct an array of complex data items for each available conversion.
                ArrayList conversions = new ArrayList(elements.Length);

                foreach (BrowseElement element in elements)
                {
                    if (element.Name != CPX_DATA_FILTERS)
                    {
                        ComplexItem item = new ComplexItem();

                        if (item.Init(element))
                        {
                            // check if data filters supported for type conversion.
                            item.GetDataFilterItem(server);

                            conversions.Add(item);
                        }
                    }
                }

                // return the set of available conversions.
                return((ComplexItem[])conversions.ToArray(typeof(ComplexItem)));
            }
            finally
            {
                if (position != null)
                {
                    position.Dispose();
                    position = null;
                }
            }
        }