modified status to array

This commit is contained in:
murmur 2024-06-30 18:17:33 +08:00
parent 2539869100
commit f0b89580fd
2 changed files with 8 additions and 7 deletions

View File

@ -116,8 +116,9 @@ udpSend = function(d){
getStatus = function(){
//-1:未上电 0:离线 1:在线
var seed = string.random("Success","Fault","PowerDown")
return {state=seed};
return {state={math.random(-1,1),math.random(-1,1),math.random(-1,1)}};
}

View File

@ -182,10 +182,10 @@
"data": {
"maxBarCnt":"60",
"items": [
{"color": "#808080"},
{"color": "#808080"},
{"color": "#808080"},
{"color": "#808080"},
//{"color": "#808080"},
//{"color": "#808080"},
//{"color": "#808080"},
//{"color": "#808080"},
]
},
"body": [
@ -194,7 +194,7 @@
"name": "items",
"items": {
"type": "tpl",
"tpl": "<div style='width: 3px; height: 50px; border-radius: 2px; background-color: ${color}; box-shadow: 0 0 5px ${color}, 0 0 10px ${color} inset' title='${state}'></div><br><div style='width: 3px; height: 50px; border-radius: 2px; background-color: ${color}; box-shadow: 0 0 5px ${color}, 0 0 10px ${color} inset' title='${state}'></div>",
"tpl": "<div style='width: 3px; height: 50px; border-radius: 2px; background-color: ${color[0]}; box-shadow: 0 0 5px ${color[0]}, 0 0 10px ${color[0]} inset' title='${state}'></div><br><div style='width: 3px; height: 50px; border-radius: 2px; background-color: ${color[1]}; box-shadow: 0 0 5px ${color[1]}, 0 0 10px ${color[1]} inset' title='${state}'></div><br><div style='width: 3px; height: 50px; border-radius: 2px; background-color: ${color[2]}; box-shadow: 0 0 5px ${color[2]}, 0 0 10px ${color[2]} inset' title='${state}'></div>",
"style": {
"display": "inline-block",
"marginRight": "5px",
@ -208,7 +208,7 @@
"actions": [
{
"actionType": "custom",
"script": "const colorMap={'Success':'#00ff00','Fault':'#ff0000','PowerDown':'#808080'};\n const ncolor = colorMap[event.data.responseData.state];\n console.log(event.data.responseData.state,ncolor);\ncontext.props.data.items.push({'color':ncolor})\nif (context.props.data.items.length > context.props.data.maxBarCnt) {\n context.props.data.items.shift(); // Remove the oldest value\n};"
"script": "const colorMap=['#808080','#ff0000','#00ff00'];\n const ncolor = [colorMap[event.data.responseData.state[0]+1],colorMap[event.data.responseData.state[1]+1],colorMap[event.data.responseData.state[2]+1]];\n console.log(event.data.responseData.state,ncolor);\ncontext.props.data.items.push({'color':ncolor})\nif (context.props.data.items.length > context.props.data.maxBarCnt) {\n context.props.data.items.shift(); // Remove the oldest value\n};"
}
]
}