Write to tag.EngUnit

ignition80
#1

Hi,

I have a script that works in 7.9 to write a new value into the EngUnit for a tag based on a boolean value.
When running it in 8.0 it won’t change the value for me. I ran the script in the script console to check and got this error.
Has something changed for writing to a tag property?

0 Likes

#2

What scripting function are you using? That looks more like an error indicating you’re not passing arguments into system.tag.write[blocking, async] correctly.

0 Likes

#3

The script i am running is from the UDT. I have pasted it below
system.tag"[.]../Engine Coolant Temperature" + ".EngUnit", "deg C")

0 Likes

#4

I think something went wrong with your paste.

It’s important to know which function you’re calling because some of them expect a list of tag paths and values, and the error you’re getting seems to indicate you’re calling one that expects a list but only providing a single value.

0 Likes

#5

Apologies.
system.tag.writeAsync("[.]../Engine Coolant Temperature"+".EngUnit", "deg C")

0 Likes

#6

Ok, so the docs show that it requires a list of tag paths and values.

You’d want something like this:

system.tag.writeAsync(["[.]../Engine Coolant Temperature"+".EngUnit"], ["deg C"])
0 Likes

#7

I have changed the script to reflect what you suggested.
it works for tag values but not for the .Engunit see below

system.tag.writeAsync(["[.]../Raw Data/Total Fuel Consumption - Conversion Factor"],[0.5])
system.tag.writeAsync(["[.]../Raw Data/Instantaneous Fuel Consumption - Conversion Factor"],[0.05])
system.tag.writeAsync(["[.]../Raw Data/Engine Oil Pressure - Conversion Factor"],[0.125])
system.tag.writeAsync(["[.]../Raw Data/Engine Coolant Temperature - Conversion Factor"],[0.03125])
system.tag.writeAsync(["[.]../Raw Data/Engine Coolant Temperature - Offset"],[-273])
system.tag.writeAsync(["[.]../Total Fuel Consumption" + ".EngUnit"],[ "l"])
system.tag.writeAsync(["[.]../Instantaneous Fuel Consumption" + ".EngUnit"], ["l/h"])
system.tag.writeAsync(["[.]../Engine Oil Pressure" + ".EngUnit"], ["kPA"])
system.tag.writeAsync(["[.]../Engine Coolant Temperature"+".EngUnit"], ["deg C"])
0 Likes

#8

Try using engUnit for the property name, like so:

system.tag.writeAsync(["MemoryTag1.engUnit"], ["deg F"])
0 Likes

#9

Tried but still no luck.

if currentValue.value == 1:
	             
system.tag.writeAsync(["[.]../Raw Data/Total Fuel Consumption - Conversion Factor"],[0.5])
system.tag.writeAsync(["[.]../Raw Data/Instantaneous Fuel Consumption - Conversion Factor"],[0.05])
system.tag.writeAsync(["[.]../Raw Data/Engine Oil Pressure - Conversion Factor"],[0.125])
system.tag.writeAsync(["[.]../Raw Data/Engine Coolant Temperature - Conversion Factor"],[0.03125])
system.tag.writeAsync(["[.]../Raw Data/Engine Coolant Temperature - Offset"],[-273])
system.tag.writeAsync(["[.]../Total Fuel Consumption.engUnit"],[ "l"])
system.tag.writeAsync(["[.]../Instantaneous Fuel Consumption.engUnit"], ["l/h"])
system.tag.writeAsync(["[.]../Engine Oil Pressure.engUnit"], ["kPA"])
system.tag.writeAsync(["[.]../Engine Coolant Temperature.engUnit"], ["deg C"])
	else:
system.tag.writeAsync(["[.]../Raw Data/Total Fuel Consumption - Conversion Factor"],[0.132086])
system.tag.writeAsync(["[.]../Raw Data/Instantaneous Fuel Consumption - Conversion Factor"],[0.0132086])
system.tag.writeAsync(["[.]../Raw Data/Engine Oil Pressure - Conversion Factor"],[0.01812975])
system.tag.writeAsync(["[.]../Raw Data/Engine Coolant Temperature - Conversion Factor"],[0.05625])
system.tag.writeAsync(["[.]../Raw Data/Engine Coolant Temperature - Offset"],[-459.67])
system.tag.writeAsync(["[.]../Total Fuel Consumption.engUnit"],["gal"])
system.tag.writeAsync(["[.]../Instantaneous Fuel Consumption.engUnit"], ["gal/h"])
system.tag.writeAsync(["[.]../Engine Oil Pressure.engUnit"], ["psi"])
system.tag.writeAsync(["[.]../Engine Coolant Temperature.engUnit"], ["deg F"])
0 Likes

#10

Exactly what happens when it doesn’t work? Is it the original error? Also, where is this script being run? Such as tag event script, gateway timer script, etc. I tried on a 8.0.4 nightly build with success, so knowing your exact Ignition version would help too.

0 Likes

#11

I have it on a check box in a UDT.
The conversion Factors are being written correctly just not the engUnit.
Our version is 8.0.4 nightly.

0 Likes

#12

Yeah, I can’t replicate any problems here with a UDT and updating the engUnit tag property. If you can export the project window and the UDT tags, you can post them either here or send them to Support. From there, we should be able to figure it out pretty quickly.

0 Likes

#13

The function works with memory tags. I tried even changing the engunits in the tag browser and it won’t work either. Is this a known problem.
I have attached the UDT to this.
tags.json (89.3 KB)

0 Likes

#14

Found a temporary fix for the issue.
The script will run ok when the override is ticked on the engunit in the instance.
Is this a bug? It worked without doing this in 7.9

0 Likes

#15

I also have this issue when trying to write to tooltip, documentation and engunit in the metadata within a UDT instance.

My code on a tag change:

tagValue = system.tag.read("[.]TagName")
toolTipText = tagValue.value +" - “+ currentValue.value
system.tag.write(”[.]…/PV.Tooltip",toolTipText)

Seems like 7.9 automatically put an override on the property when the script ran and version 8.03 does not.

Manually selecting override also works for me.

0 Likes

#16

This may have been fixed in the nightlies recently. As of today (8/23), I can write to a udt tag’s property and it will automatically create an override. My example worked with one udt instance but not a different one. I’ll have to keep digging.

0 Likes

#17

I have also found that in 8.0 a property must already have an override before I can write to it. Rather than checking boxes manually, I have been setting those overrides up programmatically via system.tag.configure().

1 Like