예제 #1
0
        void processbg(object directory)
        {
            //this.Invoke((MethodInvoker)delegate { objectListView1.Clear(); });

            string[] files1 = Directory.GetFiles(directory.ToString(), "*.tlog", SearchOption.AllDirectories);
            string[] files2 = Directory.GetFiles(directory.ToString(), "*.bin", SearchOption.AllDirectories);
            string[] files3 = Directory.GetFiles(directory.ToString(), "*.log", SearchOption.AllDirectories);

            List <string> files = new List <string>();

            files.AddRange(files1);
            files.AddRange(files2);
            files.AddRange(files3);

            //objectListView1.VirtualListSize = files.Length;

            List <object> logs = new List <object>();

            foreach (var file in files)
            {
                if (!File.Exists(file + ".jpg"))
                {
                    LogMap.MapLogs(new string[] { file });
                }

                var loginfo = new loginfo();

                loginfo.fullname = file;

                if (File.Exists(file + ".jpg"))
                {
                    loginfo.img = new Bitmap(file + ".jpg");
                }

                //objectListView1.AddObject(loginfo);

                logs.Add(loginfo);
            }

            this.Invoke((MethodInvoker) delegate
            {
                objectListView1.AddObjects(logs);
            });
        }
예제 #2
0
        void processbg(object directory)
        {
            //this.Invoke((MethodInvoker)delegate { objectListView1.Clear(); });

            string[] files1 = Directory.GetFiles(directory.ToString(), "*.tlog", SearchOption.AllDirectories);
            string[] files2 = Directory.GetFiles(directory.ToString(), "*.bin", SearchOption.AllDirectories);
            string[] files3 = Directory.GetFiles(directory.ToString(), "*.log", SearchOption.AllDirectories);

            List <string> files = new List <string>();

            files.AddRange(files1);
            files.AddRange(files2);
            files.AddRange(files3);

            //objectListView1.VirtualListSize = files.Length;

            List <object> logs = new List <object>();

            foreach (var file in files)
            {
                if (!File.Exists(file + ".jpg"))
                {
                    LogMap.MapLogs(new string[] { file });
                }

                var loginfo = new loginfo();

                loginfo.fullname = file;

                if (File.Exists(file + ".jpg"))
                {
                    loginfo.img = new Bitmap(file + ".jpg");
                }

                if (file.ToLower().EndsWith(".tlog"))
                {
                    using (MAVLinkInterface mine = new MAVLinkInterface())
                    {
                        try
                        {
                            mine.logplaybackfile =
                                new BinaryReader(File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read));
                        }
                        catch (Exception ex)
                        {
                            log.Debug(ex.ToString());
                            CustomMessageBox.Show("Log Can not be opened. Are you still connected?");
                            return;
                        }
                        mine.logreadmode = true;

                        mine.MAV.packets.Initialize(); // clear

                        mine.getHeartBeat();

                        loginfo.Date     = mine.lastlogread;
                        loginfo.Aircraft = mine.sysidcurrent;

                        var start = mine.lastlogread;

                        try
                        {
                            mine.logplaybackfile.BaseStream.Seek(-100000, SeekOrigin.End);
                        }
                        catch
                        {
                        }

                        var end = mine.lastlogread;

                        while (mine.logplaybackfile.BaseStream.Position < mine.logplaybackfile.BaseStream.Length)
                        {
                            mine.readPacket();

                            if (mine.lastlogread > end)
                            {
                                end = mine.lastlogread;
                            }
                        }

                        loginfo.Duration = (end - start).ToString();
                    }
                }

                objectListView1.AddObject(loginfo);

                logs.Add(loginfo);
            }

            /*
             * this.Invoke((MethodInvoker)delegate
             * {
             *  objectListView1.AddObjects(logs);
             * });
             */
        }
