Added seneca powermeter driver
This commit is contained in:
72
lib/SENECA/S50140_Driver.h
Normal file
72
lib/SENECA/S50140_Driver.h
Normal file
@@ -0,0 +1,72 @@
|
||||
#pragma once
|
||||
|
||||
#include <DebugLog.h>
|
||||
#include <RS485_Driver.h>
|
||||
|
||||
namespace drivers
|
||||
{
|
||||
|
||||
class S50140
|
||||
{
|
||||
private:
|
||||
const uint8_t maxRetries = 5;
|
||||
const uint8_t dataWords = 2;
|
||||
const uint16_t REG_V = 0x100C;
|
||||
const uint16_t REG_A = 0x1016;
|
||||
const uint16_t REG_Pact = 0x1026;
|
||||
const uint16_t REG_Papp = 0x102E;
|
||||
const uint16_t REG_Prea = 0x1036;
|
||||
const uint16_t REG_Freq = 0x1036;
|
||||
const uint16_t REG_WhTot = 0x1106;
|
||||
const uint16_t REG_WhPart = 0x1400;
|
||||
const uint16_t REG_Serial = 0x0500;
|
||||
const uint16_t REG_Regset = 0x0538;
|
||||
const uint16_t REG_TotCount = 0x0516;
|
||||
const uint16_t REG_PartCount = 0x0517;
|
||||
|
||||
typedef union
|
||||
{
|
||||
float_t f;
|
||||
uint16_t hi;
|
||||
uint16_t lo;
|
||||
} floatval_t;
|
||||
|
||||
public:
|
||||
typedef struct
|
||||
{
|
||||
float_t v;
|
||||
float_t a;
|
||||
float_t pAct;
|
||||
float_t pApp;
|
||||
float_t pRea;
|
||||
float_t f;
|
||||
float_t whTot;
|
||||
float_t whPar;
|
||||
} powerinfo_t;
|
||||
|
||||
public:
|
||||
S50140(drivers::MODBUS &bus, const uint8_t address);
|
||||
~S50140();
|
||||
|
||||
const powerinfo_t getAll();
|
||||
|
||||
const float_t getV();
|
||||
const float_t getA();
|
||||
const float_t getPact();
|
||||
const float_t getPapp();
|
||||
const float_t getPrea();
|
||||
const float_t getF();
|
||||
const float_t getWhTot();
|
||||
const float_t getWhPar();
|
||||
|
||||
void resetTotalCounters();
|
||||
void resetPartialCounters();
|
||||
|
||||
private:
|
||||
float_t readFloatReg(const uint16_t reg);
|
||||
|
||||
private:
|
||||
const uint8_t m_address;
|
||||
drivers::MODBUS &m_bus;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user