src/energyplus/ForwardTranslator/ForwardTranslateCoilUserDefined.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 "../ForwardTranslator.hpp" | ||
| 7 | |||
| 8 | #include "../../model/CoilUserDefined.hpp" | ||
| 9 | #include "../../model/CoilUserDefined_Impl.hpp" | ||
| 10 | #include "../../model/Model.hpp" | ||
| 11 | #include "../../model/Node.hpp" | ||
| 12 | #include "../../model/Node_Impl.hpp" | ||
| 13 | #include "../../model/ThermalZone.hpp" | ||
| 14 | #include "../../model/ThermalZone_Impl.hpp" | ||
| 15 | #include "../../model/EnergyManagementSystemProgramCallingManager.hpp" | ||
| 16 | #include "../../model/EnergyManagementSystemProgram.hpp" | ||
| 17 | #include "../../model/EnergyManagementSystemActuator.hpp" | ||
| 18 | |||
| 19 | #include "../../utilities/core/Logger.hpp" | ||
| 20 | #include "../../utilities/core/Assert.hpp" | ||
| 21 | |||
| 22 | #include <utilities/idd/Coil_UserDefined_FieldEnums.hxx> | ||
| 23 | #include <utilities/idd/IddEnums.hxx> | ||
| 24 | |||
| 25 | using namespace openstudio::model; | ||
| 26 | |||
| 27 | using namespace std; | ||
| 28 | |||
| 29 | namespace openstudio { | ||
| 30 | |||
| 31 | namespace energyplus { | ||
| 32 | |||
| 33 | 4 | boost::optional<IdfObject> ForwardTranslator::translateCoilUserDefined(CoilUserDefined& modelObject) { | |
| 34 | |||
| 35 |
2/3✓ Branch 1 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
|
4 | if (modelObject.numberofAirConnections() == 0) { |
| 36 | ✗ | LOG(Warn, modelObject.briefDescription() << "will not be translated, cannot find air connection."); | |
| 37 | ✗ | return boost::none; | |
| 38 | } | ||
| 39 | |||
| 40 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::Coil_UserDefined, modelObject); |
| 41 | |||
| 42 | //PlantConnectionisUsed default value | ||
| 43 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | idfObject.setString(Coil_UserDefinedFields::PlantConnectionisUsed, "No"); |
| 44 | |||
| 45 | // PlantConnectionInletNodeName | ||
| 46 | 4 | bool plantUsed = false; | |
| 47 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 1 time.
|
8 | if (boost::optional<ModelObject> mo = modelObject.waterInletModelObject()) { |
| 48 |
3/4✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
|
6 | if (boost::optional<Node> node = mo->optionalCast<Node>()) { |
| 49 |
3/3✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
|
3 | idfObject.setString(Coil_UserDefinedFields::PlantConnectionInletNodeName, node->nameString()); |
| 50 | //PlantConnectionisUsed to Yes since Node is connected | ||
| 51 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
3 | idfObject.setString(Coil_UserDefinedFields::PlantConnectionisUsed, "Yes"); |
| 52 | 3 | plantUsed = true; | |
| 53 | 3 | } | |
| 54 | 4 | } | |
| 55 | |||
| 56 | // PlantConnectionOutletNodeName | ||
| 57 | |||
| 58 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 1 time.
|
8 | if (boost::optional<ModelObject> mo = modelObject.waterOutletModelObject()) { |
| 59 |
3/4✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
|
6 | if (boost::optional<Node> node = mo->optionalCast<Node>()) { |
| 60 |
3/3✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
|
3 | idfObject.setString(Coil_UserDefinedFields::PlantConnectionOutletNodeName, node->nameString()); |
| 61 | 3 | } | |
| 62 | 4 | } | |
| 63 | // remove plant actuators if no plant connections | ||
| 64 |
2/2✓ Branch 0 taken 1 time.
✓ Branch 1 taken 3 times.
|
4 | if (!plantUsed) { |
| 65 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | modelObject.plantMinimumMassFlowRateActuator().remove(); |
| 66 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | modelObject.plantMaximumMassFlowRateActuator().remove(); |
| 67 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | modelObject.plantDesignVolumeFlowRateActuator().remove(); |
| 68 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | modelObject.plantMassFlowRateActuator().remove(); |
| 69 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | modelObject.plantOutletTemperatureActuator().remove(); |
| 70 | } | ||
| 71 | // AirConnection1InletNodeName | ||
| 72 | |||
| 73 |
2/3✓ Branch 1 taken 4 times.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
|
8 | if (boost::optional<ModelObject> mo = modelObject.airInletModelObject()) { |
| 74 |
3/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
|
8 | if (boost::optional<Node> node = mo->optionalCast<Node>()) { |
| 75 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
|
4 | idfObject.setString(Coil_UserDefinedFields::AirConnection1InletNodeName, node->nameString()); |
| 76 | 4 | } | |
| 77 | 4 | } | |
| 78 | |||
| 79 | // AirConnection1OutletNodeName | ||
| 80 | |||
| 81 |
2/3✓ Branch 1 taken 4 times.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
|
8 | if (boost::optional<ModelObject> mo = modelObject.airOutletModelObject()) { |
| 82 |
3/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
|
8 | if (boost::optional<Node> node = mo->optionalCast<Node>()) { |
| 83 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
|
4 | idfObject.setString(Coil_UserDefinedFields::AirConnection1OutletNodeName, node->nameString()); |
| 84 | 4 | } | |
| 85 | 4 | } | |
| 86 | |||
| 87 | // NumberofAirConnections | ||
| 88 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | idfObject.setInt(Coil_UserDefinedFields::NumberofAirConnections, modelObject.numberofAirConnections()); |
| 89 | |||
| 90 | // OverallModelSimulationProgramCallingManagerName | ||
| 91 | |||
| 92 |
3/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 8 taken 4 times.
✗ Branch 9 not taken.
|
8 | if (boost::optional<EnergyManagementSystemProgramCallingManager> pcm = modelObject.overallModelSimulationProgramCallingManager()) { |
| 93 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
|
4 | idfObject.setString(Coil_UserDefinedFields::OverallModelSimulationProgramCallingManagerName, pcm->nameString()); |
| 94 | 4 | } | |
| 95 | |||
| 96 | // ModelSetupandSizingProgramCallingManagerName | ||
| 97 | |||
| 98 |
3/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 8 taken 4 times.
✗ Branch 9 not taken.
|
8 | if (boost::optional<EnergyManagementSystemProgramCallingManager> pcm = modelObject.modelSetupandSizingProgramCallingManager()) { |
| 99 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
|
4 | idfObject.setString(Coil_UserDefinedFields::ModelSetupandSizingProgramCallingManagerName, pcm->nameString()); |
| 100 | 4 | } | |
| 101 | |||
| 102 | // AmbientZoneName | ||
| 103 | |||
| 104 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
|
8 | if (boost::optional<ThermalZone> zone_ = modelObject.ambientZone()) { |
| 105 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | idfObject.setString(Coil_UserDefinedFields::AmbientZoneName, zone_->nameString()); |
| 106 | 4 | } | |
| 107 | |||
| 108 |
1/1✓ Branch 1 taken 4 times.
|
4 | return idfObject; |
| 109 | 4 | } | |
| 110 | |||
| 111 | } // namespace energyplus | ||
| 112 | |||
| 113 | } // namespace openstudio | ||
| 114 |