I am using the Tag Historian option to log the data. On the Table, using Tag History binding, we can able to show the logged data. I need to add a filter which needs to works like ‘WHERE’ clause in SQL query.
Like the table should data of Particular column = ‘Some Value’.
The tag historian doesn’t offer that feature built-in. You will need to move the binding to a custom property and perform the filtering action yourself. You can do this with a script, but for convenience I recommend the view() expression function from my free Simulation Aids module.
You would bind the original table’s data property with an expression like this:
view("Select * Where someColumn==someConstant", {Root Container.path.to.custom.prop})
data = event.source.parent.TagHistoryData
data1= event.source.parent.getComponent(‘Power Table’)
row1=0
col1=0
for row in range(data.rowCount):
row1 = row
for col in range(data.columnCount):
col1 = col
value = data.getValueAt(row, col)
if value == event.source.parent.getComponent(‘MouldComboBox’).SelectedText:
system.dataset.addRows(data1.data, row1, value)
newData = system.dataset.setValue(data1.data, row1, col1, value)
data = event.source.parent.TagHistoryData
data1= event.source.parent.getComponent('Power Table')
row1=0
col1=0
for row in range(data.rowCount):
row1 = row
for col in range(data.columnCount):
col1 = col
value = data.getValueAt(row, col)
if value == event.source.parent.getComponent('MouldComboBox').SelectedText:
system.dataset.addRows(data1.data, row1, value)
newData = system.dataset.setValue(data1.data, row1, col1, value)
event.source.parent.getComponent('Power Table').data = newData
Here ‘TagHistoryData’ refers to Root container custom property, which is a dataset binding to Tag History.
Idk what you are all doing here but this seems quite wrong
try this
data = event.source.parent.TagHistoryData
newData = system.dataset.toDataSet(data.getColumnNames().toArray(),[])
for row in range(data.rowCount):
newRow = []
for col in range(data.columnCount):
value = data.getValueAt(row, col)
newRow.append(value)
if event.source.parent.getComponent('MouldComboBox').SelectedText in newRow:
newData = system.dataset.addRow(newData, newRow)
event.source.parent.getComponent('Power Table').data = newData