예제 #3
0
        void processbg(string file)
        {
            a++;
            Loading.ShowLoading(a + "/" + files.Count + " " + file, this);

            if (!File.Exists(file + ".jpg"))
            {
                LogMap.MapLogs(new string[] { file });
            }

            var loginfo = new loginfo();

            loginfo.fullname = file;

            try
            {
                // file not found exception even though it passes the exists check above.
                loginfo.Size = new FileInfo(file).Length;
            }
            catch
            {
            }

            if (File.Exists(file + ".jpg"))
            {
                loginfo.imgfile = file + ".jpg";
            }

            if (file.ToLower().EndsWith(".tlog"))
            {
                using (MAVLinkInterface mine = new MAVLinkInterface())
                {
                    try
                    {
                        mine.logplaybackfile =
                            new BinaryReader(File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read));
                    }
                    catch (Exception ex)
                    {
                        log.Debug(ex.ToString());
                        CustomMessageBox.Show("Log Can not be opened. Are you still connected?");
                        return;
                    }
                    mine.logreadmode   = true;
                    mine.speechenabled = false;

                    // file is to small
                    if (mine.logplaybackfile.BaseStream.Length < 1024 * 4)
                    {
                        return;
                    }

                    mine.getHeartBeat();

                    loginfo.Date     = mine.lastlogread;
                    loginfo.Aircraft = mine.sysidcurrent;

                    loginfo.Frame = mine.MAV.aptype.ToString();

                    var start = mine.lastlogread;

                    try
                    {
                        mine.logplaybackfile.BaseStream.Seek(0, SeekOrigin.Begin);
                    }
                    catch
                    {
                    }

                    var end = mine.lastlogread;

                    var length = mine.logplaybackfile.BaseStream.Length;

                    var a = 0;

                    // abandon last 100 bytes
                    while (mine.logplaybackfile.BaseStream.Position < (length - 100))
                    {
                        var packet = mine.readPacket();

                        // gcs
                        if (packet.sysid == 255)
                        {
                            continue;
                        }

                        if (packet.msgid == (uint)MAVLink.MAVLINK_MSG_ID.CAMERA_FEEDBACK)
                        {
                            loginfo.CamMSG++;
                        }

                        if (a % 10 == 0)
                        {
                            mine.MAV.cs.UpdateCurrentSettings(null, true, mine);
                        }

                        a++;

                        if (mine.lastlogread > end)
                        {
                            end = mine.lastlogread;
                        }
                    }

                    loginfo.Home = mine.MAV.cs.Location;

                    loginfo.TimeInAir = mine.MAV.cs.timeInAir;

                    loginfo.DistTraveled = mine.MAV.cs.distTraveled;

                    loginfo.Duration = (end - start).ToString();
                }
            }
            else if (file.ToLower().EndsWith(".bin") || file.ToLower().EndsWith(".log"))
            {
                using (DFLogBuffer colbuf = new DFLogBuffer(File.OpenRead(file)))
                {
                    PointLatLngAlt lastpos = null;
                    DateTime       start   = DateTime.MinValue;
                    DateTime       end     = DateTime.MinValue;
                    DateTime       tia     = DateTime.MinValue;
                    // set time in air/home/distancetraveled
                    foreach (var dfItem in colbuf.GetEnumeratorType("GPS"))
                    {
                        if (dfItem["Status"] != null)
                        {
                            var status = int.Parse(dfItem["Status"]);
                            if (status >= 3)
                            {
                                var pos = new PointLatLngAlt(
                                    double.Parse(dfItem["Lat"], CultureInfo.InvariantCulture),
                                    double.Parse(dfItem["Lng"], CultureInfo.InvariantCulture),
                                    double.Parse(dfItem["Alt"], CultureInfo.InvariantCulture));

                                if (lastpos == null)
                                {
                                    lastpos = pos;
                                }

                                if (start == DateTime.MinValue)
                                {
                                    loginfo.Date = dfItem.time;
                                    start        = dfItem.time;
                                }

                                end = dfItem.time;

                                // add distance
                                loginfo.DistTraveled += (float)lastpos.GetDistance(pos);

                                // set home
                                if (loginfo.Home == null)
                                {
                                    loginfo.Home = pos;
                                }

                                if (dfItem.time > tia.AddSeconds(1))
                                {
                                    // ground speed  > 0.2 or  alt > homelat+2
                                    if (double.Parse(dfItem["Spd"], CultureInfo.InvariantCulture) > 0.2 ||
                                        pos.Alt > (loginfo.Home.Alt + 2))
                                    {
                                        loginfo.TimeInAir++;
                                    }
                                    tia = dfItem.time;
                                }
                            }
                        }
                    }

                    loginfo.Duration = (end - start).ToString();

                    loginfo.CamMSG = colbuf.GetEnumeratorType("CAM").Count();

                    loginfo.Aircraft = 0;      //colbuf.dflog.param[""];

                    loginfo.Frame = "Unknown"; //mine.MAV.aptype.ToString();
                }
            }

            lock (logs)
                logs.Add(loginfo);
        }
