I want the memory tag to count from 1 to 1200 when the one button is clicked in View A. This memory tag will be binded to label component in View B.
I tried to execute this in memory tag, but not working,
counter = system.tag.readBlocking(["[~]counter_tag"])
counter = counter + 1
system.tag.writeBlocking(["[default]My/Tag/counter"],["counter"])
Read blocking will return a list of tag objects, to get the value of the first (and only) tag you should
counter = system.tag.readBlocking(["[~]counter_tag"])[0].value
if counter >= 1200:
counter = 1
else:
counter += 1
system.tag.writeBlocking(["[default]My/Tag/counter"],[counter])
You also seem to be writing a string as the value, and not the variable counter
1 Like
Thank you for your reply. Need a clarity how it will update continuously when I click one button in View A.
A computer can count from 1 to 1200 EXTREMELY fast... It's likely you won't see anything but 1200.
Do you want to count 1200 seconds?
Do you want this to be on a per-client basis? i.e. each client can have a different timer?
If global, you want to set the datetime you press the button in a memory tag, then in an expression memory tag, use the expression:
if(isNull({date/tag}), -1, secondsBetween({date/tag}, now(1000))) // these might be the wrong way around, I always swap them...
To stop it, use an on value change event on the counter tag to set the date tag value to None if its value is > 1200. If you want it to reset after 1200 that is.
If you want it client based, I'd use sessions props to do the same thing
3 Likes
Thankyou for your reply. Will workout and update
This and your other timer questions should really be handled by the PLC. I think you are building a fragile system that will break.
I didn't see the other timer questions, but if this is for control, certainly what @Transistor says is a must. SCADA is not for process control logic