We are working on translating our scripts from ignition7x to Ignition8 and we have troubles finding an alternative to gettag datatype in a gateway script.
Currently when a tag changes we get the value and datatype and trigger a call, but it seems its no longer available in Ignition8.
Current call to get Datatype that works in Ignition7
currentvalue = newValue.getValue()
currentquality = newValue.getQuality()
tagpath = event.getTagPath()
datatype = event.getTagPath().getdataType()
for the datatype we get an error
'com.inductiveautomation.ignition.common.tags.paths' object has no attribute 'getdataType'
I know you can get the datatype using a tag read, but I’m not sure if if you can get the type from the event object.
datatype = system.tag.read(tagpath + '.dataType')
Did .getdataType()
ever work? I would have expected it to be getDataType()
- notice the capitalization.
2 Likes
@PGriffith you are right, there is a typo in the code pasted here, still doesn’t work in Ignition 8 after correcting it.
Complete testing code.
try:
logger = system.util.logger("OnTagChange")
currentvalue = newValue.getValue()
currentquality = newValue.getQuality()
tagpath = event.getTagPath()
datatype = event.getTag().getDataType()
logger.info(str(tagpath) +' ' + str(currentvalue) + ' ' + str(datatype))
except Exception, ex:
logger.error(str(ex.message))
In the log below, firts I remove the datatype row and its corresponding part in the log, it prints the tagpath + value in the log, then I add it back and get the error.
Thanks @bmusson
this did the trick, not as simple as the original, not sure if this can be simplified somehow.
datatype = system.tag.read(str(tagpath) + '.dataType').value
1 Like