src/energyplus/ReverseTranslator/ReverseTranslateAirTerminalSingleDuctVAVNoReheat.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/AirTerminalSingleDuctVAVNoReheat.hpp" | ||
| 8 | #include "../../model/AirTerminalSingleDuctVAVNoReheat_Impl.hpp" | ||
| 9 | #include "../../model/Schedule.hpp" | ||
| 10 | #include "../../model/Schedule_Impl.hpp" | ||
| 11 | #include "../../model/DesignSpecificationOutdoorAir.hpp" | ||
| 12 | #include "../../model/DesignSpecificationOutdoorAir_Impl.hpp" | ||
| 13 | #include <utilities/idd/AirTerminal_SingleDuct_VAV_NoReheat_FieldEnums.hxx> | ||
| 14 | #include "../../utilities/idd/IddEnums.hpp" | ||
| 15 | #include <utilities/idd/IddEnums.hxx> | ||
| 16 | |||
| 17 | using namespace openstudio::model; | ||
| 18 | |||
| 19 | namespace openstudio { | ||
| 20 | |||
| 21 | namespace energyplus { | ||
| 22 | |||
| 23 | ✗ | OptionalModelObject ReverseTranslator::translateAirTerminalSingleDuctVAVNoReheat(const WorkspaceObject& workspaceObject) { | |
| 24 | ✗ | if (workspaceObject.iddObject().type() != IddObjectType::AirTerminal_SingleDuct_VAV_NoReheat) { | |
| 25 | ✗ | LOG(Error, "WorkspaceObject is not IddObjectType: AirTerminal_SingleDuct_VAV_NoReheat"); | |
| 26 | ✗ | return boost::none; | |
| 27 | } | ||
| 28 | |||
| 29 | ✗ | boost::optional<WorkspaceObject> wo = workspaceObject.getTarget(AirTerminal_SingleDuct_VAV_NoReheatFields::AvailabilityScheduleName); | |
| 30 | ✗ | boost::optional<Schedule> schedule; | |
| 31 | ✗ | boost::optional<AirTerminalSingleDuctVAVNoReheat> airTerminal; | |
| 32 | |||
| 33 | ✗ | if (wo) { | |
| 34 | ✗ | boost::optional<ModelObject> mo = translateAndMapWorkspaceObject(wo.get()); | |
| 35 | ✗ | if (mo) { | |
| 36 | ✗ | if (!(schedule = mo->optionalCast<Schedule>())) { | |
| 37 | ✗ | LOG(Error, workspaceObject.briefDescription() << " does not have an associated availability schedule"); | |
| 38 | |||
| 39 | ✗ | return boost::none; | |
| 40 | } | ||
| 41 | } | ||
| 42 | ✗ | } | |
| 43 | |||
| 44 | ✗ | if (schedule) { | |
| 45 | ✗ | airTerminal = AirTerminalSingleDuctVAVNoReheat(m_model, schedule.get()); | |
| 46 | } | ||
| 47 | |||
| 48 | ✗ | if (airTerminal) { | |
| 49 | ✗ | boost::optional<double> value; | |
| 50 | ✗ | boost::optional<std::string> s = workspaceObject.getString(AirTerminal_SingleDuct_VAV_NoReheatFields::Name); | |
| 51 | |||
| 52 | ✗ | if (s) { | |
| 53 | ✗ | airTerminal->setName(s.get()); | |
| 54 | } | ||
| 55 | |||
| 56 | // MaximumAirFlowRate | ||
| 57 | ✗ | value = workspaceObject.getDouble(AirTerminal_SingleDuct_VAV_NoReheatFields::MaximumAirFlowRate); | |
| 58 | ✗ | s = workspaceObject.getString(AirTerminal_SingleDuct_VAV_NoReheatFields::MaximumAirFlowRate); | |
| 59 | ✗ | if (value) { | |
| 60 | ✗ | airTerminal->setMaximumAirFlowRate(value.get()); | |
| 61 | ✗ | } else if (s && istringEqual(s.get(), "Autosize")) { | |
| 62 | ✗ | airTerminal->autosizeMaximumAirFlowRate(); | |
| 63 | ✗ | } else if (s && istringEqual(s.get(), "Autocalculate")) { | |
| 64 | ✗ | airTerminal->autosizeMaximumAirFlowRate(); | |
| 65 | } | ||
| 66 | |||
| 67 | // ZoneMinimumAirFlowInputMethod | ||
| 68 | ✗ | s = workspaceObject.getString(AirTerminal_SingleDuct_VAV_NoReheatFields::ZoneMinimumAirFlowInputMethod); | |
| 69 | ✗ | if (s) { | |
| 70 | ✗ | airTerminal->setZoneMinimumAirFlowInputMethod(s.get()); | |
| 71 | } | ||
| 72 | |||
| 73 | // ConstantMinimumAirFlowFraction | ||
| 74 | ✗ | value = workspaceObject.getDouble(AirTerminal_SingleDuct_VAV_NoReheatFields::ConstantMinimumAirFlowFraction); | |
| 75 | ✗ | if (value) { | |
| 76 | ✗ | airTerminal->setConstantMinimumAirFlowFraction(value.get()); | |
| 77 | } else { | ||
| 78 | ✗ | s = workspaceObject.getString(AirTerminal_SingleDuct_VAV_NoReheatFields::ConstantMinimumAirFlowFraction); | |
| 79 | ✗ | if (s && (istringEqual(s.get(), "Autosize") || istringEqual(s.get(), "Autocalculate"))) { | |
| 80 | ✗ | airTerminal->autosizeMaximumAirFlowRate(); | |
| 81 | } | ||
| 82 | } | ||
| 83 | |||
| 84 | // FixedMinimumAirFlowRate | ||
| 85 | ✗ | value = workspaceObject.getDouble(AirTerminal_SingleDuct_VAV_NoReheatFields::FixedMinimumAirFlowRate); | |
| 86 | ✗ | if (value) { | |
| 87 | ✗ | airTerminal->setFixedMinimumAirFlowRate(value.get()); | |
| 88 | } else { | ||
| 89 | ✗ | s = workspaceObject.getString(AirTerminal_SingleDuct_VAV_NoReheatFields::FixedMinimumAirFlowRate); | |
| 90 | ✗ | if (s && (istringEqual(s.get(), "Autosize") || istringEqual(s.get(), "Autocalculate"))) { | |
| 91 | ✗ | airTerminal->autosizeFixedMinimumAirFlowRate(); | |
| 92 | } | ||
| 93 | } | ||
| 94 | |||
| 95 | ✗ | boost::optional<WorkspaceObject> _schedule; | |
| 96 | |||
| 97 | // MinimumAirFlowFractionScheduleName | ||
| 98 | ✗ | _schedule = workspaceObject.getTarget(AirTerminal_SingleDuct_VAV_NoReheatFields::MinimumAirFlowFractionScheduleName); | |
| 99 | ✗ | if (_schedule) { | |
| 100 | ✗ | boost::optional<ModelObject> mo = translateAndMapWorkspaceObject(_schedule.get()); | |
| 101 | ✗ | if (mo) { | |
| 102 | ✗ | if (boost::optional<Schedule> schedule = mo->optionalCast<Schedule>()) { | |
| 103 | ✗ | airTerminal->setMinimumAirFlowFractionSchedule(schedule.get()); | |
| 104 | ✗ | } | |
| 105 | } | ||
| 106 | ✗ | } | |
| 107 | |||
| 108 | // MinimumAirFlowTurndownScheduleName | ||
| 109 | ✗ | _schedule = workspaceObject.getTarget(AirTerminal_SingleDuct_VAV_NoReheatFields::MinimumAirFlowTurndownScheduleName); | |
| 110 | ✗ | if (_schedule) { | |
| 111 | ✗ | boost::optional<ModelObject> mo = translateAndMapWorkspaceObject(_schedule.get()); | |
| 112 | ✗ | if (mo) { | |
| 113 | ✗ | if (boost::optional<Schedule> schedule = mo->optionalCast<Schedule>()) { | |
| 114 | ✗ | airTerminal->setMinimumAirFlowTurndownSchedule(schedule.get()); | |
| 115 | ✗ | } | |
| 116 | } | ||
| 117 | ✗ | } | |
| 118 | |||
| 119 | ✗ | return airTerminal.get(); | |
| 120 | ✗ | } else { | |
| 121 | ✗ | LOG(Error, "Unknown error translating " << workspaceObject.briefDescription()); | |
| 122 | |||
| 123 | ✗ | return boost::none; | |
| 124 | } | ||
| 125 | ✗ | } | |
| 126 | |||
| 127 | } // namespace energyplus | ||
| 128 | |||
| 129 | } // namespace openstudio | ||
| 130 |