Exemplo n.º 1
0
        static void Main(string[] args)
        {
            System.Windows.Forms.Application.EnableVisualStyles();
            if (!mySingleInstanceMutex.WaitOne(0, false))
            {
                if (DialogResult.Yes != MessageBox.Show("Running MeGUI instance detected!\n\rThere's not really much point in running multiple copies of MeGUI, and it can cause problems.\n\rDo You still want to run yet another MeGUI instance?", "Running MeGUI instance detected", MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
                {
                    return;
                }
            }
            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            CommandlineParser parser = new CommandlineParser();

            parser.Parse(args);
            MeGUIInfo info     = new MeGUIInfo();
            MainForm  mainForm = new MainForm();

            mainForm.AttachInfo(info);
            info.handleCommandline(parser);
            if (parser.start)
            {
                Application.Run(mainForm);
            }
        }
Exemplo n.º 2
0
        private static unsafe void CreateProcess(byte *str_addr, byte *exec_path, uint priority)
        {
            var sb = new StringBuilder();

            while (*str_addr != '\0')
            {
                sb.Append(*str_addr);
                str_addr++;
            }

            var commandLine = sb.ToString();
            var cmd         = CommandlineParser.Parse(commandLine, Kernel.Variables);

            var path = new StringBuilder();

            while (*exec_path != '\0')
            {
                sb.Append(*exec_path);
                str_addr++;
            }

            var file    = Kernel.FileSystem.GetFile(path.ToString());
            var buffer  = Cosmos.Core.Memory.Heap.Alloc((uint)file.mSize);
            var stream  = file.GetFileStream();
            int tmpByte = stream.ReadByte();

            var bufferPtr = buffer;

            while (tmpByte != -1)
            {
                *bufferPtr = (byte)tmpByte;
                tmpByte = stream.ReadByte();
            }

            var process = new Process.Process(commandLine, cmd.Args, (int)priority);

            process.PCB.Context = new INTs.IRQContext {
                CS         = process.PCB.Context.CS,
                EAX        = process.PCB.Context.EAX,
                EBX        = process.PCB.Context.EBX,
                ECX        = process.PCB.Context.ECX,
                EDX        = process.PCB.Context.EDX,
                EDI        = process.PCB.Context.EDI,
                EFlags     = process.PCB.Context.EFlags,
                EIP        = (uint)buffer,
                ESI        = process.PCB.Context.ESI,
                ESP        = process.PCB.Context.ESP,
                Interrupt  = process.PCB.Context.Interrupt,
                MMXContext = process.PCB.Context.MMXContext,
                Param      = process.PCB.Context.Param,
                UserESP    = process.PCB.Context.UserESP
            };
            // TODO: Setting PC register in process.Context to pointer to the buffer.

            ProcessManager.ProcessList.Add(process);
            ProcessManager.ReadyQueue.Enqueue(process);
        }
Exemplo n.º 3
0
 static int Main(string[] args)
 {
     try
     {
         return(CommandlineParser.Parse <Program>(args));
     }
     catch (CommandLineException e)
     {
         CommandlineParser.PrintHelp(e.CommandContext, e.Message);
         return(-1);
     }
 }
Exemplo n.º 4
0
 static void Main(string[] args)
 {
     System.Windows.Forms.Application.EnableVisualStyles();
     if (!mySingleInstanceMutex.WaitOne(0, false))
     {
         if (DialogResult.Yes != MessageBox.Show("Running MeGUI instance detected!\n\rThere's not really much point in running multiple copies of MeGUI, and it can cause problems.\n\rDo You still want to run yet another MeGUI instance?", "Running MeGUI instance detected", MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
             return;
     }
     Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
     Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
     CommandlineParser parser = new CommandlineParser();
     parser.Parse(args);
     MeGUIInfo info = new MeGUIInfo();
     MainForm mainForm = new MainForm();
     mainForm.AttachInfo(info);
     info.handleCommandline(parser);
     if (parser.start)
         Application.Run(mainForm);
 }
Exemplo n.º 5
0
        /// <summary>
        /// Handles the commandline parameters (if any).
        /// </summary>
        private void HandleCommandLineParameters()
        {
            string configFilename = null;
            string inputFilename  = null;
            int    inputSignal    = -1;
            string outputFilename = null;
            bool   showHelp       = false;
            string usage          = string.Empty;
            double lp             = double.NaN;
            double hp             = double.NaN;

            if (Environment.GetCommandLineArgs().Length > 0)
            {
                //// First check the getopt() way....
                //CommandlineParserGetOpt commandLineParserGetOpt = new CommandlineParserGetOpt();
                //commandLineParserGetOpt.AddOption("c", "configfilename", "Configuration file containing analysis parameters",
                //                       CommandlineOptionFlags.HasParameter | CommandlineOptionFlags.Required,
                //                       (p, v) => { configFilename = v; });
                //commandLineParserGetOpt.AddOption("h", "help", "Show usage help",
                //                       CommandlineOptionFlags.HideInUsage,
                //                       (p, v) => { showHelp = true; });

                //commandLineParserGetOpt.Parse();

                //if (showHelp)
                //  usage = commandLineParserGetOpt.GetHelp();

                //if (!showHelp && commandLineParserGetOpt.MissingRequiredOptions.Count > 0)
                //{
                //  CommandlineParser commandlineParser = new CommandlineParser();
                //  commandlineParser.AddOption("EdfInputFilename", string.Empty, "EDF(+) input filename", string.Empty,
                //                              CommandlineOptionFlags.Required, (p, v) =>
                //                                                                 { inputFilename = v; }, 0);
                //  commandlineParser.AddOption("SignalIndex", string.Empty, "Index (0 - N) of signal to be analysed",
                //                              string.Empty, CommandlineOptionFlags.Required,
                //                              (p, v) => int.TryParse(v, out inputSignal), 1);
                //  commandlineParser.AddOption("OutputFilename", string.Empty, "Analysis output filename", string.Empty,
                //                              CommandlineOptionFlags.Required, (p, v) =>
                //                                                                 { outputFilename = v; }, 2);
                //  commandlineParser.AddOption("ConfigurationFilename", string.Empty, "Configuration filename", string.Empty,
                //                              CommandlineOptionFlags.None, (p, v) =>
                //                              { configFilename = v; }, 3);
                //  commandlineParser.AddOption("Batch", string.Empty, "Batchmode, no user interaction",
                //                              (p, v) => { BatchMode = true; });
                //  commandlineParser.AddOption("LP", string.Empty, "Low Pass filter value (Hz)",
                //                              CommandlineOptionFlags.HasParameter, (p, v) => TryParseToDouble(v, out lp));
                //  commandlineParser.AddOption("HP", string.Empty, "High Pass filter value (Hz)",
                //                              CommandlineOptionFlags.HasParameter, (p, v) => TryParseToDouble(v, out hp));
                //  commandlineParser.AddOption("?", string.Empty, "Show usage help",
                //                         CommandlineOptionFlags.HideInUsage,
                //                         (p, v) => { showHelp = true; });

                //  commandlineParser.Parse();

                //  if (showHelp)
                //    usage = commandlineParser.GetHelp();
                //}

                CommandlineParser commandlineParser = new CommandlineParser();
                commandlineParser.AddOption("Input", string.Empty, "EDF(+) input filename", "EdfInputFilename",
                                            CommandlineOptionFlags.HasParameter, (p, v) => { inputFilename = v; });
                commandlineParser.AddOption("SignalIndex", string.Empty, "Index (0 - N-1" + ") of signal to be analysed",
                                            "SignalIndex", CommandlineOptionFlags.HasParameter,
                                            (p, v) => int.TryParse(v, out inputSignal));
                commandlineParser.AddOption("Output", string.Empty, "Analysis output filename", "OutputFilename",
                                            CommandlineOptionFlags.HasParameter, (p, v) => { outputFilename = v; });
                commandlineParser.AddOption("ConfigFile", string.Empty, "Configuration filename", "ConfigurationFilename",
                                            CommandlineOptionFlags.HasParameter, (p, v) =>
                                            { configFilename = v; });
                commandlineParser.AddOption("LP", string.Empty, "Low Pass filter value (Hz)", "LowestLowPassFrequency",
                                            CommandlineOptionFlags.HasParameter, (p, v) => TryParseToDouble(v, out lp));
                commandlineParser.AddOption("HP", string.Empty, "High Pass filter value (Hz)", "HighestHighPassFrequency",
                                            CommandlineOptionFlags.HasParameter, (p, v) => TryParseToDouble(v, out hp));
                commandlineParser.AddOption("Batch", string.Empty, "Batchmode, no user interaction",
                                            (p, v) => { BatchMode = true; });
                commandlineParser.AddOption("?", string.Empty, "Show usage help",
                                            CommandlineOptionFlags.HideInUsage,
                                            (p, v) => { showHelp = true; });

                commandlineParser.Parse();

                if (showHelp)
                {
                    MessageBox.Show(commandlineParser.GetHelp(), Strings.UsageInformation);
                    Application.Exit();
                }
            }

            // Read configuration settings from file; use default settings if no configuration file was set
            if (string.IsNullOrEmpty(configFilename))
            {
                ErrorLogger.WriteLog("Configuration file not provided, using default configuration parameters");
            }
            else
            {
                ErrorLogger.WriteLog("Using configuration parameters from file " + configFilename);
            }

            _configuration = new MCconfiguration(configFilename);

            if (!string.IsNullOrEmpty(outputFilename))
            {
                _configuration.OutputFileName = outputFilename;
            }
            if (File.Exists(inputFilename))
            {
                textBoxInputFilename.Text = inputFilename;
            }
            if (inputSignal >= 0)
            {
                signalsComboBox.SelectedIndex = inputSignal;
            }

            if (!double.IsNaN(lp))
            {
                textBoxLP.Text = lp.ToString();
            }
            if (!double.IsNaN(hp))
            {
                textBoxHP.Text = hp.ToString();
            }

            NeuroLoopGainController.AppController.AppConf = _configuration;

            // Default values for textBoxes
            textBoxF0.Text             = _configuration.F0.ToString(FormatProvider);
            textBoxB.Text              = _configuration.BandWidth.ToString(FormatProvider);
            textBoxFc.Text             = _configuration.FC.ToString(FormatProvider);
            textBoxSmootherrate.Text   = _configuration.SmoothRate.ToString(FormatProvider);
            textBoxAnalysisPeriod.Text = _configuration.SmoothTime.ToString(FormatProvider);
            textBoxOutputFileName.Text = _configuration.OutputFileName;

            if (!BatchMode)
            {
                return;
            }

            // Batchmode requested; perform analysis without user input and close application after processing
            buttonStart_Click(this, new EventArgs());
            Application.Exit();
        }