Exemple #1
0
        private static IEnumerable <Location> ParseText(MessageInput input)
        {
            if (input.DataMessage.CommaSplit.Length > 14)
            {
                input.Client.SetDevice(input.DataMessage.CommaSplit[1]);

                Location location = new Location
                {
                    Device         = input.Client.Device,
                    Latitude       = input.DataMessage.CommaSplit.Get <decimal>(4),
                    Longitude      = input.DataMessage.CommaSplit.Get <decimal>(5),
                    DateTime       = ConvertDate(input.DataMessage.CommaSplit[6]),
                    PositionStatus = input.DataMessage.CommaSplit.Get <string>(7) == "A",
                    Satellites     = input.DataMessage.CommaSplit.Get <short>(8),
                    GsmSignal      = GsmUtil.ConvertSignal(input.DataMessage.CommaSplit.Get <short>(9)),
                    Speed          = input.DataMessage.CommaSplit.Get <decimal?>(10),
                    Heading        = input.DataMessage.CommaSplit.Get <decimal?>(11),
                    HDOP           = input.DataMessage.CommaSplit.Get <decimal?>(12),
                    Altitude       = input.DataMessage.CommaSplit.Get <int>(13),
                    Odometer       = input.DataMessage.CommaSplit.Get <uint>(14)
                };

                return(new[] { location });
            }

            return(null);
        }
Exemple #2
0
        private static Location ParseLocation_AT09(MessageInput input)
        {
            input.Client.SetDevice(input.DataMessage.Reader.Skip(8).GetUntil('|'));

            return(new Location
            {
                Device = input.Client.Device,
                DateTime = ConvertDate(input.DataMessage.Reader.Skip(8).Get(12)),
                Satellites = Convert.ToInt16(input.DataMessage.Reader.Skip(36).Get(2)),
                GsmSignal = GsmUtil.ConvertSignal(Convert.ToInt16(input.DataMessage.Reader.Get(2))),
                Heading = Convert.ToInt32(input.DataMessage.Reader.Get(3)),
                Speed = Convert.ToInt32(input.DataMessage.Reader.Get(3)),
                HDOP = decimal.Parse(input.DataMessage.Reader.Get(4)),
                Odometer = uint.Parse(input.DataMessage.Reader.Get(7)),
                Latitude = GpsUtil.ConvertDmmLatToDecimal(input.DataMessage.Reader.Get(9),
                                                          input.DataMessage.Reader.Get(1)),
                Longitude = GpsUtil.ConvertDmmLongToDecimal(input.DataMessage.Reader.Get(10),
                                                            input.DataMessage.Reader.Get(1))
            });
        }
 private static Location ParseLocation_AT09(MessageInput input)
 {
     return(new Location
     {
         Device = new Device
         {
             IMEI = input.DataMessage.Reader.Skip(8).GetUntil('|')
         },
         DateTime = ConvertDate(input.DataMessage.Reader.Skip(8).Get(12)),
         Satellites = Convert.ToInt16(input.DataMessage.Reader.Skip(36).Get(2)),
         GsmSignal = GsmUtil.ConvertSignal(Convert.ToInt16(input.DataMessage.Reader.Get(2))),
         Heading = Convert.ToInt32(input.DataMessage.Reader.Get(3)),
         Speed = Convert.ToInt32(input.DataMessage.Reader.Get(3)),
         HDOP = double.Parse(input.DataMessage.Reader.Get(4)),
         Odometer = uint.Parse(input.DataMessage.Reader.Get(7)),
         Latitude = GpsUtil.ConvertDegreeAngleToDouble(@"(\d{2})(\d{2}).(\d{4})",
                                                       input.DataMessage.Reader.Get(9), input.DataMessage.Reader.Get(1)),
         Longitude = GpsUtil.ConvertDegreeAngleToDouble(@"(\d{3})(\d{2}).(\d{4})",
                                                        input.DataMessage.Reader.Get(10), input.DataMessage.Reader.Get(1))
     });
 }
        public override Location Parse(MessageInput input)
        {
            Location location = new Location
            {
                Device = new Device
                {
                    IMEI = input.DataMessage.CommaSplit[1]
                },
                Latitude       = input.DataMessage.CommaSplit.Get <decimal>(4),
                Longitude      = input.DataMessage.CommaSplit.Get <decimal>(5),
                DateTime       = ConvertDate(input.DataMessage.CommaSplit[6]),
                PositionStatus = input.DataMessage.CommaSplit.Get <string>(7) == "A",
                Satellites     = input.DataMessage.CommaSplit.Get <short>(8),
                GsmSignal      = GsmUtil.ConvertSignal(input.DataMessage.CommaSplit.Get <short>(9)),
                Speed          = input.DataMessage.CommaSplit.Get <float>(10),
                Heading        = input.DataMessage.CommaSplit.Get <float>(11),
                HDOP           = input.DataMessage.CommaSplit.Get <double>(12),
                Altitude       = input.DataMessage.CommaSplit.Get <int>(13),
                Odometer       = input.DataMessage.CommaSplit.Get <uint>(14)
            };

            return(location);
        }