Exemple #1
0
        // Функция проверки подключеиня к серверу
        public bool TestConnection()
        {
            bool result = false;

            if (String.IsNullOrEmpty(URL))
            {
                return(false);
            }
            try
            {
                Kepware.ClientAce.OpcDaClient.ConnectInfo connectInfo = new Kepware.ClientAce.OpcDaClient.ConnectInfo();
                Kepware.ClientAce.OpcDaClient.DaServerMgt DAServer    = new Kepware.ClientAce.OpcDaClient.DaServerMgt();
                Boolean connectFailed = false;

                connectInfo.LocalId                   = "en";
                connectInfo.KeepAliveTime             = KeepAliveTime;
                connectInfo.RetryAfterConnectionError = RetryAfterConnectionError;
                connectInfo.RetryInitialConnection    = RetryInitialConnection;
                connectInfo.ClientName                = "OPCClient";

                Int32 clientHandle = 1;

                DAServer.Connect(URL, clientHandle, ref connectInfo, out connectFailed);
                result = !connectFailed;
                DAServer.Disconnect();
                return(result);
            }
            catch { return(false); }
        }