| 449 | } |
| 450 | |
| 451 | bool RefrigerationSystem_Impl::addAirChiller(const RefrigerationAirChiller& refrigerationAirChiller) { |
| 452 | // From 9.2 IO ref: |
| 453 | // > This list may contain a combination of case and walk-in names OR a list of air chiller names. |
| 454 | // > Air chillers may not be included in any list that also includes cases or walk-ins. |
| 455 | if (boost::optional<ModelObjectList> modelObjectList = refrigeratedCaseAndWalkInList()) { |
| 456 | std::vector<ModelObject> modelObjects = modelObjectList->modelObjects(); |
| 457 | |
| 458 | for (const auto& elem : modelObjects) { |
| 459 | if (elem.optionalCast<RefrigerationWalkIn>() || elem.optionalCast<RefrigerationCase>()) { |
| 460 | LOG(Warn, "You cannot mix RefigerationCase/RefrigerationWalkins with RefrigerationAirChillers, occurred for " << briefDescription()); |
| 461 | return false; |
| 462 | } |
| 463 | } |
| 464 | } |
| 465 | |
| 466 | // Enforce unicity |
| 467 | if (boost::optional<RefrigerationSystem> currentSystem = refrigerationAirChiller.system()) { |
| 468 | LOG(Warn, refrigerationAirChiller.briefDescription() |
| 469 | << " was removed from its existing RefrigerationSystem named '" << currentSystem->nameString() << "'."); |
| 470 | currentSystem->removeAirChiller(refrigerationAirChiller); |
| 471 | } |
| 472 | |
| 473 | boost::optional<ModelObjectList> modelObjectList = refrigeratedCaseAndWalkInList(); |
| 474 | return addTemplate<RefrigerationAirChiller>(refrigerationAirChiller, modelObjectList); |
| 475 | } |
| 476 | |
| 477 | void RefrigerationSystem_Impl::removeAirChiller(const RefrigerationAirChiller& refrigerationAirChiller) { |
| 478 | boost::optional<ModelObjectList> modelObjectList = refrigeratedCaseAndWalkInList(); |