src/energyplus/ReverseTranslator/ReverseTranslateCoilCoolingDX.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/CoilCoolingDX.hpp" | ||
| 9 | #include "../../model/CoilCoolingDX_Impl.hpp" | ||
| 10 | |||
| 11 | #include "../../model/Node.hpp" | ||
| 12 | #include "../../model/Node_Impl.hpp" | ||
| 13 | #include "../../model/Schedule.hpp" | ||
| 14 | #include "../../model/Schedule_Impl.hpp" | ||
| 15 | #include "../../model/ThermalZone.hpp" | ||
| 16 | #include "../../model/ThermalZone_Impl.hpp" | ||
| 17 | #include "../../model/Space.hpp" | ||
| 18 | #include "../../model/Space_Impl.hpp" | ||
| 19 | #include "../../model/CoilCoolingDXCurveFitPerformance.hpp" | ||
| 20 | #include "../../model/CoilCoolingDXCurveFitPerformance_Impl.hpp" | ||
| 21 | |||
| 22 | #include <utilities/idd/Coil_Cooling_DX_FieldEnums.hxx> | ||
| 23 | #include "../../utilities/idd/IddEnums.hpp" | ||
| 24 | #include <utilities/idd/IddEnums.hxx> | ||
| 25 | |||
| 26 | #include "../../utilities/core/Assert.hpp" | ||
| 27 | |||
| 28 | using namespace openstudio::model; | ||
| 29 | |||
| 30 | namespace openstudio { | ||
| 31 | |||
| 32 | namespace energyplus { | ||
| 33 | |||
| 34 | 2 | OptionalModelObject ReverseTranslator::translateCoilCoolingDX(const WorkspaceObject& workspaceObject) { | |
| 35 |
4/5✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
|
2 | if (workspaceObject.iddObject().type() != IddObjectType::Coil_Cooling_DX) { |
| 36 | ✗ | LOG(Error, "WorkspaceObject is not IddObjectType: CoilCoolingDX"); | |
| 37 | ✗ | return boost::none; | |
| 38 | } | ||
| 39 | |||
| 40 | 2 | OptionalString s; | |
| 41 | 2 | OptionalDouble d; | |
| 42 | 2 | OptionalWorkspaceObject target; | |
| 43 | |||
| 44 | 2 | boost::optional<CoilCoolingDXCurveFitPerformance> performanceObject; | |
| 45 |
2/3✓ Branch 1 taken 2 times.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
|
4 | if ((target = workspaceObject.getTarget(openstudio::Coil_Cooling_DXFields::PerformanceObjectName))) { |
| 46 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target); |
| 47 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if (modelObject) { |
| 48 |
3/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
|
4 | if (modelObject->optionalCast<CoilCoolingDXCurveFitPerformance>()) { |
| 49 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | performanceObject = modelObject->cast<CoilCoolingDXCurveFitPerformance>(); |
| 50 | } | ||
| 51 | } | ||
| 52 | 2 | } | |
| 53 | |||
| 54 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | openstudio::model::CoilCoolingDX dx(m_model, *performanceObject); |
| 55 | |||
| 56 |
1/1✓ Branch 1 taken 2 times.
|
2 | s = workspaceObject.name(); |
| 57 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if (s) { |
| 58 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | dx.setName(*s); |
| 59 | } | ||
| 60 | |||
| 61 |
2/3✓ Branch 1 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
|
4 | if ((target = workspaceObject.getTarget(openstudio::Coil_Cooling_DXFields::AvailabilityScheduleName))) { |
| 62 | ✗ | OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target); | |
| 63 | ✗ | if (modelObject) { | |
| 64 | ✗ | if (auto optSch = modelObject->optionalCast<Schedule>()) { | |
| 65 | ✗ | dx.setAvailabilitySchedule(optSch.get()); | |
| 66 | ✗ | } | |
| 67 | } | ||
| 68 | ✗ | } | |
| 69 | |||
| 70 |
2/3✓ Branch 1 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
|
4 | if ((target = workspaceObject.getTarget(openstudio::Coil_Cooling_DXFields::CondenserZoneName))) { |
| 71 | ✗ | if (auto mo_ = translateAndMapWorkspaceObject(*target)) { | |
| 72 | // Zone is translated, and a Space is returned instead | ||
| 73 | ✗ | if (boost::optional<Space> space_ = mo_->optionalCast<Space>()) { | |
| 74 | ✗ | if (auto z_ = space_->thermalZone()) { | |
| 75 | ✗ | dx.setCondenserZone(z_.get()); | |
| 76 | ✗ | } | |
| 77 | } else { | ||
| 78 | ✗ | LOG(Warn, workspaceObject.briefDescription() << " has a wrong type for 'Condenser Zone Name'"); | |
| 79 | ✗ | } | |
| 80 | ✗ | } | |
| 81 | } | ||
| 82 | |||
| 83 | // TODO: eventually support the condenser Inlet/Outlet Nodes and the Storage Tanks | ||
| 84 | |||
| 85 |
1/1✓ Branch 1 taken 2 times.
|
2 | return dx; |
| 86 | 2 | } // End of translate function | |
| 87 | |||
| 88 | } // end namespace energyplus | ||
| 89 | } // end namespace openstudio | ||
| 90 |