Пример #1
0
        public void MoveToPublic()
        {
            if (this.state.Public)
            {
                Marshal.ThrowExceptionForHR(-2147467259);
            }
            IOPCPublicGroupStateMgt ifMgt = null;

            ifMgt = (IOPCPublicGroupStateMgt)this.ifMgt;
            if (ifMgt == null)
            {
                Marshal.ThrowExceptionForHR(-2147467262);
            }
            ifMgt.MoveToPublic();
            ifMgt.GetState(out this.state.Public);
            ifMgt = null;
        }
Пример #2
0
        //======================================================================
        // State Management

        /// <summary>
        /// Returns the current state of the subscription.
        /// </summary>
        /// <returns>The current state of the subscription.</returns>
        public TsCDaSubscriptionState GetState()
        {
            lock (this)
            {
                TsCDaSubscriptionState state = new TsCDaSubscriptionState();

                state.ClientHandle = _handle;

                string methodName = "IOPCGroupStateMgt.GetState";
                try
                {
                    string name         = null;
                    int    active       = 0;
                    int    updateRate   = 0;
                    float  deadband     = 0;
                    int    timebias     = 0;
                    int    localeID     = 0;
                    int    clientHandle = 0;
                    int    serverHandle = 0;

                    IOPCGroupStateMgt subscription = BeginComCall <IOPCGroupStateMgt>(methodName, true);
                    subscription.GetState(
                        out updateRate,
                        out active,
                        out name,
                        out timebias,
                        out deadband,
                        out localeID,
                        out clientHandle,
                        out serverHandle);

                    state.Name         = name;
                    state.ServerHandle = serverHandle;
                    if (active == 1)
                    {
                        state.Active = true;
                    }
                    else
                    {
                        state.Active = false;
                    }
                    state.UpdateRate = updateRate;
                    state.TimeBias   = timebias;
                    state.Deadband   = deadband;
                    state.Locale     = Utilities.Interop.GetLocale(localeID);

                    // cache the name separately.
                    name_ = state.Name;

                    state.KeepAlive = 0;
                }
                catch (Exception e)
                {
                    ComCallError(methodName, e);
                    throw Utilities.Interop.CreateException(methodName, e);
                }
                finally
                {
                    EndComCall(methodName);
                }

                return(state);
            }
        }
Пример #3
0
 public void GetStates()
 {
     m_IfMgt.GetState(out m_State.UpdateRate, out m_State.Active, out m_State.Name,
                      out m_State.TimeBias, out m_State.PercentDeadband, out m_State.LocaleID,
                      out m_State.HandleClient, out m_State.HandleServer);
 }
Пример #4
0
        /// <summary>
        /// Returns the current state of the subscription.
        /// </summary>
        /// <returns>The current state of the subscription.</returns>
        public override TsCDaSubscriptionState GetState()
        {
            if (subscription_ == null)
            {
                throw new NotConnectedException();
            }
            lock (lock_)
            {
                string methodName            = "IOPCGroupStateMgt.GetState";
                TsCDaSubscriptionState state = new TsCDaSubscriptionState {
                    ClientHandle = _handle
                };

                string name = null;

                try
                {
                    int   active       = 0;
                    int   updateRate   = 0;
                    float deadband     = 0;
                    int   timebias     = 0;
                    int   localeID     = 0;
                    int   clientHandle = 0;
                    int   serverHandle = 0;

                    IOPCGroupStateMgt subscription = BeginComCall <IOPCGroupStateMgt>(methodName, true);
                    subscription.GetState(
                        out updateRate,
                        out active,
                        out name,
                        out timebias,
                        out deadband,
                        out localeID,
                        out clientHandle,
                        out serverHandle);

                    if (DCOMCallWatchdog.IsCancelled)
                    {
                        throw new Exception($"{methodName} call was cancelled due to response timeout");
                    }

                    state.Name         = name;
                    state.ServerHandle = serverHandle;
                    state.Active       = active != 0;
                    state.UpdateRate   = updateRate;
                    state.TimeBias     = timebias;
                    state.Deadband     = deadband;
                    state.Locale       = Technosoftware.DaAeHdaClient.Com.Interop.GetLocale(localeID);

                    // cache the name separately.
                    name_ = state.Name;
                }
                catch (Exception e)
                {
                    ComCallError(methodName, e);
                    throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException(methodName, e);
                }
                finally
                {
                    EndComCall(methodName);
                }

                state.KeepAlive = 0;

                return(state);
            }
        }
