123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- 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<AlmInfo> listAlmInfo = new List<AlmInfo>();
- 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
- //}
- }
- }
- }
- }
|