* fixed issues (found during unit test)

This commit is contained in:
lumapu 2022-04-30 02:02:41 +02:00
parent 32e58c98c0
commit af4960f1c4
4 changed files with 30 additions and 20 deletions

View file

@ -23,6 +23,9 @@ static T calcYieldTotalCh0(Inverter<> *iv, uint8_t arg0);
template<class T=float>
static T calcYieldDayCh0(Inverter<> *iv, uint8_t arg0);
template<class T=float>
static T calcUdcCh(Inverter<> *iv, uint8_t arg0);
template<class T=float>
using func_t = T (Inverter<> *, uint8_t);
@ -37,7 +40,8 @@ struct calcFunc_t {
template<class T=float>
const calcFunc_t<T> calcFunctions[] = {
{ CALC_YT_CH0, &calcYieldTotalCh0 },
{ CALC_YD_CH0, &calcYieldDayCh0 }
{ CALC_YD_CH0, &calcYieldDayCh0 },
{ CALC_UDC_CH, &calcUdcCh }
};
@ -55,16 +59,21 @@ class Inverter {
RECORDTYPE *record; // pointer for values
Inverter() {
getAssignment();
toRadioId();
record = new RECORDTYPE[listLen];
memset(record, 0, sizeof(RECORDTYPE) * listLen);
}
~Inverter() {
// TODO: cleanup
}
void init(void) {
getAssignment();
toRadioId();
record = new RECORDTYPE[listLen];
memset(name, 0, MAX_NAME_LENGTH);
memset(record, 0, sizeof(RECORDTYPE) * listLen);
}
uint8_t getPosByChFld(uint8_t channel, uint8_t fieldId) {
uint8_t pos = 0;
for(; pos < listLen; pos++) {
@ -108,6 +117,14 @@ class Inverter {
return record[pos];
}
void doCalculations(void) {
for(uint8_t i = 0; i < listLen; i++) {
if(CMDFF == assign[i].cmdId) {
record[i] = calcFunctions<RECORDTYPE>[assign[i].start].func(this, assign[i].num);
}
}
}
private:
void toRadioId(void) {
radioId.u64 = 0ULL;
@ -145,14 +162,6 @@ class Inverter {
assign = NULL;
}
}
void doCalculations(void) {
for(uint8_t i = 0; i < listLen; i++) {
if(CMDFF == assign[i].cmdId) {
calcFunctions<RECORDTYPE>[assign[i].start].func(this, assign[i].num);
}
}
}
};