Exemplo n.º 1
0
        public int GetCommandType()
        {
            Log.Debug("GetCommandType: called.");

            _currentTask = DequeueTask();

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

            _currentTask.SetResult(response);
            _currentTask = null;

            Log.Debug("SendResponse: end.");
        }
Exemplo n.º 3
0
        public void Execute(MtCommandTask task)
        {
            lock (_taskQueue)
            {
                _taskQueue.Enqueue(task);
            }

            NotifyCommandReady();
        }
Exemplo n.º 4
0
        public void SendResponse(MtResponse response)
        {
            Log.DebugFormat("SendResponse: begin. response = {0}", response);

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

            Log.Debug("SendResponse: end.");
        }
Exemplo n.º 5
0
        public int GetCommandType()
        {
            Log.Debug("GetCommandType: called.");

            var commandManager = CommandManager;

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

            return(_commandTask?.Command?.CommandType ?? 0);
        }
Exemplo n.º 6
0
        public void EnqueueCommandTask(MtCommandTask task)
        {
            if (task == null)
            {
                return;
            }

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

            NotifyCommandReady();
        }
Exemplo n.º 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);
        }
Exemplo n.º 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.");
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }