PageEquipmentMonitor2.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using HZY.Framework.DependencyInjection;
  11. using Sunny.UI;
  12. namespace Scada
  13. {
  14. public partial class PageEquipmentMonitor2 : UIPage, ISingletonSelfDependency
  15. {
  16. private List<Control> controls;
  17. public PageEquipmentMonitor2()
  18. {
  19. InitializeComponent();
  20. controls = Globals.GetAllControls(this);
  21. this.timer1.Interval = 500;
  22. this.timer1.Tick += Timer1_Tick;
  23. this.timer1.Start();
  24. }
  25. protected override CreateParams CreateParams
  26. {
  27. get
  28. {
  29. CreateParams paras = base.CreateParams;
  30. paras.ExStyle |= 0x02000000;
  31. return paras;
  32. }
  33. }
  34. private void Timer1_Tick(object? sender, EventArgs e)
  35. {
  36. if (Globals.SiemensClient.Connected)
  37. {
  38. //遍历所有控件
  39. foreach (Control control in controls)
  40. {
  41. if (control is UserDeviceState userDeviceState)
  42. {
  43. userDeviceState.State = Globals.DataDic[userDeviceState.VariableName].ToString() == "1";
  44. }
  45. else if (control is UserVarCurrentValue userCurrentValue)
  46. {
  47. userCurrentValue.VarValue = float.Parse(Globals.DataDic[userCurrentValue.VariableName].ToString());
  48. }
  49. else if (control is UserAlarmState userAlarmState)
  50. {
  51. userAlarmState.State = Globals.DataDic[userAlarmState.VariableName].ToString() != "1";
  52. }
  53. }
  54. }
  55. }
  56. }
  57. }