private async Task EnableRfid(RfidOptions options) { logger.Information("Starting RFID"); stream = factory.CreateStream(options.GetConnectionString()); disposable = new CompositeDisposable(stream, stream.Tags.Subscribe(x => { if (options.PersistTags) { logger.Swallow(() => storageService.AppendTag(mapper.Map <Tag>(x))); } AppendRiderId(x.TagId); })); aggregator = TimestampAggregatorConfigurations.ForCheckpoint(TimeSpan.FromMilliseconds(options.CheckpointAggregationWindowMs)); disposable.Add(stream.Connected.CombineLatest(stream.Heartbeat, (con, hb) => new ReaderStatus { IsConnected = con, Heartbeat = hb }) .Subscribe(OnReaderStatus) ); disposable.Add(checkpoints.Subscribe(aggregator)); disposable.Add(aggregator.Subscribe(OnCheckpoint)); disposable.Add(aggregator.AggregatedCheckpoints.Subscribe(OnCheckpoint)); await stream.Start(); }
private async void Button_Click(object sender, RoutedEventArgs e) { if (stream != null) { stream.DisposeSafe(); } stream = factory.CreateStream("protocol=Alien;Network=127.0.0.1:20023;RfPower=200;AntennaConfiguration=Antenna1"); stream.Connected.Subscribe(c => Dispatcher.BeginInvoke(new Action(() => { connectionStatus.Text = $"{DateTime.Now}> Connected: {c}"; }))); stream.Errors.Subscribe(err => Dispatcher.BeginInvoke(new Action(() => { errors.Text = $"{DateTime.Now}> {err}"; }))); stream.Tags.Subscribe(tag => Dispatcher.BeginInvoke(new Action(() => { tags.Text = tag.TagId; }))); await stream.Start(); }