-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy patheb3-script.js
273 lines (248 loc) · 3.05 KB
/
eb3-script.js
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
>D 48
ver=20043
EBx="EB3"
C="Net."
date=""
time=""
clk=""
old=""
wfc=""
wfp=0
cnt=0
wtd=0
hh=0
mm=0
ss=0
thh=0
tmm=0
;
m:ipwrm=0 50
m:epwrm=0 50
ipwr=0
epwr=0
strm="cnt0"
fheap=0
;
p:ikw=0
p:ekw=0
fr=0
res=0
;
lp1y=0
lp1m=0
lp1d=0
lp1hh=0
lp1mm=99
lp1gmt=""
lp3i=0
lp6e=0
lps=""
lpf=""
;
p:ikwo=0
p:ekwo=0
tmp=0
chs=""
chf=""
imp=0
exp=0
;
saldo=0
p:saldo1=0
p:saldo2=0
;
vts=""
vtf=""
vt1=0
vt2=0
vt3=0
>B
tper=30
=>SerialLog 0
>E
wfc=WifiConfig#?
wfp=WifiPower
>T
ipwr=EB3#API
epwr=EB3#APE
ikw=EB3#TEI
ekw=EB3#TEE
lp1y=EB3#LP1_Y
lp1m=EB3#LP1_M
lp1d=EB3#LP1_D
lp1hh=EB3#LP1_HH
lp1mm=EB3#LP1_MM
lp1gmt=EB3#LP1_GMT
lp3i=EB3#LPid9
lp6e=EB3#LPid10
vt1=EB3#VL1
vt2=EB3#VL2
vt3=EB3#VL3
hh=EB3#HH
mm=EB3#MM
ss=EB3#SS
>S
time=st(tstamp T 2)
date=st(tstamp T 1)
fheap=heap/1024
if cnt==20
{
+>WifiConfig
+>WifiPower
+>BackLog Script 8
}
if cnt==35
{
tper=10
=>UfsRun config.txt
}
if cnt==60
{
=>UfsRun discovery-EB3.txt
}
if cnt<100
{
cnt+=1
}
if chg[ss]>0
and cnt>30
then
ipwrm=ipwr
epwrm=epwr
endif
if upsecs%600==0
and cnt>30
then
;
vts=s(2.0hh)+":"+s(2.0mm)+","+s(0vt1)+","+s(0vt2)+","+s(0vt3)+"\n"
vtf="vt-0d.csv"
res=fx(vtf)
fr=fo(vtf 2)
if res==0
then
;
if EBx=="EB1"
or EBx=="EB2"
then
res=fw(date+",L1\n" fr)
else
res=fw(date+",L1,L2,L3\n" fr)
endif
;
endif
res=fw(vts fr)
print CSV: Updating %vtf%
fc(fr)
;
endif
strd="cnt"+s(hh)
if chg[hh]>0
and cnt>55
then
;
if hh==0
then
=>UfsDelete 2d.csv
=>UfsRename 1d.csv,2d.csv
=>UfsRename 0d.csv,1d.csv
;
=>UfsDelete vt-2d.csv
=>UfsRename vt-1d.csv,vt-2d.csv
=>UfsRename vt-0d.csv,vt-1d.csv
;
tmp=lp1y-1
=>UfsDelete2 LP-%4.0tmp%-%2.0lp1m%.csv
;
endif
;
if ikwo==0
or ikw==0
then
ikwo=ikw
endif
;
if ekwo==0
or ekw==0
then
ekwo=ekw
endif
;
imp=ikw-ikwo
exp=ekw-ekwo
;
chs=s(2.0hh)+"h"+","+s(imp)+","+s(exp)+"\n"
chf="0d.csv"
res=fx(chf)
fr=fo(chf 2)
if res==0
then
res=fw(date+",Import,Export\n" fr)
endif
res=fw(chs fr)
print CSV: Updating %chf%
fc(fr)
;
ikwo=ikw
ekwo=ekw
svars
;
endif
lpf="LP-"+s(4.0lp1y)+"-"+s(2.0lp1m)+".csv"
if chg[lp1mm]>0
and lp1y>0
then
lps=s(4.0lp1y)+"-"+s(2.0lp1m)+"-"+s(2.0lp1d)+"T"+s(2.0lp1hh)+":"+s(2.0lp1mm)+"Z"+lp1gmt+","+s(5.0lp3i)+","+s(5.0lp6e)+"\n"
;
res=fx(lpf)
fr=fo(lpf 2)
if res==0
then
res=fw("Date,Import Inc,Export Inc\n" fr)
endif
;
; LP csv
res=fw(lps fr)
print CSV: Updating %lpf%
;
fc(fr)
;
saldo=(lp3i-lp6e)/1000
if saldo>0
then
saldo1+=saldo
endif
if saldo<0
then
saldo2+=saldo*-1
endif
svars
;
endif
; extras
; extras
>J
,"H%EBx%":{
"s0":%3saldo%,
"s1":%3saldo1%,
"s2":%3saldo2%
}
>W
@<b>NTP </b> %date% %time% <b> Heap </b> %1fheap% kB
@<b>Init </b> %0cnt% %% <b> TelePeriod </b> %0tper% <b> Version </b> %0ver%
@<b>Wifi </b> %wfc% <b> Power </b> %0wfp% dBm <b> Topic </b> %topic%
@<br>
<br>
%EBx% Consumo %C%{m}%3saldo1% kWh
%EBx% Excedente %C%{m}%3saldo2% kWh
<br>
<a href="ufs/%lpf%">%lpf%</a>{m}<a href="ufs/charts.html">Charts JS</a>
<br>
$<div id="chart1" style="width:95%%;height:250px;padding:0px;"></div><br><br>
$gc(lt ipwrm epwrm "wr" "Import" "Export" strm)
$var options = {
$chartArea:{left:50,width:'80%%'},
$width:'100%%',legend:'none',
$title:'Potência (W) (~10min)',
$};
$gc(e)
; EOF V2