Added power factor register
This commit is contained in:
@@ -18,6 +18,7 @@ namespace drivers
|
||||
info.pAct = getPact();
|
||||
info.pApp = getPapp();
|
||||
info.pRea = getPrea();
|
||||
info.pf = getPf();
|
||||
info.f = getF();
|
||||
info.whTot = getWhTot();
|
||||
info.whPar = getWhPar();
|
||||
@@ -44,6 +45,10 @@ namespace drivers
|
||||
{
|
||||
return readFloatReg(REG_Prea);
|
||||
}
|
||||
const float_t S50140::getPf()
|
||||
{
|
||||
return readFloatReg(REG_Pf);
|
||||
}
|
||||
const float_t S50140::getF()
|
||||
{
|
||||
return readFloatReg(REG_Freq);
|
||||
@@ -61,8 +66,8 @@ namespace drivers
|
||||
{
|
||||
auto now = millis();
|
||||
if ((now - m_lastRequest) < minDelay)
|
||||
{ // minimum 500ms between requests
|
||||
delay(now - m_lastRequest);
|
||||
{ // minimum m_lastRequest between requests
|
||||
vTaskDelay(pdMS_TO_TICKS(now - m_lastRequest));
|
||||
}
|
||||
m_lastRequest = now;
|
||||
}
|
||||
@@ -90,21 +95,22 @@ namespace drivers
|
||||
void S50140::resetPartialCounters()
|
||||
{
|
||||
uint8_t retries(0);
|
||||
const uint16_t resetAll = 0x0A03;
|
||||
const uint16_t stopAll = 0x0A02;
|
||||
const uint16_t startAll = 0x0A01;
|
||||
constexpr uint16_t nullVal = 0x0000;
|
||||
constexpr uint16_t resetAll = 0x0A03;
|
||||
constexpr uint16_t stopAll = 0x0A02;
|
||||
constexpr uint16_t startAll = 0x0A01;
|
||||
while (retries++ < maxRetries)
|
||||
{
|
||||
bool ok(true);
|
||||
delayRequest();
|
||||
LOG_WARN("Powermeter Counter STOP");
|
||||
ok &= m_bus.writeRegisters(m_address, REG_PartCount, {0x0000, stopAll});
|
||||
ok &= m_bus.writeRegisters(m_address, REG_PartCount, {nullVal, stopAll});
|
||||
delayRequest();
|
||||
LOG_WARN("Powermeter Counter RESET");
|
||||
ok &= m_bus.writeRegisters(m_address, REG_PartCount, {0x0000, resetAll});
|
||||
ok &= m_bus.writeRegisters(m_address, REG_PartCount, {nullVal, resetAll});
|
||||
delayRequest();
|
||||
LOG_WARN("Powermeter Counter START");
|
||||
ok &= m_bus.writeRegisters(m_address, REG_PartCount, {0x0000, startAll});
|
||||
ok &= m_bus.writeRegisters(m_address, REG_PartCount, {nullVal, startAll});
|
||||
if (ok)
|
||||
return;
|
||||
LOG_ERROR("Unable to Reset Powermeter Partial Counters, device", m_address);
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace drivers
|
||||
const uint16_t REG_Papp = 0x102E;
|
||||
const uint16_t REG_Prea = 0x1036;
|
||||
const uint16_t REG_Freq = 0x1038;
|
||||
const uint16_t REG_Pf = 0x101E;
|
||||
const uint16_t REG_WhTot = 0x1106;
|
||||
const uint16_t REG_WhPart = 0x1400;
|
||||
const uint16_t REG_Serial = 0x0500;
|
||||
@@ -45,6 +46,7 @@ namespace drivers
|
||||
float_t pAct;
|
||||
float_t pApp;
|
||||
float_t pRea;
|
||||
float_t pf;
|
||||
float_t f;
|
||||
float_t whTot;
|
||||
float_t whPar;
|
||||
@@ -61,6 +63,7 @@ namespace drivers
|
||||
const float_t getPact();
|
||||
const float_t getPapp();
|
||||
const float_t getPrea();
|
||||
const float_t getPf();
|
||||
const float_t getF();
|
||||
const float_t getWhTot();
|
||||
const float_t getWhPar();
|
||||
|
||||
Reference in New Issue
Block a user