Skip to content

Commit

Permalink
Allowing soft-mode table generation.
Browse files Browse the repository at this point in the history
  • Loading branch information
DamonHD committed Sep 28, 2023
1 parent 29cfceb commit 1bc57d5
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 16 deletions.
22 changes: 22 additions & 0 deletions Main-htmltable-summary-soft.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<booleanAttribute key="org.eclipse.debug.core.ATTR_FORCE_SYSTEM_CONSOLE_ENCODING" value="false"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/TRVmodel/javasrc/org/hd/d/TRVmodel/Main.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
</listAttribute>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_ATTR_USE_ARGFILE" value="false"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_EXCLUDE_TEST_CODE" value="true"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_SHOW_CODEDETAILS_IN_EXCEPTION_MESSAGES" value="true"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_CLASSPATH_ONLY_JAR" value="false"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.hd.d.TRVmodel.Main"/>
<stringAttribute key="org.eclipse.jdt.launching.MODULE_NAME" value="TRVmodel"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-htmltable summarySoft"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="TRVmodel"/>
</launchConfiguration>
5 changes: 3 additions & 2 deletions javasrc/org/hd/d/TRVmodel/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ private static void printOptions()
System.err.println(" Show Heat Geek TRV/HP model and variants.");
System.err.println(" -htmltable XXX");
System.err.println(" Write HTML table XXX to out.html for debugging.");
System.err.println(" XXX can be one of: main, summary");
System.err.println(" XXX can be one of: summary, summarySoft");
}

/**Default name of output file for debugging HTML table generation; non-null. */
Expand Down Expand Up @@ -71,7 +71,8 @@ public static void main(final String[] args)

switch(args[1])
{
case "summary": tableHTML = ShowComputations.generateHTMLMainSummaryTable(); break;
case "summary": tableHTML = ShowComputations.generateHTMLMainSummaryTable(true); break;
case "summarySoft": tableHTML = ShowComputations.generateHTMLMainSummaryTable(false); break;
default:
System.err.println("unknown table: " + args[1]);
System.exit(1);
Expand Down
15 changes: 9 additions & 6 deletions javasrc/org/hd/d/TRVmodel/hg/ShowComputations.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,18 +229,19 @@ public static void showCalcs() throws IOException
* <p>
* The table class at least should be fixed up manually.
*/
public static String generateHTMLMainSummaryTable() throws IOException
public static String generateHTMLMainSummaryTable(final boolean stiff) throws IOException
{
// Vertically split as location, heat demand delta on setback, ABAB hp demand change, AABB demand change.
// Each by bungalow/detached.
final StringBuilder result = new StringBuilder();
result.append("<table style=\"border:1px solid\" class=\"yourTableStyle\">\n");
result.append(String.format("""
<caption>\
Summary of mean power change with selected-room setback of\s\
(1) whole-home heat demand and of\s\
(2) heat-pump electrical demand in high ABAB and low AABB internal loss room setback arrangements\s\
(3) for 1- and 2- storey (bungalow and detached) archetypes, \s\
%s mode: summary of mean power change with selected-room setback of\s\
(1) %s temperature regulation in A rooms\s\
(2) whole-home heat demand and of\s\
(3) heat-pump electrical demand in high ABAB and low AABB internal loss room setback arrangements\s\
(4) for 1- and 2- storey (bungalow and detached) archetypes, \s\
for %d UK locations.\s\
Based on hourly temperature data for the ten years 201X.\s\
When B rooms are set back overall home heat demand does fall,\s\
Expand All @@ -249,6 +250,8 @@ public static String generateHTMLMainSummaryTable() throws IOException
especially in the detached house cases.\
</caption>
""",
stiff ? "Stiff" : "Soft",
stiff ? "stiff" : "soft",
DDNTemperatureDataCSV.DESCRIPTORS_201X_DATASET.size()));
result.append("""
<thead><tr>\
Expand Down Expand Up @@ -287,7 +290,7 @@ public static String generateHTMLMainSummaryTable() throws IOException
final HGTRVHPMModelByHour scenario201X = new HGTRVHPMModelByHour(
modelParameters,
temperatures201X);
final ScenarioResult result201X = scenario201X.runScenario(detached, false, null);
final ScenarioResult result201X = scenario201X.runScenario(detached, !stiff, null);
final double heatNoSetback201X = result201X.demand().noSetback().heatDemand();
final double heatWithSetback201X = result201X.demand().withSetback().heatDemand();
// Overall home heat demand is not affected by archetype or room setback layout, so only show once.
Expand Down
11 changes: 3 additions & 8 deletions test/javasrc/localtest/TestMisc.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,13 @@ public static void testSanity() { }
*/
public static void testHTMLTableBasics() throws IOException, ParserConfigurationException, SAXException
{
final String table1 = ShowComputations.generateHTMLMainSummaryTable();
// Sufficient to test it for one of the cases for now.
final boolean stiff = true;
final String table1 = ShowComputations.generateHTMLMainSummaryTable(stiff);
assertTrue(table1.startsWith("<table"));
assertTrue(table1.endsWith("</table>"));
final DocumentBuilder builder1 = DocumentBuilderFactory.newInstance().newDocumentBuilder();
final Document doc1 = builder1.parse(new InputSource(new StringReader(table1)));
assertTrue(doc1.hasChildNodes());
//
// final String table2 = ShowComputations.generateHTMLMainFullTable();
// assertTrue(table2.startsWith("<table"));
// assertTrue(table2.endsWith("</table>"));
// final DocumentBuilder builder2 = DocumentBuilderFactory.newInstance().newDocumentBuilder();
// final Document doc2 = builder2.parse(new InputSource(new StringReader(table2)));
// assertTrue(doc2.hasChildNodes());
}
}

0 comments on commit 1bc57d5

Please sign in to comment.