modified status to array
This commit is contained in:
parent
2539869100
commit
f0b89580fd
@ -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)}};
|
||||
}
|
||||
|
||||
|
||||
|
12
res/cfg.json
12
res/cfg.json
@ -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};"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user