|
@ -102,6 +102,13 @@ const calcFunc_t<T> calcFunctions[] = { |
|
|
{ CALC_IRR_CH, &calcIrradiation } |
|
|
{ CALC_IRR_CH, &calcIrradiation } |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
enum class InverterStatus : uint8_t { |
|
|
|
|
|
OFF, |
|
|
|
|
|
STARTING, |
|
|
|
|
|
PRODUCING, |
|
|
|
|
|
WAS_PRODUCING, |
|
|
|
|
|
WAS_ON |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
template <class REC_TYP> |
|
|
template <class REC_TYP> |
|
|
class Inverter { |
|
|
class Inverter { |
|
@ -123,6 +130,9 @@ class Inverter { |
|
|
//String lastAlarmMsg;
|
|
|
//String lastAlarmMsg;
|
|
|
bool initialized; // needed to check if the inverter was correctly added (ESP32 specific - union types are never null)
|
|
|
bool initialized; // needed to check if the inverter was correctly added (ESP32 specific - union types are never null)
|
|
|
bool isConnected; // shows if inverter was successfully identified (fw version and hardware info)
|
|
|
bool isConnected; // shows if inverter was successfully identified (fw version and hardware info)
|
|
|
|
|
|
InverterStatus status; // indicates the current inverter status
|
|
|
|
|
|
|
|
|
|
|
|
static uint32_t *timestamp; // system timestamp
|
|
|
|
|
|
|
|
|
Inverter() { |
|
|
Inverter() { |
|
|
ivGen = IV_HM; |
|
|
ivGen = IV_HM; |
|
@ -135,6 +145,7 @@ class Inverter { |
|
|
//lastAlarmMsg = "nothing";
|
|
|
//lastAlarmMsg = "nothing";
|
|
|
alarmMesIndex = 0; |
|
|
alarmMesIndex = 0; |
|
|
isConnected = false; |
|
|
isConnected = false; |
|
|
|
|
|
status = InverterStatus::OFF; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
~Inverter() { |
|
|
~Inverter() { |
|
@ -319,6 +330,9 @@ class Inverter { |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
DPRINTLN(DBG_ERROR, F("addValue: assignment not found with cmd 0x")); |
|
|
DPRINTLN(DBG_ERROR, F("addValue: assignment not found with cmd 0x")); |
|
|
|
|
|
|
|
|
|
|
|
// update status state-machine
|
|
|
|
|
|
isProducing(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/*inline REC_TYP getPowerLimit(void) {
|
|
|
/*inline REC_TYP getPowerLimit(void) {
|
|
@ -372,25 +386,39 @@ class Inverter { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bool isAvailable(uint32_t timestamp) { |
|
|
bool isAvailable() { |
|
|
if((timestamp - recordMeas.ts) < INACT_THRES_SEC) |
|
|
bool val = false; |
|
|
return true; |
|
|
if((*timestamp - recordMeas.ts) < INACT_THRES_SEC) |
|
|
if((timestamp - recordInfo.ts) < INACT_THRES_SEC) |
|
|
val = true; |
|
|
return true; |
|
|
if((*timestamp - recordInfo.ts) < INACT_THRES_SEC) |
|
|
if((timestamp - recordConfig.ts) < INACT_THRES_SEC) |
|
|
val = true; |
|
|
return true; |
|
|
if((*timestamp - recordConfig.ts) < INACT_THRES_SEC) |
|
|
if((timestamp - recordAlarm.ts) < INACT_THRES_SEC) |
|
|
val = true; |
|
|
return true; |
|
|
if((*timestamp - recordAlarm.ts) < INACT_THRES_SEC) |
|
|
return false; |
|
|
val = true; |
|
|
|
|
|
|
|
|
|
|
|
if(val) { |
|
|
|
|
|
if((InverterStatus::OFF == status) || (InverterStatus::WAS_ON == status)) |
|
|
|
|
|
status = InverterStatus::STARTING; |
|
|
|
|
|
} else |
|
|
|
|
|
status = InverterStatus::WAS_ON; |
|
|
|
|
|
|
|
|
|
|
|
return val; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bool isProducing(uint32_t timestamp) { |
|
|
bool isProducing() { |
|
|
|
|
|
bool val = false; |
|
|
DPRINTLN(DBG_VERBOSE, F("hmInverter.h:isProducing")); |
|
|
DPRINTLN(DBG_VERBOSE, F("hmInverter.h:isProducing")); |
|
|
if(isAvailable(timestamp)) { |
|
|
if(isAvailable()) { |
|
|
uint8_t pos = getPosByChFld(CH0, FLD_PAC, &recordMeas); |
|
|
uint8_t pos = getPosByChFld(CH0, FLD_PAC, &recordMeas); |
|
|
return (getValue(pos, &recordMeas) > INACT_PWR_THRESH); |
|
|
val = (getValue(pos, &recordMeas) > INACT_PWR_THRESH); |
|
|
|
|
|
|
|
|
|
|
|
if(val) |
|
|
|
|
|
status = InverterStatus::PRODUCING; |
|
|
|
|
|
else if(InverterStatus::PRODUCING == status) |
|
|
|
|
|
status = InverterStatus::WAS_PRODUCING; |
|
|
} |
|
|
} |
|
|
return false; |
|
|
return val; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
uint16_t getFwVersion() { |
|
|
uint16_t getFwVersion() { |
|
@ -605,6 +633,9 @@ class Inverter { |
|
|
bool mDevControlRequest; // true if change needed
|
|
|
bool mDevControlRequest; // true if change needed
|
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
template <class REC_TYP> |
|
|
|
|
|
uint32_t *Inverter<REC_TYP>::timestamp {0}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* To calculate values which are not transmitted by the unit there is a generic |
|
|
* To calculate values which are not transmitted by the unit there is a generic |
|
|