using System; using System.Collections.Generic; using Deltares.Dam.Data.Sensors.Specifications; using Deltares.Geotechnics; namespace Deltares.Dam.Data.Sensors { 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; } } }