When a tag value changes, I need an image component to become visible. After five seconds, I need it to turn off. Please help!
1 Like
In the view custom properties of the view containing that image component, create a custom prop for the tag value (with binding to the tag), and another for the most recent change timestamp. In a change script attached to the custom prop for the tag value, make this assignment:
self.view.custom.tagChangedTS = system.date.now()
On the image component, bind to props.visible
with this expression:
now(500) < addSeconds({view.custom.tagChangedTS}, 5)
If you are using my Integration Toolkit, and want the expression to use no CPU time when inactive, use this variation:
transform(
asList(
now(0),
addSeconds({view.custom.tagChangedTS}, 5)
),
transform(
value()[0] < value()[1],
asList(
value(), // The real return boolean value
now(if(value(), 250, 0)) // Trick to make the expression poll when true
)[0]
)
)
( I hate leaving polling functions running uselessly, but I want them to run quickly when needed. )
1 Like