Exemple #1
0
        public override Location Parse(MessageInput input)
        {
            Match locationMatch =
                new Regex(
                    "IMEI,(\\d{15})," +              // imei
                    "(\\d{4}\\/\\d{2}\\/\\d{2}), " + // date YYYY/mm/dd
                    "(\\d{2}:\\d{2}:\\d{2}), " +     // hh:mm:ss
                    "(N|S), Lat:(\\d+.\\d+), " +     // latitude
                    "(E|W), Lon:(\\d+.\\d+), " +     // longitude
                    "Spd:(\\d+.\\d+)")
                .Match(input.DataMessage.String);

            if (locationMatch.Success)
            {
                input.Client.SetDevice(locationMatch.Groups[1].Value);

                Location location = new Location
                {
                    Device   = input.Client.Device,
                    DateTime = DateTime.Parse($"{locationMatch.Groups[2].Value} {locationMatch.Groups[3].Value}"),
                    Latitude = GpsUtil.ConvertDmmLatToDecimal(locationMatch.Groups[5].Value,
                                                              locationMatch.Groups[4].Value),
                    Longitude = GpsUtil.ConvertDmmLatToDecimal(locationMatch.Groups[7].Value,
                                                               locationMatch.Groups[6].Value),
                    Speed = SpeedUtil.KnotsToKph(locationMatch.Groups[8].Get <decimal>())
                };

                return(location);
            }

            return(null);
        }
        private static Location ParseLocation(MessageInput input)
        {
            GroupCollection lgc =
                new Regex(
                    @"(\d{2})(\d{2})(\d{2})(A|V)(\d{4}.\d{4})(N|S)(\d{5}.\d{4})(E|W)(.{5})(\d{2})(\d{2})(\d{2})(.{6})(1|0{8})L(.{0,8})(...)")
                .Matches(input.DataMessage.String)[0].Groups;

            if (lgc.Count == 17)
            {
                Location location = new Location
                {
                    Device   = input.Client.Device,
                    DateTime = DateTimeUtil.New(lgc[1].Value, lgc[2].Value, lgc[3].Value, lgc[10].Value, lgc[11].Value,
                                                lgc[12].Value),
                    PositionStatus = lgc[4].Value == "F",
                    Latitude       = GpsUtil.ConvertDmmLatToDecimal(lgc[5].Value, lgc[6].Value),
                    Longitude      = GpsUtil.ConvertDmmLongToDecimal(lgc[7].Value, lgc[8].Value),
                    Speed          = decimal.Parse(lgc[9].Value),
                    Heading        = decimal.Parse(lgc[13].Value),
                    Odometer       = long.Parse(lgc[15].Value, NumberStyles.HexNumber)
                };

                return(location);
            }

            return(null);
        }
