static void StartPolling(SerialReader reader, DemoArgs demoArgs) { var cs = ConnectionString.Parse(demoArgs.ConnectionString); Task.Run(async() => { temperatureSubject.OnNext(reader.GetReaderTemperature().Result); var processingTime = new Stopwatch(); var sw = Stopwatch.StartNew(); while (true) { try { processingTime.Stop(); var pTime = processingTime.Elapsed; var res = await reader.TagInventory(new TagInventoryParams { QValue = (byte)cs.QValue, Session = (SessionValue)cs.Session }); processingTime.Restart(); pollingResults.OnNext(new TagInventoryResultWithProcessingTime { Result = res, ProcessingTime = pTime }); if (sw.ElapsedMilliseconds > 10000) { var t = reader.GetReaderTemperature().Result; if (t > demoArgs.ThermalLimit) { Console.WriteLine( $"Reader is overheating, temperature is {t}. To prevent damage, stopping inventory."); Environment.Exit(t); } temperatureSubject.OnNext(t); sw.Restart(); } } catch (Exception ex) { Console.WriteLine(ex); } } }); }
public void Should_get_reader_temperature(ConnectionType connectionType) { using (var r = new SerialReader(TestSettings.Instance.GetConnection(connectionType))) { //Assume we run tests at home :) r.GetReaderTemperature().Result.Should().BeInRange(10, 50); } }