MalfunctionMatrix.xaml.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using NEIntelligentControl2.Models.Windturbine;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Data;
  10. using System.Windows.Documents;
  11. using System.Windows.Input;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Imaging;
  14. using System.Windows.Navigation;
  15. using System.Windows.Shapes;
  16. namespace NEIntelligentControl2.Views.Matrix
  17. {
  18. /// <summary>
  19. /// 故障风机矩阵
  20. /// </summary>
  21. public partial class MalfunctionMatrix : UserControl
  22. {
  23. private Dictionary<string, WindBlockSmall> _ShowDataPairts; // 被展示的风机信息
  24. public MalfunctionMatrix()
  25. {
  26. InitializeComponent();
  27. _ShowDataPairts = new Dictionary<string, WindBlockSmall>();
  28. }
  29. /// <summary>
  30. /// 更新数据
  31. /// </summary>
  32. internal void UpdateData(Dictionary<string, WindturbineInfo> vs)
  33. {
  34. Dispatcher.Invoke(() =>
  35. {
  36. foreach (var v in vs)
  37. {
  38. if (_ShowDataPairts.ContainsKey(v.Key) && v.Value.Status != 5)
  39. {
  40. _UGMain.Children.Remove(_ShowDataPairts[v.Key]);
  41. _ShowDataPairts.Remove(v.Key);
  42. }
  43. if (v.Value.Status != 5) continue;
  44. if (!_ShowDataPairts.ContainsKey(v.Key))
  45. {
  46. WindBlockSmall bs = new WindBlockSmall(v.Value) { Title = v.Value.Name };
  47. _UGMain.Children.Insert(0, bs);
  48. _ShowDataPairts.Add(v.Key, bs);
  49. }
  50. _ShowDataPairts[v.Key].Update(v.Value);
  51. }
  52. });
  53. }
  54. }
  55. }