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