Exemple #1
0
        private Activity DequeueActivity(bool firstRun)
        {
            // Load the available activities into the queue if the queue is empty
            // or on first run (repeat session situation)
            if (!ExecutionQueue.Any() || firstRun)
            {
                // Add activities based on the execution count which describes
                // the overall distribution or weight of different activities
                // being executed.
                List <Activity> activities = new List <Activity>();
                foreach (var item in MasterList.OrderBy(n => n.ExecutionOrder))
                {
                    activities.Add(item);
                }

                if (Randomize)
                {
                    // If randomize was set for this collection of activities, then shuffle them
                    activities.Shuffle();
                    TraceFactory.Logger.Debug("Activities were shuffled");
                }

                foreach (Activity activity in activities)
                {
                    // Then enqueue each activity onto the execution queue.
                    ExecutionQueue.Enqueue(activity);
                }
            }

            _currentActivityExecutionCount = 1;

            return(ExecutionQueue.Dequeue());
        }
        private Activity DequeueActivity(bool firstRun)
        {
            //during a repeat session the previous session would have queued the execution queue, which makes it run out of order by 1 activity
            //by clearning the queue for the repeat session, we maintain the same order.
            if (firstRun)
            {
                ExecutionQueue.Clear();
            }

            //if there is any queued item return the topmost
            if (ExecutionQueue.Any())
            {
                return(ExecutionQueue.Dequeue());
            }

            // Load the available activities into the queue if the queue is empty
            // or on first run (repeat session situation)
            // Add activities based on the execution count which describes
            // the overall distribution or weight of different activities
            // being executed.
            List <Activity> activities = new List <Activity>();

            foreach (var activity in MasterList.OrderBy(n => n.ExecutionOrder))
            {
                for (int i = 0; i < activity.ExecutionValue; i++)
                {
                    activities.Add(activity);
                }
            }

            if (Randomize)
            {
                activities.Shuffle();
                TraceFactory.Logger.Debug("Activities were shuffled");
            }

            foreach (Activity activity in activities)
            {
                ExecutionQueue.Enqueue(activity);
            }

            return(ExecutionQueue.Dequeue());
        }
Exemple #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
                }
            }));
        }
Exemple #4
0
        // TODO: Execution logic could use a major refacoring, as it has been quite spaghettified at the moment.
        public void ExecuteAll(ExecutionMetadata metadata = null)
        {
            if (metadata == null) // If null, then create a fresh one.
            {
                metadata = new ExecutionMetadata();
            }

            if (IsExecuting)
            {
                return;
            }

            IsExecuting = true;

            while (ExecutionQueue.Count != 0)
            {
                IExecutable executable = ExecutionQueue.Dequeue();
                executable.Execute(metadata);
            }

            IsExecuting = false;
        }