GetDataDirectory() public static method

Shared data directory
public static GetDataDirectory ( ) : string
return string
コード例 #1
0
        public static void DownloadGStreamer(Action <int, string> status = null)
        {
            var output = Settings.GetDataDirectory() + "gstreamer-1.0-x86_64-1.12.4.zip";

            status?.Invoke(0, "Downloading..");

            try
            {
                Download.getFilefromNet(
                    "http://firmware.ardupilot.org/MissionPlanner/gstreamer/gstreamer-1.0-x86_64-1.12.4.zip",
                    output, status: status);

                status?.Invoke(50, "Extracting..");
                ZipFile.ExtractToDirectory(output, Settings.GetDataDirectory());
                status?.Invoke(100, "Done.");
            }
            catch (WebException ex)
            {
                status?.Invoke(-1, "Error downloading file " + ex.ToString());
                try
                {
                    if (File.Exists(output))
                    {
                        File.Delete(output);
                    }
                }
                catch
                {
                }
            }
        }
コード例 #2
0
        public static string LookForGstreamer()
        {
            List <string> dirs = new List <string>();

            dirs.Add(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));

            dirs.Add(Settings.GetDataDirectory());

            DriveInfo[] allDrives = DriveInfo.GetDrives();
            foreach (DriveInfo d in allDrives)
            {
                if (d.IsReady && d.DriveType == DriveType.Fixed)
                {
                    dirs.Add(d.RootDirectory.Name + "gstreamer");
                    dirs.Add(d.RootDirectory.Name + "Program Files" + Path.DirectorySeparatorChar + "gstreamer");
                    dirs.Add(d.RootDirectory.Name + "Program Files (x86)" + Path.DirectorySeparatorChar + "gstreamer");
                }
            }

            foreach (var dir in dirs)
            {
                if (Directory.Exists(dir))
                {
                    var ans = Directory.GetFiles(dir, "gst-launch-1.0.exe", SearchOption.AllDirectories);

                    if (ans.Length > 0)
                    {
                        log.Info("Found gstreamer " + ans.First());
                        return(ans.First());
                    }
                }
            }

            return("");
        }
