示例#1
0
        public int GetCommandType()
        {
            Log.Debug("GetCommandType: called.");

            _currentTask = DequeueTask();

            return(_currentTask?.Command?.CommandType ?? 0);
        }
示例#2
0
        public void SendResponse(MtResponse response)
        {
            Log.DebugFormat("SendResponse: begin. response = {0}", response);

            _currentTask.SetResult(response);
            _currentTask = null;

            Log.Debug("SendResponse: end.");
        }
示例#3
0
        public void Execute(MtCommandTask task)
        {
            lock (_taskQueue)
            {
                _taskQueue.Enqueue(task);
            }

            NotifyCommandReady();
        }
示例#4
0
        public void SendResponse(MtResponse response)
        {
            Log.DebugFormat("SendResponse: begin. response = {0}", response);

            _commandTask.SetResult(response);
            _commandTask = null;
            FireOnCommandExecuted();

            Log.Debug("SendResponse: end.");
        }
示例#5
0
        public int GetCommandType()
        {
            Log.Debug("GetCommandType: called.");

            var commandManager = CommandManager;

            if (commandManager != null)
            {
                _commandTask = commandManager.DequeueCommandTask();
            }

            return(_commandTask?.Command?.CommandType ?? 0);
        }
示例#6
0
        public void EnqueueCommandTask(MtCommandTask task)
        {
            if (task == null)
            {
                return;
            }

            lock (_locker)
            {
                _commandTasks.Enqueue(task);
            }

            NotifyCommandReady();
        }
示例#7
0
        public MtResponse SendCommand(MtCommand command)
        {
            MtResponse response = null;

            if (command != null)
            {
                var task = new MtCommandTask(command);
                _executorManager.EnqueueCommandTask(task);

                //wait for execute command in MetaTrader
                response = task.WaitResult(WAIT_RESPONSE_TIME);
            }

            return(response);
        }
示例#8
0
        public void EnqueueCommandTask(MtCommandTask task)
        {
            if (task == null)
            {
                throw new ArgumentNullException(nameof(task));
            }

            Log.DebugFormat("EnqueueCommandTask: begin. task = {0}", task);

            lock (_locker)
            {
                _commandTasks.Enqueue(task);
            }

            NotifyCommandReady();

            Log.Debug("EnqueueCommandTask: end.");
        }
示例#9
0
        public MtResponse SendCommand(MtCommand command)
        {
            Log.DebugFormat("SendCommand: begin. command {0}", command);

            if (command == null)
            {
                Log.Warn("SendCommand: end. command is not defined");
                return(null);
            }

            var task = new MtCommandTask(command);

            _executorManager.EnqueueCommandTask(task);

            //wait for execute command in MetaTrader
            var response = task.WaitResult(WaitResponseTime);

            return(response);
        }
示例#10
0
        public MtCommandTask SendCommand(MtCommand command)
        {
            if (command == null)
            {
                throw new ArgumentNullException(nameof(command));
            }

            var task = new MtCommandTask(command);

            Log.DebugFormat("SendTask: begin. command = {0}", command);

            ITaskExecutor executor;

            lock (_locker)
            {
                if (_executorMap.ContainsKey(command.ExpertHandle))
                {
                    executor = _executorMap[command.ExpertHandle];
                }
                else
                {
                    executor = _executorList.Count > 0 ? _executorList[0] : null;
                }
            }

            if (executor == null)
            {
                Log.Error("SendTask: Executor is null!");
            }
            else
            {
                executor.Execute(task);
            }

            Log.Debug("SendTask: end.");

            return(task);
        }