Assigning Event Handler (Set Point) output to multiple targets
-
Curious if its also possible to assign the output of an event handler set point to multiple target points via json?
-
Hi Wingnut2.0,
Sort of. It isn't possible using the return value, but you could add the points to context on the handler and do something like,
for ( var varName in CONTEXT_POINTS ) { if("source" == varName) continue; this[varName].set(source.value); } return UNCHANGED; //don't set a value to the "target" point here, we already did
And you could change up the context points via JSON (not sure how the JSON portion tied in).
-
Thanks Phillip.
In your response here https://forum.infiniteautomation.com/topic/3282/assigning-event-handlers you mentioned making the change in the JSON to have multiple points reference a single event handler.
"eventTypes":[ { "sourceType":"DATA_POINT", "dataPointXID":"DP_1234", "detectorXID":"ED_1234" } ]
I didnt know if the same approach might work by adding multiple target points in the JSON of the event handler
"targetPointId":"DP_pointOne, "targetPointId":"DP_pointTwo,
-
That enables one to handle multiple event types with the same event handler, not only point event detector event types. There is not a way through the UI to configure that sort of situation yet, but you can import it already and it'll work. It would be many-events-to-single-handler instead of single-handler-to-many-points.
Looping over points and using the set() function is the only way to set multiple values from a set point handler. You can still construct the context (which should work automatically with the snippet I shared) through JSON via the
"additionalContext"
property of the set point handler.