public ChannelExtensionBlock(Mdf mdf) : base(mdf) { byte[] data = new byte[Size - 4]; int read = Mdf.Data.Read(data, 0, data.Length); if (read != data.Length) { throw new FormatException(); } Type = (ExtensionType)BitConverter.ToUInt16(data, 0); if (Type == ExtensionType.DIM) { DimBlockSupplement = new DimBlockSupplement(mdf); } else if (Type == ExtensionType.VectorCAN) { VectorCanBlockSupplement = new VectorCanBlockSupplement(mdf); } }
internal static ProgramBlock Read(Mdf mdf, Stream stream) { var block = new ProgramBlock(mdf); block.Read(stream); if (block.Identifier != "PR") { throw new FormatException(); } var data = new byte[block.Size - 4]; var read = stream.Read(data, 0, data.Length); if (read != data.Length) { throw new FormatException(); } block.data = data; return(block); }
public TriggerBlock(Mdf mdf) : base(mdf) { }
private ChannelConversionBlock(Mdf mdf) : base(mdf) { AdditionalConversionData = new ConversionData(this); }
private DataGroupBlock(Mdf mdf) : base(mdf) { ChannelGroups = new ChannelGroupCollection(mdf, this); }
private ChannelBlock(Mdf mdf) : base(mdf) { }
public static ChannelBlock Read(Mdf mdf, Stream stream, uint position) { stream.Position = position; var block = new ChannelBlock(mdf); block.stream = stream; block.Read(stream); var data = new byte[block.Size - 4]; var read = stream.Read(data, 0, data.Length); if (read != data.Length) { throw new FormatException(); } block.next = null; block.SourceDepending = null; block.Dependency = null; block.Comment = null; block.ptrNextChannelBlock = BitConverter.ToUInt32(data, 0); block.ptrChannelConversionBlock = BitConverter.ToUInt32(data, 4); block.ptrChannelExtensionBlock = BitConverter.ToUInt32(data, 8); block.ptrChannelDependencyBlock = BitConverter.ToUInt32(data, 12); block.ptrChannelComment = BitConverter.ToUInt32(data, 16); block.Type = (ChannelType)BitConverter.ToUInt16(data, 20); block.SignalName = mdf.IDBlock.Encoding.GetString(data, 22, 32).Humanize(); block.SignalDescription = mdf.IDBlock.Encoding.GetString(data, 54, 128).Humanize(); block.BitOffset = BitConverter.ToUInt16(data, 182); block.NumberOfBits = BitConverter.ToUInt16(data, 184); block.SignalType = (SignalType)BitConverter.ToUInt16(data, 186); block.ValueRange = BitConverter.ToBoolean(data, 188); if (block.ValueRange) { block.MinValue = BitConverter.ToDouble(data, 190); block.MaxValue = BitConverter.ToDouble(data, 198); } block.SampleRate = BitConverter.ToDouble(data, 206); if (mdf.IDBlock.Version >= MIN_VERSION_LONG_SIGNAL_NAME) { block.ptrLongSignalName = BitConverter.ToUInt32(data, 214); } if (mdf.IDBlock.Version >= MIN_VERSION_DISPLAY_NAME) { block.ptrDisplayName = BitConverter.ToUInt32(data, 218); } if (mdf.IDBlock.Version >= MIN_VERSION_ADDITIONAL_BYTE_OFFSET) { block.AdditionalByteOffset = BitConverter.ToUInt16(data, 222); } if (block.ptrChannelExtensionBlock != 0) { stream.Position = block.ptrChannelExtensionBlock; block.SourceDepending = new ChannelExtensionBlock(mdf); } return(block); }
private ProgramBlock(Mdf mdf) : base(mdf) { }
public static ProgramBlock Create(Mdf mdf) { return(Create(mdf, new byte[0])); }
public static TextBlock Create(Mdf mdf) { return(Create(mdf, "")); }
private TextBlock(Mdf mdf) : base(mdf) { }
/// <summary> /// Initializes a new instance of the <see cref="HeaderBlock" /> class. /// </summary> /// <param name="mdf">The MDF.</param> /// <exception cref="System.FormatException"></exception> private HeaderBlock(Mdf mdf) : base(mdf) { }
internal static HeaderBlock Read(Mdf mdf, Stream stream) { var block = new HeaderBlock(mdf); block.Read(stream); var data = new byte[block.Size - 4]; var read = stream.Read(data, 0, data.Length); if (read != data.Length) { throw new FormatException(); } block.DataGroupsCount = BitConverter.ToUInt16(data, 12); block.Date = mdf.IDBlock.Encoding.GetString(data, 14, 10).Humanize(); block.Time = mdf.IDBlock.Encoding.GetString(data, 24, 8).Humanize(); block.Author = mdf.IDBlock.Encoding.GetString(data, 32, 32).Humanize(); block.Organization = mdf.IDBlock.Encoding.GetString(data, 64, 32).Humanize(); block.Project = mdf.IDBlock.Encoding.GetString(data, 96, 32).Humanize(); block.Subject = mdf.IDBlock.Encoding.GetString(data, 128, 32).Humanize(); if (mdf.IDBlock.Version >= 320) { block.TimeStamp = BitConverter.ToUInt64(data, 160); block.UTCTimeOffset = BitConverter.ToInt16(data, 168); block.TimeQuality = (TimeQuality)BitConverter.ToUInt16(data, 170); block.TimerIdentification = mdf.IDBlock.Encoding.GetString(data, 172, 32).Humanize(); } else { block.TimeStamp = 0; block.UTCTimeOffset = 0; block.TimeQuality = 0; block.TimerIdentification = ""; } var ptrFirstDataGroup = BitConverter.ToUInt32(data, 0); var ptrTextBlock = BitConverter.ToUInt32(data, 4); var ptrProgramBlock = BitConverter.ToUInt32(data, 8); // Check if ptrTextBlock is null if (ptrTextBlock != 0) { stream.Position = ptrTextBlock; block.FileComment = TextBlock.Read(mdf, stream); } // Check if ptrProgramBlock is null if (ptrProgramBlock != 0) { stream.Position = ptrProgramBlock; block.ProgramBlock = ProgramBlock.Read(mdf, stream); } // Check if ptrFirstDataGroup is null if (ptrFirstDataGroup != 0) { mdf.DataGroups.Read(DataGroupBlock.Read(mdf, stream, ptrFirstDataGroup)); } return(block); }
private ChannelGroupBlock(Mdf mdf) : base(mdf) { }