private opcRealated.opcUA.opcUAServer connectBeckhoff() { String beckhoffIP = "127.0.0.1"; //倍福设备的IP地址 String beckhoffPort = "49320"; //倍福设备的端口号 opcRealated.opcUA.opcUAServer uaServer = new opcRealated.opcUA.opcUAServer(); uaServer.CertificateEvent += new certificateValidation(m_Server_CertificateEvent); String connectVar = "opc.tcp://" + beckhoffIP + ":" + beckhoffPort; uaServer.Connect(connectVar); return(uaServer); }
private void showBeckhoffDisplay() { opcRealated.opcUA.opcUAServer curServer = connectBeckhoff(); m_Server = curServer; DisplayFolder.BeckhoffDisplay newBeckhoffDisplay; if (curServer != null) { newBeckhoffDisplay = new DisplayFolder.BeckhoffDisplay(curServer); newBeckhoffDisplay.Name = "BeckhoffDisplay"; newBeckhoffDisplay.Width = 900; newBeckhoffDisplay.Height = 660; newBeckhoffDisplay.HorizontalAlignment = HorizontalAlignment.Center; newBeckhoffDisplay.VerticalAlignment = VerticalAlignment.Center; Grid1.Children.Add(newBeckhoffDisplay); Grid1.RegisterName(newBeckhoffDisplay.Name, newBeckhoffDisplay); newBeckhoffDisplay.SetValue(Grid.RowSpanProperty, 2); } else { MessageBox.Show("无法连接OPC UA服务器", "警告", MessageBoxButton.OK, MessageBoxImage.Warning); newBeckhoffDisplay = new DisplayFolder.BeckhoffDisplay(); newBeckhoffDisplay.Name = "BeckhoffDisplay"; newBeckhoffDisplay.Width = 900; newBeckhoffDisplay.Height = 660; newBeckhoffDisplay.HorizontalAlignment = HorizontalAlignment.Center; newBeckhoffDisplay.VerticalAlignment = VerticalAlignment.Center; Grid1.Children.Add(newBeckhoffDisplay); Grid1.RegisterName(newBeckhoffDisplay.Name, newBeckhoffDisplay); newBeckhoffDisplay.SetValue(Grid.RowSpanProperty, 2); } }