IEnumerable <TemperatureFrame> GetFromQueues() { TemperatureFrame frame = new TemperatureFrame(); frame.Time = DateTime.Now; if (!Device.Alive()) { yield break; } float value = 0.0f; while (!TemperatureStack.TryPop(out value)) { Thread.Yield(); } frame.Temperature = value; while (!HumidityStack.TryPop(out value)) { Thread.Yield(); } frame.Humidity = value; while (!PressureStack.TryPop(out value)) { Thread.Yield(); } frame.Pressure = value; yield return(frame); }
private void Device_OnHumidityRead(object sender, ReadPacket <float> e) { if (HumidityStack.Count > 100) { HumidityStack.Clear(); } HumidityStack.Push(e.Value); }