src/energyplus/ReverseTranslator/ReverseTranslateRunPeriodControlSpecialDays.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 | #include "../../model/RunPeriodControlSpecialDays.hpp" | ||
| 8 | #include "../../model/RunPeriodControlSpecialDays_Impl.hpp" | ||
| 9 | #include <utilities/idd/RunPeriodControl_SpecialDays_FieldEnums.hxx> | ||
| 10 | #include <utilities/idd/OS_RunPeriodControl_SpecialDays_FieldEnums.hxx> | ||
| 11 | #include "../../utilities/idd/IddEnums.hpp" | ||
| 12 | #include <utilities/idd/IddEnums.hxx> | ||
| 13 | |||
| 14 | using namespace openstudio::model; | ||
| 15 | |||
| 16 | namespace openstudio { | ||
| 17 | |||
| 18 | namespace energyplus { | ||
| 19 | |||
| 20 | 80 | OptionalModelObject ReverseTranslator::translateRunPeriodControlSpecialDays(const WorkspaceObject& workspaceObject) { | |
| 21 |
4/5✓ Branch 1 taken 80 times.
✓ Branch 4 taken 80 times.
✓ Branch 7 taken 80 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 80 times.
|
80 | if (workspaceObject.iddObject().type() != IddObjectType::RunPeriodControl_SpecialDays) { |
| 22 | ✗ | LOG(Error, "WorkspaceObject is not IddObjectType: RunPeriodControl_SpecialDays"); | |
| 23 | ✗ | return boost::none; | |
| 24 | } | ||
| 25 | |||
| 26 |
1/1✓ Branch 1 taken 80 times.
|
80 | boost::optional<std::string> s = workspaceObject.getString(RunPeriodControl_SpecialDaysFields::StartDate); |
| 27 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
|
80 | if (!s) { |
| 28 | ✗ | LOG(Error, "No start date specified for RunPeriodControl:SpecialDays"); | |
| 29 | ✗ | return boost::none; | |
| 30 | } | ||
| 31 | |||
| 32 | 80 | boost::optional<RunPeriodControlSpecialDays> mo; | |
| 33 | try { | ||
| 34 |
3/3✓ Branch 1 taken 80 times.
✓ Branch 4 taken 80 times.
✓ Branch 7 taken 80 times.
|
80 | mo = RunPeriodControlSpecialDays(*s, m_model); |
| 35 | ✗ | } catch (...) { | |
| 36 | ✗ | LOG(Error, "'" << *s << "' is not a correct date specification"); | |
| 37 | ✗ | return boost::none; | |
| 38 | ✗ | } | |
| 39 | |||
| 40 |
1/1✓ Branch 1 taken 80 times.
|
80 | s = workspaceObject.getString(RunPeriodControl_SpecialDaysFields::Name); |
| 41 |
1/2✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
|
80 | if (s) { |
| 42 |
3/3✓ Branch 1 taken 80 times.
✓ Branch 4 taken 80 times.
✓ Branch 7 taken 80 times.
|
80 | mo->setName(s.get()); |
| 43 | } | ||
| 44 | |||
| 45 |
1/1✓ Branch 1 taken 80 times.
|
80 | boost::optional<int> i = workspaceObject.getInt(RunPeriodControl_SpecialDaysFields::Duration); |
| 46 |
1/2✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
|
80 | if (i) { |
| 47 |
3/3✓ Branch 1 taken 80 times.
✓ Branch 4 taken 80 times.
✓ Branch 7 taken 80 times.
|
80 | mo->setDuration(i.get()); |
| 48 | } | ||
| 49 | |||
| 50 |
1/1✓ Branch 1 taken 80 times.
|
80 | s = workspaceObject.getString(RunPeriodControl_SpecialDaysFields::SpecialDayType); |
| 51 |
1/2✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
|
80 | if (s) { |
| 52 |
3/3✓ Branch 1 taken 80 times.
✓ Branch 4 taken 80 times.
✓ Branch 7 taken 80 times.
|
80 | mo->setString(OS_RunPeriodControl_SpecialDaysFields::SpecialDayType, s.get()); |
| 53 | } | ||
| 54 | |||
| 55 |
2/2✓ Branch 1 taken 80 times.
✓ Branch 4 taken 80 times.
|
80 | return *mo; |
| 56 | 80 | } | |
| 57 | |||
| 58 | } // namespace energyplus | ||
| 59 | |||
| 60 | } // namespace openstudio | ||
| 61 |