I am experiencing some lagginess (scrolling is not smooth) when scrolling the table on Ignition client panel while the dataset that the table is being binded to is being updated at the same time. Would like to understand what causes the scrolling to be laggy, whether its due to the way Ignition power table is loading data from dataset issue.
Are you using the configureCell extension method? Are you calling any external resources in that method?
Yes, i am using configureCell extension method to map certain value.
What are external resources referred to?
Will the codes in configureCell extension method cause the scrolling to lag when an update to the dataset is ongoing?
Below is a snippet of the code under configureCell:
if system.tag.readBlocking(['[System]Client/System/SystemFlags'])[0].value >= 3:
# strTooltipValue = self.data.getValueAt(rowIndex, 'REMARKS')
# This example adds alternating background color:
if selected:
if colIndex == 4:
if value == "D":
valueNew = "DI"
valueText = value
elif value == "L":
valueNew = "LO"
valueText = value
return {'background': '#281C08','foreground': '#FF8232', 'text':valueText, 'toolTipText':valueNew}
if colIndex == 2:
return {'background': '#281C08','foreground': '#FF8232', 'text':value, 'toolTipText':value}
elif colIndex == 8:
return {'background': '#281C08','foreground': '#FF8232', 'text':value, 'toolTipText':value}
elif colIndex == 20:
return {'background': '#281C08','foreground': '#FF8232', 'text':value, 'toolTipText':value}
elif colIndex == 24:
return {'background': '#281C08','foreground': '#FF8232', 'text':value, 'toolTipText':value}
elif colIndex == 25:
return {'background': '#281C08','foreground': '#FF8232', 'text':value, 'toolTipText':value}
else:
return {'background': '#281C08','foreground': '#FF8232', 'text':value}
else:
if colIndex == 4:
if value == "D":
valueNew = "DI"
valueText = value
elif value == "L":
valueNew = "LO"
valueText = value
return {'background': '#041D2B','foreground': '#6FCCFF', 'text':valueText, 'toolTipText':valueNew}
if colIndex == 2:
return {'background': '#041D2B','foreground': '#6FCCFF', 'text':value, 'toolTipText':value}
elif colIndex == 8:
return {'background': '#041D2B','foreground': '#6FCCFF', 'text':value, 'toolTipText':value}
elif colIndex == 20:
return {'background': '#041D2B','foreground': '#6FCCFF', 'text':value, 'toolTipText':value}
elif colIndex == 24:
return {'background': '#041D2B','foreground': '#6FCCFF', 'text':value, 'toolTipText':value}
elif colIndex == 25:
return {'background': '#041D2B','foreground': '#6FCCFF', 'text':value, 'toolTipText':value}
else:
return {'background': '#041D2B','foreground': '#6FCCFF', 'text':value}
return {'horizontalAlignment':0}
{'verticalAlignment':1}
Don’t use any system.tag.* or system.alarm.* or system.db.* functions (anything that makes a round trip to the gateway). Instead, bind the needed values to custom properties of the table, so you can reference them as self.propName
in the configureCell script. That script gets called for every cell in the table, plus more when cells have to be re-drawn (like scrolling into view). That script must execute in a tiny fraction of a millisecond when there are thousands of cells.
do u mean we should not be using this line of code here?
if system.tag.readBlocking([’[System]Client/System/SystemFlags’])[0].value >= 3:
not in the configureCell yes.
if you create a custom prop and then reference that instead it should go smoother.
The codes shall run in the custom property tag event script?
no
you leave everything where it is expect
system.tag.readBlocking(['[System]Client/System/SystemFlags'])[0].value
will turn into
self.yourVariableName
and create a custom variable yourVariableName
with an expression binding to [System]Client/System/SystemFlags
This way you only read on the tag value there and not for every single cell
why by creating a custom variable helps to ensure “This way you only read on the tag value there and not for every single cell” ?
system.tag.readBlocking() = “long” read gateway
self.prop = “fast” read own props
tagBinding = async “long” read every x amount of time to the gateway
if system.tag.readBlocking() in configureCell
==> number of cells * “long” read ==> lag
if self.prop in configureCell
1 async “long” read every x amount of time to the gateway => no impact on scrolls/redrawn unless it changes
=> (number of cells * “short” read ) ==> no lag (hopefully)
This is pretty much the same as comparing this
for i in range(100):
x = long_operation()
and
preprocessed_result = long_operation()
for i in range(100):
x = preprocessed_result
In the first case, you run the long operation a hundred times,
in the second case you run it only once and use the result a hundred times.