public static bool IsLogEntry(string line, ref Hashtable dataEntry) { string pattern = @"\$GPRMC,(\d{6}),(A|V),(\d{4}\.\d{0,4}),(N|S)," + @"(\d{5}\.\d{0,4}),(E|W),(\d+\.\d{0,2}),(\d+\.\d{0,2})," + @"(\d{6}),(\d*\.?\d*),(E|W)?\*((\d|\w){0,2})"; Match lineMatch = Regex.Match(line, pattern, RegexOptions.IgnoreCase); if (!lineMatch.Success) { return(false); } dataEntry["UTCTime"] = lineMatch.Groups[1].ToString(); dataEntry["Status"] = lineMatch.Groups[2].ToString(); dataEntry["Latitude"] = lineMatch.Groups[3].ToString(); dataEntry["NSIndicator"] = lineMatch.Groups[4].ToString(); dataEntry["Longitude"] = lineMatch.Groups[5].ToString(); dataEntry["EWIndicator"] = lineMatch.Groups[6].ToString(); dataEntry["Speed"] = lineMatch.Groups[7].ToString(); dataEntry["Course"] = lineMatch.Groups[8].ToString(); dataEntry["UTCDate"] = lineMatch.Groups[9].ToString(); dataEntry["MagVariation"] = lineMatch.Groups[10].ToString(); dataEntry["MagVarEWInd"] = lineMatch.Groups[11].ToString(); dataEntry["Checksum"] = lineMatch.Groups[12].ToString(); dataEntry["GenLogFormat"] = LogFormat.GPRMC; dataEntry["GenDateTime"] = LogGPRMC.GetEntryDateTime( dataEntry["UTCTime"].ToString(), dataEntry["UTCDate"].ToString()); return(true); }
public static LogBase CreateLogInstance(LogFormat format) { LogBase logInstance = null; switch (format) { case LogFormat.GPRMC: logInstance = new LogGPRMC(); break; case LogFormat.OziExplorer: logInstance = new LogOziExplorer(); break; } return logInstance; }
public static LogBase CreateLogInstance(LogFormat format) { LogBase logInstance = null; switch (format) { case LogFormat.GPRMC: logInstance = new LogGPRMC(); break; case LogFormat.OziExplorer: logInstance = new LogOziExplorer(); break; } return(logInstance); }
public override void ParseStringData(string dataString) { string[] lines = dataString.Split('\n'); foreach (string line in lines) { Hashtable dataEntry = new Hashtable(); if (!LogGPRMC.IsLogEntry(line, ref dataEntry)) { continue; } this.dataArray.Add(dataEntry); if (dataArray.Count == 1) { this.start = (DateTime)dataEntry["GenDateTime"]; this.end = (DateTime)dataEntry["GenDateTime"]; } this.UpdateLogStartEnd((DateTime)dataEntry["GenDateTime"]); } }
public static LogFormat DetectLogFormatFromString(ref string dataString) { Hashtable dummyEntry = new Hashtable(); LogFormat format = LogFormat.Unknown; string[] lines = dataString.Split('\n'); foreach (string line in lines) { if (LogGPRMC.IsLogEntry(line, ref dummyEntry)) { format = LogFormat.GPRMC; break; } if (LogOziExplorer.IsLogEntry(line, ref dummyEntry)) { format = LogFormat.OziExplorer; break; } } return(format); }