/// <summary> /// Initializes a new instance of the ChannelInfo class that contain the values extracted from the given byte array. /// </summary> /// <param name="byteArray">The size of array need to be at least of 128 bytes.</param> public ChannelInfo(Byte[] byteArray) { _TypeOfChannel = ChannelTypes.Subbottom; _SubChannelNumber = 0; _CorrectionFlag = CorrectionFlags.Range; _Polarity = DataPolarity.Bipolar; _BytesPerSample = 0; _SamplesPerChannel = 0; _ChannelName = " "; _VoltScale = 0; _Frequency = 0; _HorizontalBeamAngle = 0; _TiltAngle = 0; _BeamWidth = 0; _OffsetX = 0; _OffsetY = 0; _OffsetZ = 0; _OffsetYaw = 0; _OffsetPitch = 0; _OffsetRoll = 0; _BeamsPerArray = 0; _Latency = 0; using (BinaryReader dp = new BinaryReader(ArrayToStream.BytesToMemory(byteArray))) { if (byteArray.Length >= 128) { _TypeOfChannel = (ChannelTypes)dp.ReadByte(); // 0 _SubChannelNumber = dp.ReadByte(); // 1 _CorrectionFlag = (CorrectionFlags)dp.ReadUInt16(); // 2-3 _Polarity = (DataPolarity)dp.ReadUInt16(); // 4-5 _BytesPerSample = dp.ReadUInt16(); // 6-7 _SamplesPerChannel = dp.ReadUInt32(); // 8-9-10-11 _ChannelName = new String(dp.ReadChars(16)); // 12-13-14-15-16-17-18-19-20-21-22-23-24-25-26-27 _VoltScale = dp.ReadSingle(); // 28-29-30-31 _Frequency = dp.ReadSingle(); // 32-33-34-35 _HorizontalBeamAngle = dp.ReadSingle(); // 36-37-38-39 _TiltAngle = dp.ReadSingle(); // 40-41-42-43 _BeamWidth = dp.ReadSingle(); // 44-45-46-47 _OffsetX = dp.ReadSingle(); // 48-49-50-51 _OffsetY = dp.ReadSingle(); // 52-53-54-55 _OffsetZ = dp.ReadSingle(); // 56-57-58-59 _OffsetYaw = dp.ReadSingle(); // 60-61-62-63 _OffsetPitch = dp.ReadSingle(); // 64-65-66-67 _OffsetRoll = dp.ReadSingle(); // 68-69-70-71 _BeamsPerArray = dp.ReadUInt16(); // 72-73 _Latency = dp.ReadSingle(); // 74-75-76-77 } } }
/// <summary> /// Initializes a new instance of the ChannelInfo class that has default zero values. /// </summary> public ChannelInfo() { _TypeOfChannel = ChannelTypes.Subbottom; _SubChannelNumber = 0; _CorrectionFlag = CorrectionFlags.Range; _Polarity = DataPolarity.Bipolar; _BytesPerSample = 0; _SamplesPerChannel = 0; _ChannelName = " "; _VoltScale = 0; _Frequency = 0; _HorizontalBeamAngle = 0; _TiltAngle = 0; _BeamWidth = 0; _OffsetX = 0; _OffsetY = 0; _OffsetZ = 0; _OffsetYaw = 0; _OffsetPitch = 0; _OffsetRoll = 0; _BeamsPerArray = 0; _Latency = 0; }
/// <summary> /// Return an unsigned integer of 16 bit that represent the value of the enum. /// </summary> /// <param name="value"></param> /// <returns></returns> public static ushort ToUInt16(this CorrectionFlags value) { return((ushort)value); }