Script will not change tag value PLC to PLC. I know I have write enabled in PLCs and in gateway

def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):

Define the source and destination tag paths

source_tag_path = "[default]Line1/Data/L1_RoboticStacker/Ignition_Retract"
destination_tag_path = "[default]Line1/Data/L1_RoboticStacker/trg1"

Get the tag values

source_tag_value = system.tag.read(source_tag_path).value

Write the value to the destination tag

system.tag.write(destination_tag_path, source_tag_value)

I'll assume that this is for Ignition V8.1, and so you should be using the read* and write* functions as the ones that you have posted are deprecated.

That being said, everything that you show here should be correct "technically". This would indicate to me that something in the device is writing over your write or you have some other type of race condition. You should only ever write to a tag (PLC or Ignition) from one direction, doing otherwise will cause issues.

def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
    source_tag_path = ['[default]Line1/Data/L1_RoboticStacker/Ignition_Retract']
    destination_tag_path = ['[default]Line1/Data/L1_RoboticStacker/trg1']

    source_tag_value = system.tag.readBlocking(source_tag_path)[0].value
    system.tag.writeAsync(destination_tag_path, [source_tag_value])

Also, please use the preformatted text option to post code, makes it a lot easier to help and read your code.

1 Like

Levi, please read Wiki - how to post code on this forum.
Then please use the pencil link below your post to edit and fix it.
Thanks.

1 Like