mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-10 07:26:38 +02:00
alarm handling
This commit is contained in:
parent
4237a33b9c
commit
14b6e08532
5 changed files with 36 additions and 14 deletions
|
@ -267,6 +267,18 @@ void app::loop(void) {
|
||||||
mSys->InfoCmd = RealTimeRunData_Debug; // Set back to default
|
mSys->InfoCmd = RealTimeRunData_Debug; // Set back to default
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case AlarmData:
|
||||||
|
{
|
||||||
|
DPRINT(DBG_INFO, "Response from AlarmData\n");
|
||||||
|
mSys->InfoCmd = RealTimeRunData_Debug; // Set back to default
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case AlarmUpdate:
|
||||||
|
{
|
||||||
|
DPRINT(DBG_INFO, "Response from AlarmUpdate\n");
|
||||||
|
mSys->InfoCmd = RealTimeRunData_Debug; // Set back to default
|
||||||
|
break;
|
||||||
|
}
|
||||||
case RealTimeRunData_Debug:
|
case RealTimeRunData_Debug:
|
||||||
{
|
{
|
||||||
uint8_t *pid = &p->packet[9];
|
uint8_t *pid = &p->packet[9];
|
||||||
|
@ -429,7 +441,7 @@ void app::loop(void) {
|
||||||
DPRINTLN(DBG_INFO, F("Devcontrol request ") + String(iv->devControlCmd) + F(" power limit ") + String(iv->powerLimit[0]));
|
DPRINTLN(DBG_INFO, F("Devcontrol request ") + String(iv->devControlCmd) + F(" power limit ") + String(iv->powerLimit[0]));
|
||||||
mSys->Radio.sendControlPacket(iv->radioId.u64,iv->devControlCmd ,iv->powerLimit);
|
mSys->Radio.sendControlPacket(iv->radioId.u64,iv->devControlCmd ,iv->powerLimit);
|
||||||
} else {
|
} else {
|
||||||
mSys->Radio.sendTimePacket(iv->radioId.u64, mSys->InfoCmd, mPayload[iv->id].ts);
|
mSys->Radio.sendTimePacket(iv->radioId.u64, mSys->InfoCmd, mPayload[iv->id].ts,iv->alarmMesIndex);
|
||||||
mRxTicker = 0;
|
mRxTicker = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -503,7 +515,7 @@ void app::processPayload(bool retransmit) {
|
||||||
if(0x00 != mLastPacketId)
|
if(0x00 != mLastPacketId)
|
||||||
mSys->Radio.sendCmdPacket(iv->radioId.u64, TX_REQ_INFO, mLastPacketId, true);
|
mSys->Radio.sendCmdPacket(iv->radioId.u64, TX_REQ_INFO, mLastPacketId, true);
|
||||||
else
|
else
|
||||||
mSys->Radio.sendTimePacket(iv->radioId.u64, mSys->InfoCmd, mPayload[iv->id].ts);
|
mSys->Radio.sendTimePacket(iv->radioId.u64, mSys->InfoCmd, mPayload[iv->id].ts,iv->alarmMesIndex);
|
||||||
}
|
}
|
||||||
mSys->Radio.switchRxCh(100);
|
mSys->Radio.switchRxCh(100);
|
||||||
}
|
}
|
||||||
|
@ -882,9 +894,9 @@ void app::showLiveData(void) {
|
||||||
|
|
||||||
modHtml += F("<div class=\"iv\">"
|
modHtml += F("<div class=\"iv\">"
|
||||||
"<div class=\"ch-iv\"><span class=\"head\">") + String(iv->name) + F(" Limit ") + String(iv->powerLimit[0]) + F(" W</span>");
|
"<div class=\"ch-iv\"><span class=\"head\">") + String(iv->name) + F(" Limit ") + String(iv->powerLimit[0]) + F(" W</span>");
|
||||||
uint8_t list[] = {FLD_UAC, FLD_IAC, FLD_PAC, FLD_F, FLD_PCT, FLD_T, FLD_YT, FLD_YD, FLD_PDC, FLD_EFF, FLD_PRA};
|
uint8_t list[] = {FLD_UAC, FLD_IAC, FLD_PAC, FLD_F, FLD_PCT, FLD_T, FLD_YT, FLD_YD, FLD_PDC, FLD_EFF, FLD_PRA, FLD_ALARM_MES_ID};
|
||||||
|
|
||||||
for(uint8_t fld = 0; fld < 11; fld++) {
|
for(uint8_t fld = 0; fld < 12; fld++) {
|
||||||
pos = (iv->getPosByChFld(CH0, list[fld]));
|
pos = (iv->getPosByChFld(CH0, list[fld]));
|
||||||
if(0xff != pos) {
|
if(0xff != pos) {
|
||||||
modHtml += F("<div class=\"subgrp\">");
|
modHtml += F("<div class=\"subgrp\">");
|
||||||
|
|
|
@ -43,8 +43,8 @@ typedef enum
|
||||||
//RealTimeRunData_A_Phase = 13, // 0x0d
|
//RealTimeRunData_A_Phase = 13, // 0x0d
|
||||||
//RealTimeRunData_B_Phase = 14, // 0x0e
|
//RealTimeRunData_B_Phase = 14, // 0x0e
|
||||||
//RealTimeRunData_C_Phase = 15, // 0x0f
|
//RealTimeRunData_C_Phase = 15, // 0x0f
|
||||||
//AlarmData = 17, // 0x11 //Alarm data - all unsent alarms
|
AlarmData = 17, // 0x11 //Alarm data - all unsent alarms
|
||||||
//AlarmUpdate = 18, // 0x12 //Alarm data - all pending alarms
|
AlarmUpdate = 18, // 0x12 //Alarm data - all pending alarms
|
||||||
//RecordData = 19, // 0x13
|
//RecordData = 19, // 0x13
|
||||||
//InternalData = 20, // 0x14
|
//InternalData = 20, // 0x14
|
||||||
GetLossRate = 21, // 0x15
|
GetLossRate = 21, // 0x15
|
||||||
|
|
|
@ -17,15 +17,15 @@ union serial_u {
|
||||||
|
|
||||||
|
|
||||||
// units
|
// units
|
||||||
enum {UNIT_V = 0, UNIT_A, UNIT_W, UNIT_WH, UNIT_KWH, UNIT_HZ, UNIT_C, UNIT_PCT, UNIT_VA};
|
enum {UNIT_V = 0, UNIT_A, UNIT_W, UNIT_WH, UNIT_KWH, UNIT_HZ, UNIT_C, UNIT_PCT, UNIT_VA, UNIT_ALARM_MES_ID};
|
||||||
const char* const units[] = {"V", "A", "W", "Wh", "kWh", "Hz", "°C", "%","VA"};
|
const char* const units[] = {"V", "A", "W", "Wh", "kWh", "Hz", "°C", "%","VAr",""};
|
||||||
|
|
||||||
|
|
||||||
// field types
|
// field types
|
||||||
enum {FLD_UDC = 0, FLD_IDC, FLD_PDC, FLD_YD, FLD_YW, FLD_YT,
|
enum {FLD_UDC = 0, FLD_IDC, FLD_PDC, FLD_YD, FLD_YW, FLD_YT,
|
||||||
FLD_UAC, FLD_IAC, FLD_PAC, FLD_F, FLD_T, FLD_PCT, FLD_EFF, FLD_IRR, FLD_PRA};
|
FLD_UAC, FLD_IAC, FLD_PAC, FLD_F, FLD_T, FLD_PCT, FLD_EFF, FLD_IRR, FLD_PRA,FLD_ALARM_MES_ID};
|
||||||
const char* const fields[] = {"U_DC", "I_DC", "P_DC", "YieldDay", "YieldWeek", "YieldTotal",
|
const char* const fields[] = {"U_DC", "I_DC", "P_DC", "YieldDay", "YieldWeek", "YieldTotal",
|
||||||
"U_AC", "I_AC", "P_AC", "Freq", "Temp", "Pct", "Efficiency", "Irradiation","P_ACr"};
|
"U_AC", "I_AC", "P_AC", "Freq", "Temp", "Pct", "Efficiency", "Irradiation","P_ACr","ALARM_MES_ID"};
|
||||||
|
|
||||||
// mqtt discovery device classes
|
// mqtt discovery device classes
|
||||||
enum {DEVICE_CLS_NONE = 0, DEVICE_CLS_CURRENT, DEVICE_CLS_ENERGY, DEVICE_CLS_PWR, DEVICE_CLS_VOLTAGE, DEVICE_CLS_FREQ, DEVICE_CLS_TEMP};
|
enum {DEVICE_CLS_NONE = 0, DEVICE_CLS_CURRENT, DEVICE_CLS_ENERGY, DEVICE_CLS_PWR, DEVICE_CLS_VOLTAGE, DEVICE_CLS_FREQ, DEVICE_CLS_TEMP};
|
||||||
|
@ -98,6 +98,7 @@ const byteAssign_t hm1chAssignment[] = {
|
||||||
{ FLD_PRA, UNIT_VA, CH0, 20, 2, 10 },
|
{ FLD_PRA, UNIT_VA, CH0, 20, 2, 10 },
|
||||||
{ FLD_F, UNIT_HZ, CH0, 16, 2, 100 },
|
{ FLD_F, UNIT_HZ, CH0, 16, 2, 100 },
|
||||||
{ FLD_T, UNIT_C, CH0, 26, 2, 10 },
|
{ FLD_T, UNIT_C, CH0, 26, 2, 10 },
|
||||||
|
{ FLD_ALARM_MES_ID, UNIT_ALARM_MES_ID, CH0, 28, 2, 1 },
|
||||||
{ FLD_PDC, UNIT_W, CH0, CALC_PDC_CH0, 0, CMD_CALC },
|
{ FLD_PDC, UNIT_W, CH0, CALC_PDC_CH0, 0, CMD_CALC },
|
||||||
{ FLD_EFF, UNIT_PCT, CH0, CALC_EFF_CH0, 0, CMD_CALC }
|
{ FLD_EFF, UNIT_PCT, CH0, CALC_EFF_CH0, 0, CMD_CALC }
|
||||||
};
|
};
|
||||||
|
@ -128,6 +129,7 @@ const byteAssign_t hm2chAssignment[] = {
|
||||||
{ FLD_PRA, UNIT_VA, CH0, 32, 2, 10 },
|
{ FLD_PRA, UNIT_VA, CH0, 32, 2, 10 },
|
||||||
{ FLD_F, UNIT_HZ, CH0, 28, 2, 100 },
|
{ FLD_F, UNIT_HZ, CH0, 28, 2, 100 },
|
||||||
{ FLD_T, UNIT_C, CH0, 38, 2, 10 },
|
{ FLD_T, UNIT_C, CH0, 38, 2, 10 },
|
||||||
|
{ FLD_ALARM_MES_ID, UNIT_ALARM_MES_ID, CH0, 40, 2, 1 },
|
||||||
{ FLD_YD, UNIT_WH, CH0, CALC_YD_CH0, 0, CMD_CALC },
|
{ FLD_YD, UNIT_WH, CH0, CALC_YD_CH0, 0, CMD_CALC },
|
||||||
{ FLD_YT, UNIT_KWH, CH0, CALC_YT_CH0, 0, CMD_CALC },
|
{ FLD_YT, UNIT_KWH, CH0, CALC_YT_CH0, 0, CMD_CALC },
|
||||||
{ FLD_PDC, UNIT_W, CH0, CALC_PDC_CH0, 0, CMD_CALC },
|
{ FLD_PDC, UNIT_W, CH0, CALC_PDC_CH0, 0, CMD_CALC },
|
||||||
|
@ -176,6 +178,7 @@ const byteAssign_t hm4chAssignment[] = {
|
||||||
{ FLD_F, UNIT_HZ, CH0, 48, 2, 100 },
|
{ FLD_F, UNIT_HZ, CH0, 48, 2, 100 },
|
||||||
{ FLD_PCT, UNIT_PCT, CH0, 56, 2, 10 },
|
{ FLD_PCT, UNIT_PCT, CH0, 56, 2, 10 },
|
||||||
{ FLD_T, UNIT_C, CH0, 58, 2, 10 },
|
{ FLD_T, UNIT_C, CH0, 58, 2, 10 },
|
||||||
|
{ FLD_ALARM_MES_ID, UNIT_ALARM_MES_ID, CH0, 60, 2, 1 },
|
||||||
{ FLD_YD, UNIT_WH, CH0, CALC_YD_CH0, 0, CMD_CALC },
|
{ FLD_YD, UNIT_WH, CH0, CALC_YD_CH0, 0, CMD_CALC },
|
||||||
{ FLD_YT, UNIT_KWH, CH0, CALC_YT_CH0, 0, CMD_CALC },
|
{ FLD_YT, UNIT_KWH, CH0, CALC_YT_CH0, 0, CMD_CALC },
|
||||||
{ FLD_PDC, UNIT_W, CH0, CALC_PDC_CH0, 0, CMD_CALC },
|
{ FLD_PDC, UNIT_W, CH0, CALC_PDC_CH0, 0, CMD_CALC },
|
||||||
|
|
|
@ -69,6 +69,7 @@ class Inverter {
|
||||||
uint8_t type; // integer which refers to inverter type
|
uint8_t type; // integer which refers to inverter type
|
||||||
byteAssign_t* assign; // type of inverter
|
byteAssign_t* assign; // type of inverter
|
||||||
uint8_t listLen; // length of assignments
|
uint8_t listLen; // length of assignments
|
||||||
|
uint16_t alarmMesIndex; // Last recorded Alarm Message Index
|
||||||
uint16_t powerLimit[2]; // limit power output
|
uint16_t powerLimit[2]; // limit power output
|
||||||
uint8_t devControlCmd; // carries the requested cmd
|
uint8_t devControlCmd; // carries the requested cmd
|
||||||
bool devControlRequest; // true if change needed
|
bool devControlRequest; // true if change needed
|
||||||
|
@ -132,7 +133,6 @@ class Inverter {
|
||||||
uint8_t ptr = assign[pos].start;
|
uint8_t ptr = assign[pos].start;
|
||||||
uint8_t end = ptr + assign[pos].num;
|
uint8_t end = ptr + assign[pos].num;
|
||||||
uint16_t div = assign[pos].div;
|
uint16_t div = assign[pos].div;
|
||||||
|
|
||||||
if(CMD_CALC != div) {
|
if(CMD_CALC != div) {
|
||||||
uint32_t val = 0;
|
uint32_t val = 0;
|
||||||
do {
|
do {
|
||||||
|
@ -142,6 +142,10 @@ class Inverter {
|
||||||
|
|
||||||
record[pos] = (RECORDTYPE)(val) / (RECORDTYPE)(div);
|
record[pos] = (RECORDTYPE)(val) / (RECORDTYPE)(div);
|
||||||
}
|
}
|
||||||
|
// get last alarm message index and save it in the inverter instance
|
||||||
|
if (getPosByChFld(0, FLD_ALARM_MES_ID) == pos){
|
||||||
|
alarmMesIndex = record[pos];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RECORDTYPE getValue(uint8_t pos) {
|
RECORDTYPE getValue(uint8_t pos) {
|
||||||
|
|
|
@ -195,15 +195,18 @@ class HmRadio {
|
||||||
sendPacket(invId, mTxBuf, 10 + (++cnt), true);
|
sendPacket(invId, mTxBuf, 10 + (++cnt), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendTimePacket(uint64_t invId, uint8_t cmd, uint32_t ts) {
|
void sendTimePacket(uint64_t invId, uint8_t cmd, uint32_t ts, uint16_t alarmMesId) {
|
||||||
//DPRINTLN(DBG_VERBOSE, F("hmRadio.h:sendTimePacket"));
|
//DPRINTLN(DBG_VERBOSE, F("hmRadio.h:sendTimePacket"));
|
||||||
sendCmdPacket(invId, TX_REQ_INFO, ALL_FRAMES, false);
|
sendCmdPacket(invId, TX_REQ_INFO, ALL_FRAMES, false);
|
||||||
mTxBuf[10] = cmd; // cid
|
mTxBuf[10] = cmd; // cid
|
||||||
mTxBuf[11] = 0x00;
|
mTxBuf[11] = 0x00;
|
||||||
CP_U32_LittleEndian(&mTxBuf[12], ts);
|
CP_U32_LittleEndian(&mTxBuf[12], ts);
|
||||||
if (cmd == RealTimeRunData_Debug){
|
if (cmd == RealTimeRunData_Debug || cmd == AlarmData || cmd == AlarmUpdate ){
|
||||||
mTxBuf[19] = 0x05; // ToDo: Shall be the last received Alarm Index Number
|
mTxBuf[18] = (alarmMesId >> 8) & 0xff;
|
||||||
|
mTxBuf[19] = (alarmMesId ) & 0xff;
|
||||||
|
//mTxBuf[19] = 0x05; // ToDo: Shall be the last received Alarm Index Number
|
||||||
} else {
|
} else {
|
||||||
|
mTxBuf[18] = 0x00;
|
||||||
mTxBuf[19] = 0x00;
|
mTxBuf[19] = 0x00;
|
||||||
}
|
}
|
||||||
uint16_t crc = crc16(&mTxBuf[10], 14);
|
uint16_t crc = crc16(&mTxBuf[10], 14);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue