コード例 #1
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;
                }
            }
        }
コード例 #2
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);
        }
コード例 #3
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);
        }
コード例 #4
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);
        }
コード例 #5
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;
                }
            }
        }
コード例 #6
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;
                }
            }
        }