I am simply trying to copy the value of one memory tag to a different memory tag. This code works in the scripting console. I am able to write to a memory tag "P1UptimeBit" based on the tag "SPOOF Press 1 Line Speed". However, as soon as I copy it over to a Gateway Timer Event Script specified to fire every second, the tag no longer updates. Code below...
writevalue = system.tag.readBlocking(["[default]TEST/SPOOF Press 1 Line Speed"])
system.tag.writeBlocking(["[default]TEST/P1UptimeBit"], writevalue)
is a list of tags, even if it's a list of one. The [0] after it says the you want to get the qualified value at position 0. Things that you can iterate over start at an index of 0.
The .value at the end gets the value portion of the qualified value.
Hey Jordan - thanks for the quick reply. I copied that directly into the Gateway Event Script and still no luck. Your code runs in the Script Console as well... Dumb question - how do I get my code to show up formatted in the forum?
More than that, it's deliberate that you're allowed to pass qualified values through, in case you want to write an explicit quality code and/or timestamp to, say, a memory tag.
So did I inadvertently pass all of those parameters (quality, timestamp, value) to the memory tag - is that possible? ...or does Ignition make an assumption if a parameter is not specified?
You did. readBlocking() returns a list of QualifiedValues, in a 1:1 relationship with the paths passed in the list of TagPaths. writeBlocking() accepts a list of objects in a 1:1 relationship with the paths passed in the list of TagPaths. Those objects can be QualifiedValue objects.
If you wanted just the value attribute of the QualifiedValue then you would use code as @JordanCClark showed.