public bool Disconnection() { try { if (DLL != null) { if (DLL.IsConnected) { try { DLL.Disconnect(); } catch { } } DLL.Dispose(); fact.Dispose(); } IsConnected = false; } catch (Exception ex) { EventscadaException?.Invoke(GetType().Name, "ConnectedFailed"); throw ex; } return(IsConnected); }
//*************************************************************** //* Create the Data Link Layer Instances //* if the IP Address is the same, then resuse a common instance //*************************************************************** public bool Connection() { try { if (DLL == null) { if (DLL != null && DLL.IsConnected) { DLL.Disconnect(); } DLL = new Server(fact, null) { Url = new URL(m_OPCServerPath + "/" + OPCServer) }; DLL.Connect(); if (DLL.IsConnected) { EventscadaException?.Invoke(GetType().Name, "ConnectedSuccess"); IsConnected = true; } else { EventscadaException?.Invoke(GetType().Name, "ConnectedFailed"); IsConnected = false; } } } catch (Exception) { EventscadaException?.Invoke(GetType().Name, "ConnectedFailed"); IsConnected = false; } return(IsConnected); }