A lightweight snapshot of an instance node.
Inheritance: IFilterTarget
Exemplo n.º 1
0
        /// <summary>
        /// Reports the state change for the condition.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="ignoreDisabledState">if set to <c>true</c> the event is reported event if the condition is in the disabled state.</param>
        protected void ReportStateChange(ISystemContext context, bool ignoreDisabledState)
        {
            // check the disabled state.
            if (!ignoreDisabledState && !this.EnabledState.Id.Value)
            {
                return;
            }

            if (AutoReportStateChanges)
            {
                // create a new event instance.
                this.EventId.Value     = Guid.NewGuid().ToByteArray();
                this.Time.Value        = DateTime.UtcNow;
                this.ReceiveTime.Value = this.Time.Value;

                ClearChangeMasks(context, includeChildren: true);

                // report a state change event.
                if (EventsMonitored())
                {
                    InstanceStateSnapshot snapshot = new InstanceStateSnapshot();
                    snapshot.Initialize(context, this);
                    ReportEvent(context, snapshot);
                }
            }
        }
        /// <summary>
        /// Reports the state change for the condition.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="ignoreDisabledState">if set to <c>true</c> the event is reported event if the condition is in the disabled state.</param>
        protected void ReportStateChange(ISystemContext context, bool ignoreDisabledState)
        {
            // check the disabled state.
            if (!ignoreDisabledState && !this.EnabledState.Id.Value)
            {
                return;
            }
                   
            if (AutoReportStateChanges)
            {
                // create a new event instance.
                this.EventId.Value = Guid.NewGuid().ToByteArray();
                this.Time.Value = DateTime.UtcNow;
                this.ReceiveTime.Value = this.Time.Value;

                // report a state change event.
                if (this.AreEventsMonitored)
                {
                    InstanceStateSnapshot snapshot = new InstanceStateSnapshot();
                    snapshot.Initialize(context, this);
                    ReportEvent(context, snapshot);
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Returns the last event produced for any conditions belonging to the node or its chilren.
        /// </summary>
        /// <param name="context">The system context.</param>
        /// <param name="events">The list of condition events to return.</param>
        /// <param name="includeChildren">Whether to recursively report events for the children.</param>
        public override void ConditionRefresh(ISystemContext context, List<IFilterTarget> events, bool includeChildren)
        {
            // need to check if this source has already been processed during this refresh operation.
            for (int ii = 0; ii < events.Count; ii++)
            {
                InstanceStateSnapshot e = events[ii] as InstanceStateSnapshot;

                if (e != null && Object.ReferenceEquals(e.Handle, this))
                {
                    return;
                }
            }

            // report the dialog.
            if (m_dialog != null)
            {
                // do not refresh dialogs that are not active.
                if (m_dialog.Retain.Value)
                {
                    // create a snapshot.
                    InstanceStateSnapshot e = new InstanceStateSnapshot();
                    e.Initialize(context, m_dialog);

                    // set the handle of the snapshot to check for duplicates.
                    e.Handle = this;

                    events.Add(e);
                }
            }

            // the alarm objects act as a cache for the last known state and are used to generate refresh events.
            foreach (AlarmConditionState alarm in m_alarms.Values)
            {
                // do not refresh alarms that are not in an interesting state.
                if (!alarm.Retain.Value)
                {
                    continue;
                }

                // create a snapshot.
                InstanceStateSnapshot e = new InstanceStateSnapshot();
                e.Initialize(context, alarm);

                // set the handle of the snapshot to check for duplicates.
                e.Handle = this;

                events.Add(e);
            }

            // report any active branches.
            foreach (AlarmConditionState alarm in m_branches.Values)
            {
                // create a snapshot.
                InstanceStateSnapshot e = new InstanceStateSnapshot();
                e.Initialize(context, alarm);

                // set the handle of the snapshot to check for duplicates.
                e.Handle = this;

                events.Add(e);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Reports the changes to the alarm.
        /// </summary>
        private void ReportChanges(AlarmConditionState alarm)
        {
            // report changes to node attributes.
            alarm.ClearChangeMasks(m_nodeManager.SystemContext, true);

            // check if events are being monitored for the source.
            if (this.AreEventsMonitored)
            {
                // create a snapshot.
                InstanceStateSnapshot e = new InstanceStateSnapshot();
                e.Initialize(m_nodeManager.SystemContext, alarm);

                // report the event.
                alarm.ReportEvent(m_nodeManager.SystemContext, e);
            }
        }