Opc.Ua.AlarmConditionState.SetShelvingState C# (CSharp) Method

SetShelvingState() public method

Sets the shelving state of the condition.
public SetShelvingState ( ISystemContext context, bool shelved, bool oneShot, double shelvingTime ) : void
context ISystemContext The shelving context.
shelved bool if set to true shelved.
oneShot bool if set to true for a one shot shelve..
shelvingTime double The duration of a timed shelve.
return void
        public virtual void SetShelvingState(
            ISystemContext context,
            bool shelved,
            bool oneShot,
            double shelvingTime)
        {
            if (this.ShelvingState == null)
            {
                return;
            }

            if (m_unshelveTimer != null)
            {
                m_unshelveTimer.Dispose();
                m_unshelveTimer = null;
            }

            if (!shelved)
            {
                if (this.SuppressedState == null || !this.SuppressedState.Id.Value)
                {
                    SuppressedOrShelved.Value = false;
                }

                this.ShelvingState.CauseProcessingCompleted(context, Methods.ShelvedStateMachineType_Unshelve);
            }
            else
            {
                SuppressedOrShelved.Value = true;
                m_oneShot = oneShot;
                m_unshelveTime = DateTime.MinValue;

                if (oneShot)
                {                    
                    this.ShelvingState.CauseProcessingCompleted(context, Methods.ShelvedStateMachineType_OneShotShelve);
                }
                else
                {
                    if (shelvingTime > 0)
                    {
                        m_unshelveTime = DateTime.UtcNow.AddMilliseconds(shelvingTime);
                        m_unshelveTimer = new Timer(OnTimerExpired, context, (int)shelvingTime, Timeout.Infinite);
                    }

                    this.ShelvingState.CauseProcessingCompleted(context, Methods.ShelvedStateMachineType_TimedShelve);
                }
            }

            UpdateEffectiveState(context);
        }
        #endregion

Usage Example

コード例 #1
0
ファイル: SourceState.cs プロジェクト: OPCFoundation/UA-.NET
        /// <summary>
        /// Called when the alarm is shelved.
        /// </summary>
        private ServiceResult OnTimedUnshelve(
            ISystemContext context,
            AlarmConditionState alarm)
        {
            // update the alarm state and produce and event.
            alarm.SetShelvingState(context, false, false, 0);
            alarm.Message.Value = "The timed shelving period expired.";

            UpdateAlarm(alarm, null);
            ReportChanges(alarm);

            return ServiceResult.Good;
        }
All Usage Examples Of Opc.Ua.AlarmConditionState::SetShelvingState