Пример #1
0
        private void UpdateAxisLimits(double t)
        {
            if (t <= 20)
            {
                XAxisMin = 0.0;
                XAxisMax = 25.0;
            }
            else
            {
                XAxisMin = t - 20.0;
                XAxisMax = t + 5.0;
            }

            // Where-clause here is needed to prevent Y-axis be influenced by NaN values.
            // If only NaNs (for instance, after an entire training), do not update the YAxis.
            var lowerTargetValues = LowerTargetValues.Where(mm => !double.IsNaN(mm.Moment));

            if (lowerTargetValues.Any())
            {
                YAxisMin = lowerTargetValues.Min(v => v.Moment) - 10.0;
            }

            var upperTargetValues = UpperTargetValues.Where(mm => !double.IsNaN(mm.Moment));

            if (upperTargetValues.Any())
            {
                YAxisMax = upperTargetValues.Max(v => v.Moment) + 10.0;
            }
        }
Пример #2
0
        private void GraphUpdate(EventArgs e)
        {
            if (_lastGraphUpdate != null && DateTime.Now - _lastGraphUpdate < TimeSpan.FromSeconds(1))
            {
                return;
            }

            var eventArgs = (SerialPortEventArgs)e;
            var moment    = _model.DetermineMoment(eventArgs.Left, eventArgs.Right);

            var t = (DateTime.Now - _t0).TotalSeconds;

            MomentValues.Add(new MeasureModel(t, moment));
            if (MomentValues.Count > 100)
            {
                MomentValues.RemoveAt(0);
            }

            _model.Training.GenerateTargetAt(t + 50.0, out double target, out double minTarget, out double maxTarget);
            TargetValues.Add(new MeasureModel(t + 50.0, target));
            UpperTargetValues.Add(new MeasureModel(t + 50.0, maxTarget));
            LowerTargetValues.Add(new MeasureModel(t + 50.0, minTarget));

            if (UpperTargetValues.Count > 100)
            {
                TargetValues.RemoveAt(0);
                LowerTargetValues.RemoveAt(0);
                UpperTargetValues.RemoveAt(0);
            }

            UpdateAxisLimits(t);

            _lastGraphUpdate = DateTime.Now;
        }