src/energyplus/ForwardTranslator/ForwardTranslateEnergyManagementSystemActuator.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/Model.hpp" | ||
| 9 | #include "../../model/ModelObject.hpp" | ||
| 10 | #include "../../model/OutputVariable.hpp" | ||
| 11 | #include "../../model/OutputVariable_Impl.hpp" | ||
| 12 | #include "../../model/OutputMeter.hpp" | ||
| 13 | #include "../../model/OutputMeter_Impl.hpp" | ||
| 14 | #include "../../model/Schedule.hpp" | ||
| 15 | #include "../../model/Schedule_Impl.hpp" | ||
| 16 | #include "../../model/EnergyManagementSystemActuator.hpp" | ||
| 17 | #include "../../model/EnergyManagementSystemActuator_Impl.hpp" | ||
| 18 | #include "../../model/Site.hpp" | ||
| 19 | #include "../../model/WeatherFile.hpp" | ||
| 20 | #include "../../model/SpaceLoad.hpp" | ||
| 21 | #include "../../model/SpaceLoad_Impl.hpp" | ||
| 22 | #include "../../model/SpaceLoadInstance.hpp" | ||
| 23 | #include "../../model/SpaceLoadInstance_Impl.hpp" | ||
| 24 | #include "../../model/Space.hpp" | ||
| 25 | #include "../../model/Space_Impl.hpp" | ||
| 26 | #include "../../model/SpaceType.hpp" | ||
| 27 | #include "../../model/SpaceType_Impl.hpp" | ||
| 28 | #include "../../model/ThermalZone.hpp" | ||
| 29 | #include "../../model/ThermalZone_Impl.hpp" | ||
| 30 | |||
| 31 | #include "../../utilities/core/Compare.hpp" | ||
| 32 | |||
| 33 | #include <utilities/idd/EnergyManagementSystem_Actuator_FieldEnums.hxx> | ||
| 34 | #include "../../utilities/idd/IddEnums.hpp" | ||
| 35 | #include <utilities/idd/IddEnums.hxx> | ||
| 36 | |||
| 37 | #include <algorithm> | ||
| 38 | |||
| 39 | using namespace openstudio::model; | ||
| 40 | |||
| 41 | using namespace std; | ||
| 42 | |||
| 43 | namespace openstudio { | ||
| 44 | |||
| 45 | namespace energyplus { | ||
| 46 | |||
| 47 | 69 | boost::optional<IdfObject> ForwardTranslator::translateEnergyManagementSystemActuator(EnergyManagementSystemActuator& modelObject) { | |
| 48 | |||
| 49 |
1/1✓ Branch 1 taken 69 times.
|
69 | const boost::optional<ModelObject> actuatedComponent_ = modelObject.actuatedComponent(); |
| 50 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 2 taken 68 times.
|
69 | if (!actuatedComponent_) { |
| 51 |
8/8✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
✓ Branch 17 taken 1 time.
✓ Branch 20 taken 1 time.
✓ Branch 23 taken 1 time.
|
1 | LOG(Error, "Actuated Component for Actuator " << modelObject.nameString() << " does not exist, it will not be translated."); |
| 52 | 1 | return boost::none; | |
| 53 | } | ||
| 54 | |||
| 55 | // Start by dealing with "OS:Site" and "OS:WeatherFile" that are special ones (will not pass the test on `m.name()` below | ||
| 56 |
3/3✓ Branch 1 taken 68 times.
✓ Branch 4 taken 68 times.
✓ Branch 7 taken 68 times.
|
68 | if (actuatedComponent_->iddObjectType() == openstudio::IddObjectType::OS_Site |
| 57 |
9/9✓ Branch 0 taken 67 times.
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 67 times.
✓ Branch 6 taken 67 times.
✓ Branch 9 taken 67 times.
✓ Branch 12 taken 1 time.
✓ Branch 13 taken 66 times.
✓ Branch 14 taken 2 times.
✓ Branch 15 taken 66 times.
|
68 | || actuatedComponent_->iddObjectType() == openstudio::IddObjectType::OS_WeatherFile) { |
| 58 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::EnergyManagementSystem_Actuator, modelObject); |
| 59 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
4 | idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentUniqueName, "Environment"); |
| 60 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentType, "Weather Data"); |
| 61 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentControlType, modelObject.actuatedComponentControlType()); |
| 62 |
1/1✓ Branch 1 taken 2 times.
|
2 | return idfObject; |
| 63 | 2 | } | |
| 64 | |||
| 65 | // As this point, it MUST have a name, as we dealt with the special ones already | ||
| 66 |
3/4✓ Branch 1 taken 66 times.
✓ Branch 4 taken 66 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 66 times.
|
66 | if (!actuatedComponent_->name()) { |
| 67 | ✗ | LOG(Error, "Actuated Component Name for Actuator '" << modelObject.nameString() << "' does not exist, it will not be translated."); | |
| 68 | ✗ | return boost::none; | |
| 69 | } | ||
| 70 | |||
| 71 | // check if actuatedComponent is a SpaceLoad | ||
| 72 |
2/2✓ Branch 1 taken 66 times.
✓ Branch 4 taken 66 times.
|
66 | auto load_ = actuatedComponent_->optionalCast<model::SpaceLoadInstance>(); |
| 73 |
2/2✓ Branch 1 taken 44 times.
✓ Branch 2 taken 22 times.
|
66 | if (!load_) { |
| 74 | // Classic case, we just write it | ||
| 75 |
2/2✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
|
44 | IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::EnergyManagementSystem_Actuator, modelObject); |
| 76 |
3/3✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
✓ Branch 7 taken 44 times.
|
44 | idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentUniqueName, actuatedComponent_->nameString()); |
| 77 |
2/2✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
|
44 | idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentType, modelObject.actuatedComponentType()); |
| 78 |
2/2✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
|
44 | idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentControlType, modelObject.actuatedComponentControlType()); |
| 79 |
1/1✓ Branch 1 taken 44 times.
|
44 | return idfObject; |
| 80 | 44 | } | |
| 81 | |||
| 82 | // SpaceLoadInstance: check if first if it's assigned to a single space | ||
| 83 |
2/2✓ Branch 1 taken 22 times.
✓ Branch 4 taken 22 times.
|
22 | auto space_ = load_->space(); |
| 84 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 18 times.
|
22 | if (space_) { |
| 85 | // if load is assigned to a single space instead of a space type then the name will not be changed in EnergyPlus | ||
| 86 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::EnergyManagementSystem_Actuator, modelObject); |
| 87 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
|
4 | idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentUniqueName, actuatedComponent_->nameString()); |
| 88 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentType, modelObject.actuatedComponentType()); |
| 89 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentControlType, modelObject.actuatedComponentControlType()); |
| 90 |
1/1✓ Branch 1 taken 4 times.
|
4 | return idfObject; |
| 91 | 4 | } | |
| 92 | |||
| 93 | // At this point the SpaceLoadInstance is not assigned to a space, so it's assigned to a SpaceType or nothing | ||
| 94 | |||
| 95 |
2/2✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
|
18 | auto spaceType_ = load_->spaceType(); |
| 96 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
|
18 | if (!spaceType_) { |
| 97 | ✗ | LOG(Error, "Actuator '" << modelObject.nameString() << "' references a SpaceLoad '" << load_->nameString() | |
| 98 | << "' which is not associated with a ThermalZone, it will not be translated."); | ||
| 99 | ✗ | return boost::none; | |
| 100 | } | ||
| 101 | |||
| 102 | // Deal with the SpaceType case... | ||
| 103 | |||
| 104 | // Case 1: the user correctly assigned a Space or ThermalZone to it | ||
| 105 |
3/3✓ Branch 1 taken 18 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 15 times.
|
36 | if (const boost::optional<Space> specificSpace_ = modelObject.space()) { |
| 106 | // Assert the space has a thermalZone attached to it. | ||
| 107 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
3 | auto tz_ = specificSpace_->thermalZone(); |
| 108 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
|
3 | if (!tz_) { |
| 109 | ✗ | LOG(Error, "Actuator '" << modelObject.nameString() << "' references a SpaceLoad '" << load_->nameString() | |
| 110 | << "' and specified that it wanted to be attached to the Space '" << specificSpace_->nameString() | ||
| 111 | << "' but the Space has no Thermal Zone, so it will not be translated."); | ||
| 112 | ✗ | return boost::none; | |
| 113 | } | ||
| 114 | |||
| 115 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
3 | std::string zoneOrSpaceName = specificSpace_->nameString(); |
| 116 | |||
| 117 | // Try to be helpful in case the user assigned a Space, but the FT doesn't translate spaces | ||
| 118 |
3/3✓ Branch 1 taken 3 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 2 times.
|
3 | if (m_forwardTranslatorOptions.excludeSpaceTranslation()) { |
| 119 |
20/20✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
✓ Branch 16 taken 1 time.
✓ Branch 19 taken 1 time.
✓ Branch 22 taken 1 time.
✓ Branch 25 taken 1 time.
✓ Branch 28 taken 1 time.
✓ Branch 31 taken 1 time.
✓ Branch 34 taken 1 time.
✓ Branch 37 taken 1 time.
✓ Branch 40 taken 1 time.
✓ Branch 43 taken 1 time.
✓ Branch 46 taken 1 time.
✓ Branch 49 taken 1 time.
✓ Branch 56 taken 1 time.
✓ Branch 59 taken 1 time.
✓ Branch 62 taken 1 time.
|
1 | LOG(Warn, "Actuator '" << modelObject.nameString() << "' references a SpaceLoad '" << load_->nameString() |
| 120 | << "' and specified that it wanted to be attached to the Space '" << specificSpace_->nameString() | ||
| 121 | << "' but you have turned off ForwardTranslation's Space Feature. Falling back to using the attached ThermalZone '" | ||
| 122 | << tz_->nameString() << "'."); | ||
| 123 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | zoneOrSpaceName = tz_->nameString(); |
| 124 | } | ||
| 125 | |||
| 126 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
3 | IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::EnergyManagementSystem_Actuator, modelObject); |
| 127 |
4/4✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
|
3 | const std::string spaceLoadNameForEMS = zoneOrSpaceName + " " + actuatedComponent_->nameString(); |
| 128 |
1/1✓ Branch 1 taken 3 times.
|
3 | idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentUniqueName, spaceLoadNameForEMS); |
| 129 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
3 | idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentType, modelObject.actuatedComponentType()); |
| 130 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
3 | idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentControlType, modelObject.actuatedComponentControlType()); |
| 131 |
1/1✓ Branch 1 taken 3 times.
|
3 | return idfObject; |
| 132 | 21 | } | |
| 133 | |||
| 134 |
3/3✓ Branch 1 taken 15 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 13 times.
|
30 | if (const boost::optional<ThermalZone> specificZone_ = modelObject.thermalZone()) { |
| 135 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | auto spaces = specificZone_->spaces(); |
| 136 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | if (spaces.empty()) { |
| 137 | ✗ | LOG(Error, "Actuator '" << modelObject.nameString() << "' references a SpaceLoad '" << load_->nameString() | |
| 138 | << "' and specified that it wanted to be attached to the ThermalZone '" << specificZone_->nameString() | ||
| 139 | << "' but the Thermal Zone has no Spaces, so it will not be translated."); | ||
| 140 | ✗ | return boost::none; | |
| 141 | } | ||
| 142 | |||
| 143 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | std::string zoneOrSpaceName = specificZone_->nameString(); |
| 144 | |||
| 145 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 1 time.
|
2 | if (!m_forwardTranslatorOptions.excludeSpaceTranslation()) { |
| 146 |
1/2✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
|
1 | if (spaces.size() == 1) { |
| 147 |
1/1✓ Branch 2 taken 1 time.
|
1 | zoneOrSpaceName = spaces.front().nameString(); |
| 148 |
18/18✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
✓ Branch 16 taken 1 time.
✓ Branch 19 taken 1 time.
✓ Branch 22 taken 1 time.
✓ Branch 25 taken 1 time.
✓ Branch 28 taken 1 time.
✓ Branch 31 taken 1 time.
✓ Branch 34 taken 1 time.
✓ Branch 37 taken 1 time.
✓ Branch 40 taken 1 time.
✓ Branch 43 taken 1 time.
✓ Branch 49 taken 1 time.
✓ Branch 52 taken 1 time.
✓ Branch 55 taken 1 time.
|
1 | LOG(Warn, "Actuator '" << modelObject.nameString() << "' references a SpaceLoad '" << load_->nameString() |
| 149 | << "' and specified that it wanted to be attached to the Thermal Zone '" << specificZone_->nameString() | ||
| 150 | << "' but you have turned on ForwardTranslation's Space Feature. Falling back to using the attached Space '" | ||
| 151 | << zoneOrSpaceName << "' since there is only 1."); | ||
| 152 | } else { // if (spaces.size() > 1) { | ||
| 153 | ✗ | std::sort(spaces.begin(), spaces.end(), WorkspaceObjectNameLess()); | |
| 154 | ✗ | zoneOrSpaceName = spaces.front().nameString(); | |
| 155 | // TODO: do we grab the first space or just don't translate it? | ||
| 156 | ✗ | LOG(Error, "Actuator '" << modelObject.nameString() << "' references a SpaceLoad '" << load_->nameString() | |
| 157 | << "' and specified that it wanted to be attached to the Thermal Zone '" << specificZone_->nameString() | ||
| 158 | << "' but you have turned on ForwardTranslation's Space Feature. Your Thermal Zone has multiple spaces " | ||
| 159 | "attached. Falling back to using the first Space '" | ||
| 160 | << zoneOrSpaceName << "'."); | ||
| 161 | } | ||
| 162 | } | ||
| 163 | |||
| 164 | // ZoneName object exists so set name to be the concatenation of it plus the spaceloadobject | ||
| 165 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::EnergyManagementSystem_Actuator, modelObject); |
| 166 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
|
2 | const std::string spaceLoadNameForEMS = zoneOrSpaceName + " " + actuatedComponent_->nameString(); |
| 167 |
1/1✓ Branch 1 taken 2 times.
|
2 | idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentUniqueName, spaceLoadNameForEMS); |
| 168 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentType, modelObject.actuatedComponentType()); |
| 169 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentControlType, modelObject.actuatedComponentControlType()); |
| 170 |
1/1✓ Branch 1 taken 2 times.
|
2 | return idfObject; |
| 171 | 17 | } | |
| 172 | |||
| 173 | // ZoneName object does not exist so try and translate anyway | ||
| 174 | |||
| 175 | // the load references a space type, this means it will reference a ZoneList (if excludeSpaceTranslation = true) or a SpaceList in EnergyPlus | ||
| 176 | // in EnergyPlus, each load in a ZoneList is duplicated into each zone with a new name based on the zone, same for SpaceList | ||
| 177 | { | ||
| 178 |
2/2✓ Branch 1 taken 13 times.
✓ Branch 4 taken 13 times.
|
13 | auto spaces = spaceType_->spaces(); |
| 179 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
|
13 | if (spaces.empty()) { |
| 180 | ✗ | LOG(Error, "Actuator '" << modelObject.nameString() << "' references a SpaceLoad '" << load_->nameString() | |
| 181 | << "' and specified that it wanted to be attached to the SpaceType '" << spaceType_->nameString() | ||
| 182 | << "' but the Space Type has no Spaces, so it will not be translated."); | ||
| 183 | ✗ | return boost::none; | |
| 184 | } | ||
| 185 | |||
| 186 | 13 | std::string zoneOrSpaceName; | |
| 187 | |||
| 188 |
3/3✓ Branch 1 taken 13 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 7 times.
|
13 | if (!m_forwardTranslatorOptions.excludeSpaceTranslation()) { |
| 189 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 2 taken 4 times.
|
6 | if (spaces.size() == 1) { |
| 190 |
1/1✓ Branch 2 taken 2 times.
|
2 | zoneOrSpaceName = spaces.front().nameString(); |
| 191 |
18/18✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✓ Branch 16 taken 2 times.
✓ Branch 19 taken 2 times.
✓ Branch 22 taken 2 times.
✓ Branch 25 taken 2 times.
✓ Branch 28 taken 2 times.
✓ Branch 31 taken 2 times.
✓ Branch 34 taken 2 times.
✓ Branch 37 taken 2 times.
✓ Branch 40 taken 2 times.
✓ Branch 43 taken 2 times.
✓ Branch 49 taken 2 times.
✓ Branch 52 taken 2 times.
✓ Branch 55 taken 2 times.
|
2 | LOG(Warn, "Actuator '" << modelObject.nameString() << "' references a SpaceLoad '" << load_->nameString() << "' attached to the SpaceType '" |
| 192 | << spaceType_->nameString() | ||
| 193 | << "' but you have turned on ForwardTranslation's Space Feature. Falling back to using the attached Space '" | ||
| 194 | << zoneOrSpaceName << "' since there is only 1."); | ||
| 195 | } else { // if (spaces.size() > 1) { | ||
| 196 | // TODO: do we grab the first space or just don't translate it? | ||
| 197 |
1/1✓ Branch 3 taken 4 times.
|
4 | std::sort(spaces.begin(), spaces.end(), WorkspaceObjectNameLess()); |
| 198 |
1/1✓ Branch 2 taken 4 times.
|
4 | zoneOrSpaceName = spaces.front().nameString(); |
| 199 |
18/18✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
✓ Branch 13 taken 4 times.
✓ Branch 16 taken 4 times.
✓ Branch 19 taken 4 times.
✓ Branch 22 taken 4 times.
✓ Branch 25 taken 4 times.
✓ Branch 28 taken 4 times.
✓ Branch 31 taken 4 times.
✓ Branch 34 taken 4 times.
✓ Branch 37 taken 4 times.
✓ Branch 40 taken 4 times.
✓ Branch 43 taken 4 times.
✓ Branch 49 taken 4 times.
✓ Branch 52 taken 4 times.
✓ Branch 55 taken 4 times.
|
4 | LOG(Error, "Actuator '" << modelObject.nameString() << "' references a SpaceLoad '" << load_->nameString() |
| 200 | << "' attached to the SpaceType '" << spaceType_->nameString() | ||
| 201 | << "' but you have turned on ForwardTranslation's Space Feature. The Space Type has multiple spaces " | ||
| 202 | "attached. Falling back to using the first Space '" | ||
| 203 | << zoneOrSpaceName << "'."); | ||
| 204 | } | ||
| 205 | } else { | ||
| 206 | // Not translating Spaces | ||
| 207 | 7 | std::set<std::string> zoneNames; | |
| 208 |
4/4✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 11 taken 8 times.
✓ Branch 12 taken 7 times.
|
15 | for (const auto& space : spaceType_->spaces()) { |
| 209 |
2/3✓ Branch 1 taken 8 times.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
|
16 | if (auto tz_ = space.thermalZone()) { |
| 210 |
3/3✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 8 times.
|
8 | zoneNames.insert(tz_->nameString()); |
| 211 | 8 | } | |
| 212 | 7 | } | |
| 213 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
|
7 | if (zoneNames.empty()) { |
| 214 | ✗ | LOG(Error, "Actuator '" << modelObject.nameString() << "' references a SpaceLoad '" << load_->nameString() | |
| 215 | << "' attached to the SpaceType '" << spaceType_->nameString() | ||
| 216 | << "' but the Space Type has zero spaces attached to any Thermal Zones, so it will not be translated."); | ||
| 217 | ✗ | return boost::none; | |
| 218 | } | ||
| 219 |
1/1✓ Branch 3 taken 7 times.
|
7 | zoneOrSpaceName = *(zoneNames.begin()); |
| 220 |
2/2✓ Branch 1 taken 6 times.
✓ Branch 2 taken 1 time.
|
7 | if (zoneNames.size() == 1) { |
| 221 |
18/18✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 6 times.
✓ Branch 10 taken 6 times.
✓ Branch 13 taken 6 times.
✓ Branch 16 taken 6 times.
✓ Branch 19 taken 6 times.
✓ Branch 22 taken 6 times.
✓ Branch 25 taken 6 times.
✓ Branch 28 taken 6 times.
✓ Branch 31 taken 6 times.
✓ Branch 34 taken 6 times.
✓ Branch 37 taken 6 times.
✓ Branch 40 taken 6 times.
✓ Branch 43 taken 6 times.
✓ Branch 49 taken 6 times.
✓ Branch 52 taken 6 times.
✓ Branch 55 taken 6 times.
|
6 | LOG(Warn, "Actuator '" << modelObject.nameString() << "' references a SpaceLoad '" << load_->nameString() << "' attached to the SpaceType '" |
| 222 | << spaceType_->nameString() | ||
| 223 | << "' but you have turned off ForwardTranslation's Space Feature. Falling back to using the attached ThermalZone '" | ||
| 224 | << zoneOrSpaceName << "' since there is only 1."); | ||
| 225 | } else { // if (zoneNames.size() > 1) { | ||
| 226 | // TODO: do we grab the first space or just don't translate it? | ||
| 227 |
18/18✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
✓ Branch 16 taken 1 time.
✓ Branch 19 taken 1 time.
✓ Branch 22 taken 1 time.
✓ Branch 25 taken 1 time.
✓ Branch 28 taken 1 time.
✓ Branch 31 taken 1 time.
✓ Branch 34 taken 1 time.
✓ Branch 37 taken 1 time.
✓ Branch 40 taken 1 time.
✓ Branch 43 taken 1 time.
✓ Branch 49 taken 1 time.
✓ Branch 52 taken 1 time.
✓ Branch 55 taken 1 time.
|
1 | LOG(Error, "Actuator '" << modelObject.nameString() << "' references a SpaceLoad '" << load_->nameString() |
| 228 | << "' attached to the SpaceType '" << spaceType_->nameString() | ||
| 229 | << "' but you have turned off ForwardTranslation's Space Feature. " | ||
| 230 | "Your SpaceType ends up linked to multiples Thermal Zones. Falling back to using the first Thermal Zone '" | ||
| 231 | << zoneOrSpaceName << "'."); | ||
| 232 | } | ||
| 233 | 7 | } | |
| 234 | |||
| 235 | // ZoneName object exists so set name to be the concatenation of it plus the spaceloadobject | ||
| 236 |
2/2✓ Branch 1 taken 13 times.
✓ Branch 4 taken 13 times.
|
13 | IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::EnergyManagementSystem_Actuator, modelObject); |
| 237 |
4/4✓ Branch 1 taken 13 times.
✓ Branch 4 taken 13 times.
✓ Branch 7 taken 13 times.
✓ Branch 10 taken 13 times.
|
13 | const std::string spaceLoadNameForEMS = zoneOrSpaceName + " " + actuatedComponent_->nameString(); |
| 238 |
1/1✓ Branch 1 taken 13 times.
|
13 | idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentUniqueName, spaceLoadNameForEMS); |
| 239 |
2/2✓ Branch 1 taken 13 times.
✓ Branch 4 taken 13 times.
|
13 | idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentType, modelObject.actuatedComponentType()); |
| 240 |
2/2✓ Branch 1 taken 13 times.
✓ Branch 4 taken 13 times.
|
13 | idfObject.setString(EnergyManagementSystem_ActuatorFields::ActuatedComponentControlType, modelObject.actuatedComponentControlType()); |
| 241 |
1/1✓ Branch 1 taken 13 times.
|
13 | return idfObject; |
| 242 | 13 | } | |
| 243 | |||
| 244 | return boost::none; | ||
| 245 | 69 | } | |
| 246 | |||
| 247 | } // namespace energyplus | ||
| 248 | |||
| 249 | } // namespace openstudio | ||
| 250 |