public void ConnectOPCServer(bool connectToOPC) { if (connectToOPC) { connectInfo.LocalId = "en"; connectInfo.KeepAliveTime = KeepAliveTime; connectInfo.RetryAfterConnectionError = RetryAfterConnectionError; connectInfo.RetryInitialConnection = RetryInitialConnection; connectInfo.ClientName = ClientName; try { if (DAServer.IsConnected == false) { DAServer.Connect(URL, clientHandle, ref connectInfo, out isOPCConnectionFiled); } } catch { } } else { try { if (DAServer.IsConnected == true) { DAServer.Disconnect(); } } catch { } } }
// Функция подключения/отключения к/от серверу(а) public void ConnectOPCServer(bool connectToOPC) { if (connectToOPC) { connectInfo.LocalId = "en"; connectInfo.KeepAliveTime = KeepAliveTime; connectInfo.RetryAfterConnectionError = RetryAfterConnectionError; connectInfo.RetryInitialConnection = RetryInitialConnection; connectInfo.ClientName = ClientName; try { if (DAServer.IsConnected == false) { DAServer.Connect(URL, clientHandle, ref connectInfo, out isOPCConnectionFailed); } int tagCount = SubscribeData(); ModifySubscription(true); MessageBox.Show(String.Format("Succesfully connected to {0} tags", tagCount), "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch { } } else { try { UnSubscribeData(); if (DAServer.IsConnected == true) { DAServer.Disconnect(); } } catch { } } }
public void Disconnect() { if (_daServerMgt.IsConnected) { _daServerMgt.Disconnect(); } }