Thanks for the help,
i am confused with
# Define a list of incomplete test values for various component types
testList = ['0', '', 'False']
The script i used in the project:
LogBookCanvas:
def generate_templates(category, enable_value, batch, process, offset_value=0):
columnNames = ["name", "template", "parameters", "x", "y", "width", "height", "layout", "z"]
new_tmp = []
fields_query = """
SELECT f.FieldName as ParamName, ft.field as Template, c.Category as Category
FROM tbl_fieldmaster f
JOIN tbl_fieldtypemaster ft ON ft.ID = f.FieldType
JOIN tbl_categorymaster c ON c.ID = f.Category
WHERE f.ProcessArea = ? AND f.Category = ?
ORDER BY _id;
"""
fields = system.db.runPrepQuery(fields_query, [process, category], "db")
for row in range(fields.getRowCount()):
paramName = fields.getValueAt(row, "ParamName")
template = fields.getValueAt(row, "Template")
value_query = """
SELECT l.ObservedValue as Value, f.FieldName as ParamName
FROM tbl_logbookentry l
JOIN tbl_fieldmaster f ON f._id = l.Parameter
JOIN tbl_fieldtypemaster ft ON ft.ID = f.FieldType
JOIN tbl_categorymaster c ON c.ID = f.Category
WHERE f.ProcessArea = ? AND f.Category = ?
AND l.OrderNumber = ?
"""
value_result = system.db.runPrepQuery(value_query, [process, category, batch], "MES_CDCMS")
paramValue = ""
for row in range(value_result.getRowCount()):
if value_result.getValueAt(row, "ParamName") == paramName:
paramValue = value_result.getValueAt(row, "Value")
break
enable = 1
xPosition = 10
yPosition = (row * 25) + 10
width = 230
height = 25
newRow = [
paramName, # name
"LogBook/" + template, # template
'{"paramName":"' + paramName + '","paramValue":"' + paramValue + '","enable":"' + str(enable) + '"}', # parameters
xPosition, # x
yPosition, # y
width, # width
height, # height
"n/a", # layout
0 # z
]
new_tmp.append(newRow)
new_tmp2 = system.dataset.toDataSet(columnNames, new_tmp)
return new_tmp2
And on vision opened event:
iProcess = system.gui.getParentWindow(event).getComponentForPath('Root Container').iProcess
iBatch = system.gui.getParentWindow(event).getComponentForPath('Root Container').iBatchNo
new_tmp1 = LogBookCanvas.generate_templates(1, 1, iBatch, iProcess) # Category 1
new_tmp2 = LogBookCanvas.generate_templates(2, 1, iBatch, iProcess) # Category 2
new_tmp3 = LogBookCanvas.generate_templates(3, 1, iBatch, iProcess) # Category 3
system.gui.getParentWindow(event).getComponentForPath('Root Container.Template Canvas_1').templates = new_tmp1
system.gui.getParentWindow(event).getComponentForPath('Root Container.Template Canvas_2').templates = new_tmp2
system.gui.getParentWindow(event).getComponentForPath('Root Container.Template Canvas_3').templates = new_tmp3