/// <summary> /// 添加Group /// </summary> /// <param name="groupName"></param> /// <param name="updateRate"></param> /// <param name="bActive"></param> /// <returns></returns> public OpcGroup AddGroup(string groupName, int updateRate, bool bActive) { OpcGroup grp = new OpcGroup(groupName, updateRate, bActive); // initialize arguments. Guid iid = typeof(IOPCItemMgt).GUID; object group = null; int serverHandle = 0; int revisedUpdateRate = 0; GCHandle hDeadband = GCHandle.Alloc(grp.Deadband, GCHandleType.Pinned); // invoke COM method. try { ((IOPCServer)m_server).AddGroup( grp.Name ?? "", (grp.Active) ? 1 : 0, grp.UpdateRate, 0, IntPtr.Zero, hDeadband.AddrOfPinnedObject(), HD.OPC.Client.Core.Com.Interop.GetLocale(grp.Locale), out serverHandle, out revisedUpdateRate, ref iid, out group); } catch (Exception e) { throw HD.OPC.Client.Core.Com.Interop.CreateException("IOPCServer.AddGroup error:" + e.Message, e); } finally { if (hDeadband.IsAllocated) { hDeadband.Free(); } } // set the revised update rate. if (revisedUpdateRate > grp.UpdateRate) { grp.UpdateRate = revisedUpdateRate; } // save server handle. grp.ServerHandle = serverHandle; // save group handle grp.ComGroup = group; // add group to server list this.m_groups.Add(grp); return(grp); }
public void RemoveGroup(OpcGroup group) { // invoke COM method. try { ((IOPCServer)m_server).RemoveGroup((int)group.ServerHandle, 0); } catch (Exception e) { throw HD.OPC.Client.Core.Com.Interop.CreateException("IOPCServer.RemoveGroup", e); } this.m_groups.Remove(group); }
/// <summary> /// Initializes the object with the containing subscription object. /// </summary> public OpcCallback(object handle, int filters, OpcGroup group) { m_handle = handle; m_filters = filters; m_group = group; }