예제 #1
0
        public AwaitableCommandInfo(AppToUCICommand command) : base(command)
        {
            if (ExpectedResponses.Length != 1)
            {
                throw new ArgumentException("Awaitable Command must have one expected response.");
            }

            ExpectedResponse = ExpectedResponses[0];
        }
예제 #2
0
 public CommandInfo(AppToUCICommand command)
 {
     ArgumentCount = CommandAttribute.GetExpectedArgCount(command);
     CommandSent   = command;
     CommandText   = CommandAttribute.GetCommandString(command);
     // ExpectedResponseFlags = command.
     ExpectedResponses = CommandAttribute.GetExpectedResponse(command);
     ExactMatch        = CommandAttribute.GetExactMatch(command);
     CommandArguments  = new string[] { };
 }
예제 #3
0
        public void TestEnqueueInterruptCommand_ClearsExistingCommands(AppToUCICommand interruptCommand)
        {
            var expectedSize = 5;

            for (var i = 0; i < expectedSize; i++)
            {
                q.Enqueue(new CommandInfo(AppToUCICommand.IsReady));
            }

            Assert.AreEqual(expectedSize, q.Count());
            q.Enqueue(new InterruptCommand(interruptCommand));
            Assert.AreEqual(1, q.Count());
        }
예제 #4
0
        public void TestEnqueueInterruptCommand_SendsAppropriateEvent(AppToUCICommand interruptCommand,
                                                                      bool shouldReceiveInterruptEvent)
        {
            var expectedSize       = 5;
            var timeout            = 100;
            var expectedWaitHandle = shouldReceiveInterruptEvent ? 0 : WaitHandle.WaitTimeout;

            for (var i = 0; i < expectedSize; i++)
            {
                q.Enqueue(new CommandInfo(AppToUCICommand.IsReady));
            }

            Assert.AreEqual(expectedSize, q.Count());
            q.Enqueue(new InterruptCommand(interruptCommand));
            var waitHandle = WaitHandle.WaitAny(new[] { q.InterruptIssued }, timeout);

            Assert.AreEqual(expectedWaitHandle, waitHandle);
        }
예제 #5
0
 public InterruptCommand(AppToUCICommand command) : base(command)
 {
 }
예제 #6
0
        public static int GetExpectedArgCount(AppToUCICommand command)
        {
            var countStr = command.AsString(ArgumentCountFormat);

            return(int.Parse(countStr));
        }
예제 #7
0
        //public static UCIToAppCommand GetExpectedResponseFlags(AppToUCICommand command)
        //{
        //    return Enum.Parse(typeof(UCIToAppCommand), command.AsString(uciResponseFlagsFormat));
        //}

        public static bool GetExactMatch(AppToUCICommand command)
        {
            return(bool.Parse(command.AsString(UCIExactMatchFormat)));
        }
예제 #8
0
        public static string[] GetExpectedResponse(AppToUCICommand command)
        {
            var str = command.AsString(UCIResponseFormat);

            return(str.Split('|'));
        }
예제 #9
0
 public static string GetCommandString(AppToUCICommand command)
 {
     return(command.AsString(UciCommandFormat));
 }
예제 #10
0
 public static bool IsInterruptCommand(this AppToUCICommand command)
 {
     return(new[] { AppToUCICommand.Stop, AppToUCICommand.Quit }.Contains(command));
 }