src/model/ExternalInterfaceSchedule.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 "ExternalInterfaceSchedule.hpp" | ||
| 7 | #include "ExternalInterfaceSchedule_Impl.hpp" | ||
| 8 | |||
| 9 | #include "Model.hpp" | ||
| 10 | #include "Model_Impl.hpp" | ||
| 11 | #include "Schedule.hpp" | ||
| 12 | #include "Schedule_Impl.hpp" | ||
| 13 | #include "ScheduleTypeLimits.hpp" | ||
| 14 | #include "ScheduleTypeLimits_Impl.hpp" | ||
| 15 | |||
| 16 | #include <utilities/idd/IddEnums.hxx> | ||
| 17 | #include <utilities/idd/OS_ExternalInterface_Schedule_FieldEnums.hxx> | ||
| 18 | |||
| 19 | #include "../utilities/units/Unit.hpp" | ||
| 20 | |||
| 21 | #include "../utilities/core/Assert.hpp" | ||
| 22 | |||
| 23 | namespace openstudio { | ||
| 24 | namespace model { | ||
| 25 | |||
| 26 | namespace detail { | ||
| 27 | |||
| 28 | 4 | ExternalInterfaceSchedule_Impl::ExternalInterfaceSchedule_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) | |
| 29 | 4 | : Schedule_Impl(idfObject, model, keepHandle) { | |
| 30 |
4/6✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 4 times.
✗ Branch 13 not taken.
|
4 | OS_ASSERT(idfObject.iddObject().type() == ExternalInterfaceSchedule::iddObjectType()); |
| 31 | 4 | } | |
| 32 | |||
| 33 | ✗ | ExternalInterfaceSchedule_Impl::ExternalInterfaceSchedule_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, | |
| 34 | ✗ | bool keepHandle) | |
| 35 | ✗ | : Schedule_Impl(other, model, keepHandle) { | |
| 36 | ✗ | OS_ASSERT(other.iddObject().type() == ExternalInterfaceSchedule::iddObjectType()); | |
| 37 | ✗ | } | |
| 38 | |||
| 39 | 1 | ExternalInterfaceSchedule_Impl::ExternalInterfaceSchedule_Impl(const ExternalInterfaceSchedule_Impl& other, Model_Impl* model, bool keepHandle) | |
| 40 | 1 | : Schedule_Impl(other, model, keepHandle) {} | |
| 41 | |||
| 42 | // return the parent object in the hierarchy | ||
| 43 | ✗ | boost::optional<ParentObject> ExternalInterfaceSchedule_Impl::parent() const { | |
| 44 | ✗ | return {}; | |
| 45 | } | ||
| 46 | |||
| 47 | // return any children objects in the hierarchy | ||
| 48 | 1 | std::vector<ModelObject> ExternalInterfaceSchedule_Impl::children() const { | |
| 49 | 1 | std::vector<ModelObject> result; | |
| 50 | 1 | return result; | |
| 51 | } | ||
| 52 | |||
| 53 | ✗ | const std::vector<std::string>& ExternalInterfaceSchedule_Impl::outputVariableNames() const { | |
| 54 | ✗ | static const std::vector<std::string> result; | |
| 55 | ✗ | return result; | |
| 56 | } | ||
| 57 | |||
| 58 | ✗ | IddObjectType ExternalInterfaceSchedule_Impl::iddObjectType() const { | |
| 59 | ✗ | return ExternalInterfaceSchedule::iddObjectType(); | |
| 60 | } | ||
| 61 | |||
| 62 | ✗ | void ExternalInterfaceSchedule_Impl::ensureNoLeapDays() { | |
| 63 | ✗ | LOG(Warn, "Ensure no leap days is not yet implemented for schedule compact"); | |
| 64 | ✗ | } | |
| 65 | |||
| 66 | ✗ | std::vector<double> ExternalInterfaceSchedule_Impl::values() const { | |
| 67 | ✗ | DoubleVector result; | |
| 68 | ✗ | result.push_back(initialValue()); | |
| 69 | ✗ | return result; | |
| 70 | ✗ | } | |
| 71 | |||
| 72 | 4 | boost::optional<ScheduleTypeLimits> ExternalInterfaceSchedule_Impl::scheduleTypeLimits() const { | |
| 73 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | return getObject<ModelObject>().getModelObjectTarget<ScheduleTypeLimits>(OS_ExternalInterface_ScheduleFields::ScheduleTypeLimitsName); |
| 74 | } | ||
| 75 | |||
| 76 | 5 | double ExternalInterfaceSchedule_Impl::initialValue() const { | |
| 77 |
1/1✓ Branch 1 taken 5 times.
|
5 | boost::optional<double> value = getDouble(OS_ExternalInterface_ScheduleFields::InitialValue, true); |
| 78 |
1/2✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
|
5 | if (value) { |
| 79 |
1/1✓ Branch 1 taken 5 times.
|
5 | return value.get(); |
| 80 | } | ||
| 81 | ✗ | return -9999; | |
| 82 | } | ||
| 83 | |||
| 84 | 2 | bool ExternalInterfaceSchedule_Impl::setScheduleTypeLimits(const ScheduleTypeLimits& scheduleTypeLimits) { | |
| 85 |
4/5✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
|
2 | if (scheduleTypeLimits.model() != model()) { |
| 86 | ✗ | return false; | |
| 87 | } | ||
| 88 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | if (!candidateIsCompatibleWithCurrentUse(scheduleTypeLimits)) { |
| 89 | ✗ | return false; | |
| 90 | } | ||
| 91 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | return setPointer(OS_ExternalInterface_ScheduleFields::ScheduleTypeLimitsName, scheduleTypeLimits.handle()); |
| 92 | } | ||
| 93 | |||
| 94 | 1 | bool ExternalInterfaceSchedule_Impl::resetScheduleTypeLimits() { | |
| 95 |
1/2✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
|
1 | if (okToResetScheduleTypeLimits()) { |
| 96 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
3 | return setString(OS_ExternalInterface_ScheduleFields::ScheduleTypeLimitsName, ""); |
| 97 | } | ||
| 98 | ✗ | return false; | |
| 99 | } | ||
| 100 | |||
| 101 | 6 | bool ExternalInterfaceSchedule_Impl::setInitialValue(double initialValue) { | |
| 102 | 6 | bool result = setDouble(OS_ExternalInterface_ScheduleFields::InitialValue, initialValue); | |
| 103 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | OS_ASSERT(result); |
| 104 | 6 | return result; | |
| 105 | } | ||
| 106 | |||
| 107 | 3 | bool ExternalInterfaceSchedule_Impl::exportToBCVTB() const { | |
| 108 |
1/1✓ Branch 1 taken 3 times.
|
3 | boost::optional<std::string> value = getString(OS_ExternalInterface_ScheduleFields::ExportToBCVTB, true); |
| 109 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 4 not taken.
|
3 | OS_ASSERT(value); |
| 110 |
3/3✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
|
6 | return openstudio::istringEqual(value.get(), "True"); |
| 111 | 3 | } | |
| 112 | |||
| 113 | 1 | bool ExternalInterfaceSchedule_Impl::isExportToBCVTBDefaulted() const { | |
| 114 | 1 | return isEmpty(OS_ExternalInterface_ScheduleFields::ExportToBCVTB); | |
| 115 | } | ||
| 116 | |||
| 117 | 1 | bool ExternalInterfaceSchedule_Impl::setExportToBCVTB(bool exportToBCVTB) { | |
| 118 | 1 | bool result = false; | |
| 119 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
|
1 | if (exportToBCVTB) { |
| 120 | ✗ | result = setString(OS_ExternalInterface_ScheduleFields::ExportToBCVTB, "True"); | |
| 121 | } else { | ||
| 122 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
3 | result = setString(OS_ExternalInterface_ScheduleFields::ExportToBCVTB, "False"); |
| 123 | } | ||
| 124 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
|
1 | OS_ASSERT(result); |
| 125 | 1 | return result; | |
| 126 | } | ||
| 127 | |||
| 128 | 1 | void ExternalInterfaceSchedule_Impl::resetExportToBCVTB() { | |
| 129 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
2 | bool result = setString(OS_ExternalInterface_ScheduleFields::ExportToBCVTB, ""); |
| 130 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
|
1 | OS_ASSERT(result); |
| 131 | 1 | } | |
| 132 | |||
| 133 | } // namespace detail | ||
| 134 | |||
| 135 | 2 | ExternalInterfaceSchedule::ExternalInterfaceSchedule(const Model& model, double initialValue) | |
| 136 | 2 | : Schedule(ExternalInterfaceSchedule::iddObjectType(), model) { | |
| 137 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 5 not taken.
|
2 | OS_ASSERT(getImpl<detail::ExternalInterfaceSchedule_Impl>()); |
| 138 | |||
| 139 |
1/1✓ Branch 1 taken 2 times.
|
2 | setInitialValue(initialValue); |
| 140 | //TODO move the Forward Translator | ||
| 141 | //if (schedule.scheduleTypeLimits()) { | ||
| 142 | // ok = setScheduleTypeLimits(schedule.scheduleTypeLimits().get()); | ||
| 143 | //} | ||
| 144 | 2 | } | |
| 145 | |||
| 146 | 2 | ExternalInterfaceSchedule::ExternalInterfaceSchedule(const Model& model) : Schedule(ExternalInterfaceSchedule::iddObjectType(), model) { | |
| 147 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 5 not taken.
|
2 | OS_ASSERT(getImpl<detail::ExternalInterfaceSchedule_Impl>()); |
| 148 |
1/1✓ Branch 1 taken 2 times.
|
2 | setInitialValue(0.0); |
| 149 | 2 | } | |
| 150 | |||
| 151 | 7736 | IddObjectType ExternalInterfaceSchedule::iddObjectType() { | |
| 152 |
1/1✓ Branch 1 taken 7736 times.
|
7736 | return {IddObjectType::OS_ExternalInterface_Schedule}; |
| 153 | } | ||
| 154 | |||
| 155 | 5 | double ExternalInterfaceSchedule::initialValue() const { | |
| 156 |
1/1✓ Branch 3 taken 5 times.
|
5 | return getImpl<detail::ExternalInterfaceSchedule_Impl>()->initialValue(); |
| 157 | } | ||
| 158 | |||
| 159 | 6 | bool ExternalInterfaceSchedule::setInitialValue(double initialValue) { | |
| 160 |
1/1✓ Branch 3 taken 6 times.
|
6 | return getImpl<detail::ExternalInterfaceSchedule_Impl>()->setInitialValue(initialValue); |
| 161 | } | ||
| 162 | |||
| 163 | 3 | bool ExternalInterfaceSchedule::exportToBCVTB() const { | |
| 164 |
1/1✓ Branch 3 taken 3 times.
|
3 | return getImpl<detail::ExternalInterfaceSchedule_Impl>()->exportToBCVTB(); |
| 165 | } | ||
| 166 | |||
| 167 | 1 | bool ExternalInterfaceSchedule::isExportToBCVTBDefaulted() const { | |
| 168 |
1/1✓ Branch 3 taken 1 time.
|
1 | return getImpl<detail::ExternalInterfaceSchedule_Impl>()->isExportToBCVTBDefaulted(); |
| 169 | } | ||
| 170 | |||
| 171 | 1 | bool ExternalInterfaceSchedule::setExportToBCVTB(bool exportToBCVTB) { | |
| 172 |
1/1✓ Branch 3 taken 1 time.
|
1 | return getImpl<detail::ExternalInterfaceSchedule_Impl>()->setExportToBCVTB(exportToBCVTB); |
| 173 | } | ||
| 174 | |||
| 175 | 1 | void ExternalInterfaceSchedule::resetExportToBCVTB() { | |
| 176 |
1/1✓ Branch 3 taken 1 time.
|
1 | getImpl<detail::ExternalInterfaceSchedule_Impl>()->resetExportToBCVTB(); |
| 177 | 1 | } | |
| 178 | |||
| 179 | /// @cond | ||
| 180 |
1/1✓ Branch 2 taken 1 time.
|
1 | ExternalInterfaceSchedule::ExternalInterfaceSchedule(std::shared_ptr<detail::ExternalInterfaceSchedule_Impl> impl) : Schedule(impl) {} |
| 181 | /// @endcond | ||
| 182 | |||
| 183 | } // namespace model | ||
| 184 | } // namespace openstudio | ||
| 185 |