| 1881 | } |
| 1882 | |
| 1883 | bool ThermalZone_Impl::addToNodeImpl(Node& node) { |
| 1884 | Model _model = model(); |
| 1885 | |
| 1886 | auto thisObject = getObject<ThermalZone>(); |
| 1887 | |
| 1888 | if (node.model() != _model) { |
| 1889 | return false; |
| 1890 | } |
| 1891 | |
| 1892 | if (isPlenum()) { |
| 1893 | return false; |
| 1894 | } |
| 1895 | |
| 1896 | auto airLoop = node.airLoopHVAC(); |
| 1897 | |
| 1898 | if (airLoop) { |
| 1899 | auto loops = airLoopHVACs(); |
| 1900 | for (const auto& loop : loops) { |
| 1901 | if (loop.handle() == airLoop->handle()) { |
| 1902 | return false; |
| 1903 | } |
| 1904 | } |
| 1905 | |
| 1906 | auto inletObj = node.inletModelObject(); |
| 1907 | auto outletObj = node.outletModelObject(); |
| 1908 | |
| 1909 | if (inletObj && outletObj) { |
| 1910 | // Rules for allowing connection: |
| 1911 | // * It must be the last node on the demand branch, meaning the outlet must be the Mixer |
| 1912 | // * There must not be any ThermalZone on the branch already |
| 1913 | // * (If ok, then the inletObj is usually an AirTerminal) |
| 1914 | // * In the most common case where not ok, inletObj is a PortList that connects to the ThermalZone |
| 1915 | // * inletObj can also be OS:AirLoopHVAC:ReturnPlenum |
| 1916 | // * => can't really check if inletObj is a Class, instead we check that the demand branch (between splitter and node) doesn't have a |
| 1917 | // ThermalZone already |
| 1918 | if ((airLoop->demandComponents(airLoop->demandSplitter(), node, IddObjectType::OS_ThermalZone).empty()) |
| 1919 | && (outletObj->optionalCast<Mixer>())) { |
| 1920 | Node newNode(_model); |
| 1921 | auto thisobj = getObject<ThermalZone>(); |
| 1922 | auto _inletPortList = inletPortList(); |
| 1923 | auto _returnPortList = returnPortList(); |
| 1924 | |
| 1925 | unsigned oldMixerPort = node.connectedObjectPort(node.outletPort()).get(); |
| 1926 | |
| 1927 | _model.connect(node, node.outletPort(), _inletPortList, _inletPortList.nextPort()); |
| 1928 | |
| 1929 | _model.connect(_returnPortList, _returnPortList.nextPort(), newNode, newNode.inletPort()); |
| 1930 | |
| 1931 | _model.connect(newNode, newNode.outletPort(), outletObj.get(), oldMixerPort); |
| 1932 | |
| 1933 | // Add the terminal to equipment list |
| 1934 | if ((!inletObj->optionalCast<Splitter>()) && (!inletObj->optionalCast<Node>())) { |
| 1935 | addEquipment(inletObj.get()); |
| 1936 | |
| 1937 | if (boost::optional<AirTerminalSingleDuctParallelPIUReheat> terminal = |
| 1938 | inletObj->optionalCast<AirTerminalSingleDuctParallelPIUReheat>()) { |
| 1939 | Node secondaryInletNode(_model); |
| 1940 |
nothing calls this directly
no test coverage detected