node-opcua icon indicating copy to clipboard operation
node-opcua copied to clipboard

Question: Alarms & Conditions HasNotifier and HasEventSource

Open AndreasHeine opened this issue 3 years ago • 0 comments

image027

Tank A from the picture!

    const tankA= namespace.addObject({
        browseName: 'TankA',
        organizedBy: addressSpace.rootFolder.objects,
        notifierOf: addressSpace.rootFolder.objects.server // skipped "Tank Farm" and "Area 1"
    })

    const myVar = namespace.addVariable({
        browseName: 'LevelMeasurement',
        componentOf: tankA,
        eventSourceOf: tankA, // "Tank A" -> HasEventSource -> "LevelMeasurement"
        dataType: DataType.Double
    })

    const ownConditionEventType = namespace.addEventType({
        browseName: 'ownConditionEventType',
        subtypeOf:  "ConditionType",
        isAbstract: false
    })

    const cond = namespace.instantiateCondition(ownConditionEventType, {
        browseName: 'MyCondition',
        conditionName: 'MyCondition',
        componentOf: tankA,
        conditionSource: tankA, // MySystemAlarmType (used a simple condition instead)
    })

    const ownEventType = namespace.addEventType({
        browseName: 'ownNonExclusiveLimitAlarmType',
        subtypeOf:  "NonExclusiveLimitAlarmType",
        isAbstract: false
    })

    const alarm = namespace.instantiateNonExclusiveLimitAlarm(ownEventType, {
        browseName: 'MyNonExclusiveLimitAlarm',
        conditionName: 'MyNonExclusiveLimitAlarm',
        componentOf: tankA,
        conditionSource: myVar, // "LevelMeasurement" -> HasCondition -> "MyNonExclusiveLimitAlarm" (just some alarm...)
        highHighLimit: 100,
        highLimit: 80,
        inputNode: myVar,
        lowLimit: 40,
        lowLowLimit: 20,
    })

Error: conditionSourceNode must be an event source 1:TankA ns=1;i=1010

Found in SourceCode: https://github.com/node-opcua/node-opcua/blob/9cfb90077559b8d7f817d5fe21156e5ee7c06789/packages/node-opcua-address-space/src/alarms_and_conditions/ua_condition_impl.ts#L908

Should an "HasNotifier" (SubType of "HasEventSource") also be in the array of "EventSources" returned by:

getEventSourceOfs(): BaseNode[]

it currently only checks "HasEventSource"! https://github.com/node-opcua/node-opcua/blob/9cfb90077559b8d7f817d5fe21156e5ee7c06789/packages/node-opcua-address-space/src/base_node_impl.ts#L500

My Workaround for now:

    const tankA= namespace.addObject({
        browseName: 'TankA',
        organizedBy: addressSpace.rootFolder.objects,
        eventSourceOf: addressSpace.rootFolder.objects.server // "eventSourceOf" instead of "notifierOf"
    })

AndreasHeine avatar Feb 19 '22 23:02 AndreasHeine