Browse Source

emon: default indexed methods to method without argument

mcspr-patch-1
Maxim Prokhorov 4 years ago
committed by Max Prokhorov
parent
commit
31641aeffa
2 changed files with 50 additions and 19 deletions
  1. +5
    -5
      code/espurna/sensor.cpp
  2. +45
    -14
      code/espurna/sensors/BaseEmonSensor.h

+ 5
- 5
code/espurna/sensor.cpp View File

@ -1858,19 +1858,19 @@ void _sensorInit() {
for (size_t index = 0; index < sensor->countDevices(); ++index) { for (size_t index = 0; index < sensor->countDevices(); ++index) {
sensor->resetEnergy(index, _sensorEnergyTotal(index)); sensor->resetEnergy(index, _sensorEnergyTotal(index));
sensor->setCurrentRatio( sensor->setCurrentRatio(
get_ratio("pwrRatioC", index, sensor->getCurrentRatio(index))
index, get_ratio("pwrRatioC", index, sensor->getCurrentRatio(index))
); );
sensor->setVoltageRatio( sensor->setVoltageRatio(
get_ratio("pwrRatioV", index, sensor->getVoltageRatio(index))
index, get_ratio("pwrRatioV", index, sensor->getVoltageRatio(index))
); );
sensor->setPowerRatio( sensor->setPowerRatio(
get_ratio("pwrRatioP", index, sensor->getPowerRatio(index))
index, get_ratio("pwrRatioP", index, sensor->getPowerRatio(index))
); );
sensor->setEnergyRatio( sensor->setEnergyRatio(
get_ratio("pwrRatioE", index, sensor->getEnergyRatio(index))
index, get_ratio("pwrRatioE", index, sensor->getEnergyRatio(index))
); );
sensor->setVoltage( sensor->setVoltage(
get_ratio("pwrVoltage", index, sensor->getVoltage(index))
index, get_ratio("pwrVoltage", index, sensor->getVoltage(index))
); );
} }


+ 45
- 14
code/espurna/sensors/BaseEmonSensor.h View File

@ -70,8 +70,15 @@ class BaseEmonSensor : public BaseSensor {
// when sensor needs explicit mains voltage value // when sensor needs explicit mains voltage value
virtual void setVoltage(double) {} virtual void setVoltage(double) {}
virtual double getVoltage() { return 0.0; }
virtual double getVoltage(unsigned char index) { return getVoltage(); }
virtual void setVoltage(unsigned char index, double value) {
setVoltage(value);
}
virtual double getVoltage() {
return 0.0;
}
virtual double getVoltage(unsigned char index) {
return getVoltage();
}
// when sensor implements ratios / multipliers // when sensor implements ratios / multipliers
virtual void setCurrentRatio(double) {} virtual void setCurrentRatio(double) {}
@ -80,22 +87,46 @@ class BaseEmonSensor : public BaseSensor {
virtual void setEnergyRatio(double) {} virtual void setEnergyRatio(double) {}
// when sensor implements ratios / multipliers // when sensor implements ratios / multipliers
virtual void setCurrentRatio(unsigned char index, double) {}
virtual void setVoltageRatio(unsigned char index, double) {}
virtual void setPowerRatio(unsigned char index, double) {}
virtual void setEnergyRatio(unsigned char index, double) {}
virtual void setCurrentRatio(unsigned char index, double value) {
setCurrentRatio(value);
}
virtual void setVoltageRatio(unsigned char index, double value) {
setVoltageRatio(value);
}
virtual void setPowerRatio(unsigned char index, double value) {
setPowerRatio(value);
}
virtual void setEnergyRatio(unsigned char index, double value) {
setEnergyRatio(value);
}
// when sensor implements a single device // when sensor implements a single device
virtual double getCurrentRatio() { return 0.0; }
virtual double getVoltageRatio() { return 0.0; }
virtual double getPowerRatio() { return 0.0; }
virtual double getEnergyRatio() { return 0.0; }
virtual double getCurrentRatio() {
return 0.0;
}
virtual double getVoltageRatio() {
return 0.0;
}
virtual double getPowerRatio() {
return 0.0;
}
virtual double getEnergyRatio() {
return 0.0;
}
// when sensor implements more than one device // when sensor implements more than one device
virtual double getCurrentRatio(unsigned char index) { return getCurrentRatio(); }
virtual double getVoltageRatio(unsigned char index) { return getCurrentRatio(); }
virtual double getPowerRatio(unsigned char index) { return getCurrentRatio(); }
virtual double getEnergyRatio(unsigned char index) { return getCurrentRatio(); }
virtual double getCurrentRatio(unsigned char index) {
return getCurrentRatio();
}
virtual double getVoltageRatio(unsigned char index) {
return getVoltageRatio();
}
virtual double getPowerRatio(unsigned char index) {
return getPowerRatio();
}
virtual double getEnergyRatio(unsigned char index) {
return getEnergyRatio();
}
virtual void expectedCurrent(double value) {} virtual void expectedCurrent(double value) {}
virtual void expectedVoltage(unsigned int value) {} virtual void expectedVoltage(unsigned int value) {}


Loading…
Cancel
Save