src/sdd/ReverseTranslator.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_REVERSETRANSLATOR_HPP | ||
| 7 | #define SDD_REVERSETRANSLATOR_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/Schedule.hpp" | ||
| 17 | #include "../model/AvailabilityManagerOptimumStart.hpp" | ||
| 18 | #include "../model/AvailabilityManagerNightCycle.hpp" | ||
| 19 | #include "../model/ConstructionBase.hpp" | ||
| 20 | #include "../model/AirConditionerVariableRefrigerantFlow.hpp" | ||
| 21 | |||
| 22 | namespace pugi { | ||
| 23 | class xml_node; | ||
| 24 | class xml_document; | ||
| 25 | } // namespace pugi | ||
| 26 | |||
| 27 | namespace openstudio { | ||
| 28 | |||
| 29 | class ProgressBar; | ||
| 30 | |||
| 31 | namespace model { | ||
| 32 | class Model; | ||
| 33 | class ModelObject; | ||
| 34 | class BuildingStory; | ||
| 35 | class Space; | ||
| 36 | class ShadingSurfaceGroup; | ||
| 37 | class PlanarSurface; | ||
| 38 | class Surface; | ||
| 39 | class SubSurface; | ||
| 40 | class PlantLoop; | ||
| 41 | } // namespace model | ||
| 42 | |||
| 43 | namespace sdd { | ||
| 44 | |||
| 45 | class SDD_API ReverseTranslator | ||
| 46 | { | ||
| 47 | public: | ||
| 48 | // If masterAutosize = true the translator will ignore choices in the sdd file and forcibly autosize the entire model. | ||
| 49 | ReverseTranslator(bool masterAutosize = false); | ||
| 50 | |||
| 51 | ~ReverseTranslator(); | ||
| 52 | |||
| 53 | boost::optional<openstudio::model::Model> loadModel(const openstudio::path& path, ProgressBar* progressBar = nullptr); | ||
| 54 | |||
| 55 | /** Get warning messages generated by the last translation. */ | ||
| 56 | std::vector<LogMessage> warnings() const; | ||
| 57 | |||
| 58 | /** Get error messages generated by the last translation. */ | ||
| 59 | std::vector<LogMessage> errors() const; | ||
| 60 | |||
| 61 | private: | ||
| 62 | std::string escapeName(std::string name); | ||
| 63 | |||
| 64 | // listed in translation order | ||
| 65 | boost::optional<openstudio::model::Model> convert(const pugi::xml_node& root); | ||
| 66 | boost::optional<openstudio::model::Model> translateSDD(const pugi::xml_node& root); | ||
| 67 | |||
| 68 | boost::optional<openstudio::model::ModelObject> translateRunPeriod(const pugi::xml_node& element, openstudio::model::Model& model); | ||
| 69 | boost::optional<openstudio::model::ModelObject> translateSite(const pugi::xml_node& element, openstudio::model::Model& model); | ||
| 70 | boost::optional<openstudio::model::ModelObject> translateWaterMainsTemperature(const pugi::xml_node& element, openstudio::model::Model& model); | ||
| 71 | std::vector<openstudio::WorkspaceObject> translateDesignDays(const pugi::xml_node& element, openstudio::model::Model& model); | ||
| 72 | boost::optional<openstudio::model::ModelObject> translateWeatherFile(const pugi::xml_node& element, openstudio::model::Model& model); | ||
| 73 | |||
| 74 | boost::optional<openstudio::model::ModelObject> translateMaterial(const pugi::xml_node& element, openstudio::model::Model& model); | ||
| 75 | boost::optional<openstudio::model::ModelObject> translateConstructAssembly(const pugi::xml_node& element, openstudio::model::Model& model); | ||
| 76 | boost::optional<openstudio::model::ModelObject> translateScheduleDay(const pugi::xml_node& element, openstudio::model::Model& model); | ||
| 77 | boost::optional<openstudio::model::ModelObject> translateScheduleWeek(const pugi::xml_node& element, openstudio::model::Model& model); | ||
| 78 | boost::optional<openstudio::model::ModelObject> translateSchedule(const pugi::xml_node& element, openstudio::model::Model& model); | ||
| 79 | boost::optional<openstudio::model::ModelObject> translateHoliday(const pugi::xml_node& element, openstudio::model::Model& model); | ||
| 80 | boost::optional<openstudio::model::ModelObject> translateDoorConstruction(const pugi::xml_node& element, openstudio::model::Model& model); | ||
| 81 | boost::optional<openstudio::model::ModelObject> translateFenestrationConstruction(const pugi::xml_node& element, openstudio::model::Model& model); | ||
| 82 | boost::optional<openstudio::model::ModelObject> translateCrvCubic(const pugi::xml_node& element, openstudio::model::Model& model); | ||
| 83 | boost::optional<openstudio::model::ModelObject> translateCrvDblQuad(const pugi::xml_node& element, openstudio::model::Model& model); | ||
| 84 | boost::optional<openstudio::model::ModelObject> translateCrvQuad(const pugi::xml_node& element, openstudio::model::Model& model); | ||
| 85 | boost::optional<openstudio::model::ModelObject> translateCrvLin(const pugi::xml_node& element, openstudio::model::Model& model); | ||
| 86 | boost::optional<openstudio::model::ModelObject> translateCrvMapSglVar(const pugi::xml_node& element, openstudio::model::Model& model); | ||
| 87 | boost::optional<openstudio::model::ModelObject> translateCrvMapDblVar(const pugi::xml_node& element, openstudio::model::Model& model); | ||
| 88 | boost::optional<openstudio::model::ModelObject> translateCoilCoolingDXVariableRefrigerantFlow(const pugi::xml_node& element, | ||
| 89 | openstudio::model::Model& model); | ||
| 90 | boost::optional<openstudio::model::ModelObject> translateCoilHeatingDXVariableRefrigerantFlow(const pugi::xml_node& element, | ||
| 91 | openstudio::model::Model& model); | ||
| 92 | boost::optional<openstudio::model::ModelObject> translateFluidSys(const pugi::xml_node& element, openstudio::model::Model& model); | ||
| 93 | boost::optional<openstudio::model::ModelObject> translatePump(const pugi::xml_node& element, openstudio::model::Model& model); | ||
| 94 | boost::optional<openstudio::model::ModelObject> translateBoiler(const pugi::xml_node& element, openstudio::model::Model& model); | ||
| 95 | boost::optional<openstudio::model::ModelObject> translateChiller(const pugi::xml_node& element, openstudio::model::Model& model); | ||
| 96 | boost::optional<openstudio::model::ModelObject> translateThrmlEngyStor(const pugi::xml_node& element, openstudio::model::Model& model); | ||
| 97 | boost::optional<openstudio::model::ModelObject> translateWtrHtr(const pugi::xml_node& element, openstudio::model::Model& model); | ||
| 98 | boost::optional<openstudio::model::ModelObject> translateHtRej(const pugi::xml_node& element, openstudio::model::Model& model); | ||
| 99 | boost::optional<openstudio::model::ModelObject> translateHX(const pugi::xml_node& element, openstudio::model::Model& model); | ||
| 100 | boost::optional<openstudio::model::ModelObject> translateBuilding(const pugi::xml_node& element, openstudio::model::Model& model); | ||
| 101 | boost::optional<openstudio::model::ModelObject> createSpace(const pugi::xml_node& element, openstudio::model::Model& model); | ||
| 102 | boost::optional<openstudio::model::ModelObject> createThermalZone(const pugi::xml_node& element, openstudio::model::Model& model); | ||
| 103 | boost::optional<openstudio::model::ModelObject> translateBuildingStory(const pugi::xml_node& element, openstudio::model::Model& model); | ||
| 104 | boost::optional<openstudio::model::ModelObject> translateSpace(const pugi::xml_node& element, openstudio::model::BuildingStory& buildingStory); | ||
| 105 | boost::optional<openstudio::model::ModelObject> translateLoads(const pugi::xml_node& element, openstudio::model::Space& space); | ||
| 106 | boost::optional<openstudio::model::ModelObject> translateConvectionCoefficients(const pugi::xml_node& element, | ||
| 107 | openstudio::model::PlanarSurface& surface); | ||
| 108 | boost::optional<openstudio::model::ModelObject> translateSurface(const pugi::xml_node& element, openstudio::model::Space& space); | ||
| 109 | boost::optional<openstudio::model::ModelObject> translateSubSurface(const pugi::xml_node& element, openstudio::model::Surface& surface); | ||
| 110 | boost::optional<openstudio::model::ModelObject> translateShadingSurface(const pugi::xml_node& element, | ||
| 111 | openstudio::model::ShadingSurfaceGroup& shadingSurfaceGroup); | ||
| 112 | boost::optional<openstudio::model::ModelObject> translateAirSystem(const pugi::xml_node& element, openstudio::model::Model& model); | ||
| 113 | boost::optional<openstudio::model::ModelObject> translateCoilCooling(const pugi::xml_node& element, openstudio::model::Model& model); | ||
| 114 | boost::optional<openstudio::model::ModelObject> translateCoilHeating(const pugi::xml_node& element, openstudio::model::Model& model); | ||
| 115 | boost::optional<openstudio::model::ModelObject> translateEvapClr(const pugi::xml_node& element, openstudio::model::Model& model); | ||
| 116 | boost::optional<openstudio::model::ModelObject> translateFan(const pugi::xml_node& element, openstudio::model::Model& model); | ||
| 117 | boost::optional<openstudio::model::ModelObject> translateHtRcvry(const pugi::xml_node& element, openstudio::model::Model& model); | ||
| 118 | boost::optional<openstudio::model::ModelObject> translateThermalZone(const pugi::xml_node& element, openstudio::model::Model& model); | ||
| 119 | boost::optional<openstudio::model::ModelObject> translateTrmlUnit(const pugi::xml_node& element, openstudio::model::Model& model); | ||
| 120 | boost::optional<openstudio::model::ModelObject> translateVRFSys(const pugi::xml_node& element, openstudio::model::Model& model); | ||
| 121 | boost::optional<openstudio::model::ModelObject> translateZnSys(const pugi::xml_node& element, openstudio::model::Model& model); | ||
| 122 | |||
| 123 | // Looks for a loop in the SDD instance with a segment named like the fluidSegInRefElement.text().as_string() | ||
| 124 | // fluidSegInRefElement must correspond to the primary/secondary SUPPLY segment. If the object is supposed to be in the demand side | ||
| 125 | // it's usually the 'FluidSegInRef' key (demand means the inlet is the supply, the outlet is the return) | ||
| 126 | // If found then looks for a model::Loop with that name and returns it | ||
| 127 | // This is useful for hooking water coils up to their plant and maybe other things. | ||
| 128 | boost::optional<model::PlantLoop> loopForSupplySegment(const pugi::xml_node& fluidSegInRefElement, openstudio::model::Model& model); | ||
| 129 | |||
| 130 | // Return the supply segment by the fluidSegInRefElement's text | ||
| 131 | pugi::xml_node supplySegment(const pugi::xml_node& fluidSegInRefElement); | ||
| 132 | |||
| 133 | // Returns the ServiceHotWater loop in the SDD instance with a segment named like the fluidSegInRefElement.text().as_string() | ||
| 134 | // // If the loop is not found in the model, this function will attempt to translate it out of the SDD. | ||
| 135 | // If the loop is found in the model it will simply be returned. | ||
| 136 | boost::optional<model::PlantLoop> serviceHotWaterLoopForSupplySegment(const pugi::xml_node& fluidSegInRefElement, | ||
| 137 | openstudio::model::Model& model); | ||
| 138 | |||
| 139 | // Return the "ZnSys" element with the name matching the znSysRefElement.text().as_string() | ||
| 140 | pugi::xml_node findZnSysElement(const pugi::xml_node& znSysRefElement); | ||
| 141 | |||
| 142 | // Find the AirSys element that is named like the airSyRefElement.text().as_string() | ||
| 143 | pugi::xml_node findAirSysElement(const pugi::xml_node& airSyRefElement); | ||
| 144 | // projectElement has to be the 'Proj' one | ||
| 145 | pugi::xml_node findAirSysElement(const std::string& airSysName, const pugi::xml_node& projectElement); | ||
| 146 | |||
| 147 | // Return the "TrmlUnit" element serving a zone named znNameElement.text().as_string() | ||
| 148 | pugi::xml_node findTrmlUnitElementForZone(const pugi::xml_node& znNameElement); | ||
| 149 | |||
| 150 | model::Schedule defaultDeckTempSchedule(openstudio::model::Model& model); | ||
| 151 | boost::optional<model::Schedule> m_defaultDeckTempSchedule; | ||
| 152 | |||
| 153 | model::Schedule hotWaterPlantSetpointSchedule(openstudio::model::Model& model); | ||
| 154 | boost::optional<model::Schedule> m_hotWaterPlantSetpointSchedule; | ||
| 155 | |||
| 156 | model::Schedule chilledWaterPlantSetpointSchedule(openstudio::model::Model& model); | ||
| 157 | boost::optional<model::Schedule> m_chilledWaterPlantSetpointSchedule; | ||
| 158 | |||
| 159 | model::Schedule serviceHotWaterSetpointSchedule(openstudio::model::Model& model); | ||
| 160 | boost::optional<model::Schedule> m_serviceHotWaterSetpointSchedule; | ||
| 161 | |||
| 162 | model::ConstructionBase shadingConstruction(openstudio::model::Model& model, double solRefl, double visRefl); | ||
| 163 | std::map<std::pair<double, double>, model::ConstructionBase> m_shadingConstructionMap; | ||
| 164 | |||
| 165 | model::Schedule shadingSchedule(openstudio::model::Model& model, double trans); | ||
| 166 | std::map<double, model::Schedule> m_shadingScheduleMap; | ||
| 167 | |||
| 168 | //helper method to do unit conversions; probably should be in OS proper | ||
| 169 | boost::optional<double> unitToUnit(double val, const std::string& ipUnitString, const std::string& siUnitString); | ||
| 170 | |||
| 171 | bool m_isInputXML; | ||
| 172 | |||
| 173 | bool autosize() const; | ||
| 174 | |||
| 175 | bool m_autosize; | ||
| 176 | |||
| 177 | bool m_masterAutosize; | ||
| 178 | |||
| 179 | StringStreamLogSink m_logSink; | ||
| 180 | |||
| 181 | openstudio::path m_path; | ||
| 182 | |||
| 183 | ProgressBar* m_progressBar; | ||
| 184 | |||
| 185 | // This is storage to match control zones with optimum start AVMs | ||
| 186 | // This is used because the ThermalZone instances are not yet created when | ||
| 187 | // the air system and AVMs are translated. | ||
| 188 | // This map is populated when the air systems are translated, | ||
| 189 | // then used to add the control zones when the zones are translated later. | ||
| 190 | // The map is zone name => AVM | ||
| 191 | std::map<std::string, model::AvailabilityManagerOptimumStart> m_optimumStartControlZones; | ||
| 192 | |||
| 193 | // Similar to m_optimumStartControlZones but for night cycle manager | ||
| 194 | std::map<std::string, model::AvailabilityManagerNightCycle> m_nightCycleControlZones; | ||
| 195 | |||
| 196 | // Map from vrf system to master control zone name | ||
| 197 | std::map<std::string, model::AirConditionerVariableRefrigerantFlow> m_vrfSystemControlZones; | ||
| 198 | |||
| 199 | − | REGISTER_LOGGER("openstudio.sdd.ReverseTranslator"); | |
| 200 | }; | ||
| 201 | |||
| 202 | } // namespace sdd | ||
| 203 | } // namespace openstudio | ||
| 204 | |||
| 205 | #endif // SDD_REVERSETRANSLATOR_HPP | ||
| 206 |