src/energyplus/ReverseTranslator/ReverseTranslateHotWaterEquipment.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/HotWaterEquipment.hpp" | ||
| 9 | #include "../../model/HotWaterEquipment_Impl.hpp" | ||
| 10 | #include "../../model/HotWaterEquipmentDefinition.hpp" | ||
| 11 | #include "../../model/HotWaterEquipmentDefinition_Impl.hpp" | ||
| 12 | #include "../../model/Space.hpp" | ||
| 13 | #include "../../model/Space_Impl.hpp" | ||
| 14 | #include "../../model/SpaceType.hpp" | ||
| 15 | #include "../../model/SpaceType_Impl.hpp" | ||
| 16 | #include "../../model/Schedule.hpp" | ||
| 17 | #include "../../model/Schedule_Impl.hpp" | ||
| 18 | |||
| 19 | #include <utilities/idd/HotWaterEquipment_FieldEnums.hxx> | ||
| 20 | #include "../../utilities/idd/IddEnums.hpp" | ||
| 21 | #include <utilities/idd/IddEnums.hxx> | ||
| 22 | |||
| 23 | #include "../../utilities/core/Assert.hpp" | ||
| 24 | |||
| 25 | using namespace openstudio::model; | ||
| 26 | |||
| 27 | namespace openstudio { | ||
| 28 | |||
| 29 | namespace energyplus { | ||
| 30 | |||
| 31 | ✗ | OptionalModelObject ReverseTranslator::translateHotWaterEquipment(const WorkspaceObject& workspaceObject) { | |
| 32 | ✗ | if (workspaceObject.iddObject().type() != IddObjectType::HotWaterEquipment) { | |
| 33 | ✗ | LOG(Error, "WorkspaceObject is not IddObjectType::HotWaterEquipment"); | |
| 34 | ✗ | return boost::none; | |
| 35 | } | ||
| 36 | |||
| 37 | ✗ | LOG(Info, "HotWaterEquipment is an internal load separate from any plant loop or water system, " | |
| 38 | << "and should not be used in models for which water use is an important output."); | ||
| 39 | |||
| 40 | // create the definition | ||
| 41 | ✗ | openstudio::model::HotWaterEquipmentDefinition definition(m_model); | |
| 42 | |||
| 43 | ✗ | OptionalString s = workspaceObject.name(); | |
| 44 | ✗ | if (s) { | |
| 45 | ✗ | definition.setName(*s + " Definition"); | |
| 46 | } | ||
| 47 | |||
| 48 | ✗ | s = workspaceObject.getString(openstudio::HotWaterEquipmentFields::DesignLevelCalculationMethod, true); | |
| 49 | ✗ | OS_ASSERT(s); | |
| 50 | |||
| 51 | ✗ | OptionalDouble d; | |
| 52 | ✗ | if (istringEqual("EquipmentLevel", *s)) { | |
| 53 | ✗ | d = workspaceObject.getDouble(openstudio::HotWaterEquipmentFields::DesignLevel); | |
| 54 | ✗ | if (d) { | |
| 55 | ✗ | definition.setDesignLevel(*d); | |
| 56 | } else { | ||
| 57 | ✗ | LOG(Error, "EquipmentLevel value not found for workspace object " << workspaceObject); | |
| 58 | } | ||
| 59 | ✗ | } else if (istringEqual("Watts/Area", *s)) { | |
| 60 | ✗ | d = workspaceObject.getDouble(openstudio::HotWaterEquipmentFields::PowerperFloorArea); | |
| 61 | ✗ | if (d) { | |
| 62 | ✗ | definition.setWattsperSpaceFloorArea(*d); | |
| 63 | } else { | ||
| 64 | ✗ | LOG(Error, "Watts/Area value not found for workspace object " << workspaceObject); | |
| 65 | } | ||
| 66 | ✗ | } else if (istringEqual("Watts/Person", *s)) { | |
| 67 | ✗ | d = workspaceObject.getDouble(openstudio::HotWaterEquipmentFields::PowerperPerson); | |
| 68 | ✗ | if (d) { | |
| 69 | ✗ | definition.setWattsperPerson(*d); | |
| 70 | } else { | ||
| 71 | ✗ | LOG(Error, "Watts/Person value not found for workspace object " << workspaceObject); | |
| 72 | } | ||
| 73 | } else { | ||
| 74 | ✗ | LOG(Error, "Unknown DesignLevelCalculationMethod value for workspace object" << workspaceObject); | |
| 75 | } | ||
| 76 | |||
| 77 | ✗ | d = workspaceObject.getDouble(openstudio::HotWaterEquipmentFields::FractionLatent); | |
| 78 | ✗ | if (d) { | |
| 79 | ✗ | definition.setFractionLatent(*d); | |
| 80 | } | ||
| 81 | |||
| 82 | ✗ | d = workspaceObject.getDouble(openstudio::HotWaterEquipmentFields::FractionRadiant); | |
| 83 | ✗ | if (d) { | |
| 84 | ✗ | definition.setFractionRadiant(*d); | |
| 85 | } | ||
| 86 | |||
| 87 | ✗ | d = workspaceObject.getDouble(openstudio::HotWaterEquipmentFields::FractionLost); | |
| 88 | ✗ | if (d) { | |
| 89 | ✗ | definition.setFractionLost(*d); | |
| 90 | } | ||
| 91 | |||
| 92 | // create the instance | ||
| 93 | ✗ | HotWaterEquipment hotWaterEquipment(definition); | |
| 94 | |||
| 95 | ✗ | s = workspaceObject.name(); | |
| 96 | ✗ | if (s) { | |
| 97 | ✗ | hotWaterEquipment.setName(*s); | |
| 98 | } | ||
| 99 | |||
| 100 | ✗ | OptionalWorkspaceObject target = workspaceObject.getTarget(openstudio::HotWaterEquipmentFields::ZoneorZoneListorSpaceorSpaceListName); | |
| 101 | ✗ | if (target) { | |
| 102 | ✗ | OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target); | |
| 103 | ✗ | if (modelObject) { | |
| 104 | ✗ | if (modelObject->optionalCast<Space>()) { | |
| 105 | ✗ | hotWaterEquipment.setSpace(modelObject->cast<Space>()); | |
| 106 | ✗ | } else if (modelObject->optionalCast<SpaceType>()) { | |
| 107 | ✗ | hotWaterEquipment.setSpaceType(modelObject->cast<SpaceType>()); | |
| 108 | } | ||
| 109 | } | ||
| 110 | ✗ | } | |
| 111 | |||
| 112 | ✗ | target = workspaceObject.getTarget(openstudio::HotWaterEquipmentFields::ScheduleName); | |
| 113 | ✗ | if (target) { | |
| 114 | ✗ | OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target); | |
| 115 | ✗ | if (modelObject) { | |
| 116 | ✗ | if (OptionalSchedule intermediate = modelObject->optionalCast<Schedule>()) { | |
| 117 | ✗ | Schedule schedule(*intermediate); | |
| 118 | ✗ | hotWaterEquipment.setSchedule(schedule); | |
| 119 | ✗ | } | |
| 120 | } | ||
| 121 | ✗ | } | |
| 122 | |||
| 123 | ✗ | s = workspaceObject.getString(openstudio::HotWaterEquipmentFields::EndUseSubcategory); | |
| 124 | ✗ | if (s) { | |
| 125 | ✗ | hotWaterEquipment.setEndUseSubcategory(*s); | |
| 126 | } | ||
| 127 | |||
| 128 | ✗ | return hotWaterEquipment; | |
| 129 | ✗ | } | |
| 130 | |||
| 131 | } // namespace energyplus | ||
| 132 | |||
| 133 | } // namespace openstudio | ||
| 134 |