예제 #4
0
        void processbg(string file)
        {
            if (!File.Exists(file + ".jpg"))
            {
                LogMap.MapLogs(new string[] { file });
            }

            var loginfo = new loginfo();

            loginfo.fullname = file;

            loginfo.Size = new FileInfo(file).Length;

            if (File.Exists(file + ".jpg"))
            {
                loginfo.img = new Bitmap(file + ".jpg");
            }

            if (file.ToLower().EndsWith(".tlog"))
            {
                using (MAVLinkInterface mine = new MAVLinkInterface())
                {
                    try
                    {
                        mine.logplaybackfile =
                            new BinaryReader(File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read));
                    }
                    catch (Exception ex)
                    {
                        log.Debug(ex.ToString());
                        CustomMessageBox.Show("Log Can not be opened. Are you still connected?");
                        return;
                    }
                    mine.logreadmode   = true;
                    mine.speechenabled = false;

                    mine.getHeartBeat();

                    loginfo.Date     = mine.lastlogread;
                    loginfo.Aircraft = mine.sysidcurrent;

                    var start = mine.lastlogread;

                    try
                    {
                        if (mine.logplaybackfile.BaseStream.Length > MaxPlaybackLogSize)
                        {
                            mine.logplaybackfile.BaseStream.Seek(-100000, SeekOrigin.End);
                        }
                        else
                        {
                            mine.logplaybackfile.BaseStream.Seek(0, SeekOrigin.Begin);
                        }
                    }
                    catch
                    {
                    }

                    var end = mine.lastlogread;

                    while (mine.logplaybackfile.BaseStream.Position < mine.logplaybackfile.BaseStream.Length)
                    {
                        mine.readPacket();

                        if (mine.lastlogread > end)
                        {
                            end = mine.lastlogread;
                        }
                    }

                    loginfo.Duration = (end - start).ToString();
                }
            }

            logs.Add(loginfo);
        }
예제 #5
0
        void processbg(string file)
        {
            Loading.ShowLoading(file, this);

            if (!File.Exists(file + ".jpg"))
            {
                LogMap.MapLogs(new string[] { file });
            }

            var loginfo = new loginfo();

            loginfo.fullname = file;

            loginfo.Size = new FileInfo(file).Length;

            if (File.Exists(file + ".jpg"))
            {
                loginfo.img = new Bitmap(file + ".jpg");
            }

            if (file.ToLower().EndsWith(".tlog"))
            {
                using (MAVLinkInterface mine = new MAVLinkInterface())
                {
                    try
                    {
                        mine.logplaybackfile =
                            new BinaryReader(File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read));
                    }
                    catch (Exception ex)
                    {
                        log.Debug(ex.ToString());
                        CustomMessageBox.Show("Log Can not be opened. Are you still connected?");
                        return;
                    }
                    mine.logreadmode   = true;
                    mine.speechenabled = false;

                    // file is to small
                    if (mine.logplaybackfile.BaseStream.Length < 1024 * 4)
                    {
                        return;
                    }

                    mine.getHeartBeat();

                    loginfo.Date     = mine.lastlogread;
                    loginfo.Aircraft = mine.sysidcurrent;

                    loginfo.Frame = mine.MAV.aptype.ToString();

                    var start = mine.lastlogread;

                    try
                    {
                        mine.logplaybackfile.BaseStream.Seek(0, SeekOrigin.Begin);
                    }
                    catch
                    {
                    }

                    var end = mine.lastlogread;

                    var length = mine.logplaybackfile.BaseStream.Length;

                    var a = 0;

                    // abandon last 100 bytes
                    while (mine.logplaybackfile.BaseStream.Position < (length - 100))
                    {
                        var packet = mine.readPacket();

                        // gcs
                        if (packet.sysid == 255)
                        {
                            continue;
                        }

                        if (a % 10 == 0)
                        {
                            mine.MAV.cs.UpdateCurrentSettings(null, true, mine);
                        }

                        a++;

                        if (mine.lastlogread > end)
                        {
                            end = mine.lastlogread;
                        }
                    }

                    loginfo.Home = mine.MAV.cs.Location;

                    loginfo.TimeInAir = mine.MAV.cs.timeInAir;

                    loginfo.DistTraveled = mine.MAV.cs.distTraveled;

                    loginfo.Duration = (end - start).ToString();
                }
            }

            logs.Add(loginfo);
        }