123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- using HardwareData;
- namespace HistoryUI.ViewModels;
- public partial class AlarmViewModel(Hardwares hardwares, IORM orm) : BaseViewModel<DBWarning>(hardwares, orm)
- {
- [RelayCommand]
- protected override void Query()
- {
- if (!base.QueryBase(out byte mini8, out byte Channel))
- return;
- //ChannelData channelData = new();
- //channelData.ChannelIndex = 0;
- //channelData.Name = "All";
- //base.Channels[0] = channelData;
- _orm.Query<DBWarning>($"Error-Mini8-{mini8}",
- t => t.DateTime >= this.StartTime
- && t.DateTime <= this.EndTime &&
- t.PV < 1600 && t.PV > 10,
- QueryResult);
- }
- private void QueryResult(List<DBWarning> results)
- {
- App.Current.Dispatcher?.Invoke(() =>
- {
- base.Results ??= [];
- base.Results?.Clear();
- });
- Task.Factory.StartNew(() =>
- {
- results = [.. results.OrderBy(t => t.DateTime)];
- for (int i = 1; i <= results.Count; i++)
- {
- App.Current.Dispatcher?.Invoke(() =>
- {
- base.Results!.Add(i, results[i - 1]);
- });
- }
- });
- }
- }
|