Beispiel #1
0
 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);
 }
Beispiel #2
0
        public Coupler(IJournal journal, string url)
        {
            mJournal = journal;

            mConnection = new TcpMaster(journal, url, 502);

            mThread = new Thread(Update);
        }
Beispiel #3
0
 private void Disconnect()
 {
     try
     {
         this._NetworkIsOK  = false;
         tmrRefrash.Enabled = false;
         if (_Master != null)
         {
             _Master.Dispose();
         }
         _Master = null;
     }
     catch (Exception ex)
     {
         LogManager.LogException(ex);
     }
 }