Beispiel #1
0
        internal void internalAdd(int[] biasTime, float[] percentDeadband, int localeID)
        {
            object obj2;
            Type   type = typeof(IOPCGroupStateMgt);
            Guid   gUID = type.GUID;

            if (this.state.Public)
            {
                IOPCServerPublicGroups ifServer = null;
                ifServer = (IOPCServerPublicGroups)this.ifServer;
                if (ifServer == null)
                {
                    Marshal.ThrowExceptionForHR(-2147467262);
                }
                ifServer.GetPublicGroupByName(this.state.Name, ref gUID, out obj2);
                ifServer = null;
            }
            else
            {
                this.ifServer.AddGroup(this.state.Name, this.state.Active, this.state.UpdateRate, this.state.HandleClient, biasTime, percentDeadband, this.state.LocaleID, out this.state.HandleServer, out this.state.UpdateRate, ref gUID, out obj2);
            }
            if (obj2 == null)
            {
                Marshal.ThrowExceptionForHR(-2147467262);
            }
            this.ifMgt = (IOPCGroupStateMgt)obj2;
            obj2       = null;
            this.GetStates();
            this.getinterfaces();
            this.AdviseIOPCDataCallback();
        }
Beispiel #2
0
        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();
        }
Beispiel #3
0
        /// <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);
            }
        }
Beispiel #4
0
        public void DeletePublic(bool p_Force)
        {
            if (!m_State.Public)
            {
                Marshal.ThrowExceptionForHR(HResults.E_FAIL);
            }

            IOPCServerPublicGroups l_IfPubGrps = null;

            l_IfPubGrps = (IOPCServerPublicGroups)m_IfServer;
            if (l_IfPubGrps == null)
            {
                Marshal.ThrowExceptionForHR(HResults.E_NOINTERFACE);
            }
            Remove(false);
            l_IfPubGrps.RemovePublicGroup(m_State.HandleServer, p_Force);
            l_IfPubGrps = null;
        }
Beispiel #5
0
        public void DeletePublic(bool bForce)
        {
            if (!this.state.Public)
            {
                Marshal.ThrowExceptionForHR(-2147467259);
            }
            IOPCServerPublicGroups ifServer = null;

            ifServer = (IOPCServerPublicGroups)this.ifServer;
            if (ifServer == null)
            {
                Marshal.ThrowExceptionForHR(-2147467262);
            }
            int handleServer = this.state.HandleServer;

            this.Remove(false);
            ifServer.RemovePublicGroup(handleServer, bForce);
            ifServer = null;
        }
Beispiel #6
0
        /// <summary>
        /// Delete public OPC group
        /// </summary>
        /// <param name="force">Force remove</param>
        public void DeletePublic(bool force)
        {
            ThrowIfDisposed();
            if (!statePublic)
            {
                Marshal.ThrowExceptionForHR(HRESULTS.E_FAIL);
            }

            IOPCServerPublicGroups ifPubGrps = parentServer as IOPCServerPublicGroups;

            if (ifPubGrps == null)
            {
                Marshal.ThrowExceptionForHR(HRESULTS.E_NOINTERFACE);
            }
            int serverhandle = stateHandleServer;

            InternalRemove(false);
            ifPubGrps.RemovePublicGroup(serverhandle, force);
            ifPubGrps = null;
        }
Beispiel #7
0
        // -------------- IOPCServerPublicGroups + IOPCPublicGroupStateMgt

        public void DeletePublic(bool bForce)
        {
            if (!state.Public)
            {
                Marshal.ThrowExceptionForHR(HRESULTS.E_FAIL);
            }

            IOPCServerPublicGroups ifPubGrps = null;

            ifPubGrps = (IOPCServerPublicGroups)ifServer;
            if (ifPubGrps == null)
            {
                Marshal.ThrowExceptionForHR(HRESULTS.E_NOINTERFACE);
            }
            int serverhandle = state.HandleServer;

            Remove(false);
            ifPubGrps.RemovePublicGroup(serverhandle, bForce);
            ifPubGrps = null;
        }
Beispiel #8
0
        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();
        }