Пример #1
0
        public override ICommandResponseAsync Execute(ICommand command)
        {
            IProtocol result = null;

            switch (command.commandID)
            {
            case ECommand.ServoCommand:
            {
                result = ExecuteServoCommands(command);
                break;
            }
            }

            if (result == null)
            {
                DebugUtility.LogError(LoggerTags.Project, "Failure to execute command : {0}", command);
            }
            else
            {
                DebugUtility.Log(LoggerTags.Project, "Success to execute command : {0}", command);
            }
            var cra = new CommandResponseAsync(result);

            cra.host    = command.host;
            cra.context = command.context;
            return(cra);
        }
Пример #2
0
        public ICommandResponseAsync Execute(ICommand command)
        {
            bool enableBroadcast      = commandType == ECommandType.Broadcast;
            ICommandResponseAsync job = null;

            for (var i = 0; i < mCommandHandlers.Count; ++i)
            {
                var h = mCommandHandlers[i];
                if (h.Verify(command))
                {
                    DebugUtility.Log(LoggerTags.Online, "Try to execute command in component  {0} - {1}", h, command);

                    var result = h.Execute(command);
                    if (result != null)
                    {
                        if (job == null)
                        {
                            job = new CommandResponseAsync();
                        }
                        job.AddResponse(result);
                        // 不是广播模式,立即停止
                        if (!enableBroadcast)
                        {
                            break;
                        }
                    }
                }
                else
                {
                    DebugUtility.Log(LoggerTags.Online, "Fail to verify command in component  {0} - {1}", h, command);
                }
            }
            return(job);
        }
Пример #3
0
        public override ICommandResponseAsync Execute(ICommand command)
        {
            bool      resImme = false;
            IProtocol result  = null;

            switch (command.commandID)
            {
            case ECommand.UKitCommand:
            {
                resImme = ExecuteUKitCommands(command, out result);
                break;
            }
            }

            if (result == null)
            {
                DebugUtility.LogError(LoggerTags.Project, "Failure to execute command : {0}", command);
            }

            ICommandResponseAsync cra = null;

            if (resImme)
            {
                DebugUtility.Log(LoggerTags.Project, "Success to execute command : {0} - Immediately", command);
                var cra2 = new CommandResponseAsync(result);
                cra2.host    = command.host;
                cra2.context = command.context;
                cra          = cra2;
            }
            else if (result != null)
            {
                DebugUtility.Log(LoggerTags.Project, "Success to execute command : {0} - Delay", command);
                waitingInputAsync         = new TriggerCommandResponseAsync(result);
                waitingInputAsync.host    = command.host;
                waitingInputAsync.context = command.context;
                cra = waitingInputAsync;
            }
            return(cra);
        }
Пример #4
0
        public virtual ICommandResponseAsync Execute(ICommand command)
        {
            bool enableBroadcast      = commandType == ECommandType.Broadcast;
            bool exitResponse         = false;
            ICommandResponseAsync job = null;

            for (var i = 0; i < parts.Count; ++i)
            {
                var h = parts[i];
                if (h.Verify(command))
                {
                    DebugUtility.Log(LoggerTags.Online, "Try to execute command in part  {0} - {1}", h.gameObject.name, command);
                    var result = h.Execute(command);
                    if (result != null)
                    {
                        if (job == null)
                        {
                            job = new CommandResponseAsync();
                        }
                        job.AddResponse(result);
                        exitResponse = true;
                        // 不是广播模式,立即停止
                        if (!enableBroadcast)
                        {
                            break;
                        }
                    }
                }
                else
                {
                    // DebugUtility.Log(LoggerTags.Online, "Fail to verify command : {0} - {1}", h.gameObject.name, command);
                }
            }

            return(job);
        }