// Copyright (C) Stichting Deltares 2017. All rights reserved. // // This file is part of the Dam Engine. // // The Dam Engine is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . // // All names, logos, and references to "Deltares" are registered trademarks of // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. using System.Collections.Generic; using Deltares.DamEngine.Data.General; using Deltares.DamEngine.Data.Standard.Calculation; using Deltares.DamEngine.Io.XmlInput; namespace Deltares.DamEngine.Interface { public static class ConversionHelper { /// /// Converts the type DamProjectType from input object type to Dam Engine type. /// /// Type of the input object. /// Dam Engine type public static DamProjectType ConvertToDamProjectType(InputDamProjectType inputDamProjectType) { var translationTable = new Dictionary() { {InputDamProjectType.Assessment, DamProjectType.Assessment}, {InputDamProjectType.AssessmentRegional, DamProjectType.AssessmentRegional}, {InputDamProjectType.Design, DamProjectType.Design}, {InputDamProjectType.Operational, DamProjectType.Operational}, {InputDamProjectType.NWO, DamProjectType.NWO} }; return translationTable[inputDamProjectType]; } /// /// Converts the type DamProjectType from Dam Engine type to input object type. /// /// Type of the dam project. /// Type of the input object. public static InputDamProjectType ConvertToInputDamProjectType(DamProjectType damProjectType) { var translationTable = new Dictionary() { {DamProjectType.Assessment, InputDamProjectType.Assessment}, {DamProjectType.AssessmentRegional, InputDamProjectType.AssessmentRegional}, {DamProjectType.Design, InputDamProjectType.Design}, {DamProjectType.Operational, InputDamProjectType.Operational}, {DamProjectType.NWO, InputDamProjectType.NWO} }; return translationTable[damProjectType]; } /// /// Converts the type PLLineCreationMethod from Dam Engine type to input object type. /// /// Type of the dam project. /// /// Type of the input object. /// public static LocationWaternetOptionsPhreaticLineCreationMethod ConvertToInputPhreaticLineCreationMethod(PLLineCreationMethod plLineCreationMethod) { var translationTable = new Dictionary() { {PLLineCreationMethod.ExpertKnowledgeLinearInDike, LocationWaternetOptionsPhreaticLineCreationMethod.ExpertKnowledgeLinearInDike}, {PLLineCreationMethod.ExpertKnowledgeRRD, LocationWaternetOptionsPhreaticLineCreationMethod.ExpertKnowledgeRRD}, {PLLineCreationMethod.GaugesWithFallbackToExpertKnowledgeRRD, LocationWaternetOptionsPhreaticLineCreationMethod.GaugesWithFallbackToExpertKnowledgeRRD}, {PLLineCreationMethod.Sensors, LocationWaternetOptionsPhreaticLineCreationMethod.Sensors}, {PLLineCreationMethod.None, LocationWaternetOptionsPhreaticLineCreationMethod.None} }; return translationTable[plLineCreationMethod]; } /// /// Converts the type PLLineCreationMethod from input object type to Dam Engine type. /// /// Type of the input object. /// /// Type of the dam object. /// public static PLLineCreationMethod ConvertToPhreaticLineCreationMethod(LocationWaternetOptionsPhreaticLineCreationMethod inputPhreaticLineCreationMethod) { var translationTable = new Dictionary() { {LocationWaternetOptionsPhreaticLineCreationMethod.ExpertKnowledgeLinearInDike,PLLineCreationMethod.ExpertKnowledgeLinearInDike}, {LocationWaternetOptionsPhreaticLineCreationMethod.ExpertKnowledgeRRD, PLLineCreationMethod.ExpertKnowledgeRRD}, {LocationWaternetOptionsPhreaticLineCreationMethod.GaugesWithFallbackToExpertKnowledgeRRD, PLLineCreationMethod.GaugesWithFallbackToExpertKnowledgeRRD}, {LocationWaternetOptionsPhreaticLineCreationMethod.Sensors, PLLineCreationMethod.Sensors}, {LocationWaternetOptionsPhreaticLineCreationMethod.None, PLLineCreationMethod.None} }; return translationTable[inputPhreaticLineCreationMethod]; } /// /// Converts the type IntrusionVerticalWaterPressureType from Dam Engine type to input object type. /// /// Type of the dam project. /// /// Type of the input object. /// public static LocationWaternetOptionsIntrusionVerticalWaterPressure ConvertToInputIntrusionVerticalWaterPressure(IntrusionVerticalWaterPressureType intrusionVerticalWaterPressureType) { var translationTable = new Dictionary() { {IntrusionVerticalWaterPressureType.FullHydroStatic, LocationWaternetOptionsIntrusionVerticalWaterPressure.FullHydroStatic}, {IntrusionVerticalWaterPressureType.HydroStatic, LocationWaternetOptionsIntrusionVerticalWaterPressure.HydroStatic}, {IntrusionVerticalWaterPressureType.Linear, LocationWaternetOptionsIntrusionVerticalWaterPressure.Linear}, {IntrusionVerticalWaterPressureType.SemiTimeDependent, LocationWaternetOptionsIntrusionVerticalWaterPressure.SemiTimeDependent}, {IntrusionVerticalWaterPressureType.Standard, LocationWaternetOptionsIntrusionVerticalWaterPressure.Standard} }; return translationTable[intrusionVerticalWaterPressureType]; } /// /// Converts the type IntrusionVerticalWaterPressureType from input object type to Dam Engine type. /// /// Type of the input object. /// /// Type of the dam object. /// public static IntrusionVerticalWaterPressureType ConvertToIntrusionVerticalWaterPressure(LocationWaternetOptionsIntrusionVerticalWaterPressure inputIntrusionVerticalWaterPressure) { var translationTable = new Dictionary() { {LocationWaternetOptionsIntrusionVerticalWaterPressure.FullHydroStatic, IntrusionVerticalWaterPressureType.FullHydroStatic}, {LocationWaternetOptionsIntrusionVerticalWaterPressure.HydroStatic, IntrusionVerticalWaterPressureType.HydroStatic}, {LocationWaternetOptionsIntrusionVerticalWaterPressure.Linear, IntrusionVerticalWaterPressureType.Linear}, {LocationWaternetOptionsIntrusionVerticalWaterPressure.SemiTimeDependent, IntrusionVerticalWaterPressureType.SemiTimeDependent}, {LocationWaternetOptionsIntrusionVerticalWaterPressure.Standard, IntrusionVerticalWaterPressureType.Standard} }; return translationTable[inputIntrusionVerticalWaterPressure]; } public static int ConvertToOutputCalculationResult(CalculationResult damProjectType) { var translationTable = new Dictionary() { {CalculationResult.NoRun, 0}, {CalculationResult.Succeeded, 1}, {CalculationResult.NoInput, 2}, {CalculationResult.NoLicense, 3}, {CalculationResult.UserAbort, 4}, {CalculationResult.InvalidInputStructure, 5}, {CalculationResult.InvalidInputData, 6}, {CalculationResult.RunFailed, 7}, {CalculationResult.UnexpectedError, 8} }; return translationTable[damProjectType]; } } }