示例#1
0
        }           //	end ProcessCommandLine

        public void Terminate()
        {
            if (m_daSubscription.CurrentState != EnumObjectState.DISCONNECTED)
            {
                m_daSubscription.Disconnect(new ExecutionOptions());
            }
            if (m_daSession.CurrentState != EnumObjectState.DISCONNECTED)
            {
                m_daSession.Disconnect(new ExecutionOptions());
            }

            m_daSubscription.RemoveDaItem(m_daItem1);
            m_daSubscription.RemoveDaItem(m_daItem2);
            m_daSubscription.RemoveDaItem(m_daItem3);

            m_daSession.RemoveDaSubscription(m_daSubscription);
            GetApplication().RemoveDaSession(m_daSession);
            GetApplication().Terminate();
            m_daSession        = null;
            m_daSubscription   = null;
            m_daItem1          = null;
            m_daItem2          = null;
            m_daItem3          = null;
            m_executionOptions = null;
            m_itemList         = null;
        }           //	end Terminate
示例#2
0
        }           //	end Terminate

        public int InitializeDaObjects()
        {
            int connectResult = (int)EnumResultCode.E_FAIL;

            m_itemList         = new MyDaItem[3];
            m_executionOptions = new ExecutionOptions();

            try
            {
                //	TODO add your server URL here
                //	this is the server url for Softing OPCToolbox Demo Server
                //	first choice is COM-DA
                string url = "opcda://localhost/Softing.OPCToolboxDemo_ServerDA/{2e565242-b238-11d3-842d-0008c779d775}";

                //uncomment if you need an XML-DA access
                //	string url = "http://localhost:8079/OPC/DA";

                m_daSession = new MyDaSession(url);

                m_daSubscription = new MyDaSubscription(500, m_daSession);

                m_daItem1     = new MyDaItem("maths.sin", m_daSubscription);
                m_itemList[0] = m_daItem1;

                m_daItem2     = new MyDaItem("time.local.second", m_daSubscription);
                m_itemList[1] = m_daItem2;

                m_daItem3     = new MyDaItem("increment.UI1", m_daSubscription);
                m_itemList[2] = m_daItem3;

                connectResult = m_daSession.Connect(true, false, m_executionOptions);
            }
            catch (Exception exc)
            {
                GetApplication().Trace(
                    EnumTraceLevel.ERR,
                    EnumTraceGroup.USER,
                    "OpcClient::InitializaDaObjects",
                    exc.ToString());
            }               //	end try...catch

            return(connectResult);
        }           //	end InitializeDaObjects
        //-----------------

        public MyDaItem(string itemId, MyDaSubscription parentSubscription) : base(itemId, parentSubscription)
        {
        }