请问如何快速刷新整列的状态数据:
我是循环改版图片状态,感觉没效率。
mainForm.lsvSwitch.setColumns({"名称","DO状态","DI状态"},{scale=true} , 1);
mainForm.lsvSwitch.addImg("SWON",$"\res\on.png")
mainForm.lsvSwitch.addImg("SWOFF",$"\res\off.png")
mainForm.lsvSwitch.setRowHeight(40);
mainForm.lsvSwitch.setHeaderHeight(30)
var t = {
{"通道1","<img name='SWOFF',x=3,y=2,w=90,h=40>","<img name='DIOFF',w=36,h=36>" }
{"通道2","<img name='SWOFF',x=3,y=2,w=90,h=40>","<img name='DIOFF',w=36,h=36>" }
{"通道3","<img name='SWOFF',x=3,y=2,w=90,h=40>","<img name='DIOFF',w=36,h=36>" }
{"通道4","<img name='SWOFF',x=3,y=2,w=90,h=40>","<img name='DIOFF',w=36,h=36>" }
{"通道5","<img name='SWOFF',x=3,y=2,w=90,h=40>","<img name='DIOFF',w=36,h=36>" }
{"通道6","<img name='SWOFF',x=3,y=2,w=90,h=40>","<img name='DIOFF',w=36,h=36>" }
{"通道7","<img name='SWOFF',x=3,y=2,w=90,h=40>","<img name='DIOFF',w=36,h=36>" }
{"通道8","<img name='SWOFF',x=3,y=2,w=90,h=40>","<img name='DIOFF',w=36,h=36>" }
{"通道9","<img name='SWOFF',x=3,y=2,w=90,h=40>","<img name='DIOFF',w=36,h=36>" }
{"通道10","<img name='SWOFF',x=3,y=2,w=90,h=40>","<img name='DIOFF',w=36,h=36>" }
{"通道11","<img name='SWOFF',x=3,y=2,w=90,h=40>","<img name='DIOFF',w=36,h=36>" }
{"通道12","<img name='SWOFF',x=3,y=2,w=90,h=40>","<img name='DIOFF',w=36,h=36>" }
}
mainForm.lsvSwitch.setTable(t,false);
mainForm.lsvSwitch.headerBkcolor = 0xE0E0E0;
//定时查询
mainForm.setInterval(
function(){
mainForm.lsvSwitch.redraw(true);
if (handle) {
//modbus读取数据
v = m.readHoldingRegisters(1,0,2)
//转二进制
strDO =string.format("%012b", tonumber(v[2],16))
strDI =string.format("%012b", tonumber(v[1],16))
//逆序
sDO=string.reverse(strDO,true)
sDI=string.reverse(strDI,true)
//这里循环12位长度字符,根据0和1刷新虚表中的图片状态
for (i = 1; 12; 1) {
mainForm.lsvSwitch.setCellImg(i,2,sDO[[i]] ="1" ? 'SWON':'SWOFF');
mainForm.lsvSwitch.setCellImg(i,3,sDI[[i]] ="1" ? 'DION':'DIOFF');
}
},1000
)