-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconvert.js
124 lines (111 loc) · 4.36 KB
/
convert.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
if (window.location.search=="?load=heatlossjs") {
setTimeout(function(){
var data_str = localStorage.getItem("heatlossjs");
if (data_str) {
var heatlossjsdata = JSON.parse(localStorage.getItem("heatlossjs"));
localStorage.removeItem('heatlossjs');
convert_heatlossjs_to_sapjs(heatlossjsdata,function(sap){
app.data = Object.assign(app.data,sap)
app.update()
});
}
},100);
}
function convert_heatlossjs_to_sapjs(heatlossjsdata,callback) {
$.getJSON( "openBEM/blank.json?v=2", function( result ) {
var sap = result;
sap.fabric.library = {}
for (var name in heatlossjsdata.element_type) {
if (name.toLowerCase().includes("loft")) {
sap.fabric.library[name] = {
type: "loft",
uvalue: heatlossjsdata.element_type[name].uvalue,
kvalue: 50
}
}
else if (name.toLowerCase().includes("floor")) {
sap.fabric.library[name] = {
type: "floor",
uvalue: heatlossjsdata.element_type[name].uvalue,
kvalue: 110
}
}
else if (name.toLowerCase().includes("wall")) {
sap.fabric.library[name] = {
type: "wall",
uvalue: heatlossjsdata.element_type[name].uvalue,
kvalue: 150
}
}
else if (name.toLowerCase().includes("glazing") || name.toLowerCase().includes("window") || name.toLowerCase().includes("door")) {
sap.fabric.library[name] = {
type: "window",
uvalue: heatlossjsdata.element_type[name].uvalue,
kvalue: 0,
g: 0.76,
gL: 0.8,
ff: 0.7
}
}
else {
sap.fabric.library[name] = {
type: "wall",
uvalue: heatlossjsdata.element_type[name].uvalue,
kvalue: 150
}
}
}
var id = 1;
var total_floor_area = 0;
var total_volume = 0;
for (var room in heatlossjsdata.rooms) {
for (var elementIndex in heatlossjsdata.rooms[room].elements) {
var element = heatlossjsdata.rooms[room].elements[elementIndex];
var room_ucfirst = room && room[0].toUpperCase() + room.slice(1);
if (element.boundary=="external" || element.boundary=="ground" || element.boundary=="unheated") {
sap.fabric.elements.push({
"id": room_ucfirst+" "+element.orientation+" e"+elementIndex,
"lib": element.type,
"l": element.width,
"h": element.height
});
}
id ++;
}
total_floor_area += heatlossjsdata.rooms[room].area;
total_volume += heatlossjsdata.rooms[room].volume;
}
sap.floors = [
{
"name": "Combined floor",
"area": total_floor_area,
"height": 1*(total_volume / total_floor_area).toFixed(2)
}
];
// Populate a default heating system
sap.heating_systems = [
{
"name": "Heat pump",
"provides": "heating_and_water",
"instantaneous_water_heating": false,
"main_space_heating_system": "mainHS1",
"fraction_water_heating": 1,
"fraction_space": 1,
"summer_efficiency": 350,
"winter_efficiency": 400,
"fuel": "Electricity",
"responsiveness": 1,
"heating_controls": 2,
"temperature_adjustment": 0,
"primary_circuit_loss": true,
"central_heating_pump": 0,
"central_heating_pump_inside": true,
"warm_air_system": false,
"fans_and_supply_pumps": 0,
"sfp": 0,
"combi_loss": 0
}
];
callback(sap);
});
}