system.tag.writeBlocking vs system.tag.configure

I have the need to modify tag properties via scripting (override UDT definition), I have noticed that I can do it 2 different ways, one with system.tag.writeblocking and also with system.tag.configure.

For example, I want to change a tag to be expresion type and set the expression, I can use any of the options below.

system.tag.configure

tag = {
            "name": "Valve_Open_DI",           
            "valueSource": "expr",
			"expression": "{[.]Close_Valve_DO}"
        }
 
system.tag.configure("[default]TestValve", [tag], "o")

system.tag.writeblocking

system.tag.writeBlocking("[default]TestValve/Valve_Open_DI.valueSource", "expr")
system.tag.writeBlocking("[default]TestValve/Valve_Open_DI.expression", "{[.]Close_Valve_DO}")

Is there any advantage or disadvantage between them?

Would the answer be different if I apply this to the UDT itself ("[default]types/SomeUDT")

Thanks in advance!
Greg

As a rule of thumb:

  • If you have one property to change, just use a write.
  • If you have more than one property (or tag!) to change, and/or you want "atomicity" of your configuration change, use configure.

Ultimately, it goes through basically the same mechanism; the write will create a configuration change and apply it using the same mechanism. But it's a bit easier to set up (I would argue) a write for a simple property change, if you know for a fact it's going to be an overwrite and there's no need for the extra functionality configure gives you.

5 Likes

@PGriffith,
I try to override the documentation prop of a tag.
I can't use tag.writeBlocking because my tag is ReadOnly, so tag's builtin props can't be modified with tag.writeBlocking.

My tag has multiple prop overrided.

The following script works well.
It override only the documentation property.

path = "[default]path/to/folder"
collisionPolicy = "m"
tags = [{"name" : "MY_TAG", "documentation" : "new doc"}]
print system.tag.configure(path, tags,collisionPolicy)

But I want to remove the override for only the doc property.
I've tried the following script

path = "[default]path/to/folder"
collisionPolicy = "m"
tags = [{"name" : "MY_TAG", "documentation" : None}]
print system.tag.configure(path, tags,collisionPolicy)

but it doesn't works

if I use:

path = "[default]path/to/folder"
collisionPolicy = "o"
tags = [{"name" : "MY_TAG"}]
print system.tag.configure(path, tags,collisionPolicy)

All overrided prop are removed.

I would like to obtain the same action by script when I click on the green ball to remove the change for the documentation

Use system.tag.getConfiguration, remove the unwanted prop, then feed the results into system.tag.configure.

I didn't try, but I'd expect it to do what you need.

It doesn't works, It will put some overrides on all properties...

That's what getLocalConfiguration was meant for

1 Like