src/energyplus/ReverseTranslator/ReverseTranslateOtherEquipment.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/OtherEquipment.hpp" | ||
| 9 | #include "../../model/OtherEquipment_Impl.hpp" | ||
| 10 | #include "../../model/OtherEquipmentDefinition.hpp" | ||
| 11 | #include "../../model/OtherEquipmentDefinition_Impl.hpp" | ||
| 12 | #include "../../model/Space.hpp" | ||
| 13 | #include "../../model/Space_Impl.hpp" | ||
| 14 | #include "../../model/SpaceType.hpp" | ||
| 15 | #include "../../model/SpaceType_Impl.hpp" | ||
| 16 | #include "../../model/Schedule.hpp" | ||
| 17 | #include "../../model/Schedule_Impl.hpp" | ||
| 18 | |||
| 19 | #include <utilities/idd/OtherEquipment_FieldEnums.hxx> | ||
| 20 | #include "../../utilities/idd/IddEnums.hpp" | ||
| 21 | #include <utilities/idd/IddEnums.hxx> | ||
| 22 | |||
| 23 | #include "../../utilities/core/Assert.hpp" | ||
| 24 | |||
| 25 | using namespace openstudio::model; | ||
| 26 | |||
| 27 | namespace openstudio { | ||
| 28 | |||
| 29 | namespace energyplus { | ||
| 30 | |||
| 31 | 1 | OptionalModelObject ReverseTranslator::translateOtherEquipment(const WorkspaceObject& workspaceObject) { | |
| 32 |
4/5✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 time.
|
1 | if (workspaceObject.iddObject().type() != IddObjectType::OtherEquipment) { |
| 33 | ✗ | LOG(Error, "WorkspaceObject is not IddObjectType::OtherEquipment"); | |
| 34 | ✗ | return boost::none; | |
| 35 | } | ||
| 36 | |||
| 37 |
6/6✓ 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.
|
1 | LOG(Info, |
| 38 | "OtherEquipment is an internal load separate from any other system, and not " << "associated with an end use subcategory. Use with caution."); | ||
| 39 | |||
| 40 | // create the definition | ||
| 41 |
1/1✓ Branch 1 taken 1 time.
|
1 | openstudio::model::OtherEquipmentDefinition definition(m_model); |
| 42 | |||
| 43 |
1/1✓ Branch 1 taken 1 time.
|
1 | OptionalString s = workspaceObject.name(); |
| 44 |
1/2✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
|
1 | if (s) { |
| 45 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | definition.setName(*s + " Definition"); |
| 46 | } | ||
| 47 | |||
| 48 |
1/1✓ Branch 1 taken 1 time.
|
1 | s = workspaceObject.getString(openstudio::OtherEquipmentFields::DesignLevelCalculationMethod, true); |
| 49 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
✗ Branch 4 not taken.
|
1 | OS_ASSERT(s); |
| 50 | |||
| 51 | 1 | OptionalDouble d; | |
| 52 |
4/5✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✗ Branch 11 not taken.
|
3 | if (istringEqual("EquipmentLevel", *s)) { |
| 53 |
1/1✓ Branch 1 taken 1 time.
|
1 | d = workspaceObject.getDouble(openstudio::OtherEquipmentFields::DesignLevel); |
| 54 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
|
1 | if (d) { |
| 55 | ✗ | if (d.get() < 0.0) { | |
| 56 | ✗ | LOG(Warn, "OtherEquipment has negative energy use. Advanced feature--use with caution."); | |
| 57 | } | ||
| 58 | ✗ | definition.setDesignLevel(*d); | |
| 59 | } else { | ||
| 60 |
6/6✓ 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.
|
1 | LOG(Error, "EquipmentLevel value not found for workspace object " << workspaceObject); |
| 61 | } | ||
| 62 | ✗ | } else if (istringEqual("Watts/Area", *s)) { | |
| 63 | ✗ | d = workspaceObject.getDouble(openstudio::OtherEquipmentFields::PowerperFloorArea); | |
| 64 | ✗ | if (d) { | |
| 65 | ✗ | if (d.get() < 0.0) { | |
| 66 | ✗ | LOG(Warn, "OtherEquipment has negative energy use. Advanced feature--use with caution."); | |
| 67 | } | ||
| 68 | ✗ | definition.setWattsperSpaceFloorArea(*d); | |
| 69 | } else { | ||
| 70 | ✗ | LOG(Error, "Watts/Area value not found for workspace object " << workspaceObject); | |
| 71 | } | ||
| 72 | ✗ | } else if (istringEqual("Watts/Person", *s)) { | |
| 73 | ✗ | d = workspaceObject.getDouble(openstudio::OtherEquipmentFields::PowerperPerson); | |
| 74 | ✗ | if (d) { | |
| 75 | ✗ | if (d.get() < 0.0) { | |
| 76 | ✗ | LOG(Warn, "OtherEquipment has negative energy use. Advanced feature--use with caution."); | |
| 77 | } | ||
| 78 | ✗ | definition.setWattsperPerson(*d); | |
| 79 | } else { | ||
| 80 | ✗ | LOG(Error, "Watts/Person value not found for workspace object " << workspaceObject); | |
| 81 | } | ||
| 82 | } else { | ||
| 83 | ✗ | LOG(Error, "Unknown DesignLevelCalculationMethod value for workspace object" << workspaceObject); | |
| 84 | } | ||
| 85 | |||
| 86 |
1/1✓ Branch 1 taken 1 time.
|
1 | d = workspaceObject.getDouble(openstudio::OtherEquipmentFields::FractionLatent); |
| 87 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
|
1 | if (d) { |
| 88 | ✗ | definition.setFractionLatent(*d); | |
| 89 | } | ||
| 90 | |||
| 91 |
1/1✓ Branch 1 taken 1 time.
|
1 | d = workspaceObject.getDouble(openstudio::OtherEquipmentFields::FractionRadiant); |
| 92 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
|
1 | if (d) { |
| 93 | ✗ | definition.setFractionRadiant(*d); | |
| 94 | } | ||
| 95 | |||
| 96 |
1/1✓ Branch 1 taken 1 time.
|
1 | d = workspaceObject.getDouble(openstudio::OtherEquipmentFields::FractionLost); |
| 97 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
|
1 | if (d) { |
| 98 | ✗ | definition.setFractionLost(*d); | |
| 99 | } | ||
| 100 | |||
| 101 | // create the instance | ||
| 102 |
1/1✓ Branch 1 taken 1 time.
|
1 | OtherEquipment otherEquipment(definition); |
| 103 | |||
| 104 |
1/1✓ Branch 1 taken 1 time.
|
1 | s = workspaceObject.name(); |
| 105 |
1/2✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
|
1 | if (s) { |
| 106 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | otherEquipment.setName(*s); |
| 107 | } | ||
| 108 | |||
| 109 |
1/1✓ Branch 1 taken 1 time.
|
1 | OptionalWorkspaceObject target = workspaceObject.getTarget(openstudio::OtherEquipmentFields::ZoneorZoneListorSpaceorSpaceListName); |
| 110 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
|
1 | if (target) { |
| 111 | ✗ | OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target); | |
| 112 | ✗ | if (modelObject) { | |
| 113 | ✗ | if (modelObject->optionalCast<Space>()) { | |
| 114 | ✗ | otherEquipment.setSpace(modelObject->cast<Space>()); | |
| 115 | ✗ | } else if (modelObject->optionalCast<SpaceType>()) { | |
| 116 | ✗ | otherEquipment.setSpaceType(modelObject->cast<SpaceType>()); | |
| 117 | } | ||
| 118 | } | ||
| 119 | ✗ | } | |
| 120 | |||
| 121 |
1/1✓ Branch 1 taken 1 time.
|
1 | target = workspaceObject.getTarget(openstudio::OtherEquipmentFields::ScheduleName); |
| 122 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
|
1 | if (target) { |
| 123 | ✗ | OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target); | |
| 124 | ✗ | if (modelObject) { | |
| 125 | ✗ | if (OptionalSchedule intermediate = modelObject->optionalCast<Schedule>()) { | |
| 126 | ✗ | Schedule schedule(*intermediate); | |
| 127 | ✗ | otherEquipment.setSchedule(schedule); | |
| 128 | ✗ | } | |
| 129 | } | ||
| 130 | ✗ | } | |
| 131 | |||
| 132 |
1/1✓ Branch 1 taken 1 time.
|
1 | s = workspaceObject.getString(openstudio::OtherEquipmentFields::EndUseSubcategory); |
| 133 |
1/2✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
|
1 | if (s) { |
| 134 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | otherEquipment.setEndUseSubcategory(*s); |
| 135 | } | ||
| 136 | |||
| 137 |
1/1✓ Branch 1 taken 1 time.
|
1 | return otherEquipment; |
| 138 | 1 | } | |
| 139 | |||
| 140 | } // namespace energyplus | ||
| 141 | |||
| 142 | } // namespace openstudio | ||
| 143 |