Finding data type of Tag Path

Hi,

I am getting tag path from dataset column, then storing it to a variable.

data = event.source.data
tagPath = data.getValueAt(ClickedItem, “tagPath”)

For Eg. Value in tagPath variable will be like Pumps/Motor 1
Now I need to check that datatype tagPath variable (which has tag path).
Then I need to check that tagPath variable (which has tag path) is UDT or not?

tried few option like system.tag.read, system.tag.browseConfiguration & system.tag.browseTags but I was unsuccessful.

Hopefully Thank you.

It looks like system.tag.browseConfiguration() has what your looking for.

The example at the bottom of the link shows how to check the tag type.

Hi,

I tried this, It gives data type for all the sub tags comes under the provided path.

tagPath = data.getValueAt(ClickedItem, “tagPath”)
browsePath = system.tag.browseConfiguration(tagPath , False)

the above code gives tagPath for all its sub tags.

I want the data type of the provided path not its sub tags.
as i explained earlier my tagPath variable will be having value like "Pumps/Motor 1" (which will UDT mostly, some times it may not UDT also. This path is what I need to validate.)

I need to check that datatype tagPath variable (which has tag path)
I need to check that tagPath variable (which has tag path) is UDT Instance or not?

Thanks,

If you want the DataType

system.tag.read("path/to/tag.DataType").value

If you want TagType

from com.inductiveautomation.ignition.common.sqltags.model.types import TagType
v = system.tag.read("path/to/tag.TagType").value
print TagType.getTypeForValue(v)

4 Likes

Thanks a lot, Its Working.

along with it I was also trying the following code.

config = system.tag.read(assetTagPath + ".TagType").value
print config

It gave me a output @console

10

I searched for online help document, But, I couldn't able to figure out what does this 10 refers to?

from com.inductiveautomation.ignition.common.sqltags.model.types import TagType
v = system.tag.read("path/to/tag.TagType").value
print TagType.getTypeForValue(v)
1 Like

Thanks a lot, Kyle.
for your Immediate response.
I got what I was expecting.

Hi @Kyle_Chase , How can I find data type for multiple tags, can you share the syntax for it please

If i understood you correctly, seems like you just need a list and a for loop.

tagList = ["New Folder/New Tag.dataType",
		   "New Folder/New Tag 1.dataType",
		   "New Folder/New Tag 2.dataType"]
for tag in tagList:
	v = system.tag.read(tag).value
	print v

If you're using Ignition 8.0+, you should use system.tag.readBlocking() or system.tag.readAsync() instead of system.tag.read().

tagList = ["New Folder/New Tag.dataType",
		   "New Folder/New Tag 1.dataType",
		   "New Folder/New Tag 2.dataType"]
tagValues = [tag.value for tag in system.tag.readBlocking(tagList)]
for dataType in tagValues:
	print dataType
1 Like

Thanks a lot for your time and efforts @leonardo.godoi for solving my query, Is there any possibility to read the dataType for all the tags. I am currently working on resetting all the tag values to zero irrespective of its data type. I am facing some difficulties can you help me with some logic please

@Vijay, this is a duplicate of your own thread, Reset tag values to zero. Please don't post twice about the same problem but you could have added a link in this post to your new question. (I have now done it so no further action is required.)