| 1101 | } |
| 1102 | |
| 1103 | Schedule Model_Impl::alwaysOffDiscreteSchedule() const { |
| 1104 | std::string alwaysOffName = this->alwaysOffDiscreteScheduleName(); |
| 1105 | |
| 1106 | std::vector<ScheduleConstant> schedules = model().getConcreteModelObjects<ScheduleConstant>(); |
| 1107 | |
| 1108 | for (const auto& schedule : schedules) { |
| 1109 | if (boost::optional<std::string> name = schedule.name()) { |
| 1110 | if (istringEqual(name.get(), alwaysOffName)) { |
| 1111 | // DLM: if a schedule matches the name but not these other properties we should reclaim the name or at least warn |
| 1112 | |
| 1113 | if (equal<double>(schedule.value(), 0.0)) { |
| 1114 | if (boost::optional<ScheduleTypeLimits> limits = schedule.scheduleTypeLimits()) { |
| 1115 | if (boost::optional<std::string> type = limits->numericType()) { |
| 1116 | if (istringEqual(type.get(), "Discrete")) { |
| 1117 | return schedule; |
| 1118 | } |
| 1119 | } |
| 1120 | } |
| 1121 | } |
| 1122 | } |
| 1123 | } |
| 1124 | } |
| 1125 | |
| 1126 | ScheduleConstant schedule(model()); |
| 1127 | |
| 1128 | schedule.setName(alwaysOffName); |
| 1129 | |
| 1130 | ScheduleTypeLimits limits(model()); |
| 1131 | |
| 1132 | limits.setName("OnOff"); |
| 1133 | |
| 1134 | limits.setNumericType("Discrete"); |
| 1135 | |
| 1136 | limits.setUnitType("Availability"); |
| 1137 | |
| 1138 | limits.setLowerLimitValue(0.0); |
| 1139 | |
| 1140 | limits.setUpperLimitValue(1.0); |
| 1141 | |
| 1142 | schedule.setScheduleTypeLimits(limits); |
| 1143 | |
| 1144 | schedule.setValue(0.0); |
| 1145 | |
| 1146 | return std::move(schedule); |
| 1147 | } |
| 1148 | |
| 1149 | std::string Model_Impl::alwaysOffDiscreteScheduleName() const { |
| 1150 | return "Always Off Discrete"; |