Esempio n. 1
0
        public void Terminate()
        {
            // disconnect all the connected objects
            if (m_aeSubscription != null && m_aeSubscription.CurrentState != EnumObjectState.DISCONNECTED)
            {
                m_aeSubscription.Disconnect(new ExecutionOptions());
            }

            if (m_aeSession != null && m_aeSession.CurrentState != EnumObjectState.DISCONNECTED)
            {
                m_aeSession.Disconnect(new ExecutionOptions());
                // remove subscription from session
                if (m_aeSession != null)
                {
                    m_aeSession.RemoveAeSubscription(m_aeSubscription);
                }
            }

            // remove session from application
            GetApplication().RemoveAeSession(m_aeSession);

            // terminate the application
            GetApplication().Terminate();
            m_aeSession        = null;
            m_aeSubscription   = null;
            m_executionOptions = null;
        }
Esempio n. 2
0
        //-----------------

        public MyAeSubscription(MyAeSession parentSession) : base(parentSession)
        {
            PerformStateTransitionCompleted += new PerformStateTransitionEventHandler(HandlePerformObjectStateTransitionCompleted);
            StateChangeCompleted            += new StateChangeEventHandler(HandleStateChangeCompleted);
            AeEventsReceived    += new AeEventsReceivedEventHandler(HandleEventsReceived);
            AeConditionsChanged += new AeConditionsChangedEventHandler(HandleConditionsChanged);
        }
Esempio n. 3
0
        public int InitializeAeObjects(string url)
        {
            int connectResult = (int)EnumResultCode.E_FAIL;

            m_executionOptions = new ExecutionOptions();
            m_executionOptions.ExecutionType    = EnumExecutionType.ASYNCHRONOUS;
            m_executionOptions.ExecutionContext = 0;

            try
            {
                m_aeSession      = new MyAeSession(url);
                m_aeSubscription = new MyAeSubscription(m_aeSession);

                connectResult = m_aeSession.Connect(true, false, new ExecutionOptions());

                uint[] categoryIds = new uint[]
                {
                    (uint)CategoriesAndAttribute.Categories.System_alarm,
                    (uint)CategoriesAndAttribute.Categories.Process_alarm,
                    (uint)CategoriesAndAttribute.Categories.Operation_record
                };
                m_aeSubscription.FilterCategories = categoryIds;

                AeReturnedAttributes[] returnedAttributes = new AeReturnedAttributes[categoryIds.Length];
                for (int i = 0; i < categoryIds.Length; i++)
                {
                    List <uint> temp         = CategoriesAndAttribute.getAttributeIDsFromCategoryID(categoryIds[i]);
                    uint[]      attributeIds = new uint[temp.Count];
                    attributeIds          = temp.ToArray();
                    returnedAttributes[i] = new AeReturnedAttributes();
                    returnedAttributes[i].AttributeIds = attributeIds;
                    returnedAttributes[i].CategoryId   = categoryIds[i];
                }
                m_aeSubscription.ReturnedAttributes = returnedAttributes;
            }
            catch (Exception exc)
            {
                GetApplication().Trace(
                    EnumTraceLevel.ERR,
                    EnumTraceGroup.USER,
                    "OpcClient::InitializeAeObjects",
                    exc.ToString());
            }   //    end try...catch

            return(connectResult);
        }       //    end InitializeAeObjects