Ejemplo n.º 1
0
        protected void SendOutput(double value)
        {
            var totalWatch = System.Diagnostics.Stopwatch.StartNew();

            var watches = new System.Diagnostics.Stopwatch[this.devices.Count];

            for (int i = 0; i < this.devices.Count; i++)
            {
                watches[i] = System.Diagnostics.Stopwatch.StartNew();

                var deviceOwner = this.devices[i].Observer;
                if (deviceOwner == null)
                {
                    continue;
                }

                deviceOwner.Data[DataElements.Brightness] = value;
                deviceOwner.PushData();

                watches[i].Stop();
            }
            totalWatch.Stop();

            if (watches.Any())
            {
                double max = watches.Select(x => x.ElapsedMilliseconds).Max();
                double avg = watches.Select(x => x.ElapsedMilliseconds).Average();

                if (totalWatch.ElapsedMilliseconds > 25)
                {
                    this.log.Information(string.Format("Devices {0}   Max: {1:N1}   Avg: {2:N1}   Total: {3:N1}",
                                                       this.devices.Count, max, avg, totalWatch.ElapsedMilliseconds));
                }
            }
        }