示例#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
文件: Form1.cs 项目: Lixreison/RSPO
        // Функция подключения/отключения к/от серверу(а)
        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();
     }
 }