Пример #1
0
        public void ConnectOPCServer(bool connectToOPC)
        {
            if (connectToOPC)
            {
                connectInfo.LocalId                   = "en";
                connectInfo.KeepAliveTime             = KeepAliveTime;
                connectInfo.RetryAfterConnectionError = RetryAfterConnectionError;
                connectInfo.RetryInitialConnection    = RetryInitialConnection;
                connectInfo.ClientName                = ClientName;

                try
                {
                    if (DAServer.IsConnected == false)
                    {
                        DAServer.Connect(URL, clientHandle, ref connectInfo, out isOPCConnectionFiled);
                    }
                }
                catch { }
            }
            else
            {
                try
                {
                    if (DAServer.IsConnected == true)
                    {
                        DAServer.Disconnect();
                    }
                }
                catch { }
            }
        }
Пример #2
0
        // Функция подключения/отключения к/от серверу(а)
        public void ConnectOPCServer(bool connectToOPC)
        {
            if (connectToOPC)
            {
                connectInfo.LocalId                   = "en";
                connectInfo.KeepAliveTime             = KeepAliveTime;
                connectInfo.RetryAfterConnectionError = RetryAfterConnectionError;
                connectInfo.RetryInitialConnection    = RetryInitialConnection;
                connectInfo.ClientName                = ClientName;

                try
                {
                    if (DAServer.IsConnected == false)
                    {
                        DAServer.Connect(URL, clientHandle, ref connectInfo, out isOPCConnectionFailed);
                    }
                    int tagCount = SubscribeData();
                    ModifySubscription(true);
                    MessageBox.Show(String.Format("Succesfully connected to {0} tags", tagCount), "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch { }
            }
            else
            {
                try
                {
                    UnSubscribeData();
                    if (DAServer.IsConnected == true)
                    {
                        DAServer.Disconnect();
                    }
                }
                catch { }
            }
        }
Пример #3
0
 public void Disconnect()
 {
     if (_daServerMgt.IsConnected)
     {
         _daServerMgt.Disconnect();
     }
 }