src/energyplus/ReverseTranslator/ReverseTranslateOutputVariable.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/OutputVariable.hpp" | ||
| 9 | #include "../../model/OutputVariable_Impl.hpp" | ||
| 10 | #include "../../model/Schedule.hpp" | ||
| 11 | #include "../../model/Schedule_Impl.hpp" | ||
| 12 | |||
| 13 | #include <utilities/idd/Output_Variable_FieldEnums.hxx> | ||
| 14 | |||
| 15 | using namespace openstudio::model; | ||
| 16 | |||
| 17 | namespace openstudio { | ||
| 18 | |||
| 19 | namespace energyplus { | ||
| 20 | |||
| 21 | 105 | OptionalModelObject ReverseTranslator::translateOutputVariable(const WorkspaceObject& workspaceObject) { | |
| 22 | |||
| 23 |
1/1✓ Branch 1 taken 105 times.
|
105 | OptionalString s = workspaceObject.getString(Output_VariableFields::VariableName); |
| 24 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
|
105 | if (!s) { |
| 25 | ✗ | return boost::none; | |
| 26 | } | ||
| 27 | |||
| 28 |
2/2✓ Branch 1 taken 105 times.
✓ Branch 4 taken 105 times.
|
105 | openstudio::model::OutputVariable outputVariable(*s, m_model); |
| 29 | |||
| 30 |
1/1✓ Branch 1 taken 105 times.
|
105 | s = workspaceObject.getString(Output_VariableFields::KeyValue); |
| 31 |
1/2✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
|
105 | if (s) { |
| 32 |
2/2✓ Branch 1 taken 105 times.
✓ Branch 4 taken 105 times.
|
105 | outputVariable.setKeyValue(*s); |
| 33 | } | ||
| 34 | |||
| 35 |
1/1✓ Branch 1 taken 105 times.
|
105 | s = workspaceObject.getString(Output_VariableFields::VariableName); |
| 36 |
1/2✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
|
105 | if (s) { |
| 37 |
2/2✓ Branch 1 taken 105 times.
✓ Branch 4 taken 105 times.
|
105 | outputVariable.setVariableName(*s); |
| 38 | } | ||
| 39 | |||
| 40 |
1/1✓ Branch 1 taken 105 times.
|
105 | s = workspaceObject.getString(Output_VariableFields::ReportingFrequency); |
| 41 |
2/2✓ Branch 0 taken 95 times.
✓ Branch 1 taken 10 times.
|
105 | if (s) { |
| 42 |
2/2✓ Branch 1 taken 95 times.
✓ Branch 4 taken 95 times.
|
95 | outputVariable.setReportingFrequency(*s); |
| 43 | } | ||
| 44 | |||
| 45 |
1/1✓ Branch 1 taken 105 times.
|
105 | OptionalWorkspaceObject target = workspaceObject.getTarget(Output_VariableFields::ScheduleName); |
| 46 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
|
105 | if (target) { |
| 47 | ✗ | OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target); | |
| 48 | ✗ | if (modelObject) { | |
| 49 | ✗ | OptionalSchedule schedule = modelObject->optionalCast<Schedule>(); | |
| 50 | ✗ | if (schedule) { | |
| 51 | ✗ | outputVariable.setSchedule(*schedule); | |
| 52 | } | ||
| 53 | ✗ | } | |
| 54 | ✗ | } | |
| 55 | |||
| 56 |
1/1✓ Branch 1 taken 105 times.
|
105 | return outputVariable; |
| 57 | 105 | } | |
| 58 | |||
| 59 | } // namespace energyplus | ||
| 60 | |||
| 61 | } // namespace openstudio | ||
| 62 |