// Input example: $GPRMC,102156.000,A,2232.4690,N,11403.6847,E,0.00,,180909,,*15 public static GPRMC Parse(string input) { Match match = new Regex("(\\d{2}\\d{2}\\d{2}.\\d+)," + // dd mm yy "(A|V)," + // gps fix "(\\d+.\\d+),(N|S)," + // latitude "(\\d+.\\d+),(E|W)," + // longitude "(.*?)," + // speed "(.*?)," + // heading "(\\d{2}\\d{2}\\d{2})") // hh mm ss . ss .Match(input); if (match.Success) { GPRMC gprmc = new GPRMC { DateTime = NewDateTimeUtil.Convert(DateFormat.HHMMSS_SS_DDMMYY, match.Groups[1].Value, match.Groups[9].Value), PositionStatus = match.Groups[2].Value == "A", Latitude = GpsUtil.ConvertDmmLatToDecimal(match.Groups[3].Value, match.Groups[4].Value), Longitude = GpsUtil.ConvertDmmLongToDecimal(match.Groups[5].Value, match.Groups[6].Value), Speed = SpeedUtil.KnotsToKph(match.Groups[7].Get <decimal>()), Heading = match.Groups[8].Get <decimal?>() }; return(gprmc); } return(null); }
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); }
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 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); }
public void Test() { //TReg.Init(); Console.WriteLine("模板处理……"); SpeedUtil.Start(); loopThird(); SpeedUtil.Stop(); }
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); }
// Input example: $GPRMC,102156.000,A,2232.4690,N,11403.6847,E,0.00,,180909,,*15 public GPRMC(string input) { input = input.Replace("$GPRMC,", String.Empty); string[] split = input.Split(","); PositionStatus = split[1] == "A"; DateTime = GetDateTime(split[0], split[8]); Latitude = GpsUtil.ConvertDmmLatToDecimal(split[2], split[3]); Longitude = GpsUtil.ConvertDmmLongToDecimal(split[4], split[5]); Speed = SpeedUtil.KnotsToKph(split.Get <decimal>(6)); Heading = split.Get <decimal?>(7); }
public override Location Parse(MessageInput input) { Match locationMatch = new Regex("24" + // header "(\\d{10})" + // terminal id "(.)" + // protocol version "(.)" + // data type "(.{4})" + // data length "(\\d{2})(\\d{2})(\\d{2})" + // dd mm yy "(\\d{2})(\\d{2})(\\d{2})" + // hh mm ss "(\\d{8})" + // latitude dd mm . mmmm "(\\d{9})" + // longitude ddd mm . mmmm "(.)" + // locating indication "(.{2})" + // speed "(.{2})" + // direction "(.{2})" + // fuel level high 8 bit "(.{8})" + // status "(.{8})" + // mileage "(.{2})" + // fuel level low 8 bit "(.{2})") // message serial number .Match(input.DataMessage.HexString); if (locationMatch.Groups.Count == 21) { Location location = new Location { Device = new Device { IMEI = locationMatch.Groups[1].Value }, DateTime = DateTimeUtil.New( locationMatch.Groups[7].Value, locationMatch.Groups[6].Value, locationMatch.Groups[5].Value, locationMatch.Groups[8].Value, locationMatch.Groups[9].Value, locationMatch.Groups[10].Value), Latitude = GetCoordinate(locationMatch.Groups[11].Value, locationMatch.Groups[13].Value[0], 1, "(\\d{4})(\\d{4})"), Longitude = GetCoordinate(locationMatch.Groups[12].Value, locationMatch.Groups[13].Value[0], 2, "(\\d{5})(\\d{4})"), Speed = SpeedUtil.KnotsToKph(int.Parse(locationMatch.Groups[14].Value, NumberStyles.HexNumber)), Heading = int.Parse(locationMatch.Groups[15].Value, NumberStyles.HexNumber), Odometer = long.Parse(locationMatch.Groups[18].Value, NumberStyles.HexNumber), PositionStatus = BitUtil.IsTrue(locationMatch.Groups[13].Value[0], 0) }; return(location); } return(null); }
public static void InitMetaData() { SpeedUtil.Start(); MappingClass.Clear(); int count = MappingClass.Instance.ClassList.Count; resetConnection(); Console.WriteLine("初始化成功!"); Console.WriteLine(); SpeedUtil.Stop(); }
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); }
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); }
public override Location Parse(MessageInput input) { Match locationMatch = new Regex("GPRS(\\d{15})," + // imei "(.*?)," + // version "(\\d{2})(\\d{2})(\\d{2})," + // yy mm dd "(\\d{2})(\\d{2})(\\d{2})," + // hh mm ss "(\\d)" + // flags "(\\d{2})(\\d{5})" + // latitude "(\\d{3})(\\d{5})," + // longitude "(\\d+)," + // speed "(\\d+)," + // heading "(\\d+)," + // status "(.*?)," + // gprs count value "(.*?)," + // gps power saving counting value "(.*?)," + // switch status "(.*?)" + // voltage "#V(\\d+)") // battery .Match(input.DataMessage.String); if (locationMatch.Groups.Count == 22) { int flags = locationMatch.Groups[9].Get <int>(); Location location = new Location { Device = new Device { IMEI = locationMatch.Groups[1].Value }, DateTime = DateTimeUtil.New(locationMatch.Groups[3].Value, locationMatch.Groups[4].Value, locationMatch.Groups[5].Value, locationMatch.Groups[6].Value, locationMatch.Groups[7].Value, locationMatch.Groups[8].Value), Latitude = GetCoordinate(locationMatch, 10, 11, flags, 2), Longitude = GetCoordinate(locationMatch, 12, 13, flags, 1), Speed = SpeedUtil.KnotsToKph(locationMatch.Groups[14].Get <decimal>() / 10), Heading = locationMatch.Groups[15].Get <decimal?>() / 10 }; 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); }
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); }
public void single() { ConsoleTitleUtil.ShowTestTitle("single"); string a = @" <h4> {#Title#}</h4> <b>{#CreateTime#}</b><br /> " ; SpeedUtil.Start(); Template t = new Template(); t.InitContent(a); t.Set("Title", "一百航的诗篇"); t.Set("CreateTime", "今年的时间 " + DateTime.Now); Console.WriteLine(t); SpeedUtil.Stop(); }
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); }
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 void SetData(string dataString, Location location) { string[] data = dataString.Split(","); string[] dataKey = DefaultDataFormat.Split(","); for (int i = 0; i < Math.Min(data.Length, dataKey.Length); i++) { if (dataKey[i] == "#LAT#") { location.Latitude = GetCoordinate(data[i]); } if (dataKey[i] == "#LONG#") { location.Longitude = GetCoordinate(data[i]); } if (dataKey[i] == "#SPD#") { location.Speed = SpeedUtil.KnotsToKph(Convert.ToDecimal(data[i])); } if (dataKey[i] == "#HEAD#") { location.Heading = Convert.ToDecimal(data[i]); } if (dataKey[i] == "#ODO#") { location.Odometer = Convert.ToDouble(data[i]) * 1000; } if (dataKey[i] == "#EDT#") { location.DateTime = NewDateTimeUtil.Convert(DateFormat.YYMMDDHHMMSS, data[i]); } } }
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); }