src/energyplus/ForwardTranslator/ForwardTranslateLights.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 | #include "../../model/Lights.hpp" | ||
| 8 | #include "../../model/LightsDefinition.hpp" | ||
| 9 | #include "../../model/Space.hpp" | ||
| 10 | #include "../../model/SpaceType.hpp" | ||
| 11 | #include "../../model/ThermalZone.hpp" | ||
| 12 | #include "../../model/Schedule.hpp" | ||
| 13 | #include "../../model/LifeCycleCost.hpp" | ||
| 14 | #include <utilities/idd/Lights_FieldEnums.hxx> | ||
| 15 | #include <utilities/idd/Lights_Instance_FieldEnums.hxx> | ||
| 16 | #include <utilities/idd/IddEnums.hxx> | ||
| 17 | |||
| 18 | using namespace openstudio::model; | ||
| 19 | |||
| 20 | using namespace std; | ||
| 21 | |||
| 22 | namespace openstudio { | ||
| 23 | |||
| 24 | namespace energyplus { | ||
| 25 | |||
| 26 | 246 | boost::optional<IdfObject> ForwardTranslator::translateLights(Lights& modelObject) { | |
| 27 |
2/2✓ Branch 1 taken 71 times.
✓ Branch 2 taken 175 times.
|
246 | if (m_forwardTranslatorOptions.excludeSpaceLoadInstances()) { |
| 28 | 71 | return translateLightsLegacy(modelObject); | |
| 29 | } | ||
| 30 | 175 | return translateLightsInstance(modelObject); | |
| 31 | } | ||
| 32 | |||
| 33 | 71 | boost::optional<IdfObject> ForwardTranslator::translateLightsLegacy(Lights& modelObject) { | |
| 34 | // create, register, and name object | ||
| 35 |
2/2✓ Branch 1 taken 71 times.
✓ Branch 4 taken 71 times.
|
71 | IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::Lights, modelObject); |
| 36 | |||
| 37 |
2/4✓ Branch 1 taken 71 times.
✗ Branch 7 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 71 times.
|
71 | for (LifeCycleCost lifeCycleCost : modelObject.lifeCycleCosts()) { |
| 38 | ✗ | translateAndMapModelObject(lifeCycleCost); | |
| 39 | 71 | } | |
| 40 | |||
| 41 |
1/1✓ Branch 1 taken 71 times.
|
71 | LightsDefinition definition = modelObject.lightsDefinition(); |
| 42 | |||
| 43 |
1/1✓ Branch 1 taken 71 times.
|
71 | IdfObject parentIdfObject = getSpaceLoadParent(modelObject); |
| 44 |
2/2✓ Branch 1 taken 71 times.
✓ Branch 4 taken 71 times.
|
71 | idfObject.setString(LightsFields::ZoneorZoneListorSpaceorSpaceListName, parentIdfObject.nameString()); |
| 45 | |||
| 46 |
3/3✓ Branch 1 taken 71 times.
✓ Branch 3 taken 19 times.
✓ Branch 4 taken 52 times.
|
142 | if (boost::optional<Schedule> schedule = modelObject.schedule()) { |
| 47 |
2/2✓ Branch 1 taken 19 times.
✓ Branch 4 taken 19 times.
|
19 | auto idf_schedule_ = translateAndMapModelObject(*schedule); |
| 48 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 19 times.
✗ Branch 4 not taken.
|
19 | OS_ASSERT(idf_schedule_); |
| 49 |
3/3✓ Branch 1 taken 19 times.
✓ Branch 4 taken 19 times.
✓ Branch 7 taken 19 times.
|
19 | idfObject.setString(LightsFields::ScheduleName, idf_schedule_->nameString()); |
| 50 | 90 | } | |
| 51 | |||
| 52 |
2/2✓ Branch 1 taken 71 times.
✓ Branch 4 taken 71 times.
|
71 | idfObject.setString(LightsFields::DesignLevelCalculationMethod, definition.designLevelCalculationMethod()); |
| 53 | |||
| 54 |
1/1✓ Branch 1 taken 71 times.
|
71 | double multiplier = modelObject.multiplier(); |
| 55 | |||
| 56 |
1/1✓ Branch 1 taken 71 times.
|
71 | boost::optional<double> d = definition.lightingLevel(); |
| 57 |
2/2✓ Branch 0 taken 37 times.
✓ Branch 1 taken 34 times.
|
71 | if (d) { |
| 58 |
2/2✓ Branch 1 taken 37 times.
✓ Branch 4 taken 37 times.
|
37 | idfObject.setDouble(LightsFields::LightingLevel, (*d) * multiplier); |
| 59 | } | ||
| 60 | |||
| 61 |
1/1✓ Branch 1 taken 71 times.
|
71 | d = definition.wattsperSpaceFloorArea(); |
| 62 |
2/2✓ Branch 0 taken 34 times.
✓ Branch 1 taken 37 times.
|
71 | if (d) { |
| 63 |
2/2✓ Branch 1 taken 34 times.
✓ Branch 4 taken 34 times.
|
34 | idfObject.setDouble(LightsFields::WattsperFloorArea, (*d) * multiplier); |
| 64 | } | ||
| 65 | |||
| 66 |
1/1✓ Branch 1 taken 71 times.
|
71 | d = definition.wattsperPerson(); |
| 67 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
|
71 | if (d) { |
| 68 | ✗ | idfObject.setDouble(LightsFields::WattsperPerson, (*d) * multiplier); | |
| 69 | } | ||
| 70 | |||
| 71 |
2/3✓ Branch 1 taken 71 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 71 times.
|
71 | if (!definition.isReturnAirFractionDefaulted()) { |
| 72 | ✗ | idfObject.setDouble(LightsFields::ReturnAirFraction, definition.returnAirFraction()); | |
| 73 | } | ||
| 74 | |||
| 75 |
2/3✓ Branch 1 taken 71 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 71 times.
|
71 | if (!definition.isFractionRadiantDefaulted()) { |
| 76 | ✗ | idfObject.setDouble(LightsFields::FractionRadiant, definition.fractionRadiant()); | |
| 77 | } | ||
| 78 | |||
| 79 |
2/3✓ Branch 1 taken 71 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 71 times.
|
71 | if (!definition.isFractionVisibleDefaulted()) { |
| 80 | ✗ | idfObject.setDouble(LightsFields::FractionVisible, definition.fractionVisible()); | |
| 81 | } | ||
| 82 | |||
| 83 |
2/3✓ Branch 1 taken 71 times.
✓ Branch 3 taken 71 times.
✗ Branch 4 not taken.
|
71 | if (!modelObject.isFractionReplaceableDefaulted()) { |
| 84 |
2/2✓ Branch 1 taken 71 times.
✓ Branch 4 taken 71 times.
|
71 | idfObject.setDouble(LightsFields::FractionReplaceable, modelObject.fractionReplaceable()); |
| 85 | } | ||
| 86 | |||
| 87 |
2/3✓ Branch 1 taken 71 times.
✓ Branch 3 taken 71 times.
✗ Branch 4 not taken.
|
71 | if (!modelObject.isEndUseSubcategoryDefaulted()) { |
| 88 |
2/2✓ Branch 1 taken 71 times.
✓ Branch 4 taken 71 times.
|
71 | idfObject.setString(LightsFields::EndUseSubcategory, modelObject.endUseSubcategory()); |
| 89 | } | ||
| 90 | |||
| 91 |
2/3✓ Branch 1 taken 71 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 71 times.
|
71 | if (!definition.isReturnAirFractionCalculatedfromPlenumTemperatureDefaulted()) { |
| 92 | ✗ | if (definition.returnAirFractionCalculatedfromPlenumTemperature()) { | |
| 93 | ✗ | idfObject.setString(LightsFields::ReturnAirFractionCalculatedfromPlenumTemperature, "Yes"); | |
| 94 | } else { | ||
| 95 | ✗ | idfObject.setString(LightsFields::ReturnAirFractionCalculatedfromPlenumTemperature, "No"); | |
| 96 | } | ||
| 97 | } | ||
| 98 | |||
| 99 |
2/3✓ Branch 1 taken 71 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 71 times.
|
71 | if (!definition.isReturnAirFractionFunctionofPlenumTemperatureCoefficient1Defaulted()) { |
| 100 | ✗ | idfObject.setDouble(LightsFields::ReturnAirFractionFunctionofPlenumTemperatureCoefficient1, | |
| 101 | definition.returnAirFractionFunctionofPlenumTemperatureCoefficient1()); | ||
| 102 | } | ||
| 103 | |||
| 104 |
2/3✓ Branch 1 taken 71 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 71 times.
|
71 | if (!definition.isReturnAirFractionFunctionofPlenumTemperatureCoefficient2Defaulted()) { |
| 105 | ✗ | idfObject.setDouble(LightsFields::ReturnAirFractionFunctionofPlenumTemperatureCoefficient2, | |
| 106 | definition.returnAirFractionFunctionofPlenumTemperatureCoefficient2()); | ||
| 107 | } | ||
| 108 | |||
| 109 |
1/1✓ Branch 1 taken 71 times.
|
142 | return idfObject; |
| 110 | 71 | } | |
| 111 | |||
| 112 | 175 | boost::optional<IdfObject> ForwardTranslator::translateLightsInstance(Lights& modelObject) { | |
| 113 | |||
| 114 |
2/2✓ Branch 1 taken 175 times.
✓ Branch 4 taken 175 times.
|
175 | IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::Lights_Instance, modelObject); |
| 115 | |||
| 116 |
2/4✓ Branch 1 taken 175 times.
✗ Branch 7 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 175 times.
|
175 | for (LifeCycleCost lifeCycleCost : modelObject.lifeCycleCosts()) { |
| 117 | ✗ | translateAndMapModelObject(lifeCycleCost); | |
| 118 | 175 | } | |
| 119 | |||
| 120 |
1/1✓ Branch 1 taken 175 times.
|
175 | LightsDefinition definition = modelObject.lightsDefinition(); |
| 121 |
1/1✓ Branch 1 taken 175 times.
|
175 | auto definitionIdfObject_ = translateAndMapModelObject(definition); |
| 122 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 175 times.
✗ Branch 4 not taken.
|
175 | OS_ASSERT(definitionIdfObject_); |
| 123 |
3/3✓ Branch 1 taken 175 times.
✓ Branch 4 taken 175 times.
✓ Branch 7 taken 175 times.
|
175 | idfObject.setString(Lights_InstanceFields::LightsDefinitionName, definitionIdfObject_->nameString()); |
| 124 | |||
| 125 |
1/1✓ Branch 1 taken 175 times.
|
175 | IdfObject parentIdfObject = getSpaceLoadParent(modelObject); |
| 126 |
2/2✓ Branch 1 taken 175 times.
✓ Branch 4 taken 175 times.
|
175 | idfObject.setString(Lights_InstanceFields::ZoneorZoneListorSpaceorSpaceListName, parentIdfObject.nameString()); |
| 127 | |||
| 128 |
3/3✓ Branch 1 taken 175 times.
✓ Branch 3 taken 160 times.
✓ Branch 4 taken 15 times.
|
350 | if (boost::optional<Schedule> schedule = modelObject.schedule()) { |
| 129 |
2/2✓ Branch 1 taken 160 times.
✓ Branch 4 taken 160 times.
|
160 | auto idf_schedule_ = translateAndMapModelObject(*schedule); |
| 130 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 160 times.
✗ Branch 4 not taken.
|
160 | OS_ASSERT(idf_schedule_); |
| 131 |
3/3✓ Branch 1 taken 160 times.
✓ Branch 4 taken 160 times.
✓ Branch 7 taken 160 times.
|
160 | idfObject.setString(Lights_InstanceFields::ScheduleName, idf_schedule_->nameString()); |
| 132 | 335 | } | |
| 133 | |||
| 134 |
3/3✓ Branch 1 taken 175 times.
✓ Branch 3 taken 55 times.
✓ Branch 4 taken 120 times.
|
175 | if (!modelObject.isFractionReplaceableDefaulted()) { |
| 135 |
2/2✓ Branch 1 taken 55 times.
✓ Branch 4 taken 55 times.
|
55 | idfObject.setDouble(Lights_InstanceFields::FractionReplaceable, modelObject.fractionReplaceable()); |
| 136 | } | ||
| 137 | |||
| 138 |
2/2✓ Branch 1 taken 175 times.
✓ Branch 4 taken 175 times.
|
175 | idfObject.setDouble(Lights_InstanceFields::Multiplier, modelObject.multiplier()); |
| 139 | |||
| 140 |
3/3✓ Branch 1 taken 175 times.
✓ Branch 3 taken 55 times.
✓ Branch 4 taken 120 times.
|
175 | if (!modelObject.isEndUseSubcategoryDefaulted()) { |
| 141 |
2/2✓ Branch 1 taken 55 times.
✓ Branch 4 taken 55 times.
|
55 | idfObject.setString(Lights_InstanceFields::EndUseSubcategory, modelObject.endUseSubcategory()); |
| 142 | } | ||
| 143 | |||
| 144 |
1/1✓ Branch 1 taken 175 times.
|
350 | return idfObject; |
| 145 | 175 | } | |
| 146 | |||
| 147 | } // namespace energyplus | ||
| 148 | |||
| 149 | } // namespace openstudio | ||
| 150 |