终端一体化运控平台
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 

121 rader
3.1 KiB

  1. using BPASmartClient.Business;
  2. using BPASmartClient.Helper;
  3. using BPASmartClient.Message;
  4. using Microsoft.Toolkit.Mvvm.ComponentModel;
  5. using Microsoft.Toolkit.Mvvm.Input;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Reflection;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using System.Windows;
  13. using System.Windows.Input;
  14. using System.Windows.Threading;
  15. namespace BPASmartClient.ViewModel
  16. {
  17. /// <summary>
  18. /// 主界面
  19. /// </summary>
  20. public class MainViewModel : ObservableObject
  21. {
  22. /// <summary>
  23. /// 网络连接状态
  24. /// </summary>
  25. private bool _NetworkConnectState = true;
  26. public bool NetworkConnectState
  27. {
  28. get
  29. {
  30. return _NetworkConnectState;
  31. }
  32. set
  33. {
  34. if (_NetworkConnectState == value)
  35. return;
  36. _NetworkConnectState = value;
  37. OnPropertyChanged("NetworkConnectState");
  38. }
  39. }
  40. /// <summary>
  41. /// 是否告警
  42. /// </summary>
  43. public AlarmModel IsAlarm { get; set; }
  44. public DispatcherTimer dispatcherTimer;
  45. public MainViewModel()
  46. {
  47. IsAlarm =new AlarmModel();
  48. OrderStatusViewModel.Init();
  49. //设备告警日志
  50. MessageLog.GetInstance.AlarmLogNotify = new Action(() =>
  51. {
  52. System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() =>
  53. {
  54. IsAlarm.IsCheck = MessageLog.GetInstance.DPAlarmInfo.Count > 0;
  55. IsAlarm.ListNum = MessageLog.GetInstance.DPAlarmInfo.Count;
  56. }));
  57. });
  58. dispatcherTimer = new DispatcherTimer();
  59. dispatcherTimer.Tick += delegate
  60. {
  61. System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() =>
  62. {
  63. NetworkConnectState = UniversalHelper.GetInstance().GetNetworkState();
  64. }));
  65. };
  66. dispatcherTimer.Interval = TimeSpan.FromSeconds(1);
  67. dispatcherTimer.Start();
  68. }
  69. }
  70. public class AlarmModel : ObservableObject
  71. {
  72. /// <summary>
  73. /// 是否告警
  74. /// </summary>
  75. private bool _IsCheck = false;
  76. public bool IsCheck
  77. {
  78. get
  79. {
  80. return _IsCheck;
  81. }
  82. set
  83. {
  84. if (_IsCheck == value)
  85. return;
  86. _IsCheck = value;
  87. OnPropertyChanged("IsCheck");
  88. }
  89. }
  90. /// <summary>
  91. /// 告警数量
  92. /// </summary>
  93. private int _ListNum = 0;
  94. public int ListNum
  95. {
  96. get
  97. {
  98. return _ListNum;
  99. }
  100. set
  101. {
  102. if (_ListNum == value)
  103. return;
  104. _ListNum = value;
  105. OnPropertyChanged("ListNum");
  106. }
  107. }
  108. public AlarmModel()
  109. {
  110. }
  111. }
  112. }