private void frmFileReplayCloseToolStripMenuItem_Click(object sender, EventArgs e) { this._playState = _playStates.IDLE; if (this._fileHdlr != null) { this._fileHdlr.Close(); } this._fileHdlr = null; this._logFileName = string.Empty; this.Text = "Idle"; this.frmFileReplayOpenToolStripMenuItem.Enabled = true; }
private void frmFileReplayOpenToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.Title = "Specify log file name:"; dialog.InitialDirectory = @"..\..\logs\"; dialog.Filter = "GP2 (*.gp2)|*.gp2|GPS (*.gps)|*.gps|All files (*.*)|*.*"; dialog.FilterIndex = 1; dialog.CheckPathExists = false; dialog.CheckFileExists = false; if (dialog.ShowDialog() != DialogResult.OK) { return; } this._logFileName = dialog.FileName; this.Text = "Open: " + this._logFileName; this._fileHdlr = new LargeFileHandler(this._logFileName); this._totalFileSize = this._fileHdlr.Length; this.frmFileReplayTrackBar.Value = 0; this.frmFileReplayTrackBar.Maximum = 100; this.frmFileReplayTrackBar.Minimum = 0; this._playState = _playStates.IDLE; this._lastPlayState = this._playState; this.comm.MessageProtocol = this.cboProtocols.SelectedItem.ToString(); string[] strArray = this._logFileName.Split(new char[] { '.' }); if (strArray.Length != 2) { return; } string str = strArray[1].ToUpper(); if (str != null) { if (!(str == "GP2") && !(str == "GPX")) { if (str == "GPS") { this._viewType = CommonClass.TransmissionType.GPS; this._fileType = CommonClass.TransmissionType.GPS; goto Label_01A1; } if (str == "TXT") { this._viewType = CommonClass.TransmissionType.Text; this._fileType = CommonClass.TransmissionType.Text; goto Label_01A1; } if (str == "BIN") { this._viewType = CommonClass.TransmissionType.Hex; this._fileType = CommonClass.TransmissionType.Hex; goto Label_01A1; } } else { this._viewType = CommonClass.TransmissionType.GP2; this._fileType = CommonClass.TransmissionType.GP2; goto Label_01A1; } } this._viewType = CommonClass.TransmissionType.Hex; this._fileType = CommonClass.TransmissionType.Hex; Label_01A1: this._processFileLog = strArray[0] + ".par"; this.frmFileReplayOpenToolStripMenuItem.Enabled = false; }
private DialogResult fileReplayOpenHandler() { bool flag = false; foreach (string str in PortManagerHash.Keys) { if (!(str == clsGlobal.FilePlayBackPortName)) { PortManager manager = (PortManager) PortManagerHash[str]; if ((manager != null) && manager.comm.IsSourceDeviceOpen()) { flag = true; break; } } } if (flag && (MessageBox.Show("Proceeding will close all open ports. Continue?", "File Playback Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.No)) { return DialogResult.Cancel; } foreach (string str2 in PortManagerHash.Keys) { if (str2 != clsGlobal.FilePlayBackPortName) { PortManager tmpP = (PortManager) PortManagerHash[str2]; if (tmpP != null) { if (tmpP.comm.IsSourceDeviceOpen()) { tmpP.comm.ClosePort(); } tmpP.CloseAll(); updateGUIOnConnectNDisconnect(tmpP); } } } updateAllMainBtn(); menuBtnInit(); OpenFileDialog dialog = new OpenFileDialog(); dialog.Title = "Specify log file name:"; dialog.InitialDirectory = @"..\..\logs\"; dialog.Filter = "GP2 (*.gp2)|*.gp2|GPS (*.gps)|*.gps|Text files (*.txt)|*.txt|All files (*.*)|*.*"; dialog.FilterIndex = 4; dialog.CheckPathExists = false; dialog.CheckFileExists = false; if (dialog.ShowDialog() != DialogResult.OK) { goto Label_04AE; } _logFileName = dialog.FileName; if ((_logFileName == string.Empty) || !File.Exists(_logFileName)) { MessageBox.Show(string.Format("Error Open file\n {0}", _logFileName), "File Playback Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); _playState = _playStates.IDLE; return DialogResult.Cancel; } Text = string.Format("{0}: File Playback", clsGlobal.SiRFLiveVersion); _fileHdlr = new LargeFileHandler(_logFileName); _totalFileSize = _fileHdlr.Length; filePlayBackTrackBar.Value = 0; filePlayBackTrackBar.Maximum = 100; filePlayBackTrackBar.Minimum = 0; filePlayBackTrackBar.Enabled = true; filePlayBackTrackBar.Visible = true; _playState = _playStates.IDLE; _lastPlayState = _playState; FileInfo info = new FileInfo(_logFileName); if (info.Length == 0L) { MessageBox.Show(string.Format("0 length file dectected!\n{0}", _logFileName), "File Playback Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); return DialogResult.Cancel; } string str3 = info.Extension.ToUpper(); if (str3 != null) { if (!(str3 == ".GP2") && !(str3 == ".GPX")) { if (str3 == ".GPS") { _viewType = CommonClass.TransmissionType.GPS; _fileType = CommonClass.TransmissionType.GPS; goto Label_033C; } if (str3 == ".TXT") { _viewType = CommonClass.TransmissionType.Text; _fileType = CommonClass.TransmissionType.Text; goto Label_033C; } if (str3 == ".BIN") { _viewType = CommonClass.TransmissionType.Hex; _fileType = CommonClass.TransmissionType.Hex; goto Label_033C; } } else { _viewType = CommonClass.TransmissionType.GPS; _fileType = CommonClass.TransmissionType.GP2; goto Label_033C; } } _viewType = CommonClass.TransmissionType.Hex; _fileType = CommonClass.TransmissionType.Hex; Label_033C: _processFileLog = info.DirectoryName + info.Name + ".par"; PortManager manager3 = setupFileReplayPort(); if (manager3 != null) { manager3.UpdateMainWindow += new PortManager.updateParentEventHandler(updateMainWindowTitle); if (!toolStripPortComboBox.Items.Contains(clsGlobal.FilePlayBackPortName)) { toolStripPortComboBox.Items.Add(clsGlobal.FilePlayBackPortName); } toolStripPortComboBox.Text = clsGlobal.FilePlayBackPortName; if (_lastPlayState == _playStates.IDLE) { manager3.comm.WriteApp("User marker: Open file: " + _logFileName); } manager3.PerPortToolStrip = AddPortToolbar((toolStripMain.Location.Y + (0x19 * PortManagerHash.Count)) + 0x23, manager3.comm.PortName); manager3.ClearSubWindowsData(true); } else { MessageBox.Show("Error Setup Port for File Playback", "File Playback Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); _playState = _playStates.IDLE; return DialogResult.Cancel; } fileOpenToolStripMenuItem.Enabled = false; toolStripOpenFileBtn.Enabled = false; logManagerStatusLabel.Text = _logFileName; _isFileOpen = true; _parseThread = new Thread(new ThreadStart(parseFile)); _parseThread.IsBackground = true; _parseThread.Start(); EnableDisableMenuAndButtonForFilePlayback(true); updateFilePlaybackBtn(true); Label_04AE: return base.DialogResult; }
private void fileReplayCloseHandler() { if (_isFileOpen) { _playState = _playStates.IDLE; _playState = _playStates.QUIT; if (_fileHdlr != null) { _fileHdlr.Close(); } _fileHdlr = null; _isFileOpen = false; _logFileName = string.Empty; toolStripOpenFileBtn.Enabled = true; fileOpenToolStripMenuItem.Enabled = true; filePlayBackTrackBar.Enabled = true; filePlayBackTrackBar.Visible = false; Text = string.Format("{0}: File Playback Close", clsGlobal.SiRFLiveVersion); } }
private void convertFiles() { EventHandler method = null; EventHandler handler3 = null; EventHandler handler4 = null; EventHandler handler5 = null; EventHandler handler6 = null; EventHandler handler7 = null; EventHandler handler8 = null; EventHandler handler9 = null; EventHandler handler10 = null; EventHandler handler11 = null; EventHandler handler12 = null; CommunicationManager manager = new CommunicationManager(); manager.RxCtrl = new OSPReceiver(); manager.RxCtrl.ResetCtrl = new OSPReset(); StreamWriter writer = null; StreamWriter writer2 = null; StreamReader reader = null; LargeFileHandler handler = null; Thread.CurrentThread.CurrentCulture = clsGlobal.MyCulture; try { foreach (string str in this.toRunList) { if (!File.Exists(str)) { this._convertedFilesCount++; if (method == null) { method = delegate { this.convertedFilesLabel.Text = string.Format("Files converted: {0}", this._convertedFilesCount); }; } this.convertedFilesLabel.BeginInvoke(method); continue; } string str2 = string.Empty; string path = string.Empty; string str4 = string.Empty; if (str.EndsWith(".gp2")) { path = str.Replace(".gp2", ".gps"); } else if (str.EndsWith(".gpx")) { path = str.Replace(".gpx", ".gps"); } else if (str.EndsWith(".bin")) { path = str.Replace(".bin", ".gps"); str4 = str.Replace(".bin", ".gp2"); } else if (str.EndsWith(".gps")) { if (this._conversionType == ConversionType.GPSToNMEA) { if (this.useSSBMsg41RadioBtn.Checked) { path = str.Replace(".gps", "_msg41.nmea"); } else if (this.useOspMsg69RadioBtn.Checked) { path = str.Replace(".gps", "_msg69.nmea"); } else if (this.autoDetectRadioBtn.Checked) { path = str.Replace(".gps", "_auto.nmea"); str4 = str.Replace(".gps", ".msg69parse"); } else { path = str.Replace(".gps", ".nmea"); } } else if (this._conversionType == ConversionType.GPSToKML) { path = str.Replace(".gps", ".kml"); } else { path = str.Replace(".gps", ".convert"); } } else if (str.EndsWith(".nmea")) { path = str.Replace(".nmea", ".gps"); } else { path = str.Substring(0, str.Length - 4) + ".gps"; } writer = new StreamWriter(path); reader = new StreamReader(str); FileInfo info = new FileInfo(str); double length = info.Length; if (length == 0.0) { this._convertedFilesCount++; if (handler3 == null) { handler3 = delegate { this.convertedFilesLabel.Text = string.Format("Files converted: {0}", this._convertedFilesCount); }; } this.convertedFilesLabel.BeginInvoke(handler3); continue; } if (handler4 == null) { handler4 = delegate { this.progressBar1.Value = 0; this.progressBar1.Maximum = 100; this.progressBar1.Minimum = 0; }; } this.progressBar1.BeginInvoke(handler4); long num2 = 0L; switch (this._conversionType) { case ConversionType.GP2ToGPS: if (handler6 == null) { handler6 = delegate { this.fileConversionStatusLabel.Text = "Status: converting..."; }; } this.fileConversionStatusLabel.BeginInvoke(handler6); while ((str2 = reader.ReadLine()) != null) { num2 += str2.Length; int percent = (int) ((((double) num2) / length) * 100.0); if (percent > 100) { percent = 100; } this.progressBar1.BeginInvoke((MethodInvoker)delegate { this.progressBar1.Value = percent; }); try { if (str2.Contains("A0 A2")) { int index = str2.IndexOf("A0 A2"); byte[] comByte = HelperFunctions.HexToByte(str2.Substring(index)); string str9 = manager.m_Protocols.ConvertRawToFields(comByte); if (this.includeDateTimeChkBox.Checked) { writer.WriteLine(str2.Substring(0, index) + " " + str9); } else { writer.WriteLine(str9); } } else { writer.WriteLine(str2); } } catch { writer.WriteLine(str2); continue; } if (this._abort) { break; } } goto Label_1731; case ConversionType.BinToGPS_GP2: break; case ConversionType.GPSToNMEA: { reader.Close(); Queue<uint> queue = new Queue<uint>(); Queue<long> queue2 = new Queue<long>(); handler = new LargeFileHandler(str); long item = 0L; if (this.autoDetectRadioBtn.Checked) { writer2 = new StreamWriter(str4); if (handler7 == null) { handler7 = delegate { this.fileConversionStatusLabel.Text = "Status: scanning..."; }; } this.fileConversionStatusLabel.BeginInvoke(handler7); str2 = handler[item]; while (str2 != "EOF") { str2 = str2.Replace(" ", ""); if (str2.StartsWith("69,1")) { try { string[] strArray3 = str2.Split(new char[] { ',' }); if (strArray3.Length > 9) { uint num8 = Convert.ToUInt32(strArray3[9]); writer2.WriteLine(string.Format("{0} -- {1}", num8, strArray3[5])); if ((strArray3[3] != "0") && (strArray3[5] == "1")) { queue.Enqueue(num8); queue2.Enqueue(item); } } } catch { } } item = handler.Index + 1L; str2 = handler[item]; } writer2.Close(); item = 0L; str2 = handler[item]; } if (handler8 == null) { handler8 = delegate { this.fileConversionStatusLabel.Text = "Status: converting..."; }; } this.fileConversionStatusLabel.BeginInvoke(handler8); while (str2 != "EOF") { string str11; num2 += str2.Length; int percent = (int) ((((double) num2) / length) * 100.0); if (percent > 100) { percent = 100; } this.progressBar1.BeginInvoke((MethodInvoker)delegate { this.progressBar1.Value = percent; }); str2 = str2.TrimEnd(new char[] { '\n' }).TrimEnd(new char[] { '\r' }).Replace(" ", ""); if (str2.StartsWith("4,")) { string[] strArray4 = str2.Split(new char[] { ',' }); string str10 = this.GPS_NMEA_OutputGSV(strArray4); if (str10 != string.Empty) { writer.Write(str10); } goto Label_0AFE; } if (!str2.StartsWith("41,")) { goto Label_0A08; } if (!this.useSSBMsg41RadioBtn.Checked && !this.autoDetectRadioBtn.Checked) { goto Label_0AFE; } string[] msgArray = str2.Split(new char[] { ',' }); if (msgArray.Length < 0x22) { item = handler.Index + 1L; str2 = handler[item]; continue; } if ((queue.Count > 0) && this.autoDetectRadioBtn.Checked) { uint num9 = Convert.ToUInt32(msgArray[4]); uint num10 = queue.Peek(); long num11 = queue2.Peek(); if (num9 == num10) { queue.Dequeue(); queue2.Dequeue(); } else { if (num9 > num10) { if (item > num11) { while (item > num11) { queue.Dequeue(); queue2.Dequeue(); num10 = queue.Peek(); num11 = queue2.Peek(); if (num9 == num10) { break; } } if (item > num11) { goto Label_0960; } continue; } item = handler.Index + 1L; str2 = handler[item]; continue; } item = handler.Index + 1L; str2 = handler[item]; continue; } } Label_0960: str11 = this.GPS_NMEA_OutputGGA(msgArray); if (str11 != string.Empty) { writer.Write(str11); } str11 = this.GPS_NMEA_OutputRMC(msgArray); if (str11 != string.Empty) { writer.Write(str11); } str11 = this.GPS_NMEA_OutputGLL(msgArray); if (str11 != string.Empty) { writer.Write(str11); } str11 = this.GPS_NMEA_OutputGSA(msgArray); if (str11 != string.Empty) { writer.Write(str11); } str11 = this.GPS_NMEA_OutputVTG(msgArray); if (str11 != string.Empty) { writer.Write(str11); } goto Label_0AFE; Label_0A08: if (str2.StartsWith("69,1") && this.useOspMsg69RadioBtn.Checked) { string[] strArray6 = new string[0x24]; if (this.msg69ToMsg4AndMsg41Format(str2, ref strArray6) != 0) { item = handler.Index + 1L; str2 = handler[item]; continue; } string str12 = this.GPS_NMEA_OutputGGA(strArray6); if (str12 != string.Empty) { writer.Write(str12); } str12 = this.GPS_NMEA_OutputRMC(strArray6); if (str12 != string.Empty) { writer.Write(str12); } str12 = this.GPS_NMEA_OutputGLL(strArray6); if (str12 != string.Empty) { writer.Write(str12); } str12 = this.GPS_NMEA_OutputGSA(strArray6); if (str12 != string.Empty) { writer.Write(str12); } str12 = this.GPS_NMEA_OutputVTG(strArray6); if (str12 != string.Empty) { writer.Write(str12); } } Label_0AFE: if (this._abort) { break; } item = handler.Index + 1L; str2 = handler[item]; } goto Label_1731; } case ConversionType.GPSToKML: { if (handler10 == null) { handler10 = delegate { this.fileConversionStatusLabel.Text = "Status: converting..."; }; } this.fileConversionStatusLabel.BeginInvoke(handler10); PortManager manager2 = new PortManager(); manager.MessageProtocol = "OSP"; manager2.comm.SetupRxCtrl(); writer.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); writer.WriteLine("<kml xmlns=\"http://earth.google.com/kml/2.0\">"); writer.WriteLine("\t<Document>"); writer.WriteLine("\t\t<Style id=\"red\">"); writer.WriteLine("\t\t\t<IconStyle>"); writer.WriteLine("\t\t\t\t<Icon><href>http://maps.google.com/mapfiles/kml/pal3/icon63.png</href></Icon>"); writer.WriteLine("\t\t\t\t<color>ff0000ff</color>"); writer.WriteLine("\t\t\t\t<scale>.3</scale>"); writer.WriteLine("\t\t\t</IconStyle>"); writer.WriteLine("\t\t</Style>"); writer.WriteLine("\t\t<Style id=\"green\">"); writer.WriteLine("\t\t\t<IconStyle>"); writer.WriteLine("\t\t\t\t<Icon><href>http://maps.google.com/mapfiles/kml/pal3/icon63.png</href></Icon>"); writer.WriteLine("\t\t\t\t<color>ff00ff00</color>"); writer.WriteLine("\t\t\t\t<scale>.3</scale>"); writer.WriteLine("\t\t\t</IconStyle>"); writer.WriteLine("\t\t</Style>"); writer.WriteLine("\t\t<Style id=\"blue\">"); writer.WriteLine("\t\t\t<IconStyle>"); writer.WriteLine("\t\t\t\t<Icon><href>http://maps.google.com/mapfiles/kml/pal3/icon63.png</href></Icon>"); writer.WriteLine("\t\t\t\t<color>ffff0000</color>"); writer.WriteLine("\t\t\t\t<scale>.3</scale>"); writer.WriteLine("\t\t\t</IconStyle>"); writer.WriteLine("\t\t</Style>"); writer.WriteLine("\t\t<Style id=\"cyan\">"); writer.WriteLine("\t\t\t<IconStyle>"); writer.WriteLine("\t\t\t\t<Icon><href>http://maps.google.com/mapfiles/kml/pal3/icon63.png</href></Icon>"); writer.WriteLine("\t\t\t\t<color>ffff41b0</color>"); writer.WriteLine("\t\t\t\t<scale>.3</scale>"); writer.WriteLine("\t\t\t</IconStyle>"); writer.WriteLine("\t\t</Style>"); bool flag4 = false; double num21 = 0.0; while ((str2 = reader.ReadLine()) != null) { num2 += str2.Length; num21++; int percent = (int) ((((double) num2) / length) * 100.0); if (percent > 100) { percent = 100; } this.progressBar1.BeginInvoke((MethodInvoker)delegate { this.progressBar1.Value = percent; }); if (str2.StartsWith("41,")) { Hashtable hashtable = manager2.comm.getSatellitesDataForGUIFromCSV(0x29, 0, "SSB", str2); if (hashtable != null) { double num22 = 0.0; int num23 = 0; double num24 = 0.0; double num25 = 0.0; double num26 = 0.0; double num27 = 0.0; double num28 = 0.0; double num29 = 0.0; double num30 = 0.0; int num31 = 0; uint num32 = 0; int num33 = 0; int num34 = 0; int num35 = 0; int num36 = 0; int num37 = 0; int num38 = 0; double num39 = 0.0; try { if (hashtable.ContainsKey("NAV Type")) { num23 = Convert.ToUInt16((string) hashtable["NAV Type"]); } if (num23 > 0) { if (hashtable.ContainsKey("TOW")) { num22 = Convert.ToDouble((string) hashtable["TOW"]) / 1000.0; } if (hashtable.ContainsKey("Latitude")) { num24 = Convert.ToDouble((string) hashtable["Latitude"]) / 10000000.0; } if (hashtable.ContainsKey("Longitude")) { num25 = Convert.ToDouble((string) hashtable["Longitude"]) / 10000000.0; } if (hashtable.ContainsKey("Altitude from Ellipsoid")) { double num1 = Convert.ToDouble((string) hashtable["Altitude from Ellipsoid"]) / 100.0; } if (hashtable.ContainsKey("Altitude from MSL")) { num26 = Convert.ToDouble((string) hashtable["Altitude from MSL"]) / 100.0; } if (hashtable.ContainsKey("UTC Hour")) { num37 = Convert.ToInt32((string) hashtable["UTC Hour"]); } if (hashtable.ContainsKey("UTC Minute")) { num38 = Convert.ToInt32((string) hashtable["UTC Minute"]); } if (hashtable.ContainsKey("UTC Second")) { num39 = Convert.ToDouble((string) hashtable["UTC Second"]) / 1000.0; } if (hashtable.ContainsKey("UTC Year")) { num34 = Convert.ToInt32((string) hashtable["UTC Year"]); } if (hashtable.ContainsKey("UTC Month")) { num36 = Convert.ToInt32((string) hashtable["UTC Month"]); } if (hashtable.ContainsKey("UTC Day")) { num35 = Convert.ToInt32((string) hashtable["UTC Day"]); } if (hashtable.ContainsKey("HDOP")) { num30 = Convert.ToDouble((string) hashtable["HDOP"]) / 5.0; } if (hashtable.ContainsKey("Speed Over Ground (SOG)")) { num27 = Convert.ToDouble((string) hashtable["Speed Over Ground (SOG)"]) / 100.0; } if (hashtable.ContainsKey("Course Over Ground (COG True)")) { num28 = Convert.ToDouble((string) hashtable["Course Over Ground (COG True)"]) / 100.0; } if (hashtable.ContainsKey("Extended Week Number")) { num32 = Convert.ToUInt16((string) hashtable["Extended Week Number"]); } if (hashtable.ContainsKey("Number of SVs in Fix")) { num33 = Convert.ToInt32((string) hashtable["Number of SVs in Fix"]); } if (hashtable.ContainsKey("AdditionalModelInfor")) { num31 = Convert.ToInt32((string) hashtable["AdditionalModelInfor"]); } if (hashtable.ContainsKey("Estimated Horizontal Position Error")) { num29 = Convert.ToDouble((string) hashtable["Estimated Horizontal Position Error"]) / 100.0; } writer.WriteLine("\t\t<Placemark>"); if (!flag4) { writer.WriteLine("\t\t\t<name>Start</name>"); flag4 = true; } writer.WriteLine("\t\t\t<description>Nav mode = 0x{0}<br/> GPS Week = {1}<br/> TOW = {2:F3} s<br/>UTC = {3}/{4}/{5} {6}:{7}:{8:F3}<br/> SV Cnt = {9}<br/> Lat = {10:F7} deg<br/> Lon = {11:F7} deg<br/> Alt (msl)= {12:F2} m<br/> Sog = {13:F2} m/s<br/> Hdg = {14:F2} deg<br/> Ehpe = {15:F2} m<br/> Hdop = {16:F2}<br/> Additional Mode Info = 0x{17}<br/></description>", new object[] { num23.ToString("X"), num32, num22, num36, num35, num34, num37, num38, num39, num33, num24, num25, num26, num27, num28, num29, num30, num31.ToString("X") }); writer.WriteLine("\t\t\t<styleUrl>red</styleUrl>"); writer.WriteLine("\t\t\t<Point><coordinates>{0:F7},{1:F7},0</coordinates></Point>", num25, num24); writer.WriteLine("\t\t</Placemark>"); } continue; } catch { writer.WriteLine("Error encounters! {0}", num21); continue; } } } } manager2 = null; writer.WriteLine("\t</Document>"); writer.WriteLine("</kml>"); goto Label_1731; } case ConversionType.NMEAToGPS: { if (handler9 == null) { handler9 = delegate { this.fileConversionStatusLabel.Text = "Status: converting..."; }; } this.fileConversionStatusLabel.BeginInvoke(handler9); string str16 = "0"; string str17 = string.Empty; string str18 = string.Empty; string str19 = string.Empty; string nS = string.Empty; string eW = string.Empty; string str22 = string.Empty; string str23 = string.Empty; double num13 = 0.0; double num14 = 0.0; int fixPosIndicator = 0; int lat = 0; int lon = 0; int num18 = 0; int gpsWeek = 0; double gpsTOW = 0.0; bool flag = false; bool flag2 = false; bool flag3 = false; while ((str2 = reader.ReadLine()) != null) { num2 += str2.Length; int percent = (int) ((((double) num2) / length) * 100.0); if (percent > 100) { percent = 100; } this.progressBar1.BeginInvoke((MethodInvoker)delegate { this.progressBar1.Value = percent; }); if (str2.Contains("GPRMC")) { string str24 = string.Empty; try { if (flag && flag2) { if (flag3) { str24 = string.Format("41,0,{0},{1},{2},{3},{4},{5},{6},{7},{8},0,{9},{10},0,0,0,{11:F2},{12:F2},0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0", new object[] { num18, gpsWeek, gpsTOW * 1000.0, str19.Substring(4, 2), str19.Substring(2, 2), str19.Substring(0, 2), str16.Substring(0, 2), str16.Substring(2, 2), str16.Substring(4, 2), lat, lon, num14, num13 }); } else { str24 = string.Format("41,0,{0},{1},{2},{3},{4},{5},{6},{7},{8},0,{9},{10},0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0", new object[] { num18, gpsWeek, gpsTOW * 1000.0, str19.Substring(4, 2), str19.Substring(2, 2), str19.Substring(0, 2), str16.Substring(0, 2), str16.Substring(2, 2), str16.Substring(4, 2), lat, lon }); } } writer.WriteLine(str24); flag = false; flag2 = false; flag3 = false; } catch (Exception exception) { MessageBox.Show("Exception in file conversion NMEA to SB: " + exception.ToString()); } string[] strArray7 = str2.Split(new char[] { ',' }); str16 = strArray7[1]; str17 = strArray7[3]; nS = strArray7[4]; str18 = strArray7[5]; eW = strArray7[6]; str19 = strArray7[9]; try { this.ConvertRMCDateToWeekAndSeconds(str16, str19, ref gpsWeek, ref gpsTOW); this.ConvertRMCLatLontoSBmsg41LatLon(str17, nS, str18, eW, ref lat, ref lon); } catch (Exception exception2) { MessageBox.Show("Exception in file conversion NMEA to SB: " + exception2.ToString()); } flag = true; } else if (str2.Contains("GPGGA")) { string[] strArray8 = str2.Split(new char[] { ',' }); string text1 = strArray8[1]; try { fixPosIndicator = Convert.ToInt32(strArray8[6]); num18 = this.ConvertGGAPosFixIndiToSBmsg41NavType(fixPosIndicator); } catch (Exception exception3) { MessageBox.Show("Exception in file conversion NMEA to SB: " + exception3.ToString()); } flag2 = true; } else if (str2.Contains("GPVTG")) { string[] strArray9 = str2.Split(new char[] { ',' }); str22 = strArray9[1]; str23 = strArray9[7]; try { num13 = Convert.ToDouble(str22); num14 = Convert.ToDouble(str23); } catch (Exception exception4) { MessageBox.Show("Exception in file conversion NMEA to SB: " + exception4.ToString()); } num13 *= 100.0; num14 = (num14 * 1000.0) / 36.0; flag3 = true; } else { writer.WriteLine(str2); } if (this._abort) { break; } } goto Label_1731; } default: goto Label_1731; } reader.Close(); FileStream stream = File.OpenRead(str); writer2 = new StreamWriter(str4); if (handler5 == null) { handler5 = delegate { this.fileConversionStatusLabel.Text = "Status: converting..."; }; } this.fileConversionStatusLabel.BeginInvoke(handler5); int offset = 0; int count = 0x1000; byte[] buffer = new byte[count]; int len = stream.Read(buffer, offset, count); manager.SetupRxCtrl(); while (len > 0) { manager.PopulateData(buffer, len); string str5 = manager.ByteToMsgQueue(new byte[1]); string[] separator = new string[] { "\r\n" }; foreach (string str6 in str5.Split(separator, StringSplitOptions.None)) { string str7 = manager.m_Protocols.ConvertRawToFields(HelperFunctions.HexToByte(str6)); writer.WriteLine(str7); writer2.WriteLine(CommonUtilsClass.LogToGP2(str6, string.Empty)); } offset += len; int percent = (int) ((((double) offset) / length) * 100.0); if (percent > 100) { percent = 100; } this.progressBar1.BeginInvoke((MethodInvoker)delegate { this.progressBar1.Value = percent; }); len = stream.Read(buffer, 0, count); if (this._abort) { break; } } stream.Close(); writer2.Close(); Label_1731: if (this._abort) { break; } reader.Close(); writer.Close(); if (handler != null) { handler.Close(); } this._convertedFilesCount++; if (handler11 == null) { handler11 = delegate { this.convertedFilesLabel.Text = string.Format("Files converted: {0}", this._convertedFilesCount); }; } this.convertedFilesLabel.BeginInvoke(handler11); } if (this._abort) { MessageBox.Show("Conversion Aborted", "Information", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); if (reader != null) { reader.Close(); } if (writer != null) { writer.Close(); } if (writer2 != null) { writer2.Close(); } if (handler != null) { handler.Close(); } } else { MessageBox.Show("Conversion Done", "Information", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } this._conversionStatus = false; } catch (Exception exception5) { if (reader != null) { reader.Close(); } if (writer != null) { writer.Close(); } if (writer2 != null) { writer2.Close(); } if (handler != null) { handler.Close(); } this._conversionStatus = false; this._abort = false; MessageBox.Show("Error: " + exception5.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); } try { if (handler12 == null) { handler12 = delegate { this.fileConversionStatusLabel.Text = "Status: idle"; }; } this.fileConversionStatusLabel.BeginInvoke(handler12); } catch { } manager.Dispose(); manager = null; }
private void performCatAnalyze() { EventHandler method = null; EventHandler handler3 = null; foreach (string str in this.toAnalysisCategoryList) { string str2 = string.Empty; int num = 1; List<Hashtable> list = new List<Hashtable>(); while (num > 0) { string str3 = "Res"; try { str2 = this.autoIniIntf.GetIniFileString(str, str3 + num.ToString(), ""); if (str2 != string.Empty) { if (str2 == "Done") { break; } Hashtable item = this.parseResString(str2.TrimEnd(new char[] { '\r', '\n' })); if (item != null) { list.Add(item); } } continue; } catch { break; } } LargeFileHandler handler = null; foreach (string str4 in this.toRunList) { if (!File.Exists(str4)) { this._processesdFilesCount++; if (method == null) { method = delegate { this.processedFilesLabel.Text = string.Format("Files Processed: {0}", this._processesdFilesCount); }; } this.processedFilesLabel.BeginInvoke(method); } else { new FileInfo(str4); if (str4.Length == 0) { if (handler3 == null) { handler3 = delegate { this.processedFilesLabel.Text = string.Format("Files Processed: {0}", this._processesdFilesCount); }; } this.processedFilesLabel.BeginInvoke(handler3); } else { handler = new LargeFileHandler(str4); long length = handler.Length; for (int i = 0; i < list.Count; i++) { Hashtable hashtable2 = list[i]; foreach (string str5 in hashtable2.Keys) { string path = str4.Replace(".gps", str5 + ".ipar"); if (File.Exists(path)) { new StreamReader(path); } } } } } } } }
private void parseGPSFile() { LargeFileHandler handler = null; EventHandler method = null; EventHandler handler3 = null; long length = 0L; try { this.getCategoryConfig(); foreach (string str in this.toRunList) { string item = "Unknown"; string str3 = "Unknown"; if (!File.Exists(str)) { this._processesdFilesCount++; if (method == null) { method = delegate { this.processedFilesLabel.Text = string.Format("Files Processed: {0}", this._processesdFilesCount); }; } this.processedFilesLabel.BeginInvoke(method); } else { new FileInfo(str); if (str.Length == 0) { this._processesdFilesCount++; if (handler3 == null) { handler3 = delegate { this.processedFilesLabel.Text = string.Format("Files Processed: {0}", this._processesdFilesCount); }; } this.processedFilesLabel.BeginInvoke(handler3); } else { handler = new LargeFileHandler(str); length = handler.Length; for (int i = 0; i < this._analyzedMsgsList.Count; i++) { StreamWriter writer = new StreamWriter(str.Replace(".gps", string.Format("_{0}.ipar", this._analyzedMsgNamesList[i]))); this._msgIndexFileList.Add(writer); } try { long num3 = 0L; string str5 = handler[num3]; int count = this._analyzedMsgsList.Count; while (str5 != "EOF") { if (str5.Contains("SW Version")) { item = str5.TrimEnd(new char[] { '\r', '\n' }); } else if (str5.Contains("DUT Name:")) { str3 = str5.TrimEnd(new char[] { '\r', '\n' }); } else { for (int j = 0; j < count; j++) { if (str5.Contains(this._analyzedMsgsList[j])) { this._msgIndexFileList[j].WriteLine(num3); break; } } } if (length != 0L) { int processPercentage = (int) ((((double) handler.Index) / ((double) length)) * 100.0); this.progressBar1.BeginInvoke((MethodInvoker)delegate { this.progressBar1.Value = processPercentage; }); } num3 = handler.Index + 1L; str5 = handler[num3]; } this._softwareVersionsList.Add(item); this._rxNamesList.Add(str3); } catch { } if (handler != null) { handler.Close(); } foreach (StreamWriter writer2 in this._msgIndexFileList) { if (writer2 != null) { writer2.Close(); } } this._msgIndexFileList.Clear(); } } } } catch { if (handler != null) { handler.Close(); } foreach (StreamWriter writer3 in this._msgIndexFileList) { if (writer3 != null) { writer3.Close(); } } this._msgIndexFileList.Clear(); } }