private void OPC_Ini() { try { MyOPCServer = new OPCServer(); MyOPCServer.Connect("KEPware.KEPServerEx.V6", "193.100.101.221"); //OpcIn = MyOPCServer.OPCGroups.Add("FR.FR"); XML.XmlConfig xmlConfig = new XML.XmlConfig(); xmlConfig.GetIPXML(); //string IP = XML.XmlConfig.GetIPXML(); Bll.T_MJAnswer t_MJAnswer = new T_MJAnswer(); //string workBay = t_MJAnswer.GetWorkBay(IP); //workBayTag = t_MJAnswer.GetWorkBayTag(IP); workBayTag = xmlConfig.staionName; T_OPCTag t_OPCTag = new T_OPCTag(); //string line = t_OPCTag.GetLine(workBay); string line = xmlConfig.line; OpcIn = MyOPCServer.OPCGroups.Add(line + "." + line); LineName = line; DataTable allOPCTag = t_OPCTag.GetAllOPCTag(workBayTag); int index = 1; foreach (DataRow item in allOPCTag.Rows) { OpcIn.OPCItems.AddItem(line + "." + line + "." + item["kepserverAllName"].ToString().Trim(), index); index++; } //OpcIn.OPCItems.AddItem("FR.FR.FR25_CODE", 1); //OpcIn.OPCItems.AddItem("FR.FR.FR25_IsCode", 2); OpcIn.UpdateRate = 50; OpcIn.IsActive = true; OpcIn.IsSubscribed = true; OpcIn.DataChange += new DIOPCGroupEvent_DataChangeEventHandler(OpcInTri_DataChange); // blState = true; } catch (Exception ex) { MessageBox.Show(ex.ToString()); // blState = false; // log.writeTxt(Application.StartupPath, ErrorLog.logType.ERRORLOG, "OPC连接异常:" + ex.Message); } }
private void Frm_Initialize() { this.BackColor = Color.White; int width = this.Width; int height = this.Height; Panel p_top = new Panel { Width = width, Height = height / 15, Location = new Point(0, 0), BackColor = Color.FromArgb(240, 244, 247) }; PictureBox logo = new PictureBox { Width = width / 8, Height = p_top.Height, Image = Properties.Resources.logo, Location = new Point(0, 0), SizeMode = PictureBoxSizeMode.StretchImage }; logo.Click += Button2_Click; Label lb_top = new Label { Width = width / 2, Height = p_top.Height, Text = "北京安道拓盲检系统 V2.02", TextAlign = System.Drawing.ContentAlignment.MiddleCenter, Font = new Font("微软雅黑", 22, FontStyle.Regular) }; lb_top.Location = new Point(width / 2 - lb_top.Width / 2, 0); lb_top.AutoSize = false; Panel p_mid = new Panel { Width = width, Height = height - p_top.Height, Location = new Point(0, p_top.Height) }; // p_mid.BackColor = Color.Orange; panel1.Width = width; panel1.Height = height / 9; int p1w = panel1.Width; int p1h = panel1.Height; panel1.Location = new Point(0, lb_top.Height); this.panel2.Width = Convert.ToInt32(p1w * 0.8) - Convert.ToInt32(width * 0.06); this.panel2.Height = Convert.ToInt32(height / 2) / 5 * Convert.ToInt32(5.5); this.panel2.Location = new Point(Convert.ToInt32(width * 0.03), lb_top.Height + panel1.Height + 10); this.panel2.BorderStyle = BorderStyle.FixedSingle; this.flowLayoutPanel1.Width = width - panel2.Width - Convert.ToInt32(width * 0.06); this.flowLayoutPanel1.Height = panel2.Height; this.flowLayoutPanel1.Location = new Point(panel2.Right + Convert.ToInt32(width * 0.01), lb_top.Height + panel1.Height + 10); this.label5.Location = new Point(panel2.Right + Convert.ToInt32(width * 0.01), Convert.ToInt32(p1h * 2.5) - label5.Height); this.mes.Size = new Size(); this.label1.Width = p1w / 10; this.label1.Height = Convert.ToInt32(p1h * 0.5); this.label1.Location = new Point(Convert.ToInt32(p1w * 0.01), Convert.ToInt32(p1h * 0.33)); this.barCode.Width = Convert.ToInt32(p1w * 0.3); this.barCode.Height = Convert.ToInt32(p1h * 0.5); this.barCode.Location = new Point(this.label1.Right, Convert.ToInt32(p1h * 0.36)); this.label2.Width = p1w / 17; this.label2.Height = Convert.ToInt32(p1h * 0.5); this.label2.Location = new Point(this.barCode.Right + 20, Convert.ToInt32(p1h * 0.33)); this.carModelName.Width = p1w / 6; this.carModelName.Height = Convert.ToInt32(p1h * 0.5); this.carModelName.Location = new Point(this.label2.Right, Convert.ToInt32(p1h * 0.36)); this.carModelName.Text = ""; this.label4.Width = p1w / 15; this.label4.Height = Convert.ToInt32(p1h * 0.5); this.label4.Location = new Point(this.carModelName.Right - 20, Convert.ToInt32(p1h * 0.33)); this.carType.Width = p1w / 13; this.carType.Height = Convert.ToInt32(p1h * 0.5); this.carType.Location = new Point(this.label4.Right, Convert.ToInt32(p1h * 0.36)); this.carType.Text = ""; this.label3.Size = this.label2.Size; this.label3.Location = new Point(this.carType.Right, Convert.ToInt32(p1h * 0.33)); this.workBay.Size = this.carType.Size; this.workBay.Location = new Point(this.label3.Right, Convert.ToInt32(p1h * 0.36)); this.workBay.Text = ""; this.exit.Width = Convert.ToInt32(p1w * 0.08); this.exit.Height = Convert.ToInt32(p1h * 0.384); this.exit.Location = new Point(20, 20); this.exit.Hide(); this.bypass.Width = Convert.ToInt32(width * 0.158); this.bypass.Height = Convert.ToInt32(height * 0.05); this.bypass.Location = new Point(Convert.ToInt32(width * 0.03), lb_top.Height + panel1.Height); this.submit.Width = Convert.ToInt32(width * 0.23); this.submit.Height = Convert.ToInt32(height * 0.099); this.submit.Location = new Point(this.submit.Right + this.Width / 13, Convert.ToInt32(height * 0.846)); submit.BringToFront(); this.pass.Size = this.submit.Size; this.pass.Location = new Point(Convert.ToInt32(width * 0.15), Convert.ToInt32(height * 0.846)); this.retry.Size = this.submit.Size; this.retry.Location = new Point(Convert.ToInt32(width * 0.645), Convert.ToInt32(height * 0.846)); this.retry.Hide(); this.pass.Hide(); this.submit.Hide(); //string IP = XML.XmlConfig.GetIPXML(); XML.XmlConfig xmlconfig = new XML.XmlConfig(); xmlconfig.GetIPXML(); //Bll.T_MJAnswer t_MJAnswer = new T_MJAnswer(); string workBay = xmlconfig.staionName; WorkbayName = workBay; this.workBay.Text = workBay; p_top.Controls.Add(lb_top); p_top.Controls.Add(logo); this.Controls.Add(p_top); this.Controls.Add(p_mid); }