Change the krunching routine
- Last UpdatedApr 24, 2025
- 2 minute read
If enabling the Indefinite Return to Normal (RTN) Alarm functionality, you may have to change your project's krunching routine. Refer to the following for information on how to make updates.
The suppress_alarm routine has an additional optional return parameter that indicates whether the krunching routine will generate an alarm even though the child point has not changed state.
In this scenario, the stateless alarm needs to be replaced by the default state-specific alarm for the point when suppression is canceled.
Follow the steps below to update your project krunching routine. You can find an example of how to update the code in hilock.cpp/gensta.cpp/genmulti.cpp. Search for the bIndefRTNAlarmWasIssued variable to find the code changes.
To change the krunching routine
-
Declare a new variable in your krunch function's alarming routine:
oas_boolean_t bIndefRTNAlarmWasIssued = OAS_FALSE; //alarm regeneration flag, default to false
-
Add a reference to the bIndefRTNAlarmWasIssued variable at the end of your pre-existing suppress_alarm call.
For example:
currentlySuppressAlarm = suppress_alarm_and_type(dbno, entno, (newState ! =HILOW_OK), newState, (pHilo->state != HILOW_OK), pHilo->state, &foundValidChildState, &prevChildState, &highestPrioritySup, &bIndefRTNAlarmWasIssued);
-
Change the "if" statement in the krunching code that checks the prevChildState and previouslySuppressAlarm.
if ((!currentlySuppressAlarm && !delay_applied) && /* If alarm not currently suppressed */
((previouslySuppressAlarm && /* AND either the alarm was previously suppressed */
foundValidChildState && /* AND we found a valid prevChildState for suppressed point */
((newState != prevChildState) && !isSetCreepAlarm && !isUserAlarm) || bIndefRTNAlarmWasIssued) || genAlarm ||
/* AND there was a change in state during suppression or need to regenerate the alarm */
(!previouslySuppressAlarm && !previously_delayed && /* OR alarm was not previously suppressed */
(rocStateChanged || // Change this to be if hilowstatechanged OR rocstatechanged OR the state has changed,
// instead of (hilowstatechanged OR rocstatechanged) AND state has changed.
(stateHasChanged(pHilo, newState, isUserAlarm, isSetCreepAlarm))) ))) /* AND the state changed */
{
/* If alarms are not inhibited or receive RTN */
if ((inAlm && !pFlag->alminh) || (!inAlm))
{
if (addDBalarm((char*)dbpnam(dbno), dbno, pnt_name, entno, fld_name,
remslot, descr, group, almType, stateMsg, (void *)pRecord, pFlag, persistAlm, flash,
krpsev(pFlag->bmsg + HILOW_OK), 0, OAS_FALSE, tstamp, getHostName(),
dataset, OAS_TRUE))
{
addedAlarm = OAS_TRUE;
}
}