GCC Code Coverage Report


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

src/energyplus/ReverseTranslator/ReverseTranslateZoneHVACEquipmentList.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/ThermalZone.hpp"
9 #include "../../model/ThermalZone_Impl.hpp"
10 #include "../../model/ZoneHVACComponent.hpp"
11 #include "../../model/ZoneHVACComponent_Impl.hpp"
12 #include "../../model/Space.hpp"
13 #include "../../model/Space_Impl.hpp"
14
15 #include "../../utilities/idf/IdfExtensibleGroup.hpp"
16
17 #include <utilities/idd/ZoneHVAC_EquipmentConnections_FieldEnums.hxx>
18 #include <utilities/idd/ZoneHVAC_EquipmentList_FieldEnums.hxx>
19 #include "../../utilities/idd/IddEnums.hpp"
20 #include <utilities/idd/IddEnums.hxx>
21
22 using namespace openstudio::model;
23
24 namespace openstudio {
25
26 namespace energyplus {
27
28 ✗ OptionalModelObject ReverseTranslator::translateZoneHVACEquipmentList(const WorkspaceObject& workspaceObject) {
29 ✗ if (workspaceObject.iddObject().type() != IddObjectType::ZoneHVAC_EquipmentList) {
30 ✗ LOG(Error, "WorkspaceObject is not IddObjectType: ZoneHVAC:EquipmentList");
31 ✗ return boost::none;
32 }
33
34 ✗ boost::optional<openstudio::model::ThermalZone> thermalZone;
35
36 ✗ std::vector<WorkspaceObject> zoneHVACEquipmentConnections = workspaceObject.getSources(IddObjectType::ZoneHVAC_EquipmentConnections);
37 ✗ if (zoneHVACEquipmentConnections.empty()) {
38 ✗ LOG(Error, "No ZoneHVAC:EquipmentConnections object associated with a zone. Check that IDF file is correct.");
39 ✗ return boost::none;
40 ✗ } else if (zoneHVACEquipmentConnections.size() > 1) {
41 ✗ LOG(Error, "More than 1 ZoneHVAC:EquipmentConnections objects associated with a zone. Check that IDF file is correct.");
42 ✗ return boost::none;
43 }
44
45 ✗ for (const auto& zoneHVACEquipmentConnection : zoneHVACEquipmentConnections) {
46 ✗ if (boost::optional<std::string> name = zoneHVACEquipmentConnection.getString(ZoneHVAC_EquipmentConnectionsFields::ZoneName)) {
47 ✗ boost::optional<model::Space> space = m_model.getConcreteModelObjectByName<model::Space>(name.get());
48
49 ✗ if (space) {
50 ✗ thermalZone = space->thermalZone();
51 }
52 ✗ }
53 }
54
55 // get extensible groups for zone HVAC equipment list
56 ✗ std::vector<IdfExtensibleGroup> extensibleGroups = workspaceObject.extensibleGroups();
57
58 // loop over extensible groups
59 ✗ unsigned n = extensibleGroups.size();
60 ✗ for (unsigned i = 0; i < n; ++i) {
61 // define variables
62 ✗ boost::optional<openstudio::model::ZoneHVACComponent> zoneHVACComponent;
63 // get zone equipment object type and zone equipment object name from extensible group
64 boost::optional<std::string> zoneEquipmentObjectType =
65 ✗ extensibleGroups[i].getString(ZoneHVAC_EquipmentListExtensibleFields::ZoneEquipmentObjectType);
66 ✗ boost::optional<std::string> zoneEquipmentName = extensibleGroups[i].getString(ZoneHVAC_EquipmentListExtensibleFields::ZoneEquipmentName);
67 // get zone equipment workspace object by type and name
68 ✗ if (zoneEquipmentObjectType && zoneEquipmentName) {
69 OptionalWorkspaceObject zoneEquipmentWorkspaceObject =
70 ✗ workspaceObject.workspace().getObjectByTypeAndName(IddObjectType(*zoneEquipmentObjectType), *zoneEquipmentName);
71 // translate zone equipment workspace object
72 ✗ if (zoneEquipmentWorkspaceObject) {
73 ✗ OptionalModelObject zoneEquipmentModelObject = translateAndMapWorkspaceObject(*zoneEquipmentWorkspaceObject);
74 // cast zone equipment model object to zone HVAC component
75 ✗ if (zoneEquipmentModelObject) {
76 ✗ zoneHVACComponent = zoneEquipmentModelObject->optionalCast<ZoneHVACComponent>();
77 }
78 ✗ }
79 ✗ }
80 // add to thermal zone
81 ✗ if (zoneHVACComponent && thermalZone) {
82 ✗ zoneHVACComponent->addToThermalZone(*thermalZone);
83 }
84 ✗ }
85
86 ✗ return boost::none;
87 ✗ }
88
89 } // namespace energyplus
90
91 } // namespace openstudio
92