Exemple #3
0
        public override Location Parse(MessageInput input)
        {
            Match locationMatch =
                new Regex(
                    "simei:(\\d+)," +      // imei
                    "(.*?)" +              // ignore
                    "(\\d{12})," +         // yy mm dd hh mm ss
                    "(A|V)," +             // gps fix
                    "(\\d+.\\d+),(N|S)," + // latitude
                    "(\\d+.\\d+),(E|W)," + // longitude
                    "(\\d+.\\d+),")        // speed
                .Match(input.DataMessage.String);

            if (locationMatch.Success)
            {
                input.Client.SetDevice(locationMatch.Groups[1].Value);

                Location location = new Location
                {
                    Device         = input.Client.Device,
                    DateTime       = NewDateTimeUtil.Convert(DateFormat.YYMMDDHHMMSS, locationMatch.Groups[3].Value),
                    PositionStatus = locationMatch.Groups[4].Value == "A",
                    Latitude       = GpsUtil.ConvertDmmLatToDecimal(locationMatch.Groups[5].Value,
                                                                    locationMatch.Groups[6].Value),
                    Longitude = GpsUtil.ConvertDmmLongToDecimal(locationMatch.Groups[7].Value,
                                                                locationMatch.Groups[8].Value),
                    Speed = locationMatch.Groups[9].Get <decimal?>()
                };

                return(location);
            }

            return(null);
        }
        public override Location Parse(MessageInput input)
        {
            Match locationMatch =
                new Regex("\\((\\d+)" +        // imei
                          "(.*?)(\\d{12})" +   // date time yy mm dd hh mm ss
                          "(A|V)" +            // gps fix
                          "(\\d+.\\d+)(N|S)" + // latitude
                          "(\\d+.\\d+)(E|W)" + // longitude
                          "(\\d{3}.\\d)" +     // speed
                          "(\\d+.\\d+)")       // heading
                .Match(input.DataMessage.String);

            if (locationMatch.Success)
            {
                Location location = new Location
                {
                    Device = new Device
                    {
                        DeviceId = locationMatch.Groups[1].Value
                    },
                    DateTime       = NewDateTimeUtil.Convert(DateFormat.YYMMDDHHMMSS, locationMatch.Groups[3].Value),
                    PositionStatus = locationMatch.Groups[4].Value == "A",
                    Latitude       = GpsUtil.ConvertDmmLatToDecimal(locationMatch.Groups[5].Value, locationMatch.Groups[6].Value),
                    Longitude      = GpsUtil.ConvertDmmLongToDecimal(locationMatch.Groups[7].Value, locationMatch.Groups[8].Value),
                    Speed          = locationMatch.Groups[9].Get <decimal?>(),
                    Heading        = locationMatch.Groups[10].Get <decimal?>()
                };

                return(location);
            }

            return(null);
        }
