mz-automation / libiec61850

Official repository for libIEC61850, the open-source library for the IEC 61850 protocols
http://libiec61850.com/libiec61850
GNU General Public License v3.0
857 stars 459 forks source link

IedServer_updateAttributeValue function call question #306

Open black0592 opened 3 years ago

black0592 commented 3 years ago

Shouldn't the checkForUpdateTrigger function be called only when the values are different? How to understand this? Why do I need to call update for the same value

void IedServer_updateAttributeValue(IedServer self, DataAttribute dataAttribute, MmsValue value) { assert(self != NULL); assert(dataAttribute != NULL); assert(MmsValue_getType(dataAttribute->mmsValue) == MmsValue_getType(value));

if (MmsValue_equals(dataAttribute->mmsValue, value))
    **checkForUpdateTrigger**(self, dataAttribute);
else {

    if (dataAttribute->type == IEC61850_BOOLEAN) {
        /* Special treatment because of transient option */
        IedServer_updateBooleanAttributeValue(self, dataAttribute, MmsValue_getBoolean(value));
    }
    else {

if (CONFIG_MMS_THREADLESS_STACK != 1)

        Semaphore_wait(self->dataModelLock);

endif

        MmsValue_update(dataAttribute->mmsValue, value);

if (CONFIG_MMS_THREADLESS_STACK != 1)

        Semaphore_post(self->dataModelLock);

endif

        checkForChangedTriggers(self, dataAttribute);
    }
}

}

mzillgith commented 3 years ago

There are some data attributes that have "dupd" (update) trigger conditions. These can cause a report when updated. But most attributes only have "dchg" (change) trigger conditions. It is up to your application if you update the attributes with "dchg" only when the value changes or whenever you do the update.