Form_Main.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using EasyModbusClient;
  2. using IMCS.UControl;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Data;
  7. using System.Drawing;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12. namespace IMCS
  13. {
  14. public partial class Form_Main : Form
  15. {
  16. public Form_Main()
  17. {
  18. InitializeComponent();
  19. this.Load += Form1_Load;
  20. }
  21. ControllerHelper controllerHelper = new ControllerHelper();
  22. private void Form1_Load(object sender, EventArgs e)
  23. {
  24. Task.Factory.StartNew(() =>
  25. {
  26. //controllerHelper.StartHttpServer();
  27. });
  28. System.Threading.Thread.Sleep(2000);
  29. this.timer1.Enabled = false;
  30. //this.userControl41.deviceStateDefaultList.Device_OnLine = true;
  31. //this.userControl41.deviceStateDefaultList.Device_ConnectionMes = true;
  32. //this.userControl41.deviceStateDefaultList.Device_Pan = DefaultList.EnumPlateNum.Plate_Zero;
  33. //this.userControl41.deviceStateDefaultList.Device_Name = "这里是一个测试";
  34. //this.userControl41.deviceStateDefaultList.Device_Runing = DefaultList.EnumDeviceRunState.RunState_Run;
  35. }
  36. private void timer1_Tick(object sender, EventArgs e)
  37. {
  38. try
  39. {
  40. if (!controllerHelper.GetDeviceCollectData())
  41. {
  42. // this.timer1.Enabled = false;
  43. }
  44. }
  45. catch(Exception ex)
  46. {
  47. YG.Log.Instance.WriteLogAdd($"46-->>{ex.Message}");
  48. }
  49. }
  50. }
  51. }