private void receiveGateState(object obj) { while (true && (!this.IsDisposed)) { try { ICustomsCMS server = XmlRpcInstance.getInstance(); List <int> gateIds = new List <int>(); for (int i = 1; i <= 100; i++) { gateIds.Add(i); } Gate_state_record_Response reportContent_Response = server.getGateAllInfo(AppConfig.gateSensor, gateIds.ToArray()); if (reportContent_Response.error_code == 0 && !this.IsDisposed) { this.Invoke(new Action <Gate_state_record_Response>(this.refreshGateMonitors), reportContent_Response); } } catch (Exception ex) { MessageBox.Show("获取闸机状态出错:" + ex.Message, "错误"); } finally { System.Threading.Thread.Sleep(AppConfig.getGateSecond); } } }
/// <summary> /// 刷新闸机监控 /// </summary> private void refreshGateMonitors(Gate_state_record_Response reportContent_Response) { //从server中获取所有的状态,使用线程的方式 Gate_state_record[] gate_state_recode = reportContent_Response.gate_state_recode; for (int i = 0; i < gate_state_recode.Length; i++) { Panel panel1 = monitorPanels[i]; String display = "闸机状态:" + EnumName.getWorkStateName(gate_state_recode[i].working_state) + "\n闸机模式:" + EnumName.getGateModeName(gate_state_recode[i].mode) + "\n误差调节:核素误差 " + gate_state_recode[i].tiny_nuclear + ",温度误差 " + gate_state_recode[i].tiny_temper + "\n报警阀值:核素报警阀值 " + gate_state_recode[i].thr_nuclear + ",温度报警阀值 " + gate_state_recode[i].thr_temper + "\n报警状态:核素报警状态-"; if (gate_state_recode[i].unnormal_type == (int)zhuhai.xmlrpc.AbnormalType.Nuclear || gate_state_recode[i].unnormal_type == (int)zhuhai.xmlrpc.AbnormalType.TemperatareNuclear) { display += "报警 " + gate_state_recode[i].nuclear.ToString() + ",温度报警状态-"; //显示报警灯 System.Windows.Forms.PictureBox pictureBox12 = (PictureBox)(panel1.Controls.Find("pictureBox" + (i + 1).ToString() + "2", false)[0]); pictureBox12.Visible = true; } else { display += "无报警,温度报警状态-"; } if (gate_state_recode[i].unnormal_type == (int)zhuhai.xmlrpc.AbnormalType.Temperatare || gate_state_recode[i].unnormal_type == (int)zhuhai.xmlrpc.AbnormalType.TemperatareNuclear) { //显示报警灯 System.Windows.Forms.PictureBox pictureBox12 = (PictureBox)(panel1.Controls.Find("pictureBox" + (i + 1).ToString() + "2", false)[0]); pictureBox12.Visible = true; display += "报警 " + gate_state_recode[i].temperature.ToString(); } else { display += "无报警"; } if (gate_state_recode[i].unnormal_type == (int)zhuhai.xmlrpc.AbnormalType.Shenbao) { display += ",申报报警异常"; //显示报警灯 System.Windows.Forms.PictureBox pictureBox12 = (PictureBox)(panel1.Controls.Find("pictureBox" + (i + 1).ToString() + "2", false)[0]); pictureBox12.Visible = true; } toolTip.SetToolTip(panel1, display); //模式 System.Windows.Forms.PictureBox pictureBox10 = (PictureBox)(panel1.Controls.Find("pictureBox" + (i + 1).ToString() + "0", false)[0]); if (gate_state_recode[i].mode == (int)WorkMode.Shenbao) { pictureBox10.Image = global::zhuhai.Properties.Resources.shenbaotongguan; } else if (gate_state_recode[i].mode == (int)WorkMode.Zizhu) { pictureBox10.Image = global::zhuhai.Properties.Resources.kuaisutongguan; } else if (gate_state_recode[i].mode == (int)WorkMode.Shuaka) { pictureBox10.Image = global::zhuhai.Properties.Resources.shuakatongguan; } else if (gate_state_recode[i].mode == (int)WorkMode.Fengbi) { pictureBox10.Image = global::zhuhai.Properties.Resources.jinzhitongxing; } //状态 if (gate_state_recode[i].working_state == (int)WorkState.ShutDown || gate_state_recode[i].working_state == (int)WorkState.Sleep) { panel1.BackgroundImage = global::zhuhai.Properties.Resources.gate_shutdown; } else if (gate_state_recode[i].working_state == (int)WorkState.Normal) { panel1.BackgroundImage = global::zhuhai.Properties.Resources.gate_normal; } else { panel1.BackgroundImage = global::zhuhai.Properties.Resources.gate_abnormal; } System.Windows.Forms.PictureBox pictureBox11 = (PictureBox)(panel1.Controls.Find("pictureBox" + (i + 1).ToString() + "1", false)[0]); //根据是否设置温度或者核素误差阈值显示该图片 if (gate_state_recode[i].tiny_nuclear != 0 || gate_state_recode[i].tiny_temper != 0) { pictureBox11.Visible = true; } else { pictureBox11.Visible = false; } //显示当前核数阈值 System.Windows.Forms.Label label12 = (Label)(panel1.Controls.Find("label" + (i + 1).ToString() + "2", false)[0]); label12.Text = gate_state_recode[i].nuclear.ToString(); //显示当前温度阈值 System.Windows.Forms.Label label13 = (Label)(panel1.Controls.Find("label" + (i + 1).ToString() + "3", false)[0]); label13.Text = gate_state_recode[i].temperature.ToString(); //通关通道上显示提示 System.Windows.Forms.Label label14 = (Label)(panel1.Controls.Find("label" + (i + 1).ToString() + "4", false)[0]); toolTip.SetToolTip(label14, display); } }