Exemple #1
0
 public int CompareTo(object obj)
 {
     if (obj is Time)
     {
         Time otherTime = (Time)obj;
         return(MSeconds.CompareTo(otherTime.MSeconds));
     }
     else
     {
         throw new ArgumentException("Object is not a Time");
     }
 }
Exemple #2
0
 public int CompareTo(Time other)
 {
     return(MSeconds.CompareTo(other.MSeconds));
 }
Exemple #3
0
        /// <summary>
        /// Initializes a new instance of the RawCustomHeader 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 64 bytes.</param>
        public RawCustomHeader(Byte[] byteArray)
        {
            _HeaderType             = 199;
            _MagicNumber            = 0;
            _SubChannelNumber       = 0;
            _NumberChannelsToFollow = 0;
            //_NumberBytesThisRecord = 64;
            _PacketTime = DateTime.MinValue;

            _ManufacturerId        = 0;
            _SonarId               = 0;
            _PacketId              = 0;
            _PingNumber            = 0;
            _TimeTag               = 0;
            _NumberCustomerBytes   = 0;
            _NumberBytesThisRecord = NumberCustomerBytes + 64;

            UInt16   chkNumber;
            UInt16   Year;
            Byte     Month;
            Byte     Day;
            Byte     Hour;
            Byte     Minutes;
            Byte     Seconds;
            Byte     MSeconds;
            String   TimeString;
            DateTime outTime;

            using (BinaryReader dp = new BinaryReader(ArrayToStream.BytesToMemory(byteArray)))
            {
                if (byteArray.Length >= 64)
                {
                    chkNumber = dp.ReadUInt16(); // 0-1
                    if (chkNumber == XtfDocument.MagicNumber)
                    {
                        dp.ReadByte();                            //HeaderType 2
                        _ManufacturerId = dp.ReadByte();          // 3
                        _SonarId        = dp.ReadUInt16();        // 4-5
                        _PacketId       = dp.ReadUInt16();        // 6-7
                        dp.ReadUInt16();                          // 8-9 Unused
                        _NumberBytesThisRecord = dp.ReadUInt32(); // 10-11-12-13

                        //Read the ping time values
                        Year     = dp.ReadUInt16(); // 14-15
                        Month    = dp.ReadByte();   // 16
                        Day      = dp.ReadByte();   // 17
                        Hour     = dp.ReadByte();   // 18
                        Minutes  = dp.ReadByte();   // 19
                        Seconds  = dp.ReadByte();   // 20
                        MSeconds = dp.ReadByte();   // 21
                        //Compose the ping time value
                        TimeString = Year.ToString("0000", CultureInfo.InvariantCulture);
                        TimeString = TimeString + "-" + Month.ToString("00", CultureInfo.InvariantCulture);
                        TimeString = TimeString + "-" + Day.ToString("00", CultureInfo.InvariantCulture);
                        TimeString = TimeString + "-" + Hour.ToString("00", CultureInfo.InvariantCulture);
                        TimeString = TimeString + "-" + Minutes.ToString("00", CultureInfo.InvariantCulture);
                        TimeString = TimeString + "-" + Seconds.ToString("00", CultureInfo.InvariantCulture);
                        TimeString = TimeString + "-" + MSeconds.ToString("00", CultureInfo.InvariantCulture);
                        if (DateTime.TryParseExact(TimeString, "yyyy-MM-dd-HH-mm-ss-ff", CultureInfo.InvariantCulture, DateTimeStyles.None, out outTime))
                        {
                            _PacketTime = outTime;
                        }
                        else
                        {
                            _PacketTime = DateTime.MinValue;
                        }

                        dp.ReadUInt16();                        // 22-23 Julian Day
                        dp.ReadUInt16();                        // 24-25 Unused
                        dp.ReadUInt16();                        // 26-27 Unused
                        _PingNumber          = dp.ReadUInt32(); // 28-29-30-31
                        _TimeTag             = dp.ReadUInt32(); // 32-33-34-35
                        _NumberCustomerBytes = dp.ReadUInt32(); // 36-37-38-39
                    }
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// Initializes a new instance of the HighSpeedSensor 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 64 bytes.</param>
        public HighSpeedSensor(Byte[] byteArray)
        {
            _HeaderType             = 15;
            _MagicNumber            = 0;
            _SubChannelNumber       = 0;
            _NumberChannelsToFollow = 0;
            _NumberBytesThisRecord  = 256;
            _PacketTime             = DateTime.MinValue;

            _NumberSensorBytes       = 0;
            _RelativeBathyPingNumber = 0;

            UInt16   chkNumber;
            UInt16   Year;
            Byte     Month;
            Byte     Day;
            Byte     Hour;
            Byte     Minutes;
            Byte     Seconds;
            UInt16   MSeconds;
            String   TimeString;
            DateTime outTime;

            using (BinaryReader dp = new BinaryReader(ArrayToStream.BytesToMemory(byteArray)))
            {
                if (byteArray.Length >= 31)
                {
                    chkNumber = dp.ReadUInt16(); // 0-1
                    if (chkNumber == XtfDocument.MagicNumber)
                    {
                        _HeaderType             = dp.ReadByte();   //HeaderType 2
                        _SubChannelNumber       = dp.ReadByte();   // 3
                        _NumberChannelsToFollow = dp.ReadUInt16(); // 4-5
                        dp.ReadUInt16();                           //Unused 6-7
                        dp.ReadUInt16();                           //Unused 8-9
                        _NumberBytesThisRecord = dp.ReadUInt32();  // 10-11-12-13
                        //Read the ping time values
                        Year     = dp.ReadUInt16();                // 14-15
                        Month    = dp.ReadByte();                  // 16
                        Day      = dp.ReadByte();                  // 17
                        Hour     = dp.ReadByte();                  // 18
                        Minutes  = dp.ReadByte();                  // 19
                        Seconds  = dp.ReadByte();                  // 20
                        MSeconds = dp.ReadUInt16();                // 21-22
                        //Compose the ping time value
                        TimeString = Year.ToString("0000", CultureInfo.InvariantCulture);
                        TimeString = TimeString + "-" + Month.ToString("00", CultureInfo.InvariantCulture);
                        TimeString = TimeString + "-" + Day.ToString("00", CultureInfo.InvariantCulture);
                        TimeString = TimeString + "-" + Hour.ToString("00", CultureInfo.InvariantCulture);
                        TimeString = TimeString + "-" + Minutes.ToString("00", CultureInfo.InvariantCulture);
                        TimeString = TimeString + "-" + Seconds.ToString("00", CultureInfo.InvariantCulture);
                        TimeString = TimeString + "-" + MSeconds.ToString("00", CultureInfo.InvariantCulture);
                        if (DateTime.TryParseExact(TimeString, "yyyy-MM-dd-HH-mm-ss-ff", CultureInfo.InvariantCulture, DateTimeStyles.None, out outTime))
                        {
                            _PacketTime = outTime;
                        }
                        else
                        {
                            _PacketTime = DateTime.MinValue;
                        }

                        _NumberSensorBytes       = dp.ReadUInt32(); // 23-24-25-26
                        _RelativeBathyPingNumber = dp.ReadUInt32(); // 27-28-29-30
                    }
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// Initializes a new instance of the RawSerialHeader 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 64 bytes.</param>
        public RawSerialHeader(Byte[] byteArray)
        {
            _HeaderType             = 6;
            _MagicNumber            = 0;
            _SubChannelNumber       = 0;
            _NumberChannelsToFollow = 0;
            _NumberBytesThisRecord  = 64;
            _PacketTime             = DateTime.MinValue;

            _SerialPort   = 0;
            _RawAsciiData = "";
            _TimeTag      = 0;

            UInt16   chkNumber;
            UInt16   Year;
            Byte     Month;
            Byte     Day;
            Byte     Hour;
            Byte     Minutes;
            Byte     Seconds;
            Byte     MSeconds;
            String   TimeString;
            DateTime outTime;
            UInt16   StringSize;

            using (BinaryReader dp = new BinaryReader(ArrayToStream.BytesToMemory(byteArray)))
            {
                if (byteArray.Length >= 64)
                {
                    chkNumber = dp.ReadUInt16(); // 0-1
                    if (chkNumber == XtfDocument.MagicNumber)
                    {
                        dp.ReadByte();                             //HeaderType 2
                        _SubChannelNumber       = dp.ReadByte();   // 3
                        _NumberChannelsToFollow = dp.ReadUInt16(); // 4-5
                        dp.ReadUInt16();                           //Unused 6-7
                        dp.ReadUInt16();                           //Unused 8-9
                        _NumberBytesThisRecord = dp.ReadUInt32();  // 10-11-12-13

                        //Read the ping time values
                        Year     = dp.ReadUInt16(); // 14-15
                        Month    = dp.ReadByte();   // 16
                        Day      = dp.ReadByte();   // 17
                        Hour     = dp.ReadByte();   // 18
                        Minutes  = dp.ReadByte();   // 19
                        Seconds  = dp.ReadByte();   // 20
                        MSeconds = dp.ReadByte();   // 21
                        //Compose the ping time value
                        TimeString = Year.ToString("0000", CultureInfo.InvariantCulture);
                        TimeString = TimeString + "-" + Month.ToString("00", CultureInfo.InvariantCulture);
                        TimeString = TimeString + "-" + Day.ToString("00", CultureInfo.InvariantCulture);
                        TimeString = TimeString + "-" + Hour.ToString("00", CultureInfo.InvariantCulture);
                        TimeString = TimeString + "-" + Minutes.ToString("00", CultureInfo.InvariantCulture);
                        TimeString = TimeString + "-" + Seconds.ToString("00", CultureInfo.InvariantCulture);
                        TimeString = TimeString + "-" + MSeconds.ToString("000", CultureInfo.InvariantCulture);
                        if (DateTime.TryParseExact(TimeString, "yyyy-MM-dd-HH-mm-ss-fff", CultureInfo.InvariantCulture, DateTimeStyles.None, out outTime))
                        {
                            _PacketTime = outTime;
                        }
                        else
                        {
                            _PacketTime = DateTime.MinValue;
                        }

                        dp.ReadUInt16();              // 22-23 Julian Day
                        _TimeTag   = dp.ReadUInt32(); // 24-25-26-27
                        StringSize = dp.ReadUInt16(); // 28-29
                        if (_NumberBytesThisRecord >= (StringSize + 30))
                        {
                            _RawAsciiData = new String(dp.ReadChars(StringSize));
                        }
                        else
                        {
                            _RawAsciiData = new String(dp.ReadChars(Convert.ToInt32(_NumberBytesThisRecord - 30)));
                        }
                    }
                }
            }
        }
Exemple #6
0
        /// <summary>
        /// Initializes a new instance of the Navigation 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 64 bytes.</param>
        public Navigation(Byte[] byteArray)
        {
            _HeaderType             = 42;
            _MagicNumber            = 0;
            _SubChannelNumber       = 0;
            _NumberChannelsToFollow = 0;
            _NumberBytesThisRecord  = 64;
            _PacketTime             = DateTime.MinValue;

            _TimeTag           = 0;
            _SourceEpoch       = 0;
            _RawCoordinateX    = 0;
            _RawCoordinateY    = 0;
            _RawAltitude       = 0;
            _TimestampValidity = 0;

            UInt16   chkNumber;
            UInt16   Year;
            Byte     Month;
            Byte     Day;
            Byte     Hour;
            Byte     Minutes;
            Byte     Seconds;
            UInt32   MSeconds;
            String   TimeString;
            DateTime outTime;

            using (BinaryReader dp = new BinaryReader(ArrayToStream.BytesToMemory(byteArray)))
            {
                if (byteArray.Length >= 58)
                {
                    chkNumber = dp.ReadUInt16(); // 0-1
                    if (chkNumber == XtfDocument.MagicNumber)
                    {
                        dp.ReadByte();                             //HeaderType 2
                        _SubChannelNumber       = dp.ReadByte();   // 3
                        _NumberChannelsToFollow = dp.ReadUInt16(); // 4-5
                        dp.ReadUInt16();                           //Unused 6-7
                        dp.ReadUInt16();                           //Unused 8-9
                        _NumberBytesThisRecord = dp.ReadUInt32();  // 10-11-12-13
                        //Read the ping time values
                        Year     = dp.ReadUInt16();                // 14-15
                        Month    = dp.ReadByte();                  // 16
                        Day      = dp.ReadByte();                  // 17
                        Hour     = dp.ReadByte();                  // 18
                        Minutes  = dp.ReadByte();                  // 19
                        Seconds  = dp.ReadByte();                  // 20
                        MSeconds = dp.ReadUInt32();                // 21-22-23-24
                        //Compose the ping time value
                        TimeString = Year.ToString("0000", CultureInfo.InvariantCulture);
                        TimeString = TimeString + "-" + Month.ToString("00", CultureInfo.InvariantCulture);
                        TimeString = TimeString + "-" + Day.ToString("00", CultureInfo.InvariantCulture);
                        TimeString = TimeString + "-" + Hour.ToString("00", CultureInfo.InvariantCulture);
                        TimeString = TimeString + "-" + Minutes.ToString("00", CultureInfo.InvariantCulture);
                        TimeString = TimeString + "-" + Seconds.ToString("00", CultureInfo.InvariantCulture);
                        TimeString = TimeString + "-" + MSeconds.ToString("000000", CultureInfo.InvariantCulture);
                        if (DateTime.TryParseExact(TimeString, "yyyy-MM-dd-HH-mm-ss-ffffff", CultureInfo.InvariantCulture, DateTimeStyles.None, out outTime))
                        {
                            _PacketTime = outTime;
                        }
                        else
                        {
                            _PacketTime = DateTime.MinValue;
                        }

                        _SourceEpoch       = dp.ReadUInt32(); // 25-26-27-28
                        _TimeTag           = dp.ReadUInt32(); // 29-30-31-32
                        _RawCoordinateY    = dp.ReadDouble(); // 33-34-35-36-37-38-39-40
                        _RawCoordinateX    = dp.ReadDouble(); // 41-42-43-44-45-46-47-48
                        _RawAltitude       = dp.ReadDouble(); // 49-50-51-52-53-54-55-56
                        _TimestampValidity = dp.ReadByte();   // 57
                    }
                }
            }
        }
Exemple #7
0
        /// <summary>
        /// Initializes a new instance of the QpsSingleBeam 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 64 bytes.</param>
        public QpsSingleBeam(Byte[] byteArray)
        {
            _HeaderType             = 26;
            _MagicNumber            = 0;
            _SubChannelNumber       = 0;
            _NumberChannelsToFollow = 0;
            _NumberBytesThisRecord  = 64;
            _PacketTime             = DateTime.MinValue;

            _TimeTag          = 0;
            _Id               = 0;
            _SoundVelocity    = 0;
            _Intensity        = 0;
            _Quality          = 0;
            _TwoWayTravelTime = 0;

            UInt16   chkNumber;
            UInt16   Year;
            Byte     Month;
            Byte     Day;
            Byte     Hour;
            Byte     Minutes;
            Byte     Seconds;
            UInt16   MSeconds;
            String   TimeString;
            DateTime outTime;

            using (BinaryReader dp = new BinaryReader(ArrayToStream.BytesToMemory(byteArray)))
            {
                if (byteArray.Length >= 53)
                {
                    chkNumber = dp.ReadUInt16(); // 0-1
                    if (chkNumber == XtfDocument.MagicNumber)
                    {
                        dp.ReadByte();                             //HeaderType 2
                        _SubChannelNumber       = dp.ReadByte();   // 3
                        _NumberChannelsToFollow = dp.ReadUInt16(); // 4-5
                        dp.ReadUInt16();                           //Unused 6-7
                        dp.ReadUInt16();                           //Unused 8-9
                        _NumberBytesThisRecord = dp.ReadUInt32();  // 10-11-12-13

                        _TimeTag          = dp.ReadUInt32();       // 14-15-16-17
                        _Id               = dp.ReadInt32();        // 18-19-20-21
                        _SoundVelocity    = dp.ReadSingle();       // 22-23-24-25
                        _Intensity        = dp.ReadSingle();       // 26-27-28-29
                        _Quality          = dp.ReadInt32();        // 30-31-32-33
                        _TwoWayTravelTime = dp.ReadSingle();       // 34-35-36-37

                        //Read the ping time values
                        Year     = dp.ReadUInt16(); // 38-39
                        Month    = dp.ReadByte();   // 40
                        Day      = dp.ReadByte();   // 41
                        Hour     = dp.ReadByte();   // 42
                        Minutes  = dp.ReadByte();   // 43
                        Seconds  = dp.ReadByte();   // 44
                        MSeconds = dp.ReadUInt16(); // 45-46
                        //Compose the ping time value
                        TimeString = Year.ToString("0000", CultureInfo.InvariantCulture);
                        TimeString = TimeString + "-" + Month.ToString("00", CultureInfo.InvariantCulture);
                        TimeString = TimeString + "-" + Day.ToString("00", CultureInfo.InvariantCulture);
                        TimeString = TimeString + "-" + Hour.ToString("00", CultureInfo.InvariantCulture);
                        TimeString = TimeString + "-" + Minutes.ToString("00", CultureInfo.InvariantCulture);
                        TimeString = TimeString + "-" + Seconds.ToString("00", CultureInfo.InvariantCulture);
                        TimeString = TimeString + "-" + MSeconds.ToString("000", CultureInfo.InvariantCulture);
                        if (DateTime.TryParseExact(TimeString, "yyyy-MM-dd-HH-mm-ss-fff", CultureInfo.InvariantCulture, DateTimeStyles.None, out outTime))
                        {
                            _PacketTime = outTime;
                        }
                        else
                        {
                            _PacketTime = DateTime.MinValue;
                        }
                    }
                }
            }
        }