var strify = require('javascript-stringify');
onMessage('chartCOP', (httpParams, callback) => {
const myJsonParams = (httpParams.myjsonparams ? JSON.parse(httpParams.myjsonparams) : {} );
console.log(`httpParams = ${JSON.stringify(httpParams)}`);
console.log(`myJsonParams = ${JSON.stringify(myJsonParams)}`);
chartCOP(result => callback(result));
});
function chartCOP(callback) {
const numVLact=getState("alias.0.1000_Heizung.WP.VLTemperatur").val;
const numATact=getState("alias.0.1000_Heizung.Klima.AussenTemperatur").val;
const numCOPact=getState("0_userdata.0.1000_Heizung.WP.COP").val;
const VLmin=30;
const VLmax=65;
const ATmin=-10;
const ATmax=20;
const option = {
"tooltip": {
"show": false,
"formatter": function (param) {
return (
"AT: " + param.value[0].toFixed(1) + "°C<br>" +
"VL: " + param.value[1].toFixed(1) + "°C<br>" +
"COP: " + param.value[2].toFixed(2)
);
}
},
"visualMap": {
"show": false,
"dimension": 2,
"seriesIndex": 0,
"min": 1,
"max": 6,
"inRange": {
"color": [
"rgba(139, 0, 0, 0.9)", // Dunkelrot – niedriger COP
"rgba(255, 69, 0, 0.85)", // Orange-Rot
"rgba(255, 205, 0, 0.8)", // Gelb
"rgba(0, 255, 127, 0.75)", // Hellgrün
"rgba(64, 224, 208, 0.75)", // Türkis / Mittelblau
"rgba(30, 144, 255, 0.8)", // Kräftiges Blau
"rgba(0, 0, 200, 0.85)" // Tiefblau – hoher COP
]
},
"text": ["COP hoch", "COP niedrig"],
"calculable": true
},
"xAxis3D": { "type": "value", "name": "AT (°C)", "min": ATmin, "max": ATmax, "interval": 5 },
"yAxis3D": { "type": "value", "name": "VL (°C)", "min": VLmin, "max": VLmax, "interval": 5 },
"zAxis3D": { "type": "value", "name": "COP", "min": 0, "max": 8, "interval": 1 },
"grid3D": {
"boxWidth": 100,
"boxDepth": 60,
"boxHeight": 45,
"environment": "auto",
"viewControl": {
"alpha": 30,
"beta": 225,
"distance": 150,
"minBeta": -360,
"maxBeta": 360,
"autoRotate": false,
"center": [
0,
-12,
0
]
},
"light": {
"main": {
"intensity": 1.4,
"shadow": true,
"alpha": 30,
"beta": 120
},
"ambient": {
"intensity": 0.5
}
}
},
"series": [
{
"type": "surface",
"name": "statisches COP Netz",
"wireframe": { "show": false },
"shading": "realistic",
"itemStyle": {
"color": "rgba(0,150,255,0.4)",
"opacity": 0.8
},
"realisticMaterial": {
"roughness": 0.1,
"metalness": 0
},
"data": (function() {
const data = [];
for (let AT = ATmin; AT <= ATmax; AT += 1) {
for (let VL = VLmin; VL <= VLmax; VL += 1) {
const COP = 6.65 - 3.8 * Math.exp(-0.165 * (AT + 10)) +
0.00015 * VL * VL - 0.035 * VL;
if (COP > 1) {
data.push([AT, VL, COP]);
}
}
}
return data;
})()
},
{
"type": "line3D",
"name": "VL = aktuelle Temperatur",
"lineStyle": { "width": 3, "color": "rgba(255,69,0,0.9)" },
"data": (function() {
const arrLine1 = [];
let VL = numVLact;
for (let AT = ATmin; AT <= ATmax; AT += 1) {
const COP = 6.65 - 3.8 * Math.exp(-0.165 * (AT + 10)) +
0.00015 * VL * VL - 0.035 * VL;
arrLine1.push([AT, VL, COP]);
}
return arrLine1;
})()
},
{
"type": "line3D",
"name": "AT = aktuelle Temperatur",
"lineStyle": { "width": 3, "color": "rgba(255,69,0,0.9)" },
"data": (function() {
const arrLine2 = [];
for (let VL = VLmin; VL <= VLmax; VL += 1) {
const COP = 6.65 - 3.8 * Math.exp(-0.165 * (numATact + 10)) +
0.00015 * VL * VL - 0.035 * VL;
arrLine2.push([numATact, VL, COP]);
}
return arrLine2;
})()
},
{
type: "line3D",
name: "COP = 4.3 Kontur",
lineStyle: { color: "rgba(139, 0, 0, 0.7)", width: 2 },
data: (function () {
const arrcop = [];
for (let AT = ATmin; AT <= ATmax; AT += 0.05) {
for (let VL = VLmin; VL <= VLmax; VL += 0.05) {
const cop = 6.65 - 3.8 * Math.exp(-0.165 * (AT + 10))
+ 0.00015 * VL * VL - 0.035 * VL;
if (Math.abs(cop - 4.3) < 0.05) {
arrcop.push([AT, VL, cop]);
}
}
}
return arrcop;
})()
},
{
"type": "scatter3D",
"name": "real",
//"symbol": "pin",
"visualMap": false,
"symbolSize": 20,
"animation": true,
"animationDuration": 800,
"animationEasing": "cubicOut",
"itemStyle": { "color": "rgba(0, 0, 200, 0.95)" },
"data": (function() {
return [[numATact, numVLact, numCOPact]];
})()
},
{
"type": "scatter3D",
"name": "Projektion CHA",
"symbolSize": 6,
"visualMap": false,
"itemStyle": { "color": "rgba(0, 0, 200, 0.95)" },
"data": [
[ATmax, VLmax, numCOPact]
]
},
{
"type": "scatter3D",
"name": "Betriebspunkt",
//"symbol": "pin",
"visualMap": false,
"symbolSize": 10,
"animation": true,
"animationDuration": 800,
"animationEasing": "cubicOut",
"itemStyle": { "color": "rgba(255,69,0,0.9)" },
"data": (function() {
const COPaktuell = 6.65 - 3.8 * Math.exp(-0.165 * (numATact + 10)) +
0.00015 * numVLact * numVLact - 0.035 * numVLact;
return [[numATact, numVLact, COPaktuell]];
})()
},
{
"type": "scatter3D",
"name": "Projektion auf AT-Ebene",
"symbolSize": 6,
"visualMap": false,
"itemStyle": { "color": "rgba(255,69,0,0.9)" },
"data": [
[ATmin, numVLact, 0]
]
},
{
"type": "scatter3D",
"name": "Projektion auf VL-Ebene",
"symbolSize": 6,
"visualMap": false,
"itemStyle": { "color": "rgba(255,69,0,0.9)" },
"data": [
[ATmax, VLmax, (6.65 - 3.8 * Math.exp(-0.165 * (numATact + 10)) +
0.00015 * numVLact * numVLact - 0.035 * numVLact)]
]
},
{
"type": "scatter3D",
"name": "Projektion auf COP-Basis",
"symbolSize": 6,
"visualMap": false,
"itemStyle": { "color": "rgba(255,69,0,0.9)" },
"data": [
[numATact, VLmax, 0]
]
}
]
};
callback(strify.stringify(option));
};