src/energyplus/ReverseTranslator/ReverseTranslateScheduleTypeLimits.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/ScheduleTypeLimits.hpp" | ||
| 9 | #include "../../model/ScheduleTypeLimits_Impl.hpp" | ||
| 10 | |||
| 11 | #include <utilities/idd/ScheduleTypeLimits_FieldEnums.hxx> | ||
| 12 | #include <utilities/idd/IddEnums.hxx> | ||
| 13 | #include <utilities/idd/OS_ScheduleTypeLimits_FieldEnums.hxx> | ||
| 14 | #include "../../utilities/idd/IddEnums.hpp" | ||
| 15 | |||
| 16 | #include "../../utilities/core/Assert.hpp" | ||
| 17 | |||
| 18 | using namespace openstudio::model; | ||
| 19 | |||
| 20 | namespace openstudio { | ||
| 21 | |||
| 22 | namespace energyplus { | ||
| 23 | |||
| 24 | 217 | OptionalModelObject ReverseTranslator::translateScheduleTypeLimits(const WorkspaceObject& workspaceObject) { | |
| 25 |
4/5✓ Branch 1 taken 217 times.
✓ Branch 4 taken 217 times.
✓ Branch 7 taken 217 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 217 times.
|
217 | if (workspaceObject.iddObject().type() != IddObjectType::ScheduleTypeLimits) { |
| 26 | ✗ | LOG(Error, "WorkspaceObject is not IddObjectType: ScheduleTypeLimits"); | |
| 27 | ✗ | return boost::none; | |
| 28 | } | ||
| 29 | |||
| 30 |
1/1✓ Branch 1 taken 217 times.
|
217 | openstudio::model::ScheduleTypeLimits scheduleTypeLimits(m_model); |
| 31 |
1/1✓ Branch 1 taken 217 times.
|
217 | OptionalString s = workspaceObject.name(); |
| 32 |
1/2✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
|
217 | if (s) { |
| 33 |
22/31✓ Branch 1 taken 217 times.
✓ Branch 3 taken 51 times.
✓ Branch 4 taken 166 times.
✓ Branch 6 taken 51 times.
✓ Branch 9 taken 51 times.
✓ Branch 12 taken 51 times.
✓ Branch 14 taken 8 times.
✓ Branch 15 taken 43 times.
✓ Branch 17 taken 8 times.
✓ Branch 20 taken 8 times.
✓ Branch 23 taken 8 times.
✓ Branch 25 taken 8 times.
✗ Branch 26 not taken.
✓ Branch 27 taken 8 times.
✓ Branch 28 taken 209 times.
✓ Branch 30 taken 8 times.
✓ Branch 31 taken 209 times.
✓ Branch 32 taken 51 times.
✓ Branch 33 taken 166 times.
✓ Branch 35 taken 51 times.
✓ Branch 36 taken 166 times.
✓ Branch 37 taken 51 times.
✓ Branch 38 taken 166 times.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
|
335 | if ((workspaceObject.numFields() == 1u) && (istringEqual(*s, "Any Number") || istringEqual(*s, "Number"))) { |
| 34 | // Do not translate ScheduleTypeLimits called "Any Number" or "Number" and | ||
| 35 | // with no other fields specified. Instead, let ModelObjects assign more | ||
| 36 | // meaningful limits. | ||
| 37 |
6/6✓ Branch 1 taken 51 times.
✓ Branch 4 taken 51 times.
✓ Branch 7 taken 51 times.
✓ Branch 10 taken 51 times.
✓ Branch 13 taken 51 times.
✓ Branch 16 taken 51 times.
|
51 | LOG(Info, "The energyplus::ReverseTranslator throws out all 'Any Number' ScheduleTypeLimits " |
| 38 | << "to leave the OpenStudio model free to apply the appropriate units and limits."); | ||
| 39 | 51 | return boost::none; | |
| 40 | } | ||
| 41 |
2/2✓ Branch 1 taken 166 times.
✓ Branch 4 taken 166 times.
|
166 | scheduleTypeLimits.setName(*s); |
| 42 | } | ||
| 43 | |||
| 44 |
1/1✓ Branch 1 taken 166 times.
|
166 | OptionalDouble d = workspaceObject.getDouble(ScheduleTypeLimitsFields::LowerLimitValue); |
| 45 |
2/2✓ Branch 0 taken 159 times.
✓ Branch 1 taken 7 times.
|
166 | if (d) { |
| 46 |
2/2✓ Branch 1 taken 159 times.
✓ Branch 4 taken 159 times.
|
159 | scheduleTypeLimits.setLowerLimitValue(*d); |
| 47 | } | ||
| 48 | |||
| 49 |
1/1✓ Branch 1 taken 166 times.
|
166 | d = workspaceObject.getDouble(ScheduleTypeLimitsFields::UpperLimitValue); |
| 50 |
2/2✓ Branch 0 taken 152 times.
✓ Branch 1 taken 14 times.
|
166 | if (d) { |
| 51 |
2/2✓ Branch 1 taken 152 times.
✓ Branch 4 taken 152 times.
|
152 | scheduleTypeLimits.setUpperLimitValue(*d); |
| 52 | } | ||
| 53 | |||
| 54 |
1/1✓ Branch 1 taken 166 times.
|
166 | s = workspaceObject.getString(ScheduleTypeLimitsFields::NumericType); |
| 55 |
1/2✓ Branch 0 taken 166 times.
✗ Branch 1 not taken.
|
166 | if (s) { |
| 56 |
2/2✓ Branch 1 taken 166 times.
✓ Branch 4 taken 166 times.
|
166 | scheduleTypeLimits.setNumericType(*s); |
| 57 | } | ||
| 58 | |||
| 59 |
1/1✓ Branch 1 taken 166 times.
|
166 | s = workspaceObject.getString(ScheduleTypeLimitsFields::UnitType); |
| 60 |
2/2✓ Branch 0 taken 65 times.
✓ Branch 1 taken 101 times.
|
166 | if (s) { |
| 61 |
2/2✓ Branch 1 taken 65 times.
✓ Branch 4 taken 65 times.
|
65 | scheduleTypeLimits.setUnitType(*s); |
| 62 | } else { | ||
| 63 | bool test; | ||
| 64 | // Attempt to default based on name (many EnergyPlus files do not have this field filled out). | ||
| 65 |
3/3✓ Branch 1 taken 101 times.
✓ Branch 4 taken 101 times.
✓ Branch 7 taken 101 times.
|
101 | std::string name = scheduleTypeLimits.name().get(); |
| 66 |
4/4✓ Branch 1 taken 101 times.
✓ Branch 4 taken 101 times.
✓ Branch 7 taken 9 times.
✓ Branch 8 taken 92 times.
|
101 | if (boost::regex_search(name, boost::regex("[Tt][Ee][Mm][Pp]"))) { |
| 67 |
3/4✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 9 times.
|
9 | if (boost::regex_search(name, boost::regex("[Dd][Ee][Ll][Tt][Aa]"))) { |
| 68 | ✗ | test = scheduleTypeLimits.setUnitType("DeltaTemperature"); | |
| 69 | ✗ | OS_ASSERT(test); | |
| 70 | } else { | ||
| 71 |
2/2✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
|
9 | test = scheduleTypeLimits.setUnitType("Temperature"); |
| 72 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 3 not taken.
|
9 | OS_ASSERT(test); |
| 73 | } | ||
| 74 |
13/18✓ Branch 1 taken 92 times.
✓ Branch 4 taken 92 times.
✓ Branch 6 taken 83 times.
✓ Branch 7 taken 9 times.
✓ Branch 9 taken 83 times.
✓ Branch 12 taken 83 times.
✓ Branch 14 taken 8 times.
✓ Branch 15 taken 75 times.
✓ Branch 16 taken 83 times.
✓ Branch 17 taken 9 times.
✓ Branch 19 taken 92 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 8 times.
✓ Branch 23 taken 84 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
|
92 | } else if (boost::regex_search(name, boost::regex("[Oo][Nn]")) && boost::regex_search(name, boost::regex("[Oo][Ff][Ff]"))) { |
| 75 |
2/2✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
|
8 | test = scheduleTypeLimits.setUnitType("Availability"); |
| 76 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✗ Branch 3 not taken.
|
8 | OS_ASSERT(test); |
| 77 |
4/4✓ Branch 1 taken 84 times.
✓ Branch 4 taken 84 times.
✓ Branch 7 taken 9 times.
✓ Branch 8 taken 75 times.
|
84 | } else if (boost::regex_search(name, boost::regex("[Cc][Oo][Nn][Tt][Rr][Oo][Ll]"))) { |
| 78 |
2/2✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
|
9 | test = scheduleTypeLimits.setUnitType("ControlMode"); |
| 79 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 3 not taken.
|
9 | OS_ASSERT(test); |
| 80 | } | ||
| 81 | 101 | } | |
| 82 | |||
| 83 |
1/1✓ Branch 1 taken 166 times.
|
166 | return scheduleTypeLimits; |
| 84 | 217 | } | |
| 85 | |||
| 86 | } // namespace energyplus | ||
| 87 | |||
| 88 | } // namespace openstudio | ||
| 89 |