GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 84.6% 44 / 0 / 52
Functions: 100.0% 1 / 0 / 1
Branches: 46.4% 64 / 0 / 138

src/energyplus/ForwardTranslator/ForwardTranslateGeneratorFuelCell.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
8 #include "../../model/Model.hpp"
9 #include "../../model/OutputVariable.hpp"
10 #include "../../model/OutputVariable_Impl.hpp"
11 #include "../../model/OutputMeter.hpp"
12 #include "../../model/OutputMeter_Impl.hpp"
13 #include "../../model/Schedule.hpp"
14 #include "../../model/Schedule_Impl.hpp"
15 #include "../../model/GeneratorFuelCell.hpp"
16 #include "../../model/GeneratorFuelCell_Impl.hpp"
17 #include "../../model/GeneratorFuelCellPowerModule.hpp"
18 #include "../../model/GeneratorFuelCellPowerModule_Impl.hpp"
19 #include "../../model/GeneratorFuelCellAirSupply.hpp"
20 #include "../../model/GeneratorFuelCellAirSupply_Impl.hpp"
21 #include "../../model/GeneratorFuelCellWaterSupply.hpp"
22 #include "../../model/GeneratorFuelCellWaterSupply_Impl.hpp"
23 #include "../../model/GeneratorFuelCellAuxiliaryHeater.hpp"
24 #include "../../model/GeneratorFuelCellAuxiliaryHeater_Impl.hpp"
25 #include "../../model/GeneratorFuelCellExhaustGasToWaterHeatExchanger.hpp"
26 #include "../../model/GeneratorFuelCellExhaustGasToWaterHeatExchanger_Impl.hpp"
27 #include "../../model/GeneratorFuelCellElectricalStorage.hpp"
28 #include "../../model/GeneratorFuelCellElectricalStorage_Impl.hpp"
29 #include "../../model/GeneratorFuelCellInverter.hpp"
30 #include "../../model/GeneratorFuelCellInverter_Impl.hpp"
31 #include "../../model/GeneratorFuelCellStackCooler.hpp"
32 #include "../../model/GeneratorFuelCellStackCooler_Impl.hpp"
33 #include "../../model/GeneratorFuelSupply.hpp"
34 #include "../../model/GeneratorFuelSupply_Impl.hpp"
35
36 #include "../../utilities/idf/IdfExtensibleGroup.hpp"
37
38 #include <utilities/idd/Generator_FuelCell_FieldEnums.hxx>
39 #include "../../utilities/idd/IddEnums.hpp"
40 #include <utilities/idd/IddEnums.hxx>
41 #include <utilities/idd/IddFactory.hxx>
42
43 using namespace openstudio::model;
44
45 using namespace std;
46
47 namespace openstudio {
48
49 namespace energyplus {
50
51 3 boost::optional<IdfObject> ForwardTranslator::translateGeneratorFuelCell(GeneratorFuelCell& modelObject) {
52
53
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 IdfObject fc = createAndRegisterIdfObject(openstudio::IddObjectType::Generator_FuelCell, modelObject);
54 //Name
55
1/1
✓ Branch 1 taken 3 times.
3 boost::optional<std::string> s = modelObject.name();
56
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (s) {
57
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 fc.setName(*s);
58 }
59
60 //PowerModuleName
61
1/1
✓ Branch 1 taken 3 times.
3 GeneratorFuelCellPowerModule pm = modelObject.powerModule();
62
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
6 if (boost::optional<IdfObject> _pm = translateAndMapModelObject(pm)) {
63
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 fc.setString(Generator_FuelCellFields::PowerModuleName, _pm->nameString());
64 } else {
65 ✗ LOG(Error,
66 "In Fuel cell " << modelObject.nameString() << ", the Generator:FuelCell:PowerModule couldn't be translated when it is required in E+");
67 3 }
68
69 //AirSupplyName
70
1/1
✓ Branch 1 taken 3 times.
3 GeneratorFuelCellAirSupply as = modelObject.airSupply();
71
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
6 if (boost::optional<IdfObject> _as = translateAndMapModelObject(as)) {
72
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 fc.setString(Generator_FuelCellFields::AirSupplyName, _as->nameString());
73 } else {
74 ✗ LOG(Error,
75 "In Fuel cell " << modelObject.nameString() << ", the Generator:FuelCell:AirSupply couldn't be translated when it is required in E+");
76 3 }
77
78 //FuelSupplyName
79
1/1
✓ Branch 1 taken 3 times.
3 GeneratorFuelSupply fs = modelObject.fuelSupply();
80
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
6 if (boost::optional<IdfObject> _fs = translateAndMapModelObject(fs)) {
81
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 fc.setString(Generator_FuelCellFields::FuelSupplyName, _fs->nameString());
82 } else {
83 ✗ LOG(Error, "In Fuel cell " << modelObject.nameString() << ", the Generator:FuelSupply couldn't be translated when it is required in E+");
84 3 }
85
86 //WaterSupplyName
87
1/1
✓ Branch 1 taken 3 times.
3 GeneratorFuelCellWaterSupply ws = modelObject.waterSupply();
88
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
6 if (boost::optional<IdfObject> _ws = translateAndMapModelObject(ws)) {
89
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 fc.setString(Generator_FuelCellFields::WaterSupplyName, _ws->nameString());
90 3 }
91 //AuxiliaryHeaterName
92
1/1
✓ Branch 1 taken 3 times.
3 GeneratorFuelCellAuxiliaryHeater ah = modelObject.auxiliaryHeater();
93
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
6 if (boost::optional<IdfObject> _ah = translateAndMapModelObject(ah)) {
94
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 fc.setString(Generator_FuelCellFields::AuxiliaryHeaterName, _ah->nameString());
95 } else {
96 ✗ LOG(Error,
97 "In Fuel cell " << modelObject.nameString() << ", the Generator:FuelCell:AuxiliaryHeater couldn't be translated when it is required in E+");
98 3 }
99
100 //HeatExchangerName
101
1/1
✓ Branch 1 taken 3 times.
3 GeneratorFuelCellExhaustGasToWaterHeatExchanger he = modelObject.heatExchanger();
102
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
6 if (boost::optional<IdfObject> _he = translateAndMapModelObject(he)) {
103
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 fc.setString(Generator_FuelCellFields::HeatExchangerName, _he->nameString());
104 } else {
105 ✗ LOG(Error, "In Fuel cell " << modelObject.nameString()
106 << ", the Generator:FuelCell:ExhaustGasToWaterHeatExchanger couldn't be translated when it is required in E+");
107 3 }
108
109 //ElectricalStorageName
110
1/1
✓ Branch 1 taken 3 times.
3 GeneratorFuelCellElectricalStorage es = modelObject.electricalStorage();
111
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
6 if (boost::optional<IdfObject> _es = translateAndMapModelObject(es)) {
112
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 fc.setString(Generator_FuelCellFields::ElectricalStorageName, _es->nameString());
113 } else {
114 ✗ LOG(Error, "In Fuel cell " << modelObject.nameString()
115 << ", the Generator:FuelCell:ElectricalStorage couldn't be translated when it is required in E+");
116 3 }
117
118 //InverterName
119
1/1
✓ Branch 1 taken 3 times.
3 GeneratorFuelCellInverter inv = modelObject.inverter();
120
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
6 if (boost::optional<IdfObject> _inv = translateAndMapModelObject(inv)) {
121
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 fc.setString(Generator_FuelCellFields::InverterName, _inv->nameString());
122 } else {
123 ✗ LOG(Error, "In Fuel cell " << modelObject.nameString() << ", the Generator:FuelCell:Inverter couldn't be translated when it is required in E+");
124 3 }
125
126 //StackCoolerName: optional
127
1/1
✓ Branch 1 taken 3 times.
3 boost::optional<GeneratorFuelCellStackCooler> sc = modelObject.stackCooler();
128
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 2 times.
3 if (sc) {
129
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<IdfObject> _sc = translateAndMapModelObject(*sc)) {
130
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
1 fc.setString(Generator_FuelCellFields::StackCoolerName, _sc->nameString());
131 } else {
132 ✗ LOG(Warn, "In Fuel cell " << modelObject.nameString()
133 << ", the Generator:FuelCell:StackCooler is set but couldn't be translated (note: it's optional in E+)");
134 1 }
135 }
136
137
1/1
✓ Branch 1 taken 3 times.
6 return fc;
138 3 }
139
140 } // namespace energyplus
141
142 } // namespace openstudio
143