Index: Ringtoets/Common/src/Ringtoets.Common.Service/Structures/StructuresCalculationServiceBase.cs =================================================================== diff -u -r470f6846d3dcd6f759a48d838cee8d1b9bbdeac7 -r058c36d676ce75456e648d75e460c24f0bc06ae7 --- Ringtoets/Common/src/Ringtoets.Common.Service/Structures/StructuresCalculationServiceBase.cs (.../StructuresCalculationServiceBase.cs) (revision 470f6846d3dcd6f759a48d838cee8d1b9bbdeac7) +++ Ringtoets/Common/src/Ringtoets.Common.Service/Structures/StructuresCalculationServiceBase.cs (.../StructuresCalculationServiceBase.cs) (revision 058c36d676ce75456e648d75e460c24f0bc06ae7) @@ -64,6 +64,7 @@ { private static readonly ILog log = LogManager.GetLogger(typeof(StructuresCalculationServiceBase)); + private readonly IStructuresCalculationMessageProvider messageProvider; private IStructuresCalculator calculator; @@ -165,22 +166,7 @@ var exceptionThrown = false; try { - calculator.Calculate(input); - - if (!canceled && string.IsNullOrEmpty(calculator.LastErrorFileContent)) - { - ProbabilityAssessmentOutput probabilityAssessmentOutput = - ProbabilityAssessmentService.Calculate(norm, - contribution, - lengthEffectN, - calculator.ExceedanceProbabilityBeta); - calculation.Output = new StructuresOutput(probabilityAssessmentOutput); - - if (calculation.InputParameters.ShouldIllustrationPointsBeCalculated) - { - SetIllustrationPointsResult(calculation.Output, calculator.IllustrationPointsResult); - } - } + PerformCalculation(calculation, lengthEffectN, norm, contribution, input); } catch (HydraRingCalculationException) { @@ -219,35 +205,6 @@ } /// - /// Sets a based on the information - /// of to the . - /// - /// The - /// for which to set the . - /// The to base the - /// to create on. - private void SetIllustrationPointsResult(StructuresOutput structuresOutput, - HydraRingGeneralResult hydraRingGeneralResult) - { - if (hydraRingGeneralResult == null) - { - log.Warn(calculator.IllustrationPointsParserErrorMessage); - return; - } - - try - { - GeneralResult generalResult = - GeneralResultConverter.CreateGeneralResultTopLevelFaultTreeIllustrationPoint(hydraRingGeneralResult); - structuresOutput.SetIllustrationPoints(generalResult); - } - catch (IllustrationPointConversionException e) - { - log.Warn(Resources.SetIllustrationPointsResult_Converting_IllustrationPointResult_Failed, e); - } - } - - /// /// Cancels any currently running structures calculation. /// public void Cancel() @@ -280,6 +237,81 @@ string hydraulicBoundaryDatabaseFilePath); /// + /// Performs a structures calculation. + /// + /// The structures calculation to use. + /// The 'N' parameter used to factor in the 'length effect'. + /// The norm used in the calculation. + /// The contribution used in the calculation. + /// The HydraRing calculation input used for the calculation. + /// Thrown when an error occurs while performing the calculation. + private void PerformCalculation(StructuresCalculation calculation, + double lengthEffectN, + double norm, + double contribution, + TCalculationInput calculationInput) + { + calculator.Calculate(calculationInput); + + if (canceled || !string.IsNullOrEmpty(calculator.LastErrorFileContent)) + { + return; + } + + ProbabilityAssessmentOutput probabilityAssessmentOutput = + ProbabilityAssessmentService.Calculate(norm, + contribution, + lengthEffectN, + calculator.ExceedanceProbabilityBeta); + SetOutput(calculation, probabilityAssessmentOutput); + } + + /// + /// Sets the calculated output to the calculation object. + /// + /// The calculation to set the output for. + /// The calculated output. + private void SetOutput(StructuresCalculation calculation, + ProbabilityAssessmentOutput probabilityAssessmentOutput) + { + calculation.Output = new StructuresOutput(probabilityAssessmentOutput); + + if (calculation.InputParameters.ShouldIllustrationPointsBeCalculated) + { + SetIllustrationPointsResult(calculation.Output, calculator.IllustrationPointsResult); + } + } + + /// + /// Sets a based on the information + /// of to the . + /// + /// The + /// for which to set the . + /// The to base the + /// to create on. + private void SetIllustrationPointsResult(StructuresOutput structuresOutput, + HydraRingGeneralResult hydraRingGeneralResult) + { + if (hydraRingGeneralResult == null) + { + log.Warn(calculator.IllustrationPointsParserErrorMessage); + return; + } + + try + { + GeneralResult generalResult = + GeneralResultConverter.CreateGeneralResultTopLevelFaultTreeIllustrationPoint(hydraRingGeneralResult); + structuresOutput.SetIllustrationPoints(generalResult); + } + catch (IllustrationPointConversionException e) + { + log.Warn(Resources.SetIllustrationPointsResult_Converting_IllustrationPointResult_Failed, e); + } + } + + /// /// Validates the input. /// /// The input of the calculation.