Indicator for estimated I2. Also fix on charts

This commit is contained in:
Gunnar Skjold
2023-12-04 11:59:18 +01:00
parent ddd08e25df
commit a30cd76354
11 changed files with 40 additions and 25 deletions

View File

@@ -68,6 +68,7 @@ public:
bool isThreePhase();
bool isTwoPhase();
bool isL2currentEstimated();
int8_t getLastError();
void setLastError(int8_t);
@@ -85,7 +86,7 @@ protected:
float l1activeExportPower = 0, l2activeExportPower = 0, l3activeExportPower = 0;
float powerFactor = 0, l1PowerFactor = 0, l2PowerFactor = 0, l3PowerFactor = 0;
double activeImportCounter = 0, reactiveImportCounter = 0, activeExportCounter = 0, reactiveExportCounter = 0;
bool threePhase = false, twoPhase = false, counterEstimated = false;
bool threePhase = false, twoPhase = false, counterEstimated = false, l2currentEstimated = false;
int8_t lastError = 0x00;
uint8_t lastErrorCount = 0;

View File

@@ -67,6 +67,7 @@ void AmsData::apply(AmsData& other) {
this->reactiveExportPower = other.getReactiveExportPower();
this->l1current = other.getL1Current();
this->l2current = other.getL2Current();
this->l2currentEstimated = other.isL2currentEstimated();
this->l3current = other.getL3Current();
this->l1voltage = other.getL1Voltage();
this->l2voltage = other.getL2Voltage();
@@ -218,6 +219,10 @@ bool AmsData::isTwoPhase() {
return this->twoPhase;
}
bool AmsData::isL2currentEstimated() {
return this->l2currentEstimated;
}
int8_t AmsData::getLastError() {
return lastErrorCount > 2 ? lastError : 0;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -7,17 +7,18 @@
export let u3;
export let i1;
export let i2;
export let i2e;
export let i3;
export let max;
let config = {};
function point(v) {
function point(v,e) {
return {
label: fmtnum(v) + 'A',
title: v.toFixed(1) + ' A',
title: (e ? 'Estimated ' : '') + v.toFixed(1) + ' A',
value: isNaN(v) ? 0 : v,
color: ampcol(v ? (v)/(max)*100 : 0)
color: ampcol(v ? (v)/(max)*100 : 0, e)
};
};
@@ -30,7 +31,7 @@
}
if(u2 > 0) {
xTicks.push({ label: 'L2' });
points.push(point(i2));
points.push(point(i2, i2e));
}
if(u3 > 0) {
xTicks.push({ label: 'L3' });

View File

@@ -9,9 +9,10 @@
let heightAvailable;
let labelOffset;
let vertSwitch = 30;
let titleHeight = 0;
$: {
heightAvailable = height-(config.title ? 20 : 0);
heightAvailable = height-titleHeight;
let innerWidth = width - (config.padding.left + config.padding.right);
barWidth = innerWidth / config.points.length;
labelOffset = barWidth < vertSwitch ? 30 : 15;
@@ -36,7 +37,7 @@
<div class="chart" bind:clientWidth={width} bind:clientHeight={height}>
{#if config.x.ticks && config.points && heightAvailable}
{#if config.title}
<strong class="text-sm">{config.title}</strong>
<div class="text-sm font-bold" bind:clientHeight={titleHeight}>{config.title}</div>
{/if}
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 {width} {heightAvailable}">
<!-- y axis -->

View File

@@ -62,7 +62,7 @@
{/if}
{#if uiVisibility(sysinfo.ui.a, data.i1 > 0.01 || data.i2 > 0.01 || data.i3 > 0.01)}
<div class="cnt">
<AmpPlot u1={data.u1} u2={data.u2} u3={data.u3} i1={data.i1} i2={data.i2} i3={data.i3} max={data.mf ? data.mf : 32}/>
<AmpPlot u1={data.u1} u2={data.u2} u3={data.u3} i1={data.i1} i2={data.i2} i2e={data.i2e} i3={data.i3} max={data.mf ? data.mf : 32}/>
</div>
{/if}
{#if uiVisibility(sysinfo.ui.r, data.ri > 0 || data.re > 0 || data.ric > 0 || data.rec > 0)}

View File

@@ -11,12 +11,15 @@ export function voltcol(volt) {
return '#d90000';
};
export function ampcol(pct) {
if(pct > 90) return '#d90000';
else if(pct > 85) return'#e32100';
else if(pct > 80) return '#ffb800';
else if(pct > 75) return '#dcd800';
else return '#32d900';
export function ampcol(pct, est) {
let col;
if(pct > 90) col = '#d90000';
else if(pct > 85) col = '#e32100';
else if(pct > 80) col = '#ffb800';
else if(pct > 75) col = '#dcd800';
else col = '#32d900';
return col+(est?'88':'');
};
export function exportcol(pct) {

View File

@@ -15,6 +15,7 @@
"u3" : %.2f,
"i1" : %.2f,
"i2" : %.2f,
"i2e" : %s,
"i3" : %.2f,
"f" : %.2f,
"f1" : %.2f,

View File

@@ -464,6 +464,7 @@ void AmsWebServer::dataJson() {
meterState->getL3Voltage(),
meterState->getL1Current(),
meterState->getL2Current(),
meterState->isL2currentEstimated() ? "true" : "false",
meterState->getL3Current(),
meterState->getPowerFactor(),
meterState->getL1PowerFactor(),

View File

@@ -102,6 +102,7 @@ IEC6205675::IEC6205675(const char* d, uint8_t useMeterType, MeterConfig* meterCo
l2voltage = sqrt(pow(l1voltage - l3voltage * cos(60 * (PI/180)), 2) + pow(l3voltage * sin(60 * (PI/180)),2));
if(l2voltage > 0) {
l2current = (((activeImportPower - activeExportPower) * sqrt(3)) - (l1voltage * l1current) - (l3voltage * l3current)) / l2voltage;
l2currentEstimated = true;
}
}
@@ -493,6 +494,7 @@ IEC6205675::IEC6205675(const char* d, uint8_t useMeterType, MeterConfig* meterCo
if(activeExportPower == 0.0) {
l2current = max((float) 0.0, l2current);
}
l2currentEstimated = true;
}
} else if(twoPhase && l1current > 0.0 && l2current > 0.0 && l3current > 0.0) {
l2voltage = sqrt(pow(l1voltage - l3voltage * cos(60.0 * (PI/180.0)), 2) + pow(l3voltage * sin(60.0 * (PI/180.0)),2));