code cleaning and env refactor

This commit is contained in:
Guille 2024-05-24 08:25:41 +02:00
parent 7c5bbbbd87
commit 768f492466
23 changed files with 99 additions and 89 deletions

4
environments/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
*
!.gitignore
!.env_demo
!README.md

9
environments/README.md Normal file
View File

@ -0,0 +1,9 @@
# Intro
The environments folder contains the env files for application it can be shared among workflows and it's intended to keep multiple environments under folder names for instance, montreal city layers env will be placed in montreal_citylayers
# env files structure
APPLICATION_USERNAME=username
APPLICATION_PASSWORD=secret_pass
APPLICATION=apikey

10
main.js
View File

@ -1,15 +1,15 @@
const Factory = require('./factory.js')
const { app, BrowserWindow, ipcMain, ipcRenderer } = require('electron')
const { app, BrowserWindow, ipcMain } = require('electron')
const { tmpdir } = require('node:os')
const path = require('node:path')
const createWindow = () => {
const win = new BrowserWindow({
width: 1400,
height: 1200,
webPreferences: {
preload: path.join(__dirname, 'preload.js')
}
height: 1200,
webPreferences: {
preload: path.join(__dirname, 'preload.js')
}
})
win.loadFile('index.html')
}

View File

@ -38,5 +38,19 @@
"category": "public.app-category.education",
"identity": null
}
}
},
"configurations": [
{
"name": "Debug Main Process",
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
"windows": {
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd"
},
"args" : ["."],
"outputCapture": "std"
}
]
}

View File

@ -1,12 +1,7 @@
const { contextBridge, ipcRenderer, ipcMain } = require('electron')
const { app, BrowserWindow} = require('electron')
contextBridge.exposeInMainWorld('functions', {
node: () => process.versions.node,
chrome: () => process.versions.chrome,
electron: () => process.versions.electron,
run: (value) => ipcRenderer.invoke('run', value),
setContent: (id, value) => ipcMain.invoke(id, value),
onTaskCompleted: (callback) => ipcRenderer.on('task-completed', (_event, value) => {
callback(value)
})

View File

@ -4,7 +4,7 @@ fetch('./workflows.json')
.then((workflowsJson) => {
workflowsJson.workflows.forEach((site) => {
let li = document.createElement('li')
li.className = "list-group-item"
li.className = 'list-group-item'
let img = document.createElement('img')
let a = document.createElement('a')
img.src = site.logo
@ -12,12 +12,12 @@ fetch('./workflows.json')
a.href = site.script
let name = document.createTextNode(site.name)
let span = document.createElement('span')
span.className = "p-1"
span.className = 'p-1'
a.appendChild(img)
span.appendChild(name)
a.appendChild(span)
li.appendChild(a)
workflowsList.appendChild(li)
})
});
})

View File

@ -1,3 +0,0 @@
APPLICATION_USERNAME=city_layers
APPLICATION_PASSWORD=city_layers
APPLICATION=36a065d9-bafb-4345-89fe-d68988ce9db2

View File

