-
Notifications
You must be signed in to change notification settings - Fork 0
/
tester01.html
216 lines (189 loc) · 5.97 KB
/
tester01.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
<html>
<!--
USER frontend for TESTERBATTERY01 - battery decharger
Requires:
IotWebUI 2.2, REST2.2, HW, CLONER01 e TESTERBATTERY01 installati e funzionanti.
Più
inc/restget.js
inc/iotwidget01.js
inc/iotwidget01.css
inc/iotwidget02
sfondo_tb.png
red_light_32x32.png
green_light_32x32.png
onbutton.png
-->
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- REQUIRED all javascript procedures to handle widgets -->
<script type="text/javascript" src="inc/restget.js"> </script >
<script type="text/javascript" src="inc/iotwidget01.js"> </script >
<!-- REQUIRED by iotwidget02 -->
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript" src="inc/iotwidget02.js"> </script >
<!-- REQUIRED Stylesheet by iotwidget01 and to use same icons as IoTwebUI -->
<link rel = "stylesheet" href ="http://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" >
<link rel = "stylesheet" href ="inc/iotwidget01.css" >
<style>
/* ======= USER PAGE DEFAULTS */
:root {
--button-width: 150px;
--button-height: 50px;
}
.butzone {
width: var(--button-width);
}
table {
border-collapse: collapse;
border: none;
}
/* defaults from iotwidget01.css: customizable look for this page
note: colors custumizable also in widget definition
*/
.hover .tooltip {
border-radius: 5px;
padding: 5px;
font: 10px Arial, sans-serif;
background-color: black;
color: #fff;
border-radius: 5px;
}
.value {
color:black;
font-size:14px;
}
.bigvalue {
color:Blue;
font-size:20px;
}
.bigbutton {
border-radius:5px;
font-weight: bold;
}
.imgbutton {
border-radius:5px;
font-weight: bold;
}
/* for iotwidget02 - extra local style */
.signal{
width: 32px;
height: 32px;
background-color: transparent;
border: none ;
}
.switch{
width: 80px;
height: 40px;
background-color: transparent;
border: none ;
}
</style>
<script type="text/javascript">
// ===== THIS PAGE WIDGET DEFINITIONS
const baseURL = 'http://localhost:3031/IoTrest/';
const RESTINTERVAL = 911; // (prime number)
const LOOPINTERVAL = 29311; // prime number
// list of dynamic widgets in the page: adjust xpos, ypos
// nota: widget[x].id must be unique!
const widgets = [
{ id :"CHART",
xpos : 0, // verticale
ypos : 0, // orizzontale
type : "linechart",
devId: "BatteryTest",
code : "smoot",
tiplabel: 'tension',
maxPoint: 300,
// instance options are merged with default options in iotwidget02
// for info https://developers.google.com/chart/interactive/docs/gallery/linechart (english version)
options: {
vAxis:{minValue: 0.8},
title: 'Tuya Battery tester v. 1.0',
},
},
{ id : "LED",
xpos : 246, // verticale
ypos : 534, // orizzontale
type : "signal",
devId: "BatteryTest", // for value: device ID
code : "step", // for value: status code
dataOK:["running"],
on: {
image:"red_light_32x32.png",
},
off: {
image:"green_light_32x32.png",
},
},
{ id :"TXT",
xpos : 250, // verticale
ypos : 580, // orizzontale
type : "bigvalue", // icon, icotip, value, bigvalue, bigbutton, imgbutton
devId: "BatteryTest", // for value, bigvalue: device ID
code : "step", // for value, bigvalue: status code
},
{ id : "BUTGO",
xpos : 20, // verticale
ypos : 534, // orizzontale
type : "imgbutton", // icon, icotip, value, bigvalue, bigbutton, imgbutton
image:"onbutton.png", // for imgbutton
text : "CLEAR", // for imgbutton, bigbutton: button text
scenerule: "start batterytest", // for imgbutton, bigbutton: scene|rule name
color: 'Blue', // for imgbutton, bigbutton: optional, default in CSS
},
{ id :"BUTSTOP",
xpos : 188, // verticale
ypos : 534, // orizzontale
type : "bigbutton", // icon, icotip, value, bigvalue, bigbutton, imgbutton
background: "#AFEEEE", // default in cs
text : "TEST OFF", // for imgbutton, bigbutton: button text
scenerule: "stop batterytest" // for imgbutton, bigbutton: scene|rule name
},
{ id :"METER",
xpos : 71, // verticale
ypos : 552, // orizzontale
type : "gauge", // icon, icotip, value, bigvalue, bigbutton, imgbutton
label: "[mAh]",
devId: "BatteryTest", // for value, bigvalue: device ID
code : "charge", // for value, bigvalue: status code
// instance options are merged with default optons in iotwidget02
// for info https://developers.google.com/chart/interactive/docs/gallery/gauge (english version)
options: {
width: 120,
height: 120,
min : 0,
max : 3000,
majorTicks :["0","1000","2000","3000"],
minorTicks: 5,
// redFrom:0,
// redTo: 1200,
yellowFrom:1200,
yellowTo: 2000,
yellowColor: '#E4E866',
greenFrom:2000,
greenTo: 3000,
greenColor: '#53E53E',
},
},
]
// for button local
function hook(widgetId, action = null){
if (widgetId == "BUTGO"){ // clear the graph
widgets[0]['clear'] = true;
}
// console.log('HOOK ' + widgetId + action);
};
</script>
<!-- ============= PAGE ============= -->
</head>
<body bgcolor="#DBD396" onload="startup()"> <!-- background color -->
<table><tr><td>
<img src="sfondo_tb.png" width="500" alt="home" border="0"> <!-- background image -->
</td><td class='butzone'> <!-- gets place for buttons -->
</td></tr></table>
<hr>
<div id="dynamic"> </div> <!-- dynamic widget division -->
<div id="output"> </div> <!-- only for tests -->
</body>
</html>