AlarmViewModel.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using HardwareData;
  2. namespace HistoryUI.ViewModels;
  3. public partial class AlarmViewModel(Hardwares hardwares, IORM orm) : BaseViewModel<DBWarning>(hardwares, orm)
  4. {
  5. [RelayCommand]
  6. protected override void Query()
  7. {
  8. if (!base.QueryBase(out byte mini8, out byte Channel))
  9. return;
  10. //ChannelData channelData = new();
  11. //channelData.ChannelIndex = 0;
  12. //channelData.Name = "All";
  13. //base.Channels[0] = channelData;
  14. _orm.Query<DBWarning>($"Error-Mini8-{mini8}",
  15. t => t.DateTime >= this.StartTime
  16. && t.DateTime <= this.EndTime &&
  17. t.PV < 1600 && t.PV > 10,
  18. QueryResult);
  19. }
  20. private void QueryResult(List<DBWarning> results)
  21. {
  22. results = [.. results.OrderBy(t => t.DateTime)];
  23. App.Current.Dispatcher?.Invoke(() =>
  24. {
  25. base.Results = null;
  26. Dictionary<int, DBWarning> temp = [];
  27. for (int i = 1; i <= results.Count; i++)
  28. {
  29. temp.Add(i, results[i - 1]);
  30. }
  31. base.Results = temp;
  32. });
  33. }
  34. }