예제 #1
0
        public void Clone_NotAllPropertiesSet_ReturnNewInstanceWithCopiedValues()
        {
            // Setup
            SemiProbabilisticPipingCalculation original = CreateRandomCalculationWithoutOutput();

            // Call
            object clone = original.Clone();

            // Assert
            CoreCloneAssert.AreObjectClones(original, clone, PipingCloneAssert.AreClones);
        }
        private static void AssertSemiProbabilisticPipingCalculationActivity(Activity activity,
                                                                             SemiProbabilisticPipingCalculation calculation,
                                                                             HydraulicBoundaryLocationCalculation hydraulicBoundaryLocationCalculation)
        {
            using (new PipingSubCalculatorFactoryConfig())
            {
                activity.Run();

                var testFactory = (TestPipingSubCalculatorFactory)PipingSubCalculatorFactory.Instance;
                Assert.AreEqual(calculation.InputParameters.ExitPointL, testFactory.LastCreatedEffectiveThicknessCalculator.ExitPointXCoordinate);
                Assert.AreEqual(hydraulicBoundaryLocationCalculation.Output.Result, testFactory.LastCreatedSellmeijerCalculator.HRiver);
            }
        }
        private static void LogAnyWarnings(SemiProbabilisticPipingCalculation calculation)
        {
            CalculationServiceHelper.LogMessagesAsWarning(PipingCalculationValidationHelper.GetValidationWarnings(calculation.InputParameters).ToArray());

            RoundedDouble diameter70Value = SemiProbabilisticPipingDesignVariableFactory.GetDiameter70(calculation.InputParameters).GetDesignValue();

            if (!double.IsNaN(diameter70Value) && (diameter70Value < 6.3e-5 || diameter70Value > 0.5e-3))
            {
                CalculationServiceHelper.LogMessagesAsWarning(new[]
                {
                    string.Format(Resources.SemiProbabilisticPipingCalculationService_GetInputWarnings_Specified_DiameterD70_value_0_not_in_valid_range_of_model, diameter70Value)
                });
            }
        }
