I have been using the script from the exchange to extract all the tag values from my udt tag see pic(3), and would like to have my float values included as well see Pic (1) if "[" "]" not added to the append statement for the var newData.
I not sure whether this is only related to the ",." issue
We use "," as decimal separator
If I put square bracket around [newData] when appending works fine however my result requires extra handling which I would like to avoid.
Any good ideas, try to fix it in the script or move the handling of the different data types to the view when presenting them ?
See picture (2) below from Perspective view.
def getAllTheTagz(udtPath):
tagPaths = [tag.fullPath for tag in system.tag.browseTags(parentPath = udtPath, recursive = True ) if not tag.isFolder() and not tag.isUDT() ]
print tagPaths
_results = system.tag.readAll(tagPaths)
var = 1.1
theTagz = {}
theTagy =[]
headers =["Tag Name","Value"]#,"Last Ok"]
today = system.date.now()
for i in range(len(tagPaths)):
newDataType = type( _results[i].value)
if newDataType == type(1) or newDataType == type(var) or newDataType == type("string") or newDataType == type(False) or newDataType == type(today):
newData = _results[i].value
#print i,str(tagPaths[i][len(udtPath):]),newData, type(newData)
theTagy.append([str(tagPaths[i][len(udtPath):]),newData])
#theTagy.append([str(tagPaths[i][len(udtPath):]), _results[i].value])
myRecipieValues = system.dataset.toDataSet(headers, theTagy)
return myRecipieValues #theTagy
You cant make a dataset with different types so this whole function doesnt work tbh.
You should not return it as dataset, just as ("json") object array.
The table can display that too
Actually, you can specify java.lang.Object as a column type, then you can put anything in the column. But a json list of mappings is better for a Perspective table.
That did work very well,
Any idea to create a style for formatting based on the result from isinstance unless it straight forward to build some logic after the value field
Would like to swap "," and "." and maybe do some formatting on the Boolean
You might be forced to bind the format string of the column against the session locale and then use a Map transform within the binding. Also, make sure the field property for the column config is pointing to the desired column in your data.