// Token: 0x06000364 RID: 868 RVA: 0x00009518 File Offset: 0x00008518 public static string GetTypeDictionary(ItemIdentifier itemID) { if (itemID == null) { return(null); } string result; lock (typeof(ComplexTypeCache)) { string text = (string)ComplexTypeCache.m_dictionaries[itemID.Key]; if (text != null) { result = text; } else { ComplexItem complexItem = ComplexTypeCache.GetComplexItem(itemID); if (complexItem != null) { text = complexItem.GetTypeDictionary(ComplexTypeCache.m_server); } result = text; } } return(result); }
// Token: 0x06000365 RID: 869 RVA: 0x0000958C File Offset: 0x0000858C public static string GetTypeDescription(ItemIdentifier itemID) { if (itemID == null) { return(null); } string result; lock (typeof(ComplexTypeCache)) { string text = null; ComplexItem complexItem = ComplexTypeCache.GetComplexItem(itemID); if (complexItem != null) { text = (string)ComplexTypeCache.m_descriptions[complexItem.TypeItemID.Key]; if (text != null) { return(text); } text = ((string)(m_descriptions[complexItem.TypeItemID.Key] = complexItem.GetTypeDescription(m_server))); } result = text; } return(result); }
/// <summary> /// Fetches the type description for the item. /// </summary> public static string GetTypeDescription(ItemIdentifier itemID) { if (itemID == null) { return(null); } lock (typeof(ComplexTypeCache)) { string description = null; ComplexItem item = GetComplexItem(itemID); if (item != null) { description = (string)m_descriptions[item.TypeItemID.Key]; if (description != null) { return(description); } m_descriptions[item.TypeItemID.Key] = description = item.GetTypeDescription(m_server); } return(description); } }
/// <summary> /// Fetches the type description for the item. /// </summary> public static string GetTypeDictionary(ItemIdentifier itemID) { if (itemID == null) { return(null); } lock (typeof(ComplexTypeCache)) { string dictionary = (string)m_dictionaries[itemID.Key]; if (dictionary != null) { return(dictionary); } ComplexItem item = GetComplexItem(itemID); if (item != null) { dictionary = item.GetTypeDictionary(m_server); } return(dictionary); } }
/// <summary> /// Returns the complex item for the specified item id. /// </summary> public static ComplexItem GetComplexItem(ItemIdentifier itemID) { if (itemID == null) { return(null); } lock (typeof(ComplexTypeCache)) { ComplexItem item = new ComplexItem(itemID); try { item.Update(m_server); } catch { // item is not a valid complex data item. item = null; } m_items[itemID.Key] = item; return(item); } }
/// <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; } } }
// 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); }
// Token: 0x06000362 RID: 866 RVA: 0x0000944C File Offset: 0x0000844C public static ComplexItem GetComplexItem(ItemIdentifier itemID) { if (itemID == null) { return(null); } ComplexItem result; lock (typeof(ComplexTypeCache)) { ComplexItem complexItem = new ComplexItem(itemID); try { complexItem.Update(ComplexTypeCache.m_server); } catch { complexItem = null; } ComplexTypeCache.m_items[itemID.Key] = complexItem; result = complexItem; } return(result); }
// 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); }
// 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); }
/// <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; } } }
/// <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; } } }