public void Update(IEnumerable <ViewDataEntity> entities, RowDecoration decoration = default) { if (isFormatChanged()) { Logger.LogOKEverywhere("Формат данных обновлен"); Clear.Execute(); } entities = entities.ToArray(); var columns = ("DateTime", DateTime.Now.ToString("HH:mm:ss")).ToSequence() .Concat(entities.Select(e => (e.CurveName, e.GetAsString(2)))); var dto = _dtoBuilder.Instantiate(columns); DTOs.Insert(0, dto); if (DTOs.Count > 1000) { DTOs.RemoveLast(); } var points = entities .Select(e => e.PointValue) .SkipNulls() .Select(p => p.Value) .ToArray(); PointsSource.PointsRows.Add(new DecoratedPointsRow(points, decoration)); if (PointsSource.CurveInfos.Count == 0) { PointsSource.CurveInfos.AddRange(entities .Where(e => e.PointValue.HasValue) .Select(e => new CurveInfo(e.CurveName, _curveInfosBeforeLastClear?.FirstOrDefault(ci => ci.Title == e.CurveName)?.IsShown ?? true))); } _lastEntities = entities; bool isFormatChanged() { if (_lastEntities == null) { return(false); } else { var isSame = _lastEntities.Count() == entities.Count() && _lastEntities.Zip(entities, (p1, p2) => p1.IsSameAs(p2)).AllTrue(); return(!isSame); } } }
public DecoratedPointsRow(double[] points, RowDecoration decoration) { Points = points ?? throw new ArgumentNullException(nameof(points)); Decoration = decoration; }
void updateData(IEnumerable <ViewDataEntity> data, RowDecoration decoration) { DeviceDataVM.Update(data, decoration); }