GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 0.0% 0 / 0 / 66
Functions: 0.0% 0 / 0 / 1
Branches: 0.0% 0 / 0 / 142

src/energyplus/ReverseTranslator/ReverseTranslateGasEquipment.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/GasEquipment.hpp"
9 #include "../../model/GasEquipment_Impl.hpp"
10 #include "../../model/GasEquipmentDefinition.hpp"
11 #include "../../model/GasEquipmentDefinition_Impl.hpp"
12 #include "../../model/Space.hpp"
13 #include "../../model/Space_Impl.hpp"
14 #include "../../model/SpaceType.hpp"
15 #include "../../model/SpaceType_Impl.hpp"
16 #include "../../model/Schedule.hpp"
17 #include "../../model/Schedule_Impl.hpp"
18
19 #include <utilities/idd/GasEquipment_FieldEnums.hxx>
20 #include "../../utilities/idd/IddEnums.hpp"
21 #include <utilities/idd/IddEnums.hxx>
22
23 #include "../../utilities/core/Assert.hpp"
24
25 using namespace openstudio::model;
26
27 namespace openstudio {
28
29 namespace energyplus {
30
31 ✗ OptionalModelObject ReverseTranslator::translateGasEquipment(const WorkspaceObject& workspaceObject) {
32 ✗ if (workspaceObject.iddObject().type() != IddObjectType::GasEquipment) {
33 ✗ LOG(Error, "WorkspaceObject is not IddObjectType: GasEquipment");
34 ✗ return boost::none;
35 }
36
37 // create the definition
38 ✗ openstudio::model::GasEquipmentDefinition definition(m_model);
39
40 ✗ OptionalString s = workspaceObject.name();
41 ✗ if (s) {
42 ✗ definition.setName(*s + " Definition");
43 }
44
45 ✗ s = workspaceObject.getString(openstudio::GasEquipmentFields::DesignLevelCalculationMethod, true);
46 ✗ OS_ASSERT(s);
47
48 ✗ OptionalDouble d;
49 ✗ if (istringEqual("EquipmentLevel", *s)) {
50 ✗ d = workspaceObject.getDouble(openstudio::GasEquipmentFields::DesignLevel);
51 ✗ if (d) {
52 ✗ definition.setDesignLevel(*d);
53 } else {
54 ✗ LOG(Error, "EquipmentLevel value not found for workspace object " << workspaceObject);
55 }
56 ✗ } else if (istringEqual("Watts/Area", *s)) {
57 ✗ d = workspaceObject.getDouble(openstudio::GasEquipmentFields::PowerperFloorArea);
58 ✗ if (d) {
59 ✗ definition.setWattsperSpaceFloorArea(*d);
60 } else {
61 ✗ LOG(Error, "Watts/Area value not found for workspace object " << workspaceObject);
62 }
63 ✗ } else if (istringEqual("Watts/Person", *s)) {
64 ✗ d = workspaceObject.getDouble(openstudio::GasEquipmentFields::PowerperPerson);
65 ✗ if (d) {
66 ✗ definition.setWattsperPerson(*d);
67 } else {
68 ✗ LOG(Error, "Watts/Person value not found for workspace object " << workspaceObject);
69 }
70 } else {
71 ✗ LOG(Error, "Unknown DesignLevelCalculationMethod value for workspace object" << workspaceObject);
72 }
73
74 ✗ d = workspaceObject.getDouble(openstudio::GasEquipmentFields::FractionLatent);
75 ✗ if (d) {
76 ✗ definition.setFractionLatent(*d);
77 }
78
79 ✗ d = workspaceObject.getDouble(openstudio::GasEquipmentFields::FractionRadiant);
80 ✗ if (d) {
81 ✗ definition.setFractionRadiant(*d);
82 }
83
84 ✗ d = workspaceObject.getDouble(openstudio::GasEquipmentFields::FractionLost);
85 ✗ if (d) {
86 ✗ definition.setFractionLost(*d);
87 }
88
89 ✗ d = workspaceObject.getDouble(openstudio::GasEquipmentFields::CarbonDioxideGenerationRate);
90 ✗ if (d) {
91 ✗ definition.setCarbonDioxideGenerationRate(*d);
92 }
93
94 // create the instance
95 ✗ GasEquipment gasEquipment(definition);
96
97 ✗ s = workspaceObject.name();
98 ✗ if (s) {
99 ✗ gasEquipment.setName(*s);
100 }
101
102 ✗ OptionalWorkspaceObject target = workspaceObject.getTarget(openstudio::GasEquipmentFields::ZoneorZoneListorSpaceorSpaceListName);
103 ✗ if (target) {
104 ✗ OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
105 ✗ if (modelObject) {
106 ✗ if (modelObject->optionalCast<Space>()) {
107 ✗ gasEquipment.setSpace(modelObject->cast<Space>());
108 ✗ } else if (modelObject->optionalCast<SpaceType>()) {
109 ✗ gasEquipment.setSpaceType(modelObject->cast<SpaceType>());
110 }
111 }
112 ✗ }
113
114 ✗ target = workspaceObject.getTarget(openstudio::GasEquipmentFields::ScheduleName);
115 ✗ if (target) {
116 ✗ OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
117 ✗ if (modelObject) {
118 ✗ if (OptionalSchedule intermediate = modelObject->optionalCast<Schedule>()) {
119 ✗ Schedule schedule(*intermediate);
120 ✗ gasEquipment.setSchedule(schedule);
121 ✗ }
122 }
123 ✗ }
124
125 ✗ s = workspaceObject.getString(openstudio::GasEquipmentFields::EndUseSubcategory);
126 ✗ if (s) {
127 ✗ gasEquipment.setEndUseSubcategory(*s);
128 }
129
130 ✗ return gasEquipment;
131 ✗ }
132
133 } // namespace energyplus
134
135 } // namespace openstudio
136