public static GetAttributeDisplayText ( Session session, uint attributeId, Variant value ) : string | ||
session | Session | The currently active session. |
attributeId | uint | The id of the attribute. |
value | Variant | The value of the attribute. |
Результат | string |
/// <summary> /// Reads the attributes for the node. /// </summary> private void ReadAttributes(NodeId nodeId) { // build list of attributes to read. ReadValueIdCollection nodesToRead = new ReadValueIdCollection(); foreach (uint attributeId in Attributes.GetIdentifiers()) { ReadValueId nodeToRead = new ReadValueId(); nodeToRead.NodeId = nodeId; nodeToRead.AttributeId = attributeId; nodesToRead.Add(nodeToRead); } // read the attributes. DataValueCollection results = null; DiagnosticInfoCollection diagnosticInfos = null; m_session.Read( null, 0, TimestampsToReturn.Neither, nodesToRead, out results, out diagnosticInfos); ClientBase.ValidateResponse(results, nodesToRead); ClientBase.ValidateDiagnosticInfos(diagnosticInfos, nodesToRead); // add the results to the display. for (int ii = 0; ii < results.Count; ii++) { // check for error. if (StatusCode.IsBad(results[ii].StatusCode)) { if (results[ii].StatusCode == StatusCodes.BadAttributeIdInvalid) { continue; } } // add the metadata for the attribute. uint attributeId = nodesToRead[ii].AttributeId; ListViewItem item = new ListViewItem(Attributes.GetBrowseName(attributeId)); item.SubItems.Add(Attributes.GetBuiltInType(attributeId).ToString()); if (Attributes.GetValueRank(attributeId) >= 0) { item.SubItems[0].Text += "[]"; } // add the value. if (StatusCode.IsBad(results[ii].StatusCode)) { item.SubItems.Add(results[ii].StatusCode.ToString()); } else { item.SubItems.Add(ClientUtils.GetAttributeDisplayText(m_session, attributeId, results[ii].WrappedValue)); } item.Tag = results[ii]; // display in list. AttributesLV.Items.Add(item); } // set the column widths. for (int ii = 0; ii < AttributesLV.Columns.Count; ii++) { AttributesLV.Columns[ii].Width = -2; } }