GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 97.2% 35 / 0 / 36
Functions: 100.0% 1 / 0 / 1
Branches: 79.2% 57 / 0 / 72

src/energyplus/ForwardTranslator/ForwardTranslatePlantComponentUserDefined.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 "../ForwardTranslator.hpp"
7 #include "../../model/Model.hpp"
8 #include "../../model/Node.hpp"
9 #include "../../model/Node_Impl.hpp"
10 #include "../../model/ThermalZone.hpp"
11 #include "../../model/ThermalZone_Impl.hpp"
12 #include "../../model/PlantComponentUserDefined.hpp"
13 #include "../../model/PlantComponentUserDefined_Impl.hpp"
14 #include "../../model/EnergyManagementSystemProgramCallingManager.hpp"
15 #include "../../model/EnergyManagementSystemProgramCallingManager_Impl.hpp"
16 #include "../../utilities/core/Logger.hpp"
17 #include "../../utilities/core/Assert.hpp"
18 #include <utilities/idd/PlantComponent_UserDefined_FieldEnums.hxx>
19 #include "../../utilities/idd/IddEnums.hpp"
20 #include <utilities/idd/IddEnums.hxx>
21 #include <utilities/idd/IddFactory.hxx>
22
23 using namespace openstudio::model;
24
25 using namespace std;
26
27 namespace openstudio {
28
29 namespace energyplus {
30
31 1 boost::optional<IdfObject> ForwardTranslator::translatePlantComponentUserDefined(PlantComponentUserDefined& modelObject) {
32 1 boost::optional<std::string> s;
33
34
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 IdfObject idfObject(IddObjectType::PlantComponent_UserDefined);
35
36
1/1
✓ Branch 1 taken 1 time.
1 m_idfObjects.push_back(idfObject);
37
38 // Name
39
40
1/1
✓ Branch 1 taken 1 time.
1 s = modelObject.name();
41
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if (s) {
42
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 idfObject.setName(*s);
43 }
44
45 // PlantConnection1LoadingMode
46
47
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 8 taken 1 time.
✗ Branch 9 not taken.
2 if ((s = modelObject.plantLoadingMode())) {
48
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 idfObject.setString(PlantComponent_UserDefinedFields::PlantConnection1LoadingMode, s.get());
49 }
50
51 // PlantConnection1LoopFlowRequestMode
52
53
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 8 taken 1 time.
✗ Branch 9 not taken.
2 if ((s = modelObject.plantLoopFlowRequestMode())) {
54
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 idfObject.setString(PlantComponent_UserDefinedFields::PlantConnection1LoopFlowRequestMode, s.get());
55 }
56
57 // NumberofPlantLoopConnections
58 // value is 1 since its a StraightComponent
59
1/1
✓ Branch 1 taken 1 time.
1 idfObject.setInt(PlantComponent_UserDefinedFields::NumberofPlantLoopConnections, 1);
60
61 // MainModelProgramCallingManagerName
62
63
2/3
✓ Branch 1 taken 1 time.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
2 if (boost::optional<EnergyManagementSystemProgramCallingManager> pcm = modelObject.mainModelProgramCallingManager()) {
64 ✗ idfObject.setString(PlantComponent_UserDefinedFields::MainModelProgramCallingManagerName, pcm->name().get());
65 1 }
66
67 // PlantConnection1InitializationProgramCallingManagerName
68
69
2/3
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
2 if (boost::optional<EnergyManagementSystemProgramCallingManager> pcm = modelObject.plantInitializationProgramCallingManager()) {
70
4/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
1 idfObject.setString(PlantComponent_UserDefinedFields::PlantConnection1InitializationProgramCallingManagerName, pcm->name().get());
71 1 }
72
73 // PlantConnection1SimulationProgramCallingManagerName
74
75
2/3
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
2 if (boost::optional<EnergyManagementSystemProgramCallingManager> pcm = modelObject.plantSimulationProgramCallingManager()) {
76
4/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
1 idfObject.setString(PlantComponent_UserDefinedFields::PlantConnection1SimulationProgramCallingManagerName, pcm->name().get());
77 1 }
78
79 // PlantConnection1InletNodeName
80
81
2/3
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
2 if (boost::optional<ModelObject> mo = modelObject.inletModelObject()) {
82
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
2 if (boost::optional<Node> node = mo->optionalCast<Node>()) {
83
4/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
1 idfObject.setString(PlantComponent_UserDefinedFields::PlantConnection1InletNodeName, node->name().get());
84 1 }
85 1 }
86
87 // PlantConnection1OutletNodeName
88
89
2/3
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
2 if (boost::optional<ModelObject> mo = modelObject.outletModelObject()) {
90
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
2 if (boost::optional<Node> node = mo->optionalCast<Node>()) {
91
4/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
1 idfObject.setString(PlantComponent_UserDefinedFields::PlantConnection1OutletNodeName, node->name().get());
92 1 }
93 1 }
94
95 // AmbientZoneName
96
97
2/3
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
2 if (boost::optional<ThermalZone> tz = modelObject.ambientZone()) {
98
4/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
1 idfObject.setString(PlantComponent_UserDefinedFields::AmbientZoneName, tz->name().get());
99 1 }
100
101
1/1
✓ Branch 1 taken 1 time.
2 return boost::optional<IdfObject>(idfObject);
102 1 }
103
104 } // namespace energyplus
105
106 } // namespace openstudio
107