forked from kasbert/epsolar-tracer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhistory.php
executable file
·652 lines (546 loc) · 19 KB
/
history.php
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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
<?php
header('Content-Type: text/html; charset=UTF-8');
//session_start();
include '/etc/epsolar/databases.php'; //Database-Crendentials in here
include './sql-class.php';
//Databaseoptions (coming out of the settings in /etc/epsolar/databases.php
$host=$GlobalLoginDBHost;
$user=$GlobalLoginDBUser;
$password=$GlobalLoginDBPass;
$db=$GlobalLoginDBDatabase;
$mydbcon=new mysql($host, $user, $password, $db);
$sqliobj=$mydbcon->getSQLIObject();
//Functions
//function getdata($mintimestamp, $maxtimestamp, $con, $type="voltages")
function getdata($timeframe, $con, $type="voltages")
{
$wholedata=array();
$fieldnames=array();
switch ($timeframe) {
case "today":
$mintimestamp=date("Y-m-d")." 00:00:00";
$maxtimestamp=date("Y-m-d")." 23:59:59";
$querytimestamp="CONCAT(DATE_FORMAT(`timestamp`,'%H:%i'), ' Uhr') as 'Zeitpunkt', ";
$querygroupby="";
break;
case "week":
//echo("<h3>Daten dieser Woche:</h3>");
$mintimestamp=date("Y-m-d", strtotime('-1 week monday 00:00:00'));
$maxtimestamp=date("Y-m-d", strtotime('sunday 23:59:59'));
$querytimestamp="CONCAT(DATE_FORMAT(`timestamp`,'%W:%H'), ' Uhr') as 'Zeitpunkt', ";
$querygroupby="";
break;
case "month":
//echo("<h3>Daten dieses Monats:</h3>");
$mintimestamp=date("Y-m-d", strtotime('first day of this month'));
$maxtimestamp=date("Y-m-d", strtotime('last day of this month'));
break;
case "year":
//echo("<h3>Daten dieses Jahres:</h3>");
$mintimestamp=date("Y-m-d", strtotime(date('Y-01-01')));
$maxtimestamp=date("Y-m-d", strtotime(date('Y-12-31')));
break;
}
switch($type){
case "all":
$queryfields="
`pv-voltage` as 'Generator-Spannung [V]',
`bat-voltage` as 'Batterie-Spannung [V]',
`load-voltage` as 'Lastausgang-Spannung [V]',
`pv-power` as 'Generator-Leistung [W]',
`bat-power` as 'Batterie-Leistung [W]',
`load-power` as 'Lastausgang-Leistung [W]',
`pv-current` as 'Generator-Strom [A]',
`bat-current` as 'Batterie-Strom [A]',
`load-current` as 'Lastausgang-Strom [A]',
`bat-perc` as 'Batterieladestand [%]',
`bat-temp` as 'Batterie-Temperatur [°C]',
`con-temp-main` as 'Controller-Temperatur [°C]',
`con-temp-heatsink` as 'Controller-Heatsink-Temperatur [°C]'
";
break;
case "voltages":
$queryfields="
`pv-voltage` as 'Generator-Spannung [V]',
`bat-voltage` as 'Batterie-Spannung [V]',
`load-voltage` as 'Lastausgang-Spannung [V]'
";
break;
case "power":
$queryfields="
`pv-power` as 'Generator-Leistung [W]',
`bat-power` as 'Batterie-Leistung [W]',
`load-power` as 'Lastausgang-Leistung [W]'
";
break;
case "current":
$queryfields="
DATE_FORMAT(`timestamp`,'%H:%i') as 'Zeitpunkt',
`pv-current` as 'Generator-Strom [A]',
`bat-current` as 'Batterie-Strom [A]',
`load-current` as 'Lastausgang-Strom [A]'
";
break;
case "battery":
$queryfields="
DATE_FORMAT(`timestamp`,'%H:%i') as 'Zeitpunkt',
`bat-perc` as 'Batterieladestand [%]',
`bat-temp` as 'Batterie-Temperatur [°C]'
";
break;
}
$statement="
SELECT "
.$querytimestamp.
$queryfields."
from
epsolar_log.tbl_reading
WHERE `timestamp`
BETWEEN '".$mintimestamp."' AND '".$maxtimestamp."'
".$querygroupby."
ORDER BY `timestamp` ASC";
$resdata= $con->arrayquery($statement, False, True); //2D-Array [rows][fields]
//Determine the fieldcount
$numfields=sizeof($resdata[0]); //Result contains fieldnames
//Process the field names in the first line of the resultset
$fnames=array();
$count=1; //Skip the first name as its the timestamp
while ($count < $numfields){
$fnames [] = $resdata[0][$count];
$count++;
}
//var_dump($resdata); //DEBUG
//Fetch the data from the result but cutting of the fieldnames
$data=array();
$count=1; //Skip the first line as that are the fieldnames
while ($count < sizeof($resdata)){
$data [] = $resdata[$count];
$count++;
}
//var_dump($data); //DEBUG
$fieldnames=$fnames;
//var_dump($fieldnames); //DEBUG
$wholedata [] = $fieldnames; //Add Fieldnames to wholedata
$datalines=array(); //Rows -> lines for datavalaues
$xnames=array(); //Rows -> lines for x-axis-names
$count=0;
while ($count < $numfields){
$tempcol=array_column($data, $count);
$tempvalcol=array(); //numeric-values of that line
foreach($tempcol as $tcval){
//Convert each value saved as string into float
if ($count==0) {
//Names
$tempvalcol [] = $tcval; //Use String data
}
else if ($count >0){
//Datavalues
$tempvalcol [] = floatval($tcval); //Convert to float
}
}
if ($count==0){
$xnames[] = json_encode($tempvalcol);
}
else if ($count>0) {
$datalines[] = json_encode($tempvalcol);
}
$count++;
}
$wholedata [] = $xnames; // Add names of the X-Axis to wholedata
$wholedata [] = $datalines; //Add datalines to wholedata
//var_dump($wholedata[1]); //DEBUG
//return $datalines;
return $wholedata; //0=Fieldnames, 1=x-axis-names, 2=data
}
//Datadefinitions
//initialize with dummy-data
$datamode=0;
$cdtype="voltages";
$timeframe="";
if (isset($_GET['type'])){
/*
typess:
1=voltages
2=power
3=current
4=battery
*/
switch($_GET['type']) {
case "0":
$cdtype="all";
break;
case "1":
$cdtype="voltages";
break;
case "2":
$cdtype="power";
break;
case "3":
$cdtype="current";
break;
case "4":
$cdtype="battery";
break;
}
}
if (isset($_GET['datamode'])){
/*
datamodes:
1=chart
2=table
3=csv
*/
switch($_GET['datamode']) {
case "1":
$datamode=1;
break;
case "2":
$datamode=2;
break;
case "3":
$datamode=3;
break;
}
}
if (isset($_GET['timeframe'])){
//Valid options: today, week, month, year
if ($_GET['timeframe'] == "today" || $_GET['timeframe'] == "week" || $_GET['timeframe'] == "month" || $_GET['timeframe'] == "year" || $_GET['timeframe'] =="allraw") {
$timeframe=$_GET['timeframe'];
}
else {
echo("Ungültiger Zeitraum angegeben.");
exit;
}
}
/*
var_dump($timeframe);
var_dump($datamode);
*/
//Main
echo("<html>\r\n");
echo("\t<head>\r\n");
echo("\t\t<link href='epsolar_main.css' rel='stylesheet'>\r\n");
echo("\t</head>\r\n");
echo("\t<body>\r\n");
//Menüif ($datamode==1){
echo("
<p>
<div id='menu'>
<ul>
<li class='topmenu'>
<a href=''>Diagramme</a>
<ul>
<li class='submenu'><a href='./history.php?datamode=1&timeframe=today&type=1'>Heute (Spannungen)</a></li>
<li class='submenu'><a href='./history.php?datamode=1&timeframe=today&type=2'>Heute (Leistung)</a></li>
<li class='submenu'><a href='./history.php?datamode=1&timeframe=today&type=3'>Heute (Ströme)</a></li>
<li class='submenu'><a href='./history.php?datamode=1&timeframe=today&type=4'>Heute (Batterie)</a></li>
<li class='submenu'><a href='./history.php?datamode=1&timeframe=today&type=0'>Heute (Alles)</a></li>
<li class='submenu'><a href='./history.php?datamode=1&timeframe=week'&type=1>Diese Woche (Spannungen)</a></li>
"./*
<li class='submenu'><a href='./history.php?datamode=1&timeframe=week'>Diese Woche</a></li>
<li class='submenu'><a href='./history.php?datamode=1&timeframe=month'>Diesen Monat</a></li>
<li class='submenu'><a href='./history.php?datamode=1&timeframe=year'>Dieses Jahr</a></li>
*/
"
</ul>
</li>
<li class='topmenu'>
<a href=''>Tabellen</a>
<ul>
<li class='submenu'><a href='./history.php?datamode=2&timeframe=today'>Heute</a></li>
<li class='submenu'><a href='./history.php?datamode=2&timeframe=week'>Diese Woche</a></li>
<li class='submenu'><a href='./history.php?datamode=2&timeframe=month'>Diesen Monat</a></li>
<li class='submenu'><a href='./history.php?datamode=2&timeframe=year'>Dieses Jahr</a></li>
<li class='submenu'><a href='./history.php?datamode=2&timeframe=allraw'>Alle Rohdaten (VORSICHT viele Daten!)</a></li>
</ul>
</li>
<li class='topmenu'>
<a href=''>CSV-Export</a>
<ul>
<li class='submenu'><a href='./csvexport.php?datamode=3&timeframe=today'>Heute</a></li>
<li class='submenu'><a href='./csvexport.php?datamode=3&timeframe=week'>Diese Woche</a></li>
<li class='submenu'><a href='./csvexport.php?datamode=3&timeframe=month'>Diesen Monat</a></li>
<li class='submenu'><a href='./csvexport.php?datamode=3&timeframe=year'>Dieses Jahr</a></li>
<li class='submenu'><a href='./csvexport.php?datamode=3&timeframe=allraw'>Alle Rohdaten (VORSICHT viele Daten!)</a></li>
</ul>
</li>
</ul>
</div>
</p>");
echo("
<p>
<div id='diagram'>");
if ($datamode==1){
//Datamode for chart (diagramm) is set. Display Canvas
//Render diagram
//Import chart.js-library
echo("
<script src='./node_modules/chart.js/dist/Chart.js'></script>");
//define new canvas-tag (where to draw)
echo(" <br />
<br />
<canvas id='sunchart' aria-label='sunchart' role='img'></canvas>");
//Define Chartoptions
$chartoptions="{
responsive: true,
aspectRatio: 4.5,
elements: {
line: {
stacked: true,
tension: 0.3 //disables bezier curves when set to zero
}
},
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}
}]
}
}";
//Colors
$linecolors=array(
//Green
"rgba(0, 255, 0, 1)",
"rgba(0, 200, 0, 0.2)",
//RED
"rgba(255, 0, 0, 1)",
"rgba(200, 0, 0, 0.2)",
//Blue
"rgba(0, 0, 255, 1)",
"rgba(0, 0, 200, 0.2)",
//Yellow
"rgba(255, 255, 0, 1)",
"rgba(200, 200, 0, 0.2)",
//Pink
"rgba(255, 0, 255, 1)",
"rgba(200, 0, 200, 0.2)",
//Violett
"rgba(128, 0, 196, 1)",
"rgba(96, 0, 128, 0.2)",
//Cyan
"rgba(0, 160, 160, 1)",
"rgba(0, 128, 128, 0.2)",
//Orange
"rgba(255, 128, 00, 1)",
"rgba(128, 96, 0, 0.2)",
//Brown
"rgba(160, 96, 0, 1)",
"rgba(96, 64, 0, 0.2)",
//Dark-Green
"rgba(0, 160, 0, 0.2)",
"rgba(0, 96, 0, 0.2)",
//Dark-RED
"rgba(196, 0, 0, 1)",
"rgba(160, 0, 0, 0.2)",
//Dark-Blue
"rgba(0, 0, 160, 1)",
"rgba(0, 0, 128, 0.2)",
//Black
"rgba(0, 0, 0, 1)",
"rgba(40, 40, 40, 0.2)",
//Grey
"rgba(160, 160, 160, 1)",
"rgba(128, 128, 128, 0.2)",
);
$maxdatalines=sizeof($linecolors)/2; //Maximum drawable line due to defined colors...
// echo($linecolors[0]); //DEBUG
//QUERY-Database an get result prepared for chart
//$chardata=getdata($mintimestamp, $maxtimestamp, $mydbcon, $cdtype); //returns: 0=Fieldnames, 1=x-axis-names, 2=data
$chardata=getdata($timeframe, $mydbcon, $cdtype); //returns: 0=Fieldnames, 1=x-axis-names, 2=data
//var_dump($chardata); //DEBUG
//Axis-labels
//$datalabels=getaxislabels($mintimestamp, $maxtimestamp, $mydbcon);
$datalabels=$chardata[1][0];
//Data-Labels
//$charlabels=getlinelabels($mintimestamp, $maxtimestamp, $mydbcon)[0];
$charlabels=$chardata[0];
//RAW-Data
//$dataarray=getdata($mintimestamp, $maxtimestamp, $mydbcon)[1];
$dataarray=$chardata[2];
//echo(sizeof($dataarray)); //DEBUG
if (sizeof($dataarray) <= $maxdatalines)
{
//define Data to render
$chartdata="{
labels: ".$datalabels.",
datasets: [";
//Prepare each dataset
$count=0;
$colorcount=0;
foreach ($dataarray as $datarow)
{
if ($count != 0 && $count<sizeof($dataarray)){
//Not first or last entry in the dataarray
//Therefore after the first and before the last one
//put a ", " after each dataset
$chartdata=$chartdata.", ";
}
$chartdata=$chartdata."{label: '".$charlabels[$count]."', data: ".$datarow.",
borderColor: [
'".$linecolors[$colorcount]."'
],
backgroundColor: [
'".$linecolors[$colorcount+1]."'
],
borderWidth: 1
}";
$count++;
$colorcount=$colorcount+2;
}
$chartdata=$chartdata."]}";
}
//echo($chartdata); //DEBUG
//define script to draw chart in canvas
echo("
<script>
var ctx = document.getElementById('sunchart').getContext('2d');
var sunchart = new Chart(ctx, {
type: 'line',
data: ".$chartdata.",
options: ".$chartoptions."
});
</script>
");
//Fetch data
//$mydbcon->tablequery($statement);
}
else if ($datamode==2){
echo(" <br />
<br />
<br />");
//Datamode for table is set. Render Table
//Make a Table-Query;
//Generate SQL-Queries by Timeframe
switch ($timeframe) {
case "today":
echo("<h3>Daten von Heute:</h3>");
$mintimestamp=date("Y-m-d")." 00:00:00";
$maxtimestamp=date("Y-m-d")." 23:59:59";
$statement="SELECT
DATE_FORMAT(`timestamp`, '%H:%i') as 'Zeitpunkt',
concat(`con-temp-main`, ' °C') as 'Controller-Temperatur',
concat(`con-temp-heatsink`, ' °C') as 'Controller-Kühler-Temperatur',
concat(`pv-voltage`, ' V') as 'Generator-Spannung',
concat(`pv-current`, ' A') as 'Generator-Strom',
concat(`pv-power`, ' W') as 'Generator-Leistung',
concat(`bat-voltage`, ' V') as 'Batterie-Spannung',
concat(`bat-current`, ' A') as 'Batterie-Strom',
concat(`bat-power`, ' W') as 'Batterie-Leistung',
concat(`bat-perc`, ' %') as 'Batterie-Ladestand',
concat(`bat-temp`, ' °C') as 'Batterie-Temperatur',
concat(`load-voltage`, ' V') as 'Lastausgang-Spannung',
concat(`load-current`, ' A') as 'Lastausgang-Strom',
concat(`load-power`, ' W') as 'Lastausgang-Leistung'
from epsolar_log.tbl_reading
WHERE `timestamp` BETWEEN '".$mintimestamp."' AND '".$maxtimestamp."'
ORDER BY `timestamp` DESC";
break;
case "week":
echo("<h3>Daten dieser Woche:</h3>");
$mintimestamp=date("Y-m-d", strtotime('-1 week monday 00:00:00'));
$maxtimestamp=date("Y-m-d", strtotime('sunday 23:59:59'));
$statement="SELECT
concat(LEFT(`timestamp`, CHAR_LENGTH(`timestamp`) -5), '00-59') as 'Zeitpunkt des Tages',
concat(ROUND(AVG(`con-temp-main`),2), ' °C') as 'Mittlere Controller-Temperatur',
concat(ROUND(AVG(`con-temp-heatsink`),2), ' °C') as 'Mittlere Controller-Kühler-Temperatur',
concat(ROUND(AVG(`pv-voltage`),2), ' V') as 'Mittlere Generator-Spannung',
concat(ROUND(AVG(`pv-current`),2), ' A') as 'Mittlere Generator-Strom',
concat(ROUND(AVG(`pv-power`),2), ' W') as 'Mittlere Generator-Leistung',
concat(ROUND(AVG(`bat-voltage`),2), ' V') as 'Mittlere Batterie-Spannung',
concat(ROUND(AVG(`bat-current`),2), ' A') as 'Mittlere Batterie-Strom',
concat(ROUND(AVG(`bat-power`),2), ' W') as 'Mittlere Batterie-Leistung',
concat(ROUND(AVG(`bat-perc`),2), ' %') as 'Mittlere Batterie-Ladestand',
concat(ROUND(AVG(`bat-temp`),2), ' °C') as 'Mittlere Batterie-Temperatur',
concat(ROUND(AVG(`load-voltage`),2), ' V') as 'Mittlere Lastausgang-Spannung',
concat(ROUND(AVG(`load-current`),2), ' A') as 'Mittlere Lastausgang-Strom',
concat(ROUND(AVG(`load-power`),2), ' W') as 'Mittlere Lastausgang-Leistung'
from epsolar_log.tbl_reading
WHERE `timestamp` BETWEEN '".$mintimestamp."' AND '".$maxtimestamp."'
GROUP BY date_format( `timestamp`, '%Y%m%d%H' )
ORDER BY `timestamp` DESC";
break;
case "month":
echo("<h3>Daten dieses Monats:</h3>");
$mintimestamp=date("Y-m-d", strtotime('first day of this month'));
$maxtimestamp=date("Y-m-d", strtotime('last day of this month'));
$statement="SELECT
concat(LEFT(`timestamp`, CHAR_LENGTH(`timestamp`) -8), '') as 'Tag des Monats',
concat(ROUND(AVG(`con-temp-main`),2), ' °C') as 'Mittlere Controller-Temperatur',
concat(ROUND(AVG(`con-temp-heatsink`),2), ' °C') as 'Mittlere Controller-Kühler-Temperatur',
concat(ROUND(AVG(`pv-voltage`),2), ' V') as 'Mittlere Generator-Spannung',
concat(ROUND(AVG(`pv-current`),2), ' A') as 'Mittlere Generator-Strom',
concat(ROUND(AVG(`pv-power`),2), ' W') as 'Mittlere Generator-Leistung',
concat(ROUND(AVG(`bat-voltage`),2), ' V') as 'Mittlere Batterie-Spannung',
concat(ROUND(AVG(`bat-current`),2), ' A') as 'Mittlere Batterie-Strom',
concat(ROUND(AVG(`bat-power`),2), ' W') as 'Mittlere Batterie-Leistung',
concat(ROUND(AVG(`bat-perc`),2), ' %') as 'Mittlere Batterie-Ladestand',
concat(ROUND(AVG(`bat-temp`),2), ' °C') as 'Mittlere Batterie-Temperatur',
concat(ROUND(AVG(`load-voltage`),2), ' V') as 'Mittlere Lastausgang-Spannung',
concat(ROUND(AVG(`load-current`),2), ' A') as 'Mittlere Lastausgang-Strom',
concat(ROUND(AVG(`load-power`),2), ' W') as 'Mittlere Lastausgang-Leistung'
from epsolar_log.tbl_reading
WHERE `timestamp` BETWEEN '".$mintimestamp."' AND '".$maxtimestamp."'
GROUP BY date_format( `timestamp`, '%Y%m%d' )
ORDER BY `timestamp` DESC";
break;
case "year":
echo("<h3>Daten dieses Jahres:</h3>");
$mintimestamp=date("Y-m-d", strtotime(date('Y-01-01')));
$maxtimestamp=date("Y-m-d", strtotime(date('Y-12-31')));
$statement="SELECT
CONCAT(WEEK(`timestamp`), ' / ', YEAR(`timestamp`)) as 'Kalenderwoche',
concat(ROUND(AVG(`con-temp-main`),2), ' °C') as 'Mittlere Controller-Temperatur',
concat(ROUND(AVG(`con-temp-heatsink`),2), ' °C') as 'Mittlere Controller-Kühler-Temperatur',
concat(ROUND(AVG(`pv-voltage`),2), ' V') as 'Mittlere Generator-Spannung',
concat(ROUND(AVG(`pv-current`),2), ' A') as 'Mittlere Generator-Strom',
concat(ROUND(AVG(`pv-power`),2), ' W') as 'Mittlere Generator-Leistung',
concat(ROUND(AVG(`bat-voltage`),2), ' V') as 'Mittlere Batterie-Spannung',
concat(ROUND(AVG(`bat-current`),2), ' A') as 'Mittlere Batterie-Strom',
concat(ROUND(AVG(`bat-power`),2), ' W') as 'Mittlere Batterie-Leistung',
concat(ROUND(AVG(`bat-perc`),2), ' %') as 'Mittlere Batterie-Ladestand',
concat(ROUND(AVG(`bat-temp`),2), ' °C') as 'Mittlere Batterie-Temperatur',
concat(ROUND(AVG(`load-voltage`),2), ' V') as 'Mittlere Lastausgang-Spannung',
concat(ROUND(AVG(`load-current`),2), ' A') as 'Mittlere Lastausgang-Strom',
concat(ROUND(AVG(`load-power`),2), ' W') as 'Mittlere Lastausgang-Leistung'
from epsolar_log.tbl_reading
WHERE `timestamp` BETWEEN '".$mintimestamp."' AND '".$maxtimestamp."'
GROUP BY WEEK( `timestamp`)
ORDER BY `timestamp` DESC";
break;
case "allraw":
echo("<h3>Alle (Roh-)Daten:</h3>");
$statement="SELECT
`timestamp` as 'Zeitpunkt',
concat(`con-temp-main`, ' °C') as 'Controller-Temperatur',
concat(`con-temp-heatsink`, ' °C') as 'Controller-Kühler-Temperatur',
concat(`pv-voltage`, ' V') as 'Generator-Spannung',
concat(`pv-current`, ' A') as 'Generator-Strom',
concat(`pv-power`, ' W') as 'Generator-Leistung',
concat(`bat-voltage`, ' V') as 'Batterie-Spannung',
concat(`bat-current`, ' A') as 'Batterie-Strom',
concat(`bat-power`, ' W') as 'Batterie-Leistung',
concat(`bat-perc`, ' %') as 'Batterie-Ladestand',
concat(`bat-temp`, ' °C') as 'Batterie-Temperatur',
concat(`load-voltage`, ' V') as 'Lastausgang-Spannung',
concat(`load-current`, ' A') as 'Lastausgang-Strom',
concat(`load-power`, ' W') as 'Lastausgang-Leistung'
from epsolar_log.tbl_reading
ORDER BY `timestamp` DESC";
break;
}
//Show Table
$mydbcon->tablequery($statement);
}
else {
//No Data-Presentation-Mode selected...
echo("<br /><br /><br />Bitte eine Darstellung auswählen.");
}
echo("
</div>
</p>");
echo("
</body>");
echo("
</html>");
?>