コード例 #1
0
        private void LetsDoIt(ATTask atTask)
        {
            ExecuteResult result = null;

            if (_context.IsAvaliable())
            {
                ushort timeout = 10;
                Log.Info("_context valid, start robot");
                try
                {
                    result          = new ConfigCommandExecutor().Execute(task, _context, timeout);
                    result.ErrorMsg = "OK";
                }
                catch (Exception ex)
                {
                    Log.Error(ex.Message);
                    result.ErrorMsg = "FAILED";
                }
            }
            else
            {
                Log.Error("_context Busy, can't run.");
                result = new ExecuteResult
                {
                    IsOK      = false,
                    ErrorCode = (int)Errors.ERR_NOT_CONNECTED,
                    ErrorMsg  = "FAILED",
                    Task      = atTask,
                    Elapsed   = 0,
                    Finished  = DateTime.Now
                };
                foreach (var ac in atTask.AtCommands.AtCommands)
                {
                    ATCommandResult r = new ATCommandResult();
                    r.GetJsonResult(ac.ToATString());
                    result.AddAtResult(r);
                }
                result.Task.Status = DACTaskStatus.FAIL;
            }

            if (atTask.Consumer != null)
            {
                atTask.Consumer(result);
            }
            this.Stop();
        }