Index: DamEngine/trunk/src/Deltares.DamEngine.Interface.Tests/FillDamFromXmlInputTests.cs =================================================================== diff -u -r1558 -r1620 --- DamEngine/trunk/src/Deltares.DamEngine.Interface.Tests/FillDamFromXmlInputTests.cs (.../FillDamFromXmlInputTests.cs) (revision 1558) +++ DamEngine/trunk/src/Deltares.DamEngine.Interface.Tests/FillDamFromXmlInputTests.cs (.../FillDamFromXmlInputTests.cs) (revision 1620) @@ -24,6 +24,7 @@ using System.IO; using Deltares.DamEngine.Data.Design; using Deltares.DamEngine.Data.General; +using Deltares.DamEngine.Data.General.Sensors; using Deltares.DamEngine.Data.General.TimeSeries; using Deltares.DamEngine.Data.Geometry; using Deltares.DamEngine.Data.Geotechnics; @@ -32,6 +33,9 @@ using KellermanSoftware.CompareNetObjects; using NUnit.Framework; using Segment = Deltares.DamEngine.Data.General.Segment; +using Sensor = Deltares.DamEngine.Data.General.Sensors.Sensor; +using SensorGroup = Deltares.DamEngine.Data.General.Sensors.SensorGroup; +using SensorLocation = Deltares.DamEngine.Data.General.Sensors.SensorLocation; using Soil = Deltares.DamEngine.Data.Geotechnics.Soil; using SoilProfile1D = Deltares.DamEngine.Data.Geotechnics.SoilProfile1D; using SoilProfile2D = Deltares.DamEngine.Data.Geotechnics.SoilProfile2D; @@ -123,10 +127,84 @@ FillSegments(damProjectData); FillLocations(dike, damProjectData.Segments, damProjectData.ProjectPath); FillInputTimeSeries(dike); + FillSensorData(damProjectData); + return damProjectData; } + private void FillSensorData(DamProjectData damProjectData) + { + damProjectData.SensorData = new SensorData(); // SensorLocations, Sensors and SensorGroups are automatically created + var sensorData = damProjectData.SensorData; + var sensor1 = new Sensor() + { + ID = 1, + RelativeLocation = 12.2, + SensorType = SensorType.WaterLevel, + PlLineMappings = new[] { PlLineType.Pl1 } + }; + sensorData.Sensors.Add(sensor1); + var sensor2 = new Sensor() + { + ID = 2, + RelativeLocation = 24.2, + SensorType = SensorType.PolderLevel, + PlLineMappings = new [] { PlLineType .Pl1} + }; + sensorData.Sensors.Add(sensor2); + var sensorGroup1 = new SensorGroup() + { + ID = 1, + SensorArray = new Sensor[] { sensor1, sensor2 } + }; + sensorData.SensorGroups.Add(sensorGroup1); + var sensorLocation1 = new SensorLocation() + { + Location = damProjectData.Dike.Locations[0], + SensorGroup = sensorGroup1, + SourceTypePl1PlLineOffsetBelowDikeTopAtRiver = DataSourceTypeSensors.LocationData, + SourceTypePl1PlLineOffsetBelowDikeTopAtPolder = DataSourceTypeSensors.LocationData, + SourceTypePl1WaterLevelAtPolder = DataSourceTypeSensors.Sensor, + SourceTypePl1WaterLevelAtRiver = DataSourceTypeSensors.Sensor, + SourceTypePl3 = DataSourceTypeSensors.Sensor, + SourceTypePl4 = DataSourceTypeSensors.Sensor, + SourceTypePl1PlLineOffsetBelowDikeToeAtPolder = DataSourceTypeSensors.LocationData, + SourceTypePl1PlLineOffsetBelowShoulderBaseInside = DataSourceTypeSensors.LocationData + }; + damProjectData.Dike.Locations[0].SensorLocation = sensorLocation1; + sensorData.SensorLocations.Add(sensorLocation1); + var sensor3 = new Sensor() + { + ID = 3, + RelativeLocation = 8.8, + SensorType = SensorType.PiezometricHead, + PlLineMappings = new [] { PlLineType.Pl3, PlLineType.Pl4} + }; + sensorData.Sensors.Add(sensor3); + var sensorGroup2 = new SensorGroup() + { + ID = 2, + SensorArray = new Sensor[] { sensor3 } + }; + sensorData.SensorGroups.Add(sensorGroup2); + var sensorLocation2 = new SensorLocation() + { + Location = damProjectData.Dike.Locations[0], + SensorGroup = sensorGroup1, + SourceTypePl1PlLineOffsetBelowDikeTopAtRiver = DataSourceTypeSensors.LocationData, + SourceTypePl1PlLineOffsetBelowDikeTopAtPolder = DataSourceTypeSensors.LocationData, + SourceTypePl1WaterLevelAtPolder = DataSourceTypeSensors.Sensor, + SourceTypePl1WaterLevelAtRiver = DataSourceTypeSensors.Sensor, + SourceTypePl3 = DataSourceTypeSensors.Sensor, + SourceTypePl4 = DataSourceTypeSensors.Sensor, + SourceTypePl1PlLineOffsetBelowDikeToeAtPolder = DataSourceTypeSensors.LocationData, + SourceTypePl1PlLineOffsetBelowShoulderBaseInside = DataSourceTypeSensors.LocationData + }; + damProjectData.Dike.Locations[2].SensorLocation = sensorLocation2; + sensorData.SensorLocations.Add(sensorLocation2); + } + private void FillInputTimeSeries(Dike dike) { const int timeSeriesCount = 2; Index: DamEngine/trunk/src/Deltares.DamEngine.Interface/FillDamFromXmlInput.cs =================================================================== diff -u -r1565 -r1620 --- DamEngine/trunk/src/Deltares.DamEngine.Interface/FillDamFromXmlInput.cs (.../FillDamFromXmlInput.cs) (revision 1565) +++ DamEngine/trunk/src/Deltares.DamEngine.Interface/FillDamFromXmlInput.cs (.../FillDamFromXmlInput.cs) (revision 1620) @@ -25,6 +25,7 @@ using System.Linq; using Deltares.DamEngine.Data.Design; using Deltares.DamEngine.Data.General; +using Deltares.DamEngine.Data.General.Sensors; using Deltares.DamEngine.Data.General.TimeSeries; using Deltares.DamEngine.Data.Geometry; using Deltares.DamEngine.Data.Geotechnics; @@ -86,11 +87,70 @@ dike.InputTimeSerieCollection = new TimeSerieCollection(); TransferInputTimeSeries(input.OperationalInputTimeSeries, dike.InputTimeSerieCollection); } + if (input.SensorData != null) + { + damProjectData.SensorData = new SensorData(); + TransferSensorData(input.SensorData, damProjectData.SensorData, damProjectData.Dike.Locations); + } + PostProcess(damProjectData); return damProjectData; } + private static void TransferSensorData(InputSensorData inputSensorData, SensorData sensorData, IList locations) + { + // Transfer sensors + foreach (var inputSensor in inputSensorData.Sensors) + { + var plLineMappings = new PlLineType[inputSensor.PlLineMapping.Length]; + int plLineMappingIndex = 0; + foreach (var plLineMapping in inputSensor.PlLineMapping) + { + plLineMappings[plLineMappingIndex] = ConversionHelper.ConvertToPlLineType(plLineMapping.PLineType); + plLineMappingIndex++; + } + sensorData.Sensors.Add(new Data.General.Sensors.Sensor() + { + ID = inputSensor.Id, + RelativeLocation = inputSensor.RelativeLocation, + SensorType = ConversionHelper.ConvertToSensorType(inputSensor.SensorType), + PlLineMappings = plLineMappings + }); + } + + // Transfer sensorgroups + foreach (var inputSensorGroup in inputSensorData.SensorGroups) + { + var sensorGroup = new Data.General.Sensors.SensorGroup(); + sensorGroup.ID = inputSensorGroup.Id; + foreach (var sensorId in inputSensorGroup.SensorIds) + { + var sensor = sensorData.Sensors.First(s => s.ID.Equals(sensorId.SensorId)); + sensorGroup.Add(sensor); + } + sensorData.SensorGroups.Add(sensorGroup); + } + + // Transfer sensorlocations + foreach (var inputSensorLocation in inputSensorData.SensorLocations) + { + var sensorLocation = new Data.General.Sensors.SensorLocation(); + sensorLocation.Location = locations.First(l => l.Name.Equals(inputSensorLocation.LocationId)); + sensorLocation.Location.SensorLocation = sensorLocation; + sensorLocation.SensorGroup = sensorData.SensorGroups.First(sg => sg.ID.Equals(inputSensorLocation.GroupId)); + sensorLocation.SourceTypePl1PlLineOffsetBelowDikeTopAtPolder = ConversionHelper.ConvertToDataSourceTypeSensors(inputSensorLocation.SourceTypePl1PlLineOffsetBelowDikeTopAtPolder); + sensorLocation.SourceTypePl1PlLineOffsetBelowDikeToeAtPolder = ConversionHelper.ConvertToDataSourceTypeSensors(inputSensorLocation.SourceTypePl1PlLineOffsetBelowDikeToeAtPolder); + sensorLocation.SourceTypePl1PlLineOffsetBelowDikeTopAtRiver = ConversionHelper.ConvertToDataSourceTypeSensors(inputSensorLocation.SourceTypePl1PlLineOffsetBelowDikeTopAtRiver); + sensorLocation.SourceTypePl1PlLineOffsetBelowShoulderBaseInside = ConversionHelper.ConvertToDataSourceTypeSensors(inputSensorLocation.SourceTypePl1PlLineOffsetBelowShoulderBaseInside); + sensorLocation.SourceTypePl1WaterLevelAtPolder = ConversionHelper.ConvertToDataSourceTypeSensors(inputSensorLocation.SourceTypePl1WaterLevelAtPolder); + sensorLocation.SourceTypePl1WaterLevelAtRiver = ConversionHelper.ConvertToDataSourceTypeSensors(inputSensorLocation.SourceTypePl1WaterLevelAtRiver); + sensorLocation.SourceTypePl3 = ConversionHelper.ConvertToDataSourceTypeSensors(inputSensorLocation.SourceTypePl3); + sensorLocation.SourceTypePl4 = ConversionHelper.ConvertToDataSourceTypeSensors(inputSensorLocation.SourceTypePl4); + sensorData.SensorLocations.Add(sensorLocation); + } + } + private static void TransferInputTimeSeries(TimeSerie[] inputOperationalInputTimeSeries, TimeSerieCollection timeSerieCollection) { foreach (var inputTimeSerie in inputOperationalInputTimeSeries) Index: DamEngine/trunk/xsd/DamSensor.xsd =================================================================== diff -u -r1611 -r1620 --- DamEngine/trunk/xsd/DamSensor.xsd (.../DamSensor.xsd) (revision 1611) +++ DamEngine/trunk/xsd/DamSensor.xsd (.../DamSensor.xsd) (revision 1620) @@ -7,7 +7,7 @@ - + @@ -28,7 +28,7 @@ - + Index: DamEngine/trunk/src/Deltares.DamEngine.Io/DamInput.cs =================================================================== diff -u -r1605 -r1620 --- DamEngine/trunk/src/Deltares.DamEngine.Io/DamInput.cs (.../DamInput.cs) (revision 1605) +++ DamEngine/trunk/src/Deltares.DamEngine.Io/DamInput.cs (.../DamInput.cs) (revision 1620) @@ -631,8 +631,6 @@ private int idField; - private bool idFieldSpecified; - /// [System.Xml.Serialization.XmlElementAttribute("SensorIds")] public SensorGroupSensorIds[] SensorIds { @@ -654,17 +652,6 @@ this.idField = value; } } - - /// - [System.Xml.Serialization.XmlIgnoreAttribute()] - public bool IdSpecified { - get { - return this.idFieldSpecified; - } - set { - this.idFieldSpecified = value; - } - } } /// @@ -698,21 +685,21 @@ private string locationIdField; - private int sourceTypePl1WaterLevelAtRiverField; + private uint sourceTypePl1WaterLevelAtRiverField; - private int sourceTypePl1PlLineOffsetBelowDikeTopAtRiverField; + private uint sourceTypePl1PlLineOffsetBelowDikeTopAtRiverField; - private int sourceTypePl1PlLineOffsetBelowDikeTopAtPolderField; + private uint sourceTypePl1PlLineOffsetBelowDikeTopAtPolderField; - private int sourceTypePl1PlLineOffsetBelowShoulderBaseInsideField; + private uint sourceTypePl1PlLineOffsetBelowShoulderBaseInsideField; - private int sourceTypePl1PlLineOffsetBelowDikeToeAtPolderField; + private uint sourceTypePl1PlLineOffsetBelowDikeToeAtPolderField; - private int sourceTypePl1WaterLevelAtPolderField; + private uint sourceTypePl1WaterLevelAtPolderField; - private int sourceTypePl3Field; + private uint sourceTypePl3Field; - private int sourceTypePl4Field; + private uint sourceTypePl4Field; private int groupIdField; @@ -729,7 +716,7 @@ /// [System.Xml.Serialization.XmlAttributeAttribute()] - public int SourceTypePl1WaterLevelAtRiver { + public uint SourceTypePl1WaterLevelAtRiver { get { return this.sourceTypePl1WaterLevelAtRiverField; } @@ -740,7 +727,7 @@ /// [System.Xml.Serialization.XmlAttributeAttribute()] - public int SourceTypePl1PlLineOffsetBelowDikeTopAtRiver { + public uint SourceTypePl1PlLineOffsetBelowDikeTopAtRiver { get { return this.sourceTypePl1PlLineOffsetBelowDikeTopAtRiverField; } @@ -751,7 +738,7 @@ /// [System.Xml.Serialization.XmlAttributeAttribute()] - public int SourceTypePl1PlLineOffsetBelowDikeTopAtPolder { + public uint SourceTypePl1PlLineOffsetBelowDikeTopAtPolder { get { return this.sourceTypePl1PlLineOffsetBelowDikeTopAtPolderField; } @@ -762,7 +749,7 @@ /// [System.Xml.Serialization.XmlAttributeAttribute()] - public int SourceTypePl1PlLineOffsetBelowShoulderBaseInside { + public uint SourceTypePl1PlLineOffsetBelowShoulderBaseInside { get { return this.sourceTypePl1PlLineOffsetBelowShoulderBaseInsideField; } @@ -773,7 +760,7 @@ /// [System.Xml.Serialization.XmlAttributeAttribute()] - public int SourceTypePl1PlLineOffsetBelowDikeToeAtPolder { + public uint SourceTypePl1PlLineOffsetBelowDikeToeAtPolder { get { return this.sourceTypePl1PlLineOffsetBelowDikeToeAtPolderField; } @@ -784,7 +771,7 @@ /// [System.Xml.Serialization.XmlAttributeAttribute()] - public int SourceTypePl1WaterLevelAtPolder { + public uint SourceTypePl1WaterLevelAtPolder { get { return this.sourceTypePl1WaterLevelAtPolderField; } @@ -795,7 +782,7 @@ /// [System.Xml.Serialization.XmlAttributeAttribute()] - public int SourceTypePl3 { + public uint SourceTypePl3 { get { return this.sourceTypePl3Field; } @@ -806,7 +793,7 @@ /// [System.Xml.Serialization.XmlAttributeAttribute()] - public int SourceTypePl4 { + public uint SourceTypePl4 { get { return this.sourceTypePl4Field; } @@ -840,12 +827,8 @@ private double relativeLocationField; - private int sensorTypeField; + private uint sensorTypeField; - private int plLineTypeField; - - private bool plLineTypeFieldSpecified; - /// [System.Xml.Serialization.XmlElementAttribute("PlLineMapping")] public SensorPlLineMapping[] PlLineMapping { @@ -881,36 +864,14 @@ /// [System.Xml.Serialization.XmlAttributeAttribute()] - public int SensorType { + public uint SensorType { get { return this.sensorTypeField; } set { this.sensorTypeField = value; } } - - /// - [System.Xml.Serialization.XmlAttributeAttribute()] - public int PlLineType { - get { - return this.plLineTypeField; - } - set { - this.plLineTypeField = value; - } - } - - /// - [System.Xml.Serialization.XmlIgnoreAttribute()] - public bool PlLineTypeSpecified { - get { - return this.plLineTypeFieldSpecified; - } - set { - this.plLineTypeFieldSpecified = value; - } - } } /// @@ -921,11 +882,11 @@ [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)] public partial class SensorPlLineMapping { - private int pLineTypeField; + private uint pLineTypeField; /// [System.Xml.Serialization.XmlAttributeAttribute()] - public int PLineType { + public uint PLineType { get { return this.pLineTypeField; } Index: DamEngine/trunk/xsd/DamSensorGroup.xsd =================================================================== diff -u -r1600 -r1620 --- DamEngine/trunk/xsd/DamSensorGroup.xsd (.../DamSensorGroup.xsd) (revision 1600) +++ DamEngine/trunk/xsd/DamSensorGroup.xsd (.../DamSensorGroup.xsd) (revision 1620) @@ -9,6 +9,6 @@ - + \ No newline at end of file Index: DamEngine/trunk/xsd/DamSensorLocation.xsd =================================================================== diff -u -r1600 -r1620 --- DamEngine/trunk/xsd/DamSensorLocation.xsd (.../DamSensorLocation.xsd) (revision 1600) +++ DamEngine/trunk/xsd/DamSensorLocation.xsd (.../DamSensorLocation.xsd) (revision 1620) @@ -3,27 +3,11 @@ - - - - - - - - - - - - - - - - - - + + - + @@ -32,7 +16,7 @@ - + @@ -41,7 +25,7 @@ - + @@ -50,7 +34,7 @@ - + @@ -59,7 +43,7 @@ - + @@ -68,7 +52,7 @@ - + Index: DamEngine/trunk/src/Deltares.DamEngine.Interface/FillXmlInputFromDam.cs =================================================================== diff -u -r1566 -r1620 --- DamEngine/trunk/src/Deltares.DamEngine.Interface/FillXmlInputFromDam.cs (.../FillXmlInputFromDam.cs) (revision 1566) +++ DamEngine/trunk/src/Deltares.DamEngine.Interface/FillXmlInputFromDam.cs (.../FillXmlInputFromDam.cs) (revision 1620) @@ -24,6 +24,7 @@ using System.IO; using System.Linq; using Deltares.DamEngine.Data.General; +using Deltares.DamEngine.Data.General.Sensors; using Deltares.DamEngine.Data.General.TimeSeries; using Deltares.DamEngine.Data.Geotechnics; using Deltares.DamEngine.Interface.Properties; @@ -87,9 +88,75 @@ input.OperationalInputTimeSeries = new Io.XmlInput.TimeSerie[dike.InputTimeSerieCollection.Series.Count]; TransferInputTimeSeries(dike.InputTimeSerieCollection, input.OperationalInputTimeSeries); } + if (damProjectData.SensorData != null) + { + input.SensorData = new InputSensorData(); + TransferSensorData(damProjectData.SensorData, input.SensorData); + } return input; } + private static void TransferSensorData(SensorData sensorData, InputSensorData inputSensorData) + { + // Transfer sensorgroups + int sensorGroupIndex = 0; + inputSensorData.SensorGroups = new Io.XmlInput.SensorGroup[sensorData.SensorGroups.Count]; + foreach (var sensorGroup in sensorData.SensorGroups) + { + var inputSensorGroup = new Io.XmlInput.SensorGroup(); + inputSensorGroup.SensorIds = new SensorGroupSensorIds[sensorGroup.SensorCount]; + inputSensorGroup.Id = sensorGroup.ID; + int sensorIdIndex = 0; + foreach (var sensor in sensorGroup.SensorArray) + { + inputSensorGroup.SensorIds[sensorIdIndex] = new SensorGroupSensorIds() {SensorId = sensor.ID}; + sensorIdIndex++; + } + inputSensorData.SensorGroups[sensorGroupIndex] = inputSensorGroup; + sensorGroupIndex++; + } + + // Transfer sensorlocations + int senserLocationIndex = 0; + inputSensorData.SensorLocations = new Io.XmlInput.SensorLocation[sensorData.SensorLocations.Count]; + foreach (var sensorLocation in sensorData.SensorLocations) + { + var inputSensorLocation = new Io.XmlInput.SensorLocation(); + inputSensorLocation.GroupId = sensorLocation.GroupID; + inputSensorLocation.LocationId = sensorLocation.LocationName; + inputSensorLocation.SourceTypePl1PlLineOffsetBelowDikeToeAtPolder = ConversionHelper.ConvertToInputDataSourceTypeSensors(sensorLocation.SourceTypePl1PlLineOffsetBelowDikeToeAtPolder); + inputSensorLocation.SourceTypePl1PlLineOffsetBelowDikeTopAtPolder = ConversionHelper.ConvertToInputDataSourceTypeSensors(sensorLocation.SourceTypePl1PlLineOffsetBelowDikeTopAtPolder); + inputSensorLocation.SourceTypePl1PlLineOffsetBelowDikeTopAtRiver = ConversionHelper.ConvertToInputDataSourceTypeSensors(sensorLocation.SourceTypePl1PlLineOffsetBelowDikeTopAtRiver); + inputSensorLocation.SourceTypePl1PlLineOffsetBelowShoulderBaseInside = ConversionHelper.ConvertToInputDataSourceTypeSensors(sensorLocation.SourceTypePl1PlLineOffsetBelowShoulderBaseInside); + inputSensorLocation.SourceTypePl1WaterLevelAtRiver = ConversionHelper.ConvertToInputDataSourceTypeSensors(sensorLocation.SourceTypePl1WaterLevelAtRiver); + inputSensorLocation.SourceTypePl1WaterLevelAtPolder = ConversionHelper.ConvertToInputDataSourceTypeSensors(sensorLocation.SourceTypePl1WaterLevelAtPolder); + inputSensorLocation.SourceTypePl3 = ConversionHelper.ConvertToInputDataSourceTypeSensors(sensorLocation.SourceTypePl3); + inputSensorLocation.SourceTypePl4 = ConversionHelper.ConvertToInputDataSourceTypeSensors(sensorLocation.SourceTypePl4); + inputSensorData.SensorLocations[senserLocationIndex] = inputSensorLocation; + senserLocationIndex++; + } + + // Transfer sensors + inputSensorData.Sensors = new Io.XmlInput.Sensor[sensorData.Sensors.Count]; + int sensorIndex = 0; + foreach (var sensor in sensorData.Sensors) + { + var inputSensor = new Io.XmlInput.Sensor(); + inputSensor.Id = sensor.ID; + inputSensor.RelativeLocation = sensor.RelativeLocation; + inputSensor.SensorType = ConversionHelper.ConvertToInputSensorType(sensor.SensorType); + inputSensor.PlLineMapping = new SensorPlLineMapping[sensor.PlLineMappings.Length]; + int mappingIndex = 0; + foreach (var plLineMapping in sensor.PlLineMappings) + { + inputSensor.PlLineMapping[mappingIndex] = new SensorPlLineMapping() { PLineType = ConversionHelper.ConvertToInputPlLineType(plLineMapping)}; + mappingIndex++; + } + inputSensorData.Sensors[sensorIndex] = inputSensor; + sensorIndex++; + } + } + private static void TransferInputTimeSeries(TimeSerieCollection inputTimeSerieCollection, Io.XmlInput.TimeSerie[] operationalInputTimeSeries) { int timeSerieIndex = 0;