终端一体化运控平台
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DeviceChartViewModel.cs 1.3 KiB

3 달 전
1234567891011121314151617181920212223242526272829303132333435363738
  1. using BPASmartClient.Academy.Model;
  2. using LiveCharts;
  3. using LiveCharts.Configurations;
  4. using LiveCharts.Wpf;
  5. using OxyPlot.Axes;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. namespace BPASmartClient.Academy.ViewModel
  12. {
  13. public class DeviceChartViewModel : NotifyBase
  14. {
  15. public DeviceChartViewModel()
  16. {
  17. DataFeedback = new DataFeedback();
  18. var mapper = Mappers.Xy<DataValue>()
  19. .X(model => model.DateTime.Ticks)
  20. .Y(model => model.Value);
  21. Charting.For<DataValue>(mapper);
  22. DataFeedback = Simens_PLC.GetInstance.dataFeedback;
  23. }
  24. private DataFeedback dataFeedback;
  25. public DataFeedback DataFeedback { get { return dataFeedback; } set { dataFeedback = value; OnPropertyChanged(); } }
  26. public Func<double, string> DateTimeFormatter { get; set; } = value => value>0 ? new DateTime((long)value).ToString("HH:mm:ss"):new DateTime((long)DateTime.Now.Ticks).ToString("HH:mm:ss");
  27. public Func<double, string> doubleFormatter { get; set; } = value => value.ToString("F2");
  28. public double AxisStep { get; set; } = TimeSpan.FromSeconds(2).Ticks;
  29. public double AxisUnit { get; set; } = TimeSpan.TicksPerSecond;
  30. }
  31. }