Esempio n. 1
0
 /// <summary>
 /// 连接opc
 /// </summary>
 /// <param name="client"></param>
 private bool ConnectOpc(IOpcClient client)
 {
     try
     {
         if (client.Connect().Result)
         {
             //创建组及绑定组内的tags
             client.CreateGroup("GroupTrigger")
             .SetUpdateRate(groupTriggerUpdateRate)
             .AddItems(TagConfig.QueryTagsByGroupName <Tag>("GroupTrigger"))
             .ValueChangedHandle = TagValueChanged;
             client.CreateGroup("GroupData")
             .SetUpdateRate(groupDataUpdateRate)
             .AddItems(TagConfig.QueryTagsByGroupName <Tag>("GroupData"))
             .AddQueue(100)
             .ValueChangedHandle = TagValueChanged;
             OpcServerRefreshUI(client);
             return(true);
         }
         else
         {
             OpcServerRefreshUI(client);
             return(false);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 2
0
 /// <summary>
 /// 连接opc
 /// </summary>
 /// <param name="client"></param>
 private bool ConnectOpc(IOpcClient client)
 {
     if (client.Connect().Result == true)
     {
         client.RemoveGroupsAll();
         //创建组及绑定组内的tags
         client.CreateGroup("GroupTrigger")
         .SetUpdateRate(groupTriggerUpdateRate)
         .AddItems(TagConfig.QueryTagsByGroupName <Tag>("GroupTrigger"))
         .ValueChangedHandle = TagValueChanged;
         client.CreateGroup("GroupData")
         .SetUpdateRate(groupDataUpdateRate)
         .AddItems(TagConfig.QueryTagsByGroupName <Tag>("GroupData"))
         .AddQueue(tagsQueueNum);
         OpcServerRefreshUI(client);
         return(true);
     }
     else
     {
         OpcServerRefreshUI(client);
         return(false);
     }
 }