13.07.2022, 06:20
Use this example. It also handles sub-datatypes which don't have a dt table entry (e.g. 01.011 -> dt.bool).
Code:
mapping = {}
for key, value in pairs(dt) do
mapping[ value ] = 'dt.' .. key
end
obj = grp.find('1/1/2')
dpt = obj.datatype
if dpt then
dtname = mapping[ dpt ]
if not dtname and dpt >= 1000 then
dtname = mapping[ math.floor(dpt / 1000) ]
end
end
log(dtname)