src/energyplus/ReverseTranslator/ReverseTranslateAirTerminalSingleDuctConstantVolumeReheat.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/AirTerminalSingleDuctConstantVolumeReheat.hpp" | ||
| 8 | #include "../../model/AirTerminalSingleDuctConstantVolumeReheat_Impl.hpp" | ||
| 9 | #include "../../model/Schedule.hpp" | ||
| 10 | #include "../../model/Schedule_Impl.hpp" | ||
| 11 | #include "../../model/CoilHeatingGas.hpp" | ||
| 12 | #include "../../model/CoilHeatingGas_Impl.hpp" | ||
| 13 | #include "../../model/CoilHeatingElectric.hpp" | ||
| 14 | #include "../../model/CoilHeatingElectric_Impl.hpp" | ||
| 15 | #include "../../model/CoilHeatingWater.hpp" | ||
| 16 | #include "../../model/CoilHeatingWater_Impl.hpp" | ||
| 17 | #include <utilities/idd/AirTerminal_SingleDuct_ConstantVolume_Reheat_FieldEnums.hxx> | ||
| 18 | #include "../../utilities/idd/IddEnums.hpp" | ||
| 19 | #include <utilities/idd/IddEnums.hxx> | ||
| 20 | |||
| 21 | using namespace openstudio::model; | ||
| 22 | |||
| 23 | namespace openstudio { | ||
| 24 | |||
| 25 | namespace energyplus { | ||
| 26 | |||
| 27 | ✗ | OptionalModelObject ReverseTranslator::translateAirTerminalSingleDuctConstantVolumeReheat(const WorkspaceObject& workspaceObject) { | |
| 28 | ✗ | if (workspaceObject.iddObject().type() != IddObjectType::AirTerminal_SingleDuct_ConstantVolume_Reheat) { | |
| 29 | ✗ | LOG(Error, "WorkspaceObject is not IddObjectType: AirTerminal_SingleDuct_ConstantVolume_Reheat"); | |
| 30 | ✗ | return boost::none; | |
| 31 | } | ||
| 32 | |||
| 33 | ✗ | boost::optional<WorkspaceObject> wo = workspaceObject.getTarget(AirTerminal_SingleDuct_ConstantVolume_ReheatFields::AvailabilityScheduleName); | |
| 34 | ✗ | boost::optional<Schedule> schedule; | |
| 35 | ✗ | boost::optional<HVACComponent> coil; | |
| 36 | ✗ | boost::optional<AirTerminalSingleDuctConstantVolumeReheat> airTerminal; | |
| 37 | |||
| 38 | ✗ | if (wo) { | |
| 39 | ✗ | boost::optional<ModelObject> mo = translateAndMapWorkspaceObject(wo.get()); | |
| 40 | ✗ | if (mo) { | |
| 41 | ✗ | if (!(schedule = mo->optionalCast<Schedule>())) { | |
| 42 | ✗ | LOG(Error, workspaceObject.briefDescription() << " does not have an associated availability schedule"); | |
| 43 | |||
| 44 | ✗ | return boost::none; | |
| 45 | } | ||
| 46 | } | ||
| 47 | ✗ | } | |
| 48 | |||
| 49 | ✗ | wo = workspaceObject.getTarget(AirTerminal_SingleDuct_ConstantVolume_ReheatFields::ReheatCoilName); | |
| 50 | ✗ | if (wo) { | |
| 51 | ✗ | boost::optional<ModelObject> mo = translateAndMapWorkspaceObject(wo.get()); | |
| 52 | ✗ | if (mo) { | |
| 53 | ✗ | if (!coil) { | |
| 54 | //TODO: Maybe try to cast this to different types depending on ReheatCoilType | ||
| 55 | ✗ | coil = mo->optionalCast<CoilHeatingElectric>(); | |
| 56 | } | ||
| 57 | } | ||
| 58 | ✗ | } | |
| 59 | |||
| 60 | ✗ | if (schedule && coil) { | |
| 61 | ✗ | airTerminal = AirTerminalSingleDuctConstantVolumeReheat(m_model, schedule.get(), coil.get()); | |
| 62 | } | ||
| 63 | |||
| 64 | ✗ | if (airTerminal) { | |
| 65 | ✗ | boost::optional<double> value; | |
| 66 | ✗ | boost::optional<std::string> s = workspaceObject.getString(AirTerminal_SingleDuct_ConstantVolume_ReheatFields::Name); | |
| 67 | |||
| 68 | ✗ | if (s) { | |
| 69 | ✗ | airTerminal->setName(s.get()); | |
| 70 | } | ||
| 71 | |||
| 72 | // MaximumAirFlowRate | ||
| 73 | ✗ | value = workspaceObject.getDouble(AirTerminal_SingleDuct_ConstantVolume_ReheatFields::MaximumAirFlowRate); | |
| 74 | ✗ | if (value) { | |
| 75 | ✗ | airTerminal->setMaximumAirFlowRate(value.get()); | |
| 76 | } else { | ||
| 77 | ✗ | s = workspaceObject.getString(AirTerminal_SingleDuct_ConstantVolume_ReheatFields::MaximumAirFlowRate); | |
| 78 | ✗ | if (s && istringEqual(s.get(), "Autosize")) { | |
| 79 | ✗ | airTerminal->autosizeMaximumAirFlowRate(); | |
| 80 | ✗ | } else if (s && istringEqual(s.get(), "Autocalculate")) { | |
| 81 | ✗ | airTerminal->autosizeMaximumAirFlowRate(); | |
| 82 | } | ||
| 83 | } | ||
| 84 | |||
| 85 | // MaximumHotWaterorSteamFlowRate | ||
| 86 | ✗ | value = workspaceObject.getDouble(AirTerminal_SingleDuct_ConstantVolume_ReheatFields::MaximumHotWaterorSteamFlowRate); | |
| 87 | ✗ | if (value) { | |
| 88 | ✗ | airTerminal->setMaximumHotWaterorSteamFlowRate(value.get()); | |
| 89 | } else { | ||
| 90 | ✗ | s = workspaceObject.getString(AirTerminal_SingleDuct_ConstantVolume_ReheatFields::MaximumHotWaterorSteamFlowRate); | |
| 91 | ✗ | if (s && istringEqual(s.get(), "Autosize")) { | |
| 92 | ✗ | airTerminal->autosizeMaximumHotWaterorSteamFlowRate(); | |
| 93 | ✗ | } else if (s && istringEqual(s.get(), "Autocalculate")) { | |
| 94 | ✗ | airTerminal->autosizeMaximumHotWaterorSteamFlowRate(); | |
| 95 | } | ||
| 96 | } | ||
| 97 | |||
| 98 | // MinimumHotWaterorSteamFlowRate | ||
| 99 | ✗ | value = workspaceObject.getDouble(AirTerminal_SingleDuct_ConstantVolume_ReheatFields::MinimumHotWaterorSteamFlowRate); | |
| 100 | ✗ | if (value) { | |
| 101 | ✗ | airTerminal->setMinimumHotWaterorSteamFlowRate(value.get()); | |
| 102 | } | ||
| 103 | |||
| 104 | // ConvergenceTolerance | ||
| 105 | ✗ | value = workspaceObject.getDouble(AirTerminal_SingleDuct_ConstantVolume_ReheatFields::ConvergenceTolerance); | |
| 106 | ✗ | if (value) { | |
| 107 | ✗ | airTerminal->setConvergenceTolerance(value.get()); | |
| 108 | } | ||
| 109 | |||
| 110 | // MaximumReheatAirTemperature | ||
| 111 | ✗ | value = workspaceObject.getDouble(AirTerminal_SingleDuct_ConstantVolume_ReheatFields::MaximumReheatAirTemperature); | |
| 112 | ✗ | if (value) { | |
| 113 | ✗ | airTerminal->setMaximumReheatAirTemperature(value.get()); | |
| 114 | } | ||
| 115 | |||
| 116 | ✗ | return airTerminal.get(); | |
| 117 | ✗ | } else { | |
| 118 | ✗ | LOG(Error, "Unknown error translating " << workspaceObject.briefDescription()); | |
| 119 | |||
| 120 | ✗ | return boost::none; | |
| 121 | } | ||
| 122 | ✗ | } | |
| 123 | |||
| 124 | } // namespace energyplus | ||
| 125 | |||
| 126 | } // namespace openstudio | ||
| 127 |