GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 38 / 0 / 38
Functions: 100.0% 1 / 0 / 1
Branches: 94.1% 48 / 0 / 51

src/energyplus/ForwardTranslator/ForwardTranslatePlantEquipmentOperationHeatingLoad.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/Schedule.hpp"
9 #include "../../model/Schedule_Impl.hpp"
10 #include "../../model/PlantEquipmentOperationHeatingLoad.hpp"
11 #include "../../model/PlantEquipmentOperationHeatingLoad_Impl.hpp"
12 #include "../../utilities/core/Logger.hpp"
13 #include "../../utilities/core/Assert.hpp"
14 #include "../../utilities/idf/IdfExtensibleGroup.hpp"
15 #include "../../utilities/idd/IddEnums.hpp"
16 #include <utilities/idd/PlantEquipmentOperation_HeatingLoad_FieldEnums.hxx>
17 #include <utilities/idd/PlantEquipmentList_FieldEnums.hxx>
18 #include <utilities/idd/IddEnums.hxx>
19 #include <utilities/idd/IddFactory.hxx>
20
21 // Special case
22 #include "../../model/GeneratorMicroTurbineHeatRecovery.hpp"
23 #include "../../model/GeneratorMicroTurbineHeatRecovery_Impl.hpp"
24 #include "../../model/GeneratorMicroTurbine.hpp"
25 #include "../../model/GeneratorMicroTurbine_Impl.hpp"
26
27 using namespace openstudio::model;
28
29 using namespace std;
30
31 namespace openstudio {
32
33 namespace energyplus {
34
35 2 boost::optional<IdfObject> ForwardTranslator::translatePlantEquipmentOperationHeatingLoad(PlantEquipmentOperationHeatingLoad& modelObject) {
36
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 IdfObject idfObject(IddObjectType::PlantEquipmentOperation_HeatingLoad);
37
1/1
✓ Branch 1 taken 2 times.
2 m_idfObjects.push_back(idfObject);
38
39 // Name
40
1/1
✓ Branch 1 taken 2 times.
2 auto name = modelObject.nameString();
41
1/1
✓ Branch 1 taken 2 times.
2 idfObject.setName(name);
42
43
1/1
✓ Branch 1 taken 2 times.
2 double lowerLimit = modelObject.minimumLowerLimit();
44 2 int i = 1;
45
3/3
✓ Branch 1 taken 2 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 2 times.
4 for (auto upperLimit : modelObject.loadRangeUpperLimits()) {
46
1/1
✓ Branch 1 taken 2 times.
2 auto equipment = modelObject.equipment(upperLimit);
47
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 if (!equipment.empty()) {
48
1/1
✓ Branch 1 taken 2 times.
2 auto eg = idfObject.pushExtensibleGroup();
49
1/1
✓ Branch 1 taken 2 times.
2 eg.setDouble(PlantEquipmentOperation_HeatingLoadExtensibleFields::LoadRangeLowerLimit, lowerLimit);
50
1/1
✓ Branch 1 taken 2 times.
2 eg.setDouble(PlantEquipmentOperation_HeatingLoadExtensibleFields::LoadRangeUpperLimit, upperLimit);
51
52
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 IdfObject equipmentList(IddObjectType::PlantEquipmentList);
53
1/1
✓ Branch 1 taken 2 times.
2 m_idfObjects.push_back(equipmentList);
54
2/2
✓ Branch 2 taken 2 times.
✓ Branch 5 taken 2 times.
2 auto equipmentListName = name + " equipment list " + std::to_string(i);
55
1/1
✓ Branch 1 taken 2 times.
2 equipmentList.setName(equipmentListName);
56
1/1
✓ Branch 1 taken 2 times.
2 eg.setString(PlantEquipmentOperation_HeatingLoadExtensibleFields::RangeEquipmentListName, equipmentListName);
57
58
2/2
✓ Branch 5 taken 4 times.
✓ Branch 6 taken 2 times.
6 for (auto& component : equipment) {
59
60 // TODO: Find the right way to deal with this
61 // For now, "dirty" (?) fix for Generator:MicroTurbine
62 // @kbenne, FYI
63 4 boost::optional<IdfObject> idf_component;
64
65 // If you find a mCHPHR
66
3/3
✓ Branch 1 taken 4 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
8 if (boost::optional<GeneratorMicroTurbineHeatRecovery> mchpHR = component.optionalCast<GeneratorMicroTurbineHeatRecovery>()) {
67 // Get the parent mchp and translate that, which will pull the appropriate fields from the mchpHR
68 // But we need the name of the mchp for the plant equipment list, not the mchpHR
69
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 GeneratorMicroTurbine mchp = mchpHR->generatorMicroTurbine();
70
1/1
✓ Branch 1 taken 2 times.
2 idf_component = translateAndMapModelObject(mchp);
71
8/8
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✓ Branch 17 taken 2 times.
✓ Branch 20 taken 2 times.
✓ Branch 23 taken 2 times.
2 LOG(Trace, "Found a mchpHR, instead translated " << idf_component->briefDescription());
72 2 } else {
73
1/1
✓ Branch 1 taken 2 times.
2 idf_component = translateAndMapModelObject(component);
74 4 }
75
76
1/1
✓ Branch 1 taken 4 times.
4 auto eg2 = equipmentList.pushExtensibleGroup();
77
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 4 not taken.
4 OS_ASSERT(idf_component);
78
4/4
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
4 eg2.setString(PlantEquipmentListExtensibleFields::EquipmentObjectType, idf_component->iddObject().name());
79
3/3
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
4 eg2.setString(PlantEquipmentListExtensibleFields::EquipmentName, idf_component->nameString());
80 4 }
81 2 }
82
83 2 lowerLimit = upperLimit;
84 2 ++i;
85 4 }
86
87
1/1
✓ Branch 1 taken 2 times.
4 return idfObject;
88 2 }
89
90 } // namespace energyplus
91
92 } // namespace openstudio
93