/// <summary> /// 初始化系统线程 /// </summary> private static void InitialSysterm() { try { //信息提示框按钮附名称 //MessageBoxManager.OK = "OK"; //MessageBoxManager.No = "No"; //MessageBoxManager.Yes = "Yes"; //MessageBoxManager.Cancel = "Cancel"; //MessageBoxManager.Retry = "Retry"; //MessageBoxManager.Ignore = "Ignore"; //MessageBoxManager.Abort = "Abort"; //MessageBoxManager.Register(); MessageBoxManager.OK = LanguageContainer.ProgramMessageBoxManagerOK[GlobalDataInterface.selectLanguageIndex]; MessageBoxManager.No = LanguageContainer.ProgramMessageBoxManagerNo[GlobalDataInterface.selectLanguageIndex]; MessageBoxManager.Yes = LanguageContainer.ProgramMessageBoxManagerYes[GlobalDataInterface.selectLanguageIndex]; MessageBoxManager.Cancel = LanguageContainer.ProgramMessageBoxManagerCancel[GlobalDataInterface.selectLanguageIndex]; MessageBoxManager.Retry = LanguageContainer.ProgramMessageBoxManagerRetry[GlobalDataInterface.selectLanguageIndex]; MessageBoxManager.Ignore = LanguageContainer.ProgramMessageBoxManagerIgnore[GlobalDataInterface.selectLanguageIndex]; MessageBoxManager.Abort = LanguageContainer.ProgramMessageBoxManagerAbort[GlobalDataInterface.selectLanguageIndex]; MessageBoxManager.Register(); Thread.Sleep(1000); if (m_splashForm != null) { // m_splashForm.Invoke(new MethodInvoker(delegate { m_splashForm.InitialStatuslabel.Text = "检查本地IP..."; })); //m_splashForm.Invoke(new MethodInvoker(delegate { m_splashForm.InitialStatuslabel.Text = "Check the local IP..."; })); m_splashForm.Invoke(new MethodInvoker(delegate { m_splashForm.InitialStatuslabel.Text = LanguageContainer.ProgramMessagebox1Text[GlobalDataInterface.selectLanguageIndex]; })); } //检查IP地址 string hostName = Dns.GetHostName(); IPHostEntry IPEntry = Dns.GetHostEntry(hostName); IPAddress HCIP = IPAddress.Parse(ConstPreDefine.HC_IP_ADDR); string currentIP = ""; //for (int i = 0; i < IPEntry.AddressList.Length; i++) //{ // if (IPEntry.AddressList[i].AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) // { // currentIP = IPEntry.AddressList[i].ToString(); // break; // } //} //if (!string.Equals(currentIP, ConstPreDefine.HC_IP_ADDR)) //{ // //MessageBox.Show("IP地址错误或没有网络连接!"); // MessageBox.Show("0x10000001 IP address error or no network!","Error",MessageBoxButtons.OK,MessageBoxIcon.Error); // IsSystemContinue = false; // return; //} //解决多网卡的问题 bool IsExistCorrentIP = false; for (int i = 0; i < IPEntry.AddressList.Length; i++) { if (IPEntry.AddressList[i].AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) { currentIP = IPEntry.AddressList[i].ToString(); if (string.Equals(currentIP, ConstPreDefine.HC_IP_ADDR)) { IsExistCorrentIP = true; break; } } } if (!IsExistCorrentIP) { //MessageBox.Show("IP地址错误或没有网络连接!"); //MessageBox.Show("0x10000001 IP address error or no network!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("0x10000001 " + LanguageContainer.ProgramMessagebox2Text[GlobalDataInterface.selectLanguageIndex], LanguageContainer.ProgramMessageboxErrorCaption[GlobalDataInterface.selectLanguageIndex], MessageBoxButtons.OK, MessageBoxIcon.Error); IsSystemContinue = false; return; } //建立网络连接 if (m_splashForm != null) { //m_splashForm.Invoke(new MethodInvoker(delegate { m_splashForm.InitialStatuslabel.Text = "正在建立网络连接..."; })); //m_splashForm.Invoke(new MethodInvoker(delegate { m_splashForm.InitialStatuslabel.Text = "Establishing network..."; })); m_splashForm.Invoke(new MethodInvoker(delegate { m_splashForm.InitialStatuslabel.Text = LanguageContainer.ProgramMessagebox3Text[GlobalDataInterface.selectLanguageIndex]; })); } global.Init();//网络初始化 Thread.Sleep(1000); //建立数据库连接 // 查询子系统 if (m_splashForm != null) { //m_splashForm.Invoke(new MethodInvoker(delegate { m_splashForm.InitialStatuslabel.Text = "正在查询子系统..."; })); //m_splashForm.Invoke(new MethodInvoker(delegate { m_splashForm.InitialStatuslabel.Text = "Checking the Subsystems..."; })); m_splashForm.Invoke(new MethodInvoker(delegate { m_splashForm.InitialStatuslabel.Text = LanguageContainer.ProgramMessagebox4Text[GlobalDataInterface.selectLanguageIndex]; })); } string strSubSystemNum = Commonfunction.GetAppSetting("子系统个数"); GlobalDataInterface.TransmitParam(-1, (int)HC_FSM_COMMAND_TYPE.HC_CMD_DISPLAY_ON, null); if (GlobalDataInterface.SubSystemIsConnected[0] == false) { //MessageBox.Show("子系统1连接失败,请检查连接!"); //MessageBox.Show("0x10000003 Subsystem 1 connection failure,please check the connection!", "Error", MessageBoxButtons.OK,MessageBoxIcon.Error); MessageBox.Show("0x10000003 初始化" + LanguageContainer.ProgramMessagebox5Text[GlobalDataInterface.selectLanguageIndex], LanguageContainer.ProgramMessageboxErrorCaption[GlobalDataInterface.selectLanguageIndex], MessageBoxButtons.OK, MessageBoxIcon.Error); //MessageBox.Show("初始化"); IsSystemContinue = false; return; } if (GlobalDataInterface.ConnectSystemNum == 0) { //MessageBox.Show("连接下位机失败,请检查连接!"); //MessageBox.Show("0x10000002 FSM connection failure,please check the connection!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("0x10000002 " + LanguageContainer.ProgramMessagebox6Text[GlobalDataInterface.selectLanguageIndex], LanguageContainer.ProgramMessageboxErrorCaption[GlobalDataInterface.selectLanguageIndex], MessageBoxButtons.OK, MessageBoxIcon.Error); IsSystemContinue = false; return; } if (GlobalDataInterface.ConnectSystemNum < byte.Parse(strSubSystemNum)) { //DialogResult result = MessageBox.Show("子系统与配置数目不符,是否继续运行?", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); //DialogResult result = MessageBox.Show("0x20001001 Configuration does not match the number of subsystems,whether to continue to run?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); DialogResult result = MessageBox.Show("0x20001001 " + LanguageContainer.ProgramMessagebox7Text[GlobalDataInterface.selectLanguageIndex], LanguageContainer.ProgramMessageboxWarningCaption[GlobalDataInterface.selectLanguageIndex], MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.No) { IsSystemContinue = false; return; } } if (m_splashForm != null) { //m_splashForm.Invoke(new MethodInvoker(delegate { m_splashForm.InitialStatuslabel.Text = "正在启动..."; })); //m_splashForm.Invoke(new MethodInvoker(delegate { m_splashForm.InitialStatuslabel.Text = "Starting..."; })); m_splashForm.Invoke(new MethodInvoker(delegate { m_splashForm.InitialStatuslabel.Text = LanguageContainer.ProgramMessagebox8Text[GlobalDataInterface.selectLanguageIndex]; })); } Thread.Sleep(2000); // m_splashForm.Invoke(new MethodInvoker(delegate { m_splashForm.InitialStatuslabel.Text = "完成"; })); } catch (Exception ex) { Trace.WriteLine("Program中函数InitialSysterm出错" + ex + "\n代码定位:" + ex.StackTrace); #if REALEASE GlobalDataInterface.WriteErrorInfo("Program中函数InitialSysterm出错:" + ex + "\n代码定位:" + ex.StackTrace); #endif } }