Merge branch 'master' into dev-v2.1.0

This commit is contained in:
Gunnar Skjold
2022-02-12 10:16:27 +01:00
26 changed files with 92 additions and 97 deletions

View File

@@ -313,16 +313,13 @@ IEC6205675::IEC6205675(const char* d, uint8_t useMeterType, uint8_t distribution
if(l3PowerFactor != 0)
l3PowerFactor /= 100;
int adiv = 1;
int watt = abs((l1voltage * l1current) + (l2voltage * l2current) + (l3voltage * l3current));
while(watt / (activeImportPower + activeExportPower + reactiveImportPower + reactiveExportPower) > 2) {
adiv *= 10;
watt /= 10;
if(watt / (activeImportPower + activeExportPower + reactiveImportPower + reactiveExportPower) > 2) {
l1current = l1current != 0 ? l1current / 10 : 0;
l2current = l2current != 0 ? l2current / 10 : 0;
l3current = l3current != 0 ? l3current / 10 : 0;
}
l1current = l1current != 0 ? l1current / adiv : 0;
l2current = l2current != 0 ? l2current / adiv : 0;
l3current = l3current != 0 ? l3current / adiv : 0;
} else if(meterType == AmsTypeSagemcom) {
CosemData* meterTs = getCosemDataAt(1, ((char *) (d)));
if(meterTs != NULL) {
@@ -359,7 +356,7 @@ IEC6205675::IEC6205675(const char* d, uint8_t useMeterType, uint8_t distribution
if(l2current == 0.0 && l1current > 0.0 && l3current > 0.0) {
l2current = (((activeImportPower - activeExportPower) * sqrt(3)) - (l1voltage * l1current) - (l3voltage * l3current)) / l2voltage;
if(activeExportPower == 0.0) {
l2current = max((double) 0.0, l2current);
l2current = max((float) 0.0, l2current);
}
}
} else if(twoPhase && l1current > 0.0 && l2current > 0.0 && l3current > 0.0) {
@@ -401,6 +398,7 @@ CosemData* IEC6205675::getCosemDataAt(uint8_t index, const char* ptr) {
pos += 2;
}
i++;
if(pos-ptr > 900) break;
} while(item->base.type != HDLC_FLAG);
return NULL;
}
@@ -444,6 +442,7 @@ CosemData* IEC6205675::findObis(uint8_t* obis, int matchlength, const char* ptr)
default:
pos += 2;
}
if(pos-ptr > 900) break;
} while(item->base.type != HDLC_FLAG);
return NULL;
}