コード例 #1
0
 private void AppendSerialLog(string msg)
 {
     RunOnUIThread(new Action(() =>
     {
         TXT_seriallog.AppendText(msg + Environment.NewLine);
     }));
 }
コード例 #2
0
 private void ClearSerialLog()
 {
     RunOnUIThread(new Action(() =>
     {
         TXT_seriallog.Clear();
     }));
 }
コード例 #3
0
        void CreateLog(string logfile)
        {
            TextReader tr = new StreamReader(logfile);

            //

            this.Invoke((System.Windows.Forms.MethodInvoker) delegate()
            {
                TXT_seriallog.AppendText("Creating KML for " + logfile + "\n");
            });

            LogOutput lo = new LogOutput();

            while (tr.Peek() != -1)
            {
                lo.processLine(tr.ReadLine());
            }

            tr.Close();

            try
            {
                lo.writeKML(logfile + ".kml");
            }
            catch { } // usualy invalid lat long error
            status = serialstatus.Done;
            updateDisplay();
        }
コード例 #4
0
        private void Log_Load(object sender, EventArgs e)
        {
            if (!MainV2.comPort.BaseStream.IsOpen)
            {
                this.Close();
                CustomMessageBox.Show("Please Connect");
                return;
            }

            try
            {
                var list = MainV2.comPort.GetLogList();

                foreach (var item in list)
                {
                    genchkcombo(item.id);

                    TXT_seriallog.AppendText(item.id + "\t" + new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(item.time_utc).ToLocalTime() + "\test size:\t" + item.size + "\r\n");
                }

                if (list.Count == 0)
                {
                    TXT_seriallog.AppendText("No logs to download");
                }
            }
            catch { CustomMessageBox.Show("Cannot get log list.", "Error"); this.Close(); }

            status = serialstatus.Done;
        }
コード例 #5
0
 private void BUT_clearlogs_Click(object sender, EventArgs e)
 {
     System.Threading.Thread.Sleep(500);
     comPort.Write("erase\r");
     System.Threading.Thread.Sleep(100);
     TXT_seriallog.AppendText("!!Allow 30 seconds for erase\n");
     status = serialstatus.Done;
 }
コード例 #6
0
 private void BUT_clearlogs_Click(object sender, EventArgs e)
 {
     try
     {
         MainV2.comPort.EraseLog();
         TXT_seriallog.AppendText("!!Allow 30-90 seconds for erase\n");
         status = serialstatus.Done;
         CHK_logs.Items.Clear();
     }
     catch (Exception ex) { CustomMessageBox.Show(ex.Message, "Error"); }
 }
コード例 #7
0
        private void Log_Load(object sender, EventArgs e)
        {
            if (!MainV2.comPort.BaseStream.IsOpen)
            {
                this.Close();
                CustomMessageBox.Show("Please Connect");
                return;
            }

            try
            {
                var list = MainV2.comPort.GetLogList();

                foreach (var item in list)
                {
                    genchkcombo(item.id);

                    TXT_seriallog.AppendText(item.id + "\t" + new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(item.time_utc).ToLocalTime() + "\test size:\t" + item.size + "\r\n");

                    //TXT_seriallog.AppendText(item.id + "\t" + new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(item.time_utc).ToLocalTime() + "\test size:\t" + item.size +"\r\n");

                    //if(item.size > 5000) //i it's at least 5 kB
                    //{mi
                    //    genchkcombo(item.id); //add to list of downloads
                    //}
                    //else
                    //{ }
                }

                if (list.Count == 0)
                {
                    TXT_seriallog.AppendText("No logs to download");
                }

                //for (int i = 0; i < CHK_logs.Items.Count; i ++) //check all the logs in the list
                //{
                //    CHK_logs.SetItemChecked(i, true);
                //}


                //    status = serialstatus.Done;



                //BUT_DLthese.PerformClick(); //download the checked items


                // BUT_DLall.PerformClick();
            }
            catch { CustomMessageBox.Show(Strings.ErrorLogList, Strings.ERROR); this.Close(); }

            status = serialstatus.Done;
        }
