Exemple #1
0
 public bool DivertToEmulation(object op, int arg, int LMIndex)
 {
     LMMMLingo.OpDesc opd = (LMMMLingo.OpDesc)op;
     commlog.TraceInformation(opd.ToString() + "(" + arg + ":" + LMIndex + ")");
     return(true);
 }
Exemple #2
0
        protected void CommandPrompt(Thread t = null)
        {
            // dev note: this Ctrl-C handler does not work when vshost is active in the dev env
            Console.CancelKeyPress      += new ConsoleCancelEventHandler(LiveDAQCtrlCHandler);
            Console.TreatControlCAsInput = false;
            string line           = "";
            bool   keepGoing      = true;
            bool   explicitPrompt = (t == null);

            Console.WriteLine(NC.App.AbbrName + "> command prompt " + NC.App.Config.VersionString + " (press CTRL+Z to exit):");
            Console.WriteLine();
            Console.Write(NC.App.AbbrName + "> ");
            NC.App.Opstate.SOH = NCC.OperatingState.Living;
            do
            {
                if ((t != null) && !Console.KeyAvailable && !explicitPrompt)
                {
                    keepGoing = !t.Join(100); // when the batch op thread ends, we're out of the prompt loop, unless we asked for the prompt. "prompt with wait sync point approach"
                }
                else
                {
                    line = Console.ReadLine();
                    if (line != null && (line.Length > 0))
                    {
                        string           tline = line.Trim();
                        LMMMLingo.OpDesc cmdt  = new LMMMLingo.OpDesc(true);
                        LMMMComm.CommandPromptMatchPrefix(tline, ref cmdt);

                        if (LMMMLingo.Tokens.unknown == cmdt.tok)
                        {
                            Console.WriteLine(NC.App.AbbrName + "> skipping '" + tline + "', \r\n  enter 'help' for valid commands");
                        }
                        else
                        {
                            Thread pnt = LMMMComm.ProcessUserCommand(cmdt, tline, this, ref keepGoing);
                            if (t == null)
                            {
                                t = pnt;
                            }
                            Console.Write(NC.App.AbbrName + ">");
                        }
                    }
                    else
                    {
                        Console.Write(NC.App.AbbrName + "> ");
                    }
                }
            } while (line != null && keepGoing);

            // Issue: user quits operations via cmd prompt but system is still going waiting for HV or file or DAQ analysis to complete.
            // todo: Solution 1 (todo): prevent exit if waiting HVCalib or Assay operations to complete, pend woud occur in ProcessUserCommand above or around it via a polling loop
            // Solution 2 (below): to use the cancellation token here, provided that t is non-null & user typed quit to prompt, so need to stop LMMM and stop the pending thread represented by t, if possible.

            if (NC.App.Opstate.SOH == NCC.OperatingState.Living && t != null && line.ToLower().StartsWith("quit"))
            {
                CancelCurrentAction();
                // todo: test this, might need to wait on it or kill it or something
                if (t.IsAlive)
                {
                    t.Abort(); // messy and likely to fail if sub-threads are pending
                }
            }
        }