コード例 #1
0
        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;
            }
        }
コード例 #2
0
 private void SetTemperatureCelsius(double reading)
 {
     if (Math.Abs(mTemperatureC - reading) > _DELTA)
     {
         TemperatureChangeEventArgs args = new TemperatureChangeEventArgs(mTemperatureC, reading);
         mTemperatureC = reading;
         OnTemperatureChanged(args);
     }
 }
コード例 #3
0
        virtual protected void OnTemperatureChanged(TemperatureChangeEventArgs args)
        {
            if (TemperatureChanged != null)
            {
                TemperatureChanged(this, args);
            }

            if (TemperatureThresholdChanged != null)
            {
                TemperatureThresholdChanged(this, args);
            }
        }
コード例 #4
0
 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);
                 }
             }
         }
     }
 }
コード例 #5
0
 public void OnTemperatureChange(object sender, TemperatureChangeEventArgs args)
 {
     mPrinterCallback(string.Format(_READING_MESSAGE, mId, args.NewTemperature));
 }