Opc.Ua.BinaryDecoder.ReadDiagnosticInfo C# (CSharp) Method

ReadDiagnosticInfo() public method

Reads an DiagnosticInfo from the stream.
public ReadDiagnosticInfo ( string fieldName ) : DiagnosticInfo
fieldName string
return DiagnosticInfo
        public DiagnosticInfo ReadDiagnosticInfo(string fieldName)
        {
            // read the encoding byte.
            byte encodingByte = m_reader.ReadByte();

            DiagnosticInfo value = new DiagnosticInfo();
                        
            // read the fields of the diagnostic info structure.
            if ((encodingByte & (byte)DiagnosticInfoEncodingBits.SymbolicId) != 0)
            {
                value.SymbolicId = ReadInt32(null);
            }

            if ((encodingByte & (byte)DiagnosticInfoEncodingBits.NamespaceUri) != 0)
            {
                value.NamespaceUri = ReadInt32(null);
            }
            
            if ((encodingByte & (byte)DiagnosticInfoEncodingBits.Locale) != 0)
            {
                value.Locale = ReadInt32(null);
            }

            if ((encodingByte & (byte)DiagnosticInfoEncodingBits.LocalizedText) != 0)
            {
                value.LocalizedText = ReadInt32(null);
            }
            
            if ((encodingByte & (byte)DiagnosticInfoEncodingBits.AdditionalInfo) != 0)
            {
                value.AdditionalInfo = ReadString(null);
            }
            
            if ((encodingByte & (byte)DiagnosticInfoEncodingBits.InnerStatusCode) != 0)
            {
                value.InnerStatusCode = ReadStatusCode(null);
            }
            
            if ((encodingByte & (byte)DiagnosticInfoEncodingBits.InnerDiagnosticInfo) != 0)
            {
                value.InnerDiagnosticInfo = ReadDiagnosticInfo(null);
            }

            return value;
        }
        

Usage Example

コード例 #1
0
ファイル: Com.Da.Server.cs プロジェクト: yuriik83/UA-.NET
        /// <summary>
        /// Converts a VARIANT value to a Builtin Type.
        /// </summary>
        private object VariantValueToScalarValue(object value, NodeId builtinTypeId)
        {        
            switch ((uint)builtinTypeId.Identifier)
            {
                case DataTypes.Guid:
                {
                    return new Uuid((string)value);
                }

                case DataTypes.XmlElement:
                {    
                    XmlDocument document = new XmlDocument();
                    document.InnerXml = (string)value;
                    return document.DocumentElement;
                }

                case DataTypes.NodeId:
                {
                    return NodeId.Parse((string)value);
                }

                case DataTypes.ExpandedNodeId:
                {
                    return ExpandedNodeId.Parse((string)value);
                }

                case DataTypes.QualifiedName:
                {
                    return QualifiedName.Parse((string)value);
                }

                case DataTypes.LocalizedText:
                {
                    return new LocalizedText(ComUtils.GetLocale(m_lcid), (string)value);
                }

                case DataTypes.StatusCode:
                {
                     return new StatusCode((uint)value);
                }

                case DataTypes.DiagnosticInfo:
                {
                    BinaryDecoder decoder = new BinaryDecoder((byte[])value, m_session.MessageContext);
                    DiagnosticInfo decodedValue = decoder.ReadDiagnosticInfo(null);
                    decoder.Close();
                    return decodedValue; 
                }

                case DataTypes.DataValue:
                {
                    BinaryDecoder decoder = new BinaryDecoder((byte[])value, m_session.MessageContext);
                    DataValue decodedValue = decoder.ReadDataValue(null);
                    decoder.Close();
                    return decodedValue; 
                }

                case DataTypes.Structure:
                {
                    BinaryDecoder decoder = new BinaryDecoder((byte[])value, m_session.MessageContext);
                    ExtensionObject decodedValue = decoder.ReadExtensionObject(null);
                    decoder.Close();
                    return decodedValue; 
                }
            }

            return value;
        }