Hi,
When using scrip console to create a tag with custom properties, how do you set the datatype of the custom property?
It seems like if I pass a string as value the datatype automatically sets to unicode. And if I pass a number as value the datatype automatically sets to float. But what if I want it to be an integer?
It’s probably not important, I’d just like to know
provider = '[SCADA]'
tagpath = provider+'test'
tagname = 'tag_prop_test'
tagtype = 'Float4'
enabled = True
ro = False
val = 999
tag = {}
tag.update(name = tagname)
tag.update(valueSource = 'memory')
tag.update(dataType = tagtype)
tag.update(enabled = True)
tag.update(readOnly = ro)
tag.update(value = val)
tag.update(Trend_Data = int(9)) # the custom parameter, typecasting doesn't seem to work?
print "Initial config ", system.tag.configure(tagpath,[tag],'o'), tagpath, tagname
t1 = system.tag.readBlocking(tagpath+'/'+tagname+'.Trend_Data')[0].value
print "Read tag value and datatype ", t1, type(t1)
# get config -> change datatype of custom parameter -> write back the changed config.
# --> datatype still float idstead of int?
c1 = system.tag.getConfiguration(tagpath+'/'+tagname, 0)[0]
print "Read tag config value and datatype ", c1['Trend_Data'], type(c1['Trend_Data'])
c1['Trend_Data'] = int(9)
#c1['Trend_Data'] = None # remove the custom parameter
print "Changed config value and datatype ", c1['Trend_Data'], type(c1['Trend_Data'])
print "Write back changed config ", system.tag.configure(tagpath, c1, 'o')
t1 = system.tag.readBlocking(tagpath+'/'+tagname+'.Trend_Data')[0].value
print "Read updated tag value and datatype ", t1, type(t1)
Thanks