GCC Code Coverage Report


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

src/energyplus/ReverseTranslator/ReverseTranslateWindowMaterialGlazingGroupThermochromic.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/ThermochromicGlazing.hpp"
9 #include "../../model/StandardGlazing.hpp"
10 #include "../../model/StandardGlazing_Impl.hpp"
11
12 #include "../../utilities/idf/IdfExtensibleGroup.hpp"
13 #include "../../utilities/idf/WorkspaceExtensibleGroup.hpp"
14
15 #include <utilities/idd/WindowMaterial_GlazingGroup_Thermochromic_FieldEnums.hxx>
16 #include <utilities/idd/IddEnums.hxx>
17
18 using namespace openstudio::model;
19
20 namespace openstudio {
21
22 namespace energyplus {
23
24 ✗ boost::optional<ModelObject> ReverseTranslator::translateWindowMaterialGlazingGroupThermochromic(const WorkspaceObject& workspaceObject) {
25
26 ✗ openstudio::model::ThermochromicGlazing modelObject(m_model);
27
28 // Name
29 ✗ if (boost::optional<std::string> name_ = workspaceObject.name()) {
30 ✗ modelObject.setName(name_.get());
31 ✗ }
32
33 // Extensible groups
34 ✗ for (const IdfExtensibleGroup& eg : workspaceObject.extensibleGroups()) {
35 ✗ auto weg = eg.cast<WorkspaceExtensibleGroup>();
36
37 ✗ double opticalDataTemperature = 0.0;
38 ✗ if (auto opticalDataTemperature_ = weg.getDouble(WindowMaterial_GlazingGroup_ThermochromicExtensibleFields::OpticalDataTemperature)) {
39 ✗ opticalDataTemperature = *opticalDataTemperature_;
40 } else {
41 ✗ LOG(Warn, "Extensible group " << eg.groupIndex() << "(0-indexed) has an opticalDataTemperature, but it's a required field. Assuming zero");
42 }
43
44 ✗ if (boost::optional<WorkspaceObject> wo_ =
45 ✗ weg.getTarget(WindowMaterial_GlazingGroup_ThermochromicExtensibleFields::WindowMaterialGlazingName)) {
46 ✗ if (boost::optional<ModelObject> mo_ = translateAndMapWorkspaceObject(*wo_)) {
47 ✗ if (boost::optional<StandardGlazing> standardGlazing_ = mo_->optionalCast<StandardGlazing>()) {
48 ✗ modelObject.addThermochromicGroup(*standardGlazing_, opticalDataTemperature);
49 } else {
50 ✗ LOG(Warn, "Extensible group " << eg.groupIndex()
51 << "(0-indexed) has a wrong type for WindowMaterialGlazingName, expected StandardGlazing, got "
52 << mo_->briefDescription());
53 ✗ }
54 } else {
55 ✗ LOG(Warn, "Could not translate WindowMaterialGlazingName for Extensible group " << eg.groupIndex());
56 ✗ }
57 } else {
58 ✗ LOG(Warn, "Extensible group " << eg.groupIndex() << "(0-indexed) is missed the WindowMaterialGlazingName field, skipping group");
59 ✗ }
60 ✗ }
61
62 ✗ return modelObject;
63 ✗ } // End of translate function
64
65 } // end namespace energyplus
66 } // end namespace openstudio
67