Esempio n. 1
0
 public NovatelEventArgs(Novatel.Message message)
 {
     Message = message;
 }
Esempio n. 2
0
        void packetReceived(object sender, DataEventArgs args)
        {
            byte[] data   = args.Data;
            int    offset = args.Offset;

            Novatel.MessageHeader h = new Novatel.MessageHeader();

            h.HeaderLength    = data[offset + 3];
            h.MessageID       = (Novatel.MessageID)BitConverter.ToUInt16(data, offset + 4);
            h.MessageType     = (Novatel.MessageType)data[offset + 6];
            h.PortAddress     = data[offset + 7];
            h.MessageLength   = BitConverter.ToUInt16(data, offset + 8);
            h.Sequence        = BitConverter.ToUInt16(data, offset + 10);
            h.Idle            = data[offset + 12];
            h.TimeStatus      = (Novatel.TimeStatus)data[offset + 13];
            h.Week            = BitConverter.ToUInt16(data, offset + 14);
            h.MS              = BitConverter.ToUInt32(data, offset + 16);
            h.ReceiverStatus  = BitConverter.ToUInt32(data, offset + 20);
            h.FirmwareVersion = BitConverter.ToUInt16(data, offset + 26);

            Novatel.Message result;

            offset += h.HeaderLength;

            switch (h.MessageID)
            {
            case Novatel.MessageID.BestPos:
            case Novatel.MessageID.MasterPos:
            case Novatel.MessageID.RTKPos:
            {
                Novatel.PositionMessage m = new Novatel.PositionMessage();
                m.SolutionStatus      = (Novatel.SolutionStatus)BitConverter.ToUInt32(data, offset);
                m.PositionType        = (Novatel.PositionType)BitConverter.ToUInt32(data, offset + 4);
                m.Latitude            = BitConverter.ToDouble(data, offset + 8);
                m.Longitude           = BitConverter.ToDouble(data, offset + 16);
                m.Height              = BitConverter.ToDouble(data, offset + 24);
                m.Undulation          = BitConverter.ToSingle(data, offset + 32);
                m.DatumID             = (Novatel.DatumID)BitConverter.ToUInt32(data, offset + 36);
                m.LatitudeDeviation   = BitConverter.ToSingle(data, offset + 40);
                m.LongitudeDeviation  = BitConverter.ToSingle(data, offset + 44);
                m.HeightDeviation     = BitConverter.ToSingle(data, offset + 48);
                m.StationID           = BitConverter.ToUInt32(data, offset + 52);
                m.DifferentialAge     = BitConverter.ToSingle(data, offset + 56);
                m.SolutionAge         = BitConverter.ToSingle(data, offset + 60);
                m.SatelliteCount      = data[offset + 64];
                m.SatellitesUsed      = data[offset + 65];
                m.L1Used              = data[offset + 66];
                m.L1L2Used            = data[offset + 67];
                m.ExtraSolutionStatus = (Novatel.ExtraSolutionStatus)data[offset + 69];
                m.SignalMask          = (Novatel.SignalMask)data[offset + 71];
                result = m;
            }
            break;

            case Novatel.MessageID.BestUTM:
            {
                Novatel.UTMMessage m = new Novatel.UTMMessage();
                m.SolutionStatus      = (Novatel.SolutionStatus)BitConverter.ToUInt32(data, offset);
                m.PositionType        = (Novatel.PositionType)BitConverter.ToUInt32(data, offset + 4);
                m.ZoneNumber          = BitConverter.ToUInt32(data, offset + 8);
                m.ZoneLetter          = BitConverter.ToUInt32(data, offset + 12);
                m.Northing            = BitConverter.ToDouble(data, offset + 16);
                m.Easting             = BitConverter.ToDouble(data, offset + 24);
                m.Height              = BitConverter.ToDouble(data, offset + 32);
                m.Undulation          = BitConverter.ToSingle(data, offset + 40);
                m.DatumID             = (Novatel.DatumID)BitConverter.ToUInt32(data, offset + 44);
                m.NorthingDeviation   = BitConverter.ToSingle(data, offset + 48);
                m.EastingDeviation    = BitConverter.ToSingle(data, offset + 52);
                m.HeightDeviation     = BitConverter.ToSingle(data, offset + 56);
                m.StationID           = BitConverter.ToUInt32(data, offset + 60);
                m.DifferentialAge     = BitConverter.ToSingle(data, offset + 64);
                m.SolutionAge         = BitConverter.ToSingle(data, offset + 68);
                m.SatelliteCount      = data[offset + 72];
                m.SatellitesUsed      = data[offset + 73];
                m.L1Used              = data[offset + 74];
                m.L1L2Used            = data[offset + 75];
                m.ExtraSolutionStatus = (Novatel.ExtraSolutionStatus)data[offset + 77];
                m.SignalMask          = (Novatel.SignalMask)data[offset + 79];
                result = m;
            }
            break;

            case Novatel.MessageID.Heading:
            {
                Novatel.HeadingMessage m = new Novatel.HeadingMessage();
                m.SolutionStatus        = (Novatel.SolutionStatus)BitConverter.ToUInt32(data, offset);
                m.PositionType          = (Novatel.PositionType)BitConverter.ToUInt32(data, offset + 4);
                m.Length                = BitConverter.ToSingle(data, offset + 8);
                m.Heading               = BitConverter.ToSingle(data, offset + 12);
                m.Pitch                 = BitConverter.ToSingle(data, offset + 16);
                m.HeadingDeviation      = BitConverter.ToSingle(data, offset + 24);
                m.PitchDeviation        = BitConverter.ToSingle(data, offset + 28);
                m.StationID             = BitConverter.ToUInt32(data, offset + 32);
                m.SatelliteCount        = data[offset + 36];
                m.SatellitesUsed        = data[offset + 37];
                m.SatellitesAboveMask   = data[offset + 38];
                m.SatellitesAboveMaskL2 = data[offset + 39];
                m.ExtraSolutionStatus   = (Novatel.ExtraSolutionStatus)data[offset + 41];
                m.SignalMask            = (Novatel.SignalMask)data[offset + 43];
                result = m;
            }
            break;

            case Novatel.MessageID.BslnXYZ:
            {
                Novatel.BaselineXYZMessage m = new Novatel.BaselineXYZMessage();
                m.SolutionStatus = (Novatel.SolutionStatus)BitConverter.ToUInt32(data, offset);
                m.PositionType   = (Novatel.PositionType)BitConverter.ToUInt32(data, offset + 4);
                m.X                   = BitConverter.ToDouble(data, offset + 8);
                m.Y                   = BitConverter.ToDouble(data, offset + 16);
                m.Z                   = BitConverter.ToDouble(data, offset + 24);
                m.XDeviation          = BitConverter.ToSingle(data, offset + 32);
                m.YDeviation          = BitConverter.ToSingle(data, offset + 36);
                m.ZDeviation          = BitConverter.ToSingle(data, offset + 40);
                m.StationID           = BitConverter.ToUInt32(data, offset + 44);
                m.SatelliteCount      = data[offset + 48];
                m.SatellitesUsed      = data[offset + 49];
                m.L1Used              = data[offset + 50];
                m.L1L2Used            = data[offset + 51];
                m.ExtraSolutionStatus = (Novatel.ExtraSolutionStatus)data[offset + 53];
                m.SignalMask          = (Novatel.SignalMask)data[offset + 55];
                result                = m;
            }
            break;

            case Novatel.MessageID.PassAUX:
            case Novatel.MessageID.PassCom1:
            case Novatel.MessageID.PassCom2:
            case Novatel.MessageID.PassCom3:
            case Novatel.MessageID.PassUSB1:
            case Novatel.MessageID.PassUSB2:
            case Novatel.MessageID.PassUSB3:
            case Novatel.MessageID.PassXCom1:
            case Novatel.MessageID.PassXCom2:
            case Novatel.MessageID.PassXCom3:
            {
                Novatel.PassMessage m = new Novatel.PassMessage();
                m.Size  = BitConverter.ToUInt32(data, offset);
                m.Bytes = new byte[m.Size];
                Array.Copy(data, offset + 4, m.Bytes, 0, m.Size);
                result = m;
            }
            break;

            default:
            {
                result = new Novatel.Message();
            }
            break;
            }
            result.Header = h;
            if (MessageReceived != null)
            {
                MessageReceived(this, new NovatelEventArgs(result));
            }
        }