GCC Code Coverage Report


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

src/sdd/ForwardTranslator.hpp
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 #ifndef SDD_FORWARDTRANSLATOR_HPP
7 #define SDD_FORWARDTRANSLATOR_HPP
8
9 #include "SDDAPI.hpp"
10
11 #include "../utilities/core/Path.hpp"
12 #include "../utilities/core/Optional.hpp"
13 #include "../utilities/core/Logger.hpp"
14 #include "../utilities/core/StringStreamLogSink.hpp"
15
16 #include "../model/ModelObject.hpp"
17
18 #include <map>
19
20 namespace pugi {
21 class xml_node;
22 class xml_document;
23 } // namespace pugi
24
25 namespace openstudio {
26
27 class ProgressBar;
28 class Transformation;
29
30 namespace model {
31 class Model;
32 class ModelObject;
33 class Material;
34 class ConstructionBase;
35 class Building;
36 class BuildingStory;
37 class ThermalZone;
38 class Space;
39 class Surface;
40 class SubSurface;
41 class ShadingSurface;
42 class AirLoopHVAC;
43 class FanConstantVolume;
44 class CoilCoolingDXSingleSpeed;
45 class CoilHeatingGas;
46 class AirLoopHVACOutdoorAirSystem;
47 } // namespace model
48
49 namespace sdd {
50
51 class SDD_API ForwardTranslator
52 {
53 public:
54 ForwardTranslator();
55
56 ~ForwardTranslator();
57
58 bool modelToSDD(const openstudio::model::Model& model, const openstudio::path& path, ProgressBar* progressBar = nullptr);
59
60 /** Get warning messages generated by the last translation.
61 * Warnings are issues encountered during translation that are important, but not fatal to producing a valid SDD for compliance analysis*/
62 std::vector<LogMessage> warnings() const;
63
64 /** Get error messages generated by the last translation.
65 * Errors are issues encountered during translation that are fatal to producing a valid SDD for compliance analysis*/
66 std::vector<LogMessage> errors() const;
67
68 private:
69 std::string escapeName(std::string name);
70
71 // listed in translation order
72 // Any of these may throw if they encounter something so terrible they cannot continue,
73 // and the caller (modelToSDD) should catch the exception and report the log up to that point.
74
75 // Use LOG(Error ... or LOG(Warn ... to produce log messages.
76 // If there is an error that prevents the translation from being able to continue then use LOG_AND_THROW.
77 // Prefer LOG(Error over LOG_AND_THROW if possible.
78 // Use OS_ASSERT to catch logic errors in the translator implementation. Do not use OS_ASSERT on bad input, use LOG( instead.
79
80 bool translateModel(const openstudio::model::Model& model, pugi::xml_document& document);
81 boost::optional<pugi::xml_node> translateMaterial(const openstudio::model::Material& material, pugi::xml_node& root);
82 boost::optional<pugi::xml_node> translateConstructionBase(const openstudio::model::ConstructionBase& constructionBase, pugi::xml_node& root);
83 boost::optional<pugi::xml_node> translateDoorConstruction(const openstudio::model::ConstructionBase& constructionBase, pugi::xml_node& root);
84 boost::optional<pugi::xml_node> translateFenestrationConstruction(const openstudio::model::ConstructionBase& constructionBase,
85 pugi::xml_node& root);
86 boost::optional<pugi::xml_node> translateBuilding(const openstudio::model::Building& building, pugi::xml_node& root);
87 boost::optional<pugi::xml_node> translateBuildingStory(const openstudio::model::BuildingStory& buildingStory, pugi::xml_node& root);
88 boost::optional<pugi::xml_node> translateSpace(const openstudio::model::Space& space, pugi::xml_node& root);
89 boost::optional<pugi::xml_node> translateSurface(const openstudio::model::Surface& surface, const openstudio::Transformation& transformation,
90 pugi::xml_node& root);
91 boost::optional<pugi::xml_node> translateSubSurface(const openstudio::model::SubSurface& subSurface,
92 const openstudio::Transformation& transformation, pugi::xml_node& root);
93 boost::optional<pugi::xml_node> translateShadingSurface(const openstudio::model::ShadingSurface& shadingSurface,
94 const openstudio::Transformation& transformation, pugi::xml_node& root);
95 boost::optional<pugi::xml_node> translateThermalZone(const openstudio::model::ThermalZone& thermalZone, pugi::xml_node& root);
96 boost::optional<pugi::xml_node> translateAirLoopHVAC(const openstudio::model::AirLoopHVAC& airLoop, pugi::xml_node& root);
97
98 boost::optional<pugi::xml_node> translateFanConstantVolume(const openstudio::model::FanConstantVolume& fan, pugi::xml_node& airSegElement);
99 boost::optional<pugi::xml_node> translateCoilCoolingDXSingleSpeed(const openstudio::model::CoilCoolingDXSingleSpeed& coil,
100 pugi::xml_node& airSegElement);
101 boost::optional<pugi::xml_node> translateCoilHeatingGas(const openstudio::model::CoilHeatingGas& coil, pugi::xml_node& airSegElement);
102 boost::optional<pugi::xml_node> translateAirLoopHVACOutdoorAirSystem(const openstudio::model::AirLoopHVACOutdoorAirSystem& oasys,
103 pugi::xml_node& airSegElement);
104
105 std::map<openstudio::Handle, pugi::xml_node> m_translatedObjects;
106
107 // Log untranslated objects as an error,
108 // unless the type is in the m_ignoreTypes or m_ignoreObjects member.
109 void logUntranslatedObjects(const model::Model& model);
110
111 // Use this member to ignore an entire class of ModelObject.
112 std::vector<IddObjectType> m_ignoreTypes;
113
114 // Use this member to ignore a specific ModelObject, but not all of that type.
115 // For example you might want to ignore FanConstantSpeed inside of terminals, but
116 // not ignore all FanConstantSpeed objects.
117 // There will be no warning that the type is ignored.
118 std::vector<Handle> m_ignoreObjects;
119
120 StringStreamLogSink m_logSink;
121
122 ProgressBar* m_progressBar;
123
124 bool m_autoHardSize;
125 bool m_autoEfficiency;
126
127 − REGISTER_LOGGER("openstudio.sdd.ForwardTranslator");
128 };
129
130 } // namespace sdd
131 } // namespace openstudio
132
133 #endif // SDD_FORWARDTRANSLATOR_HPP
134