-
Notifications
You must be signed in to change notification settings - Fork 11
/
XMLManager.py
4468 lines (3424 loc) · 187 KB
/
XMLManager.py
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
# All works in this code have been curated by ECCC and licensed under the GNU General Public License v3.0.
# Read more: https://www.gnu.org/licenses/gpl-3.0.en.html
from xml.etree.ElementTree import SubElement
from MidSectionSubPanelObj import *
import wx
import datetime
import math
import time
import ast
import sys, os
import traceback
from pdb import set_trace
#Calculate the mean time
def mean(start, end):
startHour = start.GetHour()
endHour = end.GetHour()
startMin = start.GetMinute()
endMin = end.GetMinute()
startSec = start.GetSecond()
endSec = end.GetSecond()
if (startHour + endHour)%2 != 0:
endMin += 60
if (startMin + endMin)%2 != 0:
endSec += 60
meanHour = (startHour + endHour) / 2
meanMin = (startMin + endMin) / 2
meanSec = (startSec + endSec) / 2
meanTime = str(meanHour) + ':' + str(meanMin) + ':' + str(meanSec)
return meanTime
# Create XML structure for Title Header info
def TitleHeaderAsXMLTree(TitleHeader, titleHeaderManager):
pass
# Set Title Header info from an existing XML structure
def TitleHeaderFromXML(TitleHeader, titleHeaderManager):
pass
# Create XML structure for General Info
def GenInfoAsXMLTree( GenInfo, genInfoManager):
station = SubElement(GenInfo, 'station', number=genInfoManager.stnNumCmbo)
station.text = genInfoManager.stnName
date = SubElement(GenInfo, 'date', timezone=genInfoManager.tzCmbo)
date.text = str(genInfoManager.datePicker)
# Set General Info variables from existing XML structure
def GenInfoFromXML(GenInfo, genInfoManager):
stationNumber = GenInfo.find('station').get('number')
genInfoManager.stnNumCmbo = "" if stationNumber is None else stationNumber
station = GenInfo.find('station').text
genInfoManager.stnName = "" if station is None else station
dateTimezone = GenInfo.find('date').get('timezone')
genInfoManager.tzCmbo = "" if dateTimezone is None else dateTimezone
date = GenInfo.find('date').text
genInfoManager.datePicker = "" if date is None else date
def GetStationId(GenInfo):
return GenInfo.find('station').get('number')
def GetDate(GenInfo):
return GenInfo.find('date').text
# Create XML structure for Stage Measurements
def StageMeasAsXMLTree(StageMeas, stageMeasManager):
# HgButton = SubElement(StageMeas, 'HgButton')
# HgButton.text = stageMeasManager.hgButton
HgCkbox = SubElement(StageMeas, 'HgCkbox')
HgCkbox.text = str(stageMeasManager.GetHgCkbox().IsChecked())
Hg2Ckbox = SubElement(StageMeas, 'Hg2Ckbox')
Hg2Ckbox.text = str(stageMeasManager.GetHg2Ckbox().IsChecked())
Wlr1Ckbox = SubElement(StageMeas, 'Wlr1Ckbox')
Wlr1Ckbox.text = str(stageMeasManager.GetWlr1Ckbox().IsChecked())
Wlr2Ckbox = SubElement(StageMeas, 'Wlr2Ckbox')
Wlr2Ckbox.text = str(stageMeasManager.GetWlr2Ckbox().IsChecked())
HG1Header = SubElement(StageMeas, 'HG1Header')
HG1Header.text = str(stageMeasManager.stageLabelCtrl1)
HG2Header = SubElement(StageMeas, 'HG2Header')
HG2Header.text = str(stageMeasManager.stageLabelCtrl2)
WL1Header = SubElement(StageMeas, 'WL1Header')
WL1Header.text = str(stageMeasManager.bmLeft)
WL2Header = SubElement(StageMeas, 'WL2Header')
WL2Header.text = str(stageMeasManager.bmRight)
StageMeasTable = SubElement(StageMeas, 'StageMeasTable')
for row in range(len(stageMeasManager.timeValSizer.GetChildren())):
StageMeasRow = SubElement(StageMeasTable, 'StageMeasRow', row=str(row))
time = SubElement(StageMeasRow, 'time')
timeList = str(stageMeasManager.GetTimeVal(row)).split(":")
if len(timeList[0]) < 2 and len(timeList[1]) == 2 :
time.text = "0" + str(stageMeasManager.GetTimeVal(row))
elif len(timeList[0]) == 2 and len(timeList[1]) < 2:
time.text = str(timeList[0]) + ":0" + str(timeList[1])
elif len(timeList[0]) < 2 and len(timeList[1]) < 2:
time.text = "0" + str(timeList[0]) + ":0" + str(timeList[1])
else:
time.text = str(stageMeasManager.GetTimeVal(row))
'''
if len(str(stageMeasManager.GetTimeVal(row))) == 4:
time.text = "0" + str(stageMeasManager.GetTimeVal(row))
else:
time.text = str(stageMeasManager.GetTimeVal(row))
'''
HG1 = SubElement(StageMeasRow, 'HG1')
HG1.text = str(stageMeasManager.GetHGVal(row))
HG2 = SubElement(StageMeasRow, 'HG2')
HG2.text = str(stageMeasManager.GetHG2Val(row))
WL1 = SubElement(StageMeasRow, 'WL1')
WL1.text = str(stageMeasManager.GetWLSubSizerLVal(row))
WL2 = SubElement(StageMeasRow, 'WL2')
WL2.text = str(stageMeasManager.GetWLSubSizerRVal(row))
surge = SubElement(StageMeasRow, 'Surge')
surge.text = str(stageMeasManager.GetSurgeVal(row))
SRC = SubElement(StageMeasRow, 'SRC')
SRC.text = str(stageMeasManager.GetSrcSizerVal(row))
SRCApp = SubElement(StageMeasRow, 'SRCApp')
SRCApp.text = str(stageMeasManager.GetSrcAppSizerVal(row))
MghCkbox = SubElement(StageMeasRow, 'MghCkbox')
MghCkbox.text = str(stageMeasManager.GetMghAggCheckboxVal(row))
ReadingType = SubElement(StageMeasRow, 'ReadingType')
ReadingType.text = str(stageMeasManager.GetReadingTypeVal(row))
hgCkbox = SubElement(StageMeas, 'hgCkbox')
hgCkbox.text = str(stageMeasManager.GetHgCkbox().GetValue())
hg2Ckbox = SubElement(StageMeas, 'hg2Ckbox')
hg2Ckbox.text = str(stageMeasManager.GetHg2Ckbox().GetValue())
wlr1Ckbox = SubElement(StageMeas, 'wlr1Ckbox')
wlr1Ckbox.text = str(stageMeasManager.GetWlr1Ckbox().GetValue())
wlr2Ckbox = SubElement(StageMeas, 'wlr2Ckbox')
wlr2Ckbox.text = str(stageMeasManager.GetWlr2Ckbox().GetValue())
MGHHG1 = SubElement(StageMeas, 'MGHHG1')
MGHHG1.text = str(stageMeasManager.MGHHG)
MGHHG2 = SubElement(StageMeas, 'MGHHG2')
MGHHG2.text = str(stageMeasManager.MGHHG2)
MGHWL1 = SubElement(StageMeas, 'MGHWL1')
MGHWL1.text = str(stageMeasManager.MGHWLRefL)
MGHWL2 = SubElement(StageMeas, 'MGHWL2')
MGHWL2.text = str(stageMeasManager.MGHWLRefR)
SRCHG1 = SubElement(StageMeas, 'SRCHG1')
SRCHG1.text = str(stageMeasManager.SRCHG)
SRCHG2 = SubElement(StageMeas, 'SRCHG2')
SRCHG2.text = str(stageMeasManager.SRCHG2)
GCHG1 = SubElement(StageMeas, 'GCHG1')
GCHG1.text = str(stageMeasManager.GCHG)
GCHG2 = SubElement(StageMeas, 'GCHG2')
GCHG2.text = str(stageMeasManager.GCHG2)
GCWL1 = SubElement(StageMeas, 'GCWL1')
GCWL1.text = str(stageMeasManager.GCWLRefL)
GCWL2 = SubElement(StageMeas, 'GCWL2')
GCWL2.text = str(stageMeasManager.GCWLRefR)
CMGHHG1 = SubElement(StageMeas, 'CMGHHG1')
CMGHHG1.text = str(stageMeasManager.CMGHHG)
CMGHHG2 = SubElement(StageMeas, 'CMGHHG2')
CMGHHG2.text = str(stageMeasManager.CMGHHG2)
CMGHWL1 = SubElement(StageMeas, 'CMGHWL1')
CMGHWL1.text = str(stageMeasManager.CMGHWLRefL)
CMGHWL2 = SubElement(StageMeas, 'CMGHWL2')
CMGHWL2.text = str(stageMeasManager.CMGHWLRefR)
MghMethod = SubElement(StageMeas, 'MghMethod')
MghMethod.text = str(stageMeasManager.GetMghMethod())
# AggCombo = SubElement(StageMeas, 'AggCombo')
# AggCombo.text = str(stageMeasManager.mghAggCombobox)
Factors = SubElement(StageMeas, 'Factors')
Factors.text = str(stageMeasManager.factors)
stageRemark = SubElement(StageMeas, 'stageRemark')
stageRemark.text = stageMeasManager.stageRemarksCtrl
# Set Stage Measurements variables from existing XML structure
def StageMeasFromXML(StageMeas, stageMeasManager):
HG1Header = StageMeas.find('HG1Header').text
stageMeasManager.stageLabelCtrl1 = "" if HG1Header is None else HG1Header
HG2Header = StageMeas.find('HG2Header').text
stageMeasManager.stageLabelCtrl2 = "" if HG2Header is None else HG2Header
WL1Header = StageMeas.find('WL1Header').text
stageMeasManager.bmLeft = "" if WL1Header is None else WL1Header
WL2Header = StageMeas.find('WL2Header').text
stageMeasManager.bmRight = "" if WL2Header is None else WL2Header
# try:
# HgButton = StageMeas.find('HgButton').text
# if HgButton == "True":
# stageMeasManager.SetToHG()
# else:
# stageMeasManager.SetToHG2()
# except:
# stageMeasManager.SetToHG()
#Remove all entries in table first
for i in range(len(stageMeasManager.timeValSizer.GetChildren())):
stageMeasManager.gui.RemoveEntry(0)
try:
hgCkbox = StageMeas.find('hgCkbox').text
stageMeasManager.GetHgCkbox().SetValue(hgCkbox == 'True')
hg2Ckbox = StageMeas.find('hg2Ckbox').text
stageMeasManager.GetHg2Ckbox().SetValue(hg2Ckbox == 'True')
wlr1Ckbox = StageMeas.find('wlr1Ckbox').text
stageMeasManager.GetWlr1Ckbox().SetValue(wlr1Ckbox == 'True')
wlr2Ckbox = StageMeas.find('wlr2Ckbox').text
stageMeasManager.GetWlr2Ckbox().SetValue(wlr2Ckbox == 'True')
except:
pass
StageMeasTable = StageMeas.find('StageMeasTable')
for row, StageMeasRow in enumerate(StageMeasTable.findall('StageMeasRow')):
stageMeasManager.gui.AddEntry()
time = StageMeasRow.find('time').text
HG1 = StageMeasRow.find('HG1').text
HG2 = StageMeasRow.find('HG2').text
WL1 = StageMeasRow.find('WL1').text
WL2 = StageMeasRow.find('WL2').text
surge = StageMeasRow.find('Surge')
SRC = StageMeasRow.find('SRC').text
SRCApp = StageMeasRow.find('SRCApp')
MghCkbox = StageMeasRow.find('MghCkbox')
ReadingType = StageMeasRow.find('ReadingType')
if SRCApp is not None:
SRCApp = SRCApp.text
if MghCkbox is not None:
MghCkbox = MghCkbox.text
if ReadingType is not None:
ReadingType = ReadingType.text
if surge is not None:
surge = surge.text
stageMeasManager.SetTimeVal(row, "" if time is None else time)
stageMeasManager.SetHGVal(row, "" if HG1 is None else HG1)
stageMeasManager.SetHG2Val(row, "" if HG2 is None else HG2)
stageMeasManager.SetWLSubSizerLVal(row, "" if WL1 is None else WL1)
stageMeasManager.SetWLSubSizerRVal(row, "" if WL2 is None else WL2)
stageMeasManager.SetSurgeVal(row, "" if surge is None else surge)
stageMeasManager.SetSrcSizerVal(row, "" if SRC is None else SRC)
stageMeasManager.SetSrcAppSizerVal(row, "" if SRCApp is None else SRCApp)
stageMeasManager.SetMghAggCheckbox(row, "" if MghCkbox is None else MghCkbox)
stageMeasManager.SetReadingTypeVal(row, "" if ReadingType is None else ReadingType)
stageMeasManager.GetMghAggCheckbox(row).Enable(time.split(":")[0] != "" and time.split(":")[1] != "")
# AggCombo = None
# try:
# AggCombo = StageMeas.find('AggCombo').text
# except:
# print "xml doesn't include MghMethod"
# stageMeasManager.mghAggCombobox = "" if AggCombo is None else AggCombo
Factors = None
try:
Factors = StageMeas.find('Factors').text
except:
print("xml doesn't include Factors")
stageMeasManager.factors = "" if Factors is None else Factors
######new field from version 1.1.6###############
try:
HgCkbox = StageMeas.find('HgCkbox').text
if HgCkbox == "True":
stageMeasManager.GetHgCkbox().SetValue(True)
else:
stageMeasManager.GetHgCkbox().SetValue(False)
Hg2Ckbox = StageMeas.find('Hg2Ckbox').text
if Hg2Ckbox == "True":
stageMeasManager.GetHg2Ckbox().SetValue(True)
else:
stageMeasManager.GetHg2Ckbox().SetValue(False)
Wlr1Ckbox = StageMeas.find('Wlr1Ckbox').text
if Wlr1Ckbox == "True":
stageMeasManager.GetWlr1Ckbox().SetValue(True)
else:
stageMeasManager.GetWlr1Ckbox().SetValue(False)
Wlr2Ckbox = StageMeas.find('Wlr2Ckbox').text
if Wlr2Ckbox == "True":
stageMeasManager.GetWlr2Ckbox().SetValue(True)
else:
stageMeasManager.GetWlr2Ckbox().SetValue(False)
except:
stageMeasManager.GetHgCkbox().SetValue(False)
stageMeasManager.GetHg2Ckbox().SetValue(False)
stageMeasManager.GetWlr1Ckbox().SetValue(False)
stageMeasManager.GetWlr2Ckbox().SetValue(False)
##################################
MGHHG1 = StageMeas.find('MGHHG1').text
stageMeasManager.MGHHG = "" if MGHHG1 is None else MGHHG1
MGHHG2 = StageMeas.find('MGHHG2').text
stageMeasManager.MGHHG2 = "" if MGHHG2 is None else MGHHG2
MGHWL1 = StageMeas.find('MGHWL1').text
stageMeasManager.MGHWLRefL = "" if MGHWL1 is None else MGHWL1
MGHWL2 = StageMeas.find('MGHWL2').text
stageMeasManager.MGHWLRefR = "" if MGHWL2 is None else MGHWL2
SRCHG1 = StageMeas.find('SRCHG1').text
stageMeasManager.SRCHG = "" if SRCHG1 is None else SRCHG1
SRCHG2 = StageMeas.find('SRCHG2').text
stageMeasManager.SRCHG2 = "" if SRCHG2 is None else SRCHG2
GCHG1 = StageMeas.find('GCHG1').text
stageMeasManager.GCHG = "" if GCHG1 is None else GCHG1
GCHG2 = StageMeas.find('GCHG2').text
stageMeasManager.GCHG2 = "" if GCHG2 is None else GCHG2
GCWL1 = StageMeas.find('GCWL1').text
stageMeasManager.GCWLRefL = "" if GCWL1 is None else GCWL1
GCWL2 = StageMeas.find('GCWL2').text
stageMeasManager.GCWLRefR = "" if GCWL2 is None else GCWL2
CMGHHG1 = StageMeas.find('CMGHHG1').text
stageMeasManager.CMGHHG = "" if CMGHHG1 is None else CMGHHG1
CMGHHG2 = StageMeas.find('CMGHHG2').text
stageMeasManager.CMGHHG2 = "" if CMGHHG2 is None else CMGHHG2
CMGHWL1 = StageMeas.find('CMGHWL1').text
stageMeasManager.CMGHWLRefL = "" if CMGHWL1 is None else CMGHWL1
CMGHWL2 = StageMeas.find('CMGHWL2').text
stageMeasManager.CMGHWLRefR = "" if CMGHWL2 is None else CMGHWL2
MghMethod = None
try:
MghMethod = StageMeas.find('MghMethod').text
except:
print("xml doesn't include MghMethod")
if MghMethod is not None:
stageMeasManager.SetMghMethod(MghMethod)
else:
stageMeasManager.SetMghMethod("")
try:
stageRemark = StageMeas.find('stageRemark').text
stageMeasManager.stageRemarksCtrl = "" if stageRemark is None else stageRemark
except:
pass
# stageMeasManager.gui.UpdateDischargeMGH()
# print stageMeasManager.gui.CMGHHG.GetValue()
# Create XML structure for Discharge Measurements
def DischMeasAsXMLTree(DisMeas, disMeasManager):
bkColor = disMeasManager.manager.gui.importedBGColor
startTime = SubElement(DisMeas, 'startTime')
startTime.text = str(disMeasManager.startTimeCtrl)
endTime = SubElement(DisMeas, 'endTime')
endTime.text = str(disMeasManager.endTimeCtrl)
airTemp = SubElement(DisMeas, 'airTemp')
airTemp.text = str(disMeasManager.airTempCtrl)
waterTemp = SubElement(DisMeas, 'waterTemp')
waterTemp.text = str(disMeasManager.waterTempCtrl)
width = SubElement(DisMeas, 'width')
width.text = str(disMeasManager.widthCtrl)
area = SubElement(DisMeas, 'area')
area.text = str(disMeasManager.areaCtrl)
meanVel = SubElement(DisMeas, 'meanVel')
meanVel.text = str(disMeasManager.meanVelCtrl)
mgh = SubElement(DisMeas, 'mgh')
mgh.text = str(disMeasManager.mghCtrl)
mghCmbo = SubElement(DisMeas, 'mghCmbo')
mghCmbo.text = str(disMeasManager.mghCmbo)
# mghChoice1 = SubElement(DisMeas, 'mghChoice1')
# mghChoice1.text = str(disMeasManager.GetMGHChoices()[1])
# mghChoice2 = SubElement(DisMeas, 'mghChoice2')
# mghChoice2.text = str(disMeasManager.GetMGHChoices()[2])
# mghChoice3 = SubElement(DisMeas, 'mghChoice3')
# mghChoice3.text = str(disMeasManager.GetMGHChoices()[3])
# mghChoice4 = SubElement(DisMeas, 'mghChoice4')
# mghChoice4.text = str(disMeasManager.GetMGHChoices()[4])
discharge = SubElement(DisMeas, 'discharge')
discharge.text = str(disMeasManager.dischCtrl)
# dischCombo = SubElement(DisMeas, 'dischCombo')
# dischCombo.text = str(disMeasManager.dischCombo)
uncertainty = SubElement(DisMeas, 'uncertainty')
uncertainty.text = str(disMeasManager.uncertaintyCtrl)
mmtTimeVal = SubElement(DisMeas, 'mmtTimeVal')
mmtTimeVal.text = str(disMeasManager.mmtValTxt)
shift = SubElement(DisMeas, 'shift')
shift.text = str(disMeasManager.shiftCtrl)
diff = SubElement(DisMeas, 'diff')
diff.text = str(disMeasManager.diffCtrl)
curve = SubElement(DisMeas, 'curve')
curve.text = str(disMeasManager.curveCtrl)
condition = SubElement(DisMeas, 'condition')
condition.text = str(disMeasManager.controlConditionCmbo)
dischargeRemark = SubElement(DisMeas, 'dischargeRemark')
dischargeRemark.text = disMeasManager.dischRemarksCtrl
controlConditionRemark = SubElement(DisMeas, 'controlConditionRemark')
controlConditionRemark.text = disMeasManager.ControlConditionRemarksCtrl
if disMeasManager.GetAirTempCtrl().GetBackgroundColour() == bkColor:
airTemp.attrib['imported'] = "1"
if disMeasManager.GetWaterTempCtrl().GetBackgroundColour() == bkColor:
waterTemp.attrib['imported'] = "1"
if disMeasManager.GetWidthCtrl().GetBackgroundColour() == bkColor:
width.attrib['imported'] = "1"
if disMeasManager.GetAreaCtrl().GetBackgroundColour() == bkColor:
area.attrib['imported'] = "1"
if disMeasManager.GetMeanVelCtrl().GetBackgroundColour() == bkColor:
meanVel.attrib['imported'] = "1"
if disMeasManager.GetMghCtrl().GetBackgroundColour() == bkColor:
mgh.attrib['imported'] = "1"
if disMeasManager.GetDischCtrl().GetBackgroundColour() == bkColor:
discharge.attrib['imported'] = "1"
if disMeasManager.GetUncertaintyCtrl().GetBackgroundColour() == bkColor:
uncertainty.attrib['imported'] = "1"
if disMeasManager.GetShiftCtrl().GetBackgroundColour() == bkColor:
shift.attrib['imported'] = "1"
if disMeasManager.GetDiffCtrl().GetBackgroundColour() == bkColor:
diff.attrib['imported'] = "1"
if disMeasManager.GetCurveCtrl().GetBackgroundColour() == bkColor:
curve.attrib['imported'] = "1"
# Set Discharge Measurements variables from existing XML structure
def DischMeasFromXML(DisMeas, disMeasManager):
bkColor = disMeasManager.manager.gui.importedBGColor
white = "white"
startTime = DisMeas.find('startTime').text
disMeasManager.startTimeCtrl = "" if startTime is None else startTime
endTime = DisMeas.find('endTime').text
disMeasManager.endTimeCtrl = "" if endTime is None else endTime
airTemp = DisMeas.find('airTemp')
if airTemp.text is None:
disMeasManager.airTempCtrl = ""
else:
disMeasManager.airTempCtrl = airTemp.text
if "imported" in airTemp.attrib and airTemp.attrib['imported'] == "1":
disMeasManager.GetAirTempCtrl().SetBackgroundColour(bkColor)
else:
disMeasManager.GetAirTempCtrl().SetBackgroundColour(white)
waterTemp = DisMeas.find('waterTemp')
if waterTemp.text is None:
disMeasManager.waterTempCtrl = ""
else:
disMeasManager.waterTempCtrl = waterTemp.text
if "imported" in waterTemp.attrib and waterTemp.attrib['imported'] == "1":
disMeasManager.GetWaterTempCtrl().SetBackgroundColour(bkColor)
else:
disMeasManager.GetWaterTempCtrl().SetBackgroundColour(white)
width = DisMeas.find('width')
if width.text is None:
disMeasManager.widthCtrl = ""
else:
disMeasManager.widthCtrl = width.text
if "imported" in width.attrib and width.attrib['imported'] == "1":
disMeasManager.GetWidthCtrl().SetBackgroundColour(bkColor)
else:
disMeasManager.GetWidthCtrl().SetBackgroundColour(white)
area = DisMeas.find('area')
if area.text is None:
disMeasManager.areaCtrl = ""
else:
disMeasManager.areaCtrl = area.text
if "imported" in area.attrib and area.attrib['imported'] == "1":
disMeasManager.GetAreaCtrl().SetBackgroundColour(bkColor)
else:
disMeasManager.GetAreaCtrl().SetBackgroundColour(white)
meanVel = DisMeas.find('meanVel')
if meanVel.text is None:
disMeasManager.meanVelCtrl = ""
else:
disMeasManager.meanVelCtrl = meanVel.text
if "imported" in meanVel.attrib and meanVel.attrib['imported'] == "1":
disMeasManager.GetMeanVelCtrl().SetBackgroundColour(bkColor)
else:
disMeasManager.GetMeanVelCtrl().SetBackgroundColour(white)
mgh = DisMeas.find('mgh')
if mgh.text is None:
disMeasManager.mghCtrl = ""
else:
disMeasManager.mghCtrl = mgh.text
if "imported" in mgh.attrib and mgh.attrib['imported'] == "1":
disMeasManager.GetMghCtrl().SetBackgroundColour(bkColor)
else:
disMeasManager.GetMghCtrl().SetBackgroundColour(white)
discharge = DisMeas.find('discharge')
if discharge.text is None:
disMeasManager.dischCtrl = ""
else:
disMeasManager.dischCtrl = discharge.text
if "imported" in discharge.attrib and discharge.attrib['imported'] == "1":
disMeasManager.GetDischCtrl().SetBackgroundColour(bkColor)
else:
disMeasManager.GetDischCtrl().SetBackgroundColour(white)
uncertainty = DisMeas.find('uncertainty')
if uncertainty is None:
disMeasManager.uncertaintyCtrl = ""
else:
if uncertainty.text is None:
disMeasManager.uncertaintyCtrl = ""
else:
disMeasManager.uncertaintyCtrl = uncertainty.text
if "imported" in uncertainty.attrib and uncertainty.attrib['imported'] == "1":
disMeasManager.GetUncertaintyCtrl().SetBackgroundColour(bkColor)
else:
disMeasManager.GetUncertaintyCtrl().SetBackgroundColour(white)
# dischCombo = DisMeas.find('dischCombo')
# if dischCombo is None or dischCombo.text is None:
# disMeasManager.dischCombo = ""
# else:
# disMeasManager.dischCombo = dischCombo.text
mmtTimeVal = DisMeas.find('mmtTimeVal').text
disMeasManager.mmtValTxt = "" if mmtTimeVal is None else mmtTimeVal
shift = DisMeas.find('shift')
if shift.text is None:
disMeasManager.shiftCtrl = ""
else:
disMeasManager.shiftCtrl = shift.text
if "imported" in shift.attrib and shift.attrib['imported'] == "1":
disMeasManager.GetShiftCtrl().SetBackgroundColour(bkColor)
else:
disMeasManager.GetShiftCtrl().SetBackgroundColour(white)
diff = DisMeas.find('diff')
if diff.text is None:
disMeasManager.diffCtrl = ""
else:
disMeasManager.diffCtrl = diff.text
if "imported" in diff.attrib and diff.attrib['imported'] == "1":
disMeasManager.GetDiffCtrl().SetBackgroundColour(bkColor)
else:
disMeasManager.GetDiffCtrl().SetBackgroundColour(white)
curve = DisMeas.find('curve')
if curve.text is None:
disMeasManager.curveCtrl = ""
else:
disMeasManager.curveCtrl = curve.text
if "imported" in curve.attrib and curve.attrib['imported'] == "1":
disMeasManager.GetCurveCtrl().SetBackgroundColour(bkColor)
else:
disMeasManager.GetCurveCtrl().SetBackgroundColour(white)
try:
mghCmbo = DisMeas.find('mghCmbo').text
disMeasManager.mghCmbo = "" if mghCmbo is None else mghCmbo
except:
pass
try:
condition = DisMeas.find('condition').text
disMeasManager.controlConditionCmbo = "" if condition is None else condition
dischargeRemark = DisMeas.find('dischargeRemark').text
disMeasManager.dischRemarksCtrl = "" if dischargeRemark is None else dischargeRemark
controlConditionRemark = DisMeas.find('controlConditionRemark').text
disMeasManager.ControlConditionRemarksCtrl = "" if controlConditionRemark is None else controlConditionRemark
except:
pass
# Create XML structure for Environment Conditions (Station Health / Gauge Maintenance)
def EnvCondAsXMLTree(EnvCond, envCondManager):
levels = SubElement(EnvCond, 'levels')
levels.text = envCondManager.levelsCtrl
cloudCover = SubElement(EnvCond, 'cloudCover')
cloudCover.text = envCondManager.cloudCoverCmbo
precip = SubElement(EnvCond, 'precipitation')
precip.text = envCondManager.precipCmbo
windMagnitude = SubElement(EnvCond, 'windMagnitude')
windMagnitude.text = envCondManager.windMagCmbo
windMagVel = SubElement(EnvCond, 'windMagnitudeSpeed')
windMagVel.text = envCondManager.windMagCtrl
windDir = SubElement(EnvCond, 'windDirection')
windDir.text = envCondManager.windDirCmbo
batteryVolt = SubElement(EnvCond, 'batteryVolt')
batteryVolt.text = envCondManager.batteryCtrl
gasSys = SubElement(EnvCond, 'gasSys')
gasSys.text = envCondManager.gasSysCtrl
feed = SubElement(EnvCond, 'feed')
feed.text = envCondManager.feedCtrl
bpmRotChoice = SubElement(EnvCond, 'bpmRotChoice')
bpmRotChoice.text = envCondManager.bpmrotCmbo
bpmRot = SubElement(EnvCond, 'bpmRot')
bpmRot.text = envCondManager.bpmrotCtrl
gasSysDepCtrl = SubElement(EnvCond, 'gasSysDepCtrl')
gasSysDepCtrl.text = envCondManager.gasSysDepCtrl
gasArrTime = SubElement(EnvCond, 'gasArrTime')
gasArrTime.text = envCondManager.gasArrTime
gasDepTime = SubElement(EnvCond, 'gasDepTime')
gasDepTime.text = envCondManager.gasDepTime
feedDepCtrl = SubElement(EnvCond, 'feedDepCtrl')
feedDepCtrl.text = envCondManager.feedDepCtrl
feedArrTime = SubElement(EnvCond, 'feedArrTime')
feedArrTime.text = envCondManager.feedArrTime
feedDepTime = SubElement(EnvCond, 'feedDepTime')
feedDepTime.text = envCondManager.feedDepTime
bpmrotDepCtrl = SubElement(EnvCond, 'bpmrotDepCtrl')
bpmrotDepCtrl.text = envCondManager.bpmrotDepCtrl
bpmrotArrTime = SubElement(EnvCond, 'bpmrotArrTime')
bpmrotArrTime.text = envCondManager.bpmrotArrTime
bpmrotDepTime = SubElement(EnvCond, 'bpmrotDepTime')
bpmrotDepTime.text = envCondManager.bpmrotDepTime
intakeFlushed = SubElement(EnvCond, 'intakeFlushed')
intakeFlushed.text = str(envCondManager.intakeCB)
intakeTime = SubElement(EnvCond, 'intakeTime')
intakeTime.text = str(envCondManager.intakeTimeCtrl)
orificeTime = SubElement(EnvCond, 'orificeTime')
orificeTime.text = str(envCondManager.orificeTimeCtrl)
orificePurged = SubElement(EnvCond, 'orificePurged')
orificePurged.text = str(envCondManager.orificeCB)
downloadedProgram = SubElement(EnvCond, 'downloadedProgram')
downloadedProgram.text = str(envCondManager.programCB)
downloadedData = SubElement(EnvCond, 'downloadedData')
downloadedData.text = str(envCondManager.dataCB)
dataPeriodStart = SubElement(EnvCond, 'dataPeriodStart')
dataPeriodStart.text = str(envCondManager.dataPeriodFromPicker)
dataPeriodEnd = SubElement(EnvCond, 'dataPeriodEnd')
dataPeriodEnd.text = str(envCondManager.dataPeriodToPicker)
stationHealthRemark = SubElement(EnvCond, 'stationHealthRemark')
stationHealthRemark.text = envCondManager.stationHealthRemarksCtrl
# Set Environment Conditions (Station Health / Gauge Maintenance) variables from existing XML structure
def EnvCondFromXML(EnvCond, envCondManager):
levels = EnvCond.find('levels').text
envCondManager.levelsCtrl = "" if levels is None else levels
cloudCover = EnvCond.find('cloudCover').text
envCondManager.cloudCoverCmbo = "" if cloudCover is None else cloudCover
precip = EnvCond.find('precipitation').text
envCondManager.precipCmbo = "" if precip is None else precip
windMagnitude = EnvCond.find('windMagnitude').text
envCondManager.windMagCmbo = "" if windMagnitude is None else windMagnitude
windMagVel = EnvCond.find('windMagnitudeSpeed').text
envCondManager.windMagCtrl = "" if windMagVel is None else windMagVel
windDir = EnvCond.find('windDirection').text
envCondManager.windDirCmbo = "" if windDir is None else windDir
batteryVolt = EnvCond.find('batteryVolt').text
envCondManager.batteryCtrl = "" if batteryVolt is None else batteryVolt
gasSys = EnvCond.find('gasSys').text
envCondManager.gasSysCtrl = "" if gasSys is None else gasSys
feed = EnvCond.find('feed').text
envCondManager.feedCtrl = "" if feed is None else feed
bpmRotChoice = EnvCond.find('bpmRotChoice').text
envCondManager.bpmrotCmbo = "" if bpmRotChoice is None else bpmRotChoice
bpmRot = EnvCond.find('bpmRot').text
envCondManager.bpmrotCtrl = "" if bpmRot is None else bpmRot
try:
gasSysDepCtrl = EnvCond.find('gasSysDepCtrl').text
envCondManager.gasSysDepCtrl = "" if gasSysDepCtrl is None else gasSysDepCtrl
gasArrTime = EnvCond.find('gasArrTime').text
envCondManager.gasArrTime = "" if gasArrTime is None else gasArrTime
gasDepTime = EnvCond.find('gasDepTime').text
envCondManager.gasDepTime = "" if gasDepTime is None else gasDepTime
feedDepCtrl = EnvCond.find('feedDepCtrl').text
envCondManager.feedDepCtrl = "" if feedDepCtrl is None else feedDepCtrl
feedArrTime = EnvCond.find('feedArrTime').text
envCondManager.feedArrTime = "" if feedArrTime is None else feedArrTime
feedDepTime = EnvCond.find('feedDepTime').text
envCondManager.feedDepTime = "" if feedDepTime is None else feedDepTime
bpmrotDepCtrl = EnvCond.find('bpmrotDepCtrl').text
envCondManager.bpmrotDepCtrl = "" if bpmrotDepCtrl is None else bpmrotDepCtrl
bpmrotArrTime = EnvCond.find('bpmrotArrTime').text
envCondManager.bpmrotArrTime = "" if bpmrotArrTime is None else bpmrotArrTime
bpmrotDepTime = EnvCond.find('bpmrotDepTime').text
envCondManager.bpmrotDepTime = "" if bpmrotDepTime is None else bpmrotDepTime
except:
pass
intakeTime = EnvCond.find('intakeTime').text
envCondManager.intakeTimeCtrl = "00:00:00" if intakeTime is None else intakeTime
orificeTime = EnvCond.find('orificeTime').text
envCondManager.orificeTimeCtrl = "00:00:00" if orificeTime is None else orificeTime
intakeFlushed = EnvCond.find('intakeFlushed').text
envCondManager.intakeCB = False if intakeFlushed is None else (False if intakeFlushed == 'False' else True)
orificePurged = EnvCond.find('orificePurged').text
envCondManager.orificeCB = False if orificePurged is None else (False if orificePurged == 'False' else True)
downloadedProgram = EnvCond.find('downloadedProgram').text
envCondManager.programCB = False if downloadedProgram is None else (False if downloadedProgram == 'False' else True)
downloadedData = EnvCond.find('downloadedData').text
if downloadedData == None or downloadedData == 'False':
envCondManager.dataCB = False
else:
envCondManager.dataCB = True
envCondManager.GetDataPeriodFromPicker().Enable(True)
envCondManager.GetDataPeriodToPicker().Enable(True)
dataPeriodStart = EnvCond.find('dataPeriodStart').text
envCondManager.dataPeriodFromPicker = "" if dataPeriodStart is None else dataPeriodStart
dataPeriodEnd = EnvCond.find('dataPeriodEnd').text
envCondManager.dataPeriodToPicker = "" if dataPeriodEnd is None else dataPeriodEnd
if intakeFlushed == 'True':
envCondManager.gui.intakeTimeCtrl.Show()
else:
envCondManager.gui.intakeTimeCtrl.Hide()
if orificePurged == 'True':
envCondManager.gui.orificeTimeCtrl.Show()
else:
envCondManager.gui.orificeTimeCtrl.Hide()
envCondManager.gui.layoutSizer.Layout()
try:
stationHealthRemark = EnvCond.find('stationHealthRemark').text
except:
stationHealthRemark = None
envCondManager.stationHealthRemarksCtrl = "" if stationHealthRemark is None else stationHealthRemark
# Create XML structure for Measurement Results (Sensor Calibrations)
def MeasResultsAsXMLTree(MeasResults, measResultsManager):
# time = SubElement(MeasResults, 'time')
# time.text = str(measResultsManager.timeCtrl)
sensRefsExist = False
SensorRefs = SubElement(MeasResults, 'SensorRefs')
HourMinutes = SubElement(MeasResults, 'HourMinutes')
Times = SubElement(MeasResults, 'Times')
ObservedVals = SubElement(MeasResults, 'ObservedVals')
SensorVals = SubElement(MeasResults, 'SensorVals')
if measResultsManager.sensorRefEntry1 != "":
sensRefsExist = True
sensorRef1 = SubElement(SensorRefs, 'SensorRef', row="1")
sensorRef1.text = measResultsManager.sensorRefEntry1
hour1 = SubElement(HourMinutes, 'Hour', row="1")
hour1.text = measResultsManager.hour1
minute1 = SubElement(HourMinutes, 'Minute', row="1")
minute1.text = measResultsManager.minute1
time = SubElement(Times, 'Time', row="1")
time.text = measResultsManager.GetTime(0)
observedVal1 = SubElement(ObservedVals, 'ObservedVal', row="1")
observedVal1.text = measResultsManager.observedVal1
sensorVal1 = SubElement(SensorVals, 'SensorVal', row="1")
sensorVal1.text = measResultsManager.sensorVal1
if measResultsManager.sensorRefEntry2 != "":
sensRefsExist = True
sensorRef2 = SubElement(SensorRefs, 'SensorRef', row="2")
sensorRef2.text = measResultsManager.sensorRefEntry2
hour2 = SubElement(HourMinutes, 'Hour', row="2")
hour2.text = measResultsManager.hour2
minute2 = SubElement(HourMinutes, 'Minute', row="2")
minute2.text = measResultsManager.minute2
time = SubElement(Times, 'Time', row="2")
time.text = measResultsManager.GetTime(1)
observedVal2 = SubElement(ObservedVals, 'ObservedVal', row="2")
observedVal2.text = measResultsManager.observedVal2
sensorVal2 = SubElement(SensorVals, 'SensorVal', row="2")
sensorVal2.text = measResultsManager.sensorVal2
if measResultsManager.sensorRefEntry3 != "":
sensRefsExist = True
sensorRef3 = SubElement(SensorRefs, 'SensorRef', row="3")
sensorRef3.text = measResultsManager.sensorRefEntry3
hour3 = SubElement(HourMinutes, 'Hour', row="3")
hour3.text = measResultsManager.hour3
minute1 = SubElement(HourMinutes, 'Minute', row="3")
minute1.text = measResultsManager.minute3
time = SubElement(Times, 'Time', row="3")
time.text = measResultsManager.GetTime(2)
observedVal3 = SubElement(ObservedVals, 'ObservedVal', row="3")
observedVal3.text = measResultsManager.observedVal3
sensorVal3 = SubElement(SensorVals, 'SensorVal', row="3")
sensorVal3.text = measResultsManager.sensorVal3
if measResultsManager.sensorRefEntry4 != "":
sensRefsExist = True
sensorRef4 = SubElement(SensorRefs, 'SensorRef', row="4")
sensorRef4.text = measResultsManager.sensorRefEntry4
hour4 = SubElement(HourMinutes, 'Hour', row="4")
hour4.text = measResultsManager.hour4
minute4 = SubElement(HourMinutes, 'Minute', row="4")
minute4.text = measResultsManager.minute4
time = SubElement(Times, 'Time', row="4")
time.text = measResultsManager.GetTime(3)
observedVal4 = SubElement(ObservedVals, 'ObservedVal', row="4")
observedVal4.text = measResultsManager.observedVal4
sensorVal4 = SubElement(SensorVals, 'SensorVal', row="4")
sensorVal4.text = measResultsManager.sensorVal4
# if measResultsManager.sensorRefEntry5 != "":
# sensRefsExist = True
# sensorRef5 = SubElement(SensorRefs, 'SensorRef', row="5")
# sensorRef5.text = measResultsManager.sensorRefEntry5
# hour5 = SubElement(HourMinutes, 'Hour', row="5")
# hour5.text = measResultsManager.hour5
# minute5 = SubElement(HourMinutes, 'Minute', row="5")
# minute5.text = measResultsManager.minute5
# time = SubElement(Times, 'Time', row="5")
# time.text = measResultsManager.GetTime(4)
# observedVal5 = SubElement(ObservedVals, 'ObservedVal', row="5")
# observedVal5.text = measResultsManager.observedVal5
# sensorVal5 = SubElement(SensorVals, 'SensorVal', row="5")
# sensorVal5.text = measResultsManager.sensorVal5
# if measResultsManager.sensorRefEntry6 != "":
# sensRefsExist = True
# sensorRef6 = SubElement(SensorRefs, 'SensorRef', row="6")
# sensorRef6.text = measResultsManager.sensorRefEntry6
if not sensRefsExist:
MeasResults.attrib['empty'] = 'True'
# if measResultsManager.observedVal1 != "":
# observedVal1 = SubElement(ObservedVals, 'ObservedVal', row="1")
# observedVal1.text = measResultsManager.observedVal1