public Bus(IOsdpConnection connection, BlockingCollection <Reply> replies, ILogger <ControlPanel> logger = null) { _connection = connection ?? throw new ArgumentNullException(nameof(connection)); _replies = replies ?? throw new ArgumentNullException(nameof(replies)); _logger = logger; Id = Guid.NewGuid(); }
private static void StartConnection(IOsdpConnection osdpConnection) { _controlPanel.Shutdown(); _connectionId = _controlPanel.StartConnection(osdpConnection); foreach (var device in _settings.Devices) { _controlPanel.AddDevice(_connectionId, device.Address, device.UseCrc, device.UseSecureChannel, device.SecureChannelKey); } }
/// <summary> /// Start polling on a connection /// </summary> /// <param name="connection">Details of the connection</param> /// <returns>The id of the connection</returns> public Guid StartConnection(IOsdpConnection connection) { var newBus = new Bus(connection, _replies, _logger); newBus.ConnectionStatusChanged += BusOnConnectionStatusChanged; _buses.Add(newBus); Task.Factory.StartNew(async() => { await newBus.StartPollingAsync().ConfigureAwait(false); }, TaskCreationOptions.LongRunning); return(newBus.Id); }