Exemplo n.º 1
0
        public void CompileToVisualC()
        {
            try
            {
                string baseFileName = ProbeEnvironment.FindBaseFile(ActiveFileName);
                if (string.IsNullOrEmpty(baseFileName))
                {
                    MessageBox.Show("Base file could not be found.");
                    return;
                }

                var pr = new ProcessRunner();
                int exitCode = pr.ExecuteProcess("fec.exe", string.Concat("\"", baseFileName, "\""),
                    Path.GetDirectoryName(baseFileName), true);

                if (exitCode != 0)
                {
                    Errors.Show(NppWindow, "FEC returned exit code {0}.", exitCode);
                    return;
                }

                var cFileName = Path.Combine(Path.GetDirectoryName(baseFileName),
                    string.Concat(Path.GetFileNameWithoutExtension(baseFileName), ".c"));
                if (!File.Exists(cFileName))
                {
                    Errors.Show(NppWindow, "Unable to find .c file produced by FEC.");
                    return;
                }

                OpenFile(cFileName);
            }
            catch (Exception ex)
            {
                Errors.Show(NppWindow, ex);
            }
        }
Exemplo n.º 2
0
        private bool RunSam()
        {
            if (_plugin.Settings.RunSamCam.SetDbDate)
            {
                ProcessRunner pr = new ProcessRunner();
                int exitCode = pr.ExecuteProcess("setdbdat", "today force", ProbeEnvironment.TempDir, true);
                if (exitCode != 0)
                {
                    Errors.Show(this, "\"setdbdat today force\" returned exit code {0}.\n\n" +
                        "(The SAM will still start, but the dbdate may be incorrect)", exitCode);
                }
            }

            StringBuilder args = new StringBuilder();
            args.Append(string.Format("/N{0}", CleanSamName(string.Concat(ProbeEnvironment.CurrentApp, "_", System.Environment.UserName))));
            args.Append(string.Format(" /p{0}", ProbeEnvironment.SamPort));
            args.Append(" /o0");
            args.Append(string.Format(" /y{0:00}{1:00}", _plugin.Settings.RunSamCam.TransReportTimeout, _plugin.Settings.RunSamCam.TransAbortTimeout));
            args.Append(string.Format(" /z{0}", _plugin.Settings.RunSamCam.MinChannels));
            args.Append(string.Format(" /Z{0}", _plugin.Settings.RunSamCam.MaxChannels));
            if (_plugin.Settings.RunSamCam.Diags) args.Append(" /d2");

            using (Process proc = new Process())
            {
                ProcessStartInfo info = new ProcessStartInfo("sam", args.ToString());
                info.UseShellExecute = false;
                info.RedirectStandardOutput = false;
                info.RedirectStandardError = false;
                info.CreateNoWindow = false;
                info.WorkingDirectory = ProbeEnvironment.ExeDir;
                proc.StartInfo = info;
                if (!proc.Start())
                {
                    Errors.Show(this, "Unable to start the SAM.");
                    return false;
                }
            }

            if (_plugin.Settings.RunSamCam.LoadSam && !_plugin.Settings.RunSamCam.Diags) RunLoadSam();

            return true;
        }