예제 #1
0
        /// <summary>Establishes a physical connection to the remote server.</summary>
        /// <exception cref="OpcResultException" caption="OpcResultException Class">If an OPC specific error occur this exception is raised. The Result field includes then the OPC specific code.</exception>
        /// <param name="url">Name of the server. The usual form is http:://xxx/yyy, e.g. http://localhost//TsOpcXSampleServer/Service.asmx.</param>
        public virtual void Connect(string url)
        {
            OpcConnectData connectData = null;

            _factory = null;
            OpcUrl opcurl = new OpcUrl(url);

            Connect(opcurl, connectData);
        }
예제 #2
0
        /// <summary>
        /// Establishes a physical connection to the remote server identified by a OpcUrl.
        /// </summary>
        /// <param name="url">The network address of the remote server.</param>
        /// <param name="connectData">Any protocol configuration or user authenication information.</param>
        public virtual void Connect(OpcUrl url, OpcConnectData connectData)
        {
            if (url == null)
            {
                throw new ArgumentNullException("url");
            }
            if (_server != null)
            {
                throw new OpcResultException(new OpcResult((int)OpcResult.E_FAIL.Code, OpcResult.FuncCallType.SysFuncCall, null), "The server is already connected.");
            }

            //  save url.
            SetUrl(url);

            try
            {
                _factory.ForceDa20Usage = ForceDa20Usage;

                // instantiate the server object.
                _server = _factory.CreateInstance(url, connectData);

                // save the connect data.
                _connectData = connectData;

                try
                {
                    // cache the supported locales.
                    GetSupportedLocales();

                    // update the default locale.
                    SetLocale(_locale);

                    SupportedSpecifications = new List <OpcSpecification>();
#if (_OPCCLIENTSDK_DA)
                    if (_server is Com.Da20.Server)
                    {
                        SupportedSpecifications.Add(OpcSpecification.OPC_DA_20);
                    }
                    else if (_server is Com.Da.Server)
                    {
                        SupportedSpecifications.Add(OpcSpecification.OPC_DA_30);
                        SupportedSpecifications.Add(OpcSpecification.OPC_DA_20);
                    }
#endif
#if (_OPCCLIENTSDK_AE)
#if (_OPCCLIENTSDK_DA)
                    else if (_server is Com.Ae.Server)
#else
                    if (_server is Com.Ae.Server)
#endif
                    {
                        SupportedSpecifications.Add(OpcSpecification.OPC_AE_10);
                    }
#endif
#if (_OPCCLIENTSDK_HDA)
#if (_OPCCLIENTSDK_DA || _OPCCLIENTSDK_AE)
                    else if (_server is Com.Hda.Server)
#else
                    if (_server is Com.Hda.Server)
#endif
                    {
                        SupportedSpecifications.Add(OpcSpecification.OPC_HDA_10);
                    }
#endif
#if (_OPCCLIENTSDK_XMLDA)
                    else if (m_server is Xml.Da.Server)
                    {
                        SupportedSpecifications.Add(OpcSpecification.XML_DA_10);
                    }
#endif
#if (_OPCCLIENTSDK_XI)
                    else if (m_server is Xi.Server)
                    {
                        SupportedSpecifications.Add(OpcSpecification.OPC_XI_10);
                    }
#endif
                }
                catch (Exception e)
                {
                }
            }
            catch (Exception e)
            {
                if (_server != null)
                {
                    try { Disconnect(); }
                    catch (Exception e1)
                    {
                    }
                }

                throw e;
            }
        }
예제 #3
0
 /// <summary>
 /// Establishes a physical connection to the remote server.
 /// </summary>
 /// <param name="connectData">Any protocol configuration or user authenication information.</param>
 public virtual void Connect(OpcConnectData connectData)
 {
     Connect(_url, connectData);
 }
        /// <summary>
        /// Creates a new instance of the server.
        /// </summary>
        public virtual IOpcServer CreateInstance(OpcUrl url, OpcConnectData connectData)
        {
            IOpcServer server = (IOpcServer)Activator.CreateInstance(SystemType, new object[] { url, connectData });

            return(server);
        }