Repository navigation
Expand file tree
/
Copy pathSolarPanelConfigScreen.qml
More file actions
1650 lines (1477 loc) · 55.9 KB
/
Copy pathSolarPanelConfigScreen.qml
File metadata and controls
1650 lines (1477 loc) · 55.9 KB
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
import QtQuick 2.1
import BasicUIControls 1.0
import qb.components 1.0
import FileIO 1.0
import "SolarZonneplanProc.js" as SolarZonneplan
Screen {
id: solarPanelConfigScreen
screenTitle: "SolarPanel Configuratie"
property variant invertersNameArray: []
property variant filenameArray: []
property variant dataStringArray: []
property variant inputDataType: []
property variant info: []
property bool isDemoMode : false
property url inverterUrl : "https://raw.githubusercontent.com/ToonSoftwareCollective/solarpanel-plugins/main/inverters.json"
property url inverterTestUrl : "https://raw.githubusercontent.com/ToonSoftwareCollective/solarpanel-plugins/main/invertersTest.json"
property url pluginUrl : app.pluginUrl
property int numberofItems
property string selectedInverter:app.selectedInverter
property string selectedInverter2:app.selectedInverter2
property string pluginFile : ""
property string fieldText1 : "Wachtwoord :"
property string fieldText2 : "Gebruikersnaam :"
property string fieldText3 : "SiteID:"
property string fieldText4 : "API Key:"
property string fieldText5 : "URL like \"192.168.10.5\":"
property string fieldText6 : "IDX:"
property string pluginFile2: ""
property string fieldText21 : "Wachtwoord :"
property string fieldText22 : "Gebruikersnaam :"
property string fieldText23 : "SiteID:"
property string fieldText24 : "API Key:"
property string fieldText25 : "URL like \"192.168.10.5\":"
property string fieldText26 : "IDX:"
property bool field1visible : false
property bool field2visible : false
property bool field3visible : false
property bool field4visible : false
property bool field5visible : false
property bool field6visible : false
property bool field1visible2 : false
property bool field2visible2 : false
property bool field3visible2 : false
property bool field4visible2 : false
property bool field5visible2 : false
property bool field6visible2 : false
property string tempPassWord : app.passWord
property string tempUserName: app.userName
property string tempSiteID: app.siteID
property string tempApiKey: app.apiKey
property string tempURL: app.urlString
property string tempIDX: app.idx
property string onlinePluginFileName : ""
property string tempPassWord2 : app.passWord2
property string tempUserName2: app.userName2
property string tempSiteID2: app.siteID2
property string tempApiKey2: app.apiKey2
property string tempURL2: app.urlString2
property string tempIDX2: app.idx2
property string onlinePluginFileName2 : ""
property bool manual: false
property int configChangeStep : 0
property bool stepRunning : false
property bool needReboot : false
property bool needRestart : false
property string oldconfigfileString
property string oldConfigScsyncFileString
property bool updatepossible : false
property string oldversionTotal
property string onlineversionTotal
property bool updatechecked : false
property bool showUpdate : false
property bool updated : false
property bool updateSucces : false
property bool updatepossible2 : false
property string oldversionTotal2
property string onlineversionTotal2
property bool updatechecked2 : false
property bool showUpdate2 : false
property bool updated2 : false
property bool updateSucces2 : false
property bool inverterSel1Clicked : true
property bool inverterSel2Clicked : false
property bool wrongPlugin: false
property bool wrongPlugin2: false
property int tempInverterCount
property bool debugOutput : app.debugOutput // Show console messages. Turn on in settings file !
property string sendMailText
property string getPasseText
property string sendMailText2
property string getPasseText2
FileIO {id: hcb_scsync_Configfile; source: "file:///mnt/data/qmf/config/config_happ_scsync.xml"}
FileIO {id: hcb_scsync_Configfile_bak; source: "file:///mnt/data/qmf/config/config_happ_scsync.solarpanelbackup"}
FileIO {id: hcb_rrd_Configfile; source: "file:///qmf/config/config_hcb_rrd.xml"}
FileIO {id: hcb_rrd_Configfile_bak; source: "file:///qmf/config/config_hcb_rrd.solarpanelbackup"}
FileIO {id: solarPanel_refreshtoken; source: "file:///mnt/data/tsc/appData/solarPanel_refreshtoken.txt"}
FileIO {id: mergeFile1; source: "solarpanel_merge_prod.txt"}
FileIO {id: mergeFile2; source: "solarpanel_merge_solar.txt"}
FileIO {id: pluginFile; source: "SolarObjectPlugin.js"}
FileIO {id: pluginFile2;source: "SolarObjectPlugin2.js"}
onShown: {
addCustomTopRightButton("Opslaan")
getInverters()
sendMailText = "mail versturen"
getPasseText = "Eerst mail versturen"
sendMailText2 = "mail versturen"
getPasseText2 = "Eerst mail versturen"
enableSleepToggle.isSwitchedOn = app.enableSleep
enablePollingToggle.isSwitchedOn = app.enablePolling
inputField1.inputText = tempPassWord
inputField2.inputText = tempUserName
inputField3.inputText = tempSiteID
inputField4.inputText = tempApiKey
inputField5.inputText = tempURL
inputField6.inputText = tempApiKey
inputField21.inputText = tempPassWord2
inputField22.inputText = tempUserName2
inputField23.inputText = tempSiteID2
inputField24.inputText = tempApiKey2
inputField25.inputText = tempURL2
inputField26.inputText = tempApiKey2
if (app.inverterCount >1){tempInverterCount = 2 ;inverterCountToggle.isSwitchedOn = true}else{tempInverterCount = 1;inverterCountToggle.isSwitchedOn = false}
}
onCustomButtonClicked: {
configChangeStep = 0
stepRunning = true
}
/////////////////////////////////////////////////////// ADD ALL INVERTERS TO THE LIST ///////////////////////////////////////////////
function fillInverters(){
numberofItems = invertersNameArray.length
model.clear()
for(var x1 = 0;x1 < invertersNameArray.length;x1++){
listview1.model.append({name: invertersNameArray[x1]})
}
}
/////////////////////////////////////////////////////// GET INVERTERS FROM THE INTERNET ///////////////////////////////////////////////
function getInverters(){
if (debugOutput) console.log("*********SolarPanel getInverters()")
if (invertersNameArray.length < 1 || manual){
manual = false
var http = new XMLHttpRequest()
http.onreadystatechange=function() {
if (http.readyState === 4){
if (http.status === 200 || http.status === 300 || http.status === 302) {
model.clear()
invertersNameArray= []
inputDataType =[]
filenameArray = []
var JsonString = http.responseText
if (debugOutput) console.log("responsetext: " + http.responseText)
var JsonObject= JSON.parse(JsonString)
var invertersArray = JsonObject.plugins
numberofItems = invertersArray.length
for (var i in invertersArray){
info[i] = invertersArray[i].info
invertersNameArray[i] = invertersArray[i].friendlyName
filenameArray[i] = invertersArray[i].filename
inputDataType[i] = invertersArray[i].data
}
resumefromHttpRequest()
}
else {
if (debugOutput) console.log("*********SolarPanel error: " + http.status)
}
}
}
if (isDemoMode){
selectedInverter=""
selectedInverter2=""
http.open("GET",inverterTestUrl, true)
}else{
http.open("GET",inverterUrl, true)
}
http.send()
}
}
/////////////////////////////////////////////////////// AFTER INVERTERS ARE FETCHED FROM THE INTERNET ///////////////////////////////////////////////
function resumefromHttpRequest(){
if (debugOutput) console.log("*********SolarPanel gselectedInverter : " + selectedInverter)
enableSleepToggle.isSwitchedOn = app.enableSleep
addCustomTopRightButton("Opslaan")
fillInverters()
if (app.inverterCount == 2){
tempPassWord2 = app.passWord2
tempUserName2 = app.userName2
tempApiKey2 = app.apiKey2
tempSiteID2= app.siteID2
tempURL2 = app.urlString2
tempIDX2 = app.apiKey2
setFieldText2()
}
tempPassWord = app.passWord
tempUserName = app.userName
tempApiKey = app.apiKey
tempSiteID= app.siteID
tempURL = app.urlString
tempIDX = app.apiKey
setFieldText()
}
/////////////////////////////////////////////////////// CREATE INPUTFIELDS DEPENDANT ON THER "DATA" FIELD ///////////////////////////////////////////////
function setFieldText() {
if (debugOutput) console.log("*********SolarPanel gselectedInverter : " + selectedInverter)
for(var x2 = 0;x2 < invertersNameArray.length;x2++){
if (invertersNameArray[x2].toLowerCase()==selectedInverter.toLowerCase()){listview1.currentIndex = x2 }
}
field1visible = ((inputDataType[listview1.currentIndex]).toString().toLowerCase().indexOf('ass')>-1)
field2visible = ((inputDataType[listview1.currentIndex]).toString().toLowerCase().indexOf('use')>-1)
field3visible = ((inputDataType[listview1.currentIndex]).toString().toLowerCase().indexOf('iteid')>-1)
field4visible = ((inputDataType[listview1.currentIndex]).toString().toLowerCase().indexOf('api')>-1)
field5visible = ((inputDataType[listview1.currentIndex]).toString().toLowerCase().indexOf('url')>-1)
field6visible = ((inputDataType[listview1.currentIndex]).toString().toLowerCase().indexOf('idx')>-1)
}
function setFieldText2() {
for(var x2 = 0;x2 < invertersNameArray.length;x2++){
if (invertersNameArray[x2].toLowerCase()==selectedInverter2.toLowerCase()){ listview1.currentIndex = x2}
}
field1visible2 = ((inputDataType[listview1.currentIndex]).toString().toLowerCase().indexOf('ass')>-1)
field2visible2 = ((inputDataType[listview1.currentIndex]).toString().toLowerCase().indexOf('use')>-1)
field3visible2 = ((inputDataType[listview1.currentIndex]).toString().toLowerCase().indexOf('iteid')>-1)
field4visible2 = ((inputDataType[listview1.currentIndex]).toString().toLowerCase().indexOf('api')>-1)
field5visible2 = ((inputDataType[listview1.currentIndex]).toString().toLowerCase().indexOf('url')>-1)
field6visible2 = ((inputDataType[listview1.currentIndex]).toString().toLowerCase().indexOf('idx')>-1)
field7visible2 = ((inputDataType[listview1.currentIndex]).toString().toLowerCase().indexOf('info')>-1)
}
/////////////////////////////////////////////////////// SAVE DATA TO TEMPS WHEN SAVE IS CLICKED ON AN INPUTFIELD ///////////////////////////////////////////////
function saveFieldData1(text) { tempPassWord = text }
function saveFieldData2(text) { tempUserName= text }
function saveFieldData3(text) { tempSiteID= text }
function saveFieldData4(text) { tempApiKey= text }
function saveFieldData5(text) { tempURL= text }
function saveFieldData6(text) { tempApiKey= text }
function saveFieldData21(text) {tempPassWord2 = text}
function saveFieldData22(text) {tempUserName2= text }
function saveFieldData23(text) {tempSiteID2= text }
function saveFieldData24(text) {tempApiKey2= text }
function saveFieldData25(text) {tempURL2= text}
function saveFieldData26(text) {tempApiKey2= text}
/////////////////////////////////////////////////////// CHECK FOR UPDATES ///////////////////////////////////////////////
function checkforUpdates(){
//check current version
updatechecked = true
var oldPluginFileString = pluginFile.read()
var n1 = oldPluginFileString.indexOf('<version>')
var n2 = oldPluginFileString.indexOf('</version>',n1)
oldversionTotal = (oldPluginFileString.substring(n1 + 9, n2)).trim()
//get filename of installed inverter
for(var x2 = 0;x2 < invertersNameArray.length;x2++){
if (invertersNameArray[x2].toLowerCase()==app.selectedInverter.toLowerCase()){onlinePluginFileName = filenameArray[x2]}
}
var onlineversionArray = ["0","0","0"]
//check online version
var http = new XMLHttpRequest()
http.onreadystatechange=function() {
if (http.readyState === 4){
if (http.status === 200) {
if (debugOutput) console.log("*********SolarPanel new Plugin: " + http.responseText)
var onlinePluginFileString = http.responseText
var n1 = onlinePluginFileString.indexOf('<version>')
var n2 = onlinePluginFileString.indexOf('</version>',n1)
onlineversionTotal = (onlinePluginFileString.substring(n1 + 9, n2)).trim()
compareVersions(oldversionTotal,onlineversionTotal)
}
else {
if (debugOutput) console.log("*********SolarPanel error retrieving new Plugin: " + http.status)
}
}
}
if (debugOutput) console.log(pluginUrl + onlinePluginFileName + ".plugin.txt")
http.open("GET",pluginUrl + onlinePluginFileName + ".plugin.txt" , true)
http.send()
}
function checkforUpdates2(){
//check current version
updatechecked2 = true
var oldPluginFileString = pluginFile2.read()
var n1 = oldPluginFileString.indexOf('<version>')
var n2 = oldPluginFileString.indexOf('</version>',n1)
oldversionTotal2 = (oldPluginFileString.substring(n1 + 9, n2)).trim()
//get filename of installed inverter
for(var x2 = 0;x2 < invertersNameArray.length;x2++){
if (invertersNameArray[x2].toLowerCase()==app.selectedInverter2.toLowerCase()){onlinePluginFileName2 = filenameArray[x2]}
}
var onlineversionArray = ["0","0","0"]
//check online version
var http = new XMLHttpRequest()
http.onreadystatechange=function() {
if (http.readyState === 4){
if (http.status === 200) {
if (debugOutput) console.log("*********SolarPanel new Plugin: " + http.responseText)
var onlinePluginFileString = http.responseText
var n1 = onlinePluginFileString.indexOf('<version>')
var n2 = onlinePluginFileString.indexOf('</version>',n1)
onlineversionTotal2 = (onlinePluginFileString.substring(n1 + 9, n2)).trim()
compareVersions2(oldversionTotal2,onlineversionTotal2)
}
else {
if (debugOutput) console.log("*********SolarPanel error retrieving new Plugin2: " + http.status)
}
}
}
if (debugOutput) console.log(pluginUrl + onlinePluginFileName2 + ".plugin.txt")
http.open("GET",pluginUrl + onlinePluginFileName2 + ".plugin.txt" , true)
http.send()
}
/////////////////////////////////////////////////////// CHECK DIFFERENCE BETWEEN VERSIONS ///////////////////////////////////////////////
function compareVersions(oldversionTotal,onlineversionTotal){
updatepossible = false
var oldversionArray = oldversionTotal.split(".")
if(typeof(oldversionArray[2]) == "undefined"){oldversionTotal = "0.0.0" ; oldversionArray[0] = 0 ; oldversionArray[1] = 0 ; oldversionArray[2] = 0 }
oldversionText.text = "Oude versie: " + oldversionTotal
var onlineversionArray = onlineversionTotal.split(".")
if(typeof(onlineversionArray[2]) == "undefined"){onlineversionTotal = "0.0.0" ; onlineversionArray[0] = 0 ; onlineversionArray[1] = 0 ; onlineversionArray[2] = 0 }
//compare versions
if (parseInt(onlineversionArray[0]) > parseInt(oldversionArray[0])) {
updatepossible = true
}
if (!updatepossible && (parseInt(onlineversionArray[1]) > parseInt(oldversionArray[1]))) {
updatepossible = true
}
if (!updatepossible && (parseInt(onlineversionArray[2]) > parseInt(oldversionArray[2]))) {
updatepossible = true
}
if (debugOutput) console.log("*********SolarPanel updatepossible : " + updatepossible)
}
function compareVersions2(oldversionTotal2,onlineversionTotal2){
updatepossible2 = false
if (debugOutput) console.log("*********SolarPanel oldvalue of Plugin2 : " + oldversionTotal2)
var oldversionArray2 = oldversionTotal2.split(".")
if(typeof(oldversionArray2[2]) == "undefined"){oldversionTotal2 = "0.0.0" ; oldversionArray2[0] = 0 ; oldversionArray2[1] = 0 ; oldversionArray2[2] = 0 }
oldversionText2.text = "Oude versie: " + oldversionTotal2
var onlineversionArray2 = onlineversionTotal2.split(".")
if(typeof(onlineversionArray2[2]) == "undefined"){onlineversionTotal2 = "0.0.0" ; onlineversionArray2[0] = 0 ; onlineversionArray2[1] = 0 ; onlineversionArray2[2] = 0 }
//compare versions
if (parseInt(onlineversionArray2[0]) > parseInt(oldversionArray2[0])) {
updatepossible2 = true
}
if (!updatepossible2 && (parseInt(onlineversionArray2[1]) > parseInt(oldversionArray2[1]))) {
updatepossible2 = true
}
if (!updatepossible2 && (parseInt(onlineversionArray2[2]) > parseInt(oldversionArray2[2]))) {
updatepossible2 = true
}
}
/////////////////////////////////////////////////////// UPDATE PLUGIN ///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function updatePlugin(){
app.popupString = "Plugin ophalen voor " + selectedInverter + "..."
app.solarRebootPopup.show()
//get filename of installed inverter
for(var x2 = 0;x2 < invertersNameArray.length;x2++){
if (invertersNameArray[x2].toLowerCase()==selectedInverter.toLowerCase()){onlinePluginFileName = filenameArray[x2]}
}
needRestart = true
if (debugOutput) console.log("*********SolarPanel downloading new inverter plugin")
var http = new XMLHttpRequest()
http.onreadystatechange=function() {
if (http.readyState === 4){
if (http.status === 200) {
if (debugOutput) console.log("*********SolarPanel new Plugin: " + http.responseText)
pluginFile.write(http.responseText)
needRestart = true
app.popupString = "Plugin opgehaald voor " + selectedInverter + "..."
oldversionTotal = onlineversionTotal
oldversionText.text = "Oude versie: " + oldversionTotal + " (geupdate, restart nodig)"
app.solarRebootPopup.hide()
updated = true
updateSucces = true
needRestart = true
updateSuccesText.text = "Update geslaagd"
}
else {
if (debugOutput) console.log("*********SolarPanel error retrieving new Plugin: " + http.status)
app.popupString = "Fout in ophalen van plugin" + "..."
updateSucces = false
updateSuccesText.text = "Update mislukt"
app.solarRebootPopup.hide()
}
}
}
if (debugOutput) console.log(pluginUrl + onlinePluginFileName+ ".plugin.txt")
http.open("GET",pluginUrl + onlinePluginFileName+ ".plugin.txt" , true)
http.send()
}
function updatePlugin2(){
app.popupString = "Plugin ophalen voor " + selectedInverter2 + "..."
app.solarRebootPopup.show()
//get filename of installed inverter
for(var x2 = 0;x2 < invertersNameArray.length;x2++){
if (invertersNameArray[x2].toLowerCase()==selectedInverter2.toLowerCase()){onlinePluginFileName2 = filenameArray[x2]}
}
needRestart = true
if (debugOutput) console.log("*********SolarPanel downloading new inverter plugin")
var http = new XMLHttpRequest()
http.onreadystatechange=function() {
if (http.readyState === 4){
if (http.status === 200) {
if (debugOutput) console.log("*********SolarPanel new Plugin: " + http.responseText)
pluginFile2.write(http.responseText)
app.popupString = "Plugin opgehaald voor " + selectedInverter2 + "..."
oldversionTotal2 = onlineversionTotal2
oldversionText2.text = "Oude versie: " + oldversionTotal2 + " (geupdate, restart nodig)"
app.solarRebootPopup.hide()
updated2 = true
updateSucces2 = true
needRestart = true
updateSuccesText2.text = "Update geslaagd"
}
else {
if (debugOutput) console.log("*********SolarPanel error retrieving new Plugin: " + http.status)
app.popupString = "Fout in ophalen van plugin" + "..."
updateSucces2 = false
updateSuccesText2.text = "Update mislukt"
app.solarRebootPopup.hide()
}
}
}
if (debugOutput) console.log(pluginUrl + onlinePluginFileName2+ ".plugin.txt")
http.open("GET",pluginUrl + onlinePluginFileName2+ ".plugin.txt" , true)
http.send()
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////// START GUI ///////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Text {
id: mytexttop1
text: "Selecteer je inverter(s) en vul je gegevens in."
font {
family: qfont.semiBold.name
pixelSize: isNxt ? 18:14
}
anchors {
top:parent.top
left:parent.left
leftMargin: isNxt ? 10 :8
topMargin: isNxt ? 5 :4
}
}
Text {
id: inverterCountText
width: isNxt? 160:128
text: "Aantal inverters : 1"
font.pixelSize: isNxt ? 18 : 14
font.family: qfont.semiBold.name
anchors {
left: mytexttop1.left
top: mytexttop1.bottom
topMargin: isNxt? 8 : 6
}
}
OnOffToggle {
id: inverterCountToggle
height: 30
anchors {
left: inverterCountText.right
top: inverterCountText.top
leftMargin: isNxt ? 20:16
}
leftIsSwitchedOn: false
onSelectedChangedByUser: {
if (isSwitchedOn) {
tempInverterCount = 2
} else {
tempInverterCount = 1
}
}
}
Text {
id: inverterCountText2
width: isNxt? 20:16
text: " 2"
font.pixelSize: isNxt ? 18 : 14
font.family: qfont.semiBold.name
anchors {
left: inverterCountToggle.right
leftMargin: isNxt ? 10 : 8
top: inverterCountText.top
}
}
Text {
id: mytexttop2
text: "Selecteer jouw inverter:"
font {
family: qfont.semiBold.name
pixelSize: isNxt ? 18:14
}
anchors {
top:inverterCountText.bottom
left:mytexttop1.left
topMargin: isNxt? 8 : 6
}
}
Rectangle{
id: listviewContainer1
width: isNxt ? 250 : 200
height: isNxt ? 180 : 120
color: "white"
radius: isNxt ? 5 : 4
border.color: "black"
border.width: isNxt ? 3 : 2
anchors {
top: mytexttop2.bottom
topMargin: isNxt? 8:6
left: mytexttop1.left
}
Component {
id: aniDelegate
Item {
width: isNxt ? (parent.width-20) : (parent.width-16)
height: isNxt ? 20 : 16
Text {
id: tst
text: name
font.pixelSize: isNxt ? 18:14
}
}
}
ListModel {
id: model
}
ListView {
id: listview1
anchors {
top: parent.top
topMargin:isNxt ? 16 : 12
leftMargin: isNxt ? 12 : 9
left: parent.left
}
width: parent.width
height: isNxt ? (parent.height-50) : (parent.height-40)
model:model
delegate: aniDelegate
highlight: Rectangle {
color: "lightsteelblue";
radius: isNxt ? 5 : 4
}
focus: true
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
IconButton {
id: upButton
anchors {
top: listviewContainer1.top
left: listviewContainer1.right
leftMargin : isNxt? 3 : 2
}
iconSource: "qrc:/tsc/up.png"
onClicked: {
if (listview1.currentIndex>0){
listview1.currentIndex = listview1.currentIndex -1
}
}
}
IconButton {
id: refreshButton
anchors {
verticalCenter: listviewContainer1.verticalCenter
left: listviewContainer1.right
leftMargin : isNxt? 3 : 2
}
iconSource: "qrc:/tsc/refresh.png"
onClicked: {
manual =true
getInverters()
}
}
IconButton {
id: downButton
anchors {
bottom: listviewContainer1.bottom
left: listviewContainer1.right
leftMargin : isNxt? 3 : 2
}
iconSource: "qrc:/tsc/down.png"
onClicked: {
if (listview1.currentIndex+1< numberofItems){
listview1.currentIndex = listview1.currentIndex +1
}
}
}
Text {
id: helpText1
text: "Druk een van de groene knopjes hieronder na selecteren van de juiste omvormer"
wrapMode: Text.WordWrap
width : isNxt ? parent.width/2 - 100 : parent.width/2 - 80
font {
family: qfont.semiBold.name
pixelSize: isNxt ? 18:14
}
anchors {
top:listviewContainer1.bottom
left:mytexttop1.left
topMargin: isNxt? 5: 4
}
}
NewTextLabel {
id: selText
width: isNxt ? 120 : 96;
height: isNxt ? 40:32
buttonActiveColor: "lightgreen"
buttonHoverColor: "blue"
enabled : true
textColor : "black"
buttonText: "Selecteer 1"
anchors {
top: helpText1.bottom
left: listviewContainer1.left
topMargin: isNxt? 5: 4
}
onClicked: {
inverterSel1Clicked = true
inverterSel2Clicked = false
selectedInverter = invertersNameArray[listview1.currentIndex]
if (app.selectedInverter == selectedInverter){
showUpdate = true
}else{
showUpdate = false
}
if (selectedInverter == "Zonneplan T"){
app.zonneplan=true
}else{
app.zonneplan=false
}
if (selectedInverter != listview1.name){
setFieldText()
}
}
}
NewTextLabel {
id: selText2
width: isNxt ? 120 : 96;
height: isNxt ? 40:32
buttonActiveColor: "lightgreen"
buttonHoverColor: "blue"
enabled : true
textColor : "black"
buttonText: "Selecteer 2"
anchors {
top: selText.top
right: listviewContainer1.right
}
onClicked: {
inverterSel1Clicked = false
inverterSel2Clicked = true
selectedInverter2 = invertersNameArray[listview1.currentIndex]
if (app.selectedInverter2 == selectedInverter2){
showUpdate2 = true
}else{
showUpdate2 = false
}
if (selectedInverter == "Zonneplan T"){
app.zonneplan2=true
}else{
app.zonneplan2=false
}
if (selectedInverter2 != listview1.name){
setFieldText2()
}
}
visible : (tempInverterCount == 2)
}
///////////////////////////////////////////// SELECTED ///////////////////////////////////////////////////////////////////////////////
Text {
id: showInSleep
width: isNxt? 160:128
text: "Zichtbaar in gedimde mode: "
font.pixelSize: isNxt ? 18 : 14
font.family: qfont.semiBold.name
anchors {
left: listviewContainer1.left
top: selText.bottom
topMargin: isNxt? 8 : 6
}
}
OnOffToggle {
id: enableSleepToggle
height: 30
anchors.left: showInSleep.right
anchors.leftMargin: isNxt ? 140 : 112
anchors.top: showInSleep.top
leftIsSwitchedOn: false
onSelectedChangedByUser: {
if (isSwitchedOn) {
app.enableSleep = true;
} else {
app.enableSleep = false;
}
}
}
Text {
id: enablePolling
width: isNxt? 160:128
text: "Ophalen van data ingeschakeld: "
font.pixelSize: isNxt ? 18 : 14
font.family: qfont.semiBold.name
anchors {
left: listviewContainer1.left
top: showInSleep.bottom
topMargin: isNxt? 8 : 6
}
}
OnOffToggle {
id: enablePollingToggle
height: 30
anchors.left: enableSleepToggle.left
anchors.top: enablePolling.top
leftIsSwitchedOn: false
onSelectedChangedByUser: {
if (isSwitchedOn) {
app.enablePolling = true;
} else {
app.enablePolling = false;
}
}
}
Text {
id: select1
text: (selectedInverter.length >2 ) ? "Gelecteerde omvormer 1: " + selectedInverter : "Gelecteerd omvormer 1: " +"n/a"
font {
family: qfont.semiBold.name
pixelSize: isNxt ? 24:18
}
anchors {
bottom:parent.bottom
left: enablePolling.left
bottomMargin: isNxt? 8 : 6
}
}
Text {
id: select2
text: (selectedInverter2.length >2 ) ? "Gelecteerde omvormer 2: " + selectedInverter2 : "Gelecteerd omvormer 2: " +"n/a"
font {
family: qfont.semiBold.name
pixelSize: isNxt ? 24:18
}
anchors {
top: select1.bottom
left: select1.left
}
visible : (tempInverterCount == 2)
}
////////////////////////////////////////////// SELECTED 1 ///////////////////////////////////////////////////////////////////////////////
Text {
id: mytext1
text: "Geselecteerd 1: "
font {
family: qfont.semiBold.name
pixelSize: isNxt ? 18:14
}
anchors {
top: mytexttop1.top
left:upButton.right
leftMargin:isNxt ? 140:112
}
visible: (selectedInverter.length>2) & !inverterSel2Clicked & inverterSel1Clicked
}
Text {
id: selectedText
text: selectedInverter
font {
family: qfont.semiBold.name
pixelSize: isNxt ? 24:18
}
anchors {
bottom: mytext1.bottom
left: mytext1.right
leftMargin: isNxt ? 20:16
}
visible: (selectedInverter.length>2) & !inverterSel2Clicked & inverterSel1Clicked
}
Text {
id: infoText1
text: "info"
font {
family: qfont.semiBold.name
pixelSize: isNxt ? 18:14
}
anchors {
top: mytext1.bottom
topMargin: isNxt ? 10:8
left: mytext1.left
}
visible: selectedInverter.length>2 && info[listview1.currentIndex].length>2
}
Text {
id: infoText2
width: parent.width/2
wrapMode: Text.WordWrap
text:info[listview1.currentIndex]
font {
family: qfont.semiBold.name
pixelSize: isNxt ? 18:14
}
anchors {
top: infoText1.bottom
left: mytext1.left
}
visible: selectedInverter.length>2
}
Grid {
id: gridContainer1
columns: 1
spacing: 2
visible: (selectedInverter.length>2) & !inverterSel2Clicked & inverterSel1Clicked
anchors {
top: infoText2.bottom
topMargin: isNxt ? 10:8
left : mytext1.left
}
//username
Text {id: inputField2Text;font.pixelSize: isNxt ? 18:14; font.family: qfont.semiBold.name ;text:fieldText2;visible: field2visible}
EditTextLabel4421 {
id: inputField2 ; width: isNxt? parent.width - mytext1.left - 40 : parent.width - mytext1.left - 32; height: isNxt? 35:28; leftTextAvailableWidth: isNxt? 100:80;
leftText: ""; visible: (inputField2Text.visible); onClicked: {qkeyboard.open(fieldText2, inputField2.inputText, saveFieldData2)}
}
//password
Text {id: inputField1Text;font.pixelSize: isNxt ? 18:14; font.family: qfont.semiBold.name ;text:fieldText1;visible: field1visible }
EditTextLabel4421 {
id: inputField1 ; width: isNxt? parent.width - mytext1.left - 40 : parent.width - mytext1.left - 32; height: isNxt? 35:28; leftTextAvailableWidth: isNxt? 100:80;
leftText: "";visible: (inputField1Text.visible); onClicked:{qkeyboard.open(fieldText1, inputField1.inputText, saveFieldData1)}
}
//siteid
Text {id: inputField3Text;font.pixelSize: isNxt ? 18:14; font.family: qfont.semiBold.name ;text:fieldText3;visible: field3visible }
EditTextLabel4421 {
id: inputField3 ; width: isNxt? parent.width - mytext1.left - 40 : parent.width - mytext1.left - 32; height: isNxt? 35:28; leftTextAvailableWidth: isNxt? 100:80;
leftText: "";visible: (inputField3Text.visible); onClicked: {qkeyboard.open(fieldText3, inputField3.inputText, saveFieldData3)}
}
//apikey
Text {id: inputField4Text;font.pixelSize: isNxt ? 18:14; font.family: qfont.semiBold.name ;text:fieldText4;visible: field4visible}
EditTextLabel4421 {
id: inputField4 ; width: isNxt? parent.width - mytext1.left - 40 : parent.width - mytext1.left - 32; height: isNxt? 35:28; leftTextAvailableWidth: isNxt? 100:80;
leftText: ""; visible: (inputField4Text.visible); onClicked: {qkeyboard.open(fieldText4, inputField4.inputText, saveFieldData4)}
}
//url
Text {id: inputField5Text;font.pixelSize: isNxt ? 18:14; font.family: qfont.semiBold.name ;text:fieldText5;visible: field5visible}
EditTextLabel4421 {
id: inputField5 ; width: isNxt? parent.width - mytext1.left - 40 : parent.width - mytext1.left - 32; height: isNxt? 35:28; leftTextAvailableWidth: isNxt? 100:80;
leftText: "";visible: (inputField5Text.visible);onClicked: {qkeyboard.open(fieldText5, inputField5.inputText, saveFieldData5)}
}
//idx
Text {id: inputField6Text;font.pixelSize: isNxt ? 18:14; font.family: qfont.semiBold.name ;text:fieldText6;visible: field6visible}
EditTextLabel4421 {
id: inputField6 ; width: isNxt? parent.width - mytext1.left - 40 : parent.width - mytext1.left - 32; height: isNxt? 35:28; leftTextAvailableWidth: isNxt? 100:80;
leftText: "";visible: (inputField6Text.visible);onClicked: {qkeyboard.open(fieldText6, inputField6.inputText, saveFieldData6)}
}
}
Grid {
id: gridContainer2
columns: 1
spacing: 2
visible: (selectedInverter.length>2) & !inverterSel2Clicked & inverterSel1Clicked
anchors {
top: gridContainer1.bottom
topMargin: isNxt ? 10:8
left : mytext1.left
}
NewTextLabel {
id: sendMail
width: isNxt? parent.width - mytext1.left - 40 : parent.width - mytext1.left - 32
height: isNxt ? 40:32
buttonActiveColor: "lightgreen" ; buttonHoverColor: "blue";
enabled : true;
textColor : "black"
buttonText: sendMailText
onClicked: SolarZonneplan.sendZonneplanMailRequest(inputField2.inputText,1)
visible: app.zonneplan
}
NewTextLabel {
id: getPassw
width: isNxt? parent.width - mytext1.left - 40 : parent.width - mytext1.left - 32
height: isNxt ? 40:32
buttonActiveColor: "lightgreen" ; buttonHoverColor: "blue"; enabled : true; textColor : "black"
buttonText: getPasseText
onClicked: SolarZonneplan.getPassword(inputField2.inputText,1)
visible: app.zonneplan
}
NewTextLabel {
id: updateText
width: isNxt? parent.width - mytext1.left - 40 : parent.width - mytext1.left - 32
height: isNxt ? 40:32
buttonActiveColor: "lightgreen" ; buttonHoverColor: "blue"; enabled : true; textColor : "black"
buttonText: "Controleer op updates voor " + app.selectedInverter
onClicked: {checkforUpdates()}
visible: showUpdate
}
Text {
id:oldversionText
text: "Oude versie: " + oldversionTotal
font.family: qfont.semiBold.name; font.pixelSize: isNxt ? 18:14
visible : showUpdate && updatechecked
}
Text {
id: onlineversionText
text: "Online versie: " + onlineversionTotal
font.family: qfont.semiBold.name;font.pixelSize: isNxt ? 18:14
visible : showUpdate && updatechecked
}
NewTextLabel {