Change the Value of tag using time slicing


I was wondering if there is a way of doing time slicing. I have a button and on action I want the current time saved in a memory tag and but clicking it again I want it to store the time stamp in another memory tag. I am trying to get the start and end times.

In computer terms, “time slicing” is something else entirely. What you describe is more like a stopwatch function. Use a custom property on your button to hold a “Started” boolean. Your button’s action performed script would then be something like this:

if event.source.Started:
    event.source.Started = False
    event.source.Started = True

You can use this boolean to also drive styling of your button so it is obvious when the timer is running. If you need to be able to operate this setup from multiple clients, or with window open/close in between, create another tag in the gateway to hold the boolean and bind it bidirectionally to the custom property.

1 Like