예제 #4
0
        /// <summary>
        /// Creates a new instance of <see cref="SemiProbabilisticPipingCalculationActivity"/>.
        /// </summary>
        /// <param name="calculation">The <see cref="SemiProbabilisticPipingCalculation"/> to perform.</param>
        /// <param name="generalPipingInput">The <see cref="GeneralPipingInput"/> to use during the calculation.</param>
        /// <param name="normativeAssessmentLevel">The normative assessment level to use in case the manual assessment level is not applicable.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="calculation"/> or <paramref name="generalPipingInput"/>
        /// is <c>null</c>.</exception>
        public SemiProbabilisticPipingCalculationActivity(SemiProbabilisticPipingCalculation calculation,
                                                          GeneralPipingInput generalPipingInput,
                                                          RoundedDouble normativeAssessmentLevel)
            : base(calculation)
        {
            if (generalPipingInput == null)
            {
                throw new ArgumentNullException(nameof(generalPipingInput));
            }

            this.calculation              = calculation;
            this.generalPipingInput       = generalPipingInput;
            this.normativeAssessmentLevel = normativeAssessmentLevel;

            Description = string.Format(RiskeerCommonServiceResources.Perform_calculation_with_name_0_, calculation.Name);
        }
        /// <summary>
        /// Performs a piping calculation based on the supplied <see cref="SemiProbabilisticPipingCalculation"/> and sets
        /// <see cref="SemiProbabilisticPipingCalculation.Output"/> if the calculation was successful. Error and status
        /// information is logged during the execution of the operation.
        /// </summary>
        /// <param name="calculation">The <see cref="SemiProbabilisticPipingCalculation"/> to base the input for the calculation upon.</param>
        /// <param name="generalInput">The <see cref="GeneralPipingInput"/> to derive values from during the calculation.</param>
        /// <param name="normativeAssessmentLevel">The normative assessment level to use in case the manual assessment level is not applicable.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="calculation"/> or <paramref name="generalInput"/> is <c>null</c>.</exception>
        /// <exception cref="PipingCalculatorException">Thrown when an unexpected error occurred during the calculation.</exception>
        /// <remarks>Consider calling <see cref="Validate"/> first to see if calculation is possible.</remarks>
        public static void Calculate(SemiProbabilisticPipingCalculation calculation,
                                     GeneralPipingInput generalInput,
                                     RoundedDouble normativeAssessmentLevel)
        {
            if (calculation == null)
            {
                throw new ArgumentNullException(nameof(calculation));
            }

            if (generalInput == null)
            {
                throw new ArgumentNullException(nameof(generalInput));
            }

            CalculationServiceHelper.LogCalculationBegin();

            try
            {
                PipingCalculatorResult pipingResult = new PipingCalculator(CreateInputFromData(calculation.InputParameters,
                                                                                               generalInput,
                                                                                               normativeAssessmentLevel),
                                                                           PipingSubCalculatorFactory.Instance).Calculate();

                calculation.Output = new SemiProbabilisticPipingOutput(new SemiProbabilisticPipingOutput.ConstructionProperties
                {
                    UpliftFactorOfSafety       = pipingResult.UpliftFactorOfSafety,
                    HeaveFactorOfSafety        = pipingResult.HeaveFactorOfSafety,
                    SellmeijerFactorOfSafety   = pipingResult.SellmeijerFactorOfSafety,
                    UpliftEffectiveStress      = pipingResult.UpliftEffectiveStress,
                    HeaveGradient              = pipingResult.HeaveGradient,
                    SellmeijerCreepCoefficient = pipingResult.SellmeijerCreepCoefficient,
                    SellmeijerCriticalFall     = pipingResult.SellmeijerCriticalFall,
                    SellmeijerReducedFall      = pipingResult.SellmeijerReducedFall
                });
            }
            catch (PipingCalculatorException e)
            {
                CalculationServiceHelper.LogExceptionAsError(RiskeerCommonServiceResources.CalculationService_Calculate_unexpected_error, e);

                throw;
            }
            finally
            {
                CalculationServiceHelper.LogCalculationEnd();
            }
        }
        private static bool LogAnyErrors(SemiProbabilisticPipingCalculation calculation, GeneralPipingInput generalInput, RoundedDouble normativeAssessmentLevel)
        {
            string[] messages = ValidateInput(calculation.InputParameters, generalInput, normativeAssessmentLevel).ToArray();

            if (messages.Length > 0)
            {
                CalculationServiceHelper.LogMessagesAsError(messages);
                return(true);
            }

            messages = new PipingCalculator(CreateInputFromData(calculation.InputParameters, generalInput, normativeAssessmentLevel),
                                            PipingSubCalculatorFactory.Instance).Validate().ToArray();

            if (messages.Length > 0)
            {
                CalculationServiceHelper.LogMessagesAsError(messages);
                return(true);
            }

            return(false);
        }
        /// <summary>
        /// Performs validation over the values on the given <paramref name="calculation"/>. Error and status information is logged during
        /// the execution of the operation.
        /// </summary>
        /// <param name="calculation">The <see cref="SemiProbabilisticPipingCalculation"/> for which to validate the values.</param>
        /// <param name="generalInput">The <see cref="GeneralPipingInput"/> to derive values from during the validation.</param>
        /// <param name="normativeAssessmentLevel">The normative assessment level to use in case the manual assessment level is not applicable.</param>
        /// <returns><c>false</c> if <paramref name="calculation"/> contains validation errors; <c>true</c> otherwise.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="calculation"/> or <paramref name="generalInput"/> is <c>null</c>.</exception>
        public static bool Validate(SemiProbabilisticPipingCalculation calculation,
                                    GeneralPipingInput generalInput,
                                    RoundedDouble normativeAssessmentLevel)
        {
            if (calculation == null)
            {
                throw new ArgumentNullException(nameof(calculation));
            }

            if (generalInput == null)
            {
                throw new ArgumentNullException(nameof(generalInput));
            }

            CalculationServiceHelper.LogValidationBegin();

            LogAnyWarnings(calculation);

            bool hasErrors = LogAnyErrors(calculation, generalInput, normativeAssessmentLevel);

            CalculationServiceHelper.LogValidationEnd();

            return(!hasErrors);
        }
        /// <summary>
        /// Creates a <see cref="CalculatableActivity"/> based on the given <paramref name="calculation"/>.
        /// </summary>
        /// <param name="calculation">The calculation to create an activity for.</param>
        /// <param name="generalPipingInput">The general piping input that is used during the calculation.</param>
        /// <param name="assessmentSection">The assessment section the <paramref name="calculation"/> belongs to.</param>
        /// <returns>A <see cref="CalculatableActivity"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        public static CalculatableActivity CreateSemiProbabilisticPipingCalculationActivity(SemiProbabilisticPipingCalculation calculation,
                                                                                            GeneralPipingInput generalPipingInput,
                                                                                            IAssessmentSection assessmentSection)
        {
            if (calculation == null)
            {
                throw new ArgumentNullException(nameof(calculation));
            }

            if (generalPipingInput == null)
            {
                throw new ArgumentNullException(nameof(generalPipingInput));
            }

            if (assessmentSection == null)
            {
                throw new ArgumentNullException(nameof(assessmentSection));
            }

            return(new SemiProbabilisticPipingCalculationActivity(calculation,
                                                                  generalPipingInput,
                                                                  assessmentSection.GetNormativeAssessmentLevel(calculation.InputParameters.HydraulicBoundaryLocation)));
        }
예제 #9
0
 /// <summary>
 /// Method that asserts whether <paramref name="original"/> and <paramref name="clone"/>
 /// are clones.
 /// </summary>
 /// <param name="original">The original object.</param>
 /// <param name="clone">The cloned object.</param>
 /// <exception cref="AssertionException">Thrown when <paramref name="original"/> and
 /// <paramref name="clone"/> are not clones.</exception>
 public static void AreClones(SemiProbabilisticPipingCalculation original, SemiProbabilisticPipingCalculation clone)
 {
     CommonCloneAssert.AreClones(original, clone);
     CoreCloneAssert.AreObjectClones(original.InputParameters, clone.InputParameters, AreClones);
     CoreCloneAssert.AreObjectClones(original.Output, clone.Output, AreClones);
 }