private void DisconnectFromDevice()
        {
            if (IsUserWantToSaveDeviceConfiguration())
            {
                OperationTask nextDisconnectTask = new OperationTask
                {
                    OperationToExecute = WorkerTasks.Disconnect,
                    OperationArgument  = null
                };
                OperationTask writeTask = new OperationTask
                {
                    OperationToExecute = WorkerTasks.Writing,
                    OperationArgument  = nextDisconnectTask
                };
                ChannelReady = false;
                _worker.RunWorkerAsync(writeTask);
                return;
            }

            ReaderSaver.DisconnectFromDevice();
            СonnectionStatus      = "Отключено";
            OperationStatus       = "";
            PortIsOpen            = false;
            IsConfigurationLoaded = false;
            _deviceSnapshotBefore = null;
        }
        public void ExecuteDeviceCommand(object param)
        {
            DeviceControlCommands command = (DeviceControlCommands)param;
            OperationTask         task    = new OperationTask
            {
                OperationToExecute = WorkerTasks.ExecutingCommand,
                OperationArgument  = command
            };

            ChannelReady = false;
            _worker.RunWorkerAsync(task);
        }
        private void WriteConfigurationToDevice()
        {
            if (MessageBoxResult.No == MessageBox.Show("Записать конфигурацию в устройство?", Constants.messageBoxTitle,
                                                       MessageBoxButton.YesNo, MessageBoxImage.Question))
            {
                return;
            }

            OperationTask task = new OperationTask
            {
                OperationToExecute = WorkerTasks.Writing,
                OperationArgument  = null
            };

            ChannelReady = false;
            _worker.RunWorkerAsync(task);
        }
        private void ConnectToDevice()
        {
            if (IsUserWantToSaveDeviceConfiguration())
            {
                OperationTask nextConnectTask = new OperationTask
                {
                    OperationToExecute = WorkerTasks.Connect,
                    OperationArgument  = null
                };
                OperationTask writeTask = new OperationTask
                {
                    OperationToExecute = WorkerTasks.Writing,
                    OperationArgument  = nextConnectTask
                };
                ChannelReady = false;
                _worker.RunWorkerAsync(writeTask);
                return;
            }
            try
            {
                OperationStatus = "Подключение...";
                ReaderSaver.ConnectToDevice(true);
            }
            catch (Exception exception)
            {
                MessageBox.Show("Ошибка подключения:" + exception.Message,
                                Constants.messageBoxTitle, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return;
            }

            /*OperationTask task = new OperationTask
             * {
             *  OperationToExecute = WorkerTasks.SetSlaveMode,
             *  OperationArgument = null
             * };*/
            OperationTask task = new OperationTask
            {
                OperationToExecute = WorkerTasks.Reading,
                OperationArgument  = null
            };

            ChannelReady = false;
            _worker.RunWorkerAsync(task);
        }