66class ElectricityMeter :
public ElementWithChannelActions,
67 public ActionHandler {
71 virtual void updateChannelValues();
74 void setFwdActEnergy(
int phase,
unsigned _supla_int64_t energy);
77 void setRvrActEnergy(
int phase,
unsigned _supla_int64_t energy);
80 void setFwdReactEnergy(
int phase,
unsigned _supla_int64_t energy);
83 void setRvrReactEnergy(
int phase,
unsigned _supla_int64_t energy);
87 void setFwdBalancedEnergy(uint64_t energy);
91 void setRvrBalancedEnergy(uint64_t energy);
94 void setVoltage(
int phase,
unsigned _supla_int16_t voltage);
97 void setCurrent(
int phase,
unsigned _supla_int_t current);
100 void setFreq(
unsigned _supla_int16_t freq);
103 void setPowerActive(
int phase, int64_t power);
106 void setPowerReactive(
int phase, int64_t power);
109 void setPowerApparent(
int phase, int64_t power);
112 void setPowerFactor(
int phase, _supla_int_t powerFactor);
115 void setPhaseAngle(
int phase, _supla_int_t phaseAngle);
118 void setVoltagePhaseAngle12(
unsigned _supla_int16_t voltagePhaseAngle);
121 void setVoltagePhaseAngle13(
unsigned _supla_int16_t voltagePhaseAngle);
124 void setVoltagePhaseSequence(
bool clockwise);
127 void setCurrentPhaseSequence(
bool clockwise);
142 unsigned _supla_int64_t getFwdActEnergy(
int phase);
145 unsigned _supla_int64_t getRvrActEnergy(
int phase);
148 uint64_t getFwdBalancedActEnergy();
151 uint64_t getRvrBalancedActEnergy();
154 unsigned _supla_int64_t getFwdReactEnergy(
int phase);
157 unsigned _supla_int64_t getRvrReactEnergy(
int phase);
160 unsigned _supla_int16_t getVoltage(
int phase);
163 unsigned _supla_int_t getCurrent(
int phase);
166 unsigned _supla_int16_t getFreq();
169 int64_t getPowerActive(
int phase);
172 int64_t getPowerReactive(
int phase);
175 int64_t getPowerApparent(
int phase);
178 _supla_int_t getPowerFactor(
int phase);
181 _supla_int_t getPhaseAngle(
int phase);
184 uint16_t getVoltagePhaseAngle12()
const;
187 uint16_t getVoltagePhaseAngle13()
const;
190 bool isVoltagePhaseSequenceSet()
const;
193 bool isVoltagePhaseSequenceClockwise()
const;
196 bool isCurrentPhaseSequenceSet()
const;
199 bool isCurrentPhaseSequenceClockwise()
const;
202 static unsigned _supla_int64_t
207 static unsigned _supla_int64_t
215 static unsigned _supla_int64_t
220 static unsigned _supla_int64_t
228 static unsigned _supla_int64_t
233 static unsigned _supla_int64_t
238 static unsigned _supla_int16_t
242 static unsigned _supla_int_t
246 static unsigned _supla_int16_t
250 static int64_t getPowerActive(
254 static int64_t getPowerReactive(
258 static int64_t getPowerApparent(
262 static _supla_int_t getPowerFactor(
266 static _supla_int_t getPhaseAngle(
270 static uint16_t getVoltagePhaseAngle12(
274 static uint16_t getVoltagePhaseAngle13(
278 static bool isVoltagePhaseSequenceSet(
282 static bool isVoltagePhaseSequenceClockwise(
286 static bool isCurrentPhaseSequenceSet(
290 static bool isCurrentPhaseSequenceClockwise(
293 static bool isVoltagePhaseAngle12Used(
296 static bool isVoltagePhaseAngle13Used(
299 static bool isFwdActEnergyUsed(
302 static bool isRvrActEnergyUsed(
305 static bool isFwdReactEnergyUsed(
308 static bool isRvrReactEnergyUsed(
311 static bool isFwdBalancedActEnergyUsed(
314 static bool isRvrBalancedActEnergyUsed(
317 static bool isVoltageUsed(
320 static bool isCurrentUsed(
323 static bool isFreqUsed(
326 static bool isPowerActiveUsed(
329 static bool isPowerReactiveUsed(
332 static bool isPowerApparentUsed(
335 static bool isPowerFactorUsed(
338 static bool isPhaseAngleUsed(
341 void resetReadParameters();
342 void resetReadParametersForPhase(
int phase);
347 virtual void readValuesFromDevice();
352 void fillChannelConfig(
void *channelConfig,
int *size)
override;
366 virtual void resetStorage();
373 void handleAction(
int event,
int action)
override;
375 void setRefreshRate(
unsigned int sec);
377 Channel *getChannel()
override;
378 const Channel *getChannel()
const override;
381 void enableChannelConfig();
382 void addCtType(uint64_t ctType);
383 void addPhaseLedType(uint64_t ledType);
384 bool isCtTypeSupported(uint64_t ctType)
const;
386 int8_t getPhaseLedType()
const;
387 int32_t getLedVoltageLow()
const;
388 int32_t getLedVoltageHigh()
const;
389 int32_t getLedPowerLow()
const;
390 int32_t getLedPowerHigh()
const;
391 bool isPhaseLedTypeSupported(uint64_t ledType)
const;
395 ChannelExtended extChannel;
396 uint32_t lastChannelUpdateTime = 0;
397 uint32_t rawCurrent[MAX_PHASES] = {};
398 int64_t rawActivePower[MAX_PHASES] = {};
399 int64_t rawReactivePower[MAX_PHASES] = {};
400 int64_t rawApparentPower[MAX_PHASES] = {};
402 uint32_t lastReadTime = 0;
403 uint16_t refreshRateSec = 5;
404 bool valueChanged =
false;
405 bool currentMeasurementAvailable =
false;
406 bool powerActiveMeasurementAvailable =
false;
407 bool powerReactiveMeasurementAvailable =
false;
408 bool powerApparentMeasurementAvailable =
false;
410 uint64_t availableCtTypes = 0;
411 uint64_t availablePhaseLedTypes = 0;
412 bool channelConfigUsed =
false;
413 int8_t usedCtType = -1;
415 int8_t usedPhaseLedType = -1;
417 int32_t ledVoltageLow = 21000;
418 int32_t ledVoltageHigh = 25000;
419 int32_t ledPowerLow = -5000;
420 int32_t ledPowerHigh = 5000;