Exemple #5
0
        public override Location Parse(MessageInput input)
        {
            MeiligaoInputMessage inputMessage = new MeiligaoInputMessage(input.DataMessage);

            HandleMessage(input, inputMessage);

            if (inputMessage.MeiligaoDataMessage != null)
            {
                Location location = new Location
                {
                    Device = new Device {
                        IMEI = inputMessage.DeviceIdTrimmed
                    },
                    PositionStatus = inputMessage.MeiligaoDataMessage.GPRMCArray[1] == "A",
                    Latitude       = GpsUtil.ConvertDmmLatToDecimal(inputMessage.MeiligaoDataMessage.GPRMCArray[2],
                                                                    inputMessage.MeiligaoDataMessage.GPRMCArray[3]),
                    Longitude = GpsUtil.ConvertDmmLongToDecimal(inputMessage.MeiligaoDataMessage.GPRMCArray[4],
                                                                inputMessage.MeiligaoDataMessage.GPRMCArray[5]),
                    DateTime = GetDateTime(inputMessage.MeiligaoDataMessage.GPRMCArray[0],
                                           inputMessage.MeiligaoDataMessage.GPRMCArray[8]),
                    Speed    = SpeedUtil.KnotsToKph(inputMessage.MeiligaoDataMessage.GPRMCArray.Get <decimal>(6)),
                    Heading  = inputMessage.MeiligaoDataMessage.GPRMCArray.Get <decimal?>(7),
                    HDOP     = inputMessage.MeiligaoDataMessage.StringSplit.Get <decimal?>(1),
                    Altitude = inputMessage.MeiligaoDataMessage.StringSplit.Get <decimal?>(2),
                    Odometer = inputMessage.MeiligaoDataMessage.StringSplit.Get <uint?>(7)
                };

                return(location);
            }

            return(null);
        }
        private static Location Location(MessageInput input)
        {
            Match locationMatch =
                new Regex(
                    _pattern)
                .Match(input.DataMessage.String);

            if (locationMatch.Success)
            {
                Location location = new Location
                {
                    Device = new Device
                    {
                        DeviceId = locationMatch.Groups[1].Value
                    },
                    DateTime = NewDateTimeUtil.Convert(DateFormat.DDMMYYHHMMSS,
                                                       $"{locationMatch.Groups[10].Value}{locationMatch.Groups[2].Value}"),
                    Latitude = GpsUtil.ConvertDmmLatToDecimal(locationMatch.Groups[4].Value,
                                                              locationMatch.Groups[5].Value),
                    Longitude = GpsUtil.ConvertDmmLongToDecimal(locationMatch.Groups[6].Value,
                                                                locationMatch.Groups[7].Value),
                    Speed   = SpeedUtil.KnotsToKph(locationMatch.Groups[8].Get <decimal>()),
                    Heading = locationMatch.Groups[9].Get <decimal>()
                };

                SendLocationAcknowledge(locationMatch.Groups[3].Value, locationMatch.Groups[11].Value,
                                        locationMatch.Groups[17].Value, input);

                return(location);
            }

            return(null);
        }
        private static decimal GetCoordinate(string value, char locatingIndicator, int index, string regex)
        {
            Match locationMatch =
                new Regex("(\\d{4})(\\d{4})")
                .Match(value);

            string direction = BitUtil.IsTrue(locatingIndicator, 1) ? "N" : "S";

            return(GpsUtil.ConvertDmmLatToDecimal($"{locationMatch.Groups[1].Value}.{locationMatch.Groups[2].Value}",
                                                  direction));
        }
        public override Location Parse(MessageInput input)
        {
            Match locationMatch =
                new Regex("\\$\\$" +                             // header
                          "(\\d+)(.*?)" +                        // device id
                          "&A(\\d{4})" +                         // command
                          "&B" +                                 // gps data header
                          "(\\d{2})(\\d{2})(\\d{2}).(\\d{3})," + // hh mm ss . sss
                          "(A|V)," +                             // position status
                          "(\\d{4}.\\d{4}),(N|S)," +             // latitude
                          "(\\d{5}.\\d{4}),(E|W)," +             // longitude
                          "(.*?)," +                             // speed
                          "(.*?)," +                             // heading
                          "(\\d{2})(\\d{2})(\\d{2})," +          // dd mm yy
                          "(.*?)" +
                          "\\*(..)\\|" +                         // checksum
                          "(.*)\\|" +                            // hdop
                          "&C(\\d+)" +                           // io
                          "&D(.*?)" +                            // odometer
                          "&E(\\d+)" +                           // alarm
                          "(&Y(\\d+)|)" +                        // ad
                          "(#*)")                                // end
                .Match(input.DataMessage.String);

            if (locationMatch.Groups.Count == 27)
            {
                Location location = new Location
                {
                    Device = new Device
                    {
                        IMEI = locationMatch.Groups[1].Value
                    },
                    DateTime = DateTimeUtil.New(locationMatch.Groups[17].Value,
                                                locationMatch.Groups[16].Value,
                                                locationMatch.Groups[15].Value,
                                                locationMatch.Groups[4].Value,
                                                locationMatch.Groups[5].Value,
                                                locationMatch.Groups[6].Value,
                                                locationMatch.Groups[7].Value),
                    PositionStatus = locationMatch.Groups[8].Value == "A",
                    Latitude       = GpsUtil.ConvertDmmLatToDecimal(locationMatch.Groups[9].Value, locationMatch.Groups[10].Value),
                    Longitude      = GpsUtil.ConvertDmmLatToDecimal(locationMatch.Groups[11].Value, locationMatch.Groups[12].Value),
                    Speed          = SpeedUtil.KnotsToKph(locationMatch.Groups[13].Get <decimal>()),
                    Heading        = locationMatch.Groups[14].Get <decimal?>() / 10,
                    HDOP           = locationMatch.Groups[20].Get <decimal?>() / 10,
                    Odometer       = GetOdometer(locationMatch.Groups[22].Value)
                };

                return(location);
            }

            return(null);
        }
        public override Location Parse(MessageInput input)
        {
            Match locationMatch =
                new Regex("(\\()" +
                          "(\\d{15})" +                                        // IMEI
                          "(U\\d\\d\\d)" +                                     // Type
                          "(\\d)" +                                            // GPS Type
                          "(A|V)" +                                            // Position status
                          "(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})" + // Date yy mm dd hh mm ss
                          "(\\d{4}.\\d{4})(N|S)" +                             // Latitude dd mm.mmmm N/S
                          "(\\d{5}.\\d{4})(E|W)" +                             // Longitude ddd mm.mmmm E/W
                          "(\\d{3})" +                                         // Speed
                          "(\\d{3})" +                                         // Heading
                          "(.{3})" +                                           // Altitude HEX
                          "(.{8})" +                                           // Odometer HEX
                          "(.)" +                                              // Satellites HEX
                          "(\\d{2})" +                                         // HDOP
                          "(\\d{2})" +                                         // GSM signal
                          "(.*)" +                                             // ???
                          "\\^(..)")                                           // Checksum
                .Match(input.DataMessage.String);

            if (locationMatch.Groups.Count == 25)
            {
                Location location = new Location
                {
                    Device = new Device
                    {
                        IMEI = locationMatch.Groups[2].Value
                    },
                    PositionStatus = locationMatch.Groups[5].Value == "A",
                    DateTime       = DateTimeUtil.New(locationMatch.Groups[6].Value, locationMatch.Groups[7].Value,
                                                      locationMatch.Groups[8].Value, locationMatch.Groups[9].Value, locationMatch.Groups[10].Value,
                                                      locationMatch.Groups[11].Value),
                    Latitude = GpsUtil.ConvertDmmLatToDecimal(locationMatch.Groups[12].Value,
                                                              locationMatch.Groups[13].Value),
                    Longitude = GpsUtil.ConvertDmmLatToDecimal(locationMatch.Groups[14].Value,
                                                               locationMatch.Groups[15].Value),
                    Speed      = locationMatch.Groups[16].Get <decimal?>(),
                    Heading    = locationMatch.Groups[17].Get <decimal?>(),
                    Altitude   = int.Parse(locationMatch.Groups[18].Value, NumberStyles.HexNumber),
                    Odometer   = int.Parse(locationMatch.Groups[19].Value, NumberStyles.HexNumber),
                    Satellites = short.Parse(locationMatch.Groups[20].Value, NumberStyles.HexNumber),
                    HDOP       = locationMatch.Groups[21].Get <decimal?>(),
                    GsmSignal  = locationMatch.Groups[22].Get <short?>()
                };

                return(location);
            }

            return(null);
        }
