Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/Sensors/SensorLocation.cs =================================================================== diff -u -r2529 -r2699 --- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/Sensors/SensorLocation.cs (.../SensorLocation.cs) (revision 2529) +++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/Sensors/SensorLocation.cs (.../SensorLocation.cs) (revision 2699) @@ -349,6 +349,10 @@ internal static readonly string PolderLevel = StaticReflection.GetMemberName(x => x.SourceTypePl1WaterLevelAtPolder); internal static readonly string PL3 = StaticReflection.GetMemberName(x => x.SourceTypePl3); internal static readonly string PL4 = StaticReflection.GetMemberName(x => x.SourceTypePl4); + internal static readonly string Pl1PlLineOffsetBelowDikeToeAtPolder = StaticReflection.GetMemberName(x => x.SourceTypePl1PlLineOffsetBelowDikeToeAtPolder); + internal static readonly string Pl1PlLineOffsetBelowDikeTopAtPolder = StaticReflection.GetMemberName(x => x.SourceTypePl1PlLineOffsetBelowDikeTopAtPolder); + internal static readonly string Pl1PlLineOffsetBelowDikeTopAtRiver = StaticReflection.GetMemberName(x => x.SourceTypePl1PlLineOffsetBelowDikeTopAtRiver); + internal static readonly string Pl1PlLineOffsetBelowShoulderBaseInside = StaticReflection.GetMemberName(x => x.SourceTypePl1PlLineOffsetBelowShoulderBaseInside); } /// @@ -378,6 +382,8 @@ { if (SourceTypePl1WaterLevelAtRiver == DataSourceTypeSensors.Sensor) return sensorValues[sensor]; + if (SourceTypePl1WaterLevelAtRiver == DataSourceTypeSensors.LocationData) + return Location.Scenarios[0].RiverLevel; } if (memberName == MemberNames.PolderLevel) @@ -393,15 +399,41 @@ { if (SourceTypePl3 == DataSourceTypeSensors.Sensor) return sensorValues[sensor]; + if (SourceTypePl3 == DataSourceTypeSensors.LocationData) + return Location.Scenarios[0].HeadPl3; } if (memberName == MemberNames.PL4) { if (SourceTypePl4 == DataSourceTypeSensors.Sensor) return sensorValues[sensor]; + if (SourceTypePl4 == DataSourceTypeSensors.LocationData) + return Location.Scenarios[0].HeadPl4; } + if (memberName == MemberNames.Pl1PlLineOffsetBelowDikeToeAtPolder) + { + if (SourceTypePl1PlLineOffsetBelowDikeToeAtPolder == DataSourceTypeSensors.LocationData) + return Location.Scenarios[0].PlLineOffsetBelowDikeToeAtPolder; + } + if (memberName == MemberNames.Pl1PlLineOffsetBelowDikeTopAtPolder) + { + if (SourceTypePl1PlLineOffsetBelowDikeTopAtPolder == DataSourceTypeSensors.LocationData) + return Location.Scenarios[0].PlLineOffsetBelowDikeTopAtPolder; + } + if (memberName == MemberNames.Pl1PlLineOffsetBelowDikeTopAtRiver) + { + if (SourceTypePl1PlLineOffsetBelowDikeTopAtRiver == DataSourceTypeSensors.LocationData) + return Location.Scenarios[0].PlLineOffsetBelowDikeTopAtRiver; + } + + if (memberName == MemberNames.Pl1PlLineOffsetBelowShoulderBaseInside) + { + if (SourceTypePl1PlLineOffsetBelowShoulderBaseInside == DataSourceTypeSensors.LocationData) + return Location.Scenarios[0].PlLineOffsetBelowShoulderBaseInside; + } + return null; } @@ -413,10 +445,44 @@ /// public bool IsValid() { - return !Validator.Validate(this).Any(); + + if (IsLocationDataAsDataSourceUsed() && Location != null) + { + if (Location.Scenarios.Count != 1) + { + return false; + } + } + + if (Validator.Validate(this).Any()) + { + return false; + } + + return true; } /// + /// Checks if LocationData is used as a source. + /// + /// + private bool IsLocationDataAsDataSourceUsed() + { + if (SourceTypePl1WaterLevelAtRiver == DataSourceTypeSensors.LocationData || + SourceTypePl1WaterLevelAtPolder == DataSourceTypeSensors.LocationData || + SourceTypePl3 == DataSourceTypeSensors.LocationData || + SourceTypePl4 == DataSourceTypeSensors.LocationData|| + SourceTypePl1PlLineOffsetBelowDikeToeAtPolder == DataSourceTypeSensors.LocationData|| + SourceTypePl1PlLineOffsetBelowDikeTopAtPolder == DataSourceTypeSensors.LocationData|| + SourceTypePl1PlLineOffsetBelowDikeTopAtRiver == DataSourceTypeSensors.LocationData|| + SourceTypePl1PlLineOffsetBelowShoulderBaseInside == DataSourceTypeSensors.LocationData) + { + return true; + } + return false; + } + + /// /// Serializes this instance. /// /// Index: DamClients/DamUI/trunk/src/Dam/Tests/Sensors/SensorLocationTests.cs =================================================================== diff -u -r2529 -r2699 --- DamClients/DamUI/trunk/src/Dam/Tests/Sensors/SensorLocationTests.cs (.../SensorLocationTests.cs) (revision 2529) +++ DamClients/DamUI/trunk/src/Dam/Tests/Sensors/SensorLocationTests.cs (.../SensorLocationTests.cs) (revision 2699) @@ -35,7 +35,7 @@ public class SensorLocationTest { readonly Location location = new Location(); - + readonly Scenario scenario = new Scenario(); #region Setup [TestFixtureSetUp] @@ -51,11 +51,13 @@ [SetUp] public void TestSetup() { + location.Scenarios.Add(scenario); } [TearDown] public void TestTearDown() { + location.Scenarios.Clear(); location.Dispose(); } @@ -512,8 +514,9 @@ const double testValue = 1.1; var sensorValues = new Dictionary { { sensor, testValue } }; var sensorLocation = CreateValidSensorLocation(); -// location.PlLineOffsetBelowDikeToeAtPolder = testValue; + location.Scenarios[0].PlLineOffsetBelowDikeToeAtPolder = testValue; + sensorLocation.SourceTypePl1PlLineOffsetBelowDikeToeAtPolder = DataSourceTypeSensors.LocationData; // call @@ -568,7 +571,7 @@ const double testValue = 1.1; var sensorValues = new Dictionary { { sensor, testValue } }; var sensorLocation = CreateValidSensorLocation(); -// location.PlLineOffsetBelowDikeTopAtPolder = testValue; + location.Scenarios[0].PlLineOffsetBelowDikeTopAtPolder = testValue; sensorLocation.SourceTypePl1PlLineOffsetBelowDikeTopAtPolder = DataSourceTypeSensors.LocationData; @@ -624,7 +627,7 @@ const double testValue = 1.1; var sensorValues = new Dictionary { { sensor, testValue } }; var sensorLocation = CreateValidSensorLocation(); -// location.PlLineOffsetBelowDikeTopAtRiver = testValue; + location.Scenarios[0].PlLineOffsetBelowDikeTopAtRiver = testValue; sensorLocation.SourceTypePl1PlLineOffsetBelowDikeTopAtRiver = DataSourceTypeSensors.LocationData; @@ -680,8 +683,9 @@ const double testValue = 1.1; var sensorValues = new Dictionary { { sensor, testValue } }; var sensorLocation = CreateValidSensorLocation(); -// location.PlLineOffsetBelowShoulderBaseInside = testValue; + location.Scenarios[0].PlLineOffsetBelowShoulderBaseInside = testValue; + sensorLocation.SourceTypePl1PlLineOffsetBelowShoulderBaseInside = DataSourceTypeSensors.LocationData; // call @@ -792,8 +796,7 @@ var sensorValues = new Dictionary { { sensor, testValue } }; var sensorLocation = CreateValidSensorLocation(); -// location.RiverLevel = testValue; -// Assert.AreEqual(testValue, location.RiverLevel); + location.Scenarios[0].RiverLevel = testValue; sensorLocation.SourceTypePl1WaterLevelAtRiver = DataSourceTypeSensors.LocationData; @@ -850,7 +853,8 @@ var sensorValues = new Dictionary { { sensor, testValue } }; var sensorLocation = CreateValidSensorLocation(); -// location.HeadPl3 = testValue; + location.Scenarios[0].HeadPl3 = testValue; + sensorLocation.SourceTypePl3 = DataSourceTypeSensors.LocationData; // call @@ -906,7 +910,8 @@ var sensorValues = new Dictionary { { sensor, testValue } }; var sensorLocation = CreateValidSensorLocation(); -// location.HeadPl4 = testValue; + location.Scenarios[0].HeadPl4 = testValue; + sensorLocation.SourceTypePl4 = DataSourceTypeSensors.LocationData; // call