コード例 #3
0
        private static void clientdata(IAsyncResult ar)
        {
            var client = ((UdpClient)ar.AsyncState);

            if (client == null || client.Client == null)
            {
                return;
            }

            var port = ((IPEndPoint)client.Client.LocalEndPoint).Port;

            if (client != null)
            {
                client.Close();
            }

            if (!File.Exists(GStreamer.gstlaunch))
            {
                var gstpath = GStreamer.LookForGstreamer();

                if (File.Exists(gstpath))
                {
                    GStreamer.gstlaunch = gstpath;
                }
                else
                {
                    if (CustomMessageBox.Show("A video stream has been detected, but gstreamer has not been configured/installed.\nDo you want to install/config it now? It will download in the background.", "GStreamer", System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                    {
                        //CustomMessageBox.Show("Please download gstreamer 1.9.2 from [link;HERE;https://gstreamer.freedesktop.org/data/pkg/windows/1.9.2/gstreamer-1.0-x86-1.9.2.msi]\n And install it using the 'COMPLETE' option");

                        var output = Settings.GetDataDirectory() + "gstreamer-1.0-x86-1.9.2.zip";

                        Download.ParallelDownloadFile(
                            "http://firmware.ardupilot.org/MissionPlanner/gstreamer/gstreamer-1.0-x86-1.9.2.zip",
                            output);

                        ZipArchive zip = new ZipArchive(File.OpenRead(output));

                        zip.ExtractToDirectory(Settings.GetDataDirectory());

                        zip.Dispose();

                        GStreamer.gstlaunch = GStreamer.LookForGstreamer();
                        if (!File.Exists(GStreamer.gstlaunch))
                        {
                            return;
                        }
                    }
                    else
                    {
                        return;
                    }
                }
            }

            GStreamer.UdpPort = port;
            gst = GStreamer.Start();
        }
コード例 #4
0
        static GStreamer()
        {
            UdpPort    = 5600;
            OutputPort = 1235;

            var dataDirectory = Settings.GetDataDirectory();
            var gstdir        = Path.Combine(dataDirectory, @"gstreamer\1.0\x86_64\bin\libgstreamer-1.0-0.dll");


            SetGSTPath(gstdir);
        }
コード例 #5
0
        public static async Task GetMetaData()
        {
            List <Task> tlist = new List <Task>();

            vehicles.ForEach(a =>
            {
                try
                {
                    var newurl = String.Format(url, a);
                    var file   = Path.Combine(Settings.GetDataDirectory(), a + ".apm.pdef.xml.gz");
                    if (File.Exists(file))
                    {
                        if (new FileInfo(file).LastWriteTime.AddDays(7) > DateTime.Now)
                        {
                            return;
                        }
                    }
                    var dltask = Download.getFilefromNetAsync(newurl, file);
                    tlist.Add(dltask);
                }
                catch (Exception ex) { log.Error(ex); }
            });

            await Task.WhenAll(tlist);

            vehicles.ForEach(a =>
            {
                try
                {
                    var fileout = Path.Combine(Settings.GetDataDirectory(), a + ".apm.pdef.xml");
                    var file    = Path.Combine(Settings.GetDataDirectory(), a + ".apm.pdef.xml.gz");
                    if (File.Exists(file))
                    {
                        using (var read = File.OpenRead(file))
                        {
                            //if (XZStream.IsXZStream(read))
                            {
                                read.Position = 0;
                                var stream    = new GZipStream(read, CompressionMode.Decompress);
                                //var stream = new XZStream(read);
                                using (var outst = File.OpenWrite(fileout))
                                {
                                    stream.CopyTo(outst);
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    log.Error(ex);
                }
            });
        }
コード例 #6
0
ファイル: GStreamer.cs プロジェクト: tajisoft/MissionPlanner
        public static string LookForGstreamer()
        {
            List <string> dirs = new List <string>();

            // linux
            dirs.Add("/usr/lib/x86_64-linux-gnu");
            // rpi
            dirs.Add("/usr/lib/arm-linux-gnueabihf");
            // current
            dirs.Add(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
            // settings
            dirs.Add(Settings.GetDataDirectory());
            // custom settings
            dirs.Add(Settings.CustomUserDataDirectory);
            // sitl bindle
            dirs.Add(GStreamer.BundledPath);

            DriveInfo[] allDrives = DriveInfo.GetDrives();
            foreach (DriveInfo d in allDrives)
            {
                if (d.IsReady && d.DriveType == DriveType.Fixed)
                {
                    dirs.Add(d.RootDirectory.Name + "gstreamer");
                    dirs.Add(d.RootDirectory.Name + "Program Files" + Path.DirectorySeparatorChar + "gstreamer");
                    dirs.Add(d.RootDirectory.Name + "Program Files (x86)" + Path.DirectorySeparatorChar + "gstreamer");
                }
            }

            var is64bit = Environment.Is64BitProcess;

            foreach (var dir in dirs)
            {
                log.Info($"look in dir {dir}");
                if (Directory.Exists(dir))
                {
                    var ans = Directory.GetFiles(dir, "*.*", SearchOption.AllDirectories).Where(a => a.ToLower().Contains("libgstreamer-1.0-0.dll") || a.ToLower().Contains("libgstreamer-1.0.so.0") || a.ToLower().Contains("libgstreamer_android.so")).ToArray();

                    ans = ans.Where(a =>
                                    (!is64bit && !a.ToLower().Contains("_64")) || is64bit && a.ToLower().Contains("_64")).ToArray();

                    if (ans.Length > 0)
                    {
                        log.Info("Found gstreamer " + ans.First());
                        SetGSTPath(ans.First());
                        return(ans.First());
                    }
                }
            }

            log.Info("No gstreamer found");
            return("");
        }
コード例 #7
0
        public static void DownloadGStreamer(Action <int, string> status = null)
        {
            var output = Settings.GetDataDirectory() + "gstreamer-1.0-x86_64-1.12.4.zip";

            status?.Invoke(0, "Downloading..");

            Download.ParallelDownloadFile(
                "http://firmware.ardupilot.org/MissionPlanner/gstreamer/gstreamer-1.0-x86_64-1.12.4.zip",
                output, status: status);

            status?.Invoke(50, "Extracting..");
            ZipFile.ExtractToDirectory(output, Settings.GetDataDirectory());
            status?.Invoke(100, "Done.");
        }
コード例 #8
0
ファイル: GStreamer.cs プロジェクト: apdmrl/MissionPlanner
        public static void DownloadGStreamer()
        {
            var output = Settings.GetDataDirectory() + "gstreamer-1.0-x86-1.9.2.zip";

            Download.ParallelDownloadFile(
                "http://firmware.ardupilot.org/MissionPlanner/gstreamer/gstreamer-1.0-x86-1.9.2.zip",
                output);

            ZipArchive zip = new ZipArchive(File.OpenRead(output));

            zip.ExtractToDirectory(Settings.GetDataDirectory());

            zip.Dispose();
        }
コード例 #9
0
ファイル: GStreamer.cs プロジェクト: tajisoft/MissionPlanner
        public static void DownloadGStreamer(Action <int, string> status = null)
        {
            string output = "";
            string url    = "";

            if (RuntimeInformation.OSArchitecture == Architecture.Arm || RuntimeInformation.OSArchitecture == Architecture.Arm64)
            {
                return;
            }

            if (System.Environment.Is64BitProcess)
            {
                output = Settings.GetDataDirectory() + "gstreamer-1.0-x86_64-1.14.4.zip";
                url    = "https://firmware.ardupilot.org/MissionPlanner/gstreamer/gstreamer-1.0-x86_64-1.14.4.zip";
            }
            else
            {
                output = Settings.GetDataDirectory() + "gstreamer-1.0-x86-1.14.4.zip";
                url    = "https://firmware.ardupilot.org/MissionPlanner/gstreamer/gstreamer-1.0-x86-1.14.4.zip";
            }


            status?.Invoke(0, "Downloading..");

            try
            {
                Download.getFilefromNet(url, output, status: status);

                status?.Invoke(50, "Extracting..");
                ZipFile.ExtractToDirectory(output, Settings.GetDataDirectory());
                status?.Invoke(100, "Done.");
            }
            catch (WebException ex)
            {
                status?.Invoke(-1, "Error downloading file " + ex.ToString());
                try
                {
                    if (File.Exists(output))
                    {
                        File.Delete(output);
                    }
                }
                catch
                {
                }
            }
        }
コード例 #10
0
        static GStreamer()
        {
            UdpPort    = 5600;
            OutputPort = 1235;

            var dataDirectory = Settings.GetDataDirectory();
            var gstdir        = Path.Combine(dataDirectory, @"gstreamer\1.0\x86_64");

            // Prepend native path to environment path, to ensure the
            // right libs are being used.
            var path = Environment.GetEnvironmentVariable("PATH");

            path = Path.Combine(gstdir, "bin") + ";" + Path.Combine(gstdir, "lib") + ";" + path;
            Environment.SetEnvironmentVariable("PATH", path);

            Environment.SetEnvironmentVariable("GST_PLUGIN_PATH", Path.Combine(gstdir, "lib"));
        }
コード例 #11
0
        public static void Reload(string vehicle = "")
        {
            string paramMetaDataXMLFileName =
                String.Format("{0}{1}", Settings.GetDataDirectory(), vehicle + ".apm.pdef.xml");

            try
            {
                if (File.Exists(paramMetaDataXMLFileName))
                {
                    _parameterMetaDataXML[vehicle] = XDocument.Load(paramMetaDataXMLFileName);
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
        }
コード例 #12
0
        public static string LookForGstreamer()
        {
            List <string> dirs = new List <string>();

            dirs.Add(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));

            dirs.Add(Settings.GetDataDirectory());

            DriveInfo[] allDrives = DriveInfo.GetDrives();
            foreach (DriveInfo d in allDrives)
            {
                if (d.IsReady && d.DriveType == DriveType.Fixed)
                {
                    dirs.Add(d.RootDirectory.Name + "gstreamer");
                    dirs.Add(d.RootDirectory.Name + "Program Files" + Path.DirectorySeparatorChar + "gstreamer");
                    dirs.Add(d.RootDirectory.Name + "Program Files (x86)" + Path.DirectorySeparatorChar + "gstreamer");
                }
            }

            var is64bit = Environment.Is64BitProcess;

            foreach (var dir in dirs)
            {
                if (Directory.Exists(dir))
                {
                    var ans = Directory.GetFiles(dir, "libgstreamer-1.0-0.dll", SearchOption.AllDirectories);

                    ans = ans.Where(a =>
                                    (!is64bit && !a.ToLower().Contains("_64")) || is64bit && a.ToLower().Contains("_64")).ToArray();

                    if (ans.Length > 0)
                    {
                        log.Info("Found gstreamer " + ans.First());
                        SetGSTPath(ans.First());
                        return(ans.First());
                    }
                }
            }

            log.Info("No gstreamer found");
            return("");
        }
コード例 #13
0
        public static string CheckLogFile(string FileName)
        {
            if (Program.WindowsStoreApp)
            {
                CustomMessageBox.Show(Strings.Not_available_when_used_as_a_windows_store_app);
                return("");
            }

            var dir = Settings.GetDataDirectory() + "LogAnalyzer" +
                      Path.DirectorySeparatorChar;

            var runner = dir + "runner.exe";

            var zip = dir + "LogAnalyzer.zip";

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            //if (!File.Exists(runner))
            {
                Loading.ShowLoading("Downloading LogAnalyzer");
                bool gotit = false;
                if (Environment.Is64BitOperatingSystem)
                {
                    gotit = Common.getFilefromNet(
                        "http://firmware.ardupilot.org/Tools/MissionPlanner/LogAnalyzer/LogAnalyzer64.zip",
                        zip);
                }
                else
                {
                    gotit = Common.getFilefromNet(
                        "http://firmware.ardupilot.org/Tools/MissionPlanner/LogAnalyzer/LogAnalyzer.zip",
                        zip);
                }

                // download zip
                if (gotit)
                {
                    Loading.ShowLoading("Extracting zip file");
                    // extract zip
                    FastZip fzip = new FastZip();
                    fzip.ExtractZip(zip, dir, "");
                }
                else
                {
                    if (!File.Exists(runner))
                    {
                        CustomMessageBox.Show("Failed to download LogAnalyzer");
                        return("");
                    }
                }
            }

            if (!File.Exists(runner))
            {
                CustomMessageBox.Show("Failed to download LogAnalyzer");
                return("");
            }

            var sb = new StringBuilder();

            Process P = new Process();

            P.StartInfo.FileName  = runner;
            P.StartInfo.Arguments = @" -x """ + FileName + @".xml"" -s """ + FileName + @"""";

            P.StartInfo.UseShellExecute  = false;
            P.StartInfo.WorkingDirectory = dir;

            P.StartInfo.RedirectStandardOutput = true;
            P.StartInfo.RedirectStandardError  = true;

            P.OutputDataReceived += (sender, args) => sb.AppendLine(args.Data);
            P.ErrorDataReceived  += (sender, args) => sb.AppendLine(args.Data);

            try
            {
                Loading.ShowLoading("Running LogAnalyzer");

                P.Start();

                P.BeginOutputReadLine();
                P.BeginErrorReadLine();

                // until we are done
                P.WaitForExit();

                log.Info(sb.ToString());
            }
            catch
            {
                CustomMessageBox.Show("Failed to start LogAnalyzer");
            }

            Loading.Close();

            return(FileName + ".xml");
        }