Exemple #10
0
        private static Location ParseFormat0(MessageInput input)
        {
            input.NetworkStream.Write(StringUtil.ConvertStringToByteArray("ACK\r"));

            Match locationMatch =
                new Regex("(\\d{15})," +                // imei
                          "(.*)," +                     // skip
                          "(\\d)," +                    // gps fix
                          "(\\d{2})(\\d{2})(\\d{2})," + // dd mm yy
                          "(\\d{2})(\\d{2})(\\d{2})," + // hh mm ss
                          "(E|W)(\\d+.\\d+)," +         // longitude
                          "(N|S)(\\d+.\\d+)," +         // latitude
                          "(\\d+)," +                   // altitude
                          "(.*?)," +                    // speed
                          "(\\d+)," +                   // heading
                          "(\\d+)," +                   // number of satellites
                          "(.*?)")                      // hdop
                .Match(input.DataMessage.String);

            if (locationMatch.Success)
            {
                input.Client.SetDevice(locationMatch.Groups[1].Value);

                Location location = new Location
                {
                    Device   = input.Client.Device,
                    DateTime = DateTimeUtil.New(
                        locationMatch.Groups[6].Value,
                        locationMatch.Groups[5].Value,
                        locationMatch.Groups[4].Value,
                        locationMatch.Groups[7].Value,
                        locationMatch.Groups[8].Value,
                        locationMatch.Groups[9].Value),
                    PositionStatus = locationMatch.Groups[3].Value != "1",
                    Longitude      = GpsUtil.ConvertDmmLongToDecimal(locationMatch.Groups[11].Value,
                                                                     locationMatch.Groups[10].Value),
                    Latitude = GpsUtil.ConvertDmmLatToDecimal(locationMatch.Groups[13].Value,
                                                              locationMatch.Groups[12].Value),
                    Altitude   = locationMatch.Groups[14].Get <decimal?>(),
                    Speed      = SpeedUtil.KnotsToKph(locationMatch.Groups[15].Get <decimal>()),
                    Heading    = locationMatch.Groups[16].Get <decimal?>(),
                    Satellites = locationMatch.Groups[17].Get <short?>(),
                    HDOP       = locationMatch.Groups[18].Get <decimal?>()
                };

                return(location);
            }

            return(null);
        }
        public override Location Parse(MessageInput input)
        {
            // TODO: join patterns
            GroupCollection lgc =
                new Regex(
                    @"GPRMC,(\d{2})(\d{2})(\d{2}).(\d{3}),(A|V),(\d{4}.\d{4}),(N|S),(\d{5}.\d{4}),(E|W),(.*?),(.*?),(\d{2})(\d{2})(\d{2})(.*?\*..,)(\w)(.*?imei:)(\d{15})")
                .Matches(input.DataMessage.String)[0].Groups;

            if (lgc.Count == 19)
            {
                Location location = new Location
                {
                    Device = new Device
                    {
                        IMEI = lgc[18].Value
                    },
                    DateTime = DateTimeUtil.New(lgc[12].Value, lgc[13].Value, lgc[14].Value, lgc[1].Value, lgc[2].Value,
                                                lgc[3].Value, lgc[4].Value),
                    PositionStatus = lgc[16].Value == "F",
                    Latitude       = GpsUtil.ConvertDmmLatToDecimal(lgc[6].Value, lgc[7].Value),
                    Longitude      = GpsUtil.ConvertDmmLongToDecimal(lgc[8].Value, lgc[9].Value),
                    Speed          = SpeedUtil.KnotsToKph(lgc[10].Get <decimal>()),
                    Heading        = string.IsNullOrEmpty(lgc[11].Value) ? default(decimal?) : decimal.Parse(lgc[11].Value)
                };

                MatchCollection extra =
                    new Regex(@"(.*?imei:)(\d{15}),(\d+),(.*?),(F:)(.*?)V,(1|0),(.*?),(.*?),(\d+),(\d+),(.*?),(\d+)")
                    .Matches(input.DataMessage.String);

                if (extra.Any())
                {
                    GroupCollection match = extra[0].Groups;

                    if (match.Count == 14)
                    {
                        location.Satellites        = short.Parse(match[3].Value);
                        location.Altitude          = decimal.Parse(match[4].Value);
                        location.MobileCountryCode = int.Parse(match[10].Value);
                        location.MobileNetworkCode = int.Parse(match[11].Value, NumberStyles.HexNumber);
                        location.LocationAreaCode  = int.Parse(match[12].Value, NumberStyles.HexNumber);
                        location.CellId            = int.Parse(match[13].Value, NumberStyles.HexNumber);
                    }
                }

                return(location);
            }

            return(null);
        }
        public override Location Parse(MessageInput input)
        {
            Match locationMatch =
                new Regex("#(\\d+)#" +                  //imei
                          "(.*?)#" +                    // username
                          "(.*?)#" +                    // acc status
                          "(.*?)#" +                    // extend byte
                          "(.*?)#" +                    // data type
                          "(.*?)#" +                    // extend byte
                          "(.*?)#" +                    // lbs
                          "(\\d+.\\d+),(E|W)," +        // longitude
                          "(\\d+.\\d+),(N|S)," +        // latitude
                          "(.*)?," +                    // speed
                          "(\\d+)#" +                   // heading
                          "(\\d{2})(\\d{2})(\\d{2})#" + // date dd mm yy
                          "(\\d{2})(\\d{2})(\\d{2})#")  // time hh mm ss
                .Match(input.DataMessage.String);

            if (locationMatch.Groups.Count == 20)
            {
                Location location = new Location
                {
                    Device = new Device
                    {
                        IMEI = locationMatch.Groups[1].Value
                    },
                    DateTime = DateTimeUtil.New(
                        locationMatch.Groups[16].Value,
                        locationMatch.Groups[15].Value,
                        locationMatch.Groups[14].Value,
                        locationMatch.Groups[17].Value,
                        locationMatch.Groups[18].Value,
                        locationMatch.Groups[19].Value),
                    Latitude = GpsUtil.ConvertDmmLatToDecimal(locationMatch.Groups[10].Value,
                                                              locationMatch.Groups[11].Value),
                    Longitude = GpsUtil.ConvertDmmLongToDecimal(locationMatch.Groups[8].Value,
                                                                locationMatch.Groups[9].Value),
                    Speed          = SpeedUtil.KnotsToKph(locationMatch.Groups[12].Get <decimal>()),
                    Heading        = locationMatch.Groups[15].Get <decimal>(),
                    Odometer       = long.Parse(locationMatch.Groups[18].Value, NumberStyles.HexNumber),
                    PositionStatus = locationMatch.Groups[7].Value != "V"
                };

                return(location);
            }

            return(null);
        }
