GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 80.0% 28 / 0 / 35
Functions: 100.0% 1 / 0 / 1
Branches: 49.5% 45 / 0 / 91

src/energyplus/ReverseTranslator/ReverseTranslateExteriorWaterEquipment.cpp
Line Branch Exec Source
1 /***********************************************************************************************************************
2 * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC.
3 * See also https://openstudio.net/license
4 ***********************************************************************************************************************/
5
6 #include "../ReverseTranslator.hpp"
7
8 #include "../../model/ExteriorWaterEquipment.hpp"
9 #include "../../model/ExteriorWaterEquipment_Impl.hpp"
10 #include "../../model/ExteriorWaterEquipmentDefinition.hpp"
11 #include "../../model/ExteriorWaterEquipmentDefinition_Impl.hpp"
12 #include "../../model/Schedule.hpp"
13 #include "../../model/Schedule_Impl.hpp"
14
15 #include <utilities/idd/Exterior_WaterEquipment_FieldEnums.hxx>
16 #include "../../utilities/idd/IddEnums.hpp"
17 #include <utilities/idd/IddEnums.hxx>
18
19 #include "../../utilities/core/Assert.hpp"
20
21 namespace openstudio {
22 namespace energyplus {
23
24 1 boost::optional<model::ModelObject> ReverseTranslator::translateExteriorWaterEquipment(const WorkspaceObject& workspaceObject) {
25
4/5
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 time.
1 if (workspaceObject.iddObject().type() != IddObjectType::Exterior_WaterEquipment) {
26 ✗ LOG(Error, "WorkspaceObject " << workspaceObject.briefDescription() << " is not of IddObjectType::Exterior_WaterEquipment.");
27 ✗ return boost::none;
28 }
29
30 // Create an EquipmentDefinition to hold the Design Level
31
1/1
✓ Branch 1 taken 1 time.
1 model::ExteriorWaterEquipmentDefinition definition(m_model);
32
33 1 OptionalString s;
34 1 OptionalDouble d;
35
36
2/3
✓ Branch 1 taken 1 time.
✓ Branch 5 taken 1 time.
✗ Branch 6 not taken.
2 if ((s = workspaceObject.name())) {
37
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
1 definition.setName(*s + " Definition");
38 }
39
40
2/3
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
2 if ((d = workspaceObject.getDouble(Exterior_WaterEquipmentFields::DesignLevel))) {
41
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 definition.setDesignLevel(*d);
42 }
43
44 1 model::OptionalExteriorWaterEquipment exteriorWaterEquipment;
45 1 model::OptionalSchedule schedule;
46
47
2/3
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
2 if (OptionalWorkspaceObject target = workspaceObject.getTarget(Exterior_WaterEquipmentFields::ScheduleName)) {
48
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
2 if (model::OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target)) {
49
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 schedule = modelObject->optionalCast<model::Schedule>();
50 1 }
51 1 }
52
53
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if (schedule) {
54 try {
55
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
1 exteriorWaterEquipment = model::ExteriorWaterEquipment(definition, *schedule);
56 ✗ } catch (std::exception& e) {
57 ✗ LOG(Warn, "Could not reverse translate " << workspaceObject.briefDescription() << " in full, because " << e.what() << ".");
58 ✗ }
59 }
60
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
1 if (!exteriorWaterEquipment) {
61 ✗ exteriorWaterEquipment = model::ExteriorWaterEquipment(definition);
62 }
63
64
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
✗ Branch 4 not taken.
1 OS_ASSERT(exteriorWaterEquipment);
65
66
2/3
✓ Branch 1 taken 1 time.
✓ Branch 5 taken 1 time.
✗ Branch 6 not taken.
2 if ((s = workspaceObject.name())) {
67
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
1 exteriorWaterEquipment->setName(*s);
68 }
69
70 // Fuel Use Type is always water, so it doesn't exist in OpenStudio
71
2/3
✓ Branch 1 taken 1 time.
✓ Branch 5 taken 1 time.
✗ Branch 6 not taken.
2 if ((s = workspaceObject.getString(Exterior_WaterEquipmentFields::FuelUseType, false, true))) {
72
4/5
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 time.
3 if (!openstudio::istringEqual("Water", *s)) {
73 ✗ LOG(Error, "The Fuel Use Type is not 'Water' for "
74 << workspaceObject.briefDescription() << " but " << *s
75 << " which is highly unexpected for a water equipment. OpenStudio will use 'Water' instead.");
76 }
77 }
78
79
2/3
✓ Branch 1 taken 1 time.
✓ Branch 5 taken 1 time.
✗ Branch 6 not taken.
2 if ((s = workspaceObject.getString(Exterior_WaterEquipmentFields::EndUseSubcategory, false, true))) {
80
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
1 exteriorWaterEquipment->setEndUseSubcategory(*s);
81 }
82
83
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 return *exteriorWaterEquipment;
84 1 }
85
86 } // namespace energyplus
87 } // namespace openstudio
88