First time doing a tag script
Vision
Version: 8.1.17
Background: I have AB PLC’s 5, 500 and 5000 that will all need to have the clock synced to within a few seconds. I want the following tag to be a “call” from the PLC’s at first scan then I will run it every hour to keep time.
I can toggle the plc and see the tag go true and I can set numbers in the write tag and see them change in the plc. The Gateway_Seconds tag is showing seconds. Can’t figure out what I am doing wrong or where to look to figure it out.
I have a Bool UDT from a plc with the following script.
def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
“”"
Fired whenever the current value changes in value or quality.
Arguments:
tag: The source tag object. A read-only wrapper for obtaining tag
properties.
tagPath: The full path to the tag (String)
previousValue: The previous value. This is a "qualified value", so it
has value, quality, and timestamp properties.
currentValue: The current value. This is a "qualified value", so it has
value, quality, and timestamp properties.
initialChange: A boolean flag indicating whether this event is due to
the first execution or initial subscription.
missedEvents: A flag indicating that some events have been skipped due
to event overflow.
"""
gatesec = system.tag.readBlocking("[default]Gateway_Seconds")[0].value
if currentValue.value == true:
system.tag.writeBlocking(["[.]Clock Second Write"],["gatesec"])