Exemple #1
0
        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 != null) ? grp.Name : "",
                    (grp.Active) ? 1 : 0,
                    grp.UpdateRate,
                    0,
                    IntPtr.Zero,
                    hDeadband.AddrOfPinnedObject(),
                    OpcDa.Client.Com.Interop.GetLocale(grp.Locale),
                    out serverHandle,
                    out revisedUpdateRate,
                    ref iid,
                    out group);
            }
            catch (Exception e)
            {
                throw OpcDa.Client.Com.Interop.CreateException("IOPCServer.AddGroup", 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);
        }
Exemple #2
0
        public void RemoveGroup(OpcGroup group)
        {
            // invoke COM method.
            try
            {
                ((IOPCServer)m_server).RemoveGroup((int)group.ServerHandle, 0);
            }
            catch (Exception e)
            {
                throw OpcDa.Client.Com.Interop.CreateException("IOPCServer.RemoveGroup", e);
            }


            this.m_groups.Remove(group);
        }
Exemple #3
0
 /// <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;
 }