Skip to content

Commit

Permalink
fix calculate new limit state
Browse files Browse the repository at this point in the history
  • Loading branch information
dpazj committed Nov 29, 2024
1 parent ed02bb4 commit e94699c
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/server/ua_subscription_alarms_conditions.c
Original file line number Diff line number Diff line change
Expand Up @@ -4102,32 +4102,33 @@ static UA_StatusCode calculateNewLimitState (
if (exclusive) goto done;
}
}

readObjectPropertyDouble (server, *conditionId, UA_QUALIFIEDNAME(0, CONDITION_FIELD_LOWDEADBAND), &lowDeadband);
retval = readObjectPropertyDouble (server, *conditionId, UA_QUALIFIEDNAME(0, CONDITION_FIELD_LOWLIMIT), &lowLimit);
readObjectPropertyDouble (server, *conditionId, UA_QUALIFIEDNAME(0, CONDITION_FIELD_LOWLOWDEADBAND), &lowLowDeadband);
retval = readObjectPropertyDouble (server, *conditionId, UA_QUALIFIEDNAME(0, CONDITION_FIELD_LOWLOWLIMIT), &lowLowLimit);
if (retval == UA_STATUSCODE_GOOD)
{
UA_Double limit = UA_LIMITSTATE_CHECK(prevState, UA_LIMITSTATE_LOWSTATEBIT) ?
(lowLimit + lowDeadband) : lowLimit;
UA_Double limit = UA_LIMITSTATE_CHECK(prevState, UA_LIMITSTATE_LOWLOWSTATEBIT) ?
(lowLowLimit + lowLowDeadband) : lowLowLimit;
if (inputValue <= limit)
{
UA_LIMITSTATE_SET(state, UA_LIMITSTATE_LOWSTATEBIT);
UA_LIMITSTATE_SET(state, UA_LIMITSTATE_LOWLOWSTATEBIT);
if (exclusive) goto done;
}
}

readObjectPropertyDouble (server, *conditionId, UA_QUALIFIEDNAME(0, CONDITION_FIELD_LOWLOWDEADBAND), &lowLowDeadband);
retval = readObjectPropertyDouble (server, *conditionId, UA_QUALIFIEDNAME(0, CONDITION_FIELD_LOWLOWLIMIT), &lowLowLimit);
readObjectPropertyDouble (server, *conditionId, UA_QUALIFIEDNAME(0, CONDITION_FIELD_LOWDEADBAND), &lowDeadband);
retval = readObjectPropertyDouble (server, *conditionId, UA_QUALIFIEDNAME(0, CONDITION_FIELD_LOWLIMIT), &lowLimit);
if (retval == UA_STATUSCODE_GOOD)
{
UA_Double limit = UA_LIMITSTATE_CHECK(prevState, UA_LIMITSTATE_LOWLOWSTATEBIT) ?
(lowLowLimit + lowLowDeadband) : lowLowLimit;
UA_Double limit = UA_LIMITSTATE_CHECK(prevState, UA_LIMITSTATE_LOWSTATEBIT) ?
(lowLimit + lowDeadband) : lowLimit;
if (inputValue <= limit)
{
UA_LIMITSTATE_SET(state, UA_LIMITSTATE_LOWLOWSTATEBIT);
UA_LIMITSTATE_SET(state, UA_LIMITSTATE_LOWSTATEBIT);
if (exclusive) goto done;
}
}

retval = UA_STATUSCODE_GOOD;
done:
*stateOut = state;
Expand Down

0 comments on commit e94699c

Please sign in to comment.