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

Fix #792 - Add support for HotWaterEquipment and HotWaterEquipmentDefinition #793

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/openstudio_lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ set(${target_name}_SRC
GridViewSubTab.hpp
HorizontalTabWidget.cpp
HorizontalTabWidget.hpp
HotWaterEquipmentInspectorView.cpp
HotWaterEquipmentInspectorView.hpp
Comment on lines +96 to +97
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really a copy paste from ElectricEquipment it behaves exactly the same.

HVACSystemsController.cpp
HVACSystemsController.hpp
HVACSystemsTabController.cpp
Expand Down Expand Up @@ -540,6 +542,7 @@ set(${target_name}_moc
GridScene.hpp
GridViewSubTab.hpp
HorizontalTabWidget.hpp
HotWaterEquipmentInspectorView.hpp
HVACSystemsController.hpp
HVACSystemsTabController.hpp
HVACSystemsTabView.hpp
Expand Down
212 changes: 212 additions & 0 deletions src/openstudio_lib/HotWaterEquipmentInspectorView.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
/***********************************************************************************************************************
* OpenStudio(R), Copyright (c) OpenStudio Coalition and other contributors.
* See also https://openstudiocoalition.org/about/software_license/
***********************************************************************************************************************/

#include "HotWaterEquipmentInspectorView.hpp"
#include "../shared_gui_components/OSLineEdit.hpp"
#include "../shared_gui_components/OSQuantityEdit.hpp"
#include "OSDropZone.hpp"
#include <openstudio/model/HotWaterEquipmentDefinition.hpp>
#include <openstudio/model/HotWaterEquipmentDefinition_Impl.hpp>
#include <openstudio/utilities/core/Assert.hpp>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QGridLayout>
#include <QScrollArea>
#include <QStackedWidget>

namespace openstudio {

HotWaterEquipmentDefinitionInspectorView::HotWaterEquipmentDefinitionInspectorView(bool isIP, const openstudio::model::Model& model, QWidget* parent)
: ModelObjectInspectorView(model, true, parent), m_nameEdit(new OSLineEdit2()), m_isIP(isIP) {

auto* visibleWidget = new QWidget();
this->stackedWidget()->addWidget(visibleWidget);

auto* mainGridLayout = new QGridLayout();
mainGridLayout->setContentsMargins(7, 7, 7, 7);
mainGridLayout->setSpacing(14);
visibleWidget->setLayout(mainGridLayout);

// Name

auto* label = new QLabel("Name: ");
label->setObjectName("H2");
mainGridLayout->addWidget(label, 0, 0);

mainGridLayout->addWidget(m_nameEdit, 1, 0, 1, 3);

// Design Level

label = new QLabel("Design Level: ");
label->setObjectName("H2");
mainGridLayout->addWidget(label, 2, 0);

m_designLevelEdit = new OSQuantityEdit2("W", "W", "W", m_isIP);
connect(this, &HotWaterEquipmentDefinitionInspectorView::toggleUnitsClicked, m_designLevelEdit, &OSQuantityEdit2::onUnitSystemChange);
mainGridLayout->addWidget(m_designLevelEdit, 3, 0);

// Watts Per Space Floor Area

label = new QLabel("Watts Per Space Floor Area: ");
label->setObjectName("H2");
mainGridLayout->addWidget(label, 2, 1);

m_wattsPerSpaceFloorAreaEdit = new OSQuantityEdit2("W/m^2", "W/m^2", "W/ft^2", m_isIP);
connect(this, &HotWaterEquipmentDefinitionInspectorView::toggleUnitsClicked, m_wattsPerSpaceFloorAreaEdit, &OSQuantityEdit2::onUnitSystemChange);
mainGridLayout->addWidget(m_wattsPerSpaceFloorAreaEdit, 3, 1);

// Watts Per Person

label = new QLabel("Watts Per Person: ");
label->setObjectName("H2");
mainGridLayout->addWidget(label, 2, 2);

m_wattsPerPersonEdit = new OSQuantityEdit2("W/person", "W/person", "W/person", m_isIP);
connect(this, &HotWaterEquipmentDefinitionInspectorView::toggleUnitsClicked, m_wattsPerPersonEdit, &OSQuantityEdit2::onUnitSystemChange);
mainGridLayout->addWidget(m_wattsPerPersonEdit, 3, 2);

// Fraction Latent

label = new QLabel("Fraction Latent: ");
label->setObjectName("H2");
mainGridLayout->addWidget(label, 4, 0);

m_fractionLatentEdit = new OSQuantityEdit2("", "", "", m_isIP);
connect(this, &HotWaterEquipmentDefinitionInspectorView::toggleUnitsClicked, m_fractionLatentEdit, &OSQuantityEdit2::onUnitSystemChange);
mainGridLayout->addWidget(m_fractionLatentEdit, 5, 0);

// Fraction Radiant

label = new QLabel("Fraction Radiant: ");
label->setObjectName("H2");
mainGridLayout->addWidget(label, 4, 1);

m_fractionRadiantEdit = new OSQuantityEdit2("", "", "", m_isIP);
connect(this, &HotWaterEquipmentDefinitionInspectorView::toggleUnitsClicked, m_fractionRadiantEdit, &OSQuantityEdit2::onUnitSystemChange);
mainGridLayout->addWidget(m_fractionRadiantEdit, 5, 1);

// Fraction Lost

label = new QLabel("Fraction Lost: ");
label->setObjectName("H2");
mainGridLayout->addWidget(label, 6, 0);

m_fractionLostEdit = new OSQuantityEdit2("", "", "", m_isIP);
connect(this, &HotWaterEquipmentDefinitionInspectorView::toggleUnitsClicked, m_fractionLostEdit, &OSQuantityEdit2::onUnitSystemChange);
mainGridLayout->addWidget(m_fractionLostEdit, 7, 0);

// Stretch

mainGridLayout->setRowStretch(8, 100);

mainGridLayout->setColumnStretch(3, 100);
}

void HotWaterEquipmentDefinitionInspectorView::onClearSelection() {
ModelObjectInspectorView::onClearSelection(); // call parent implementation
detach();
}

void HotWaterEquipmentDefinitionInspectorView::onSelectModelObject(const openstudio::model::ModelObject& modelObject) {
detach();
auto hotwaterEquipmentDefinition = modelObject.cast<model::HotWaterEquipmentDefinition>();
attach(hotwaterEquipmentDefinition);
refresh();
}

void HotWaterEquipmentDefinitionInspectorView::onUpdate() {
refresh();
}

void HotWaterEquipmentDefinitionInspectorView::attach(const openstudio::model::HotWaterEquipmentDefinition& hotwaterEquipmentDefinition) {
m_hotwaterEquipmentDefinition = hotwaterEquipmentDefinition;

// m_nameEdit->bind(hotwaterEquipmentDefinition,"name");
m_nameEdit->bind(*m_hotwaterEquipmentDefinition,
OptionalStringGetter(std::bind(&model::HotWaterEquipmentDefinition::name, m_hotwaterEquipmentDefinition.get_ptr(), true)),
boost::optional<StringSetterOptionalStringReturn>(
std::bind(&model::HotWaterEquipmentDefinition::setName, m_hotwaterEquipmentDefinition.get_ptr(), std::placeholders::_1)));

// m_designLevelEdit->bind(hotwaterEquipmentDefinition,"designLevel",m_isIP);
m_designLevelEdit->bind(m_isIP, *m_hotwaterEquipmentDefinition,
OptionalDoubleGetter(std::bind(&model::HotWaterEquipmentDefinition::designLevel, m_hotwaterEquipmentDefinition.get_ptr())),
boost::optional<DoubleSetter>(std::bind(
static_cast<bool (model::HotWaterEquipmentDefinition::*)(double)>(&model::HotWaterEquipmentDefinition::setDesignLevel),
m_hotwaterEquipmentDefinition.get_ptr(), std::placeholders::_1)));

// m_wattsPerSpaceFloorAreaEdit->bind(hotwaterEquipmentDefinition,"wattsperSpaceFloorArea",m_isIP);
m_wattsPerSpaceFloorAreaEdit->bind(
m_isIP, *m_hotwaterEquipmentDefinition,
OptionalDoubleGetter(std::bind(&model::HotWaterEquipmentDefinition::wattsperSpaceFloorArea, m_hotwaterEquipmentDefinition.get_ptr())),
boost::optional<DoubleSetter>(
std::bind(static_cast<bool (model::HotWaterEquipmentDefinition::*)(double)>(&model::HotWaterEquipmentDefinition::setWattsperSpaceFloorArea),
m_hotwaterEquipmentDefinition.get_ptr(), std::placeholders::_1)));

// m_wattsPerPersonEdit->bind(hotwaterEquipmentDefinition,"wattsperPerson",m_isIP);
m_wattsPerPersonEdit->bind(
m_isIP, *m_hotwaterEquipmentDefinition,
OptionalDoubleGetter(std::bind(&model::HotWaterEquipmentDefinition::wattsperPerson, m_hotwaterEquipmentDefinition.get_ptr())),
boost::optional<DoubleSetter>(
std::bind(static_cast<bool (model::HotWaterEquipmentDefinition::*)(double)>(&model::HotWaterEquipmentDefinition::setWattsperPerson),
m_hotwaterEquipmentDefinition.get_ptr(), std::placeholders::_1)));

// m_fractionLatentEdit->bind(hotwaterEquipmentDefinition,"fractionLatent",m_isIP);
m_fractionLatentEdit->bind(
m_isIP, *m_hotwaterEquipmentDefinition,
OptionalDoubleGetter(std::bind(&model::HotWaterEquipmentDefinition::fractionLatent, m_hotwaterEquipmentDefinition.get_ptr())),
boost::optional<DoubleSetter>(
std::bind(static_cast<bool (model::HotWaterEquipmentDefinition::*)(double)>(&model::HotWaterEquipmentDefinition::setFractionLatent),
m_hotwaterEquipmentDefinition.get_ptr(), std::placeholders::_1)),
boost::optional<NoFailAction>(std::bind(&model::HotWaterEquipmentDefinition::resetFractionLatent, m_hotwaterEquipmentDefinition.get_ptr())),
boost::none, boost::none,
boost::optional<BasicQuery>(std::bind(&model::HotWaterEquipmentDefinition::isFractionLatentDefaulted, m_hotwaterEquipmentDefinition.get_ptr())));

// m_fractionRadiantEdit->bind(hotwaterEquipmentDefinition,"fractionRadiant",m_isIP);
m_fractionRadiantEdit->bind(
m_isIP, *m_hotwaterEquipmentDefinition,
OptionalDoubleGetter(std::bind(&model::HotWaterEquipmentDefinition::fractionRadiant, m_hotwaterEquipmentDefinition.get_ptr())),
boost::optional<DoubleSetter>(
std::bind(static_cast<bool (model::HotWaterEquipmentDefinition::*)(double)>(&model::HotWaterEquipmentDefinition::setFractionRadiant),
m_hotwaterEquipmentDefinition.get_ptr(), std::placeholders::_1)),
boost::optional<NoFailAction>(std::bind(&model::HotWaterEquipmentDefinition::resetFractionRadiant, m_hotwaterEquipmentDefinition.get_ptr())),
boost::none, boost::none,
boost::optional<BasicQuery>(std::bind(&model::HotWaterEquipmentDefinition::isFractionRadiantDefaulted, m_hotwaterEquipmentDefinition.get_ptr())));

// m_fractionLostEdit->bind(hotwaterEquipmentDefinition,"fractionLost",m_isIP);
m_fractionLostEdit->bind(
m_isIP, *m_hotwaterEquipmentDefinition,
OptionalDoubleGetter(std::bind(&model::HotWaterEquipmentDefinition::fractionLost, m_hotwaterEquipmentDefinition.get_ptr())),
boost::optional<DoubleSetter>(
std::bind(static_cast<bool (model::HotWaterEquipmentDefinition::*)(double)>(&model::HotWaterEquipmentDefinition::setFractionLost),
m_hotwaterEquipmentDefinition.get_ptr(), std::placeholders::_1)),
boost::optional<NoFailAction>(std::bind(&model::HotWaterEquipmentDefinition::resetFractionLost, m_hotwaterEquipmentDefinition.get_ptr())),
boost::none, boost::none,
boost::optional<BasicQuery>(std::bind(&model::HotWaterEquipmentDefinition::isFractionLostDefaulted, m_hotwaterEquipmentDefinition.get_ptr())));

this->stackedWidget()->setCurrentIndex(1);
}

void HotWaterEquipmentDefinitionInspectorView::detach() {
this->stackedWidget()->setCurrentIndex(0);

m_nameEdit->unbind();
m_designLevelEdit->unbind();
m_wattsPerSpaceFloorAreaEdit->unbind();
m_wattsPerPersonEdit->unbind();
m_fractionLatentEdit->unbind();
m_fractionRadiantEdit->unbind();
m_fractionLostEdit->unbind();

m_hotwaterEquipmentDefinition = boost::none;
}

void HotWaterEquipmentDefinitionInspectorView::refresh() {}

void HotWaterEquipmentDefinitionInspectorView::toggleUnits(bool displayIP) {
m_isIP = displayIP;
}

} // namespace openstudio
68 changes: 68 additions & 0 deletions src/openstudio_lib/HotWaterEquipmentInspectorView.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/***********************************************************************************************************************
* OpenStudio(R), Copyright (c) OpenStudio Coalition and other contributors.
* See also https://openstudiocoalition.org/about/software_license/
***********************************************************************************************************************/

#ifndef OPENSTUDIO_HOTWATEREQUIPMENTINSPECTORVIEW_HPP
#define OPENSTUDIO_HOTWATEREQUIPMENTINSPECTORVIEW_HPP

#include "ModelObjectInspectorView.hpp"
#include <openstudio/model/HotWaterEquipmentDefinition.hpp>

namespace openstudio {

class OSLineEdit2;

class OSQuantityEdit2;

class OSDropZone;

class HotWaterEquipmentDefinitionInspectorView : public ModelObjectInspectorView
{
Q_OBJECT

public:
HotWaterEquipmentDefinitionInspectorView(bool isIP, const openstudio::model::Model& model, QWidget* parent = nullptr);

virtual ~HotWaterEquipmentDefinitionInspectorView() = default;

protected:
virtual void onClearSelection() override;

virtual void onSelectModelObject(const openstudio::model::ModelObject& modelObject) override;

virtual void onUpdate() override;

private:
void attach(const openstudio::model::HotWaterEquipmentDefinition& hotwaterEquipmentDefinition);

void detach();

void refresh();

OSLineEdit2* m_nameEdit;

OSQuantityEdit2* m_designLevelEdit;

OSQuantityEdit2* m_wattsPerSpaceFloorAreaEdit;

OSQuantityEdit2* m_wattsPerPersonEdit;

OSQuantityEdit2* m_fractionLatentEdit;

OSQuantityEdit2* m_fractionRadiantEdit;

OSQuantityEdit2* m_fractionLostEdit;

bool m_isIP;

boost::optional<model::HotWaterEquipmentDefinition> m_hotwaterEquipmentDefinition;

public slots:

void toggleUnits(bool displayIP) override;
};

} // namespace openstudio

#endif // OPENSTUDIO_HOTWATEREQUIPMENTINSPECTORVIEW_HPP
4 changes: 4 additions & 0 deletions src/openstudio_lib/IconLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,10 @@ IconLibrary::IconLibrary() {
new QPixmap(":/images/mini_icons/heat_transfer_mini.png");
m_miniIcons[openstudio::IddObjectType(openstudio::IddObjectType::OS_HeatExchanger_FluidToFluid).value()] =
new QPixmap(":/images/mini_icons/fluid_hx_mini.png");
m_miniIcons[openstudio::IddObjectType(openstudio::IddObjectType::OS_HotWaterEquipment).value()] =
new QPixmap(":/images/mini_icons/hotwater_equipment.png");
m_miniIcons[openstudio::IddObjectType(openstudio::IddObjectType::OS_HotWaterEquipment_Definition).value()] =
new QPixmap(":/images/mini_icons/hotwater_equipment_definition.png");
m_miniIcons[openstudio::IddObjectType(openstudio::IddObjectType::OS_Humidifier_Steam_Electric).value()] =
new QPixmap(":/images/mini_icons/mini_electric_humidifier.png");
m_miniIcons[openstudio::IddObjectType(openstudio::IddObjectType::OS_Humidifier_Steam_Gas).value()] =
Expand Down
5 changes: 5 additions & 0 deletions src/openstudio_lib/LoadsController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include <openstudio/model/WaterUseEquipmentDefinition_Impl.hpp>
#include <openstudio/model/PeopleDefinition.hpp>
#include <openstudio/model/PeopleDefinition_Impl.hpp>
#include <openstudio/model/HotWaterEquipmentDefinition.hpp>
#include <openstudio/model/HotWaterEquipmentDefinition_Impl.hpp>

#include <openstudio/utilities/core/Assert.hpp>

Expand Down Expand Up @@ -73,6 +75,9 @@ void LoadsController::onAddObject(const openstudio::IddObjectType& iddObjectType
case IddObjectType::OS_WaterUse_Equipment_Definition:
openstudio::model::WaterUseEquipmentDefinition(this->model());
break;
case IddObjectType::OS_HotWaterEquipment_Definition:
openstudio::model::HotWaterEquipmentDefinition(this->model());
break;
Comment on lines +78 to +80
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

simple

default:
LOG_FREE(Error, "LoadsController", "Unknown IddObjectType '" << iddObjectType.valueName() << "'");
}
Expand Down
15 changes: 15 additions & 0 deletions src/openstudio_lib/LoadsView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "SteamEquipmentInspectorView.hpp"
#include "OtherEquipmentInspectorView.hpp"
#include "WaterUseEquipmentInspectorView.hpp"
#include "HotWaterEquipmentInspectorView.hpp"

#include <openstudio/model/Model_Impl.hpp>

Expand Down Expand Up @@ -50,6 +51,7 @@ std::vector<std::pair<IddObjectType, std::string>> LoadsView::modelObjectTypesAn
result.push_back(std::make_pair<IddObjectType, std::string>(IddObjectType::OS_OtherEquipment_Definition, "Other Equipment Definitions"));
result.push_back(std::make_pair<IddObjectType, std::string>(IddObjectType::OS_InternalMass_Definition, "Internal Mass Definitions"));
result.push_back(std::make_pair<IddObjectType, std::string>(IddObjectType::OS_WaterUse_Equipment_Definition, "Water Use Equipment Definitions"));
result.push_back(std::make_pair<IddObjectType, std::string>(IddObjectType::OS_HotWaterEquipment_Definition, "Hot Water Equipment Definitions"));

return result;
}
Expand Down Expand Up @@ -95,6 +97,9 @@ void LoadsInspectorView::onSelectModelObject(const openstudio::model::ModelObjec
case IddObjectType::OS_WaterUse_Equipment_Definition:
this->showWaterUseEquipmentDefinitionsInspector(modelObject);
break;
case IddObjectType::OS_HotWaterEquipment_Definition:
this->showHotWaterEquipmentDefinitionsInspector(modelObject);
break;
default:
showDefaultView();
}
Expand Down Expand Up @@ -199,6 +204,16 @@ void LoadsInspectorView::showInternalMassDefinitionsInspector(const openstudio::
this->showInspector(internalMassDefinitionInspectorView);
}

void LoadsInspectorView::showHotWaterEquipmentDefinitionsInspector(const openstudio::model::ModelObject& modelObject) {
auto* hotWaterEquipmentDefinitionInspectorView = new HotWaterEquipmentDefinitionInspectorView(m_isIP, m_model);
connect(this, &LoadsInspectorView::toggleUnitsClicked, hotWaterEquipmentDefinitionInspectorView,
&HotWaterEquipmentDefinitionInspectorView::toggleUnitsClicked);

hotWaterEquipmentDefinitionInspectorView->selectModelObject(modelObject);

showInspector(hotWaterEquipmentDefinitionInspectorView);
}
Comment on lines +207 to +215
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Easy peasy


void LoadsInspectorView::showDefaultView() {
if (QWidget* widget = this->stackedWidget()->currentWidget()) {
this->stackedWidget()->removeWidget(widget);
Expand Down
2 changes: 2 additions & 0 deletions src/openstudio_lib/LoadsView.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ class LoadsInspectorView : public ModelObjectInspectorView

void showWaterUseEquipmentDefinitionsInspector(const openstudio::model::ModelObject& modelObject);

void showHotWaterEquipmentDefinitionsInspector(const openstudio::model::ModelObject& modelObject);

void showInspector(QWidget* widget);

void showDefaultView();
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New icons

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/openstudio_lib/openstudio.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,10 @@
<file>images/mini_icons/[email protected]</file>
<file>images/mini_icons/hightempradiant.png</file>
<file>images/mini_icons/[email protected]</file>
<file>images/mini_icons/hotwater_equipment.png</file>
<file>images/mini_icons/[email protected]</file>
<file>images/mini_icons/hotwater_equipment_definition.png</file>
<file>images/mini_icons/[email protected]</file>
Comment on lines +829 to +832
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Icons registered in qrc

<file>images/mini_icons/illuminance_map.png</file>
<file>images/mini_icons/[email protected]</file>
<file>images/mini_icons/indirectEvap.png</file>
Expand Down
Loading
Loading