internal void InternalAdd(int[] p_BiasTime, float[] p_PercentDeadband, int p_LocaleID) { Type l_TypGrpMgt = typeof(IOPCGroupStateMgt); Guid l_GuidGrpTst = l_TypGrpMgt.GUID; object l_ObjTemp; if (m_State.Public) { IOPCServerPublicGroups l_IfPubGrps = null; l_IfPubGrps = (IOPCServerPublicGroups)m_IfServer; if (l_IfPubGrps == null) { Marshal.ThrowExceptionForHR(HResults.E_NOINTERFACE); } l_IfPubGrps.GetPublicGroupByName(m_State.Name, ref l_GuidGrpTst, out l_ObjTemp); l_IfPubGrps = null; } else { m_IfServer.AddGroup(m_State.Name, m_State.Active, m_State.UpdateRate, m_State.HandleClient, p_BiasTime, p_PercentDeadband, m_State.LocaleID, out m_State.HandleServer, out m_State.UpdateRate, ref l_GuidGrpTst, out l_ObjTemp); } if (l_ObjTemp == null) { Marshal.ThrowExceptionForHR(HResults.E_NOINTERFACE); } m_IfMgt = (IOPCGroupStateMgt)l_ObjTemp; l_ObjTemp = null; GetStates(); GetInterfaces(); AdviseIOPCDataCallback(); }
/// <summary> /// Create OPC Group /// </summary> /// <param name="opcServer">If server link</param> /// <param name="isPublic">Is public</param> /// <param name="groupName">Group name</param> /// <param name="setActive">Set active</param> /// <param name="requestedUpdateRate">Requested update rate</param> /// <param name="biasTime">Bias time</param> /// <param name="percentDeadband">Percent deadband</param> /// <param name="localeID">Locale ID</param> internal OpcGroup(IOPCServer opcServer, bool isPublic, string groupName, bool setActive, int requestedUpdateRate, int?biasTime, float?percentDeadband, int localeID) { IsDisposed = false; parentServer = opcServer; stateName = groupName; statePublic = isPublic; stateUpdateRate = requestedUpdateRate; stateActive = setActive; stateTimeBias = 0; statePercentDeadband = 0.0f; stateLocaleID = 0; stateHandleClient = this.GetHashCode(); stateHandleServer = 0; Type typGrpMgt = typeof(IOPCGroupStateMgt); Guid guidGrpTst = typGrpMgt.GUID; if (statePublic) { IOPCServerPublicGroups ifPubGrps = null; ifPubGrps = (IOPCServerPublicGroups)parentServer; if (ifPubGrps == null) { Marshal.ThrowExceptionForHR(HRESULTS.E_NOINTERFACE); } ifPubGrps.GetPublicGroupByName(stateName, ref guidGrpTst, out opcGroupObject); ifPubGrps = null; } else { int[] biasTimeArray = biasTime == null ? null : new int[1] { biasTime.Value }; float[] percentDeadbandArray = percentDeadband == null ? null : new float[1] { percentDeadband.Value }; parentServer.AddGroup(stateName, stateActive, stateUpdateRate, stateHandleClient, biasTimeArray, percentDeadbandArray, stateLocaleID, out stateHandleServer, out stateUpdateRate, ref guidGrpTst, out opcGroupObject); } if (opcGroupObject == null) { Marshal.ThrowExceptionForHR(HRESULTS.E_NOINTERFACE); } RefreshState(); // Advise callback Guid sinkGuid = typeof(IOPCDataCallback).GUID; connectionPointContainer.FindConnectionPoint(ref sinkGuid, out callbackConnectionPoint); if (callbackConnectionPoint != null) { callbackConnectionPoint.Advise(this, out callbackCookie); } }
internal void internalAdd(int[] biasTime, float[] percentDeadband, int localeID) { Type typGrpMgt = typeof(IOPCGroupStateMgt); Guid guidGrpTst = typGrpMgt.GUID; object objtemp; if (state.Public) { IOPCServerPublicGroups ifPubGrps = null; ifPubGrps = (IOPCServerPublicGroups)ifServer; if (ifPubGrps == null) { Marshal.ThrowExceptionForHR(HRESULTS.E_NOINTERFACE); } ifPubGrps.GetPublicGroupByName(state.Name, ref guidGrpTst, out objtemp); ifPubGrps = null; } else { ifServer.AddGroup(state.Name, state.Active, state.UpdateRate, state.HandleClient, biasTime, percentDeadband, state.LocaleID, out state.HandleServer, out state.UpdateRate, ref guidGrpTst, out objtemp); } if (objtemp == null) { Marshal.ThrowExceptionForHR(HRESULTS.E_NOINTERFACE); } ifMgt = (IOPCGroupStateMgt)objtemp; objtemp = null; GetStates(); getinterfaces(); AdviseIOPCDataCallback(); }