コード例 #1
0
        /// <summary>
        /// Sets the locale used in any error messages or results returned to the client.
        /// </summary>
        /// <param name="locale">The locale name in the format "[languagecode]-[country/regioncode]".</param>
        /// <returns>A locale that the server supports and is the best match for the requested locale.</returns>
        public virtual string SetLocale(string locale)
        {
            if (_server == null)
            {
                throw new NotConnectedException();
            }

            try
            {
                // set the requested locale on the server.
                _locale = _server.SetLocale(locale);
            }
            catch
            {
                // find a best match and check if the server supports it.
                string revisedLocale = OpcServer.FindBestLocale(locale, _supportedLocales);

                if (revisedLocale != locale)
                {
                    _server.SetLocale(revisedLocale);
                }

                // cache the revised locale.
                _locale = revisedLocale;
            }

            // return actual local used.
            return(_locale);
        }
コード例 #2
0
        /// <summary>
        /// Creates a new instance of a server object with the same factory and url.
        /// </summary>
        /// <remarks>This method does not copy the value of any properties.</remarks>
        /// <returns>An unconnected duplicate instance of the server object.</returns>
        public virtual Technosoftware.DaAeHdaClient.OpcServer Duplicate()
        {
            OpcServer instance = (Technosoftware.DaAeHdaClient.OpcServer)Activator.CreateInstance(GetType(), new object[] { _factory, _url });

            //  preserve the credentials.
            instance._connectData = _connectData;

            //  preserve the locale.
            instance._locale = _locale;

            return(instance);
        }
コード例 #3
0
        /// <summary>
        /// Returns an unconnected copy of the server with the same OpcUrl.
        /// </summary>
        public virtual object Clone()
        {
            //  do a memberwise clone.
            OpcServer clone = (OpcServer)MemberwiseClone();

            //  place clone in disconnected state.
            clone._server           = null;
            clone._supportedLocales = null;
            clone._locale           = null;
            clone._resourceManager  = new ResourceManager("Technosoftware.DaAeHdaClient.Resources.Strings", Assembly.GetExecutingAssembly());

            //  return clone.
            return(clone);
        }
コード例 #4
0
        /// <summary>
        /// Creates a server object for the specified URL.
        /// </summary>
        /// <param name="url">The OpcUrl of the OPC server.</param>
        /// <returns>The OpcServer object.</returns>
        public static OpcServer GetServer(OpcUrl url)
        {
            if (url == null)
            {
                throw new ArgumentNullException(nameof(url));
            }

            OpcServer server = null;

            // create an unconnected server object for COM based servers.

            // DA
            if (String.CompareOrdinal(url.Scheme, OpcUrlScheme.DA) == 0)
            {
                server = new Da.TsCDaServer(new Factory(), url);
            }

            // AE
            else if (String.CompareOrdinal(url.Scheme, OpcUrlScheme.AE) == 0)
            {
                server = new Ae.TsCAeServer(new Factory(), url);
            }

            // HDA
            else if (String.CompareOrdinal(url.Scheme, OpcUrlScheme.HDA) == 0)
            {
                server = new Hda.TsCHdaServer(new Factory(), url);
            }

            // Other specifications not supported yet.
            if (server == null)
            {
                throw new NotSupportedException(url.Scheme);
            }

            return(server);
        }
コード例 #5
0
        ///////////////////////////////////////////////////////////////////////
        #region Public Methods (Returns OpcServer object for a specific URL)

        /// <summary>
        /// Creates a server object for the specified URL.
        /// </summary>
        /// <param name="url">The OpcUrl of the OPC server.</param>
        /// <returns>The OpcServer obkect.</returns>
        public static OpcServer GetServer(Technosoftware.DaAeHdaClient.OpcUrl url)
        {
            if (url == null)
            {
                throw new ArgumentNullException("url");
            }

            OpcServer server = null;

            // create an unconnected server object for COM based servers.

            // DA
            if (server == null && String.Compare(url.Scheme, OpcUrlScheme.DA, false) == 0)
            {
                server = new Da.TsCDaServer(new Technosoftware.DaAeHdaClient.Com.Factory(), url);
            }

            // AE
            else if (String.Compare(url.Scheme, OpcUrlScheme.AE, false) == 0)
            {
                server = new Ae.TsCAeServer(new Technosoftware.DaAeHdaClient.Com.Factory(), url);
            }

            // HDA
            else if (String.Compare(url.Scheme, OpcUrlScheme.HDA, false) == 0)
            {
                server = new Hda.TsCHdaServer(new Technosoftware.DaAeHdaClient.Com.Factory(), url);
            }

            // Other specifications not supported yet.
            if (server == null)
            {
                throw new NotSupportedException(url.Scheme);
            }

            return(server);
        }