// Copyright (C) Stichting Deltares 2018. 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; using System.Collections.Generic; using Deltares.DamEngine.Data.General; using Deltares.DamEngine.Data.General.Sensors; using Deltares.DamEngine.Data.General.Sensors.Specifications; namespace Deltares.DamEngine.Calculators.PlLinesCreator { internal class SensorPlLine4Creator : SensorPlLine3Or4CreatorBase { public SensorPlLine4Creator(SensorLocation sensorLocation, IDictionary sensorValues) : base(sensorLocation, sensorValues, PlLineType.Pl4) { } /// /// Gets the start z level of the PL line /// /// /// The start level is based on the Pl4 configuration (locationdata or sensor) /// and the position of the first sensor /// /// protected override double GetStartLevel() { var locationAsDataSource = new UseLocationAsDataSource(); bool useLocationAsDataSource = locationAsDataSource.IsSatisfiedBy(SensorLocation.SourceTypePl4); if (useLocationAsDataSource) { if (!SensorLocation.HeadPl4.HasValue) throw new PlLinesCreatorException("Pl4 head has no value defined on this location"); return SensorLocation.HeadPl4.Value; } double level; try { level = WaterLevelAtRiver; } catch (Exception e) { throw new PlLinesCreatorException("There was an error trying to read the water level", e); } return level; } } }