Example #1
0
 public void Disconnect()
 {
     if (_server == null)
     {
         throw new InvalidOperationException("OPC Serverに接続されていません。");
     }
     _group.Dispose();
     _group = null;
     _server.Dispose();
     _server        = null;
     _serverHandles = null;
 }
Example #2
0
 public void Connect(string progId)
 {
     _logger.Trace($"Connect( {progId ?? "<null>"} )");
     if (_server != null)
     {
         throw new InvalidOperationException("既にOPC Serverに接続されています。");
     }
     if (progId == null)
     {
         throw new ArgumentNullException(nameof(progId));
     }
     _server = _factory.CreateFromProgId(progId);
     if (_server == null)
     {
         throw new NullReferenceException(nameof(_server));
     }
     _group = _server.AddGroup("default", true, 1000, 0, 0, 0);
     if (_group == null)
     {
         throw new NullReferenceException(nameof(_group));
     }
     _serverHandles = new ConcurrentDictionary <string, int>();
 }