using BaseLibRWFile; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; namespace HRT_Measure { public class AlmInfo { public string strAdd; public string strContent; } public class AlmInfoHelp { public static List listAlmInfo = new List(); public static Ini newIni; public static void GetAlmInfo() { try { newIni = new Ini(Application.StartupPath + "\\Config\\AlmInfo.ini"); int iServoAlmCount = Convert.ToInt32(newIni.ReadIni("System", "伺服报警", "20")); int iCylinderAlmCount = Convert.ToInt32(newIni.ReadIni("System", "气缸报警", "20")); int iRobotAlmCount = Convert.ToInt32(newIni.ReadIni("System", "机械手报警", "20")); for (int i = 0; i < iServoAlmCount; i++) { string str = newIni.ReadIni("伺服报警", (i + 1).ToString(), ""); AlmInfo almInfo = new AlmInfo(); almInfo.strAdd = str.Split(',')[0]; almInfo.strContent = str.Split(',')[1]; listAlmInfo.Add(almInfo); } for (int i = 0; i < iCylinderAlmCount; i++) { string str = newIni.ReadIni("气缸报警", (i + 1).ToString(), ""); AlmInfo almInfo = new AlmInfo(); almInfo.strAdd = str.Split(',')[0]; almInfo.strContent = str.Split(',')[1]; listAlmInfo.Add(almInfo); } for (int i = 0; i < iRobotAlmCount; i++) { string str = newIni.ReadIni("机械手报警", (i + 1).ToString(), ""); AlmInfo almInfo = new AlmInfo(); almInfo.strAdd = str.Split(',')[0]; almInfo.strContent = str.Split(',')[1]; listAlmInfo.Add(almInfo); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } public static Thread thAlm = new Thread(new ThreadStart(ThAlm)); public static void AlmMonitorStart() { if (!thAlm.IsAlive) { thAlm.IsBackground = true; thAlm.Start(); } } private static void ThAlm() { while (true) { try { //if (GlobalPara.CurrentMachineState == MachineState.AutoRunning && ProgramHelp.Instance.commPLC.isPLCConnected) //{ // AlmMonitorRun(); //} } catch (Exception ex) { MessageBox.Show("AlmMonitorRun线程运行出错!" + ex.ToString()); } Thread.Sleep(2); } } private static void AlmMonitorRun() { for (int i = 0; i < listAlmInfo.Count; i++) { //ProgramHelp.Instance.commPLC.ReadCoin(listAlmInfo[i].strAdd, out bool bResult, out string strmsg); //if(bResult) //{ // string strContent = listAlmInfo[i].strContent; // //上传mes //} } } } }