src/energyplus/ReverseTranslator/ReverseTranslateRefrigerationCase.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 | #include "../../model/RefrigerationCase.hpp" | ||
| 8 | #include "../../model/RefrigerationCase_Impl.hpp" | ||
| 9 | #include "../../model/Schedule.hpp" | ||
| 10 | #include "../../model/Schedule_Impl.hpp" | ||
| 11 | #include "../../model/ThermalZone.hpp" | ||
| 12 | #include "../../model/ThermalZone_Impl.hpp" | ||
| 13 | #include "../../model/CurveCubic.hpp" | ||
| 14 | #include "../../model/CurveCubic_Impl.hpp" | ||
| 15 | #include "../../model/Space.hpp" | ||
| 16 | #include "../../model/Space_Impl.hpp" | ||
| 17 | |||
| 18 | #include <utilities/idd/Refrigeration_Case_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::translateRefrigerationCase(const WorkspaceObject& workspaceObject) { | |
| 29 | ✗ | if (workspaceObject.iddObject().type() != IddObjectType::Refrigeration_Case) { | |
| 30 | ✗ | LOG(Error, "WorkspaceObject is not IddObjectType: Refrigeration_Case"); | |
| 31 | ✗ | return boost::none; | |
| 32 | } | ||
| 33 | |||
| 34 | ✗ | boost::optional<WorkspaceObject> wo = workspaceObject.getTarget(Refrigeration_CaseFields::CaseDefrostScheduleName); | |
| 35 | ✗ | boost::optional<Schedule> caseDefrostSchedule; | |
| 36 | ✗ | boost::optional<RefrigerationCase> refrigerationCase; | |
| 37 | |||
| 38 | ✗ | if (wo) { | |
| 39 | ✗ | if (boost::optional<ModelObject> mo = translateAndMapWorkspaceObject(wo.get())) { | |
| 40 | ✗ | if (!(caseDefrostSchedule = mo->optionalCast<Schedule>())) { | |
| 41 | ✗ | LOG(Error, workspaceObject.briefDescription() << " does not have an associated case defrost schedule"); | |
| 42 | |||
| 43 | ✗ | return boost::none; | |
| 44 | } | ||
| 45 | ✗ | } | |
| 46 | } | ||
| 47 | |||
| 48 | ✗ | if (caseDefrostSchedule) { | |
| 49 | ✗ | refrigerationCase = RefrigerationCase(m_model, caseDefrostSchedule.get()); | |
| 50 | } | ||
| 51 | |||
| 52 | ✗ | if (refrigerationCase) { | |
| 53 | ✗ | boost::optional<double> value; | |
| 54 | ✗ | boost::optional<std::string> s = workspaceObject.getString(Refrigeration_CaseFields::Name); | |
| 55 | |||
| 56 | // Name | ||
| 57 | ✗ | if (s) { | |
| 58 | ✗ | refrigerationCase->setName(s.get()); | |
| 59 | } | ||
| 60 | // AvailabilityScheduleName | ||
| 61 | ✗ | if ((wo = workspaceObject.getTarget(Refrigeration_CaseFields::AvailabilityScheduleName))) { | |
| 62 | ✗ | if (boost::optional<ModelObject> mo = translateAndMapWorkspaceObject(wo.get())) { | |
| 63 | ✗ | if (boost::optional<Schedule> schedule = mo->optionalCast<Schedule>()) { | |
| 64 | ✗ | refrigerationCase->setAvailabilitySchedule(schedule.get()); | |
| 65 | ✗ | } | |
| 66 | ✗ | } | |
| 67 | } | ||
| 68 | // ZoneName | ||
| 69 | ✗ | if ((wo = workspaceObject.getTarget(Refrigeration_CaseFields::ZoneName))) { | |
| 70 | ✗ | if (boost::optional<ModelObject> mo_ = translateAndMapWorkspaceObject(wo.get())) { | |
| 71 | // Zone is translated, and a Space is returned instead | ||
| 72 | ✗ | if (boost::optional<Space> space_ = mo_->optionalCast<Space>()) { | |
| 73 | ✗ | if (auto z_ = space_->thermalZone()) { | |
| 74 | ✗ | refrigerationCase->setThermalZone(z_.get()); | |
| 75 | ✗ | } | |
| 76 | } else { | ||
| 77 | ✗ | LOG(Warn, workspaceObject.briefDescription() << " has a wrong type for 'Zone Name'"); | |
| 78 | ✗ | } | |
| 79 | ✗ | } | |
| 80 | } | ||
| 81 | |||
| 82 | // RatedAmbientTemperature | ||
| 83 | ✗ | value = workspaceObject.getDouble(Refrigeration_CaseFields::RatedAmbientTemperature); | |
| 84 | ✗ | if (value) { | |
| 85 | ✗ | refrigerationCase->setRatedAmbientTemperature(value.get()); | |
| 86 | } | ||
| 87 | // RatedAmbientRelativeHumidity | ||
| 88 | ✗ | value = workspaceObject.getDouble(Refrigeration_CaseFields::RatedAmbientRelativeHumidity); | |
| 89 | ✗ | if (value) { | |
| 90 | ✗ | refrigerationCase->setRatedAmbientRelativeHumidity(value.get()); | |
| 91 | } | ||
| 92 | // RatedTotalCoolingCapacityperUnitLength | ||
| 93 | ✗ | value = workspaceObject.getDouble(Refrigeration_CaseFields::RatedTotalCoolingCapacityperUnitLength); | |
| 94 | ✗ | if (value) { | |
| 95 | ✗ | refrigerationCase->setRatedTotalCoolingCapacityperUnitLength(value.get()); | |
| 96 | } | ||
| 97 | // RatedLatentHeatRatio | ||
| 98 | ✗ | value = workspaceObject.getDouble(Refrigeration_CaseFields::RatedLatentHeatRatio); | |
| 99 | ✗ | if (value) { | |
| 100 | ✗ | refrigerationCase->setRatedLatentHeatRatio(value.get()); | |
| 101 | } | ||
| 102 | // RatedRuntimeFraction | ||
| 103 | ✗ | value = workspaceObject.getDouble(Refrigeration_CaseFields::RatedRuntimeFraction); | |
| 104 | ✗ | if (value) { | |
| 105 | ✗ | refrigerationCase->setRatedRuntimeFraction(value.get()); | |
| 106 | } | ||
| 107 | // CaseLength | ||
| 108 | ✗ | value = workspaceObject.getDouble(Refrigeration_CaseFields::CaseLength); | |
| 109 | ✗ | if (value) { | |
| 110 | ✗ | refrigerationCase->setCaseLength(value.get()); | |
| 111 | } | ||
| 112 | // CaseOperatingTemperature | ||
| 113 | ✗ | value = workspaceObject.getDouble(Refrigeration_CaseFields::CaseOperatingTemperature); | |
| 114 | ✗ | if (value) { | |
| 115 | ✗ | refrigerationCase->setCaseOperatingTemperature(value.get()); | |
| 116 | } | ||
| 117 | // LatentCaseCreditCurveType | ||
| 118 | ✗ | s = workspaceObject.getString(Refrigeration_CaseFields::LatentCaseCreditCurveType); | |
| 119 | ✗ | if (s) { | |
| 120 | ✗ | refrigerationCase->setLatentCaseCreditCurveType(s.get()); | |
| 121 | } | ||
| 122 | // LatentCaseCreditCurveName | ||
| 123 | ✗ | if ((wo = workspaceObject.getTarget(Refrigeration_CaseFields::LatentCaseCreditCurveName))) { | |
| 124 | ✗ | if (boost::optional<ModelObject> mo = translateAndMapWorkspaceObject(wo.get())) { | |
| 125 | ✗ | if (boost::optional<CurveCubic> curve = mo->optionalCast<CurveCubic>()) { | |
| 126 | ✗ | refrigerationCase->setLatentCaseCreditCurve(curve.get()); | |
| 127 | ✗ | } | |
| 128 | ✗ | } | |
| 129 | } | ||
| 130 | // StandardCaseFanPowerperUnitLength | ||
| 131 | ✗ | value = workspaceObject.getDouble(Refrigeration_CaseFields::StandardCaseFanPowerperUnitLength); | |
| 132 | ✗ | if (value) { | |
| 133 | ✗ | refrigerationCase->setStandardCaseFanPowerperUnitLength(value.get()); | |
| 134 | } | ||
| 135 | // OperatingCaseFanPowerperUnitLength | ||
| 136 | ✗ | value = workspaceObject.getDouble(Refrigeration_CaseFields::OperatingCaseFanPowerperUnitLength); | |
| 137 | ✗ | if (value) { | |
| 138 | ✗ | refrigerationCase->setOperatingCaseFanPowerperUnitLength(value.get()); | |
| 139 | } | ||
| 140 | // StandardCaseLightingPowerperUnitLength | ||
| 141 | ✗ | value = workspaceObject.getDouble(Refrigeration_CaseFields::StandardCaseLightingPowerperUnitLength); | |
| 142 | ✗ | if (value) { | |
| 143 | ✗ | refrigerationCase->setStandardCaseLightingPowerperUnitLength(value.get()); | |
| 144 | } | ||
| 145 | // InstalledCaseLightingPowerperUnitLength | ||
| 146 | ✗ | value = workspaceObject.getDouble(Refrigeration_CaseFields::InstalledCaseLightingPowerperUnitLength); | |
| 147 | ✗ | if (value) { | |
| 148 | ✗ | refrigerationCase->setInstalledCaseLightingPowerperUnitLength(value.get()); | |
| 149 | } | ||
| 150 | // CaseLightingScheduleName | ||
| 151 | ✗ | if ((wo = workspaceObject.getTarget(Refrigeration_CaseFields::CaseLightingScheduleName))) { | |
| 152 | ✗ | if (boost::optional<ModelObject> mo = translateAndMapWorkspaceObject(wo.get())) { | |
| 153 | ✗ | if (boost::optional<Schedule> schedule = mo->optionalCast<Schedule>()) { | |
| 154 | ✗ | refrigerationCase->setCaseLightingSchedule(schedule.get()); | |
| 155 | ✗ | } | |
| 156 | ✗ | } | |
| 157 | } | ||
| 158 | // FractionofLightingEnergytoCase | ||
| 159 | ✗ | value = workspaceObject.getDouble(Refrigeration_CaseFields::FractionofLightingEnergytoCase); | |
| 160 | ✗ | if (value) { | |
| 161 | ✗ | refrigerationCase->setFractionofLightingEnergytoCase(value.get()); | |
| 162 | } | ||
| 163 | // CaseAntiSweatHeaterPowerperUnitLength | ||
| 164 | ✗ | value = workspaceObject.getDouble(Refrigeration_CaseFields::CaseAntiSweatHeaterPowerperUnitLength); | |
| 165 | ✗ | if (value) { | |
| 166 | ✗ | refrigerationCase->setCaseAntiSweatHeaterPowerperUnitLength(value.get()); | |
| 167 | } | ||
| 168 | // MinimumAntiSweatHeaterPowerperUnitLength | ||
| 169 | ✗ | value = workspaceObject.getDouble(Refrigeration_CaseFields::MinimumAntiSweatHeaterPowerperUnitLength); | |
| 170 | ✗ | if (value) { | |
| 171 | ✗ | refrigerationCase->setMinimumAntiSweatHeaterPowerperUnitLength(value.get()); | |
| 172 | } | ||
| 173 | // AntiSweatHeaterControlType | ||
| 174 | ✗ | s = workspaceObject.getString(Refrigeration_CaseFields::AntiSweatHeaterControlType); | |
| 175 | ✗ | if (s) { | |
| 176 | ✗ | refrigerationCase->setAntiSweatHeaterControlType(s.get()); | |
| 177 | } | ||
| 178 | // HumidityatZeroAntiSweatHeaterEnergy | ||
| 179 | ✗ | value = workspaceObject.getDouble(Refrigeration_CaseFields::HumidityatZeroAntiSweatHeaterEnergy); | |
| 180 | ✗ | if (value) { | |
| 181 | ✗ | refrigerationCase->setHumidityatZeroAntiSweatHeaterEnergy(value.get()); | |
| 182 | } | ||
| 183 | // CaseHeight | ||
| 184 | ✗ | value = workspaceObject.getDouble(Refrigeration_CaseFields::CaseHeight); | |
| 185 | ✗ | if (value) { | |
| 186 | ✗ | refrigerationCase->setCaseHeight(value.get()); | |
| 187 | } | ||
| 188 | // FractionofAntiSweatHeaterEnergytoCase | ||
| 189 | ✗ | value = workspaceObject.getDouble(Refrigeration_CaseFields::FractionofAntiSweatHeaterEnergytoCase); | |
| 190 | ✗ | if (value) { | |
| 191 | ✗ | refrigerationCase->setFractionofAntiSweatHeaterEnergytoCase(value.get()); | |
| 192 | } | ||
| 193 | // CaseDefrostPowerperUnitLength | ||
| 194 | ✗ | value = workspaceObject.getDouble(Refrigeration_CaseFields::CaseDefrostPowerperUnitLength); | |
| 195 | ✗ | if (value) { | |
| 196 | ✗ | refrigerationCase->setCaseDefrostPowerperUnitLength(value.get()); | |
| 197 | } | ||
| 198 | // CaseDefrostType | ||
| 199 | ✗ | s = workspaceObject.getString(Refrigeration_CaseFields::CaseDefrostType); | |
| 200 | ✗ | if (s) { | |
| 201 | ✗ | refrigerationCase->setCaseDefrostType(s.get()); | |
| 202 | } | ||
| 203 | // CaseDefrostScheduleName | ||
| 204 | ✗ | if ((wo = workspaceObject.getTarget(Refrigeration_CaseFields::CaseDefrostScheduleName))) { | |
| 205 | ✗ | if (boost::optional<ModelObject> mo = translateAndMapWorkspaceObject(wo.get())) { | |
| 206 | ✗ | if (boost::optional<Schedule> schedule = mo->optionalCast<Schedule>()) { | |
| 207 | ✗ | refrigerationCase->setCaseDefrostSchedule(schedule.get()); | |
| 208 | ✗ | } | |
| 209 | ✗ | } | |
| 210 | } | ||
| 211 | // CaseDefrostDripDownScheduleName | ||
| 212 | ✗ | if ((wo = workspaceObject.getTarget(Refrigeration_CaseFields::CaseDefrostDripDownScheduleName))) { | |
| 213 | ✗ | if (boost::optional<ModelObject> mo = translateAndMapWorkspaceObject(wo.get())) { | |
| 214 | ✗ | if (boost::optional<Schedule> schedule = mo->optionalCast<Schedule>()) { | |
| 215 | ✗ | refrigerationCase->setCaseDefrostDripDownSchedule(schedule.get()); | |
| 216 | ✗ | } | |
| 217 | ✗ | } | |
| 218 | } | ||
| 219 | // DefrostEnergyCorrectionCurveType | ||
| 220 | ✗ | s = workspaceObject.getString(Refrigeration_CaseFields::DefrostEnergyCorrectionCurveType); | |
| 221 | ✗ | if (s) { | |
| 222 | ✗ | refrigerationCase->setDefrostEnergyCorrectionCurveType(s.get()); | |
| 223 | } | ||
| 224 | // DefrostEnergyCorrectionCurveName | ||
| 225 | ✗ | if ((wo = workspaceObject.getTarget(Refrigeration_CaseFields::DefrostEnergyCorrectionCurveName))) { | |
| 226 | ✗ | if (boost::optional<ModelObject> mo = translateAndMapWorkspaceObject(wo.get())) { | |
| 227 | ✗ | if (boost::optional<CurveCubic> curve = mo->optionalCast<CurveCubic>()) { | |
| 228 | ✗ | refrigerationCase->setDefrostEnergyCorrectionCurve(curve.get()); | |
| 229 | ✗ | } | |
| 230 | ✗ | } | |
| 231 | } | ||
| 232 | // UnderCaseHVACReturnAirFraction | ||
| 233 | ✗ | value = workspaceObject.getDouble(Refrigeration_CaseFields::UnderCaseHVACReturnAirFraction); | |
| 234 | ✗ | if (value) { | |
| 235 | ✗ | refrigerationCase->setUnderCaseHVACReturnAirFraction(value.get()); | |
| 236 | } | ||
| 237 | // RefrigeratedCaseRestockingScheduleName | ||
| 238 | ✗ | if ((wo = workspaceObject.getTarget(Refrigeration_CaseFields::RefrigeratedCaseRestockingScheduleName))) { | |
| 239 | ✗ | if (boost::optional<ModelObject> mo = translateAndMapWorkspaceObject(wo.get())) { | |
| 240 | ✗ | if (boost::optional<Schedule> schedule = mo->optionalCast<Schedule>()) { | |
| 241 | ✗ | refrigerationCase->setRefrigeratedCaseRestockingSchedule(schedule.get()); | |
| 242 | ✗ | } | |
| 243 | ✗ | } | |
| 244 | } | ||
| 245 | // CaseCreditFractionScheduleName | ||
| 246 | ✗ | if ((wo = workspaceObject.getTarget(Refrigeration_CaseFields::CaseCreditFractionScheduleName))) { | |
| 247 | ✗ | if (boost::optional<ModelObject> mo = translateAndMapWorkspaceObject(wo.get())) { | |
| 248 | ✗ | if (boost::optional<Schedule> schedule = mo->optionalCast<Schedule>()) { | |
| 249 | ✗ | refrigerationCase->setCaseCreditFractionSchedule(schedule.get()); | |
| 250 | ✗ | } | |
| 251 | ✗ | } | |
| 252 | } | ||
| 253 | // DesignEvaporatorTemperatureorBrineInletTemperature | ||
| 254 | ✗ | value = workspaceObject.getDouble(Refrigeration_CaseFields::DesignEvaporatorTemperatureorBrineInletTemperature); | |
| 255 | ✗ | if (value) { | |
| 256 | ✗ | refrigerationCase->setDesignEvaporatorTemperatureorBrineInletTemperature(value.get()); | |
| 257 | } | ||
| 258 | // AverageRefrigerantChargeInventory | ||
| 259 | ✗ | value = workspaceObject.getDouble(Refrigeration_CaseFields::AverageRefrigerantChargeInventory); | |
| 260 | ✗ | if (value) { | |
| 261 | ✗ | refrigerationCase->setAverageRefrigerantChargeInventory(value.get()); | |
| 262 | } | ||
| 263 | |||
| 264 | ✗ | return refrigerationCase.get(); | |
| 265 | ✗ | } else { | |
| 266 | ✗ | LOG(Error, "Unknown error translating " << workspaceObject.briefDescription()); | |
| 267 | |||
| 268 | ✗ | return boost::none; | |
| 269 | } | ||
| 270 | ✗ | } | |
| 271 | |||
| 272 | } // namespace energyplus | ||
| 273 | |||
| 274 | } // namespace openstudio | ||
| 275 |