Пример #5
0
        // 2011/11/14 シャットダウンイベントを受けれるようにする	)


        // 2012/01/12 グループのアクティブ/非アクティブを切り替え	(
        //=====================================================
        //Function		: SetGroupActiveStatus(bool bSetActiveState, out string sErrMsg)
        //Distribution	: グループのアクティブ状態を設定
        //return		: true	接続完了
        //				  false	接続失敗
        //=====================================================
        public bool SetGroupActiveStatus(bool bSetActiveState, out string sErrMsg)
        {
            sErrMsg = string.Empty;
            if (m_OPCServer == null)
            {
                sErrMsg = "No connecting";
                return(false);
            }

            if (((m_OPCGroup == null) && (m_OPCGroup2 == null)) || m_iServerGroup == 0)
            {
                sErrMsg = "No connecting";
                return(false);
            }

            // アクティブ状態指定用
            IntPtr pActive = IntPtr.Zero;

            try
            {
                int    nUpdateRate        = 0;
                int    nActive            = 0;
                string sName              = "";
                int    nTimeBias          = 0;
                float  fDeadband          = 0;
                int    nLCID              = 0;
                int    nClientGroup       = 0;
                int    nServerGroup       = 0;
                int    nRevisedUpdateRate = 0;
                int    nActiveState       = (bSetActiveState == true) ? 1 : 0;

                // ポインタ実体メモリエリアを確保し、nActiveStateをコピー(アンセーフコードで確保)
                pActive = Marshal.AllocHGlobal(sizeof(int));
                Marshal.StructureToPtr(nActiveState, pActive, false);

                switch (m_OpcdaVer)
                {
                case DEF_OPCDA.VER_30:
                {
                    IOPCGroupStateMgt2 OPCGroup = (IOPCGroupStateMgt2)m_OPCGroup2;
                    OPCGroup.GetState(out nUpdateRate, out nActive, out sName, out nTimeBias, out fDeadband, out nLCID, out nClientGroup, out nServerGroup);
                    OPCGroup.SetState(IntPtr.Zero, out nRevisedUpdateRate, pActive, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
                }
                break;

                case DEF_OPCDA.VER_10:
                case DEF_OPCDA.VER_20:
                default:
                {
                    IOPCGroupStateMgt OPCGroup = (IOPCGroupStateMgt)m_OPCGroup;
                    OPCGroup.GetState(out nUpdateRate, out nActive, out sName, out nTimeBias, out fDeadband, out nLCID, out nClientGroup, out nServerGroup);
                    OPCGroup.SetState(IntPtr.Zero, out nRevisedUpdateRate, pActive, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
                }
                break;
                }
                return(true);
            }
            catch (Exception exc)
            {
                // 例外処理
                sErrMsg = exc.ToString();
                return(false);
            }
            finally
            {
                // 確保したメモリエリアを解放(アンセーフコードで確保したため)
                Marshal.FreeHGlobal(pActive);
            }
        }
Пример #6
0
        // 2011/11/14 �V���b�g?�E���C�x���g���󂯂��悤�ɂ���	)


        // 2012/01/12 �O��?�v�̃A�N�e�B�u/��A�N�e�B�u��؂�ւ�	(
        //=====================================================
        //Function		: SetGroupActiveStatus(bool bSetActiveState, out string sErrMsg)
        //Distribution	: �O��?�v�̃A�N�e�B�u��Ԃ�ݒ�
        //return		: true	�ڑ�����
        //				  false	�ڑ����s
        //=====================================================
        public bool SetGroupActiveStatus(bool bSetActiveState, out string sErrMsg)
        {
            sErrMsg = string.Empty;
            if (m_OPCServer == null)
            {
                sErrMsg = "No connecting";
                return(false);
            }

            if (((m_OPCGroup == null) && (m_OPCGroup2 == null)) || m_iServerGroup == 0)
            {
                sErrMsg = "No connecting";
                return(false);
            }

            // �A�N�e�B�u��Ԏw��p
            IntPtr pActive = IntPtr.Zero;

            try
            {
                int    nUpdateRate        = 0;
                int    nActive            = 0;
                string sName              = "";
                int    nTimeBias          = 0;
                float  fDeadband          = 0;
                int    nLCID              = 0;
                int    nClientGroup       = 0;
                int    nServerGroup       = 0;
                int    nRevisedUpdateRate = 0;
                int    nActiveState       = (bSetActiveState == true) ? 1 : 0;

                // ?�C��?���̃������G���A���m�ۂ��AnActiveState���R�s?(�A���Z?�t�R?�h�Ŋm�ہj
                pActive = Marshal.AllocHGlobal(sizeof(int));
                Marshal.StructureToPtr(nActiveState, pActive, false);

                switch (m_OpcdaVer)
                {
                case DEF_OPCDA.VER_30:
                {
                    IOPCGroupStateMgt2 OPCGroup = (IOPCGroupStateMgt2)m_OPCGroup2;
                    OPCGroup.GetState(out nUpdateRate, out nActive, out sName, out nTimeBias, out fDeadband, out nLCID, out nClientGroup, out nServerGroup);
                    OPCGroup.SetState(IntPtr.Zero, out nRevisedUpdateRate, pActive, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
                }
                break;

                case DEF_OPCDA.VER_10:
                case DEF_OPCDA.VER_20:
                default:
                {
                    IOPCGroupStateMgt OPCGroup = (IOPCGroupStateMgt)m_OPCGroup;
                    OPCGroup.GetState(out nUpdateRate, out nActive, out sName, out nTimeBias, out fDeadband, out nLCID, out nClientGroup, out nServerGroup);
                    OPCGroup.SetState(IntPtr.Zero, out nRevisedUpdateRate, pActive, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
                }
                break;
                }
                return(true);
            }
            catch (Exception exc)
            {
                // ��O����
                sErrMsg = exc.ToString();
                return(false);
            }
            finally
            {
                // �m�ۂ����������G���A�����(�A���Z?�t�R?�h�Ŋm�ۂ������߁j
                Marshal.FreeHGlobal(pActive);
            }
        }