diff --git a/src/model/AvailabilityManagerNightCycle.cpp b/src/model/AvailabilityManagerNightCycle.cpp index d5a2d4e9421..057b20ef4d6 100644 --- a/src/model/AvailabilityManagerNightCycle.cpp +++ b/src/model/AvailabilityManagerNightCycle.cpp @@ -121,6 +121,82 @@ namespace detail { return result; } + ModelObject AvailabilityManagerNightCycle_Impl::clone(Model model) const { + AvailabilityManagerNightCycle avmClone = ModelObject_Impl::clone(model).cast(); + + // Now recreate the lists + // Control Zone List + ModelObjectList controlThermalZoneList = ModelObjectList(model); + controlThermalZoneList.setName(this->name().get() + " Control Zone List"); + bool ok = avmClone.getImpl()->setPointer( + OS_AvailabilityManager_NightCycleFields::ControlZoneorZoneListName, controlThermalZoneList.handle() + ); + OS_ASSERT(ok); + + // Cooling Control Zone List + ModelObjectList coolingControlThermalZoneList = ModelObjectList(model); + coolingControlThermalZoneList.setName(this->name().get() + " Cooling Control Zone List"); + ok = avmClone.getImpl()->setPointer( + OS_AvailabilityManager_NightCycleFields::CoolingControlZoneorZoneListName, coolingControlThermalZoneList.handle() + ); + OS_ASSERT(ok); + + // Heating Control Zone List + ModelObjectList heatingControlThermalZoneList = ModelObjectList(model); + heatingControlThermalZoneList.setName(this->name().get() + " Heating Control Zone List"); + ok = avmClone.getImpl()->setPointer( + OS_AvailabilityManager_NightCycleFields::HeatingControlZoneorZoneListName, heatingControlThermalZoneList.handle() + ); + OS_ASSERT(ok); + + // Heating Zone Fans Only Zone List + ModelObjectList heatingZoneFansOnlyThermalZoneList = ModelObjectList(model); + heatingZoneFansOnlyThermalZoneList.setName(this->name().get() + " Heating Zone Fans Only Zone List"); + ok = avmClone.getImpl()->setPointer( + OS_AvailabilityManager_NightCycleFields::HeatingZoneFansOnlyZoneorZoneListName, heatingZoneFansOnlyThermalZoneList.handle() + ); + OS_ASSERT(ok); + + return avmClone; + } + + std::vector AvailabilityManagerNightCycle_Impl::remove() { + std::vector result; + + // Remove the ModelObjectLists. You have to clear them first, or it'll also remove the ThermalZones contained within. + { + ModelObjectList mo_list = controlThermalZoneList(); + mo_list.removeAllModelObjects(); + std::vector removedMoList = mo_list.remove(); + result.insert(result.end(), removedMoList.begin(), removedMoList.end()); + } + + { + ModelObjectList mo_list = coolingControlThermalZoneList(); + mo_list.removeAllModelObjects(); + std::vector removedMoList = mo_list.remove(); + result.insert(result.end(), removedMoList.begin(), removedMoList.end()); + } + + { + ModelObjectList mo_list = heatingControlThermalZoneList(); + mo_list.removeAllModelObjects(); + std::vector removedMoList = mo_list.remove(); + result.insert(result.end(), removedMoList.begin(), removedMoList.end()); + } + + { + ModelObjectList mo_list = heatingZoneFansOnlyThermalZoneList(); + mo_list.removeAllModelObjects(); + std::vector removedMoList = mo_list.remove(); + result.insert(result.end(), removedMoList.begin(), removedMoList.end()); + } + + std::vector AvailabilityManagerNightCycle = ModelObject_Impl::remove(); + result.insert(result.end(), AvailabilityManagerNightCycle.begin(), AvailabilityManagerNightCycle.end()); + + return result; + } boost::optional AvailabilityManagerNightCycle_Impl::airLoopHVAC() const { if (boost::optional _loop = loop()) { @@ -245,10 +321,7 @@ namespace detail { } void AvailabilityManagerNightCycle_Impl::clearControlThermalZoneList() { ModelObjectList mo_list = controlThermalZoneList(); - for (const ModelObject& mo : mo_list.modelObjects()) { - mo_list.removeModelObject(mo); - } - // Assert size = 0? + mo_list.removeAllModelObjects(); } @@ -301,10 +374,7 @@ namespace detail { void AvailabilityManagerNightCycle_Impl::clearCoolingControlThermalZoneList() { ModelObjectList mo_list = coolingControlThermalZoneList(); - for (const ModelObject& mo : mo_list.modelObjects()) { - mo_list.removeModelObject(mo); - } - // Assert size = 0? + mo_list.removeAllModelObjects(); } @@ -355,10 +425,7 @@ namespace detail { void AvailabilityManagerNightCycle_Impl::clearHeatingControlThermalZoneList() { ModelObjectList mo_list = heatingControlThermalZoneList(); - for (const ModelObject& mo : mo_list.modelObjects()) { - mo_list.removeModelObject(mo); - } - // Assert size = 0? + mo_list.removeAllModelObjects(); } @@ -411,10 +478,7 @@ namespace detail { void AvailabilityManagerNightCycle_Impl::clearHeatingZoneFansOnlyThermalZoneList() { ModelObjectList mo_list = heatingZoneFansOnlyThermalZoneList(); - for (const ModelObject& mo : mo_list.modelObjects()) { - mo_list.removeModelObject(mo); - } - // Assert size = 0? + mo_list.removeAllModelObjects(); } @@ -691,4 +755,4 @@ AvailabilityManagerNightCycle::AvailabilityManagerNightCycle(std::shared_ptr getScheduleTypeKeys(const Schedule& schedule) const override; + // Cloning should ensure we do have modelObjectLists for control zones, but they should be empty + // as it is not connected to an AirLoopHVAC (yet) and it wouldn't make sense to have zones there + virtual ModelObject clone(Model model) const override; + + // Clears the ModelObjectLists, then remove them + virtual std::vector remove() override; + boost::optional airLoopHVAC() const; Schedule applicabilitySchedule() const; @@ -142,4 +149,4 @@ namespace detail { } // model } // openstudio -#endif // MODEL_AVAILABILITYMANAGERNIGHTCYCLE_IMPL_HPP \ No newline at end of file +#endif // MODEL_AVAILABILITYMANAGERNIGHTCYCLE_IMPL_HPP