src/energyplus/ReverseTranslator/ReverseTranslateSwimmingPoolIndoor.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/SwimmingPoolIndoor.hpp" | ||
| 9 | |||
| 10 | #include "../../model/Surface.hpp" | ||
| 11 | #include "../../model/Surface_Impl.hpp" | ||
| 12 | |||
| 13 | #include "../../model/Schedule.hpp" | ||
| 14 | #include "../../model/Schedule_Impl.hpp" | ||
| 15 | |||
| 16 | #include "../../model/Node.hpp" | ||
| 17 | #include "../../model/Node_Impl.hpp" | ||
| 18 | |||
| 19 | #include <utilities/idd/SwimmingPool_Indoor_FieldEnums.hxx> | ||
| 20 | #include <utilities/idd/IddEnums.hxx> | ||
| 21 | |||
| 22 | using namespace openstudio::model; | ||
| 23 | |||
| 24 | namespace openstudio { | ||
| 25 | |||
| 26 | namespace energyplus { | ||
| 27 | |||
| 28 | ✗ | boost::optional<ModelObject> ReverseTranslator::translateSwimmingPoolIndoor(const WorkspaceObject& workspaceObject) { | |
| 29 | ✗ | boost::optional<WorkspaceObject> _wo; | |
| 30 | ✗ | boost::optional<ModelObject> _mo; | |
| 31 | |||
| 32 | // Surface Name: Required Object, and as Ctor arg. And will throw if not the right SurfaceType... | ||
| 33 | ✗ | boost::optional<Surface> _surface; | |
| 34 | ✗ | if ((_wo = workspaceObject.getTarget(SwimmingPool_IndoorFields::SurfaceName))) { | |
| 35 | ✗ | if ((_mo = translateAndMapWorkspaceObject(_wo.get()))) { | |
| 36 | // TODO: check return types | ||
| 37 | ✗ | if ((_surface = _mo->optionalCast<Surface>())) { | |
| 38 | ✗ | if (_surface->surfaceType() != "Floor") { | |
| 39 | ✗ | LOG(Warn, workspaceObject.briefDescription() << " has a surface assigned, but it is NOT of type 'Floor' like it should"); | |
| 40 | ✗ | return ::boost::none; | |
| 41 | } | ||
| 42 | } else { | ||
| 43 | ✗ | LOG(Warn, workspaceObject.briefDescription() << " has a wrong type for 'Surface Name'"); | |
| 44 | ✗ | return boost::none; | |
| 45 | } | ||
| 46 | } else { | ||
| 47 | ✗ | LOG(Error, "For " << workspaceObject.briefDescription() << ", cannot reverse translate required object 'Surface Name'"); | |
| 48 | ✗ | return boost::none; | |
| 49 | } | ||
| 50 | } else { | ||
| 51 | ✗ | LOG(Error, "For " << workspaceObject.briefDescription() << ", cannot find required object 'Surface Name'"); | |
| 52 | ✗ | return boost::none; | |
| 53 | } | ||
| 54 | |||
| 55 | // Instantiate an object of the class to store the values, | ||
| 56 | // but we don't return it until we know it's ok | ||
| 57 | ✗ | openstudio::model::SwimmingPoolIndoor modelObject(m_model, _surface.get()); | |
| 58 | |||
| 59 | // Name | ||
| 60 | ✗ | if (boost::optional<std::string> _name = workspaceObject.name()) { | |
| 61 | ✗ | modelObject.setName(_name.get()); | |
| 62 | ✗ | } | |
| 63 | |||
| 64 | // Average Depth: Required Double | ||
| 65 | ✗ | if (boost::optional<double> _averageDepth = workspaceObject.getDouble(SwimmingPool_IndoorFields::AverageDepth)) { | |
| 66 | ✗ | modelObject.setAverageDepth(_averageDepth.get()); | |
| 67 | } else { | ||
| 68 | ✗ | LOG(Warn, "For " << workspaceObject.briefDescription() << ", cannot find required property 'Average Depth', using default"); | |
| 69 | ✗ | return boost::none; | |
| 70 | } | ||
| 71 | |||
| 72 | // Activity Factor Schedule Name: Required Object | ||
| 73 | ✗ | if ((_wo = workspaceObject.getTarget(SwimmingPool_IndoorFields::ActivityFactorScheduleName))) { | |
| 74 | ✗ | if ((_mo = translateAndMapWorkspaceObject(_wo.get()))) { | |
| 75 | ✗ | if (boost::optional<Schedule> _activityFactorSchedule = _mo->optionalCast<Schedule>()) { | |
| 76 | ✗ | modelObject.setActivityFactorSchedule(_activityFactorSchedule.get()); | |
| 77 | } else { | ||
| 78 | ✗ | LOG(Warn, workspaceObject.briefDescription() << " has a wrong type for 'Activity Factor Schedule Name'"); | |
| 79 | ✗ | } | |
| 80 | } else { | ||
| 81 | ✗ | LOG(Error, "For " << workspaceObject.briefDescription() << ", cannot reverse translate required object 'Activity Factor Schedule Name'"); | |
| 82 | ✗ | return boost::none; | |
| 83 | } | ||
| 84 | } else { | ||
| 85 | ✗ | LOG(Error, "For " << workspaceObject.briefDescription() << ", cannot find required object 'Activity Factor Schedule Name'"); | |
| 86 | ✗ | return boost::none; | |
| 87 | } | ||
| 88 | // Make-up Water Supply Schedule Name: Required Object | ||
| 89 | ✗ | if ((_wo = workspaceObject.getTarget(SwimmingPool_IndoorFields::MakeupWaterSupplyScheduleName))) { | |
| 90 | ✗ | if ((_mo = translateAndMapWorkspaceObject(_wo.get()))) { | |
| 91 | ✗ | if (boost::optional<Schedule> _makeupWaterSupplySchedule = _mo->optionalCast<Schedule>()) { | |
| 92 | ✗ | modelObject.setMakeupWaterSupplySchedule(_makeupWaterSupplySchedule.get()); | |
| 93 | } else { | ||
| 94 | ✗ | LOG(Warn, workspaceObject.briefDescription() << " has a wrong type for 'Make-up Water Supply Schedule Name'"); | |
| 95 | ✗ | } | |
| 96 | } else { | ||
| 97 | ✗ | LOG(Error, "For " << workspaceObject.briefDescription() << ", cannot reverse translate required object 'Make-up Water Supply Schedule Name'"); | |
| 98 | ✗ | return boost::none; | |
| 99 | } | ||
| 100 | } else { | ||
| 101 | ✗ | LOG(Error, "For " << workspaceObject.briefDescription() << ", cannot find required object 'Make-up Water Supply Schedule Name'"); | |
| 102 | ✗ | return boost::none; | |
| 103 | } | ||
| 104 | // Cover Schedule Name: Required Object | ||
| 105 | ✗ | if ((_wo = workspaceObject.getTarget(SwimmingPool_IndoorFields::CoverScheduleName))) { | |
| 106 | ✗ | if ((_mo = translateAndMapWorkspaceObject(_wo.get()))) { | |
| 107 | ✗ | if (boost::optional<Schedule> _coverSchedule = _mo->optionalCast<Schedule>()) { | |
| 108 | ✗ | modelObject.setCoverSchedule(_coverSchedule.get()); | |
| 109 | } else { | ||
| 110 | ✗ | LOG(Warn, workspaceObject.briefDescription() << " has a wrong type for 'Cover Schedule Name'"); | |
| 111 | ✗ | } | |
| 112 | } else { | ||
| 113 | ✗ | LOG(Error, "For " << workspaceObject.briefDescription() << ", cannot reverse translate required object 'Cover Schedule Name'"); | |
| 114 | ✗ | return boost::none; | |
| 115 | } | ||
| 116 | } else { | ||
| 117 | ✗ | LOG(Error, "For " << workspaceObject.briefDescription() << ", cannot find required object 'Cover Schedule Name'"); | |
| 118 | ✗ | return boost::none; | |
| 119 | } | ||
| 120 | // Cover Evaporation Factor: Optional Double | ||
| 121 | ✗ | if (boost::optional<double> _coverEvaporationFactor = workspaceObject.getDouble(SwimmingPool_IndoorFields::CoverEvaporationFactor)) { | |
| 122 | ✗ | modelObject.setCoverEvaporationFactor(_coverEvaporationFactor.get()); | |
| 123 | } | ||
| 124 | |||
| 125 | // Cover Convection Factor: Optional Double | ||
| 126 | ✗ | if (boost::optional<double> _coverConvectionFactor = workspaceObject.getDouble(SwimmingPool_IndoorFields::CoverConvectionFactor)) { | |
| 127 | ✗ | modelObject.setCoverConvectionFactor(_coverConvectionFactor.get()); | |
| 128 | } | ||
| 129 | |||
| 130 | // Cover Short-Wavelength Radiation Factor: Optional Double | ||
| 131 | ✗ | if (boost::optional<double> _coverShortWavelengthRadiationFactor = | |
| 132 | ✗ | workspaceObject.getDouble(SwimmingPool_IndoorFields::CoverShortWavelengthRadiationFactor)) { | |
| 133 | ✗ | modelObject.setCoverShortWavelengthRadiationFactor(_coverShortWavelengthRadiationFactor.get()); | |
| 134 | } | ||
| 135 | |||
| 136 | // Cover Long-Wavelength Radiation Factor: Optional Double | ||
| 137 | ✗ | if (boost::optional<double> _coverLongWavelengthRadiationFactor = | |
| 138 | ✗ | workspaceObject.getDouble(SwimmingPool_IndoorFields::CoverLongWavelengthRadiationFactor)) { | |
| 139 | ✗ | modelObject.setCoverLongWavelengthRadiationFactor(_coverLongWavelengthRadiationFactor.get()); | |
| 140 | } | ||
| 141 | |||
| 142 | // Pool Water Inlet Node: Required Node | ||
| 143 | |||
| 144 | // Pool Water Outlet Node: Required Node | ||
| 145 | |||
| 146 | // Pool Heating System Maximum Water Flow Rate: Optional Double | ||
| 147 | ✗ | if (boost::optional<double> _poolHeatingSystemMaximumWaterFlowRate = | |
| 148 | ✗ | workspaceObject.getDouble(SwimmingPool_IndoorFields::PoolHeatingSystemMaximumWaterFlowRate)) { | |
| 149 | ✗ | modelObject.setPoolHeatingSystemMaximumWaterFlowRate(_poolHeatingSystemMaximumWaterFlowRate.get()); | |
| 150 | } | ||
| 151 | |||
| 152 | // Pool Miscellaneous Equipment Power: Optional Double | ||
| 153 | ✗ | if (boost::optional<double> _poolMiscellaneousEquipmentPower = | |
| 154 | ✗ | workspaceObject.getDouble(SwimmingPool_IndoorFields::PoolMiscellaneousEquipmentPower)) { | |
| 155 | ✗ | modelObject.setPoolMiscellaneousEquipmentPower(_poolMiscellaneousEquipmentPower.get()); | |
| 156 | } | ||
| 157 | |||
| 158 | // Setpoint Temperature Schedule: Required Object | ||
| 159 | ✗ | if ((_wo = workspaceObject.getTarget(SwimmingPool_IndoorFields::SetpointTemperatureSchedule))) { | |
| 160 | ✗ | if ((_mo = translateAndMapWorkspaceObject(_wo.get()))) { | |
| 161 | ✗ | if (boost::optional<Schedule> _setpointTemperatureSchedule = _mo->optionalCast<Schedule>()) { | |
| 162 | ✗ | modelObject.setSetpointTemperatureSchedule(_setpointTemperatureSchedule.get()); | |
| 163 | } else { | ||
| 164 | ✗ | LOG(Warn, workspaceObject.briefDescription() << " has a wrong type for 'Setpoint Temperature Schedule'"); | |
| 165 | ✗ | } | |
| 166 | } else { | ||
| 167 | ✗ | LOG(Error, "For " << workspaceObject.briefDescription() << ", cannot reverse translate required object 'Setpoint Temperature Schedule'"); | |
| 168 | ✗ | return boost::none; | |
| 169 | } | ||
| 170 | } else { | ||
| 171 | ✗ | LOG(Error, "For " << workspaceObject.briefDescription() << ", cannot find required object 'Setpoint Temperature Schedule'"); | |
| 172 | ✗ | return boost::none; | |
| 173 | } | ||
| 174 | // Maximum Number of People: Required Double | ||
| 175 | ✗ | if (boost::optional<double> _maximumNumberofPeople = workspaceObject.getDouble(SwimmingPool_IndoorFields::MaximumNumberofPeople)) { | |
| 176 | ✗ | modelObject.setMaximumNumberofPeople(_maximumNumberofPeople.get()); | |
| 177 | } else { | ||
| 178 | ✗ | LOG(Error, "For " << workspaceObject.briefDescription() << ", cannot find required property 'Maximum Number of People'"); | |
| 179 | ✗ | return boost::none; | |
| 180 | } | ||
| 181 | |||
| 182 | // People Schedule: Optional Object | ||
| 183 | ✗ | if ((_wo = workspaceObject.getTarget(SwimmingPool_IndoorFields::PeopleSchedule))) { | |
| 184 | ✗ | if ((_mo = translateAndMapWorkspaceObject(_wo.get()))) { | |
| 185 | ✗ | if (boost::optional<Schedule> _peopleSchedule = _mo->optionalCast<Schedule>()) { | |
| 186 | ✗ | modelObject.setPeopleSchedule(_peopleSchedule.get()); | |
| 187 | } else { | ||
| 188 | ✗ | LOG(Warn, workspaceObject.briefDescription() << " has a wrong type for 'People Schedule'"); | |
| 189 | ✗ | } | |
| 190 | } | ||
| 191 | } | ||
| 192 | // People Heat Gain Schedule: Optional Object | ||
| 193 | ✗ | if ((_wo = workspaceObject.getTarget(SwimmingPool_IndoorFields::PeopleHeatGainSchedule))) { | |
| 194 | ✗ | if ((_mo = translateAndMapWorkspaceObject(_wo.get()))) { | |
| 195 | ✗ | if (boost::optional<Schedule> _peopleHeatGainSchedule = _mo->optionalCast<Schedule>()) { | |
| 196 | ✗ | modelObject.setPeopleHeatGainSchedule(_peopleHeatGainSchedule.get()); | |
| 197 | } else { | ||
| 198 | ✗ | LOG(Warn, workspaceObject.briefDescription() << " has a wrong type for 'People Heat Gain Schedule'"); | |
| 199 | ✗ | } | |
| 200 | } | ||
| 201 | } | ||
| 202 | |||
| 203 | ✗ | return modelObject; | |
| 204 | |||
| 205 | ✗ | } // End of translate function | |
| 206 | |||
| 207 | } // end namespace energyplus | ||
| 208 | } // end namespace openstudio | ||
| 209 |