Set MaxChannel Power on startup and in webapi
This commit is contained in:
parent
10974ade3e
commit
746aa087ac
@ -136,8 +136,14 @@ uint8_t InverterAbstract::getChannelCount()
|
|||||||
|
|
||||||
uint16_t InverterAbstract::getChannelMaxPower(uint8_t channel)
|
uint16_t InverterAbstract::getChannelMaxPower(uint8_t channel)
|
||||||
{
|
{
|
||||||
// todo;
|
return _chanMaxPower[channel];
|
||||||
return 0;
|
}
|
||||||
|
|
||||||
|
void InverterAbstract::setChannelMaxPower(uint8_t channel, uint16_t power)
|
||||||
|
{
|
||||||
|
if (channel < CH4) {
|
||||||
|
_chanMaxPower[channel] = power;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t InverterAbstract::getAssignIdxByChannelField(uint8_t channel, uint8_t fieldId)
|
uint8_t InverterAbstract::getAssignIdxByChannelField(uint8_t channel, uint8_t fieldId)
|
||||||
|
|||||||
@ -99,6 +99,7 @@ public:
|
|||||||
virtual const uint8_t getAssignmentCount() = 0;
|
virtual const uint8_t getAssignmentCount() = 0;
|
||||||
uint8_t getChannelCount();
|
uint8_t getChannelCount();
|
||||||
uint16_t getChannelMaxPower(uint8_t channel);
|
uint16_t getChannelMaxPower(uint8_t channel);
|
||||||
|
void setChannelMaxPower(uint8_t channel, uint16_t power);
|
||||||
|
|
||||||
void clearRxFragmentBuffer();
|
void clearRxFragmentBuffer();
|
||||||
void addRxFragment(uint8_t fragment[], uint8_t len);
|
void addRxFragment(uint8_t fragment[], uint8_t len);
|
||||||
@ -122,4 +123,5 @@ private:
|
|||||||
|
|
||||||
uint8_t _payloadStats[MAX_RF_FRAGMENT_COUNT * MAX_RF_PAYLOAD_SIZE];
|
uint8_t _payloadStats[MAX_RF_FRAGMENT_COUNT * MAX_RF_PAYLOAD_SIZE];
|
||||||
uint32_t _lastStatsUpdate = 0;
|
uint32_t _lastStatsUpdate = 0;
|
||||||
|
uint16_t _chanMaxPower[CH4];
|
||||||
};
|
};
|
||||||
@ -130,7 +130,11 @@ void WebApiInverterClass::onInverterAdd(AsyncWebServerRequest* request)
|
|||||||
response->setLength();
|
response->setLength();
|
||||||
request->send(response);
|
request->send(response);
|
||||||
|
|
||||||
Hoymiles.addInverter(inverter->Name, inverter->Serial);
|
auto inv = Hoymiles.addInverter(inverter->Name, inverter->Serial);
|
||||||
|
|
||||||
|
for (uint8_t c = 0; c < INV_MAX_CHAN_COUNT; c++) {
|
||||||
|
inv->setChannelMaxPower(c, inverter->MaxChannelPower[c]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebApiInverterClass::onInverterEdit(AsyncWebServerRequest* request)
|
void WebApiInverterClass::onInverterEdit(AsyncWebServerRequest* request)
|
||||||
@ -210,6 +214,10 @@ void WebApiInverterClass::onInverterEdit(AsyncWebServerRequest* request)
|
|||||||
std::shared_ptr<InverterAbstract> inv = Hoymiles.getInverterByPos(root[F("id")].as<uint64_t>());
|
std::shared_ptr<InverterAbstract> inv = Hoymiles.getInverterByPos(root[F("id")].as<uint64_t>());
|
||||||
inv->setName(inverter.Name);
|
inv->setName(inverter.Name);
|
||||||
inv->setSerial(inverter.Serial);
|
inv->setSerial(inverter.Serial);
|
||||||
|
|
||||||
|
for (uint8_t c = 0; c < INV_MAX_CHAN_COUNT; c++) {
|
||||||
|
inv->setChannelMaxPower(c, inverter.MaxChannelPower[c]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebApiInverterClass::onInverterDelete(AsyncWebServerRequest* request)
|
void WebApiInverterClass::onInverterDelete(AsyncWebServerRequest* request)
|
||||||
|
|||||||
@ -80,9 +80,13 @@ void setup()
|
|||||||
|
|
||||||
for (uint8_t i = 0; i < INV_MAX_COUNT; i++) {
|
for (uint8_t i = 0; i < INV_MAX_COUNT; i++) {
|
||||||
if (config.Inverter[i].Serial > 0) {
|
if (config.Inverter[i].Serial > 0) {
|
||||||
Hoymiles.addInverter(
|
auto inv = Hoymiles.addInverter(
|
||||||
config.Inverter[i].Name,
|
config.Inverter[i].Name,
|
||||||
config.Inverter[i].Serial);
|
config.Inverter[i].Serial);
|
||||||
|
|
||||||
|
for (uint8_t c = 0; c < INV_MAX_CHAN_COUNT; c++) {
|
||||||
|
inv->setChannelMaxPower(c, config.Inverter[i].MaxChannelPower[c]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Serial.println(F("done"));
|
Serial.println(F("done"));
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user