@ -1,5 +1,6 @@
const { dialog, BrowserWindow } = require('electron')
const BrowserWindow = require('electron')
const fs = require('fs')
const path = require('path')
const { Blob } = require('buffer')
const dotenv = require('dotenv')
const session_start = 'https://nextgenerations-cities.encs.concordia.ca/api/v1.4/session/start'
@ -7,10 +8,11 @@ const energy_plus = 'https://nextgenerations-cities.encs.concordia.ca/api/v1.4/w
exports.run = async (application, param, tmp_path) => {
console.log(`Executing ${application}`)
dotenv.config({ path:__dirname+'/.env' })
const application_uuid = process.env.APPLICATION;
const username = process.env.APPLICATION_USERNAME;
const password = process.env.APPLICATION_PASSWORD;
env_path = path.resolve(`${__dirname}/../../../environments/workflow_launcher/.env`)
dotenv.config({ path: env_path })
const application_uuid = process.env.APPLICATION
const username = process.env.APPLICATION_USERNAME
const password = process.env.APPLICATION_PASSWORD
let response = await fetch(session_start, {
method: 'PUT',
headers: {
@ -48,10 +50,10 @@ exports.run = async (application, param, tmp_path) => {
if (response.status == 200) {
var blob = await response.blob()
const buffer = Buffer.from(await blob.arrayBuffer())
require("fs").writeFile(
require('fs').writeFile(
`${tmp_path}/energyplus_results.zip`,
buffer,
(err) => { console.log(err ? err : 'energy+ zip saved'); }
(err) => { console.log(err ? err : 'energy+ zip saved') }
)
BrowserWindow.fromId(1).webContents.send('task-completed', `<a href="${tmp_path}/energyplus_results.zip">Energy plus results</a>`)
return

View File

@ -2,8 +2,8 @@ let param = {
'workflow': 'energy_plus',
'application': 'Energy+'
}
document.getElementById("runWorkflow").addEventListener("click", runWorkflow)
document.getElementById("geometry_file").addEventListener("change", (event) => {
document.getElementById('runWorkflow').addEventListener('click', runWorkflow)
document.getElementById('geometry_file').addEventListener('change', (event) => {
const file = event.target.files[0]
document.getElementById('parameters').style.visibility = 'visible'
let extension

View File

@ -1,3 +0,0 @@
APPLICATION_USERNAME=city_layers
APPLICATION_PASSWORD=city_layers
APPLICATION=36a065d9-bafb-4345-89fe-d68988ce9db2

View File

@ -1,3 +0,0 @@
APPLICATION_USERNAME=username
APPLICATION_PASSWORD=secret_pass
APPLICATION=apikey

View File

@ -1,4 +1,5 @@
const { dialog, BrowserWindow } = require ("electron");
const BrowserWindow = require('electron')
const path = require('path')
const dotenv = require('dotenv')
const session_start = 'https://nextgenerations-cities.encs.concordia.ca/api/v1.4/session/start'
const retrofit_results = 'https://nextgenerations-cities.encs.concordia.ca/api/v1.4/persistence/retrofit-results'
@ -6,10 +7,11 @@ const retrofit_results = 'https://nextgenerations-cities.encs.concordia.ca/api/v
exports.run = async (application, param, tmp_path) => {
buildings = param['buildings']
console.log(`Executing idf generation for ${application}`)
dotenv.config({ path:__dirname+'/.env' })
const application_uuid = process.env.APPLICATION;
const username = process.env.APPLICATION_USERNAME;
const password = process.env.APPLICATION_PASSWORD;
env_path = path.resolve(`${__dirname}/../../../environments/${application}/.env`)
dotenv.config({ path: env_path })
const application_uuid = process.env.APPLICATION
const username = process.env.APPLICATION_USERNAME
const password = process.env.APPLICATION_PASSWORD
let response = await fetch(session_start, {
method: 'PUT',
headers: {
@ -19,7 +21,7 @@ exports.run = async (application, param, tmp_path) => {
'application-uuid': application_uuid,
'accept': 'application/json'
}
});
})
if (response.status == 200) {
const application_response = await response.json()
const session_id = response.headers.get('session_id')
@ -46,7 +48,7 @@ exports.run = async (application, param, tmp_path) => {
if (response.status == 200) {
results = await response.json()
var meb_header = "SCENARIO;BUILDING NAME;TOTAL HEATING AREA;YEAR_OF_CONSTRUCTION;FUNTION"
var meb_header = 'SCENARIO;BUILDING NAME;TOTAL HEATING AREA;YEAR_OF_CONSTRUCTION;FUNTION'
meb_header = `${meb_header};YEARLY COOLING DEMAND;YEARLY HEATING DEMAND;MONTHLY COOLING DEMAND(JAN);MONTHLY COOLING DEMAND(FEB);MONTHLY COOLING DEMAND(MAR);MONTHLY COOLING DEMAND(APR);MONTHLY COOLING DEMAND(MAY);MONTHLY COOLING DEMAND(JUN);MONTHLY COOLING DEMAND(JUL);MONTHLY COOLING DEMAND(AUG);MONTHLY COOLING DEMAND(SEPT);MONTHLY COOLING DEMAND(OCT);MONTHLY COOLING DEMAND(NOV);MONTHLY COOLING DEMAND(DEC);MONTHLY HEATING DEMAND(JAN);MONTHLY HEATING DEMAND(FEB);MONTHLY HEATING DEMAND(MAR);MONTHLY HEATING DEMAND(APR);MONTHLY HEATING DEMAND(MAY);MONTHLY HEATING DEMAND(JUN);MONTHLY HEATING DEMAND(JUL);MONTHLY HEATING DEMAND(AUG);MONTHLY HEATING DEMAND(SEPT);MONTHLY HEATING DEMAND(OCT);MONTHLY HEATING DEMAND(NOV);MONTHLY HEATING DEMAND(DEC)`
meb_header = `${meb_header};YEARLY COOLING PEAK LOAD;YEARLY HEATING PEAK LOAD;MONTHLY COOLING PEAK LOAD (JAN);MONTHLY COOLING PEAK LOAD (FEB);MONTHLY COOLING PEAK LOAD (MAR);MONTHLY COOLING PEAK LOAD (APR);MONTHLY COOLING PEAK LOAD (MAY);MONTHLY COOLING PEAK LOAD (JUN);MONTHLY COOLING PEAK LOAD (JUL);MONTHLY COOLING PEAK LOAD (AUG);MONTHLY COOLING PEAK LOAD (SEPT);MONTHLY COOLING PEAK LOAD (OCT);MONTHLY COOLING PEAK LOAD (NOV);MONTHLY COOLING PEAK LOAD (DEC);MONTHLY HEATING PEAK LOAD (JAN);MONTHLY HEATING PEAK LOAD (FEB);MONTHLY HEATING PEAK LOAD (MAR);MONTHLY HEATING PEAK LOAD (APR);MONTHLY HEATING PEAK LOAD (MAY);MONTHLY HEATING PEAK LOAD (JUN);MONTHLY HEATING PEAK LOAD (JUL);MONTHLY HEATING PEAK LOAD (AUG);MONTHLY HEATING PEAK LOAD (SEPT);MONTHLY HEATING PEAK LOAD (OCT);MONTHLY HEATING PEAK LOAD (NOV);MONTHLY HEATING PEAK LOAD (DEC)`
meb_header = `${meb_header};YEARLY LIGHTING PEAK LOAD;MONTHLY LIGHTING PEAK LOAD(JAN);MONTHLY LIGHTING PEAK LOAD(FEB);MONTHLY LIGHTING PEAK LOAD(MAR);MONTHLY LIGHTING PEAK LOAD(APR);MONTHLY LIGHTING PEAK LOAD(MAY);MONTHLY LIGHTING PEAK LOAD(JUN);MONTHLY LIGHTING PEAK LOAD(JUL);MONTHLY LIGHTING PEAK LOAD(AUG);MONTHLY LIGHTING PEAK LOAD(SEPT);MONTHLY LIGHTING PEAK LOAD(OCT);MONTHLY LIGHTING PEAK LOAD(NOV);MONTHLY LIGHTING PEAK LOAD(DEC)`
@ -58,7 +60,7 @@ exports.run = async (application, param, tmp_path) => {
meb_header = `${meb_header};YEARLY DOMESTIC HOT WATER CONSUMPTION;YEARLY DOMESTIC HOT WATER HEAT DEMAND;MONTHLY DOMESTIC HOT WATER CONSUMPTION(JAN);MONTHLY DOMESTIC HOT WATER CONSUMPTION(FEB);MONTHLY DOMESTIC HOT WATER CONSUMPTION(MAR);MONTHLY DOMESTIC HOT WATER CONSUMPTION(APR);MONTHLY DOMESTIC HOT WATER CONSUMPTION(MAY);MONTHLY DOMESTIC HOT WATER CONSUMPTION(JUN);MONTHLY DOMESTIC HOT WATER CONSUMPTION(JUL);MONTHLY DOMESTIC HOT WATER CONSUMPTION(AUG);MONTHLY DOMESTIC HOT WATER CONSUMPTION(SEPT);MONTHLY DOMESTIC HOT WATER CONSUMPTION(OCT);MONTHLY DOMESTIC HOT WATER CONSUMPTION(NOV);MONTHLY DOMESTIC HOT WATER CONSUMPTION(DEC);MONTHLY DOMESTIC HOT WATER HEAT DEMAND(JAN);MONTHLY DOMESTIC HOT WATER HEAT DEMAND(FEB);MONTHLY DOMESTIC HOT WATER HEAT DEMAND(MAR);MONTHLY DOMESTIC HOT WATER HEAT DEMAND(APR);MONTHLY DOMESTIC HOT WATER HEAT DEMAND(MAY);MONTHLY DOMESTIC HOT WATER HEAT DEMAND(JUN);MONTHLY DOMESTIC HOT WATER HEAT DEMAND(JUL);MONTHLY DOMESTIC HOT WATER HEAT DEMAND(AUG);MONTHLY DOMESTIC HOT WATER HEAT DEMAND(SEPT);MONTHLY DOMESTIC HOT WATER HEAT DEMAND(OCT);MONTHLY DOMESTIC HOT WATER HEAT DEMAND(NOV);MONTHLY DOMESTIC HOT WATER HEAT DEMAND(DEC)`
meb_header = `${meb_header};YEARLY DISTRIBUTION SYSTEMS ELECTRICAL CONSUMPTION;MONTHLY DISTRIBUTION SYSTEMS ELECTRICAL CONSUMPTION(JAN);MONTHLY DISTRIBUTION SYSTEMS ELECTRICAL CONSUMPTION(FEB);MONTHLY DISTRIBUTION SYSTEMS ELECTRICAL CONSUMPTION(MAR);MONTHLY DISTRIBUTION SYSTEMS ELECTRICAL CONSUMPTION(APR);MONTHLY DISTRIBUTION SYSTEMS ELECTRICAL CONSUMPTION(MAY);MONTHLY DISTRIBUTION SYSTEMS ELECTRICAL CONSUMPTION(JUN);MONTHLY DISTRIBUTION SYSTEMS ELECTRICAL CONSUMPTION(JUL);MONTHLY DISTRIBUTION SYSTEMS ELECTRICAL CONSUMPTION(AUG);MONTHLY DISTRIBUTION SYSTEMS ELECTRICAL CONSUMPTION(SEPT);MONTHLY DISTRIBUTION SYSTEMS ELECTRICAL CONSUMPTION(OCT);MONTHLY DISTRIBUTION SYSTEMS ELECTRICAL CONSUMPTION(NOV);MONTHLY DISTRIBUTION SYSTEMS ELECTRICAL CONSUMPTION(DEC)`
var costs_header = "SCENARIO;BUILDING NAME;TOTAL HEATING AREA;YEAR_OF_CONSTRUCTION;FUNTION"
var costs_header = 'SCENARIO;BUILDING NAME;TOTAL HEATING AREA;YEAR_OF_CONSTRUCTION;FUNTION'
costs_header = `${costs_header};TOTAL CAPITAL COSTS SKIN;TOTAL CAPITAL COSTS SYSTEMS;END OF LIFE COSTS;TOTAL OPERATIONAL COSTS;TOTAL MAINTENANCE COSTS;OPERATIONAL INCOMES`
costs_header = `${costs_header};B2010 OPAQUE WALLS(1);B2010 OPAQUE WALLS(2);B2010 OPAQUE WALLS(3);B2010 OPAQUE WALLS(4);B2010 OPAQUE WALLS(5);B2010 OPAQUE WALLS(6);B2010 OPAQUE WALLS(7);B2010 OPAQUE WALLS(8);B2010 OPAQUE WALLS(9);B2010 OPAQUE WALLS(10);B2010 OPAQUE WALLS(11);B2010 OPAQUE WALLS(12);B2010 OPAQUE WALLS(13);B2010 OPAQUE WALLS(14);B2010 OPAQUE WALLS(15);B2010 OPAQUE WALLS(16);B2010 OPAQUE WALLS(17);B2010 OPAQUE WALLS(18);B2010 OPAQUE WALLS(19);B2010 OPAQUE WALLS(20);B2010 OPAQUE WALLS(21);B2010 OPAQUE WALLS(22);B2010 OPAQUE WALLS(23);B2010 OPAQUE WALLS(24);B2010 OPAQUE WALLS(25);B2010 OPAQUE WALLS(26);B2010 OPAQUE WALLS(27);B2010 OPAQUE WALLS(28);B2010 OPAQUE WALLS(29);B2010 OPAQUE WALLS(30);B2010 OPAQUE WALLS(31)`
costs_header = `${costs_header};B2020 TRANSPARENT(1);B2020 TRANSPARENT(2);B2020 TRANSPARENT(3);B2020 TRANSPARENT(4);B2020 TRANSPARENT(5);B2020 TRANSPARENT(6);B2020 TRANSPARENT(7);B2020 TRANSPARENT(8);B2020 TRANSPARENT(9);B2020 TRANSPARENT(10);B2020 TRANSPARENT(11);B2020 TRANSPARENT(12);B2020 TRANSPARENT(13);B2020 TRANSPARENT(14);B2020 TRANSPARENT(15);B2020 TRANSPARENT(16);B2020 TRANSPARENT(17);B2020 TRANSPARENT(18);B2020 TRANSPARENT(19);B2020 TRANSPARENT(20);B2020 TRANSPARENT(21);B2020 TRANSPARENT(22);B2020 TRANSPARENT(23);B2020 TRANSPARENT(24);B2020 TRANSPARENT(25);B2020 TRANSPARENT(26);B2020 TRANSPARENT(27);B2020 TRANSPARENT(28);B2020 TRANSPARENT(29);B2020 TRANSPARENT(30);B2020 TRANSPARENT(31)`
@ -83,7 +85,7 @@ exports.run = async (application, param, tmp_path) => {
costs_header = `${costs_header};SUBSIDIES HVAC(1);SUBSIDIES HVAC(2);SUBSIDIES HVAC(3);SUBSIDIES HVAC(4);SUBSIDIES HVAC(5);SUBSIDIES HVAC(6);SUBSIDIES HVAC(7);SUBSIDIES HVAC(8);SUBSIDIES HVAC(9);SUBSIDIES HVAC(10);SUBSIDIES HVAC(11);SUBSIDIES HVAC(12);SUBSIDIES HVAC(13);SUBSIDIES HVAC(14);SUBSIDIES HVAC(15);SUBSIDIES HVAC(16);SUBSIDIES HVAC(17);SUBSIDIES HVAC(18);SUBSIDIES HVAC(19);SUBSIDIES HVAC(20);SUBSIDIES HVAC(21);SUBSIDIES HVAC(22);SUBSIDIES HVAC(23);SUBSIDIES HVAC(24);SUBSIDIES HVAC(25);SUBSIDIES HVAC(26);SUBSIDIES HVAC(27);SUBSIDIES HVAC(28);SUBSIDIES HVAC(29);SUBSIDIES HVAC(30);SUBSIDIES HVAC(31)`
costs_header = `${costs_header};SUBSIDIES PV(1);SUBSIDIES PV(2);SUBSIDIES PV(3);SUBSIDIES PV(4);SUBSIDIES PV(5);SUBSIDIES PV(6);SUBSIDIES PV(7);SUBSIDIES PV(8);SUBSIDIES PV(9);SUBSIDIES PV(10);SUBSIDIES PV(11);SUBSIDIES PV(12);SUBSIDIES PV(13);SUBSIDIES PV(14);SUBSIDIES PV(15);SUBSIDIES PV(16);SUBSIDIES PV(17);SUBSIDIES PV(18);SUBSIDIES PV(19);SUBSIDIES PV(20);SUBSIDIES PV(21);SUBSIDIES PV(22);SUBSIDIES PV(23);SUBSIDIES PV(24);SUBSIDIES PV(25);SUBSIDIES PV(26);SUBSIDIES PV(27);SUBSIDIES PV(28);SUBSIDIES PV(29);SUBSIDIES PV(30);SUBSIDIES PV(31)`
var operational_co2_header = "SCENARIO;BUILDING NAME;TOTAL HEATING AREA;YEAR_OF_CONSTRUCTION;FUNTION"
var operational_co2_header = 'SCENARIO;BUILDING NAME;TOTAL HEATING AREA;YEAR_OF_CONSTRUCTION;FUNTION'
operational_co2_header = `${operational_co2_header};HEATING YEAR;HEATING MONTH(JAN);HEATING MONTH(FEB);HEATING MONTH(MAR);HEATING MONTH(APR);HEATING MONTH(MAY);HEATING MONTH(JUN);HEATING MONTH(JUL);HEATING MONTH(AUG);HEATING MONTH(SEPT);HEATING MONTH(OCT);HEATING MONTH(NOV);HEATING MONTH(DEC)`
operational_co2_header = `${operational_co2_header};DOMESTIC HOT WATER YEAR;DOMESTIC HOT WATER MONTH(JAN);DOMESTIC HOT WATER MONTH(FEB);DOMESTIC HOT WATER MONTH(MAR);DOMESTIC HOT WATER MONTH(APR);DOMESTIC HOT WATER MONTH(MAY);DOMESTIC HOT WATER MONTH(JUN);DOMESTIC HOT WATER MONTH(JUL);DOMESTIC HOT WATER MONTH(AUG);DOMESTIC HOT WATER MONTH(SEPT);DOMESTIC HOT WATER MONTH(OCT);DOMESTIC HOT WATER MONTH(NOV);DOMESTIC HOT WATER MONTH(DEC)`
operational_co2_header = `${operational_co2_header};COOLING YEAR;COOLING MONTH(JAN);COOLING MONTH(FEB);COOLING MONTH(MAR);COOLING MONTH(APR);COOLING MONTH(MAY);COOLING MONTH(JUN);COOLING MONTH(JUL);COOLING MONTH(AUG);COOLING MONTH(SEPT);COOLING MONTH(OCT);COOLING MONTH(NOV);COOLING MONTH(DEC)`
@ -171,17 +173,17 @@ exports.run = async (application, param, tmp_path) => {
operational_co2_lines.push(operational_co2)
})
}
require("fs").writeFile(
require('fs').writeFile(
`${tmp_path}/retrofit_meb.csv`,
`${meb_header}\n${meb_lines.join('\n')}`,
function (err) { console.log(err ? err : 'meb saved') }
)
require("fs").writeFile(
require('fs').writeFile(
`${tmp_path}/retrofit_cost.csv`,
`${costs_header}\n${cost_lines.join('\n')}`,
function (err) { console.log(err ? err : 'cost saved') }
)
require("fs").writeFile(
require('fs').writeFile(
`${tmp_path}/retrofit_operational_co2.csv`,
`${operational_co2_header}\n${operational_co2_lines.join('\n')}`,
function (err) { console.log(err ? err : 'operational_co2 saved') }

View File

@ -1,19 +1,20 @@
let param = {
document.getElementById('runWorkflow').addEventListener('click', runWorkflow)
async function runWorkflow() {
let param = {
'workflow': 'idf',
'application': '',
'building': []
}
document.getElementById("runWorkflow").addEventListener("click", runWorkflow)
async function runWorkflow() {
}
try {
document.getElementById('links').innerHTML = '<img id="spinner" src="../../img/spinner.gif" width="50px" />'
document.getElementById('building').style.backgroundColor = "#FFFFFF"
document.getElementById('building').style.backgroundColor = '#FFFFFF'
param['application'] = document.getElementById('application').value
let building = document.getElementById('building').value
if (building == "")
if (building == '')
{
document.getElementById('links').innerHTML = ''
document.getElementById('building').style.backgroundColor = "#FFAAAA"
document.getElementById('building').style.backgroundColor = '#FFAAAA'
return
}
param['building'] = building

View File

@ -1,3 +0,0 @@
APPLICATION_USERNAME=city_layers
APPLICATION_PASSWORD=city_layers
APPLICATION=36a065d9-bafb-4345-89fe-d68988ce9db2

View File

@ -1,3 +0,0 @@
APPLICATION_USERNAME=username
APPLICATION_PASSWORD=secret_pass
APPLICATION=apikey

View File

@ -1,5 +1,6 @@
const { dialog, BrowserWindow } = require('electron')
const BrowserWindow = require('electron')
const fs = require('fs')
const path = require('path')
const { Blob } = require('buffer')
const dotenv = require('dotenv')
const session_start = 'https://nextgenerations-cities.encs.concordia.ca/api/v1.4/session/start'
@ -8,10 +9,11 @@ const insel_meb = 'https://nextgenerations-cities.encs.concordia.ca/api/v1.4/wor
exports.run = async (application, param, tmp_path) => {
console.log(`Executing ${application}`)
dotenv.config({ path:__dirname+'/.env' })
const application_uuid = process.env.APPLICATION;
const username = process.env.APPLICATION_USERNAME;
const password = process.env.APPLICATION_PASSWORD;
env_path = path.resolve(`${__dirname}/../../../environments/workflow_launcher/.env`)
dotenv.config({ path: env_path })
const application_uuid = process.env.APPLICATION
const username = process.env.APPLICATION_USERNAME
const password = process.env.APPLICATION_PASSWORD
let response = await fetch(session_start, {
method: 'PUT',
headers: {
@ -49,7 +51,7 @@ exports.run = async (application, param, tmp_path) => {
var error = ''
if (response.status == 200) {
results = await response.json()
var meb_header = "BUILDING NAME;TOTAL HEATING AREA;YEAR_OF_CONSTRUCTION;FUNCTION"
var meb_header = 'BUILDING NAME;TOTAL HEATING AREA;YEAR_OF_CONSTRUCTION;FUNCTION'
meb_header = `${meb_header};YEARLY COOLING DEMAND;YEARLY HEATING DEMAND;MONTHLY COOLING DEMAND(JAN);MONTHLY COOLING DEMAND(FEB);MONTHLY COOLING DEMAND(MAR);MONTHLY COOLING DEMAND(APR);MONTHLY COOLING DEMAND(MAY);MONTHLY COOLING DEMAND(JUN);MONTHLY COOLING DEMAND(JUL);MONTHLY COOLING DEMAND(AUG);MONTHLY COOLING DEMAND(SEPT);MONTHLY COOLING DEMAND(OCT);MONTHLY COOLING DEMAND(NOV);MONTHLY COOLING DEMAND(DEC);MONTHLY HEATING DEMAND(JAN);MONTHLY HEATING DEMAND(FEB);MONTHLY HEATING DEMAND(MAR);MONTHLY HEATING DEMAND(APR);MONTHLY HEATING DEMAND(MAY);MONTHLY HEATING DEMAND(JUN);MONTHLY HEATING DEMAND(JUL);MONTHLY HEATING DEMAND(AUG);MONTHLY HEATING DEMAND(SEPT);MONTHLY HEATING DEMAND(OCT);MONTHLY HEATING DEMAND(NOV);MONTHLY HEATING DEMAND(DEC)`
meb_header = `${meb_header};YEARLY COOLING PEAK LOAD;YEARLY HEATING PEAK LOAD;MONTHLY COOLING PEAK LOAD (JAN);MONTHLY COOLING PEAK LOAD (FEB);MONTHLY COOLING PEAK LOAD (MAR);MONTHLY COOLING PEAK LOAD (APR);MONTHLY COOLING PEAK LOAD (MAY);MONTHLY COOLING PEAK LOAD (JUN);MONTHLY COOLING PEAK LOAD (JUL);MONTHLY COOLING PEAK LOAD (AUG);MONTHLY COOLING PEAK LOAD (SEPT);MONTHLY COOLING PEAK LOAD (OCT);MONTHLY COOLING PEAK LOAD (NOV);MONTHLY COOLING PEAK LOAD (DEC);MONTHLY HEATING PEAK LOAD (JAN);MONTHLY HEATING PEAK LOAD (FEB);MONTHLY HEATING PEAK LOAD (MAR);MONTHLY HEATING PEAK LOAD (APR);MONTHLY HEATING PEAK LOAD (MAY);MONTHLY HEATING PEAK LOAD (JUN);MONTHLY HEATING PEAK LOAD (JUL);MONTHLY HEATING PEAK LOAD (AUG);MONTHLY HEATING PEAK LOAD (SEPT);MONTHLY HEATING PEAK LOAD (OCT);MONTHLY HEATING PEAK LOAD (NOV);MONTHLY HEATING PEAK LOAD (DEC)`
meb_header = `${meb_header};YEARLY LIGHTING PEAK LOAD;MONTHLY LIGHTING PEAK LOAD(JAN);MONTHLY LIGHTING PEAK LOAD(FEB);MONTHLY LIGHTING PEAK LOAD(MAR);MONTHLY LIGHTING PEAK LOAD(APR);MONTHLY LIGHTING PEAK LOAD(MAY);MONTHLY LIGHTING PEAK LOAD(JUN);MONTHLY LIGHTING PEAK LOAD(JUL);MONTHLY LIGHTING PEAK LOAD(AUG);MONTHLY LIGHTING PEAK LOAD(SEPT);MONTHLY LIGHTING PEAK LOAD(OCT);MONTHLY LIGHTING PEAK LOAD(NOV);MONTHLY LIGHTING PEAK LOAD(DEC)`
@ -85,7 +87,7 @@ exports.run = async (application, param, tmp_path) => {
console.log(values)
meb_lines.push(meb)
}
require("fs").writeFile(
require('fs').writeFile(
`${tmp_path}/insel_meb.csv`,
`${meb_header}\n${meb_lines.join('\n')}`,
function (err) { console.log(err ? err : 'meb saved') }

View File

@ -2,8 +2,8 @@ let param = {
'workflow': 'meb',
'application': 'Insel MEB'
}
document.getElementById("runWorkflow").addEventListener("click", runWorkflow)
document.getElementById("geometry_file").addEventListener("change", (event) => {
document.getElementById('runWorkflow').addEventListener('click', runWorkflow)
document.getElementById('geometry_file').addEventListener('change', (event) => {
const file = event.target.files[0]
document.getElementById('parameters').style.visibility = 'visible'
let extension

View File

@ -25,7 +25,7 @@
<form id="form">
<div class="form-element">
<select name="application" id="application">
<option value="citylayers" selected>Montreal retrofit scenario (City-Layers)</option>
<option value="montreal_citylayers" selected>Montreal retrofit scenario (City-Layers)</option>
</select>
</div>
<div class="form-element">

View File

@ -1,3 +0,0 @@
APPLICATION_USERNAME=city_layers
APPLICATION_PASSWORD=city_layers
APPLICATION=36a065d9-bafb-4345-89fe-d68988ce9db2

View File

@ -1,3 +0,0 @@
APPLICATION_USERNAME=username
APPLICATION_PASSWORD=secret_pass
APPLICATION=apikey

View File

@ -1,4 +1,5 @@
const { dialog, BrowserWindow } = require ("electron");
const { BrowserWindow } = require('electron')
const path = require('path')
const dotenv = require('dotenv')
const session_start = 'https://nextgenerations-cities.encs.concordia.ca/api/v1.4/session/start'
const retrofit_results = 'https://nextgenerations-cities.encs.concordia.ca/api/v1.4/persistence/retrofit-results'
@ -6,10 +7,11 @@ const retrofit_results = 'https://nextgenerations-cities.encs.concordia.ca/api/v
exports.run = async (application, param, tmp_path) => {
buildings = param['buildings']
console.log(`Executing ${application}`)
dotenv.config({ path:__dirname+'/.env' })
const application_uuid = process.env.APPLICATION;
const username = process.env.APPLICATION_USERNAME;
const password = process.env.APPLICATION_PASSWORD;
env_path = path.resolve(`${__dirname}/../../../environments/${application}/.env`)
dotenv.config({ path: env_path })
const application_uuid = process.env.APPLICATION
const username = process.env.APPLICATION_USERNAME
const password = process.env.APPLICATION_PASSWORD
let response = await fetch(session_start, {
method: 'PUT',
headers: {
@ -19,7 +21,7 @@ exports.run = async (application, param, tmp_path) => {
'application-uuid': application_uuid,
'accept': 'application/json'
}
});
})
if (response.status == 200) {
const application_response = await response.json()
const session_id = response.headers.get('session_id')
@ -46,7 +48,7 @@ exports.run = async (application, param, tmp_path) => {
if (response.status == 200) {
results = await response.json()
var meb_header = "SCENARIO;BUILDING NAME;TOTAL HEATING AREA;YEAR_OF_CONSTRUCTION;FUNTION"
var meb_header = 'SCENARIO;BUILDING NAME;TOTAL HEATING AREA;YEAR_OF_CONSTRUCTION;FUNTION'
meb_header = `${meb_header};YEARLY COOLING DEMAND;YEARLY HEATING DEMAND;MONTHLY COOLING DEMAND(JAN);MONTHLY COOLING DEMAND(FEB);MONTHLY COOLING DEMAND(MAR);MONTHLY COOLING DEMAND(APR);MONTHLY COOLING DEMAND(MAY);MONTHLY COOLING DEMAND(JUN);MONTHLY COOLING DEMAND(JUL);MONTHLY COOLING DEMAND(AUG);MONTHLY COOLING DEMAND(SEPT);MONTHLY COOLING DEMAND(OCT);MONTHLY COOLING DEMAND(NOV);MONTHLY COOLING DEMAND(DEC);MONTHLY HEATING DEMAND(JAN);MONTHLY HEATING DEMAND(FEB);MONTHLY HEATING DEMAND(MAR);MONTHLY HEATING DEMAND(APR);MONTHLY HEATING DEMAND(MAY);MONTHLY HEATING DEMAND(JUN);MONTHLY HEATING DEMAND(JUL);MONTHLY HEATING DEMAND(AUG);MONTHLY HEATING DEMAND(SEPT);MONTHLY HEATING DEMAND(OCT);MONTHLY HEATING DEMAND(NOV);MONTHLY HEATING DEMAND(DEC)`
meb_header = `${meb_header};YEARLY COOLING PEAK LOAD;YEARLY HEATING PEAK LOAD;MONTHLY COOLING PEAK LOAD (JAN);MONTHLY COOLING PEAK LOAD (FEB);MONTHLY COOLING PEAK LOAD (MAR);MONTHLY COOLING PEAK LOAD (APR);MONTHLY COOLING PEAK LOAD (MAY);MONTHLY COOLING PEAK LOAD (JUN);MONTHLY COOLING PEAK LOAD (JUL);MONTHLY COOLING PEAK LOAD (AUG);MONTHLY COOLING PEAK LOAD (SEPT);MONTHLY COOLING PEAK LOAD (OCT);MONTHLY COOLING PEAK LOAD (NOV);MONTHLY COOLING PEAK LOAD (DEC);MONTHLY HEATING PEAK LOAD (JAN);MONTHLY HEATING PEAK LOAD (FEB);MONTHLY HEATING PEAK LOAD (MAR);MONTHLY HEATING PEAK LOAD (APR);MONTHLY HEATING PEAK LOAD (MAY);MONTHLY HEATING PEAK LOAD (JUN);MONTHLY HEATING PEAK LOAD (JUL);MONTHLY HEATING PEAK LOAD (AUG);MONTHLY HEATING PEAK LOAD (SEPT);MONTHLY HEATING PEAK LOAD (OCT);MONTHLY HEATING PEAK LOAD (NOV);MONTHLY HEATING PEAK LOAD (DEC)`
meb_header = `${meb_header};YEARLY LIGHTING PEAK LOAD;MONTHLY LIGHTING PEAK LOAD(JAN);MONTHLY LIGHTING PEAK LOAD(FEB);MONTHLY LIGHTING PEAK LOAD(MAR);MONTHLY LIGHTING PEAK LOAD(APR);MONTHLY LIGHTING PEAK LOAD(MAY);MONTHLY LIGHTING PEAK LOAD(JUN);MONTHLY LIGHTING PEAK LOAD(JUL);MONTHLY LIGHTING PEAK LOAD(AUG);MONTHLY LIGHTING PEAK LOAD(SEPT);MONTHLY LIGHTING PEAK LOAD(OCT);MONTHLY LIGHTING PEAK LOAD(NOV);MONTHLY LIGHTING PEAK LOAD(DEC)`
@ -58,7 +60,7 @@ exports.run = async (application, param, tmp_path) => {
meb_header = `${meb_header};YEARLY DOMESTIC HOT WATER CONSUMPTION;YEARLY DOMESTIC HOT WATER HEAT DEMAND;MONTHLY DOMESTIC HOT WATER CONSUMPTION(JAN);MONTHLY DOMESTIC HOT WATER CONSUMPTION(FEB);MONTHLY DOMESTIC HOT WATER CONSUMPTION(MAR);MONTHLY DOMESTIC HOT WATER CONSUMPTION(APR);MONTHLY DOMESTIC HOT WATER CONSUMPTION(MAY);MONTHLY DOMESTIC HOT WATER CONSUMPTION(JUN);MONTHLY DOMESTIC HOT WATER CONSUMPTION(JUL);MONTHLY DOMESTIC HOT WATER CONSUMPTION(AUG);MONTHLY DOMESTIC HOT WATER CONSUMPTION(SEPT);MONTHLY DOMESTIC HOT WATER CONSUMPTION(OCT);MONTHLY DOMESTIC HOT WATER CONSUMPTION(NOV);MONTHLY DOMESTIC HOT WATER CONSUMPTION(DEC);MONTHLY DOMESTIC HOT WATER HEAT DEMAND(JAN);MONTHLY DOMESTIC HOT WATER HEAT DEMAND(FEB);MONTHLY DOMESTIC HOT WATER HEAT DEMAND(MAR);MONTHLY DOMESTIC HOT WATER HEAT DEMAND(APR);MONTHLY DOMESTIC HOT WATER HEAT DEMAND(MAY);MONTHLY DOMESTIC HOT WATER HEAT DEMAND(JUN);MONTHLY DOMESTIC HOT WATER HEAT DEMAND(JUL);MONTHLY DOMESTIC HOT WATER HEAT DEMAND(AUG);MONTHLY DOMESTIC HOT WATER HEAT DEMAND(SEPT);MONTHLY DOMESTIC HOT WATER HEAT DEMAND(OCT);MONTHLY DOMESTIC HOT WATER HEAT DEMAND(NOV);MONTHLY DOMESTIC HOT WATER HEAT DEMAND(DEC)`
meb_header = `${meb_header};YEARLY DISTRIBUTION SYSTEMS ELECTRICAL CONSUMPTION;MONTHLY DISTRIBUTION SYSTEMS ELECTRICAL CONSUMPTION(JAN);MONTHLY DISTRIBUTION SYSTEMS ELECTRICAL CONSUMPTION(FEB);MONTHLY DISTRIBUTION SYSTEMS ELECTRICAL CONSUMPTION(MAR);MONTHLY DISTRIBUTION SYSTEMS ELECTRICAL CONSUMPTION(APR);MONTHLY DISTRIBUTION SYSTEMS ELECTRICAL CONSUMPTION(MAY);MONTHLY DISTRIBUTION SYSTEMS ELECTRICAL CONSUMPTION(JUN);MONTHLY DISTRIBUTION SYSTEMS ELECTRICAL CONSUMPTION(JUL);MONTHLY DISTRIBUTION SYSTEMS ELECTRICAL CONSUMPTION(AUG);MONTHLY DISTRIBUTION SYSTEMS ELECTRICAL CONSUMPTION(SEPT);MONTHLY DISTRIBUTION SYSTEMS ELECTRICAL CONSUMPTION(OCT);MONTHLY DISTRIBUTION SYSTEMS ELECTRICAL CONSUMPTION(NOV);MONTHLY DISTRIBUTION SYSTEMS ELECTRICAL CONSUMPTION(DEC)`
var costs_header = "SCENARIO;BUILDING NAME;TOTAL HEATING AREA;YEAR_OF_CONSTRUCTION;FUNTION"
var costs_header = 'SCENARIO;BUILDING NAME;TOTAL HEATING AREA;YEAR_OF_CONSTRUCTION;FUNTION'
costs_header = `${costs_header};TOTAL CAPITAL COSTS SKIN;TOTAL CAPITAL COSTS SYSTEMS;END OF LIFE COSTS;TOTAL OPERATIONAL COSTS;TOTAL MAINTENANCE COSTS;OPERATIONAL INCOMES`
costs_header = `${costs_header};B2010 OPAQUE WALLS(1);B2010 OPAQUE WALLS(2);B2010 OPAQUE WALLS(3);B2010 OPAQUE WALLS(4);B2010 OPAQUE WALLS(5);B2010 OPAQUE WALLS(6);B2010 OPAQUE WALLS(7);B2010 OPAQUE WALLS(8);B2010 OPAQUE WALLS(9);B2010 OPAQUE WALLS(10);B2010 OPAQUE WALLS(11);B2010 OPAQUE WALLS(12);B2010 OPAQUE WALLS(13);B2010 OPAQUE WALLS(14);B2010 OPAQUE WALLS(15);B2010 OPAQUE WALLS(16);B2010 OPAQUE WALLS(17);B2010 OPAQUE WALLS(18);B2010 OPAQUE WALLS(19);B2010 OPAQUE WALLS(20);B2010 OPAQUE WALLS(21);B2010 OPAQUE WALLS(22);B2010 OPAQUE WALLS(23);B2010 OPAQUE WALLS(24);B2010 OPAQUE WALLS(25);B2010 OPAQUE WALLS(26);B2010 OPAQUE WALLS(27);B2010 OPAQUE WALLS(28);B2010 OPAQUE WALLS(29);B2010 OPAQUE WALLS(30);B2010 OPAQUE WALLS(31)`
costs_header = `${costs_header};B2020 TRANSPARENT(1);B2020 TRANSPARENT(2);B2020 TRANSPARENT(3);B2020 TRANSPARENT(4);B2020 TRANSPARENT(5);B2020 TRANSPARENT(6);B2020 TRANSPARENT(7);B2020 TRANSPARENT(8);B2020 TRANSPARENT(9);B2020 TRANSPARENT(10);B2020 TRANSPARENT(11);B2020 TRANSPARENT(12);B2020 TRANSPARENT(13);B2020 TRANSPARENT(14);B2020 TRANSPARENT(15);B2020 TRANSPARENT(16);B2020 TRANSPARENT(17);B2020 TRANSPARENT(18);B2020 TRANSPARENT(19);B2020 TRANSPARENT(20);B2020 TRANSPARENT(21);B2020 TRANSPARENT(22);B2020 TRANSPARENT(23);B2020 TRANSPARENT(24);B2020 TRANSPARENT(25);B2020 TRANSPARENT(26);B2020 TRANSPARENT(27);B2020 TRANSPARENT(28);B2020 TRANSPARENT(29);B2020 TRANSPARENT(30);B2020 TRANSPARENT(31)`
@ -83,7 +85,7 @@ exports.run = async (application, param, tmp_path) => {
costs_header = `${costs_header};SUBSIDIES HVAC(1);SUBSIDIES HVAC(2);SUBSIDIES HVAC(3);SUBSIDIES HVAC(4);SUBSIDIES HVAC(5);SUBSIDIES HVAC(6);SUBSIDIES HVAC(7);SUBSIDIES HVAC(8);SUBSIDIES HVAC(9);SUBSIDIES HVAC(10);SUBSIDIES HVAC(11);SUBSIDIES HVAC(12);SUBSIDIES HVAC(13);SUBSIDIES HVAC(14);SUBSIDIES HVAC(15);SUBSIDIES HVAC(16);SUBSIDIES HVAC(17);SUBSIDIES HVAC(18);SUBSIDIES HVAC(19);SUBSIDIES HVAC(20);SUBSIDIES HVAC(21);SUBSIDIES HVAC(22);SUBSIDIES HVAC(23);SUBSIDIES HVAC(24);SUBSIDIES HVAC(25);SUBSIDIES HVAC(26);SUBSIDIES HVAC(27);SUBSIDIES HVAC(28);SUBSIDIES HVAC(29);SUBSIDIES HVAC(30);SUBSIDIES HVAC(31)`
costs_header = `${costs_header};SUBSIDIES PV(1);SUBSIDIES PV(2);SUBSIDIES PV(3);SUBSIDIES PV(4);SUBSIDIES PV(5);SUBSIDIES PV(6);SUBSIDIES PV(7);SUBSIDIES PV(8);SUBSIDIES PV(9);SUBSIDIES PV(10);SUBSIDIES PV(11);SUBSIDIES PV(12);SUBSIDIES PV(13);SUBSIDIES PV(14);SUBSIDIES PV(15);SUBSIDIES PV(16);SUBSIDIES PV(17);SUBSIDIES PV(18);SUBSIDIES PV(19);SUBSIDIES PV(20);SUBSIDIES PV(21);SUBSIDIES PV(22);SUBSIDIES PV(23);SUBSIDIES PV(24);SUBSIDIES PV(25);SUBSIDIES PV(26);SUBSIDIES PV(27);SUBSIDIES PV(28);SUBSIDIES PV(29);SUBSIDIES PV(30);SUBSIDIES PV(31)`
var operational_co2_header = "SCENARIO;BUILDING NAME;TOTAL HEATING AREA;YEAR_OF_CONSTRUCTION;FUNTION"
var operational_co2_header = 'SCENARIO;BUILDING NAME;TOTAL HEATING AREA;YEAR_OF_CONSTRUCTION;FUNTION'
operational_co2_header = `${operational_co2_header};HEATING YEAR;HEATING MONTH(JAN);HEATING MONTH(FEB);HEATING MONTH(MAR);HEATING MONTH(APR);HEATING MONTH(MAY);HEATING MONTH(JUN);HEATING MONTH(JUL);HEATING MONTH(AUG);HEATING MONTH(SEPT);HEATING MONTH(OCT);HEATING MONTH(NOV);HEATING MONTH(DEC)`
operational_co2_header = `${operational_co2_header};DOMESTIC HOT WATER YEAR;DOMESTIC HOT WATER MONTH(JAN);DOMESTIC HOT WATER MONTH(FEB);DOMESTIC HOT WATER MONTH(MAR);DOMESTIC HOT WATER MONTH(APR);DOMESTIC HOT WATER MONTH(MAY);DOMESTIC HOT WATER MONTH(JUN);DOMESTIC HOT WATER MONTH(JUL);DOMESTIC HOT WATER MONTH(AUG);DOMESTIC HOT WATER MONTH(SEPT);DOMESTIC HOT WATER MONTH(OCT);DOMESTIC HOT WATER MONTH(NOV);DOMESTIC HOT WATER MONTH(DEC)`
operational_co2_header = `${operational_co2_header};COOLING YEAR;COOLING MONTH(JAN);COOLING MONTH(FEB);COOLING MONTH(MAR);COOLING MONTH(APR);COOLING MONTH(MAY);COOLING MONTH(JUN);COOLING MONTH(JUL);COOLING MONTH(AUG);COOLING MONTH(SEPT);COOLING MONTH(OCT);COOLING MONTH(NOV);COOLING MONTH(DEC)`
@ -171,17 +173,17 @@ exports.run = async (application, param, tmp_path) => {
operational_co2_lines.push(operational_co2)
})
}
require("fs").writeFile(
require('fs').writeFile(
`${tmp_path}/retrofit_meb.csv`,
`${meb_header}\n${meb_lines.join('\n')}`,
function (err) { console.log(err ? err : 'meb saved') }
)
require("fs").writeFile(
require('fs').writeFile(
`${tmp_path}/retrofit_cost.csv`,
`${costs_header}\n${cost_lines.join('\n')}`,
function (err) { console.log(err ? err : 'cost saved') }
)
require("fs").writeFile(
require('fs').writeFile(
`${tmp_path}/retrofit_operational_co2.csv`,
`${operational_co2_header}\n${operational_co2_lines.join('\n')}`,
function (err) { console.log(err ? err : 'operational_co2 saved') }

View File

@ -3,17 +3,17 @@ let param = {
'application': '',
'buildings': []
}
document.getElementById("runWorkflow").addEventListener("click", runWorkflow)
document.getElementById('runWorkflow').addEventListener('click', runWorkflow)
async function runWorkflow() {
try {
document.getElementById('links').innerHTML = '<img id="spinner" src="../../img/spinner.gif" width="50px" />'
document.getElementById('buildings').style.backgroundColor = "#FFFFFF"
document.getElementById('buildings').style.backgroundColor = '#FFFFFF'
param['application'] = document.getElementById('application').value
let buildingsString = document.getElementById('buildings').value
if (buildingsString == "")
if (buildingsString == '')
{
document.getElementById('links').innerHTML = ''
document.getElementById('buildings').style.backgroundColor = "#FFAAAA"
document.getElementById('buildings').style.backgroundColor = '#FFAAAA'
return
}
buildings = buildingsString.replace('\r', '').replace('\n', '').replace('\t', '').split(';').map(e => e.trim())