/// <summary> /// Refresh information on the panel /// </summary> /// <param name="client">The bacnet client to use for refreshing</param> /// <returns>The task for the refresh operation</returns> public async override Task Refresh(Client.Client client) { var alarms = await client.With(this._device.ObjectIdentifier.Instance) .GetAlarmsAsync(); _gridView.DataStore = alarms; }
/// <summary> /// Refreshes the data on the panel /// </summary> /// <param name="client">The client to use for refreshing</param> /// <returns>The asynchronous task</returns> public async override Task Refresh(Client.Client client) { var tl = client.With <ITrendLog>(_info.DeviceInstance, _info.ObjectIdentifier); var props = await tl.ReadPropertiesAsync( obj => obj.ObjectName, obj => obj.LogDeviceObjectProperty); var name = props.Item1; var reference = props.Item2; var records = await tl.ReadRangeAsync(obj => obj.LogBuffer); if (!reference.HasValue) { _plot.Model = null; return; } var type = _getTrendType(reference.Value); if (type == TrendType.Unknown) { _plot.Model = null; return; } else if (records.Length > 0) { var minDate = records.Length > 0 ? records[0].Timestamp.ToDateTime() : DateTime.MinValue; var maxDate = records.Length > 0 ? records[records.Length - 1].Timestamp.ToDateTime() : DateTime.MaxValue; var model = this._plot.Model; if (model == null) { model = new PlotModel(); model.Title = name; model.Axes.Add(new DateTimeAxis() { Position = AxisPosition.Bottom, IsPanEnabled = true, IsZoomEnabled = true }); model.Axes.Add(new LinearAxis() { Position = AxisPosition.Left, IsPanEnabled = false, IsZoomEnabled = false }); } var dateAxis = model.Axes.OfType <DateTimeAxis>().First(); dateAxis.AbsoluteMinimum = DateTimeAxis.ToDouble(minDate); dateAxis.AbsoluteMaximum = DateTimeAxis.ToDouble(maxDate); model.Series.Clear(); if (type == TrendType.Real) { model.Series.Add(new LineSeries() { Color = OxyColors.Red, ItemsSource = records.Where(rec => rec.LogDatum.IsRealValue) .Select(rec => DateTimeAxis.CreateDataPoint( rec.Timestamp.ToDateTime(), rec.LogDatum.AsRealValue )).ToList() }); } else if (type == TrendType.Binary) { model.Series.Add(new StairStepSeries() { Color = OxyColors.Red, ItemsSource = records.Where(rec => rec.LogDatum.IsEnumValue) .Select(rec => DateTimeAxis.CreateDataPoint( rec.Timestamp.ToDateTime(), rec.LogDatum.AsEnumValue.Value )).ToList() }); } _plot.Model = model; } }