AlmInfo.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. using BaseLibRWFile;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading;
  7. using System.Threading.Tasks;
  8. using System.Windows.Forms;
  9. namespace HRT_Measure
  10. {
  11. public class AlmInfo
  12. {
  13. public string strAdd;
  14. public string strContent;
  15. }
  16. public class AlmInfoHelp
  17. {
  18. public static List<AlmInfo> listAlmInfo = new List<AlmInfo>();
  19. public static Ini newIni;
  20. public static void GetAlmInfo()
  21. {
  22. try
  23. {
  24. newIni = new Ini(Application.StartupPath + "\\Config\\AlmInfo.ini");
  25. int iServoAlmCount = Convert.ToInt32(newIni.ReadIni("System", "伺服报警", "20"));
  26. int iCylinderAlmCount = Convert.ToInt32(newIni.ReadIni("System", "气缸报警", "20"));
  27. int iRobotAlmCount = Convert.ToInt32(newIni.ReadIni("System", "机械手报警", "20"));
  28. for (int i = 0; i < iServoAlmCount; i++)
  29. {
  30. string str = newIni.ReadIni("伺服报警", (i + 1).ToString(), "");
  31. AlmInfo almInfo = new AlmInfo();
  32. almInfo.strAdd = str.Split(',')[0];
  33. almInfo.strContent = str.Split(',')[1];
  34. listAlmInfo.Add(almInfo);
  35. }
  36. for (int i = 0; i < iCylinderAlmCount; i++)
  37. {
  38. string str = newIni.ReadIni("气缸报警", (i + 1).ToString(), "");
  39. AlmInfo almInfo = new AlmInfo();
  40. almInfo.strAdd = str.Split(',')[0];
  41. almInfo.strContent = str.Split(',')[1];
  42. listAlmInfo.Add(almInfo);
  43. }
  44. for (int i = 0; i < iRobotAlmCount; i++)
  45. {
  46. string str = newIni.ReadIni("机械手报警", (i + 1).ToString(), "");
  47. AlmInfo almInfo = new AlmInfo();
  48. almInfo.strAdd = str.Split(',')[0];
  49. almInfo.strContent = str.Split(',')[1];
  50. listAlmInfo.Add(almInfo);
  51. }
  52. }
  53. catch (Exception ex)
  54. {
  55. MessageBox.Show(ex.ToString());
  56. }
  57. }
  58. public static Thread thAlm = new Thread(new ThreadStart(ThAlm));
  59. public static void AlmMonitorStart()
  60. {
  61. if (!thAlm.IsAlive)
  62. {
  63. thAlm.IsBackground = true;
  64. thAlm.Start();
  65. }
  66. }
  67. private static void ThAlm()
  68. {
  69. while (true)
  70. {
  71. try
  72. {
  73. //if (GlobalPara.CurrentMachineState == MachineState.AutoRunning && ProgramHelp.Instance.commPLC.isPLCConnected)
  74. //{
  75. // AlmMonitorRun();
  76. //}
  77. }
  78. catch (Exception ex)
  79. {
  80. MessageBox.Show("AlmMonitorRun线程运行出错!" + ex.ToString());
  81. }
  82. Thread.Sleep(2);
  83. }
  84. }
  85. private static void AlmMonitorRun()
  86. {
  87. for (int i = 0; i < listAlmInfo.Count; i++)
  88. {
  89. //ProgramHelp.Instance.commPLC.ReadCoin(listAlmInfo[i].strAdd, out bool bResult, out string strmsg);
  90. //if(bResult)
  91. //{
  92. // string strContent = listAlmInfo[i].strContent;
  93. // //上传mes
  94. //}
  95. }
  96. }
  97. }
  98. }