Exemple #13
0
        private static Location ParseFormatAlternative(MessageInput input)
        {
            Match locationMatch =
                new Regex("(\\d+)," +                   // imei
                          "(\\d)," +                    // skip
                          "(\\d+)," +                   // gps fix
                          "(\\d{2})(\\d{2})(\\d{2})," + // dd mm yy
                          "(\\d{2})(\\d{2})(\\d{2})," + // hh mm ss
                          "(E|W)(\\d+.\\d+)," +         // longitude
                          "(N|S)(\\d+.\\d+)," +         // latitude
                          "(\\d+.\\d+)," +              // altitude
                          "(\\d+.\\d+)," +              // speed
                          "(.*?|)," +                   // heading
                          "(\\d+)" +                    // satellites
                          "(,(\\d+.\\d+)|)")            // hdop
                .Match(input.DataMessage.String);

            if (locationMatch.Groups.Count == 20)
            {
                Location location = new Location
                {
                    Device = new Device
                    {
                        IMEI = locationMatch.Groups[1].Value
                    },
                    DateTime = DateTimeUtil.New(
                        locationMatch.Groups[6].Value,
                        locationMatch.Groups[5].Value,
                        locationMatch.Groups[4].Value,
                        locationMatch.Groups[7].Value,
                        locationMatch.Groups[8].Value,
                        locationMatch.Groups[9].Value),
                    PositionStatus = locationMatch.Groups[2].Value != "1",
                    Longitude      = GpsUtil.ConvertDmmLongToDecimal(locationMatch.Groups[11].Value, locationMatch.Groups[10].Value),
                    Latitude       = GpsUtil.ConvertDmmLatToDecimal(locationMatch.Groups[13].Value, locationMatch.Groups[12].Value),
                    Altitude       = locationMatch.Groups[14].Get <decimal?>(),
                    Speed          = SpeedUtil.KnotsToKph(locationMatch.Groups[15].Get <decimal>()),
                    Heading        = locationMatch.Groups[16].Get <decimal?>(),
                    Satellites     = locationMatch.Groups[17].Get <short?>(),
                    HDOP           = locationMatch.Groups[18].Get <decimal?>()
                };

                return(location);
            }

            return(null);
        }
        private static Location ParseLocation(MessageInput input)
        {
            if (input.Client.Device == null)
            {
                return(null);
            }

            Match locationMatch =
                new Regex(
                    "GPRMC," +
                    "(\\d{2})(\\d{2})(\\d{2})(.|)(\\d+|)," + // hh mm ss . sss
                    "(A|V)," +                               // gps fix
                    "(\\d+.\\d+),(N|S)," +                   // latitude
                    "(\\d+.\\d+),(W|E)," +                   // longitude
                    "(\\d+.\\d+)," +                         // speed
                    "(\\d+.\\d+)," +                         // heading
                    "(\\d{2})(\\d{2})(\\d{2}),")             // dd mm yy
                .Match(input.DataMessage.String);

            if (locationMatch.Success)
            {
                Location location = new Location
                {
                    Device   = input.Client.Device,
                    DateTime = DateTimeUtil.New(
                        locationMatch.Groups[15].Value,
                        locationMatch.Groups[14].Value,
                        locationMatch.Groups[13].Value,
                        locationMatch.Groups[1].Value,
                        locationMatch.Groups[2].Value,
                        locationMatch.Groups[3].Value,
                        locationMatch.Groups[5].Value),
                    PositionStatus = locationMatch.Groups[6].Value == "A",
                    Latitude       = GpsUtil.ConvertDmmLatToDecimal(locationMatch.Groups[7].Value, locationMatch.Groups[8].Value),
                    Longitude      = GpsUtil.ConvertDmmLongToDecimal(locationMatch.Groups[9].Value, locationMatch.Groups[10].Value),
                    Speed          = SpeedUtil.KnotsToKph(locationMatch.Groups[11].Get <decimal>()),
                    Heading        = locationMatch.Groups[12].Get <decimal?>()
                };

                return(location);
            }

            return(null);
        }
        public override Location Parse(MessageInput input)
        {
            Match locationMatch =
                new Regex("imei(.)" +
                          "(\\d+)" +                               // imei
                          "(.*?)GPRMC," +
                          "(\\d{2})(\\d{2})(\\d{2}).(\\d{2,3})," + // time hh mm ss . ss(s)
                          "(A|V)," +                               // position status
                          "(\\d{2}\\d{2}.\\d+),(N|S)," +           // latitude
                          "(\\d{2}\\d{3}.\\d+),(E|W)," +           // longitude
                          "(\\d+.\\d+)," +                         // speed
                          "(\\d+.\\d+|)," +                        // heading
                          "(\\d{2})(\\d{2})(\\d{2})")              // date dd mm yy
                .Match(input.DataMessage.String);

            if (locationMatch.Success)
            {
                Location location = new Location
                {
                    Device = new Device
                    {
                        DeviceId = locationMatch.Groups[2].Value
                    },
                    DateTime = DateTimeUtil.New(
                        locationMatch.Groups[17].Value,
                        locationMatch.Groups[16].Value,
                        locationMatch.Groups[15].Value,
                        locationMatch.Groups[4].Value,
                        locationMatch.Groups[5].Value,
                        locationMatch.Groups[6].Value,
                        locationMatch.Groups[7].Value),
                    PositionStatus = locationMatch.Groups[8].Value == "A",
                    Latitude       = GpsUtil.ConvertDmmLatToDecimal(locationMatch.Groups[9].Value, locationMatch.Groups[10].Value),
                    Longitude      = GpsUtil.ConvertDmmLongToDecimal(locationMatch.Groups[11].Value, locationMatch.Groups[12].Value),
                    Speed          = SpeedUtil.KnotsToKph(locationMatch.Groups[14].Get <decimal>()),
                    Heading        = locationMatch.Groups[15].Get <decimal?>()
                };

                return(location);
            }

            return(null);
        }
