public double GetBaseFailureRateForScope(String scope) { // Since the Base Failure Rate does not change during the lifetime of a part // we cache that data internally so as to not have to call the Reliability module // constantly. Therefore here we are returning what we have if we have it, // or else getting it from the Reliability module and caching that for next time. scope = scope.ToLower().Trim(); // LogFormatted_DebugOnly(String.Format("TestFlightCore: GetBaseFailureRateForScope({0})",scope)); if (baseFailureRate == null) { // LogFormatted_DebugOnly("BaseFailureRate data is invalid"); return(TestFlightUtil.MIN_FAILURE_RATE); } if (baseFlightData == null) { // LogFormatted_DebugOnly("baseFlightData is invalid"); return(TestFlightUtil.MIN_FAILURE_RATE); } if (baseFailureRate.ContainsKey(scope)) { // LogFormatted_DebugOnly("TestFlightCore: Returning cached Base Failure Rate"); return(baseFailureRate[scope]); } else { // LogFormatted_DebugOnly("TestFlightCore: Calculating Base Failure Rate from Reliability modules"); double totalBFR = 0; double data = 0; FlightDataBody body = baseFlightData.GetFlightData(scope); if (body != null) { data = body.flightData; } List <ITestFlightReliability> reliabilityModules = TestFlightUtil.GetReliabilityModules(this.part); if (reliabilityModules == null) { return(TestFlightUtil.MIN_FAILURE_RATE); } foreach (ITestFlightReliability rm in reliabilityModules) { totalBFR += rm.GetBaseFailureRateForScope(data, scope); } totalBFR = Mathf.Max((float)totalBFR, (float)TestFlightUtil.MIN_FAILURE_RATE); baseFailureRate.Add(scope, totalBFR); return(totalBFR); } }
public double GetFlightDataForScope(String scope) { if (flightData == null) { Log("FlightData is invalid"); return(0); } FlightDataBody dataBody = flightData.GetFlightData(scope); if (dataBody == null) { return(0); } else { return(dataBody.flightData); } }