Opc.Ua.ConditionState.ReportStateChange C# (CSharp) Method

ReportStateChange() protected method

Reports the state change for the condition.
protected ReportStateChange ( ISystemContext context, bool ignoreDisabledState ) : void
context ISystemContext The context.
ignoreDisabledState bool if set to true the event is reported event if the condition is in the disabled state.
return void
        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);
                }
            }
        }

Usage Example

コード例 #1
0
        /// <summary>
        /// Create a branch based off the original Event
        /// </summary>
        /// <param name="context">The system context.</param>
        /// <param name="branchId">The Desired Branch Id</param>
        /// <returns>ConditionState newly created branch</returns>
        public virtual ConditionState CreateBranch(ISystemContext context, NodeId branchId)
        {
            ConditionState state = null;

            Type   alarmType     = this.GetType();
            object branchedAlarm = Activator.CreateInstance(alarmType, this);

            if (branchedAlarm != null)
            {
                ConditionState branchedNodeState = (ConditionState)branchedAlarm;
                branchedNodeState.Initialize(context, this);
                branchedNodeState.BranchId.Value         = branchId;
                branchedNodeState.AutoReportStateChanges = AutoReportStateChanges;
                branchedNodeState.ReportStateChange(context, false);

                string postEventId = Utils.ToHexString(branchedNodeState.EventId.Value as byte[]);

                Dictionary <string, ConditionState> branches = GetBranches();

                branches.Add(postEventId, branchedNodeState);

                state = branchedNodeState;
            }

            return(state);
        }