mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-10 23:46:37 +02:00
MI - add "get loss logic"
* as we don't have info from inverter side, this is just dull tx/rx statistics from the recent cycle...
This commit is contained in:
parent
3aa4751689
commit
e23daad910
3 changed files with 48 additions and 22 deletions
|
@ -141,6 +141,8 @@ class Communication : public CommQueue<> {
|
||||||
q->iv->radio->switchFrequency(q->iv, HOY_BOOT_FREQ_KHZ, (q->iv->config->frequency*FREQ_STEP_KHZ + HOY_BASE_FREQ_KHZ));
|
q->iv->radio->switchFrequency(q->iv, HOY_BOOT_FREQ_KHZ, (q->iv->config->frequency*FREQ_STEP_KHZ + HOY_BASE_FREQ_KHZ));
|
||||||
mWaitTime.startTimeMonitor(1000);
|
mWaitTime.startTimeMonitor(1000);
|
||||||
}
|
}
|
||||||
|
if(IV_MI == q->iv->ivGen)
|
||||||
|
q->iv->mIvTxCnt++;
|
||||||
}
|
}
|
||||||
closeRequest(q, false);
|
closeRequest(q, false);
|
||||||
break;
|
break;
|
||||||
|
@ -733,17 +735,16 @@ class Communication : public CommQueue<> {
|
||||||
miNextRequest((p->packet[0] - ALL_FRAMES + 1), q);
|
miNextRequest((p->packet[0] - ALL_FRAMES + 1), q);
|
||||||
} else {
|
} else {
|
||||||
q->iv->miMultiParts = 7; // indicate we are ready
|
q->iv->miMultiParts = 7; // indicate we are ready
|
||||||
//miComplete(q->iv);
|
|
||||||
}
|
}
|
||||||
} else if((p->packet[0] == (MI_REQ_CH1 + ALL_FRAMES)) && (q->iv->type == INV_TYPE_2CH)) {
|
} else if((p->packet[0] == (MI_REQ_CH1 + ALL_FRAMES)) && (q->iv->type == INV_TYPE_2CH)) {
|
||||||
//addImportant(q->iv, MI_REQ_CH2);
|
//addImportant(q->iv, MI_REQ_CH2);
|
||||||
miNextRequest(MI_REQ_CH2, q);
|
miNextRequest(MI_REQ_CH2, q);
|
||||||
mHeu.evalTxChQuality(q->iv, true, (q->attemptsMax - 1 - q->attempts), q->iv->curFrmCnt);
|
mHeu.evalTxChQuality(q->iv, true, (q->attemptsMax - 1 - q->attempts), q->iv->curFrmCnt);
|
||||||
//use also miMultiParts here for better statistics?
|
q->iv->mIvRxCnt++; // statistics workaround...
|
||||||
//mHeu.setGotFragment(q->iv);
|
|
||||||
} else { // first data msg for 1ch, 2nd for 2ch
|
} else { // first data msg for 1ch, 2nd for 2ch
|
||||||
q->iv->miMultiParts += 6; // indicate we are ready
|
q->iv->miMultiParts += 6; // indicate we are ready
|
||||||
//miComplete(q->iv);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -757,13 +758,9 @@ class Communication : public CommQueue<> {
|
||||||
DBGHEXLN(cmd);
|
DBGHEXLN(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(q->iv->miMultiParts == 7) {
|
if(q->iv->miMultiParts == 7)
|
||||||
//mHeu.setGotAll(q->iv);
|
|
||||||
q->iv->radioStatistics.rxSuccess++;
|
q->iv->radioStatistics.rxSuccess++;
|
||||||
} else
|
|
||||||
//mHeu.setGotFragment(q->iv);
|
|
||||||
/*iv->radioStatistics.rxFail++; // got no complete payload*/
|
|
||||||
//q->iv->radioStatistics.retransmits++;
|
|
||||||
q->iv->radio->sendCmdPacket(q->iv, cmd, 0x00, true);
|
q->iv->radio->sendCmdPacket(q->iv, cmd, 0x00, true);
|
||||||
|
|
||||||
mWaitTime.startTimeMonitor(MI_TIMEOUT);
|
mWaitTime.startTimeMonitor(MI_TIMEOUT);
|
||||||
|
@ -871,6 +868,26 @@ class Communication : public CommQueue<> {
|
||||||
DPRINT_IVID(DBG_INFO, iv->id);
|
DPRINT_IVID(DBG_INFO, iv->id);
|
||||||
DBGPRINTLN(F("got all data msgs"));
|
DBGPRINTLN(F("got all data msgs"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (iv->mGetLossInterval >= AHOY_GET_LOSS_INTERVAL) { // initially mIvRxCnt = mIvTxCnt = 0
|
||||||
|
iv->mGetLossInterval = 1;
|
||||||
|
iv->radioStatistics.ivSent = iv->mIvRxCnt + iv->mDtuTxCnt; // iv->mIvRxCnt is the nr. of additional answer frames, default we expect one frame per request
|
||||||
|
iv->radioStatistics.ivLoss = iv->radioStatistics.ivSent - iv->mDtuRxCnt; // this is what we didn't receive
|
||||||
|
iv->radioStatistics.dtuLoss = iv->mIvTxCnt; // this is somehow the requests w/o answers in that periode
|
||||||
|
iv->radioStatistics.dtuSent = iv->mDtuTxCnt;
|
||||||
|
if (mSerialDebug) {
|
||||||
|
DPRINT_IVID(DBG_INFO, iv->id);
|
||||||
|
DBGPRINTLN("DTU loss: " +
|
||||||
|
String (iv->radioStatistics.ivLoss) + "/" +
|
||||||
|
String (iv->radioStatistics.ivSent) + " frames for " +
|
||||||
|
String (iv->radioStatistics.dtuSent) + " requests");
|
||||||
|
}
|
||||||
|
iv->mIvRxCnt = 0; // start new interval, iVRxCnt is abused to collect additional possible frames
|
||||||
|
iv->mIvTxCnt = 0; // start new interval, iVTxCnt is abused to collect nr. of unanswered requests
|
||||||
|
iv->mDtuRxCnt = 0; // start new interval
|
||||||
|
iv->mDtuTxCnt = 0; // start new interval
|
||||||
|
}
|
||||||
|
|
||||||
record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug);
|
record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug);
|
||||||
iv->setValue(iv->getPosByChFld(0, FLD_YD, rec), rec, calcYieldDayCh0(iv,0));
|
iv->setValue(iv->getPosByChFld(0, FLD_YD, rec), rec, calcYieldDayCh0(iv,0));
|
||||||
|
|
||||||
|
|
|
@ -212,16 +212,22 @@ class Inverter {
|
||||||
cb(RealTimeRunData_Debug, false); // get live data
|
cb(RealTimeRunData_Debug, false); // get live data
|
||||||
}
|
}
|
||||||
} else { // MI
|
} else { // MI
|
||||||
if(0 == getFwVersion())
|
if(0 == getFwVersion()) {
|
||||||
|
mIvRxCnt +=2;
|
||||||
cb(0x0f, false); // get firmware version; for MI, this makes part of polling the device software and hardware version number
|
cb(0x0f, false); // get firmware version; for MI, this makes part of polling the device software and hardware version number
|
||||||
else {
|
} else {
|
||||||
record_t<> *rec = getRecordStruct(InverterDevInform_Simple);
|
record_t<> *rec = getRecordStruct(InverterDevInform_Simple);
|
||||||
if (getChannelFieldValue(CH0, FLD_PART_NUM, rec) == 0)
|
if (getChannelFieldValue(CH0, FLD_PART_NUM, rec) == 0) {
|
||||||
cb(0x0f, false); // hard- and firmware version for missing HW part nr, delivered by frame 1
|
cb(0x0f, false); // hard- and firmware version for missing HW part nr, delivered by frame 1
|
||||||
else if((getChannelFieldValue(CH0, FLD_GRID_PROFILE_CODE, rec) == 0) && generalConfig->readGrid) // read grid profile
|
mIvRxCnt +=2;
|
||||||
|
} else if((getChannelFieldValue(CH0, FLD_GRID_PROFILE_CODE, rec) == 0) && generalConfig->readGrid) // read grid profile
|
||||||
cb(0x10, false); // legacy GPF command
|
cb(0x10, false); // legacy GPF command
|
||||||
else
|
else {
|
||||||
cb(((type == INV_TYPE_4CH) ? MI_REQ_4CH : MI_REQ_CH1), false);
|
cb(((type == INV_TYPE_4CH) ? MI_REQ_4CH : MI_REQ_CH1), false);
|
||||||
|
mGetLossInterval++;
|
||||||
|
if (type != INV_TYPE_4CH)
|
||||||
|
mIvRxCnt++; // statistics workaround...
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -619,7 +625,7 @@ class Inverter {
|
||||||
radioStatistics.dtuSent = txCnt + ((uint16_t)65535 - mIvTxCnt) + 1;
|
radioStatistics.dtuSent = txCnt + ((uint16_t)65535 - mIvTxCnt) + 1;
|
||||||
else
|
else
|
||||||
radioStatistics.dtuSent = txCnt - mIvTxCnt;
|
radioStatistics.dtuSent = txCnt - mIvTxCnt;
|
||||||
|
|
||||||
radioStatistics.dtuLoss = radioStatistics.dtuSent - mDtuRxCnt;
|
radioStatistics.dtuLoss = radioStatistics.dtuSent - mDtuRxCnt;
|
||||||
|
|
||||||
DPRINT_IVID(DBG_INFO, id);
|
DPRINT_IVID(DBG_INFO, id);
|
||||||
|
@ -831,15 +837,16 @@ class Inverter {
|
||||||
bool mDevControlRequest; // true if change needed
|
bool mDevControlRequest; // true if change needed
|
||||||
uint8_t mGridLen = 0;
|
uint8_t mGridLen = 0;
|
||||||
uint8_t mGridProfile[MAX_GRID_LENGTH];
|
uint8_t mGridProfile[MAX_GRID_LENGTH];
|
||||||
uint8_t mGetLossInterval; // request iv every AHOY_GET_LOSS_INTERVAL RealTimeRunData_Debug
|
|
||||||
uint16_t mIvRxCnt = 0;
|
|
||||||
uint16_t mIvTxCnt = 0;
|
|
||||||
uint8_t mAlarmNxtWrPos = 0; // indicates the position in array (rolling buffer)
|
uint8_t mAlarmNxtWrPos = 0; // indicates the position in array (rolling buffer)
|
||||||
bool mNextLive = true; // first read live data after booting up then version etc.
|
bool mNextLive = true; // first read live data after booting up then version etc.
|
||||||
|
|
||||||
public:
|
public:
|
||||||
uint16_t mDtuRxCnt = 0;
|
uint16_t mDtuRxCnt = 0;
|
||||||
uint16_t mDtuTxCnt = 0;
|
uint16_t mDtuTxCnt = 0;
|
||||||
|
uint8_t mGetLossInterval = 0; // request iv every AHOY_GET_LOSS_INTERVAL RealTimeRunData_Debug
|
||||||
|
uint16_t mIvRxCnt = 0;
|
||||||
|
uint16_t mIvTxCnt = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class REC_TYP>
|
template <class REC_TYP>
|
||||||
|
|
|
@ -42,8 +42,10 @@ class Radio {
|
||||||
|
|
||||||
void prepareDevInformCmd(Inverter<> *iv, uint8_t cmd, uint32_t ts, uint16_t alarmMesId, bool isRetransmit, uint8_t reqfld=TX_REQ_INFO) { // might not be necessary to add additional arg.
|
void prepareDevInformCmd(Inverter<> *iv, uint8_t cmd, uint32_t ts, uint16_t alarmMesId, bool isRetransmit, uint8_t reqfld=TX_REQ_INFO) { // might not be necessary to add additional arg.
|
||||||
if(IV_MI == getIvGen(iv)) {
|
if(IV_MI == getIvGen(iv)) {
|
||||||
DPRINT(DBG_DEBUG, F("legacy cmd 0x"));
|
if(*mSerialDebug) {
|
||||||
DPRINTLN(DBG_DEBUG,String(cmd, HEX));
|
DPRINT(DBG_DEBUG, F("legacy cmd 0x"));
|
||||||
|
DPRINTLN(DBG_DEBUG,String(cmd, HEX));
|
||||||
|
}
|
||||||
sendCmdPacket(iv, cmd, cmd, false, false);
|
sendCmdPacket(iv, cmd, cmd, false, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue