Exemplo n.º 1
0
        public SonOfStrikeGui cmd(string cmdToExecute)
        {
            if (cmdToExecute.starts(">"))
            {
                sosApi.invoke(cmdToExecute.removeFirstChar());
            }
            else
            {
                switch (cmdToExecute)
                {
                //case "Ctrl+C":
                //	cmdApi.hostCmd_Ctrl_C();
                //	break;
                case "queue":                           // while debugging
                    "there are {0} items in the queue".format(ExecutionQueue.Count).error();
                    //ExecutingRequest.Set();
                    break;

                case "queueSet":                                // while debugging
                    "ExecutingRequest.Set()".error();
                    ExecutingRequest.Set();
                    break;

                default:
                    addToExecutionQueue(cmdToExecute);
                    break;
                }
            }
            selectThis();
            return(this);
        }
Exemplo n.º 2
0
 public void dataReceived(string text)
 {
     if (text.contains(endExecutionString))
     {
         var size = LastCommandResult.str().size();
         try
         {
             var snipptet = (size == 0) ? "" : LastCommandResult.str().Substring(0, (size > 40) ? 40 : size);
             var stats    = "Execution Result: {0} chars [{1}]".format(size, snipptet).remove("".line()).lineBeforeAndAfter();
             stats.info();
             writeToOutput(stats);
             if (size == 0)
             {
                 writeToOutput("[no data returned]".lineBeforeAndAfter());
             }
         }
         catch (Exception ex)
         {
             ex.log("in SonOfStrikeApi.dataReceived");
         }
         ExecutingRequest.Set();
         //processExecutionQueue();
         return;
     }
     //if (text.starts(cdbPrompt))
     //	text = text.Substring(cdbPrompt.Length);
     LastCommandResult.AppendLine(text);
     if (sosApi.showReceivedData)
     {
         writeToOutput(text);
     }
 }
Exemplo n.º 3
0
        public Thread processExecutionQueue()
        {
            return(O2Thread.mtaThread(
                       () => {
                if (ExecutionQueue.Count == 0)
                {
                    return;
                }

                while (ExecutingRequest.WaitOne(1000).isFalse())                                                // after one second check if the next command is Ctrl+C
                {
                    if (ExecutionQueue.Peek() == "Ctrl+C")
                    {
                        //ExecutionQueue.Dequeue();
                        "breaking loop".error();
                        //cmdApi.hostCmd_Ctrl_C();
                        break;
                    }
                }
                //ExecutingRequest.Reset();
                //if (ExecutionQueue.Count == 0)
                //	return;

                LastCommandResult = new StringBuilder();

                var cmdToExecute = ExecutionQueue.Dequeue();
                "executing Queued command:{0}".format(cmdToExecute).debug();
                //"from queue, executing cmd:{0}".format(cmdToExecute).debug();
                //cmd(cmdToExecute);
                sosApi.setShowHideReceivedDataForCommand(cmdToExecute);
                if (cmdToExecute == "Ctrl+C")
                {
                    cmdApi.hostCmd_Ctrl_C();
                }
                else
                {
                    cmdApi.hostCmd(cmdToExecute);
                    cmdApi.hostCmd(extraExecutionCommand);                                      // so we can detect when the execution is completed
                }
            }));
        }