Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chiller:Electric:EIR API related to node need a serious refactor #3606

Closed
jmarrec opened this issue Jul 23, 2019 · 2 comments · Fixed by #3847
Closed

Chiller:Electric:EIR API related to node need a serious refactor #3606

jmarrec opened this issue Jul 23, 2019 · 2 comments · Fixed by #3847
Assignees

Comments

@jmarrec
Copy link
Collaborator

jmarrec commented Jul 23, 2019

None of these should exist, especially not in the public header (ChillerElectricEIR.hpp):

  bool setChilledWaterInletNodeName(std::string chilledWaterInletNodeName);
  bool setChilledWaterOutletNodeName(std::string chilledWaterOutletNodeName);

  bool setCondenserInletNodeName(boost::optional<std::string> condenserInletNodeName);
  bool setCondenserInletNodeName(std::string condenserInletNodeName);
  void resetCondenserInletNodeName();

  bool setCondenserOutletNodeName(boost::optional<std::string> condenserOutletNodeName);
  bool setCondenserOutletNodeName(std::string condenserOutletNodeName);
  void resetCondenserOutletNodeName();

  bool setHeatRecoveryInletNodeName(boost::optional<std::string> heatRecoveryInletNodeName);
  bool setHeatRecoveryInletNodeName(std::string heatRecoveryInletNodeName);
  void resetHeatRecoveryInletNodeName();

  bool setHeatRecoveryOutletNodeName(boost::optional<std::string> heatRecoveryOutletNodeName);
  bool setHeatRecoveryOutletNodeName(std::string heatRecoveryOutletNodeName);
  void resetHeatRecoveryOutletNodeName();

All of these plant loop connections are supposed to be set using addToNode / addToTertiaryNode.

ChillerElectricEIR::addToNode should probably be overloaded to do something like what I've done for CentralHeatPumpSystem:

bool CentralHeatPumpSystem_Impl::addToNode(Node & node)
{
boost::optional<PlantLoop> t_plantLoop = node.plantLoop();
// If trying to add to a node that is on the supply side of a plant loop
if( t_plantLoop ) {
if( t_plantLoop->supplyComponent(node.handle()) ) {
// If there is already a cooling Plant Loop
boost::optional<PlantLoop> coolingPlant = this->coolingPlantLoop();
if (coolingPlant) {
// And it's not the same as the node's loop
if (t_plantLoop.get() != coolingPlant.get()) {
// And if there is no heatingPlantLoop (tertiary)
boost::optional<PlantLoop> heatingPlant = this->heatingPlantLoop();
if (!heatingPlant) {
// Then try to add it to the tertiary one
LOG(Warn, "Calling addToTertiaryNode to connect it to the tertiary (=heating) loop for " << briefDescription());
return this->addToTertiaryNode(node);
}
}
}
}
}
// All other cases, call the base class implementation
return WaterToWaterComponent_Impl::addToNode(node);
}

@eringold can give you a MCVE of a ruby script that produces a hard crash

@eringold
Copy link
Contributor

eringold commented Jul 23, 2019

m = OpenStudio::Model::Model.new

chiller = OpenStudio::Model::ChillerElectricEIR.new(m)

puts chiller

node = OpenStudio::Model::Node.new(m)

chiller.setHeatRecoveryInletNodeName(node.name.get)

puts chiller

chiller.setHeatRecoveryOutletNodeName(node.name.get)

puts chiller

The above will not hard crash, but will print:

[BOOST_ASSERT] <2> Assertion result failed on line 665 of bool __cdecl openstudio::model::detail::ChillerElectricEIR_Impl::setHeatRecoveryInletNodeName(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >) in file C:\Users\jenkins\git\OpenStudio\openstudiocore\src\model\ChillerElectricEIR.cpp.

and

[BOOST_ASSERT] <2> Assertion result failed on line 685 of bool __cdecl openstudio::model::detail::ChillerElectricEIR_Impl::setHeatRecoveryOutletNodeName(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >) in file C:\Users\jenkins\git\OpenStudio\openstudiocore\src\model\ChillerElectricEIR.cpp.

and otherwise do nothing to the chiller.

@jmarrec
Copy link
Collaborator Author

jmarrec commented Dec 2, 2019

Related to the tertiary node: #3111, might be worth doing both objects at the same time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants