/// <summary>
        /// Returns <see cref="NumericsSetting"/> based on the provided location id.
        /// </summary>
        /// <param name="locationId">The location id to obtain the <see cref="NumericsSetting"/> for.</param>
        /// <returns>A new <see cref="NumericsSetting"/> containing values corresponding to the provided location id.</returns>
        /// <exception cref="CriticalFileReadException">Thrown when a column that is being read doesn't
        /// contain expected type.</exception>
        public NumericsSetting GetNumericsSettingForPreprocessor(long locationId)
        {
            FailureMechanismDefaults failureMechanismDefaults = new FailureMechanismDefaultsProvider().GetFailureMechanismDefaults(HydraRingFailureMechanismType.AssessmentLevel);
            int       mechanismId = failureMechanismDefaults.MechanismId;
            const int preprocessorSubMechanismId = 7;
            const int defaultSubMechanismId      = 1;

            return(numericsSettingsReader.ReadNumericsSetting(locationId, mechanismId, preprocessorSubMechanismId)
                   ?? numericsSettingsReader.ReadNumericsSetting(locationId, mechanismId, defaultSubMechanismId)
                   ?? defaultNumericsSettings[HydraRingFailureMechanismType.AssessmentLevel][defaultSubMechanismId]);
        }
        /// <summary>
        /// Returns <see cref="NumericsSetting"/> based on the provided combination of failure mechanism type, sub mechanism id and location id.
        /// </summary>
        /// <param name="locationId">The location id to obtain the <see cref="NumericsSetting"/> for.</param>
        /// <param name="failureMechanismType">The <see cref="HydraRingFailureMechanismType"/> to obtain the <see cref="NumericsSetting"/> for.</param>
        /// <returns>A new <see cref="Dictionary{T, T}"/> where the key is the sub mechanism id, and the value is
        /// the <see cref="NumericsSetting"/> containing values corresponding to the provided failure mechanism type and location id.</returns>
        /// <exception cref="InvalidEnumArgumentException">Thrown when <paramref name="failureMechanismType"/> is not a valid
        /// <see cref="HydraRingFailureMechanismType"/> value.</exception>
        /// <exception cref="CriticalFileReadException">Thrown when a column that is being read doesn't
        /// contain expected type.</exception>
        public Dictionary <int, NumericsSetting> GetNumericsSettings(long locationId, HydraRingFailureMechanismType failureMechanismType)
        {
            FailureMechanismDefaults failureMechanismDefaults = new FailureMechanismDefaultsProvider().GetFailureMechanismDefaults(failureMechanismType);
            IEnumerable <int>        subMechanismIds          = failureMechanismDefaults.SubMechanismIds;
            int mechanismId = failureMechanismDefaults.MechanismId;

            var numericsSettings = new Dictionary <int, NumericsSetting>();

            foreach (int subMechanismId in subMechanismIds)
            {
                numericsSettings[subMechanismId] = numericsSettingsReader.ReadNumericsSetting(locationId, mechanismId, subMechanismId) ??
                                                   defaultNumericsSettings[failureMechanismType][subMechanismId];
            }

            return(numericsSettings);
        }
Exemple #3
0
        public void GetFailureMechanismDefaults_ReturnsExpectedFailureMechanismDefaults(HydraRingFailureMechanismType failureMechanismType,
                                                                                        int expectedMechanismId,
                                                                                        IEnumerable <int> expectedSubMechanismIds,
                                                                                        int expectedPreprocessorFaultTreeModelId,
                                                                                        int expectedPreprocessorMechanismId)
        {
            // Setup
            var failureMechanismDefaultsProvider = new FailureMechanismDefaultsProvider();

            // Call
            FailureMechanismDefaults failureMechanismDefaults = failureMechanismDefaultsProvider.GetFailureMechanismDefaults(failureMechanismType);

            // Assert
            Assert.AreEqual(expectedMechanismId, failureMechanismDefaults.MechanismId);
            Assert.AreEqual(expectedSubMechanismIds, failureMechanismDefaults.SubMechanismIds);
            Assert.AreEqual(expectedPreprocessorFaultTreeModelId, failureMechanismDefaults.PreprocessorFaultTreeModelId);
            Assert.AreEqual(expectedPreprocessorMechanismId, failureMechanismDefaults.PreprocessorMechanismId);
        }