private bool Connect() { if (_Master != null) { _Master.Dispose(); } if (CheckInternet()) { try { // Create Modbus TCP Master _Master = new TcpMaster(txtRemoteIP.Text, int.Parse(txtPort.Text)); _Master.Retries = 0; // 不需要重試 _Master.ReadTimeout = 1500; LogManager.WriteLog("Cannot to Remote Modbus Device({0}:{1})", txtRemoteIP.Text, txtPort.Text); return(true); } catch (Exception ex) { LogManager.LogException(ex); return(false); } } return(false); }
public Coupler(IJournal journal, string url) { mJournal = journal; mConnection = new TcpMaster(journal, url, 502); mThread = new Thread(Update); }
private void Disconnect() { try { this._NetworkIsOK = false; tmrRefrash.Enabled = false; if (_Master != null) { _Master.Dispose(); } _Master = null; } catch (Exception ex) { LogManager.LogException(ex); } }