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