src/model/ExternalInterfaceFunctionalMockupUnitImportToSchedule.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 "ExternalInterfaceFunctionalMockupUnitImportToSchedule.hpp" | ||
| 7 | #include "ExternalInterfaceFunctionalMockupUnitImportToSchedule_Impl.hpp" | ||
| 8 | |||
| 9 | #include "ExternalInterfaceFunctionalMockupUnitImport.hpp" | ||
| 10 | #include "ExternalInterfaceFunctionalMockupUnitImport_Impl.hpp" | ||
| 11 | #include "ScheduleTypeLimits.hpp" | ||
| 12 | #include "ScheduleTypeLimits_Impl.hpp" | ||
| 13 | #include "Schedule.hpp" | ||
| 14 | #include "Schedule_Impl.hpp" | ||
| 15 | #include "Model.hpp" | ||
| 16 | #include "Model_Impl.hpp" | ||
| 17 | |||
| 18 | #include <utilities/idd/IddEnums.hxx> | ||
| 19 | #include <utilities/idd/OS_ExternalInterface_FunctionalMockupUnitImport_To_Schedule_FieldEnums.hxx> | ||
| 20 | |||
| 21 | #include "../utilities/units/Unit.hpp" | ||
| 22 | |||
| 23 | #include "../utilities/core/Assert.hpp" | ||
| 24 | |||
| 25 | namespace openstudio { | ||
| 26 | namespace model { | ||
| 27 | |||
| 28 | namespace detail { | ||
| 29 | |||
| 30 | 4 | ExternalInterfaceFunctionalMockupUnitImportToSchedule_Impl::ExternalInterfaceFunctionalMockupUnitImportToSchedule_Impl(const IdfObject& idfObject, | |
| 31 | Model_Impl* model, | ||
| 32 | 4 | bool keepHandle) | |
| 33 | 4 | : Schedule_Impl(idfObject, model, keepHandle) { | |
| 34 |
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() == ExternalInterfaceFunctionalMockupUnitImportToSchedule::iddObjectType()); |
| 35 | 4 | } | |
| 36 | |||
| 37 | ✗ | ExternalInterfaceFunctionalMockupUnitImportToSchedule_Impl::ExternalInterfaceFunctionalMockupUnitImportToSchedule_Impl( | |
| 38 | ✗ | const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle) | |
| 39 | ✗ | : Schedule_Impl(other, model, keepHandle) { | |
| 40 | ✗ | OS_ASSERT(other.iddObject().type() == ExternalInterfaceFunctionalMockupUnitImportToSchedule::iddObjectType()); | |
| 41 | ✗ | } | |
| 42 | |||
| 43 | 1 | ExternalInterfaceFunctionalMockupUnitImportToSchedule_Impl::ExternalInterfaceFunctionalMockupUnitImportToSchedule_Impl( | |
| 44 | 1 | const ExternalInterfaceFunctionalMockupUnitImportToSchedule_Impl& other, Model_Impl* model, bool keepHandle) | |
| 45 | 1 | : Schedule_Impl(other, model, keepHandle) {} | |
| 46 | |||
| 47 | // return the parent object in the hierarchy | ||
| 48 | ✗ | boost::optional<ParentObject> ExternalInterfaceFunctionalMockupUnitImportToSchedule_Impl::parent() const { | |
| 49 | ✗ | return {}; | |
| 50 | } | ||
| 51 | |||
| 52 | // return any children objects in the hierarchy | ||
| 53 | 1 | std::vector<ModelObject> ExternalInterfaceFunctionalMockupUnitImportToSchedule_Impl::children() const { | |
| 54 | 1 | std::vector<ModelObject> result; | |
| 55 | 1 | return result; | |
| 56 | } | ||
| 57 | |||
| 58 | ✗ | const std::vector<std::string>& ExternalInterfaceFunctionalMockupUnitImportToSchedule_Impl::outputVariableNames() const { | |
| 59 | ✗ | static const std::vector<std::string> result; | |
| 60 | ✗ | return result; | |
| 61 | } | ||
| 62 | |||
| 63 | ✗ | IddObjectType ExternalInterfaceFunctionalMockupUnitImportToSchedule_Impl::iddObjectType() const { | |
| 64 | ✗ | return ExternalInterfaceFunctionalMockupUnitImportToSchedule::iddObjectType(); | |
| 65 | } | ||
| 66 | |||
| 67 | 4 | boost::optional<ScheduleTypeLimits> ExternalInterfaceFunctionalMockupUnitImportToSchedule_Impl::scheduleTypeLimits() const { | |
| 68 |
1/1✓ Branch 1 taken 4 times.
|
8 | return getObject<ModelObject>().getModelObjectTarget<ScheduleTypeLimits>( |
| 69 |
1/1✓ Branch 1 taken 4 times.
|
8 | OS_ExternalInterface_FunctionalMockupUnitImport_To_ScheduleFields::ScheduleTypeLimitsName); |
| 70 | } | ||
| 71 | |||
| 72 | ✗ | void ExternalInterfaceFunctionalMockupUnitImportToSchedule_Impl::ensureNoLeapDays() { | |
| 73 | ✗ | LOG(Warn, "Ensure no leap days is not yet implemented for schedule compact"); | |
| 74 | ✗ | } | |
| 75 | |||
| 76 | ✗ | std::vector<double> ExternalInterfaceFunctionalMockupUnitImportToSchedule_Impl::values() const { | |
| 77 | ✗ | DoubleVector result; | |
| 78 | ✗ | result.push_back(initialValue()); | |
| 79 | ✗ | return result; | |
| 80 | ✗ | } | |
| 81 | |||
| 82 | 4 | ExternalInterfaceFunctionalMockupUnitImport ExternalInterfaceFunctionalMockupUnitImportToSchedule_Impl::fMUFile() const { | |
| 83 |
1/1✓ Branch 1 taken 4 times.
|
8 | return this->getTarget(OS_ExternalInterface_FunctionalMockupUnitImport_To_ScheduleFields::FMUFileName) |
| 84 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
8 | ->cast<ExternalInterfaceFunctionalMockupUnitImport>(); |
| 85 | } | ||
| 86 | |||
| 87 | 3 | std::string ExternalInterfaceFunctionalMockupUnitImportToSchedule_Impl::fMUInstanceName() const { | |
| 88 |
1/1✓ Branch 1 taken 3 times.
|
3 | boost::optional<std::string> value = getString(OS_ExternalInterface_FunctionalMockupUnitImport_To_ScheduleFields::FMUInstanceName, true); |
| 89 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | if (value) { |
| 90 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
3 | return value.get(); |
| 91 | } | ||
| 92 | ✗ | return ""; | |
| 93 | 3 | } | |
| 94 | |||
| 95 | 3 | std::string ExternalInterfaceFunctionalMockupUnitImportToSchedule_Impl::fMUVariableName() const { | |
| 96 |
1/1✓ Branch 1 taken 3 times.
|
3 | boost::optional<std::string> value = getString(OS_ExternalInterface_FunctionalMockupUnitImport_To_ScheduleFields::FMUVariableName, true); |
| 97 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | if (value) { |
| 98 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
3 | return value.get(); |
| 99 | } | ||
| 100 | ✗ | return ""; | |
| 101 | 3 | } | |
| 102 | |||
| 103 | 4 | double ExternalInterfaceFunctionalMockupUnitImportToSchedule_Impl::initialValue() const { | |
| 104 |
1/1✓ Branch 1 taken 4 times.
|
4 | boost::optional<double> value = getDouble(OS_ExternalInterface_FunctionalMockupUnitImport_To_ScheduleFields::InitialValue, true); |
| 105 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | if (value) { |
| 106 |
1/1✓ Branch 1 taken 4 times.
|
4 | return value.get(); |
| 107 | } | ||
| 108 | ✗ | return -9999; | |
| 109 | } | ||
| 110 | |||
| 111 | 2 | bool ExternalInterfaceFunctionalMockupUnitImportToSchedule_Impl::setScheduleTypeLimits(const ScheduleTypeLimits& scheduleTypeLimits) { | |
| 112 |
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()) { |
| 113 | ✗ | return false; | |
| 114 | } | ||
| 115 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | if (!candidateIsCompatibleWithCurrentUse(scheduleTypeLimits)) { |
| 116 | ✗ | return false; | |
| 117 | } | ||
| 118 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | return setPointer(OS_ExternalInterface_FunctionalMockupUnitImport_To_ScheduleFields::ScheduleTypeLimitsName, scheduleTypeLimits.handle()); |
| 119 | } | ||
| 120 | |||
| 121 | 1 | bool ExternalInterfaceFunctionalMockupUnitImportToSchedule_Impl::resetScheduleTypeLimits() { | |
| 122 |
1/2✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
|
1 | if (okToResetScheduleTypeLimits()) { |
| 123 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
3 | return setString(OS_ExternalInterface_FunctionalMockupUnitImport_To_ScheduleFields::ScheduleTypeLimitsName, ""); |
| 124 | } | ||
| 125 | ✗ | return false; | |
| 126 | } | ||
| 127 | |||
| 128 | 5 | bool ExternalInterfaceFunctionalMockupUnitImportToSchedule_Impl::setFMUFile(const ExternalInterfaceFunctionalMockupUnitImport& fMUFile) { | |
| 129 |
2/2✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
|
5 | bool result = setPointer(OS_ExternalInterface_FunctionalMockupUnitImport_To_ScheduleFields::FMUFileName, fMUFile.handle()); |
| 130 | //TODO in FT use .fMUFile(); | ||
| 131 | 5 | return result; | |
| 132 | } | ||
| 133 | |||
| 134 | 5 | bool ExternalInterfaceFunctionalMockupUnitImportToSchedule_Impl::setFMUInstanceName(const std::string& fMUInstanceName) { | |
| 135 | 5 | bool result = setString(OS_ExternalInterface_FunctionalMockupUnitImport_To_ScheduleFields::FMUInstanceName, fMUInstanceName); | |
| 136 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
|
5 | OS_ASSERT(result); |
| 137 | 5 | return result; | |
| 138 | } | ||
| 139 | |||
| 140 | 5 | bool ExternalInterfaceFunctionalMockupUnitImportToSchedule_Impl::setFMUVariableName(const std::string& fMUVariableName) { | |
| 141 | 5 | bool result = setString(OS_ExternalInterface_FunctionalMockupUnitImport_To_ScheduleFields::FMUVariableName, fMUVariableName); | |
| 142 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
|
5 | OS_ASSERT(result); |
| 143 | 5 | return result; | |
| 144 | } | ||
| 145 | |||
| 146 | 6 | bool ExternalInterfaceFunctionalMockupUnitImportToSchedule_Impl::setInitialValue(double initialValue) { | |
| 147 | 6 | bool result = setDouble(OS_ExternalInterface_FunctionalMockupUnitImport_To_ScheduleFields::InitialValue, initialValue); | |
| 148 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | OS_ASSERT(result); |
| 149 | 6 | return result; | |
| 150 | } | ||
| 151 | |||
| 152 | } // namespace detail | ||
| 153 | |||
| 154 | 4 | ExternalInterfaceFunctionalMockupUnitImportToSchedule::ExternalInterfaceFunctionalMockupUnitImportToSchedule( | |
| 155 | const Model& model, const ExternalInterfaceFunctionalMockupUnitImport& fMUFile, const std::string& fMUInstanceName, | ||
| 156 | 4 | const std::string& fMUVariableName, double initialValue) | |
| 157 | 4 | : Schedule(ExternalInterfaceFunctionalMockupUnitImportToSchedule::iddObjectType(), model) { | |
| 158 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 5 not taken.
|
4 | OS_ASSERT(getImpl<detail::ExternalInterfaceFunctionalMockupUnitImportToSchedule_Impl>()); |
| 159 | |||
| 160 |
1/1✓ Branch 1 taken 4 times.
|
4 | bool ok = setFMUFile(fMUFile); |
| 161 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
4 | if (!ok) { |
| 162 | ✗ | remove(); | |
| 163 | ✗ | LOG_AND_THROW("Unable to set " << briefDescription() << "'s FMUFileName to " << fMUFile.fMUFileName() << "."); | |
| 164 | } | ||
| 165 |
1/1✓ Branch 1 taken 4 times.
|
4 | setFMUInstanceName(fMUInstanceName); |
| 166 |
1/1✓ Branch 1 taken 4 times.
|
4 | setFMUVariableName(fMUVariableName); |
| 167 |
1/1✓ Branch 1 taken 4 times.
|
4 | setInitialValue(initialValue); |
| 168 | //TODO move the Forward Translator | ||
| 169 | //if (schedule.scheduleTypeLimits()) { | ||
| 170 | // ok = setScheduleTypeLimits(schedule.scheduleTypeLimits().get()); | ||
| 171 | //} | ||
| 172 | 4 | } | |
| 173 | |||
| 174 | 7606 | IddObjectType ExternalInterfaceFunctionalMockupUnitImportToSchedule::iddObjectType() { | |
| 175 |
1/1✓ Branch 1 taken 7606 times.
|
7606 | return {IddObjectType::OS_ExternalInterface_FunctionalMockupUnitImport_To_Schedule}; |
| 176 | } | ||
| 177 | |||
| 178 | 4 | ExternalInterfaceFunctionalMockupUnitImport ExternalInterfaceFunctionalMockupUnitImportToSchedule::fMUFile() const { | |
| 179 |
1/1✓ Branch 3 taken 4 times.
|
4 | return getImpl<detail::ExternalInterfaceFunctionalMockupUnitImportToSchedule_Impl>()->fMUFile(); |
| 180 | } | ||
| 181 | |||
| 182 | 3 | std::string ExternalInterfaceFunctionalMockupUnitImportToSchedule::fMUInstanceName() const { | |
| 183 |
1/1✓ Branch 3 taken 3 times.
|
3 | return getImpl<detail::ExternalInterfaceFunctionalMockupUnitImportToSchedule_Impl>()->fMUInstanceName(); |
| 184 | } | ||
| 185 | |||
| 186 | 3 | std::string ExternalInterfaceFunctionalMockupUnitImportToSchedule::fMUVariableName() const { | |
| 187 |
1/1✓ Branch 3 taken 3 times.
|
3 | return getImpl<detail::ExternalInterfaceFunctionalMockupUnitImportToSchedule_Impl>()->fMUVariableName(); |
| 188 | } | ||
| 189 | |||
| 190 | 4 | double ExternalInterfaceFunctionalMockupUnitImportToSchedule::initialValue() const { | |
| 191 |
1/1✓ Branch 3 taken 4 times.
|
4 | return getImpl<detail::ExternalInterfaceFunctionalMockupUnitImportToSchedule_Impl>()->initialValue(); |
| 192 | } | ||
| 193 | |||
| 194 | 5 | bool ExternalInterfaceFunctionalMockupUnitImportToSchedule::setFMUFile(const ExternalInterfaceFunctionalMockupUnitImport& fMUFile) { | |
| 195 |
1/1✓ Branch 3 taken 5 times.
|
5 | return getImpl<detail::ExternalInterfaceFunctionalMockupUnitImportToSchedule_Impl>()->setFMUFile(fMUFile); |
| 196 | } | ||
| 197 | |||
| 198 | 5 | bool ExternalInterfaceFunctionalMockupUnitImportToSchedule::setFMUInstanceName(const std::string& fMUInstanceName) { | |
| 199 |
1/1✓ Branch 3 taken 5 times.
|
5 | return getImpl<detail::ExternalInterfaceFunctionalMockupUnitImportToSchedule_Impl>()->setFMUInstanceName(fMUInstanceName); |
| 200 | } | ||
| 201 | |||
| 202 | 5 | bool ExternalInterfaceFunctionalMockupUnitImportToSchedule::setFMUVariableName(const std::string& fMUVariableName) { | |
| 203 |
1/1✓ Branch 3 taken 5 times.
|
5 | return getImpl<detail::ExternalInterfaceFunctionalMockupUnitImportToSchedule_Impl>()->setFMUVariableName(fMUVariableName); |
| 204 | } | ||
| 205 | |||
| 206 | 6 | bool ExternalInterfaceFunctionalMockupUnitImportToSchedule::setInitialValue(double initialValue) { | |
| 207 |
1/1✓ Branch 3 taken 6 times.
|
6 | return getImpl<detail::ExternalInterfaceFunctionalMockupUnitImportToSchedule_Impl>()->setInitialValue(initialValue); |
| 208 | } | ||
| 209 | |||
| 210 | /// @cond | ||
| 211 | 1 | ExternalInterfaceFunctionalMockupUnitImportToSchedule::ExternalInterfaceFunctionalMockupUnitImportToSchedule( | |
| 212 | 1 | std::shared_ptr<detail::ExternalInterfaceFunctionalMockupUnitImportToSchedule_Impl> impl) | |
| 213 |
1/1✓ Branch 2 taken 1 time.
|
1 | : Schedule(impl) {} |
| 214 | /// @endcond | ||
| 215 | |||
| 216 | } // namespace model | ||
| 217 | } // namespace openstudio | ||
| 218 |