/// <summary> /// Determine the worst violation of a collection /// </summary> /// <param name="InViolations"></param> /// <returns></returns> public static MM_AlarmViolation_Type WorstViolation(params MM_AlarmViolation_Type[] InViolations) { MM_AlarmViolation_Type OutViol = null; foreach (MM_AlarmViolation_Type Viol in InViolations) { if (Viol == null) { } else if (OutViol == null) { OutViol = Viol; } else if (OutViol.Priority < Viol.Priority) { OutViol = Viol; } } return(OutViol); }
/// <summary> /// Create a new violation /// </summary> /// <param name="ViolatedElement"></param> /// <param name="ViolText"></param> /// <param name="ViolType"></param> /// <param name="EventTime"></param> /// <param name="New"></param> /// <param name="ViolatedCtg"></param> /// <param name="PostCtgValue"></param> /// <param name="PreCtgValue"></param> /// <returns></returns> public static MM_AlarmViolation CreateViolation(MM_Element ViolatedElement, string ViolText, MM_AlarmViolation_Type ViolType, DateTime EventTime, bool New, MM_Contingency ViolatedCtg, float PreCtgValue, float PostCtgValue) { MM_AlarmViolation NewViol = new MM_AlarmViolation(); NewViol.TEID = Integration.Data_Integration.GetTEID(); NewViol.ViolatedElement = ViolatedElement; if (ViolatedElement is MM_Transformer) { NewViol.KVLevel = (ViolatedElement as MM_Transformer).Winding1.KVLevel; } else { NewViol.KVLevel = ViolatedElement.KVLevel; } NewViol.ElemType = ViolatedElement.ElemType; NewViol.Owner = ViolatedElement.Owner; NewViol.Operator = ViolatedElement.Operator; NewViol.Contingency = ViolatedCtg; NewViol.New = New; NewViol.Text = ViolText; NewViol.Type = ViolType; NewViol.EventTime = EventTime; NewViol.PreCtgValue = PreCtgValue; NewViol.PostCtgValue = PostCtgValue; return(NewViol); }