src/model/ScheduleConstant.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 "ScheduleConstant.hpp" | ||
| 7 | #include "ScheduleConstant_Impl.hpp" | ||
| 8 | #include "Model.hpp" | ||
| 9 | |||
| 10 | #include "ScheduleTypeLimits.hpp" | ||
| 11 | #include "ScheduleTypeLimits_Impl.hpp" | ||
| 12 | |||
| 13 | #include "../utilities/idf/IdfExtensibleGroup.hpp" | ||
| 14 | |||
| 15 | #include <utilities/idd/OS_Schedule_Constant_FieldEnums.hxx> | ||
| 16 | #include <utilities/idd/IddEnums.hxx> | ||
| 17 | |||
| 18 | #include "../utilities/core/Assert.hpp" | ||
| 19 | |||
| 20 | using openstudio::Handle; | ||
| 21 | using openstudio::OptionalHandle; | ||
| 22 | using openstudio::HandleVector; | ||
| 23 | using openstudio::IdfObject; | ||
| 24 | using openstudio::WorkspaceObject; | ||
| 25 | using openstudio::OptionalWorkspaceObject; | ||
| 26 | using openstudio::WorkspaceObjectVector; | ||
| 27 | using openstudio::Workspace; | ||
| 28 | |||
| 29 | namespace openstudio { | ||
| 30 | namespace model { | ||
| 31 | |||
| 32 | namespace detail { | ||
| 33 | |||
| 34 | 4436 | ScheduleConstant_Impl::ScheduleConstant_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) | |
| 35 | 4436 | : Schedule_Impl(idfObject, model, keepHandle) { | |
| 36 |
4/6✓ Branch 1 taken 4436 times.
✓ Branch 4 taken 4436 times.
✓ Branch 7 taken 4436 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 4436 times.
✗ Branch 13 not taken.
|
4436 | OS_ASSERT(idfObject.iddObject().type() == ScheduleConstant::iddObjectType()); |
| 37 | 4436 | } | |
| 38 | |||
| 39 | 141 | ScheduleConstant_Impl::ScheduleConstant_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle) | |
| 40 | 141 | : Schedule_Impl(other, model, keepHandle) { | |
| 41 |
4/6✓ Branch 1 taken 141 times.
✓ Branch 4 taken 141 times.
✓ Branch 7 taken 141 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 141 times.
✗ Branch 13 not taken.
|
141 | OS_ASSERT(other.iddObject().type() == ScheduleConstant::iddObjectType()); |
| 42 | 141 | } | |
| 43 | |||
| 44 | 1299 | ScheduleConstant_Impl::ScheduleConstant_Impl(const ScheduleConstant_Impl& other, Model_Impl* model, bool keepHandle) | |
| 45 | 1299 | : Schedule_Impl(other, model, keepHandle) {} | |
| 46 | |||
| 47 | // return the parent object in the hierarchy | ||
| 48 | 110 | boost::optional<ParentObject> ScheduleConstant_Impl::parent() const { | |
| 49 | 110 | return {}; | |
| 50 | } | ||
| 51 | |||
| 52 | // return any children objects in the hierarchy | ||
| 53 | 3153 | std::vector<ModelObject> ScheduleConstant_Impl::children() const { | |
| 54 | 3153 | std::vector<ModelObject> result; | |
| 55 | 3153 | return result; | |
| 56 | } | ||
| 57 | |||
| 58 | // Get all output variable names that could be associated with this object. | ||
| 59 | 1 | const std::vector<std::string>& ScheduleConstant_Impl::outputVariableNames() const { | |
| 60 |
5/11✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 11 taken 1 time.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
|
4 | static const std::vector<std::string> result{"Schedule Value"}; |
| 61 | 1 | return result; | |
| 62 | 3 | } | |
| 63 | |||
| 64 | 22 | IddObjectType ScheduleConstant_Impl::iddObjectType() const { | |
| 65 | 22 | return ScheduleConstant::iddObjectType(); | |
| 66 | } | ||
| 67 | |||
| 68 | 5825 | boost::optional<ScheduleTypeLimits> ScheduleConstant_Impl::scheduleTypeLimits() const { | |
| 69 |
2/2✓ Branch 1 taken 5825 times.
✓ Branch 4 taken 5825 times.
|
5825 | return getObject<ModelObject>().getModelObjectTarget<ScheduleTypeLimits>(OS_Schedule_ConstantFields::ScheduleTypeLimitsName); |
| 70 | } | ||
| 71 | |||
| 72 | ✗ | std::vector<double> ScheduleConstant_Impl::values() const { | |
| 73 | ✗ | return DoubleVector(1u, value()); | |
| 74 | } | ||
| 75 | |||
| 76 | 5619 | double ScheduleConstant_Impl::value() const { | |
| 77 |
1/1✓ Branch 1 taken 5619 times.
|
5619 | boost::optional<double> result = getDouble(OS_Schedule_ConstantFields::Value, true); |
| 78 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 5619 times.
|
5619 | if (!result) { |
| 79 | ✗ | return 0.0; | |
| 80 | } | ||
| 81 |
1/1✓ Branch 1 taken 5619 times.
|
5619 | return *result; |
| 82 | } | ||
| 83 | |||
| 84 | 4134 | bool ScheduleConstant_Impl::setScheduleTypeLimits(const ScheduleTypeLimits& scheduleTypeLimits) { | |
| 85 |
4/5✓ Branch 1 taken 4134 times.
✓ Branch 4 taken 4134 times.
✓ Branch 7 taken 4134 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 4134 times.
|
4134 | if (scheduleTypeLimits.model() != model()) { |
| 86 | ✗ | return false; | |
| 87 | } | ||
| 88 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 4134 times.
|
4134 | if (!candidateIsCompatibleWithCurrentUse(scheduleTypeLimits)) { |
| 89 | ✗ | return false; | |
| 90 | } | ||
| 91 |
2/2✓ Branch 1 taken 4134 times.
✓ Branch 4 taken 4134 times.
|
4134 | return setPointer(OS_Schedule_ConstantFields::ScheduleTypeLimitsName, scheduleTypeLimits.handle()); |
| 92 | } | ||
| 93 | |||
| 94 | 2 | bool ScheduleConstant_Impl::resetScheduleTypeLimits() { | |
| 95 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 2 taken 1 time.
|
2 | if (okToResetScheduleTypeLimits()) { |
| 96 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
3 | return setString(OS_Schedule_ConstantFields::ScheduleTypeLimitsName, ""); |
| 97 | } | ||
| 98 | 1 | return false; | |
| 99 | } | ||
| 100 | |||
| 101 | 8318 | bool ScheduleConstant_Impl::setValue(double value) { | |
| 102 | 8318 | bool ok = setDouble(OS_Schedule_ConstantFields::Value, value); | |
| 103 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8318 times.
|
8318 | OS_ASSERT(ok); |
| 104 | 8318 | return ok; | |
| 105 | } | ||
| 106 | |||
| 107 | ✗ | void ScheduleConstant_Impl::ensureNoLeapDays() { | |
| 108 | // nothing to do | ||
| 109 | ✗ | } | |
| 110 | |||
| 111 | ✗ | std::vector<EMSActuatorNames> ScheduleConstant_Impl::emsActuatorNames() const { | |
| 112 | ✗ | std::vector<EMSActuatorNames> actuators{{"Schedule:Constant", "Schedule Value"}}; | |
| 113 | ✗ | return actuators; | |
| 114 | ✗ | } | |
| 115 | |||
| 116 | ✗ | std::vector<std::string> ScheduleConstant_Impl::emsInternalVariableNames() const { | |
| 117 | ✗ | std::vector<std::string> types; | |
| 118 | ✗ | return types; | |
| 119 | } | ||
| 120 | } // namespace detail | ||
| 121 | |||
| 122 | // create a new ScheduleConstant object in the model's workspace | ||
| 123 | 4294 | ScheduleConstant::ScheduleConstant(const Model& model) : Schedule(ScheduleConstant::iddObjectType(), model) { | |
| 124 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 4294 times.
✗ Branch 5 not taken.
|
4294 | OS_ASSERT(getImpl<detail::ScheduleConstant_Impl>()); |
| 125 |
1/1✓ Branch 1 taken 4294 times.
|
4294 | setValue(0.0); |
| 126 | 4294 | } | |
| 127 | |||
| 128 | // constructor | ||
| 129 |
1/1✓ Branch 3 taken 10787 times.
|
10787 | ScheduleConstant::ScheduleConstant(std::shared_ptr<detail::ScheduleConstant_Impl> impl) : Schedule(std::move(impl)) {} |
| 130 | |||
| 131 | 22688 | IddObjectType ScheduleConstant::iddObjectType() { | |
| 132 |
1/1✓ Branch 1 taken 22688 times.
|
22688 | IddObjectType result(IddObjectType::OS_Schedule_Constant); |
| 133 | 22688 | return result; | |
| 134 | } | ||
| 135 | |||
| 136 | 5619 | double ScheduleConstant::value() const { | |
| 137 |
1/1✓ Branch 3 taken 5619 times.
|
5619 | return getImpl<detail::ScheduleConstant_Impl>()->value(); |
| 138 | } | ||
| 139 | |||
| 140 | 8318 | bool ScheduleConstant::setValue(double value) { | |
| 141 |
1/1✓ Branch 3 taken 8318 times.
|
8318 | return getImpl<detail::ScheduleConstant_Impl>()->setValue(value); |
| 142 | } | ||
| 143 | |||
| 144 | } // namespace model | ||
| 145 | } // namespace openstudio | ||
| 146 |