} // end Terminate public int InitializeAeObjects() { int connectResult = (int)EnumResultCode.E_FAIL; m_executionOptions = new ExecutionOptions(); m_executionOptions.ExecutionType = EnumExecutionType.ASYNCHRONOUS; m_executionOptions.ExecutionContext = 0; try { m_aeSession = new MyAeSession("opcae:///Softing.OPCToolboxDemo_ServerAE.1/{2E565243-B238-11D3-842D-0008C779D775}"); m_aeSubscription = new MyAeSubscription(m_aeSession); connectResult = m_aeSession.Connect(true, true, new ExecutionOptions()); } catch (Exception exc) { GetApplication().Trace( EnumTraceLevel.ERR, EnumTraceGroup.USER, "OpcClient::InitializeAeObjects", exc.ToString()); } // end try...catch return(connectResult); } // end InitializeAeObjects
} // end ProcessCommandLine public void Terminate() { if (m_aeSubscription.CurrentState != EnumObjectState.DISCONNECTED) { m_aeSubscription.Disconnect(m_executionOptions); } // end if if (m_aeSession.CurrentState != EnumObjectState.DISCONNECTED) { m_aeSession.Disconnect(m_executionOptions); } // end if m_aeSession.RemoveAeSubscription(m_aeSubscription); GetApplication().RemoveAeSession(m_aeSession); GetApplication().Terminate(); m_aeSession = null; m_aeSubscription = null; m_executionOptions = null; } // end Terminate
//----------------- public MyAeSubscription(MyAeSession parentSession) : base(parentSession) { }