コード例 #8
0
ファイル: Log.cs プロジェクト: OOP-03376400/Software
 private void BUT_clearlogs_Click(object sender, EventArgs e)
 {
     try
     {
         System.Threading.Thread.Sleep(500);
         comPort.Write("erase\r");
         System.Threading.Thread.Sleep(100);
         TXT_seriallog.AppendText("!!Allow 30-90 seconds for erase\n");
         status = serialstatus.Done;
         CHK_logs.Items.Clear();
     }
     catch (Exception ex) { CustomMessageBox.Show(ex.Message, "Error"); }
 }
コード例 #9
0
ファイル: LogDownload.cs プロジェクト: 894880010/MP
        private void BUT_firstperson_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog openFileDialog1 = new OpenFileDialog())
            {
                openFileDialog1.Filter           = "*.log|*.log";
                openFileDialog1.FilterIndex      = 2;
                openFileDialog1.RestoreDirectory = true;
                openFileDialog1.Multiselect      = true;
                try
                {
                    openFileDialog1.InitialDirectory = Settings.Instance.LogDir + Path.DirectorySeparatorChar;
                }
                catch
                {
                } // incase dir doesnt exist

                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    foreach (string logfile in openFileDialog1.FileNames)
                    {
                        TXT_seriallog.AppendText("\n\nProcessing " + logfile + "\n");
                        this.Refresh();

                        LogOutput lo = new LogOutput();

                        try
                        {
                            TextReader tr = new StreamReader(logfile);


                            while (tr.Peek() != -1)
                            {
                                lo.processLine(tr.ReadLine());
                            }

                            tr.Close();
                        }
                        catch (Exception ex)
                        {
                            CustomMessageBox.Show("Error processing log. Is it still downloading? " + ex.Message);
                            continue;
                        }

                        lo.writeKMLFirstPerson(logfile + "-fp.kml");

                        TXT_seriallog.AppendText("Done\n");
                    }
                }
            }
        }
コード例 #10
0
 private void BUT_clearlogs_Click(object sender, EventArgs e)
 {
     if (CustomMessageBox.Show("Are you sure?", "sure", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
     {
         try
         {
             MainV2.comPort.EraseLog();
             TXT_seriallog.AppendText("!!Allow 30-90 seconds for erase\n");
             status = serialstatus.Done;
             updateDisplay();
             CHK_logs.Items.Clear();
         }
         catch (Exception ex) { CustomMessageBox.Show(ex.Message, "Error"); }
     }
 }
コード例 #11
0
        private void BUT_redokml_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog openFileDialog1 = new OpenFileDialog())
            {
                openFileDialog1.Filter           = "*.log|*.log";
                openFileDialog1.FilterIndex      = 2;
                openFileDialog1.RestoreDirectory = true;
                openFileDialog1.Multiselect      = true;
                try
                {
                    openFileDialog1.InitialDirectory = MainV2.LogDir + Path.DirectorySeparatorChar;
                }
                catch
                {
                } // incase dir doesnt exist

                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    foreach (string logfile in openFileDialog1.FileNames)
                    {
                        TXT_seriallog.AppendText("\n\nProcessing " + logfile + "\n");
                        this.Refresh();
                        LogOutput lo = new LogOutput();
                        try
                        {
                            TextReader tr = new StreamReader(logfile);

                            while (tr.Peek() != -1)
                            {
                                lo.processLine(tr.ReadLine());
                            }

                            tr.Close();
                        }
                        catch (Exception ex)
                        {
                            CustomMessageBox.Show("Error processing file. Make sure the file is not in use.\n" +
                                                  ex.ToString());
                        }

                        lo.writeKML(logfile + ".kml");

                        TXT_seriallog.AppendText("Done\n");
                    }
                }
            }
        }
