-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathzonnepanelen.php
2808 lines (2725 loc) · 105 KB
/
zonnepanelen.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
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!--
#
# Copyright (C) 2019 André Rijkeboer
#
# This file is part of zonnepanelen, which shows telemetry data from
# the TCP traffic of SolarEdge PV inverters.
#
# zonnepanelen is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# zonnepanelen is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with zonnepanelen. If not, see <http://www.gnu.org/licenses/>.
#
versie: 1.71.4
auteurs:
André Rijkeboer
Jos van der Zande
Marcel Mol
datum: 24-02-2021
omschrijving: hoofdprogramma
-->
<html>
<head>
<title>Zonnepanelen-p1</title>
<link rel="shortcut icon" href="./img/sun.ico" type="image/x-icon"/>
<script type="text/javascript" src="js/loader.js"></script>
<script type="text/javascript" src="js/highcharts.js"></script>
<script type="text/javascript" src="js/highcharts-more.js"></script>
<script type="text/javascript" src="js/exporting.js"></script>
<script type="text/javascript" src="js/data.js"></script>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery-ui.min.js"></script>
<script type="text/javascript" src="js/Moonrise.js"></script>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="css/jquery.calendars.picker.css" id="theme">
<link rel="stylesheet" href="css/app.css">
<link href='css/zonnepanelen.css' rel='stylesheet' type='text/css'/>
<link href='css/zonnepanelen-local.css' rel='stylesheet' type='text/css'/>
<script src="js/jquery.plugin.js"></script>
<script src="js/jquery.mousewheel.js"></script>
<script src="js/jquery.calendars.js"></script>
<script src="js/jquery.calendars.plus.js"></script>
<script src="js/jquery.calendars.picker.js"></script>
<script src="js/jquery.calendars.picker.ext.js"></script>
<script src="js/jquery.calendars.validation.js"></script>
<link type="text/css" rel="stylesheet" href="css/jquery.qtip.css" />
<script type="text/javascript" src="js/jquery.qtip.js"></script>
<?php
// start error handling
set_error_handler("errorHandler");
register_shutdown_function("shutdownHandler");
function errorHandler($error_level, $error_message, $error_file, $error_line)
{
$error = "lvl: " . $error_level . " | msg:" . $error_message . " | file:" . $error_file . " | ln:" . $error_line;
switch ($error_level) {
case E_ERROR:
case E_CORE_ERROR:
case E_COMPILE_ERROR:
case E_PARSE:
mylog($error, "fatal");
break;
case E_USER_ERROR:
case E_RECOVERABLE_ERROR:
mylog($error, "error");
break;
case E_WARNING:
case E_CORE_WARNING:
case E_COMPILE_WARNING:
case E_USER_WARNING:
mylog($error, "warn");
break;
case E_NOTICE:
case E_USER_NOTICE:
mylog($error, "info");
break;
case E_STRICT:
mylog($error, "debug");
break;
default:
mylog($error, "warn");
}
}
function shutdownHandler() //will be called when php script ends.
{
$lasterror = error_get_last();
if( $lasterror !== NULL) {
switch ($lasterror['type'])
{
case E_ERROR:
case E_CORE_ERROR:
case E_COMPILE_ERROR:
case E_USER_ERROR:
case E_RECOVERABLE_ERROR:
case E_CORE_WARNING:
case E_COMPILE_WARNING:
case E_PARSE:
$error = "[SHUTDOWN] lvl:" . $lasterror['type'] . " | msg:" . $lasterror['message'] . " | file:" . $lasterror['file'] . " | ln:" . $lasterror['line'];
mylog($error, "fatal");
}
}
}
function mylog($error, $errlvl)
{
echo "<div style=background-color:Red;color:white;>";
echo "<p>We found a problem in the PHP code: $errlvl<br><br>$error<br><br>";
echo "<p>The website can't be shown until this issue is fixed.</p>";
echo "</div>";
}
// end error handling
function conv2rgba($rgbval,$opacity)
{
if (substr($rgbval,0,1) == "#") {
list($r, $g, $b) = sscanf($rgbval, "#%02x%02x%02x");
$rgbval = 'rgba(' . $r . ',' . $g . ',' . $b . ',' . $opacity . ')';
}
return $rgbval;
}
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { include('general_functions.php'); }
include('config.php');
$mysqli = new mysqli($host, $user, $passwd, $db, $port);
if (!mysqli_connect_errno()) {
$query = "SELECT min(timestamp) as timestamp FROM telemetry_optimizers";
$result = $mysqli->query($query);
$row = mysqli_fetch_assoc($result);
$begin = gmdate("Y-m-d",$row['timestamp']);
$thread_id = $mysqli->thread_id;
$mysqli->kill($thread_id);
$mysqli->close();
}
if ($aantal < 0) { $aantal = 0;}
for ($i=1; $i<=$aantal; $i++){
if ($op_id[$i][2] == 1){$pro[$i] = "6%"; $top[$i] = "65%";}
else {$pro[$i] = "20%"; $top[$i] = "78%";}
}
$week[1] = "Maandag";
$week[2] = "Dinsdag";
$week[3] = "Woensdag";
$week[4] = "Donderdag";
$week[5] = "Vrijdag";
$week[6] = "Zaterdag";
$week[7] = "Zondag";
$reportDate = array_key_exists('date', $_GET) ? $_GET['date'] : "";
$ds = array_key_exists('ds', $_GET) ? $_GET['ds'] : "";
setlocale(LC_ALL, 'nl_NL');
if ($reportDate == '') { $reportDate = date("d-m-Y H:i:s", time()); }
$InvDays = (isset($InvDays) ? $InvDays : '14');
for ($i=0; $i<=$InvDays; $i++){
$productie[$i] = $week[date("N", strtotime($reportDate)-$i*86400)] . date(" d-m-Y", strtotime($reportDate)-$i*86400);
}
$reportDT = new DateTime("today " . date("Y-m-d 00:00:00", strtotime($reportDate)));
$reportStamp = $reportDT->getTimestamp();
$reportWinterOffset = date("I",$reportStamp)-1;
$reportJaar = date("Y",$reportStamp)*1;
$reportMaand = date("m",$reportStamp)*1;
$reportDag = date("d",$reportStamp)*1;
$currentDayStartStamp = (new DateTime("today " . date("Y-m-d 00:00:00", time())))->getTimestamp();
$reportDateStr = date("d-m-Y H:i:s",$reportStamp);
$reportEndStamp = (new DateTime("tomorrow " . date("Y-m-d 00:00:00", strtotime($reportDate))))->getTimestamp();
$currentDayYMD = date("Y-m-d", time());
$reportDayDMY = date("d-m-Y", strtotime($reportDate));
$a = date_parse_from_format('d-m-Y H:M:S',$reportDateStr);
if ($a['year'] < 2000) { $a = date_parse_from_format('Y-m-d',$reportDate); }
$a = mktime(0,0,0,$a['month'], $a['day'], $a['year']);
$reportDateYMD = date('Y-m-d', $a);
$datum = $reportStamp/86400;
$timezone = date('Z',strtotime($reportDate))/3600;
$localtime = 0; //Time (pas local midnight)
$sunrise_s = iteratie($datum,$lat,$long,$timezone,$localtime,0,-.833);
$solar_noon_s = iteratie($datum,$lat,$long,$timezone,$localtime,1,0);
$sunset_s = iteratie($datum,$lat,$long,$timezone,$localtime,2,-.833);
$goldenrise_s = iteratie($datum,$lat,$long,$timezone,$localtime,0,+6);
$goldenset_s = iteratie($datum,$lat,$long,$timezone,$localtime,2,+6);
$bleurise_s = iteratie($datum,$lat,$long,$timezone,$localtime,0,-6);
$bleuset_s = iteratie($datum,$lat,$long,$timezone,$localtime,2,-6);
$nauticalrise_s = iteratie($datum,$lat,$long,$timezone,$localtime,0,-12);
$nauticalset_s = iteratie($datum,$lat,$long,$timezone,$localtime,2,-12);
$sunrise = date("H:i:s",(int) ($datum+$sunrise_s)*86400);
$solar_noon = date("H:i:s",(int) ($datum+$solar_noon_s)*86400);
$sunset = date("H:i:s",(int) ($datum+$sunset_s)*86400);
$goldenrise = date("H:i:s",(int) ($datum+$goldenrise_s)*86400);
$goldenset = date("H:i:s",(int) ($datum+$goldenset_s)*86400);
$bleurise = date("H:i:s",(int) ($datum+$bleurise_s)*86400);
$bleuset = date("H:i:s",(int) ($datum+$bleuset_s)*86400);
$nauticalrise = date("H:i:s",(int) ($datum+$nauticalrise_s)*86400);
$nauticalset = date("H:i:s",(int) ($datum+$nauticalset_s)*86400);
$daglengte = date("H:i:s",(int) ($datum+$sunset_s-$sunrise_s)*86400);
// bereken contract Start en Eind datum tbv jaar totalen
$contract_datum = empty($contract_datum) ? "01-01" : $contract_datum ;
$con_date_fields = explode("-", $contract_datum,2);
$con_d = intval($con_date_fields[0]) == 0 ? 1 : intval($con_date_fields[0]) ;
$con_m = intval($con_date_fields[1]) == 0 ? 1 : intval($con_date_fields[1]) ;
$con_s_y = $reportJaar;
$con_e_y = $reportJaar + 1;
if($con_m > $reportMaand || ($con_m == $reportMaand && $con_d > $reportDag)) {
$con_s_y = $reportJaar -1;
$con_e_y = $reportJaar;
}
$contract_datum_start = sprintf("%04d-%02d-%02d", $con_s_y, $con_m, $con_d);
$contract_datum_end = sprintf("%04d-%02d-%02d", $con_e_y, $con_m, $con_d);
// set defaults in case not provided in config.php, to avoid errors.
$P = (isset($P) ? $P : 0);
$kleur = (isset($kleur) ? $kleur : '#4169E1');
$kleur1 = (isset($kleur1) ? $kleur1 : '#009900');
$kleur2 = (isset($kleur2) ? $kleur2 : '#009900');
$kleurg = (isset($kleurg) ? $kleurg : '#d4d0d0');
$vermogen = (isset($vermogen) ? $vermogen : 1);
$groupMoonSun = (isset($groupMoonSun) ? $groupMoonSun : 1);
$PVGtxt = (isset($PVGtxt) ? $PVGtxt : 'PVGis');
$Gem_Verm = (isset($Gem_Verm) ? $Gem_Verm : 1);
$kleurSR = conv2rgba((isset($kleurSR) ? $kleurSR : 'rgba(0,153,0,0.7)'),(isset($OpacitySR) ? $OpacitySR : '0.7'));
$fillOpacitySR = (isset($fillOpacitySR ) ? $fillOpacitySR : '0.4');
$kleurSV = conv2rgba((isset($kleurSV) ? $kleurSV : 'rgba(0,153,0,0.7)'),(isset($OpacitySV) ? $OpacitySV : '0.4'));
$fillOpacitySV = (isset($fillOpacitySV ) ? $fillOpacitySV : '0.2');
$kleurVL = conv2rgba((isset($kleurVL) ? $kleurVL : 'rgba(65,105,225,0.8)'),(isset($OpacityVL) ? $OpacityVL : '0.8'));
$kleurVS = conv2rgba((isset($kleurVS) ? $kleurVS : 'rgba(65,105,225,0.6)'),(isset($OpacityVS) ? $OpacityVS : '0.6'));
$kleurS = conv2rgba((isset($kleurS) ? $kleurS : 'rgba(255,0,0,0.9)'),(isset($OpacityS) ? $OpacityS : '0.9'));
// start functions
function iteratie($datum,$lat,$long,$timezone,$localtime,$i,$d) {
$epsilon = 0.000000000001;
do {
$st = $solar_noon_s = bereken($datum,$lat,$long,$timezone,$localtime,$i,$d);
$sv = $st - $localtime/24;
$localtime = $st*24;
}
while ( abs($sv) > $epsilon );
return $st;
}
function bereken($datum,$lat,$long,$timezone,$localtime,$i,$d) {
$julian_day = $datum + 2440587.5 + ($localtime-$timezone)/24; //Julian Day
$julian_cen =($julian_day-2451545)/36525; //Julian Century
$geom_mean_long_sun = ((280.46646+$julian_cen*(36000.76983 + $julian_cen*0.0003032))/360 - floor((280.46646+$julian_cen*(36000.76983 + $julian_cen*0.0003032))/360))*360; //Geom Mean Long Sun (deg)
$geom_mean_anom_sun = 357.52911+$julian_cen*(35999.05029 - 0.0001537*$julian_cen); //Geom Mean Anom Sun (deg)
$eccent_earth_orbit = 0.016708634-$julian_cen*(0.000042037+0.0000001267*$julian_cen); //Eccent Earth Orbit
$sun_eq_of_ctr = sin(deg2rad($geom_mean_anom_sun))*(1.914602-$julian_cen*(0.004817+0.000014*$julian_cen))+sin(deg2rad(2*$geom_mean_anom_sun))*(0.019993-0.000101*$julian_cen)+sin(deg2rad(3*$geom_mean_anom_sun))*0.000289; //Sun Eq of Ctr
$sun_true_long = $geom_mean_long_sun+$sun_eq_of_ctr; //Sun True Long (deg)
$sun_app_long = $sun_true_long-0.00569-0.00478*sin(deg2rad(125.04-1934.136*$julian_cen)); //Sun App Long (deg)
$mean_obliq_ecliptic = 23+(26+((21.448-$julian_cen*(46.815+$julian_cen*(0.00059-$julian_cen*0.001813))))/60)/60; //Mean Obliq Ecliptic (deg)
$obliq_corr = $mean_obliq_ecliptic+0.00256*cos(deg2rad(125.04-1934.136*$julian_cen)); // Obliq Corr (deg)
$sun_declin = rad2deg(asin(sin(deg2rad($obliq_corr))*sin(deg2rad($sun_app_long)))); //Sun Declin (deg)
$var_y = tan(deg2rad($obliq_corr/2))*tan(deg2rad($obliq_corr/2)); //var y
$eq_of_time = 4*rad2deg($var_y*sin(2*deg2rad($geom_mean_long_sun))-2*$eccent_earth_orbit*sin(deg2rad($geom_mean_anom_sun))+4*$eccent_earth_orbit*$var_y*sin(deg2rad($geom_mean_anom_sun))*cos(2*deg2rad($geom_mean_long_sun))-0.5*$var_y*$var_y*sin(4*deg2rad($geom_mean_long_sun))-1.25*$eccent_earth_orbit*$eccent_earth_orbit*sin(2*deg2rad($geom_mean_anom_sun))); //Eq of Time
$ha_sunrise = rad2deg(acos(cos(deg2rad(90-$d))/(cos(deg2rad($lat))*cos(deg2rad($sun_declin)))-tan(deg2rad($lat))*tan(deg2rad($sun_declin)))); //HA Sunrise (deg)
$solar_noon_a = (720-4*$long-$eq_of_time+$timezone*60)/1440; //Solar Noon
if ($i==0) {$s = $solar_noon_a-$ha_sunrise*4/1440;} // Sunrise
else if ($i == 2) {$s = $solar_noon_a+$ha_sunrise*4/1440;} // Sunset
else {$s = $solar_noon_a;}
return $s;
}
function genxAxis() {
print "
type: 'datetime',
maxZoom: 9000 * 1000, // 600 seconds = 10 minutes
title: { text: null },
minPadding: 0,
maxPadding: 0,
labels: { overflow: 'justify' },
tooltip: { enabled: true, crosshair: true },
plotBands: [\n";
for ($i = 0; $i < 25; $i += 2) { print " {
color: '#ebfbff',
from: Date.UTC(reportJaar, reportMaand-1 , reportDag, " . $i . "-reportWinterOffset),
to: Date.UTC(reportJaar, reportMaand-1, reportDag, " . ($i+1) . "-reportWinterOffset),
},\n";
}
print "],\n";
}
function productieSeries($ingr, $kleur, $kleur1, $kleurg, $InvDays) {
print "
series: [\n";
for ($i = 0; $i <= $InvDays - 1; $i++) { print " {
name: productie[" . $i . "],
showInLegend: false,
type: 'areaspline',
animation: 0,
trackByArea: true,
yAxis: 0,
color: '" . ($i > $InvDays - 2 ? $kleur1 : $kleurg) . "',
fillOpacity: 0.0,
zIndex: " . $i . ",
data: []//this will be filled by requestData()
},";
}
print "
{
name: productie[" . $InvDays . "],
showInLegend: true,
type: 'areaspline',
animation: 0,
yAxis: 0,
lineWidth: 2,
color: '" . $kleur . "',
fillOpacity: " . ($ingr ? "0.3" : "0.0") . ",
zIndex: 20,
data: []//this will be filled by requestData()
}],\n";
}
function panelenSeries($aantal, $kleur2, $kleurg) {
print "
series: [\n";
for ($i=$aantal; $i>=2; $i--) { print " {
name: 'Paneel_" . $i . "',
showInLegend: false,
type: 'spline',
animation: 0,
yAxis: 0,
color: '" . $kleurg . "',
data: []//this will be filled by requestData()
},";
}
print "
{
name: 'Energie Productie',
showInLegend: true,
type: 'areaspline',
animation: 0,
marker: { symbol: 'triangle' },
yAxis: 1,
showEmpty: true,
lineWidth: 1,
color: 'rgba(204,255,153,1)',
pointWidth: 2,
data: []//this will be filled by requestData()
},{
name: 'Paneel_1',
showInLegend: true,
type: 'spline',
animation: 0,
yAxis: 0,
color: '" . $kleur2 . "',
data: []//this will be filled by requestData()
}],\n";
}
?>
</head>
<body>
<div class='mainpage'>
<div class='container' id='container'>
<div Class='box_inverter' id='box_inverter'>
<img src="./img/<?php echo $zonnesysteem;?>" alt="" style="position:absolute; top: 0px; left: 0px; width: 100%; height: 100%; z-index: -100;"/>
<div class='datum' id='datum'>
<input type="button" id="PrevDay" class="btn btn-success btn-sm" value="<" title="Vorige dag">
<input type="text" id="multiShowPicker" class="embed" size="8.5" style="text-align:center;">
<input type="button" id="NextDay" class="btn btn-success btn-sm" value=">" title="Volgende dag">
<input type="button" id="Today" class="btn btn-success btn-sm" value=">|" title="Vandaag">
</div>
<div class='map_inverter' id='map_inverter'>
<img src="./img/dummy.gif" style="width:100%; height:100%" usemap="#inverter"/>
</div>
<map name="inverter" style="z-index: 20;">
<area id="inverter_1" data-ttitle="Inverter <?php echo $naam?>" shape="rect" coords="0,0,252,252" title="">
</map>
<div class="inverter_text" id="inverter_text"></div>
<div class="sola_text" id="sola_text"></div>
<div class="arrow_prd_pos"><div id="arrow_PRD"></div></div>
<div class="so_text"><div id="so_text"></div></div>
<div class="arrow_return_pos"><div id="arrow_RETURN"></div></div>
<div class="sum_text" id="sum_text"></div>
<div class="elec_text" id="elec_text"></div>
<div class="p1_text_pos"><div id="p1_text"></div></div>
<div class="map_p1_meter" id="map_p1_meter">
<img src="./img/dummy.gif" style="width:100%; height:100%" usemap="#meter"/>
</div>
<map name="meter" style="z-index: 20;">
<area id="meter_1" data-ttitle="<?php echo $ElecLeverancier?> P1 Meter" shape="rect" coords="0,0,252,252" title="">
</map>
<div class="p1_huis_pos"><div id="p1_huis"></div></div>
<div class="map_huis" id="map_huis">
<img src="./img/dummy.gif" style="width:100%; height:100%" usemap="#huis"/>
</div>
<map name="huis" style="z-index: 20;">
<area id="huis_1" data-ttitle="Thuis verbruik" shape="rect" coords="0,0,252,252" title="">
</map>
</div>
<div Class='box_panel_energy' id='box_panel_energy'>
<div id="panel_energy" style="position: absolute; width: 100%; height: 100%;"></div>
</div>
<div Class='box_panel_vermogen' id='box_panel_vermogen'>
<div id="panel_vermogen" style="position: absolute; width: 100%; height: 100%;"></div>
</div>
<div Class='box_chart_energy' id='box_chart_energy'>
<div id="chart_energy" style="position: absolute; width: 100%; height: 100%;"></div>
</div>
<div Class='box_chart_vermogen' id='box_chart_vermogen'>
<div id="chart_vermogen" style="position: absolute; width: 100%; height: 100%;"></div>
</div>
<?php
if ($P1 == 1){
echo <<<EOF
<div Class='box_daygraph' id='box_daygraph'>
<div id="daygraph" style="position: absolute; width: 100%; height: 100%;"></div>
</div>
<div Class='box_monthgraph' id='box_monthgraph'>
<div id="monthgraph" style="position: absolute; width: 100%; height: 100%;"></div>
</div>
EOF
;
} else {
echo <<<EOF
<div Class='box_power_chart_body' id='box_power_chart_body'>
<div id="power_chart_body" style="position: absolute; width: 100%; height: 100%;"></div>
</div>
EOF
;
}
?>
<div Class="box_Zonnepanelen" id="box_Zonnepanelen">
<?php
for ($i=1; $i<=$aantal; $i++){
echo ' <div class="box_Zonnepaneel_'.$i.'" id="box_Zonnepaneel_'.$i.'">'."\n";
echo ' <div class="text_paneel_W" id="text_paneel_W_'.$i.'"></div>'."\n";
echo ' <div class="text_paneel_WX" id="text_paneel_W_'.$i.'a"></div>'."\n";
echo ' <div class="text_Zonnepaneel_n" id="text_Zonnepaneel_'.$i.'">'.$op_id[$i][1].'</div>'."\n";
echo ' <img id="image_'.$i.'" src="./img/Zonnepaneel-'.($op_id[$i][2] == 0 ? 'ver.gif':'hor.gif').'" alt="" width="100%" height="100%" style="width: 100%; height: 100%; position:relative; z-index: 5;"/>'."\n";
echo ' </div>'."\n";
echo ' <div class="box_Zonnepaneel_'.$i.'">'."\n";
echo ' <img src="./img/dummy.gif" alt="" width="100%" Height="100%" style="width: 100%; height: 100%; position: relative; z-index: 15;" usemap="#'.$i.'">'."\n";
echo ' <map name="'.$i.'">'."\n";
echo ' <area id="tool_paneel_'.$i.'" data-ttitle="Paneel '.$op_id[$i][1].'" shape="rect" coords="0,0,252,252" title="">'."\n";
echo ' </map>'."\n";
echo ' </div>'."\n";
}
?>
</div>
<div Class='box_sunrise' id='box_sunrise'>
<div class="astro" id="astro">
<img src="./img/dummy.gif" style="width:100%; height:100%" usemap="#astro"/>
</div>
<map name="astro" style="z-index: 40;">
<area id="astro_1" data-ttitle="Astronomische gegevens" shape="rect" coords="0,0,252,252" title="">
</map>
<img src="./img/zon/sunrise.gif" style="top: .1%; left: 3%; z-index: -10; width: 32%; height: 25%; position: absolute;" />
<div class='sunrise_text' id='sunrise_text' style="top: 10.1%; left: 40%; z-index: -10; width: 40%; height: 9%; line-height: 1.0em; position: absolute;"></div>
<img src="./img/zon/solar_noon.gif" style="top: 25.1%; left: 3%; z-index: -10; width: 32%; height: 25%; position: absolute;" />
<div class='solar_noon_text' id='solar_noon_text' style="top: 35.1%; left: 40%; z-index: -10; width: 40%; height: 9%; line-height: 1.0em; position: absolute;"></div>
<img src="./img/zon/sunset.gif" style="top: 50.1%; left: 3%; z-index: -10; width: 32%; height: 25%; position: absolute;" />
<div class='sunset_text' id='sunset_text' style="top: 60.1%; left: 40%; z-index: -10; width: 50%; height: 9%; line-height: 1.0em; position: absolute;"></div>
<img src="./img/zon/daglengte.gif" style="top: 75.1%; left: 3%; z-index: -10; width: 32%; height: 25%; position: absolute;" />
<div class='daglengte_text' id='daglengte_text' style="top: 85.1%; left: 40%; z-index: -10; width: 40%; height: 9%; line-height: 1.0em; position: absolute;"></div>
</div>
<div Class='box_moonphase' id='box_moonphase'>
<div class="astro2" id="astro">
<img src="./img/dummy.gif" style="width:100%; height:100%" usemap="#astro2"/>
</div>
<map name="astro2" style="z-index: 40;">
<area id="astro_2" data-ttitle="Astronomische gegevens" shape="rect" coords="0,0,252,500" title="">
</map>
<img class="maan_th" id="maan_th" src="" style="top: 0.6%; left: 7%; z-index: -10; height: 100%; position: absolute;" />
<div class='fase_text' id='fase_text' style="top: 22.0%; left: 40%; z-index: -10; width: 50%; height: 42%; line-height: 1.0em; position: absolute;"></div>
<div class='verlicht_text' id='verlicht_text' style="top: 55.0%; left: 40%; z-index: -10; width: 50%; height: 42%; line-height: 1.0em; position: absolute;"></div>
</div>
</div>
</body>
<script language="javascript" type="text/javascript">
$(document).on('mouseover', 'area', function(event) {
$(this).qtip({
overwrite: false, // Make sure the tooltip won't be overridden once created
position: {
viewport: $(window),
target: 'mouse',
adjust: {
x: 20,
y: 10
}
},
content: {
title: function(event, api) {
// Retrieve content from ALT attribute of the $('.selector') element
return $(this).attr('data-ttitle');
},
text: function(event, api) {
// Retrieve content from ALT attribute of the $('.selector') element
return $(this).attr('data-tcontent');
},
},
style: { classes: 'qtip-light qtipformat', },
show: {
event: event.type, // Use the same show event as the one that triggered the event handler
ready: true // Show the tooltip as soon as it's bound, vital so it shows up the first time you hover!
},
hide: { delay: 100 }
}, event); // Pass through our original event to qTip
})
$(document).on('mouseout', '', function(event) {
paneelChartcl();
})
$(document).on('mouseover', 'area', function(event) {
var panelid = this.id;
if (panelid.substring(0, 11) == "tool_paneel") {
var id = parseInt(panelid.substring(12),10);
paneelChart(event, id);
}
})
var ds = '<?php echo $ds ?>';
var reportDate = '<?php echo $reportDate ?>';
var reportDateStr = '<?php echo $reportDateStr ?>';
var currentDayStartStamp = '<?php echo $currentDayStartStamp ?>';
var reportEndStamp = '<?php echo $reportEndStamp ?>';
var reportDateYMD = "<?php echo $reportDateYMD ?>";
var currentDayYMD = "<?php echo $currentDayYMD ?>";
var reportDayDMY = "<?php echo $reportDayDMY ?>";
var reportWinterOffset = '<?php echo $reportWinterOffset?>';
var reportJaar = parseInt('<?php echo $reportJaar?>');
var reportMaand = parseInt('<?php echo $reportMaand?>');
var reportDag = parseInt('<?php echo $reportDag?>');
var sunrise = '<?php echo $sunrise ?>';
var solar_noon = '<?php echo $solar_noon ?>';
var sunset = '<?php echo $sunset ?>';
var goldenrise = '<?php echo $goldenrise ?>';
var goldenset = '<?php echo $goldenset ?>';
var bleurise = '<?php echo $bleurise ?>';
var bleuset = '<?php echo $bleuset ?>';
var nauticalrise = '<?php echo $nauticalrise ?>';
var nauticalset = '<?php echo $nauticalset ?>';
var daglengte = '<?php echo $daglengte ?>';
var lat = '<?php echo $lat ?>';
var lon = '<?php echo $long ?>';
var moondate = new Date(reportDateYMD);
var zone = Math.round(moondate.getTimezoneOffset() / 60);
var maanrise = moonRiseSet(lat, lon, moondate, zone, "r");
var maanset = moonRiseSet(lat, lon, moondate, zone, "s");
var begin = '<?php echo $begin?>';
var vermogen = '<?php echo $vermogen?>';
var inverter = '<?php echo $inverter?>';
var naam = '<?php echo $naam?>';
var P1 = '<?php echo $P1?>';
var aantal = '<?php echo $aantal?>';
var groupMoonSun = <?php echo $groupMoonSun ?>;
var op_sn = [0,<?php for ($i=1; $i<=$aantal; $i++){ echo "'", $op_id[$i][0], "',";} ?>];
var pn_sn = [0,<?php for ($i=1; $i<=$aantal; $i++){ echo "'", $op_id[$i][3], "',";} ?>];
var op_id = [0,<?php for ($i=1; $i<=$aantal; $i++){ echo "'", $op_id[$i][1], "',";} ?>];
var rpan = [0,<?php for ($i=1; $i<=$aantal; $i++){ echo "'", $op_id[$i][2], "',";} ?>];
var vpan = [0,<?php for ($i=1; $i<=$aantal; $i++){ echo $op_id[$i][4], ",";} ?>];
var tverm = 0;
for (i=1; i<=aantal; i++) {
tverm += vpan[i];
}
var PVGtxt = '<?php echo $PVGtxt; ?>';
var PVGis = [0<?php for ($i=0; $i<=11; $i++){ echo ",", $PVGis[$i];} ?>];
var data_p = [];
var data_i = [];
var gem_verm = <?php echo (isset($Gem_Verm) ? $Gem_Verm : 1); ?>;
var sgem_verm = gem_verm;
var InvDays = <?php echo $InvDays ?>;
var productie = [<?php for ($i=$InvDays; $i>=0; $i--){ echo "'", $productie[$i], "',"; } ?>];
var start_i = 0;
var inverter_redraw = 1;
var SolarProdToday = 0;
var p1CounterToday = 0;
var p1CounterDelivToday = 0;
var s_lasttimestamp = 0;
var contract_datum = '<?php echo $contract_datum?>';
var contract_start_date = '<?php echo $contract_datum_start?>';
var contract_end_date = '<?php echo $contract_datum_end?>';
var s_p1CounterToday = 0;
var s_p1CounterDelivToday = 0;
var wchart="";
var ychart="";
var pve = 0;
var pvs = 0;
var pse = 0;
var psv = 0;
var ve = 0;
var vs = 0;
var se = 0;
var sv = 0;
var mse = 0;
var msv = 0;
var mve = 0;
var mvs = 0;
var yse = 0;
var ysv = 0;
var yve = 0;
var yvs = 0;
var tPVGis=0;
var PVGisd = "";
var PVGism = "";
var PVGisj = "";
var reportMonthDays = daysInMonth(reportMaand, reportJaar);
var con_start_date = new Date(contract_start_date);
var con_end_date = new Date(contract_end_date);
var con_day = con_start_date.getDate();
var con_month = con_start_date.getMonth()+1;
var con_start_year = con_start_date.getFullYear();
var con_days = daysInMonth(con_month, con_start_year);
var period_60sec = "s";
var solarloaded=false;
var p1cloaded=false;
var p1mloaded=false;
var p1dloaded=false;
var yearstarted=false;
var yearloaded=false;
google.charts.load('current', {'packages':['gauge', 'line']});
google.charts.setOnLoadCallback(drawChart);
var maart = "";
var juni = "";
var september = "";
var december = "";
var firstTime = true; // Initialization flag
function writeN( n, str ) {
switch( n ) {
case 1: maart = stringToTimestamp(str); break;
case 2: juni = stringToTimestamp(str); break;
case 3: september = stringToTimestamp(str); break;
case 4: december = stringToTimestamp(str); break;
}
}
function calc(year) {
//Main Calculations started here
for( var i=1; i<=4; i++ ) { // Loop over 4 events: 1=AE, 2=SS, 3-VE, 4=WS
calcEquiSol( i, year ); // This routine calculates and displays a single event
}
} // End calc
calc(reportJaar);
function stringToTimestamp(s) {
var t = s.match(/[\d\w]+/g);
var months = {jan:'01',feb:'02',mar:'03',apr:'04',may:'05',jun:'06',
jul:'07',aug:'08',sep:'09',oct:'10',nov:'11',dec:'12'};
function pad(n){return (n<10?'0':'') + +n;}
var hrs = t[4];
return t[3] + '-' + months[t[1].toLowerCase()] + '-' + pad(t[2]) + ' ' +
pad(t[4]) + ':' + pad(t[5]) + ':' + pad(t[6]);
}
function calcEquiSol( i, year ) {
var k = i - 1;
var str;
var JDE0 = calcInitial( k, year); // Initial estimate of date of event
var T = ( JDE0 - 2451545.0) / 36525;
var W = 35999.373*T - 2.47;
var dL = 1 + 0.0334*COS(W) + 0.0007*COS(2*W);
var S = periodic24( T );
var JDE = JDE0 + ( (0.00001*S) / dL ); // This is the answer in Julian Emphemeris Days
var TDT = fromJDtoUTC( JDE ); // Convert Julian Days to TDT in a Date Object
var UTC = fromTDTtoUTC( TDT ); // Correct TDT to UTC, both as Date Objects
str = UTC.toString() + "\n"; //Convert to Local time string
writeN( i, str ); // Output date & time of event in Local Time
} // End calcEquiSol
//-----Calcualte an initial guess as the JD of the Equinox or Solstice of a Given Year
// Meeus Astronmical Algorithms Chapter 27
function calcInitial( k, year ) { // Valid for years 1000 to 3000
var JDE0=0, Y=(year-2000)/1000;
switch( k ) {
case 0: JDE0 = 2451623.80984 + 365242.37404*Y + 0.05169*POW2(Y) - 0.00411*POW3(Y) - 0.00057*POW4(Y); break;
case 1: JDE0 = 2451716.56767 + 365241.62603*Y + 0.00325*POW2(Y) + 0.00888*POW3(Y) - 0.00030*POW4(Y); break;
case 2: JDE0 = 2451810.21715 + 365242.01767*Y - 0.11575*POW2(Y) + 0.00337*POW3(Y) + 0.00078*POW4(Y); break;
case 3: JDE0 = 2451900.05952 + 365242.74049*Y - 0.06223*POW2(Y) - 0.00823*POW3(Y) + 0.00032*POW4(Y); break;
}
return JDE0;
} // End calcInitial
//-----Calculate 24 Periodic Terms----------------------------------------------------
// Meeus Astronmical Algorithms Chapter 27
function periodic24( T ) {
var A = new Array(485,203,199,182,156,136,77,74,70,58,52,50,45,44,29,18,17,16,14,12,12,12,9,8);
var B = new Array(324.96,337.23,342.08,27.85,73.14,171.52,222.54,296.72,243.58,119.81,297.17,21.02,
247.54,325.15,60.93,155.12,288.79,198.04,199.76,95.39,287.11,320.81,227.73,15.45);
var C = new Array(1934.136,32964.467,20.186,445267.112,45036.886,22518.443,
65928.934,3034.906,9037.513,33718.147,150.678,2281.226,
29929.562,31555.956,4443.417,67555.328,4562.452,62894.029,
31436.921,14577.848,31931.756,34777.259,1222.114,16859.074);
var S = 0;
for( var i=0; i<24; i++ ) { S += A[i]*COS( B[i] + (C[i]*T) ); }
return S;
}
//-----Correct TDT to UTC----------------------------------------------------------------
function fromTDTtoUTC( tobj ) {
// from Meeus Astronmical Algroithms Chapter 10
// Correction lookup table has entry for every even year between TBLfirst and TBLlast
var TBLfirst = 1620, TBLlast = 2002; // Range of years in lookup table
var TBL = new Array( // Corrections in Seconds
/*1620*/ 121,112,103, 95, 88, 82, 77, 72, 68, 63, 60, 56, 53, 51, 48, 46, 44, 42, 40, 38,
/*1660*/ 35, 33, 31, 29, 26, 24, 22, 20, 18, 16, 14, 12, 11, 10, 9, 8, 7, 7, 7, 7,
/*1700*/ 7, 7, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11,
/*1740*/ 11, 11, 12, 12, 12, 12, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 15, 16, 16,
/*1780*/ 16, 16, 16, 16, 16, 16, 15, 15, 14, 13,
/*1800*/ 13.1, 12.5, 12.2, 12.0, 12.0, 12.0, 12.0, 12.0, 12.0, 11.9, 11.6, 11.0, 10.2, 9.2, 8.2,
/*1830*/ 7.1, 6.2, 5.6, 5.4, 5.3, 5.4, 5.6, 5.9, 6.2, 6.5, 6.8, 7.1, 7.3, 7.5, 7.6,
/*1860*/ 7.7, 7.3, 6.2, 5.2, 2.7, 1.4, -1.2, -2.8, -3.8, -4.8, -5.5, -5.3, -5.6, -5.7, -5.9,
/*1890*/ -6.0, -6.3, -6.5, -6.2, -4.7, -2.8, -0.1, 2.6, 5.3, 7.7, 10.4, 13.3, 16.0, 18.2, 20.2,
/*1920*/ 21.1, 22.4, 23.5, 23.8, 24.3, 24.0, 23.9, 23.9, 23.7, 24.0, 24.3, 25.3, 26.2, 27.3, 28.2,
/*1950*/ 29.1, 30.0, 30.7, 31.4, 32.2, 33.1, 34.0, 35.0, 36.5, 38.3, 40.2, 42.2, 44.5, 46.5, 48.5,
/*1980*/ 50.5, 52.5, 53.8, 54.9, 55.8, 56.9, 58.3, 60.0, 61.6, 63.0, 63.8, 64.3); /*2002 last entry*/
// Values for Delta T for 2000 thru 2002 from NASA
var deltaT = 0; // deltaT = TDT - UTC (in Seconds)
var Year = tobj.getUTCFullYear();
var t = (Year - 2000) / 100; // Centuries from the epoch 2000.0
if ( Year >= TBLfirst && Year <= TBLlast ) { // Find correction in table
if (Year%2) { // Odd year - interpolate
deltaT = ( TBL[(Year-TBLfirst-1)/2] + TBL[(Year-TBLfirst+1)/2] ) / 2;
} else { // Even year - direct table lookup
deltaT = TBL[(Year-TBLfirst)/2];
}
} else if( Year < 948) {
deltaT = 2177 + 497*t + 44.1*POW2(t);
} else if( Year >=948) {
deltaT = 102 + 102*t + 25.3*POW2(t);
if (Year>=2000 && Year <=2100) { // Special correction to avoid discontinurity in 2000
deltaT += 0.37 * ( Year - 2100 );
}
} else { alert("Error: TDT to UTC correction not computed"); }
return( new Date( tobj.getTime() - (deltaT*1000) ) ); // JavaScript native time is in milliseonds
} // End fromTDTtoUTC
//-----Julian Date to UTC Date Object----------------------------------------------------
// Meeus Astronmical Algorithms Chapter 7
function fromJDtoUTC( JD ){
// JD = Julian Date, possible with fractional days
// Output is a JavaScript UTC Date Object
var A, alpha;
var Z = INT( JD + 0.5 ); // Integer JD's
var F = (JD + 0.5) - Z; // Fractional JD's
if (Z < 2299161) { A = Z; }
else {
alpha = INT( (Z-1867216.25) / 36524.25 );
A = Z + 1 + alpha - INT( alpha / 4 );
}
var B = A + 1524;
var C = INT( (B-122.1) / 365.25 );
var D = INT( 365.25*C );
var E = INT( ( B-D )/30.6001 );
var DT = B - D - INT(30.6001*E) + F; // Day of Month with decimals for time
var Mon = E - (E<13.5?1:13); // Month Number
var Yr = C - (Mon>2.5?4716:4715); // Year
var Day = INT( DT ); // Day of Month without decimals for time
var H = 24*(DT - Day); // Hours and fractional hours
var Hr = INT( H ); // Integer Hours
var M = 60*(H - Hr); // Minutes and fractional minutes
var Min = INT( M ); // Integer Minutes
var Sec = INT( 60*(M-Min) ); // Integer Seconds (Milliseconds discarded)
//Create and set a JavaScript Date Object and return it
var theDate = new Date(0);
theDate.setUTCFullYear(Yr, Mon-1, Day);
theDate.setUTCHours(Hr, Min, Sec);
return( theDate );
} //End fromJDtoUTC
//-----Utility Funtions------------------------------------------------------------
function INT ( n ) { return Math.floor(n); } // Emulates BASIC's INT Funtion
function POW2( n ) { return Math.pow(n,2); } // Square a number
function POW3( n ) { return Math.pow(n,3); } // Cube a number
function POW4( n ) { return Math.pow(n,4); } // Number to the 4th power
function COS( deg ) { // Cosine function with degrees as input
return Math.cos( deg * Math.PI/180 );
}
function drawChart() {
requestData60sec();
if (P1 == 1){
Get_All_P1_data();
} else {
p1mloaded = true;
p1dloaded = true;
p1cloaded = true;
}
document.getElementById("box_panel_vermogen").style.display = "none"
document.getElementById("box_panel_energy").style.display = "none"
document.getElementById("sunrise_text").innerHTML = sunrise+" uur";
document.getElementById("solar_noon_text").innerHTML = solar_noon+" uur";
document.getElementById("sunset_text").innerHTML = sunset+" uur";
document.getElementById("daglengte_text").innerHTML = daglengte+" uur";
var initVar = setInterval(function() {
if (!p1mloaded && typeof ychart.series[2].data.length !== 'undefined' && ychart.series[2].data.length > 0) {p1mloaded=true;}
if (!p1dloaded && typeof wchart.series[2].data.length !== 'undefined' && wchart.series[2].data.length > 0) {p1dloaded=true;}
if (!yearstarted && p1mloaded && p1dloaded){yearstarted = true; update_jaar();}
if (!solarloaded && typeof inverter_chartv.series[0] !== 'undefined' && inverter_chartv.series[0].data.length > 0) {solarloaded=true;}
if (solarloaded && (P1 == 0 || (p1mloaded && p1dloaded))) {
clearInterval(initVar);
if (currentDayStartStamp < reportEndStamp) {
p1_update();
setInterval(function() {
var now = new Date();
if (ds == '' && reportEndStamp < now/1000) {
window.location = window.location.pathname;
return false;
}
if (P1 == 1){
p1_update();
}
}, 10000);
setInterval(function() {
requestData60sec();
}, 60000);
} else {
update_map_fields();
}
}
}, 100);
}
var paneelGraph = {
'Vermogen': { 'metric': 'cp', 'tekst': 'Vermogen', 'unit': 'W' },
'Energie': { 'metric': 'vp', 'tekst': 'Energie', 'unit': 'Wh' },
'Temperatuur': { 'metric': 'temp', 'tekst': 'Temperatuur', 'unit': '°C' },
'V_in': { 'metric': 'vin', 'tekst': 'Spanning In', 'unit': 'V' },
'V_out': { 'metric': 'vout', 'tekst': 'Spanning Uit', 'unit': 'V' },
'I_in': { 'metric': 'iin', 'tekst': 'Stroom In', 'unit': 'A' }
};
function paneelFillSeries(metric, id, ichart) {
for (var i = 0; i <= aantal; i++) {
ichart.series[i].setData([], false);
}
var series = ichart.series[0];
var shift = series.data.length > 86400; // shift if the series is longer than 86400(=1 dag)
for (var i = 0; i < data_p.length; i++) {
if (data_p[i]['op_id'] !== id && data_p[i]['serie'] == 0) {
var sIdx = data_p[i]['op_id'] - 1;
if (data_p[i]['op_id'] > id ) { --sIdx; }
ichart.series[sIdx].addPoint([data_p[i]['ts'], data_p[i][paneelGraph[metric]['metric']]*1], false, shift);
} else {
ichart.series[aantal].addPoint([data_p[i]['ts'], data_p[i][paneelGraph[metric]['metric']]*1], false, shift);
}
}
ichart.setTitle(null, { text: 'Paneel: ' + op_id[id] + ' en alle andere panelen', x: 20});
ichart.legend.update({x: 10, y: 20});
ichart.series[aantal].update({name: paneelGraph[metric]['tekst'] + " paneel: " + op_id[id], style: {font: 'Arial', fontWeight: 'bold', fontSize: '12px' }});
ichart.series[aantal-1].update({showInLegend: false});
ichart.series[aantal-2].update({showInLegend: true, name: paneelGraph[metric]['tekst'] + " overige panelen"});
ichart.yAxis[0].update({ opposite: true });
ichart.yAxis[0].update({ title: { text: paneelGraph[metric]['tekst'] + ' (' + paneelGraph[metric]['unit'] + ')' }, });
ichart.yAxis[1].update({ labels: { enabled: false }, title: { text: null } });
ichart.redraw();
}
function paneelChart(event, id) {
if (id <= aantal) {
inverter_redraw = 0;
document.getElementById("box_chart_vermogen").style.display = "none";
document.getElementById("box_chart_energy").style.display = "none";
// #### Vermogen #####
paneelFillSeries('Energie', id, paneel_charte);
if (event.shiftKey) {
paneelFillSeries('Temperatuur', id, paneel_chartv);
} else {
paneelFillSeries('Vermogen', id, paneel_chartv);
}
document.getElementById("box_panel_vermogen").style.display = "block";
document.getElementById("box_panel_energy").style.display = "block";
paneel_charte.reflow();
paneel_chartv.reflow();
}
}
function paneelChartcl() {
inverter_redraw = 1;
setTimeout(function () {
if (inverter_redraw == 1) {
document.getElementById("box_panel_vermogen").style.display = "none"
document.getElementById("box_panel_energy").style.display = "none"
inverter_charte.redraw();
inverter_chartv.redraw();
document.getElementById("box_chart_vermogen").style.display = "block"
document.getElementById("box_chart_energy").style.display = "block"
inverter_charte.reflow();
inverter_chartv.reflow();
}
}, 200);
}
function waarde(l,d,x){
s = String(x);
n = s.indexOf('-');
if ( n==0) { s=s.slice(1,s.length);}
p=s.indexOf('.');
if ( p <0 ) { s = s + ".";}
for (var i=1; i <= l; i++) {
if (l > i) {if (s.indexOf('.')<i+1) { s = "0"+ s;};}
}
p=s.indexOf('.');
for (var i=1; i<=d; i++){
if (s.length<p+1+i) { s = s + "0";}
}
if (d == 0 && p+1 <= s.length) { s=s.slice(0,p);}
if (d > 0 && p+1+d < s.length) { s=s.slice(0,p+1+d);}
if (n==0) { s="-"+s;}
return s;
}
function p1_update(){
var p1data = $.ajax({
url: "<?php echo $DataURL?>?period=c",
dataType: "json",
type: 'GET',
data: { "date" : reportDateStr },
cache: false,
async: true,
success: function(data) {
p1data = eval(data);
if (p1data[0]["ServerTime"].length > 6){
p1servertime = p1data[0]["ServerTime"];
if (typeof p1servertime === 'undefined') {p1servertime = "";}
p1CounterToday = p1data[0]["CounterToday"];
p1CounterDelivToday = p1data[0]["CounterDelivToday"];
p1Usage = p1data[0]["Usage"];
p1UsageDeliv = p1data[0]["UsageDeliv"];
p1CounterToday = (typeof p1CounterToday === 'undefined') ? 0 : parseFloat(p1CounterToday);
p1CounterDelivToday = (typeof p1CounterDelivToday === 'undefined') ? 0 : parseFloat(p1CounterDelivToday);
p1Usage = (typeof p1Usage === 'undefined') ? 0 : parseFloat(p1Usage);
p1UsageDeliv = (typeof p1UsageDeliv === 'undefined') ? 0 : parseFloat(p1UsageDeliv);
if (currentDayStartStamp < reportEndStamp) {
if (p1CounterToday == 0) {
document.getElementById("arrow_RETURN").className = "";
document.getElementById("p1_text").className = "red_text";
document.getElementById("p1_text").innerHTML = "No data";
} else if( parseFloat(p1Usage) == 0) {
document.getElementById("arrow_RETURN").className = "arrow_right_green";
document.getElementById("p1_text").className = "green_text";
document.getElementById("p1_text").innerHTML = p1UsageDeliv + " Watt";
} else {
document.getElementById("arrow_RETURN").className = "arrow_left_red";
document.getElementById("p1_text").className = "red_text";
document.getElementById("p1_text").innerHTML = p1Usage + " Watt";
}
}
if (currentDayStartStamp < reportEndStamp) {
var diff = p1CounterToday - p1CounterDelivToday;
var cdiff = "red_text";
if (diff < 0) {
cdiff = "green_text";
diff = -diff;
}
document.getElementById("elec_text").innerHTML = "<table width=100% class=data-table>"+
"<tr><td><u><b><?php echo $ElecLeverancier?> vandaag</u></b></td><td style=\"font-size:smaller\">"+p1servertime.substr(11,10)+"</td></tr>" +
"<tr><td>verbruik:</td><td>"+waarde(0,3,parseFloat(p1CounterToday))+" kWh</td></tr>" +
"<tr><td>retour:</td><td><u>"+waarde(0,3,parseFloat(p1CounterDelivToday))+" kWh</u></td></tr>" +
"<tr><td class="+cdiff+">netto:</td><td class="+cdiff+" >"+waarde(0,3,diff)+" kWh</td></tr>"+
"</table>";
if (pse+psv+pve+pvs > 0) {
// update current day info in graphs
var prod = SolarProdToday; //Solar productie
var ve = p1CounterToday;
var vs = prod - p1CounterDelivToday;
var se = p1CounterDelivToday;
var sv = vs;
wchart.series[0].data[wchart.series[0].data.length-1].update(se);
wchart.series[1].data[wchart.series[1].data.length-1].update(sv);
wchart.series[2].data[wchart.series[2].data.length-1].update(ve);
wchart.series[3].data[wchart.series[3].data.length-1].update(vs);
//
// update huidige maand
var mse = ychart.series[0].data[ychart.series[0].data.length-1].y - pse + se;
var msv = ychart.series[1].data[ychart.series[1].data.length-1].y - psv + sv;
var mve = ychart.series[2].data[ychart.series[2].data.length-1].y - pve + ve;
var mvs = ychart.series[3].data[ychart.series[3].data.length-1].y - pvs + vs;
ychart.series[0].data[ychart.series[0].data.length-1].update(mse);
ychart.series[1].data[ychart.series[1].data.length-1].update(msv);
ychart.series[2].data[ychart.series[2].data.length-1].update(mve);
ychart.series[3].data[ychart.series[3].data.length-1].update(mvs);
pve = ve;
pvs = vs;
pse = se;
psv = sv;
//
p1cloaded = true;
if (s_p1CounterToday+s_p1CounterDelivToday == 0) {
s_p1CounterToday = p1CounterToday;
s_p1CounterDelivToday = p1CounterDelivToday;
document.getElementById("sola_text").innerHTML = document.getElementById("sola_text").innerHTML.replace(
"verbruik?",
waarde(0,3,parseFloat(SolarProdToday)-parseFloat(s_p1CounterDelivToday)))