public Form1() { InitializeComponent(); ReadSettings(); this.m_ReaJetComms = new ReaJetComms(this._portName, this._baudRate, this._parity, this._dataBits, this._stopBits, this._readTimeOut, this._writeTimeOut); this.m_ReaJetComms.ACK_TIMEOUT = this._ackTimeOut; this.m_ReaJetComms.REPLY_TELEGRAM_TIMEOUT = this._replyTelegramTimeOut; }
// Dispose(bool disposing) executes in two distinct scenarios. // If disposing equals true, the method has been called directly // or indirectly by a user's code. Managed and unmanaged resources // can be disposed. // If disposing equals false, the method has been called by the // runtime from inside the finalizer and you should not reference // other objects. Only unmanaged resources can be disposed. protected virtual void Dispose(bool disposing) { try { LogSession.EnterMethod(this, "Dispose"); /*--------- Your code goes here-------*/ // Check to see if Dispose has already been called. if (!this.disposed) { // If disposing equals true, dispose all managed // and unmanaged resources. if (disposing) { // Free any managed resources in this section // free managed resources try { if (this.HandshakeMgr != null) { UnhookFromHandshake(); if ((this.HandshakeMgr as IDisposable) != null) (this.HandshakeMgr as IDisposable).Dispose(); this.HandshakeMgr = null; } if (this.m_ReaJetComms != null) { if ((this.m_ReaJetComms as IDisposable) != null) (this.m_ReaJetComms as IDisposable).Dispose(); this.m_ReaJetComms = null; } if (this.m_PlcComms != null) { this.m_PlcComms.StateChanged -= this.m_PlcComms_StateChanged; if (this.m_PlcComms.IsOpen) this.m_PlcComms.Close(); if ((this.m_PlcComms as IDisposable) != null) (this.m_PlcComms as IDisposable).Dispose(); this.m_PlcComms = null; } } catch (Exception ex) { LogSession.LogException(ex); } } // Call the appropriate methods to clean up // unmanaged resources here. // If disposing is false, // only the following code is executed. } disposed = true; /*------------------------------------*/ } catch (Exception ex) { LogSession.LogException(ex); throw ex; } finally { LogSession.LeaveMethod(this, "Dispose"); } }
public void Initialize() { if (!this.IsInitialized) { this.m_ReaJetComms = new ReaJetComms(this.Settings.portName, this.Settings.baudRate, this.Settings.parity, this.Settings.dataBits, this.Settings.stopBits, this.Settings.readTimeOut, this.Settings.writeTimeOut); this.m_ReaJetComms.ACK_TIMEOUT = this.Settings.ackTimeOut; this.m_ReaJetComms.REPLY_TELEGRAM_TIMEOUT = this.Settings.replyTelegramTimeOut; if(this.Settings.OpcInterfaceRequired) CreateAcquisitionSession(); this.IsInitialized = true; } }