/// <summary>Execute action, returns true if the link was alterated.</summary> public bool Execute(EpanetNetwork net, TraceSource log, double tol, long htime) { bool flag = false; StatType s = _link.SimStatus; double v = _link.SimSetting; double x = _setting; if (_status == Values.IS_OPEN && s <= StatType.CLOSED) { // Switch link from closed to open _link.SetLinkStatus(true); flag = true; } else if (_status == Values.IS_CLOSED && s > StatType.CLOSED) { // Switch link from not closed to closed _link.SetLinkStatus(false); flag = true; } else if (!double.IsNaN(x)) { // Change link's setting switch (_link.Type) { case LinkType.PRV: case LinkType.PSV: case LinkType.PBV: x /= net.FieldsMap.GetUnits(FieldType.PRESSURE); break; case LinkType.FCV: x /= net.FieldsMap.GetUnits(FieldType.FLOW); break; } if (Math.Abs(x - v) > tol) { _link.SetLinkSetting(x); flag = true; } } if (flag) { if (net.StatFlag > 0) // Report rule action { LogRuleExecution(log, htime); } return(true); } return(false); }