public ComPortControlViewModel(ISharedAppAbilities appAbilities, ILogger logger, IThreadNotifier notifier, IWindowSystem windowSystem, string channelName) { _appAbilities = appAbilities; _logger = logger; _notifier = notifier; _windowSystem = windowSystem; _openPortCommand = new RelayCommand(OpenPort, () => !_isPortOpened); _closePortCommand = new RelayCommand(ClosePort, () => _isPortOpened); GetPortsAvailableCommand = new RelayCommand(GetPortsAvailable); RecordVm = new RecordViewModel(_notifier, _windowSystem); //TODO: unsubscribe _channel = _appAbilities.CreateChannel(channelName); _channel.Channel.CommandHeared += SerialChannelOnCommandHeared; _channel.Channel.CommandHearedWithReplyPossibility += SerialChannelOnCommandHearedWithReplyPossibility; _channel.TimeoutMonitor.SomeCommandWasHeared += CommandHearedTimeoutMonitorOnSomeCommandWasHeared; _channel.TimeoutMonitor.NoAnyCommandWasHearedTooLong += CommandHearedTimeoutMonitorOnNoAnyCommandWasHearedTooLong; _channelWithIoProgress = _channel.Channel as ISerialChannelWithIoProgress; if (_channelWithIoProgress != null) { _channelWithIoProgress.ProgressChanged += ChannelWithIoProgressOnProgressChanged; } GetPortsAvailable(); _logger.Log("Канал обмена добавлен"); }
public SerialChannelWithTimeoutMonitorAndSendReplyAbility CreateChannel(string channelName) { var serialChannel = new SerialChannelWithTimeoutMonitorAndSendReplyAbility(new SerialChannel(new CommandPartSearcherPsnConfigBasedFast(PsnProtocolConfiguration))); _channels.Add(channelName, serialChannel); CmdNotifierStd.AddSerialChannel(serialChannel.Channel); return(serialChannel); }