src/energyplus/ReverseTranslator/ReverseTranslateOutputTableAnnual.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/OutputTableAnnual.hpp" | ||
| 9 | |||
| 10 | #include "../../model/Schedule.hpp" | ||
| 11 | #include "../../model/Schedule_Impl.hpp" | ||
| 12 | |||
| 13 | #include "../../utilities/idf/IdfExtensibleGroup.hpp" | ||
| 14 | |||
| 15 | #include <utilities/idd/Output_Table_Annual_FieldEnums.hxx> | ||
| 16 | #include <utilities/idd/IddEnums.hxx> | ||
| 17 | |||
| 18 | using namespace openstudio::model; | ||
| 19 | |||
| 20 | namespace openstudio { | ||
| 21 | |||
| 22 | namespace energyplus { | ||
| 23 | |||
| 24 | 1 | boost::optional<ModelObject> ReverseTranslator::translateOutputTableAnnual(const WorkspaceObject& workspaceObject) { | |
| 25 | |||
| 26 |
1/1✓ Branch 1 taken 1 time.
|
1 | openstudio::model::OutputTableAnnual modelObject(m_model); |
| 27 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | modelObject.setName(workspaceObject.nameString()); |
| 28 | |||
| 29 | // Filter: Optional String | ||
| 30 |
2/3✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
|
2 | if (boost::optional<std::string> filter_ = workspaceObject.getString(Output_Table_AnnualFields::Filter)) { |
| 31 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | modelObject.setFilter(filter_.get()); |
| 32 | 1 | } | |
| 33 | |||
| 34 | // Schedule Name: Optional Object | ||
| 35 |
2/3✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
|
2 | if (boost::optional<WorkspaceObject> wo_ = workspaceObject.getTarget(Output_Table_AnnualFields::ScheduleName)) { |
| 36 |
3/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
|
2 | if (boost::optional<ModelObject> mo_ = translateAndMapWorkspaceObject(wo_.get())) { |
| 37 |
3/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
|
2 | if (boost::optional<Schedule> schedule_ = mo_->optionalCast<Schedule>()) { |
| 38 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | modelObject.setSchedule(schedule_.get()); |
| 39 | } else { | ||
| 40 | ✗ | LOG(Warn, workspaceObject.briefDescription() << " has a wrong type for 'Schedule Name'"); | |
| 41 | 1 | } | |
| 42 | 1 | } | |
| 43 | 1 | } | |
| 44 | |||
| 45 | // Extensible groups | ||
| 46 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 1 time.
|
3 | for (const IdfExtensibleGroup& eg : workspaceObject.extensibleGroups()) { |
| 47 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | auto variableorMeterorEMSVariableorField = eg.getString(Output_Table_AnnualExtensibleFields::VariableorMeterorEMSVariableorFieldName).get(); |
| 48 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | if (variableorMeterorEMSVariableorField.empty()) { |
| 49 | ✗ | LOG(Warn, "Extensible group " << eg.groupIndex() | |
| 50 | << "(0-indexed) has an empty Variable or Meter or EMS Variable or Field Name field, skipping group"); | ||
| 51 | ✗ | continue; | |
| 52 | ✗ | } | |
| 53 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | auto aggregationType = eg.getString(Output_Table_AnnualExtensibleFields::AggregationTypeforVariableorMeter).get(); |
| 54 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | if (aggregationType.empty()) { |
| 55 | ✗ | LOG(Warn, | |
| 56 | "Extensible group " << eg.groupIndex() << "(0-indexed) has an empty Aggregation Type for VariableorMeter field, assuming SumOrAverage."); | ||
| 57 | ✗ | aggregationType = "SumOrAverage"; | |
| 58 |
2/3✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
|
2 | } else if (!OutputTableAnnual::isAggregationTypeValid(aggregationType)) { |
| 59 | ✗ | LOG(Warn, "Extensible group " << eg.groupIndex() << "(0-indexed) has an Aggregation Type = '" << aggregationType | |
| 60 | << "' that is invalid. Skipping group."); | ||
| 61 | ✗ | continue; | |
| 62 | ✗ | } | |
| 63 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | const int num_digits = eg.getInt(Output_Table_AnnualExtensibleFields::DigitsAfterDecimal).value_or(2); |
| 64 | |||
| 65 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | modelObject.addAnnualVariableGroup(variableorMeterorEMSVariableorField, aggregationType, num_digits); |
| 66 | 3 | } | |
| 67 | |||
| 68 |
1/1✓ Branch 1 taken 1 time.
|
2 | return modelObject; |
| 69 | 1 | } // End of translate function | |
| 70 | |||
| 71 | } // end namespace energyplus | ||
| 72 | } // end namespace openstudio | ||
| 73 |