private void ShowDirectionalThreshold(Direction direction, TemperatureChangeEventArgs args) { switch (direction) { case Direction.Increasing: if ((Math.Abs(args.OldTemperature - args.NewTemperature) > mSettings.fluctuation) && (args.OldTemperature - args.NewTemperature < 0)) { Print(direction.ToString().ToUpper(), args.NewTemperature); } break; case Direction.Decreasing: if ((Math.Abs(args.OldTemperature - args.NewTemperature) > mSettings.fluctuation) && (args.OldTemperature - args.NewTemperature > 0)) { Print(direction.ToString().ToUpper(), args.NewTemperature); } break; default: if (Math.Abs(args.OldTemperature - args.NewTemperature) > mSettings.fluctuation) { string bearing = (args.OldTemperature - args.NewTemperature > 0) ? _DECREASING : _INCREASING; Print(bearing, args.NewTemperature); } break; } }
private void SetTemperatureCelsius(double reading) { if (Math.Abs(mTemperatureC - reading) > _DELTA) { TemperatureChangeEventArgs args = new TemperatureChangeEventArgs(mTemperatureC, reading); mTemperatureC = reading; OnTemperatureChanged(args); } }
virtual protected void OnTemperatureChanged(TemperatureChangeEventArgs args) { if (TemperatureChanged != null) { TemperatureChanged(this, args); } if (TemperatureThresholdChanged != null) { TemperatureThresholdChanged(this, args); } }
public void OnTemperatureThresholdChange(object sender, TemperatureChangeEventArgs args) { if (mSettings.threshold.Count > 0) { foreach (var threshold in mSettings.threshold) { if (Math.Abs(args.NewTemperature - threshold) <= _DELTA) // threashold { if (mTresholdReached) { string bearing = (args.OldTemperature - args.NewTemperature > 0) ? _DECREASING : _INCREASING; Print(bearing, args.NewTemperature); mTresholdReached = false; } else { ShowDirectionalThreshold(mSettings.direction, args); } } } } }
public void OnTemperatureChange(object sender, TemperatureChangeEventArgs args) { mPrinterCallback(string.Format(_READING_MESSAGE, mId, args.NewTemperature)); }