Skip to content

Commit 729608a

Browse files
committed
Add WWR to report.
Change result output from WholeNetEnergyConsumptionRefPerArea to WholeNetEnergyConsumptionPerArea.
1 parent d95b882 commit 729608a

File tree

6 files changed

+61
-8
lines changed

6 files changed

+61
-8
lines changed

openstudiocore/src/bec/ForwardTranslator.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ namespace bec {
415415
ForwardTranslator::ForwardTranslator()
416416
{
417417
_sunlits = NULL;
418+
_wwr_totoal = 0.0f;
418419
m_logSink.setLogLevel(Warn);
419420
m_logSink.setChannelRegex(boost::regex("openstudio\\.bec\\.ForwardTranslator"));
420421
m_logSink.setThreadId(QThread::currentThread());
@@ -428,10 +429,12 @@ bool ForwardTranslator::modelTobec(const openstudio::model::Model& model
428429
, const openstudio::path& path
429430
, ProgressBar* progressBar
430431
, std::string *bvName
431-
, QHash<QString, QList<double>>* sunlits)
432+
, QHash<QString, QList<double>>* sunlits
433+
, float wwr_totoal)
432434
{
433435
QInputDialog inputBuildingType;
434436
_sunlits = sunlits;
437+
_wwr_totoal = wwr_totoal;
435438
inputBuildingType.setOption(QInputDialog::UseListViewForComboBoxItems);
436439
inputBuildingType.setWindowTitle("What is building type.");
437440
inputBuildingType.setLabelText("Selection:");
@@ -936,6 +939,7 @@ void ForwardTranslator::doSectionOfWall(const model::Model &model, QDomElement &
936939
}else{
937940
//TODO:ERROR
938941
}
942+
939943
QDomElement WallD = createTagWithText(WallDetail,"WallD");
940944
createTagWithText(WallD, "WallDetailWallListName", sfName);
941945
createTagWithText(WallD, "WallDetailSectionName", sfName);

openstudiocore/src/bec/ForwardTranslator.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ namespace bec {
7272

7373
bool modelTobec(const openstudio::model::Model& model
7474
, const openstudio::path& path
75-
, ProgressBar* progressBar = nullptr
76-
, std::string *bvName=nullptr, QHash<QString, QList<double> > *sunlits=nullptr);
75+
, ProgressBar* progressBar
76+
, std::string *bvName, QHash<QString, QList<double> > *sunlits
77+
, float wwr_totoal);
7778

7879
/** Get warning messages generated by the last translation. */
7980
std::vector<LogMessage> warnings() const;
@@ -185,6 +186,7 @@ namespace bec {
185186
QDomElement BuildingZoneOtherEquipment;
186187

187188
QHash<QString, QList<double>>* _sunlits;
189+
float _wwr_totoal;
188190
QHash<QString, QList<QString>> chilledEq;
189191
StringStreamLogSink m_logSink;
190192
ProgressBar* m_progressBar;

openstudiocore/src/openstudio_lib/OSDocument.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1233,7 +1233,7 @@ void OSDocument::exportFile(fileType type)
12331233
}
12341234
else if (type == BEC){
12351235
bec::ForwardTranslator trans;
1236-
trans.modelTobec(m, outDir);
1236+
trans.modelTobec(m, outDir, NULL, NULL, NULL, 0.0f);
12371237
translatorErrors = trans.errors();
12381238
translatorWarnings = trans.warnings();
12391239
}

openstudiocore/src/openstudio_lib/ResultsTabView.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ ResultsView::ResultsView(QWidget *t_parent)
120120
hLayout->addWidget(m_openResultsViewerBtn, 0, Qt::AlignVCenter);
121121

122122
m_view = new ResultsWebView(this);
123+
m_view->setLocale(QLocale(QLocale::Thai, QLocale::Thailand));
123124
m_view->setContextMenuPolicy(Qt::NoContextMenu);
124125
m_view->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
125126
mainLayout->addWidget(m_view, 0, Qt::AlignTop);

openstudiocore/src/openstudio_lib/RunTabView.cpp

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ class doTableOnPath : public IDoTable
424424
QDomNode nd = nodes.at(idx);
425425
QDomElement element = nd.toElement();
426426

427-
if(element.tagName() == "WholeNetEnergyConsumptionRefPerArea"){
427+
if(element.tagName() == "WholeNetEnergyConsumptionPerArea"){
428428
bool isOK = false;
429429
WholeNetEnergyConsumptionPerArea = element.text().toDouble(&isOK);
430430
if(!isOK){
@@ -625,7 +625,17 @@ static openstudio::path resourcesPath()
625625
}
626626
}
627627

628-
static bool doBecReport(const QString &path, QString& outpath, QString &err){
628+
static QDomElement createTagWithText(QDomDocument* doc, QDomElement &parent, const QString &tag, const QString &text)
629+
{
630+
QDomElement elm = doc->createElement(tag);
631+
if(!text.isEmpty())
632+
elm.appendChild(doc->createTextNode(text.toUtf8()));
633+
634+
parent.appendChild(elm);
635+
return elm;
636+
}
637+
638+
static bool doBecReport(const QString &path, QString& outpath, QString &err, float wwr_total){
629639
QDomDocument doc("becreport");
630640

631641
QFileInfo fi(path);
@@ -714,6 +724,15 @@ background-color: #ffff99;\n\
714724

715725
QDomElement docElem = doc.documentElement();
716726
//doTable(docElem.tagName(), docElem, file, 0);
727+
728+
QDomElement ottvReport = findElementOnPath(docElem, QStringList() << "EnvelopeSystem" << "BuildingOTTVReport");
729+
if(!ottvReport.isNull()){
730+
QString str = ottvReport.toDocument().toString();
731+
str = str + "xxxx";
732+
createTagWithText(&doc, ottvReport, "WWR", QString::number(wwr_total));
733+
createTagWithText(&doc, ottvReport, "WWRUnit", "A/C");
734+
}
735+
717736
QString tables = doTableV2(docElem);
718737
file.write(tables.toUtf8());
719738

@@ -1015,7 +1034,7 @@ bool RunView::doBecInput(const QString &path, const model::Model &model, QString
10151034
m_outputWindow->appendPlainText(QString("Create input.xml at %1").arg(path));
10161035

10171036
std::string bvn;
1018-
bool success = trans.modelTobec(model, path.toStdString().c_str(), NULL, &bvn, &sunlits);
1037+
bool success = trans.modelTobec(model, path.toStdString().c_str(), NULL, &bvn, &sunlits, wwr_totoal);
10191038
bvName = bvn.c_str();
10201039

10211040
std::string bvsdefault = resourcesPath().string() + "/" + "default_building_standard.bvs";
@@ -1653,11 +1672,13 @@ void RunView::playButtonClicked(bool t_checked)
16531672
//////////////////////////
16541673
QFile file(outpath+"../5-EnergyPlus-0/eplustbl.htm");
16551674
sunlits.clear();
1675+
wwr_totoal = 0.0f;
16561676
if (file.open(QIODevice::ReadOnly | QIODevice::Text))
16571677
{
16581678
m_outputWindow->appendHtml(QString("<font color=\"blue\">Start read eblustbl.htm</font>"));
16591679
QTextStream in(&file);
16601680
QString str = in.readAll();
1681+
QString gwstr = str;
16611682
int start = str.indexOf("<b>Sunlit Fraction</b>");
16621683
int table_start_idx = str.indexOf("<table", start);
16631684
int table_end_idx = str.indexOf("</table>", table_start_idx+6);
@@ -1691,6 +1712,30 @@ void RunView::playButtonClicked(bool t_checked)
16911712
m_outputWindow->appendHtml(QString("<font color=\"green\">%1</font>\n").arg(msg));
16921713
}
16931714
m_outputWindow->appendHtml(QString("<font color=\"blue\">SF:%1</font>").arg(QString::number(sunlits.size())));
1715+
1716+
//Read Conditioned Window-Wall Ratio --> Gross Window-Wall Ratio [%] --> <td align="right"> 35.20</td>
1717+
int idx_of_wwrAll = gwstr.indexOf("Conditioned Window-Wall Ratio");
1718+
int idx_of_wwrAll_end = -1;
1719+
if (idx_of_wwrAll > -1){
1720+
idx_of_wwrAll = gwstr.indexOf("Gross Window-Wall Ratio [%]", idx_of_wwrAll);
1721+
const QString tdBegin("<td align=\"right\"> ");
1722+
const QString tdEnd("</td>");
1723+
idx_of_wwrAll = gwstr.indexOf(tdBegin, idx_of_wwrAll);
1724+
if (idx_of_wwrAll > -1){
1725+
idx_of_wwrAll += tdBegin.length();
1726+
idx_of_wwrAll_end = gwstr.indexOf(tdEnd, idx_of_wwrAll);
1727+
m_outputWindow->appendHtml(QString("idx0:%1, idx1:%2").arg(idx_of_wwrAll).arg(idx_of_wwrAll_end));
1728+
if (idx_of_wwrAll_end > -1){
1729+
gwstr = gwstr.mid(idx_of_wwrAll, idx_of_wwrAll_end - idx_of_wwrAll);
1730+
m_outputWindow->appendHtml(QString("gwstr:[%1]").arg(gwstr));
1731+
gwstr = gwstr.trimmed();
1732+
wwr_totoal = gwstr.toFloat();
1733+
wwr_totoal = wwr_totoal/100.0f;
1734+
m_outputWindow->appendHtml(QString("wwr_totoal:[%1]").arg(wwr_totoal));
1735+
m_outputWindow->appendHtml(QString("<font color=\"blue\"><b>wwr totoal:%1</b></font>").arg(gwstr));
1736+
}
1737+
}
1738+
}
16941739
}else{
16951740
m_outputWindow->appendHtml(QString("<font color=\"red\">ERROR:Can't read eblustbl.htm</font>"));
16961741
}
@@ -1848,7 +1893,7 @@ void RunView::becFinished(int exitCode, QProcess::ExitStatus exitStatus)
18481893
m_outputWindow->appendPlainText("BEC Finished.");
18491894
m_outputWindow->appendPlainText("Generate Report.");
18501895
QString outpath, err;
1851-
if(!doBecReport(becoutputPath, outpath, err)){
1896+
if(!doBecReport(becoutputPath, outpath, err, wwr_totoal)){
18521897
m_outputWindow->appendPlainText("Error BEC Report.");
18531898
m_outputWindow->appendPlainText(err);
18541899
}

openstudiocore/src/openstudio_lib/RunTabView.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ namespace openstudio {
152152
//openstudio::path scriptsDir() const;
153153

154154
QHash<QString, QList<double>> sunlits;
155+
float wwr_totoal;
155156
QWidget * m_runNavigatorWidget;
156157
QToolButton * m_playButton;
157158
QComboBox * m_chooser;

0 commit comments

Comments
 (0)