Exemple #16
0
        public override Location Parse(MessageInput input)
        {
            Match locationMatch =
                new Regex("(\\d{15})," +                                            // imei
                          "(.{6})," +                                               // id code
                          "(\\d{3})," +                                             // status
                          "(L\\d{3})," +                                            // version
                          "(A|V)," +                                                // position status
                          "(\\d+.\\d+),(N|S)," +                                    // latitude dd mm.mmmm N/S
                          "(\\d+.\\d+),(E|W)," +                                    // longitude ddd mm.mmmm E/W
                          "(.*?)," +                                                // speed
                          "(.*?)," +                                                // heading
                          "(.*?)," +                                                // hdop
                          "(\\d{2}):(\\d{2}):(\\d{2}) (\\d{2})-(\\d{2})-(\\d{2}),") // hh:mm:ss dd-mm-yy
                .Match(input.DataMessage.String);

            if (locationMatch.Success)
            {
                Location location = new Location
                {
                    Device = new Device
                    {
                        DeviceId = locationMatch.Groups[1].Value
                    },
                    PositionStatus = locationMatch.Groups[5].Value == "A",
                    Latitude       = GpsUtil.ConvertDmmLatToDecimal(locationMatch.Groups[6].Value,
                                                                    locationMatch.Groups[7].Value),
                    Longitude = GpsUtil.ConvertDmmLatToDecimal(locationMatch.Groups[8].Value,
                                                               locationMatch.Groups[9].Value),
                    Speed    = SpeedUtil.KnotsToKph(locationMatch.Groups[10].Get <decimal>()),
                    Heading  = locationMatch.Groups[11].Get <decimal?>(),
                    HDOP     = locationMatch.Groups[12].Get <decimal?>(),
                    DateTime = DateTimeUtil.New(locationMatch.Groups[18].Value, locationMatch.Groups[17].Value,
                                                locationMatch.Groups[16].Value, locationMatch.Groups[13].Value, locationMatch.Groups[14].Value,
                                                locationMatch.Groups[15].Value)
                };

                return(location);
            }

            return(null);
        }
