Example #1
0
        void RaiseTemperatureReport(double temperature)
        {
            var eh = this.TemperatureReport;
            if (eh != null)
            {
                var args = new TemperatureReportEventArgs
                {
                    Temperature = temperature,
                    Time = DateTime.Now
                };

                eh(this, args);
            }
        }
Example #2
0
        void RaiseTemperatureReport(double temperature)
        {
            var eh = this.TemperatureReport;

            if (eh != null)
            {
                var args = new TemperatureReportEventArgs
                {
                    Temperature = temperature,
                    Time        = DateTime.Now
                };

                eh(this, args);
            }
        }
Example #3
0
        void OnTemperatureReport(object sender, TemperatureReportEventArgs e)
        {
            this.movingAverage.Calculate(e.Temperature);

            Console.WriteLine("{0} {1}", e.Time, e.Temperature);

            if (this.movingAverage.IsReady)
            {
                Console.WriteLine("Average for last {0} periods: {1}", this.movingAverage.Period, this.movingAverage.LastValue);

                if (this.movingAverage.LastValue > 15 && this.above)
                    this.RaiseExecuted();
                else if (this.movingAverage.LastValue < 15 && !this.above)
                    this.RaiseExecuted();
            }
        }