Exemple #1
0
        public override void Decode(Stream inputStream)
        {
            if (inputStream == null || !inputStream.CanRead)
            {
                return;
            }

            // 1. Content
            Content = SimpleArray <byte> .Decode(inputStream, BaseType.ReadByte);

            // 2. Path
            Path = String.Decode(inputStream);

            // 3. Timestamp
            long?readTime = BaseType.ReadInt64(inputStream);

            if (readTime != null)
            {
                Time = readTime.Value;
            }

            // 4. File type
            FileType = String.Decode(inputStream);

            // 5. Name (is not used via OPC UA but can be used for logging etc.)
            Name = System.IO.Path.GetFileName(Path.Value);
        }
Exemple #2
0
        public static StructureField Decode(Stream inputStream)
        {
            if (inputStream == null || !inputStream.CanRead)
            {
                return(null);
            }
            StructureField instance = new StructureField();

            instance.Name        = String.Decode(inputStream);
            instance.Description = LocalizedText.Decode(inputStream);
            instance.DataType    = NodeID.Decode(inputStream);
            int?readInt32 = BaseType.ReadInt32(inputStream);

            if (readInt32 != null)
            {
                instance.ValueRank = readInt32.Value;
            }
            instance.ArrayDimension = SimpleArray <uint> .Decode(inputStream, BaseType.ReadUInt32);

            uint?readUInt32 = BaseType.ReadUInt32(inputStream);

            if (readUInt32 != null)
            {
                instance.MaxStringLength = readUInt32.Value;
            }
            instance.IsOptional = inputStream.ReadByte() != 0;
            return(instance);
        }
        public static ChunkedMessage Decode(Stream inputStream)
        {
            if (inputStream == null || !inputStream.CanRead)
            {
                return(null);
            }
            ChunkedMessage instance = new ChunkedMessage();

            instance.PayloadHeader = ChunkedPayloadHeader.Decode(inputStream);
            ushort?seqValue = BaseType.ReadUInt16(inputStream);

            if (seqValue == null)
            {
                return(null);
            }
            instance.MessageSequenceNumber = seqValue.Value;
            uint?offSetValue = BaseType.ReadUInt32(inputStream);

            if (offSetValue == null)
            {
                return(null);
            }
            instance.ChunkOffset = offSetValue.Value;
            uint?sizeValue = BaseType.ReadUInt32(inputStream);

            if (sizeValue == null)
            {
                return(null);
            }
            instance.TotalSize = sizeValue.Value;
            instance.ChunkData = SimpleArray <byte> .Decode(inputStream, BaseType.ReadByte);

            return(instance);
        }
        public static DataSetPayloadHeader Decode(Stream inputStream)
        {
            if (inputStream == null || !inputStream.CanRead)
            {
                return(null);
            }
            DataSetPayloadHeader instance = new DataSetPayloadHeader();

            instance.Count           = (byte)inputStream.ReadByte();
            instance.DataSetWriterID = SimpleArray <ushort> .Decode(inputStream, BaseType.ReadUInt16, instance.Count);

            return(instance);
        }
        public static FieldMetaData Decode(Stream inputStream, EncodingOptions options)
        {
            FieldMetaData instance = new FieldMetaData(options);

            // 1. Name
            instance.Name = String.Decode(inputStream);

            // 2. Description
            instance.Description = LocalizedText.Decode(inputStream);

            // 3. Field Flags
            instance.Flags = DataSetFieldFlags.Decode(inputStream, options);

            // 4. Built-in Type
            instance.Type = (BuiltinType)inputStream.ReadByte();

            // 5. DataType
            instance.DataType = NodeID.Decode(inputStream);

            // 6. Value Rank
            int?valueRank = BaseType.ReadInt32(inputStream);

            if (valueRank.HasValue)
            {
                instance.ValueRank = valueRank.Value;
            }

            // 7. Array Dimension
            instance.ArrayDimension = SimpleArray <uint> .Decode(inputStream, BaseType.ReadUInt32);

            // 8. Size
            uint?readUInt32 = BaseType.ReadUInt32(inputStream);

            if (readUInt32 != null)
            {
                instance.MaxStringLength = readUInt32.Value;
            }

            // 9. Field ID
            byte[] guidAsByte = Common.ReadBytes(inputStream, 16);
            if (guidAsByte != null && guidAsByte.Length == 16)
            {
                instance.FieldID = new Guid(guidAsByte);
            }

            // 10. Properties
            instance.Properties = ParseProperties(inputStream);
            return(instance);
        }
        public static DataSet Decode(Stream inputStream)
        {
            DataSet instance = new DataSet();

            instance.MessageCount    = (byte)inputStream.ReadByte();
            instance.DataSetWriterID = SimpleArray <ushort> .Decode(inputStream, BaseType.ReadUInt16);

            instance.Size = SimpleArray <ushort> .Decode(inputStream, BaseType.ReadUInt16);

            instance.MessageType = (MessageTypeEnum)inputStream.ReadByte();
            if (instance.MessageType == MessageTypeEnum.MetaFrame ||
                instance.MessageType == MessageTypeEnum.KeyFrame ||
                instance.MessageType == MessageTypeEnum.DeltaFrame)
            {
                instance.EncodingFlags = (byte)inputStream.ReadByte();
                ushort?sequenceNumber = BaseType.ReadUInt16(inputStream);
                if (!sequenceNumber.HasValue)
                {
                    return(null);
                }
                instance.MessageSequenceNumber = sequenceNumber.Value;
                uint?major = BaseType.ReadUInt32(inputStream);
                if (!major.HasValue)
                {
                    return(null);
                }
                instance.MajorVersion = major.Value;
                uint?minor = BaseType.ReadUInt32(inputStream);
                if (!minor.HasValue)
                {
                    return(null);
                }
                instance.MinorVersion = minor.Value;
            }
            return(instance);
        }