/// <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);
}
}
}