From ed802c9af069420181e37d04ca92402ba2ea7c0c Mon Sep 17 00:00:00 2001 From: Joe Robertson Date: Wed, 1 Jul 2020 14:44:35 -0700 Subject: [PATCH 1/4] Prevent elec equip latent, radiant, lost greater than 1. --- src/model/ElectricEquipmentDefinition.cpp | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/model/ElectricEquipmentDefinition.cpp b/src/model/ElectricEquipmentDefinition.cpp index b02b0f8be93..5ec05d91bb8 100644 --- a/src/model/ElectricEquipmentDefinition.cpp +++ b/src/model/ElectricEquipmentDefinition.cpp @@ -207,6 +207,14 @@ namespace detail { } bool ElectricEquipmentDefinition_Impl::setFractionLatent(double fractionLatent) { + + double fractionRadiantAndLost = fractionRadiant() + fractionLost(); + if ( (fractionLatent + fractionRadiantAndLost) > 1.0) { + LOG(Error, "Radiant Fraction and Lost Fraction sum to " << fractionRadiantAndLost + << " and you supplied a Latent Fraction of " << fractionLatent + << " which would result in a sum greater than 1.0"); + return false; + } bool result = setDouble(OS_ElectricEquipment_DefinitionFields::FractionLatent, fractionLatent); return result; } @@ -217,6 +225,14 @@ namespace detail { } bool ElectricEquipmentDefinition_Impl::setFractionRadiant(double fractionRadiant) { + + double fractionLatentAndLost = fractionLatent() + fractionLost(); + if ( (fractionRadiant + fractionLatentAndLost) > 1.0) { + LOG(Error, "Latent Fraction and Lost Fraction sum to " << fractionLatentAndLost + << " and you supplied a Radiant Fraction of " << fractionRadiant + << " which would result in a sum greater than 1.0"); + return false; + } bool result = setDouble(OS_ElectricEquipment_DefinitionFields::FractionRadiant, fractionRadiant); return result; } @@ -227,6 +243,14 @@ namespace detail { } bool ElectricEquipmentDefinition_Impl::setFractionLost(double fractionLost) { + + double fractionLatentAndRadiant = fractionLatent() + fractionRadiant(); + if ( (fractionLost + fractionLatentAndRadiant) > 1.0) { + LOG(Error, "Latent Fraction and Radiant Fraction sum to " << fractionLatentAndRadiant + << " and you supplied a Lost Fraction of " << fractionLost + << " which would result in a sum greater than 1.0"); + return false; + } bool result = setDouble(OS_ElectricEquipment_DefinitionFields::FractionLost, fractionLost); return result; } From ffd6f3f5bb0676bb20dfc2b60637f85349b4ed97 Mon Sep 17 00:00:00 2001 From: Joe Robertson Date: Wed, 1 Jul 2020 14:45:02 -0700 Subject: [PATCH 2/4] Test for elec equipment latent, radiant, lost fractions. --- src/model/test/ElectricEquipment_GTest.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/model/test/ElectricEquipment_GTest.cpp b/src/model/test/ElectricEquipment_GTest.cpp index 8b6554b7f60..f6c3bf0f43a 100644 --- a/src/model/test/ElectricEquipment_GTest.cpp +++ b/src/model/test/ElectricEquipment_GTest.cpp @@ -104,3 +104,16 @@ TEST_F(ModelFixture, ElectricEquipment_Cost) { EXPECT_DOUBLE_EQ(300.0, cost->totalCost()); } + +/* Tests that you cannot set Fractions that sum to greater than 1 */ +TEST_F(ModelFixture, ElectricEquipment_FractionsLatentRadiantLost) { + Model m; + ElectricEquipmentDefinition definition(model); + ElectricEquipment electricEquipment(definition); + + ASSERT_TRUE(definition.setFractionLatent(0.5)); + ASSERT_TRUE(definition.setFractionRadiant(0.5)); + ASSERT_FALSE(definition.setFractionLost(0.75)); + ASSERT_FALSE(definition.setFractionLatent(0.75)); + ASSERT_FALSE(definition.setFractionRadiant(0.75)); +} From e401fea17bd18e1b1dfcbc91e73f64bdd900dfff Mon Sep 17 00:00:00 2001 From: Joe Robertson Date: Wed, 1 Jul 2020 15:22:10 -0700 Subject: [PATCH 3/4] Updates for gas, hot water, other, steam equip. --- src/model/GasEquipmentDefinition.cpp | 24 ++++++++++++++++++++++ src/model/HotWaterEquipmentDefinition.cpp | 24 ++++++++++++++++++++++ src/model/OtherEquipmentDefinition.cpp | 24 ++++++++++++++++++++++ src/model/SteamEquipmentDefinition.cpp | 24 ++++++++++++++++++++++ src/model/test/ElectricEquipment_GTest.cpp | 1 - src/model/test/GasEquipment_GTest.cpp | 12 +++++++++++ src/model/test/HotWaterEquipment_GTest.cpp | 12 +++++++++++ src/model/test/OtherEquipment_GTest.cpp | 12 +++++++++++ src/model/test/SteamEquipment_GTest.cpp | 12 +++++++++++ 9 files changed, 144 insertions(+), 1 deletion(-) diff --git a/src/model/GasEquipmentDefinition.cpp b/src/model/GasEquipmentDefinition.cpp index 9889c558979..d3d995eb73e 100644 --- a/src/model/GasEquipmentDefinition.cpp +++ b/src/model/GasEquipmentDefinition.cpp @@ -217,6 +217,14 @@ namespace detail { } bool GasEquipmentDefinition_Impl::setFractionLatent(double fractionLatent) { + + double fractionRadiantAndLost = fractionRadiant() + fractionLost(); + if ( (fractionLatent + fractionRadiantAndLost) > 1.0) { + LOG(Error, "Radiant Fraction and Lost Fraction sum to " << fractionRadiantAndLost + << " and you supplied a Latent Fraction of " << fractionLatent + << " which would result in a sum greater than 1.0"); + return false; + } bool result = setDouble(OS_GasEquipment_DefinitionFields::FractionLatent, fractionLatent); return result; } @@ -227,6 +235,14 @@ namespace detail { } bool GasEquipmentDefinition_Impl::setFractionRadiant(double fractionRadiant) { + + double fractionLatentAndLost = fractionLatent() + fractionLost(); + if ( (fractionRadiant + fractionLatentAndLost) > 1.0) { + LOG(Error, "Latent Fraction and Lost Fraction sum to " << fractionLatentAndLost + << " and you supplied a Radiant Fraction of " << fractionRadiant + << " which would result in a sum greater than 1.0"); + return false; + } bool result = setDouble(OS_GasEquipment_DefinitionFields::FractionRadiant, fractionRadiant); return result; } @@ -237,6 +253,14 @@ namespace detail { } bool GasEquipmentDefinition_Impl::setFractionLost(double fractionLost) { + + double fractionLatentAndRadiant = fractionLatent() + fractionRadiant(); + if ( (fractionLost + fractionLatentAndRadiant) > 1.0) { + LOG(Error, "Latent Fraction and Radiant Fraction sum to " << fractionLatentAndRadiant + << " and you supplied a Lost Fraction of " << fractionLost + << " which would result in a sum greater than 1.0"); + return false; + } bool result = setDouble(OS_GasEquipment_DefinitionFields::FractionLost, fractionLost); return result; } diff --git a/src/model/HotWaterEquipmentDefinition.cpp b/src/model/HotWaterEquipmentDefinition.cpp index f33cf1b1e60..e045bd52bdd 100644 --- a/src/model/HotWaterEquipmentDefinition.cpp +++ b/src/model/HotWaterEquipmentDefinition.cpp @@ -209,6 +209,14 @@ namespace detail { } bool HotWaterEquipmentDefinition_Impl::setFractionLatent(double fractionLatent) { + + double fractionRadiantAndLost = fractionRadiant() + fractionLost(); + if ( (fractionLatent + fractionRadiantAndLost) > 1.0) { + LOG(Error, "Radiant Fraction and Lost Fraction sum to " << fractionRadiantAndLost + << " and you supplied a Latent Fraction of " << fractionLatent + << " which would result in a sum greater than 1.0"); + return false; + } bool result = setDouble(OS_HotWaterEquipment_DefinitionFields::FractionLatent, fractionLatent); return result; } @@ -219,6 +227,14 @@ namespace detail { } bool HotWaterEquipmentDefinition_Impl::setFractionRadiant(double fractionRadiant) { + + double fractionLatentAndLost = fractionLatent() + fractionLost(); + if ( (fractionRadiant + fractionLatentAndLost) > 1.0) { + LOG(Error, "Latent Fraction and Lost Fraction sum to " << fractionLatentAndLost + << " and you supplied a Radiant Fraction of " << fractionRadiant + << " which would result in a sum greater than 1.0"); + return false; + } bool result = setDouble(OS_HotWaterEquipment_DefinitionFields::FractionRadiant, fractionRadiant); return result; } @@ -229,6 +245,14 @@ namespace detail { } bool HotWaterEquipmentDefinition_Impl::setFractionLost(double fractionLost) { + + double fractionLatentAndRadiant = fractionLatent() + fractionRadiant(); + if ( (fractionLost + fractionLatentAndRadiant) > 1.0) { + LOG(Error, "Latent Fraction and Radiant Fraction sum to " << fractionLatentAndRadiant + << " and you supplied a Lost Fraction of " << fractionLost + << " which would result in a sum greater than 1.0"); + return false; + } bool result = setDouble(OS_HotWaterEquipment_DefinitionFields::FractionLost, fractionLost); return result; } diff --git a/src/model/OtherEquipmentDefinition.cpp b/src/model/OtherEquipmentDefinition.cpp index 0106af2739d..5b4264f153a 100644 --- a/src/model/OtherEquipmentDefinition.cpp +++ b/src/model/OtherEquipmentDefinition.cpp @@ -175,6 +175,14 @@ namespace detail { } bool OtherEquipmentDefinition_Impl::setFractionLatent(double fractionLatent) { + + double fractionRadiantAndLost = fractionRadiant() + fractionLost(); + if ( (fractionLatent + fractionRadiantAndLost) > 1.0) { + LOG(Error, "Radiant Fraction and Lost Fraction sum to " << fractionRadiantAndLost + << " and you supplied a Latent Fraction of " << fractionLatent + << " which would result in a sum greater than 1.0"); + return false; + } bool result = setDouble(OS_OtherEquipment_DefinitionFields::FractionLatent, fractionLatent); return result; } @@ -185,6 +193,14 @@ namespace detail { } bool OtherEquipmentDefinition_Impl::setFractionRadiant(double fractionRadiant) { + + double fractionLatentAndLost = fractionLatent() + fractionLost(); + if ( (fractionRadiant + fractionLatentAndLost) > 1.0) { + LOG(Error, "Latent Fraction and Lost Fraction sum to " << fractionLatentAndLost + << " and you supplied a Radiant Fraction of " << fractionRadiant + << " which would result in a sum greater than 1.0"); + return false; + } bool result = setDouble(OS_OtherEquipment_DefinitionFields::FractionRadiant, fractionRadiant); return result; } @@ -195,6 +211,14 @@ namespace detail { } bool OtherEquipmentDefinition_Impl::setFractionLost(double fractionLost) { + + double fractionLatentAndRadiant = fractionLatent() + fractionRadiant(); + if ( (fractionLost + fractionLatentAndRadiant) > 1.0) { + LOG(Error, "Latent Fraction and Radiant Fraction sum to " << fractionLatentAndRadiant + << " and you supplied a Lost Fraction of " << fractionLost + << " which would result in a sum greater than 1.0"); + return false; + } bool result = setDouble(OS_OtherEquipment_DefinitionFields::FractionLost, fractionLost); return result; } diff --git a/src/model/SteamEquipmentDefinition.cpp b/src/model/SteamEquipmentDefinition.cpp index 264ff102a59..f9427b55f10 100644 --- a/src/model/SteamEquipmentDefinition.cpp +++ b/src/model/SteamEquipmentDefinition.cpp @@ -177,6 +177,14 @@ namespace detail { } bool SteamEquipmentDefinition_Impl::setFractionLatent(double fractionLatent) { + + double fractionRadiantAndLost = fractionRadiant() + fractionLost(); + if ( (fractionLatent + fractionRadiantAndLost) > 1.0) { + LOG(Error, "Radiant Fraction and Lost Fraction sum to " << fractionRadiantAndLost + << " and you supplied a Latent Fraction of " << fractionLatent + << " which would result in a sum greater than 1.0"); + return false; + } bool result = setDouble(OS_SteamEquipment_DefinitionFields::FractionLatent, fractionLatent); return result; } @@ -187,6 +195,14 @@ namespace detail { } bool SteamEquipmentDefinition_Impl::setFractionRadiant(double fractionRadiant) { + + double fractionLatentAndLost = fractionLatent() + fractionLost(); + if ( (fractionRadiant + fractionLatentAndLost) > 1.0) { + LOG(Error, "Latent Fraction and Lost Fraction sum to " << fractionLatentAndLost + << " and you supplied a Radiant Fraction of " << fractionRadiant + << " which would result in a sum greater than 1.0"); + return false; + } bool result = setDouble(OS_SteamEquipment_DefinitionFields::FractionRadiant, fractionRadiant); return result; } @@ -197,6 +213,14 @@ namespace detail { } bool SteamEquipmentDefinition_Impl::setFractionLost(double fractionLost) { + + double fractionLatentAndRadiant = fractionLatent() + fractionRadiant(); + if ( (fractionLost + fractionLatentAndRadiant) > 1.0) { + LOG(Error, "Latent Fraction and Radiant Fraction sum to " << fractionLatentAndRadiant + << " and you supplied a Lost Fraction of " << fractionLost + << " which would result in a sum greater than 1.0"); + return false; + } bool result = setDouble(OS_SteamEquipment_DefinitionFields::FractionLost, fractionLost); return result; } diff --git a/src/model/test/ElectricEquipment_GTest.cpp b/src/model/test/ElectricEquipment_GTest.cpp index f6c3bf0f43a..504d3e3d58d 100644 --- a/src/model/test/ElectricEquipment_GTest.cpp +++ b/src/model/test/ElectricEquipment_GTest.cpp @@ -109,7 +109,6 @@ TEST_F(ModelFixture, ElectricEquipment_Cost) { TEST_F(ModelFixture, ElectricEquipment_FractionsLatentRadiantLost) { Model m; ElectricEquipmentDefinition definition(model); - ElectricEquipment electricEquipment(definition); ASSERT_TRUE(definition.setFractionLatent(0.5)); ASSERT_TRUE(definition.setFractionRadiant(0.5)); diff --git a/src/model/test/GasEquipment_GTest.cpp b/src/model/test/GasEquipment_GTest.cpp index 0792051164c..9610f6379f8 100644 --- a/src/model/test/GasEquipment_GTest.cpp +++ b/src/model/test/GasEquipment_GTest.cpp @@ -91,3 +91,15 @@ TEST_F(ModelFixture, GasEquipment_Cost) EXPECT_DOUBLE_EQ(80.0, cost->totalCost()); } + +/* Tests that you cannot set Fractions that sum to greater than 1 */ +TEST_F(ModelFixture, GasEquipment_FractionsLatentRadiantLost) { + Model m; + GasEquipmentDefinition definition(model); + + ASSERT_TRUE(definition.setFractionLatent(0.5)); + ASSERT_TRUE(definition.setFractionRadiant(0.5)); + ASSERT_FALSE(definition.setFractionLost(0.75)); + ASSERT_FALSE(definition.setFractionLatent(0.75)); + ASSERT_FALSE(definition.setFractionRadiant(0.75)); +} diff --git a/src/model/test/HotWaterEquipment_GTest.cpp b/src/model/test/HotWaterEquipment_GTest.cpp index fea28f16aa3..b74e944aa8a 100644 --- a/src/model/test/HotWaterEquipment_GTest.cpp +++ b/src/model/test/HotWaterEquipment_GTest.cpp @@ -49,3 +49,15 @@ TEST_F(ModelFixture, HotWaterEquipment) HotWaterEquipment hotWaterEquipment(definition); EXPECT_EQ(2u, model.numObjects()); } + +/* Tests that you cannot set Fractions that sum to greater than 1 */ +TEST_F(ModelFixture, HotWaterEquipment_FractionsLatentRadiantLost) { + Model m; + HotWaterEquipmentDefinition definition(model); + + ASSERT_TRUE(definition.setFractionLatent(0.5)); + ASSERT_TRUE(definition.setFractionRadiant(0.5)); + ASSERT_FALSE(definition.setFractionLost(0.75)); + ASSERT_FALSE(definition.setFractionLatent(0.75)); + ASSERT_FALSE(definition.setFractionRadiant(0.75)); +} diff --git a/src/model/test/OtherEquipment_GTest.cpp b/src/model/test/OtherEquipment_GTest.cpp index 68f58f5943a..23db2afeec2 100644 --- a/src/model/test/OtherEquipment_GTest.cpp +++ b/src/model/test/OtherEquipment_GTest.cpp @@ -125,3 +125,15 @@ TEST_F(ModelFixture, OtherEquipment_EndUseSubcategory) EXPECT_TRUE(equipment.isEndUseSubcategoryDefaulted()); } + +/* Tests that you cannot set Fractions that sum to greater than 1 */ +TEST_F(ModelFixture, OtherEquipment_FractionsLatentRadiantLost) { + Model m; + OtherEquipmentDefinition definition(model); + + ASSERT_TRUE(definition.setFractionLatent(0.5)); + ASSERT_TRUE(definition.setFractionRadiant(0.5)); + ASSERT_FALSE(definition.setFractionLost(0.75)); + ASSERT_FALSE(definition.setFractionLatent(0.75)); + ASSERT_FALSE(definition.setFractionRadiant(0.75)); +} diff --git a/src/model/test/SteamEquipment_GTest.cpp b/src/model/test/SteamEquipment_GTest.cpp index ad9163d65ec..6b4fabadcb8 100644 --- a/src/model/test/SteamEquipment_GTest.cpp +++ b/src/model/test/SteamEquipment_GTest.cpp @@ -83,3 +83,15 @@ TEST_F(ModelFixture, SteamEquipment_Instance) SteamEquipment instance(definition); EXPECT_TRUE(instance.definition().optionalCast()); } + +/* Tests that you cannot set Fractions that sum to greater than 1 */ +TEST_F(ModelFixture, SteamEquipment_FractionsLatentRadiantLost) { + Model m; + SteamEquipmentDefinition definition(model); + + ASSERT_TRUE(definition.setFractionLatent(0.5)); + ASSERT_TRUE(definition.setFractionRadiant(0.5)); + ASSERT_FALSE(definition.setFractionLost(0.75)); + ASSERT_FALSE(definition.setFractionLatent(0.75)); + ASSERT_FALSE(definition.setFractionRadiant(0.75)); +} From 0b67f4a616f3010508f3c9c481b04648bcf70dae Mon Sep 17 00:00:00 2001 From: Joe Robertson Date: Mon, 6 Jul 2020 16:41:45 -0700 Subject: [PATCH 4/4] Fix typo in new model tests. --- src/model/test/ElectricEquipment_GTest.cpp | 2 +- src/model/test/GasEquipment_GTest.cpp | 2 +- src/model/test/HotWaterEquipment_GTest.cpp | 2 +- src/model/test/OtherEquipment_GTest.cpp | 2 +- src/model/test/SteamEquipment_GTest.cpp | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/model/test/ElectricEquipment_GTest.cpp b/src/model/test/ElectricEquipment_GTest.cpp index 504d3e3d58d..68c4bbec4a4 100644 --- a/src/model/test/ElectricEquipment_GTest.cpp +++ b/src/model/test/ElectricEquipment_GTest.cpp @@ -108,7 +108,7 @@ TEST_F(ModelFixture, ElectricEquipment_Cost) { /* Tests that you cannot set Fractions that sum to greater than 1 */ TEST_F(ModelFixture, ElectricEquipment_FractionsLatentRadiantLost) { Model m; - ElectricEquipmentDefinition definition(model); + ElectricEquipmentDefinition definition(m); ASSERT_TRUE(definition.setFractionLatent(0.5)); ASSERT_TRUE(definition.setFractionRadiant(0.5)); diff --git a/src/model/test/GasEquipment_GTest.cpp b/src/model/test/GasEquipment_GTest.cpp index 9610f6379f8..56b317ba809 100644 --- a/src/model/test/GasEquipment_GTest.cpp +++ b/src/model/test/GasEquipment_GTest.cpp @@ -95,7 +95,7 @@ TEST_F(ModelFixture, GasEquipment_Cost) /* Tests that you cannot set Fractions that sum to greater than 1 */ TEST_F(ModelFixture, GasEquipment_FractionsLatentRadiantLost) { Model m; - GasEquipmentDefinition definition(model); + GasEquipmentDefinition definition(m); ASSERT_TRUE(definition.setFractionLatent(0.5)); ASSERT_TRUE(definition.setFractionRadiant(0.5)); diff --git a/src/model/test/HotWaterEquipment_GTest.cpp b/src/model/test/HotWaterEquipment_GTest.cpp index b74e944aa8a..18e511a0f0b 100644 --- a/src/model/test/HotWaterEquipment_GTest.cpp +++ b/src/model/test/HotWaterEquipment_GTest.cpp @@ -53,7 +53,7 @@ TEST_F(ModelFixture, HotWaterEquipment) /* Tests that you cannot set Fractions that sum to greater than 1 */ TEST_F(ModelFixture, HotWaterEquipment_FractionsLatentRadiantLost) { Model m; - HotWaterEquipmentDefinition definition(model); + HotWaterEquipmentDefinition definition(m); ASSERT_TRUE(definition.setFractionLatent(0.5)); ASSERT_TRUE(definition.setFractionRadiant(0.5)); diff --git a/src/model/test/OtherEquipment_GTest.cpp b/src/model/test/OtherEquipment_GTest.cpp index 23db2afeec2..4f871c949e1 100644 --- a/src/model/test/OtherEquipment_GTest.cpp +++ b/src/model/test/OtherEquipment_GTest.cpp @@ -129,7 +129,7 @@ TEST_F(ModelFixture, OtherEquipment_EndUseSubcategory) /* Tests that you cannot set Fractions that sum to greater than 1 */ TEST_F(ModelFixture, OtherEquipment_FractionsLatentRadiantLost) { Model m; - OtherEquipmentDefinition definition(model); + OtherEquipmentDefinition definition(m); ASSERT_TRUE(definition.setFractionLatent(0.5)); ASSERT_TRUE(definition.setFractionRadiant(0.5)); diff --git a/src/model/test/SteamEquipment_GTest.cpp b/src/model/test/SteamEquipment_GTest.cpp index 6b4fabadcb8..aa87124012d 100644 --- a/src/model/test/SteamEquipment_GTest.cpp +++ b/src/model/test/SteamEquipment_GTest.cpp @@ -87,7 +87,7 @@ TEST_F(ModelFixture, SteamEquipment_Instance) /* Tests that you cannot set Fractions that sum to greater than 1 */ TEST_F(ModelFixture, SteamEquipment_FractionsLatentRadiantLost) { Model m; - SteamEquipmentDefinition definition(model); + SteamEquipmentDefinition definition(m); ASSERT_TRUE(definition.setFractionLatent(0.5)); ASSERT_TRUE(definition.setFractionRadiant(0.5));