コード例 #12
0
        private void BUT_firstperson_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.Filter           = "*.log|*.log";
            openFileDialog1.FilterIndex      = 2;
            openFileDialog1.RestoreDirectory = true;
            openFileDialog1.Multiselect      = true;
            try
            {
                openFileDialog1.InitialDirectory = Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + @"logs" + Path.DirectorySeparatorChar;
            }
            catch { } // incase dir doesnt exist

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                foreach (string logfile in openFileDialog1.FileNames)
                {
                    TXT_seriallog.AppendText("\n\nProcessing " + logfile + "\n");
                    this.Refresh();

                    try
                    {
                        TextReader tr = new StreamReader(logfile);

                        MainV2.cs.firmware = MainV2.Firmwares.ArduPlane;

                        while (tr.Peek() != -1)
                        {
                            processLine(tr.ReadLine());
                        }

                        tr.Close();
                    }
                    catch (Exception ex) { MessageBox.Show("Error processing log. Is it still downloading? " + ex.Message); continue; }

                    writeKMLFirstPerson(logfile + ".kml");

                    TXT_seriallog.AppendText("Done\n");
                }
            }
        }
コード例 #13
0
ファイル: LogDownloadMavLink.cs プロジェクト: ststeiger/PcGcs
        private void Log_Load(object sender, EventArgs e)
        {
            //if (!MainV2.comPort.BaseStream.IsOpen)
            //{
            //    this.Close();
            //    CustomMessageBox.Show("Please Connect");
            //    return;
            //}
            if (!GCSMainForm.comPort.BaseStream.IsOpen)
            {
                this.Close();
                CustomMessageBox.Show("请先连接");
                return;
            }

            try
            {
                //var list = MainV2.comPort.GetLogList();
                var list = GCSMainForm.comPort.GetLogList();

                foreach (var item in list)
                {
                    genchkcombo(item.id);

                    TXT_seriallog.AppendText(item.id + "\t" + new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(item.time_utc).ToLocalTime() + "\test size:\t" + item.size + "\r\n");
                }

                if (list.Count == 0)
                {
                    TXT_seriallog.AppendText("无日志");
                }
            }
            catch { CustomMessageBox.Show(Strings.ErrorLogList, Strings.ERROR); this.Close(); }

            status = serialstatus.Done;
        }
コード例 #14
0
        private void BUT_redokml_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.Filter           = "*.log|*.log";
            openFileDialog1.FilterIndex      = 2;
            openFileDialog1.RestoreDirectory = true;
            openFileDialog1.Multiselect      = true;
            try
            {
                openFileDialog1.InitialDirectory = Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + @"logs" + Path.DirectorySeparatorChar;
            }
            catch { } // incase dir doesnt exist

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                foreach (string logfile in openFileDialog1.FileNames)
                {
                    TXT_seriallog.AppendText("\n\nProcessing " + logfile + "\n");
                    this.Refresh();

                    TextReader tr = new StreamReader(logfile);

                    while (tr.Peek() != -1)
                    {
                        processLine(tr.ReadLine());
                    }

                    tr.Close();

                    writeKML(logfile + ".kml");

                    TXT_seriallog.AppendText("Done\n");
                }
            }
        }
