Exemplo n.º 1
0
        private void singleExecute()
        {
            // Get new raw command if nothing is running at the moment
            if (rawCommand == null)
            {
                // If there isn't anything in queue, nothing to do
                if (commands.Count == 0)
                {
                    timeToConsume = 0f;
                    return;
                }
                // Get command
                AbsCmd command = commands[0];
                commands.RemoveAt(0);
                rawCommand = command.getRawCommand(dotMatrix, displayModel, this);
                // Possibly add back to queue
                if (command.Repeat)
                {
                    commands.Add(command);
                }
            }

            // Run raw command
            timeToConsume = rawCommand.runStep(displayModel, timeToConsume);

            // Clear raw command if finished
            if (rawCommand.isFinished(displayModel))
            {
                rawCommand = null;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Replace command in controller queue. If command that is replaced is currently being executed it will finish normally.
        /// If command to replace doesn't found, this method changes nothing.
        /// </summary>
        /// <param name="oldCommand">
        /// Command to remove from queue.
        /// </param>
        /// <param name="newCommand">
        /// Command to be added to queue to the same index where old command was.
        /// </param>
        /// <returns>
        /// True if command was replaced, false otherwise.
        /// </returns>
        public bool ReplaceCommand(AbsCmd oldCommand, AbsCmd newCommand)
        {
            int index = commands.IndexOf(oldCommand);

            if (index == -1)
            {
                return(false);
            }
            commands.RemoveAt(index);
            commands.Insert(index, newCommand);
            return(true);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Remove command from controller queue. If this command is currently being executed it will finish normally.
 /// </summary>
 /// <param name="command">
 /// Command to remove from queue.
 /// </param>
 /// <returns>
 /// True if command was found and removed, false otherwise.
 /// </returns>
 public bool RemoveCommand(AbsCmd command)
 {
     return(commands.Remove(command));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Add new command to controller queue. If queue is empty, instantly start executing this command.
 /// </summary>
 /// <param name="command">
 /// Command to add to queue.
 /// </param>
 public void AddCommand(AbsCmd command)
 {
     commands.Add(command);
 }