src/energyplus/ReverseTranslator/ReverseTranslateOutputTableMonthly.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/OutputTableMonthly.hpp" | ||
| 9 | |||
| 10 | #include "../../utilities/idf/IdfExtensibleGroup.hpp" | ||
| 11 | |||
| 12 | #include <utilities/idd/Output_Table_Monthly_FieldEnums.hxx> | ||
| 13 | #include <utilities/idd/IddEnums.hxx> | ||
| 14 | |||
| 15 | using namespace openstudio::model; | ||
| 16 | |||
| 17 | namespace openstudio { | ||
| 18 | |||
| 19 | namespace energyplus { | ||
| 20 | |||
| 21 | 96 | boost::optional<ModelObject> ReverseTranslator::translateOutputTableMonthly(const WorkspaceObject& workspaceObject) { | |
| 22 | |||
| 23 |
1/1✓ Branch 1 taken 96 times.
|
96 | openstudio::model::OutputTableMonthly modelObject(m_model); |
| 24 | |||
| 25 | // Name | ||
| 26 |
2/2✓ Branch 1 taken 96 times.
✓ Branch 4 taken 96 times.
|
96 | modelObject.setName(workspaceObject.nameString()); |
| 27 | |||
| 28 | // Digits After Decimal: Optional Integer | ||
| 29 |
2/3✓ Branch 1 taken 96 times.
✓ Branch 3 taken 96 times.
✗ Branch 4 not taken.
|
192 | if (boost::optional<int> digitsAfterDecimal_ = workspaceObject.getInt(Output_Table_MonthlyFields::DigitsAfterDecimal)) { |
| 30 |
2/2✓ Branch 1 taken 96 times.
✓ Branch 4 taken 96 times.
|
96 | modelObject.setDigitsAfterDecimal(digitsAfterDecimal_.get()); |
| 31 | } | ||
| 32 | |||
| 33 | // Extensible groups | ||
| 34 |
3/3✓ Branch 1 taken 96 times.
✓ Branch 8 taken 943 times.
✓ Branch 9 taken 96 times.
|
1039 | for (const IdfExtensibleGroup& eg : workspaceObject.extensibleGroups()) { |
| 35 |
3/3✓ Branch 1 taken 943 times.
✓ Branch 4 taken 943 times.
✓ Branch 7 taken 943 times.
|
943 | auto variableorMeterName = eg.getString(Output_Table_MonthlyExtensibleFields::VariableorMeterName).get(); |
| 36 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 943 times.
|
943 | if (variableorMeterName.empty()) { |
| 37 | ✗ | LOG(Warn, "Extensible group " << eg.groupIndex() << "(0-indexed) has an empty Variable or Meter Name field, skipping group"); | |
| 38 | ✗ | continue; | |
| 39 | ✗ | } | |
| 40 |
3/3✓ Branch 1 taken 943 times.
✓ Branch 4 taken 943 times.
✓ Branch 7 taken 943 times.
|
943 | auto aggregationType = eg.getString(Output_Table_MonthlyExtensibleFields::AggregationTypeforVariableorMeter).get(); |
| 41 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 943 times.
|
943 | if (aggregationType.empty()) { |
| 42 | ✗ | LOG(Warn, | |
| 43 | "Extensible group " << eg.groupIndex() << "(0-indexed) has an empty Aggregation Type for VariableorMeter field, assuming SumOrAverage."); | ||
| 44 | ✗ | aggregationType = "SumOrAverage"; | |
| 45 |
2/3✓ Branch 1 taken 943 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 943 times.
|
943 | } else if (!OutputTableMonthly::isAggregationTypeValid(aggregationType)) { |
| 46 | ✗ | LOG(Warn, "Extensible group " << eg.groupIndex() << "(0-indexed) has an Aggregation Type = '" << aggregationType | |
| 47 | << "' that is invalid. Skipping group."); | ||
| 48 | ✗ | continue; | |
| 49 | ✗ | } | |
| 50 | |||
| 51 |
4/5✓ Branch 1 taken 943 times.
✓ Branch 4 taken 943 times.
✓ Branch 7 taken 943 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 943 times.
|
943 | if (!modelObject.addMonthlyVariableGroup(variableorMeterName, aggregationType)) { |
| 52 | ✗ | LOG(Warn, "Extensible group " << eg.groupIndex() << "(0-indexed) is already present, not adding it twice"); | |
| 53 | } | ||
| 54 | 1039 | } | |
| 55 | |||
| 56 |
1/1✓ Branch 1 taken 96 times.
|
192 | return modelObject; |
| 57 | 96 | } // End of translate function | |
| 58 | |||
| 59 | } // end namespace energyplus | ||
| 60 | } // end namespace openstudio | ||
| 61 |