Skip to content

Commit

Permalink
Fixed Toggle trigger-cause
Browse files Browse the repository at this point in the history
  • Loading branch information
shining-man committed Mar 28, 2024
1 parent 3094fa1 commit df64d1a
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions src/AlarmRules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,6 @@ void setAlarm(uint8_t alarmNr, bool bo_lAlarm, uint8_t cause)
{
//BSC_LOGD(TAG,"setAlarm: alarmNr=%i TRUE",alarmNr);
bo_Alarm[alarmNr]=true;
if(((alarmCauseAktiv[alarmNr]>>cause)&0x1)==0)
{
BSC_LOGI(TAG,"Trigger %i high, cause %i",alarmNr+1,cause);
logTrigger(alarmNr, cause, bo_lAlarm);
}
bitSet(alarmCauseAktiv[alarmNr],cause);
bo_alarmActivate[alarmNr]=true;
}
Expand All @@ -177,15 +172,29 @@ void setAlarm(uint8_t alarmNr, bool bo_lAlarm, uint8_t cause)
bo_alarmActivate[alarmNr]=true;
}
}
}

if(bo_lAlarm==false)
/* Wenn sich die Triggergründe geändert haben, dann Meldung ins Log */
void handleLogTrigger(uint16_t (&alarmCauseAktivLast)[CNT_ALARMS])
{
for(uint8_t triggerNr=0; triggerNr<CNT_ALARMS; triggerNr++)
{
if(((alarmCauseAktiv[alarmNr]>>cause)&0x1)==1)
for(uint8_t cause=0; cause < 16; cause++)
{
BSC_LOGI(TAG,"Trigger %i low, cause %i",alarmNr+1,cause);
logTrigger(alarmNr, cause, bo_lAlarm);
if(isBitSet(alarmCauseAktivLast[triggerNr], cause)==0 &&
isBitSet(alarmCauseAktiv[triggerNr], cause)==1)
{
BSC_LOGI(TAG,"Trigger %i high, cause %i",triggerNr+1,cause);
logTrigger(triggerNr, cause, true);
}
else if(isBitSet(alarmCauseAktivLast[triggerNr], cause)==1 &&
isBitSet(alarmCauseAktiv[triggerNr], cause)==0)
{
BSC_LOGI(TAG,"Trigger %i low, cause %i",triggerNr+1,cause);
logTrigger(triggerNr, cause, false);
bitClear(alarmCauseAktiv[triggerNr],cause);
}
}
bitClear(alarmCauseAktiv[alarmNr],cause);
}
}

Expand All @@ -206,6 +215,12 @@ void runAlarmRules()
uint8_t i;
bool bo_lChangeAlarmSettings=false;

// Merker für die letzten Alarm Gründe
uint16_t alarmCauseAktivLast[CNT_ALARMS];
memcpy(alarmCauseAktivLast, alarmCauseAktiv, sizeof(uint16_t)*CNT_ALARMS);
// Lösche den letzten Triggergrund; Der Grund wird in dem Durchgang neu gesetzt
for(uint8_t triggerNr=0; triggerNr<CNT_ALARMS; triggerNr++) alarmCauseAktiv[triggerNr]=0;

//Toggle LED
if(getHwVersion()==0)u8_mDoByte ^= (1 << 7);
else digitalWrite(GPIO_LED1_HW1, !digitalRead(GPIO_LED1_HW1));
Expand Down Expand Up @@ -300,6 +315,7 @@ void runAlarmRules()
}

setDOs();
handleLogTrigger(alarmCauseAktivLast);
}


Expand Down

0 comments on commit df64d1a

Please sign in to comment.