コード例 #15
0
        void comPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            try
            {
                while (comPort.BytesToRead > 0 && threadrun)
                {
                    updateDisplay();

                    string line = "";

                    comPort.ReadTimeout = 500;
                    try
                    {
                        line = comPort.ReadLine(); //readline(comPort);
                        if (!line.Contains("\n"))
                        {
                            line = line + "\n";
                        }
                    }
                    catch
                    {
                        line = comPort.ReadExisting();
                        //byte[] data = readline(comPort);
                        //line = Encoding.ASCII.GetString(data, 0, data.Length);
                    }

                    receivedbytes += line.Length;

                    //string line = Encoding.ASCII.GetString(data, 0, data.Length);

                    switch (status)
                    {
                    case serialstatus.Connecting:

                        if (line.Contains("ENTER") || line.Contains("GROUND START") || line.Contains("reset to FLY") || line.Contains("interactive setup") || line.Contains("CLI") || line.Contains("Ardu"))
                        {
                            try
                            {
                                System.Threading.Thread.Sleep(200);
                                comPort.Write("\n\n\n\n");
                            }
                            catch { }

                            System.Threading.Thread.Sleep(500);

                            comPort.Write("logs\r");
                            status = serialstatus.Done;
                        }
                        break;

                    case serialstatus.Closefile:
                        sw.Close();
                        TextReader tr = new StreamReader(logfile);

                        this.Invoke((System.Windows.Forms.MethodInvoker) delegate()
                        {
                            TXT_seriallog.AppendText("Creating KML for " + logfile);
                        });


                        while (tr.Peek() != -1)
                        {
                            processLine(tr.ReadLine());
                        }

                        tr.Close();

                        try
                        {
                            writeKML(logfile + ".kml");
                        }
                        catch { }     // usualy invalid lat long error
                        status = serialstatus.Done;
                        comPort.DiscardInBuffer();
                        break;

                    case serialstatus.Createfile:
                        receivedbytes = 0;
                        Directory.CreateDirectory(MainV2.LogDir);
                        logfile = MainV2.LogDir + Path.DirectorySeparatorChar + DateTime.Now.ToString("yyyy-MM-dd HH-mm") + " " + currentlog + ".log";
                        sw      = new StreamWriter(logfile);
                        status  = serialstatus.Waiting;
                        lock (thisLock)
                        {
                            this.Invoke((System.Windows.Forms.MethodInvoker) delegate()
                            {
                                TXT_seriallog.Clear();
                            });
                        }
                        //if (line.Contains("Dumping Log"))
                        {
                            status = serialstatus.Reading;
                        }
                        break;

                    case serialstatus.Done:
                        //
                        // if (line.Contains("start") && line.Contains("end"))
                    {
                        Regex regex2 = new Regex(@"^Log ([0-9]+)[,\s]", RegexOptions.IgnoreCase);
                        if (regex2.IsMatch(line))
                        {
                            MatchCollection matchs = regex2.Matches(line);
                            logcount = int.Parse(matchs[0].Groups[1].Value);
                            genchkcombo(logcount);
                            //status = serialstatus.Done;
                        }
                    }
                        if (line.Contains("No logs"))
                        {
                            status = serialstatus.Done;
                        }
                        break;

                    case serialstatus.Reading:
                        if (line.Contains("packets read") || line.Contains("Done") || line.Contains("logs enabled"))
                        {
                            status = serialstatus.Closefile;
                            Console.Write("CloseFile: " + line);
                            break;
                        }
                        sw.Write(line);
                        continue;

                    case serialstatus.Waiting:
                        if (line.Contains("Dumping Log") || line.Contains("GPS:") || line.Contains("NTUN:") || line.Contains("CTUN:") || line.Contains("PM:"))
                        {
                            status = serialstatus.Reading;
                            Console.Write("Reading: " + line);
                        }
                        break;
                    }
                    lock (thisLock)
                    {
                        this.BeginInvoke((MethodInvoker) delegate()
                        {
                            Console.Write(line);

                            TXT_seriallog.AppendText(line.Replace((char)0x0, ' '));

                            // auto scroll
                            if (TXT_seriallog.TextLength >= 10000)
                            {
                                TXT_seriallog.Text = TXT_seriallog.Text.Substring(TXT_seriallog.TextLength / 2);
                            }

                            TXT_seriallog.SelectionStart = TXT_seriallog.Text.Length;

                            TXT_seriallog.ScrollToCaret();

                            TXT_seriallog.Refresh();
                        });
                    }
                }

                //log.Info("exit while");
            }
            catch (Exception ex) { CustomMessageBox.Show("Error reading data" + ex.ToString()); }
        }