Exemple #17
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))
            });
        }
        public override Location Parse(MessageInput input)
        {
            int timeIndex = input.DataMessage.CommaSplit[2] == "V1" || input.DataMessage.CommaSplit[2] == "V2" ? 3 : 5;

            input.Client.SetDevice(input.DataMessage.CommaSplit.Get <string>(1));

            Location location = new Location
            {
                Device   = input.Client.Device,
                DateTime = ConvertDate(input.DataMessage.CommaSplit.Get <string>(timeIndex),
                                       input.DataMessage.CommaSplit.Get <string>(timeIndex + 8)),
                PositionStatus = input.DataMessage.CommaSplit.Get <string>(timeIndex + 1) == "A",
                Latitude       = GpsUtil.ConvertDmmLatToDecimal(input.DataMessage.CommaSplit[timeIndex + 2],
                                                                input.DataMessage.CommaSplit[timeIndex + 3]),
                Longitude = GpsUtil.ConvertDmmLongToDecimal(input.DataMessage.CommaSplit[timeIndex + 4],
                                                            input.DataMessage.CommaSplit[timeIndex + 5]),
                Speed   = SpeedUtil.KnotsToKph(input.DataMessage.CommaSplit.Get <decimal>(timeIndex + 6)),
                Heading = input.DataMessage.CommaSplit.Get <decimal?>(timeIndex + 7)
            };

            return(location);
        }
        private static Location Location(MessageInput input)
        {
            input.Client.SetDevice(input.DataMessage.CommaSplit.Get <string>(0).Replace("imei:", Empty));

            Location location = new Location
            {
                Device         = input.Client.Device,
                DateTime       = GetDate(input.DataMessage.CommaSplit.Get <string>(2)),
                PositionStatus = input.DataMessage.CommaSplit.Get <string>(4) == "F",
                Latitude       = GpsUtil.ConvertDmmLatToDecimal(input.DataMessage.CommaSplit[7],
                                                                input.DataMessage.CommaSplit[8]),
                Longitude = GpsUtil.ConvertDmmLongToDecimal(input.DataMessage.CommaSplit[9],
                                                            input.DataMessage.CommaSplit[10]),
                Speed   = SpeedUtil.KnotsToKph(input.DataMessage.CommaSplit.Get <decimal>(11)),
                Heading = input.DataMessage.CommaSplit.Get <string>(12) != "1"
                    ? input.DataMessage.CommaSplit.Get <decimal?>(12)
                    : null,
                Altitude = input.DataMessage.CommaSplit.Get <decimal?>(13),
            };

            return(location);
        }
        private static Location Parse_V3(MessageInput input)
        {
            input.Client.SetDevice(input.DataMessage.CommaSplit[1]);

            Location location = new Location
            {
                Device   = input.Client.Device,
                Latitude = GpsUtil.ConvertDmmLatToDecimal(input.DataMessage.CommaSplit[7],
                                                          input.DataMessage.CommaSplit[8]),
                Longitude = GpsUtil.ConvertDmmLongToDecimal(input.DataMessage.CommaSplit[9],
                                                            input.DataMessage.CommaSplit[10]),
                DateTime   = GetDate(input.DataMessage.CommaSplit[4], input.DataMessage.CommaSplit[5]),
                Satellites = input.DataMessage.CommaSplit.Get <short?>(12),
                HDOP       = input.DataMessage.CommaSplit.Get <decimal?>(14),
                Speed      = SpeedUtil.KnotsToKph(input.DataMessage.CommaSplit.Get <decimal>(15)),
                Heading    = input.DataMessage.CommaSplit.Get <decimal?>(16),
                Altitude   = input.DataMessage.CommaSplit.Get <decimal?>(17),
                Odometer   = input.DataMessage.CommaSplit.Get <double?>(18) * 1000,
                GsmSignal  = input.DataMessage.CommaSplit.Get <short?>(23)
            };

            return(location);
        }