mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-01-12 00:02:53 +00:00
Adjustments during testing
This commit is contained in:
parent
433b602fb7
commit
768cbf22c9
@ -113,7 +113,7 @@ uint8_t PriceService::getResolutionInMinutes() {
|
||||
}
|
||||
|
||||
uint8_t PriceService::getNumberOfPointsAvailable() {
|
||||
if(today == NULL) return getResolutionInMinutes() == 15 ? 96 : 24;
|
||||
if(today == NULL) return getResolutionInMinutes() == 15 ? 192 : 48;
|
||||
if(tomorrow != NULL) return today->getNumberOfPoints() + tomorrow->getNumberOfPoints();
|
||||
return today->getNumberOfPoints();
|
||||
}
|
||||
@ -163,8 +163,6 @@ float PriceService::getPricePoint(uint8_t direction, uint8_t point) {
|
||||
}
|
||||
|
||||
float PriceService::getCurrentPrice(uint8_t direction) {
|
||||
if(today == NULL) return PRICE_NO_VALUE;
|
||||
|
||||
time_t ts = time(nullptr);
|
||||
tmElements_t tm;
|
||||
breakTime(tz->toLocal(ts), tm);
|
||||
|
||||
12
lib/SvelteUi/app/dist/index.js
vendored
12
lib/SvelteUi/app/dist/index.js
vendored
File diff suppressed because one or more lines are too long
@ -32,98 +32,102 @@
|
||||
});
|
||||
|
||||
$: {
|
||||
let currency = json.currency;
|
||||
let val = 0;
|
||||
let yTicks = [];
|
||||
let xTicks = [];
|
||||
let values = [];
|
||||
min = max = 0;
|
||||
let i = Math.floor(((cur.getHours()*60) + cur.getMinutes()) / json?.resolution);
|
||||
cur.setMinutes(Math.floor(cur.getMinutes()/json.resolution)*json.resolution,0,0);
|
||||
while(json?.hasOwnProperty(zeropad(i))) {
|
||||
val = json[zeropad(i++)];
|
||||
if(val == null) break;
|
||||
xTicks.push({
|
||||
label: values.length > 1 && json.resolution < 60 && cur.getMinutes() != 0 ? '' : zeropad(cur.getHours())
|
||||
});
|
||||
values.push(val*100);
|
||||
min = Math.min(min, val*100);
|
||||
max = Math.max(max, val*100);
|
||||
addMinutes(cur, json.resolution);
|
||||
}
|
||||
|
||||
let ret = formatCurrency(Math.max(Math.abs(min) / 100.0, Math.abs(max) / 100.0), currency);
|
||||
if(ret && ret[1] && ret[1] != currency) {
|
||||
currency = ret[1];
|
||||
min *= 100;
|
||||
max *= 100;
|
||||
for(i = 0; i < values.length; i++) {
|
||||
values[i] *= 100;
|
||||
if(json?.prices?.length > 0) {
|
||||
let currency = json?.currency;
|
||||
let val = 0;
|
||||
let yTicks = [];
|
||||
let xTicks = [];
|
||||
let values = [];
|
||||
min = max = 0;
|
||||
let i = Math.floor(((cur.getHours()*60) + cur.getMinutes()) / json?.resolution);
|
||||
cur.setMinutes(Math.floor(cur.getMinutes()/json?.resolution)*json?.resolution,0,0);
|
||||
while(i++ < json?.prices?.length) {
|
||||
val = json.prices[i];
|
||||
if(val == null) break;
|
||||
xTicks.push({
|
||||
label: values.length > 1 && json?.resolution < 60 && cur.getMinutes() != 0 ? '' : zeropad(cur.getHours())
|
||||
});
|
||||
values.push(val*100);
|
||||
min = Math.min(min, val*100);
|
||||
max = Math.max(max, val*100);
|
||||
addMinutes(cur, json?.resolution);
|
||||
}
|
||||
}
|
||||
|
||||
let points = [];
|
||||
for(i = 0; i < values.length; i++) {
|
||||
val = values[i];
|
||||
let disp = val * 0.01;
|
||||
let d = Math.abs(val) < 1000 ? 2 : 0;
|
||||
points.push({
|
||||
label: disp >= 0 ? disp.toFixed(d) : '',
|
||||
title: disp >= 0 ? disp.toFixed(2) + ' ' + currency : '',
|
||||
value: val >= 0 ? Math.abs(val) : 0,
|
||||
label2: disp < 0 ? disp.toFixed(d) : '',
|
||||
title2: disp < 0 ? disp.toFixed(2) + ' ' + currency : '',
|
||||
value2: val < 0 ? Math.abs(val) : 0,
|
||||
color: dark ? '#5c2da5' : '#7c3aed'
|
||||
});
|
||||
}
|
||||
let range = Math.max(max, Math.abs(min));
|
||||
let ret = formatCurrency(Math.max(Math.abs(min) / 100.0, Math.abs(max) / 100.0), currency);
|
||||
if(ret && ret[1] && ret[1] != currency) {
|
||||
currency = ret[1];
|
||||
min *= 100;
|
||||
max *= 100;
|
||||
for(i = 0; i < values.length; i++) {
|
||||
values[i] *= 100;
|
||||
}
|
||||
}
|
||||
|
||||
if(min < 0) {
|
||||
min = Math.min((range/4)*-1, min);
|
||||
let yTicksNum = Math.ceil((Math.abs(min)/range) * 4);
|
||||
let yTickDistDown = min/yTicksNum;
|
||||
for(i = 1; i < yTicksNum+1; i++) {
|
||||
let val = (yTickDistDown*i);
|
||||
let points = [];
|
||||
for(i = 0; i < values.length; i++) {
|
||||
val = values[i];
|
||||
let disp = val * 0.01;
|
||||
let d = Math.abs(val) < 1000 ? 2 : 0;
|
||||
points.push({
|
||||
label: disp >= 0 ? disp.toFixed(d) : '',
|
||||
title: disp >= 0 ? disp.toFixed(2) + ' ' + currency : '',
|
||||
value: val >= 0 ? Math.abs(val) : 0,
|
||||
label2: disp < 0 ? disp.toFixed(d) : '',
|
||||
title2: disp < 0 ? disp.toFixed(2) + ' ' + currency : '',
|
||||
value2: val < 0 ? Math.abs(val) : 0,
|
||||
color: dark ? '#5c2da5' : '#7c3aed'
|
||||
});
|
||||
}
|
||||
let range = Math.max(max, Math.abs(min));
|
||||
|
||||
if(min < 0) {
|
||||
min = Math.min((range/4)*-1, min);
|
||||
let yTicksNum = Math.ceil((Math.abs(min)/range) * 4);
|
||||
let yTickDistDown = min/yTicksNum;
|
||||
for(i = 1; i < yTicksNum+1; i++) {
|
||||
let val = (yTickDistDown*i);
|
||||
yTicks.push({
|
||||
value: val,
|
||||
label: (val/100).toFixed(2)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
max = Math.max((range/4), max);
|
||||
let xTicksNum = Math.ceil((max/range) * 4);
|
||||
let yTickDistUp = max/xTicksNum;
|
||||
for(i = 0; i < xTicksNum+1; i++) {
|
||||
let val = (yTickDistUp*i);
|
||||
yTicks.push({
|
||||
value: val,
|
||||
label: (val/100).toFixed(2)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
max = Math.max((range/4), max);
|
||||
let xTicksNum = Math.ceil((max/range) * 4);
|
||||
let yTickDistUp = max/xTicksNum;
|
||||
for(i = 0; i < xTicksNum+1; i++) {
|
||||
let val = (yTickDistUp*i);
|
||||
yTicks.push({
|
||||
value: val,
|
||||
label: (val/100).toFixed(2)
|
||||
});
|
||||
config = {
|
||||
title: title + " (" + currency + ")",
|
||||
dark: document.documentElement.classList.contains('dark'),
|
||||
padding: { top: 20, right: 15, bottom: 20, left: 35 },
|
||||
y: {
|
||||
min: min,
|
||||
max: max,
|
||||
ticks: yTicks
|
||||
},
|
||||
x: {
|
||||
ticks: xTicks
|
||||
},
|
||||
points: points,
|
||||
link: {
|
||||
text: "Provided by: " + getPriceSourceName(json.source),
|
||||
url: getPriceSourceUrl(json.source),
|
||||
target: '_blank'
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
config = {
|
||||
title: title + " (" + currency + ")",
|
||||
dark: document.documentElement.classList.contains('dark'),
|
||||
padding: { top: 20, right: 15, bottom: 20, left: 35 },
|
||||
y: {
|
||||
min: min,
|
||||
max: max,
|
||||
ticks: yTicks
|
||||
},
|
||||
x: {
|
||||
ticks: xTicks
|
||||
},
|
||||
points: points,
|
||||
link: {
|
||||
text: "Provided by: " + getPriceSourceName(json.source),
|
||||
url: getPriceSourceUrl(json.source),
|
||||
target: '_blank'
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<BarChart config={config} />
|
||||
{#if config.points && config.points.length > 0}
|
||||
<BarChart config={config} />
|
||||
{/if}
|
||||
@ -41,12 +41,6 @@
|
||||
min = 0;
|
||||
max = 0;
|
||||
|
||||
/*
|
||||
console.log("\n--Realtime plot debug--")
|
||||
console.log("Data length: %d\nSize: %d", realtime?.data?.length, realtime?.size);
|
||||
console.log("Height: %d\nWidth: %d\nBar width: %s", heightAvailable, widthAvailable, barWidth);
|
||||
*/
|
||||
|
||||
if(realtime.data && heightAvailable > 10 && widthAvailable > 100 && barWidth > 0.1) {
|
||||
visible = true;
|
||||
for(let p in realtime.data) {
|
||||
@ -90,9 +84,6 @@
|
||||
} else {
|
||||
visible = false;
|
||||
}
|
||||
/*
|
||||
console.log("Min: %d\nMax: %d\nShow: %s", min, max, visible);
|
||||
*/
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@ -25,8 +25,6 @@
|
||||
label: 0
|
||||
});
|
||||
|
||||
console.log(realtime);
|
||||
|
||||
if(tariffData && !isNaN(realtime?.h?.u)) {
|
||||
points.push({
|
||||
label: realtime.h.u.toFixed(2),
|
||||
|
||||
@ -776,7 +776,7 @@ void AmsWebServer::priceJson(uint8_t direction) {
|
||||
prices[i] = ps->getPricePoint(direction, i);
|
||||
}
|
||||
|
||||
snprintf_P(buf, BufferSize, PSTR("{\"currency\":\"%s\",\"source\":\"%s\",\"resolution\":%d,\"direction\":\"%s\",\"importExportPriceDifferent\":%s"),
|
||||
snprintf_P(buf, BufferSize, PSTR("{\"currency\":\"%s\",\"source\":\"%s\",\"resolution\":%d,\"direction\":\"%s\",\"importExportPriceDifferent\":%s,\"prices\":["),
|
||||
ps->getCurrency(),
|
||||
ps->getSource(),
|
||||
ps->getResolutionInMinutes(),
|
||||
@ -794,14 +794,14 @@ void AmsWebServer::priceJson(uint8_t direction) {
|
||||
|
||||
for(uint8_t i = 0;i < numberOfPoints; i++) {
|
||||
if(prices[i] == PRICE_NO_VALUE) {
|
||||
snprintf_P(buf, BufferSize, PSTR(",\"%02d\":null"), i);
|
||||
snprintf_P(buf, BufferSize, PSTR("%snull"), i == 0 ? "" : ",");
|
||||
server.sendContent(buf);
|
||||
} else {
|
||||
snprintf_P(buf, BufferSize, PSTR(",\"%02d\":%.4f"), i, prices[i]);
|
||||
snprintf_P(buf, BufferSize, PSTR("%s%.4f"), i == 0 ? "" : ",", prices[i]);
|
||||
server.sendContent(buf);
|
||||
}
|
||||
}
|
||||
server.sendContent_P(PSTR("}"));
|
||||
server.sendContent_P(PSTR("]}"));
|
||||
}
|
||||
|
||||
void AmsWebServer::temperatureJson() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user