Get only the value in reading OPC tag

I have a script to read specific value of an OPC tag

currentVal = system.tag.readBlocking(event.source.parent.parent.PID.Meta.TagPath +'/SV')
print currentVal

and it output as:

[[23.0, Good, Thu Aug 31 12:41:11 SGT 2023 (1693456871880)]]

Now I wanna get only the value "23.0" on my array.
I tried this code: (I am using this before using python to get the first value of array)

currentVal = system.tag.readBlocking(event.source.parent.parent.PID.Meta.TagPath +'/SV')
print currentVal
print currentVal[0][0]

But I am having error:

Caused by: org.python.core.PyException: TypeError: 'com.inductiveautomation.ignition.common.model.values.BasicQualifiedValue' object is unsubscriptable
	... 45 common frames omitted

Anyone encountered this?
Or is there a way to get only the value in the ArrayList?

Thanks and Regards,

Solved!

currentVal = system.tag.readBlocking(event.source.parent.parent.PID.Meta.TagPath +'/SV')
print currentVal
print currentVal[0].getValue()

Reference:
https://files.inductiveautomation.com/sdk/javadoc/ignition80/8.0.0-beta/com/inductiveautomation/ignition/common/model/values/BasicQualifiedValue.html

This is also discussed in the user manual, which includes examples for accessing each component of the QualifiedValue: system.tag.readBlocking - Ignition User Manual 8.1 - Ignition Documentation

2 Likes

do you have to use .getValue, can't you just use .value?

you can

.value, that is, not .Value. Case matters.

4 Likes