-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathflogger_gui.py
1458 lines (1254 loc) · 62.2 KB
/
flogger_gui.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
import sys
import os
import string
from PyQt4 import QtGui, QtCore, uic
from PyQt4.Qt import SIGNAL
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import subprocess
from parse import *
#from ConfigParser import *
from configobj import ConfigObj
from flogger3 import *
from flogger_settings import *
from LatLon import *
import gpxpy
import matplotlib.pyplot as plt
import mplleaflet
#from flogger_splash import *
from flogger_moviesplash import *
from importlib import import_module
# 20170311
# get the directory of this script
path = os.path.dirname(os.path.abspath(__file__))
#path = "/home/pjr/git_neon.2/OGN-Flight-Logger_V3.2"
print "Current path is: ", path
try:
print "Directory name: ", path
pyrcc4_cmd = "pyrcc4 -o "
pyrcc4_out = os.path.join(path,"flogger_resources_rc.py")
# pyrcc4_out = os.path.join(path,flogger_resources)
pyrcc4_in = os.path.join(path,"flogger_resources.qrc")
pyrcc4_cmd = "pyrcc4 -o %s %s" % (pyrcc4_out, pyrcc4_in)
os.system(pyrcc4_cmd)
try:
resources_rc_path = os.path.join(path, "flogger_resources_rc")
# resources_rc = __import__(resources_rc_path)
# resources_rc = import_module(resources_rc_path)
# resources_rc
# print "Dynamic import success"
except:
print "Dynamic import failed"
# import flogger_resources_rc # pyrcc4 makes the file, then it can be imported
print "PyQt4 flogger_resources_rc.py built and imported-1"
except:
print "failed to compile resources"
exit()
Ui_MainWindow, base_class = uic.loadUiType(os.path.join(path,"flogger.ui"))
Ui_AboutWindow, base_class = uic.loadUiType(os.path.join(path,"flogger_about.ui"))
Ui_HelpWindow, base_class = uic.loadUiType(os.path.join(path,"flogger_help.ui"))
#form = Form()
#form.show()
#splash.finish(form)
#sys.path.append(os.path.dirname(__file__))
#FORM_CLASS, _ = uic.loadUiType(os.path.join(os.path.dirname(__file__), 'flogger.ui'), resource_suffix='')
class AboutWindow(QtGui.QMainWindow, Ui_AboutWindow):
def __init__(self, parent=None):
super(QMainWindow, self).__init__(parent)
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
self.setupUi(self)
# Only one button - Ok
self.OkpushButton.clicked.connect(self.floggerOkpushButton)
return
def floggerOkpushButton(self):
print "About Ok button clicked"
self.close()
return
class HelpWindow(QtGui.QMainWindow, Ui_HelpWindow):
def __init__(self, parent=None):
super(QMainWindow, self).__init__(parent)
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
self.setupUi(self)
# Only one button - Ok
self.HelppushButton.clicked.connect(self.floggerHelppushButton)
return
def floggerHelppushButton(self):
print "Help Ok button clicked"
self.close()
return
#class Window (QtGui.QMainWindow, form_class):
class MyApp(QtGui.QMainWindow, Ui_MainWindow):
def __init__(self):
QtGui.QMainWindow.__init__(self)
Ui_MainWindow.__init__(self)
# Ui_AboutWindow.__init__(self)
# self.Iconlabel.setPixmap(pixmap)
# self.iconlabel.show()
self.show()
self.setupUi(self)
global settings
settings = class_settings()
self.actionAbout.triggered.connect(self.AboutButton)
self.actionHelp_2.triggered.connect(self.HelpButton)
# self.RunningLabel.setText("Stopped")
self.iconpath = os.path.join(path, "flogger_icon-08.png")
print "Icon path: ", self.iconpath
self.setWindowIcon(QtGui.QIcon(self.iconpath))
self.pixmap = QPixmap(self.iconpath)
self.Iconlabel.setPixmap(self.pixmap)
# label = QLabel()
# pixmap = QPixmap('path_to_your_image')
self.Iconlabel.setPixmap(self.pixmap)
# self.Iconlabel = QtGui.QPlainTextEdit(self)
# self.Iconlabel.setMinimumSize (480,150)
# self.Iconlabel.setStyleSheet("background-image: url(self.iconpath); background-attachment: fixed")
# self.Iconlabel.show()
self.actionStart.triggered.connect(self.floggerStart)
self.actionStop.triggered.connect(self.floggerStop)
self.actionQuit.triggered.connect(self.floggerQuit)
# self.AirfieldBaseButton.clicked.connect(self.floggerAirfieldEdit)
# self.AirfieldBaseButton.clicked.connect(self.floggerAirfieldEdit)
# self.APRSUserButton.clicked.connect(self.floggerAPRSUserEdit)
# self.AirfieldDetailsButton.clicked.connect(self.floggerAirfieldDetailsEdit)
# self.MinFlightTimeButton.clicked.connect(self.floggerMinFlightTimeEdit)
self.FleetCheckRadioButton.toggled.connect(self.floggerFleetCheckRadioButton)
self.RecordTracksRadioButton.toggled.connect(self.floggerRecordTracksRadioButton)
self.TakeoffEmailButton.toggled.connect(self.floggerTakeoffEmailButton)
self.LandingEmailButton.toggled.connect(self.floggerLandingEmailButton)
self.LaunchFailuresButton.toggled.connect(self.floggerLaunchFailuresButton)
self.LogTugsButton.toggled.connect(self.floggerLogTugsButton)
self.IGCFormatButton.toggled.connect(self.floggerIGCFormatButton)
self.LiveTestButton.toggled.connect(self.floggerLiveTestButton)
self.UpdateButton.clicked.connect(self.floggerUpdateConfig)
self.CancelButton.clicked.connect(self.floggerCancelConfigUpdate)
self.Add2FleetOkButton.clicked.connect(self.floggerAdd2FleetOkButton)
self.Add2FleetCancelButton.clicked.connect(self.floggerAdd2FleetCancelButton)
self.DelFromFleetOkButton.clicked.connect(self.floggerDelFromFleetOkButton)
self.RunningLabel.setStyleSheet("color: red")
self.FlightLogcalendar.clicked.connect(self.floggerFlightLog)
self.IncludeTugsButton.toggled.connect(self.floggerIncludeTugsButton)
self.FlightLogTable.doubleClicked.connect(self.floggerFlightLogDoubleClicked)
self.FlightLogTable.verticalHeader().sectionClicked.connect(self.floggerFlightLogDoubleClicked)
self.FlightLogTable.setColumnHidden(10, True)
# Initialise values from config file
# filepath = os.path.join(path, "flogger_settings.py")
filepath = os.path.join(path, "flogger_settings_file.txt")
# filename = open(filepath)
try:
self.config = ConfigObj("flogger_settings_file.txt", raise_errors = True)
print "Opened"
except:
print "Open failed"
print self.config
#
# This section reads all the values from the config file and outputs these in the gui fields.
# It also initialises the corresponding settings object config fields. If the values are changed
# in the gui they must be saved in the config file and used as the current values in the settings object
#
old_val = self.getOldValue(self.config, "FLOGGER_AIRFIELD_NAME")
settings.FLOGGER_AIRFIELD_NAME = old_val
# print settings.FLOGGER_AIRFIELD_NAME
self.AirfieldBase.setText(old_val)
old_val = self.getOldValue(self.config, "APRS_USER")
settings.APRS_USER = old_val
self.APRSUser.setText(old_val)
old_val = self.getOldValue(self.config, "APRS_PASSCODE") # This might get parsed as an int - need to watch it!
settings.APRS_PASSCODE = old_val
self.APRSPasscode.setText(old_val)
old_val = self.getOldValue(self.config, "APRS_SERVER_HOST")
settings.APRS_SERVER_HOST = old_val
self.APRSServerHostName.setText(old_val)
old_val = self.getOldValue(self.config, "APRS_SERVER_PORT") # This might get parsed as an int - need to watch it!
settings.APRS_SERVER_PORT = int(old_val)
self.APRSServerPort.setText(old_val)
old_val = self.getOldValue(self.config, "FLOGGER_RAD") # This might get parsed as an int - need to watch it!
settings.FLOGGER_RAD = int(old_val)
self.AirfieldFlarmRadius.setText(old_val)
old_val = self.getOldValue(self.config, "FLOGGER_AIRFIELD_LIMIT") # This might get parsed as an int - need to watch it!
settings.FLOGGER_AIRFIELD_LIMIT = int(old_val)
self.LandOutRadius.setText(old_val)
old_val = self.getOldValue(self.config, "FLOGGER_AIRFIELD_DETAILS")
settings.FLOGGER_AIRFIELD_DETAILS = old_val
self.AirfieldDetails.setText(old_val)
old_val = self.getOldValue(self.config, "FLOGGER_QFE_MIN")
settings.FLOGGER_QFE_MIN = int(old_val)
self.MinFlightQFE.setText(old_val)
old_val = self.getOldValue(self.config, "FLOGGER_MIN_FLIGHT_TIME")
settings.FLOGGER_MIN_FLIGHT_TIME = old_val
self.MinFlightTime.setText(old_val)
old_val = self.getOldValue(self.config, "FLOGGER_V_TAKEOFF_MIN")
settings.FLOGGER_V_TAKEOFF_MIN = old_val
self.MinFlightTakeoffVelocity.setText(old_val)
old_val = self.getOldValue(self.config, "FLOGGER_V_LANDING_MIN")
settings.FLOGGER_V_LANDING_MIN = old_val
self.MinFlightLandingVelocity.setText(old_val)
old_val = self.getOldValue(self.config, "FLOGGER_DT_TUG_LAUNCH")
settings.FLOGGER_DT_TUG_LAUNCH = old_val
self.MinTugLaunchTIme.setText(old_val)
#
# Note this could be done using LatLon
#
old_val_lat = self.getOldValue(self.config, "FLOGGER_LATITUDE") # This might get parsed as a real - need to watch it!
print "Old_val: " + old_val_lat
settings.FLOGGER_LATITUDE = old_val_lat
old_val_lon = self.getOldValue(self.config, "FLOGGER_LONGITUDE") # This might get parsed as a real - need to watch it!
print "Old_lon: " + old_val_lon
settings.FLOGGER_LONGITUDE = old_val_lon
# self.AirfieldLongitude.setText(old_val_lon)
old_latlon = LatLon(Latitude( old_val_lat), Longitude(old_val_lon))
old_latlonstr = old_latlon.to_string('D% %H')
self.AirfieldLatitude.setText(old_latlonstr[0])
self.AirfieldLongitude.setText(old_latlonstr[1])
old_val = self.getOldValue(self.config, "FLOGGER_FLEET_CHECK")
print "Fleet Check: " + old_val
if old_val == "Y":
print "Y"
self.FleetCheckRadioButton.setChecked(True)
else:
print "N"
self.FleetCheckRadioButton.setChecked(False)
settings.FLOGGER_FLEET_CHECK = old_val
old_val = self.getOldValue(self.config, "FLOGGER_LOG_TUGS")
print "Log Tugs Button: ", old_val
if old_val == "Y":
print "Y"
self.LogTugsButton.setChecked(True)
else:
print "N"
self.LogTugsButton.setChecked(False)
settings.FLOGGER_FLEET_CHECK = old_val
# self.LogTugsButton.setChecked(True)
# settings.FLOGGER_LOG_TUGS = "Y"
# settings.FLOGGER_LOG_TUGS = old_val
old_val = self.getOldValue(self.config, "FLOGGER_TRACKS")
print "Record Tracks: " + old_val
if old_val == "Y":
print "Y"
self.RecordTracksRadioButton.setChecked(True)
else:
print "N"
settings.FLOGGER_TRACKS = old_val
old_val = self.getOldValue(self.config, "FLOGGER_TAKEOFF_EMAIL")
print "Email takeoffs is: " + old_val
if old_val == "Y":
print "Y"
self.TakeoffEmailButton.setChecked(True)
else:
print "N"
settings.FLOGGER_TAKEOFF_EMAIL = old_val
old_val = self.getOldValue(self.config, "FLOGGER_LANDING_EMAIL")
print "Email landings is: " + old_val
if old_val == "Y":
print "Y"
self.LandingEmailButton.setChecked(True)
else:
print "N"
settings.FLOGGER_LANDING_EMAIL = old_val
old_val = self.getOldValue(self.config, "FLOGGER_DB_SCHEMA")
settings.FLOGGER_DB_SCHEMA = old_val
self.DBSchemaFile.setText(old_val)
settings.FLOGGER_DB_SCHEMA = old_val
old_val = self.getOldValue(self.config, "FLOGGER_DB_NAME")
settings.FLOGGER_DB_NAME = old_val
self.DBName.setText(old_val)
settings.FLOGGER_DB_NAME = old_val
old_val = self.getOldValue(self.config, "FLOGGER_FLARMNET_DB_URL")
settings.FLOGGER_FLARMNET_DB_URL = old_val
self.FlarmnetURL.setText(old_val)
# settings.FLOGGER_FLARMNET_DB_URL = old_val
old_val = self.getOldValue(self.config, "FLOGGER_OGN_DB_URL")
settings.FLOGGER_OGN_DB_URL = old_val
self.OGNURL.setText(old_val)
# settings.FLOGGER_OGN_DB_URL = old_val
old_val = self.getOldValue(self.config, "FLOGGER_KEEPALIVE_TIME")
settings.FLOGGER_KEEPALIVE_TIME = int(old_val)
self.APRSKeepAliveTIme.setText(old_val)
old_val = self.getOldValue(self.config, "FLOGGER_SMTP_SERVER_URL")
print "Initialise FLOGGER_SMTP_SERVER_URL"
settings.FLOGGER_SMTP_SERVER_URL = old_val
self.SMTPServerURL.setText(old_val)
settings.FLOGGER_SMTP_SERVER_URL = old_val
print "settings.FLOGGER_SMTP_SERVER_URL: ", settings.FLOGGER_SMTP_SERVER_URL
old_val = self.getOldValue(self.config, "FLOGGER_SMTP_SERVER_PORT")
settings.FLOGGER_SMTP_SERVER_PORT = int(old_val)
self.SMTPServerPort.setText(old_val)
settings.FLOGGER_SMTP_SERVER_PORT = int(old_val)
old_val = self.getOldValue(self.config, "FLOGGER_SMTP_TX")
print "TX from file: ", old_val
settings.FLOGGER_SMTP_TX = old_val
self.EmailSenderTX.setText(old_val)
settings.FLOGGER_SMTP_TX = old_val
old_val = self.getOldValue(self.config, "FLOGGER_SMTP_RX")
settings.FLOGGER_SMTP_RX = old_val
self.EmailReceiverRX.setText(old_val)
settings.FLOGGER_SMTP_RX = old_val
old_val = self.getOldValue(self.config, "FLOGGER_APRS_BASES")
i = 1
for item in old_val:
# print "APRS Base: " + item
if i == 1:
self.APRSBase1Edit.setText(item)
i += 1
continue
if i == 2:
self.APRSBase2Edit.setText(item)
i += 1
continue
if i == 3:
self.APRSBase3Edit.setText(item)
i += 1
continue
if i == 4:
self.APRSBase4Edit.setText(item)
i += 1
continue
if i == 5:
self.APRSBase5Edit.setText(item)
i += 1
continue
settings.FLOGGER_APRS_BASES = old_val
# print "APRS_BASES: ", old_val
print "APRS_BASES: ", settings.FLOGGER_APRS_BASES
old_val = self.getOldValue(self.config, "FLOGGER_FLEET_LIST")
# print "FLOGGER_FLEET_LIST: ", old_val
for key in old_val.keys():
# Convert string form of value to int
old_val[key] = int(old_val[key])
# print "Key: ", key, " = ", int(old_val[key])
settings.FLOGGER_FLEET_LIST = old_val
print "FLOGGER_FLEET_LIST: ", settings.FLOGGER_FLEET_LIST
rowPosition = self.FleetListTable.rowCount()
for registration in settings.FLOGGER_FLEET_LIST:
print "rowPosition: ", rowPosition, " Registration: ", registration, " Code: ", settings.FLOGGER_FLEET_LIST[registration]
self.FleetListTable.insertRow(rowPosition)
self.FleetListTable.setItem(rowPosition , 0, QtGui.QTableWidgetItem(registration))
self.FleetListTable.setItem(rowPosition , 1, QtGui.QTableWidgetItem(str(settings.FLOGGER_FLEET_LIST[registration])))
rowPosition = rowPosition + 1
old_val = self.getOldValue(self.config, "FLOGGER_DATA_RETENTION") # This might get parsed as an int - need to watch it!
settings.FLOGGER_DATA_RETENTION = int(old_val)
self.DataRetentionTime.setText(old_val)
old_val = self.getOldValue(self.config, "FLOGGER_LOG_TIME_DELTA") # This might get parsed as an int - need to watch it!
settings.FLOGGER_LOG_TIME_DELTA = int(old_val)
self.LogTimeDelta.setText(old_val)
old_val = self.getOldValue(self.config, "FLOGGER_LOCATION_HORIZON") # This might get parsed as an int - need to watch it!
settings.FLOGGER_LOCATION_HORIZON = old_val
self.HorizonAdjustment.setText(old_val)
old_val = self.getOldValue(self.config, "FLOGGER_DUPLICATE_FLIGHT_DELTA_T")
settings.FLOGGER_DUPLICATE_FLIGHT_DELTA_T = old_val
self.MinFlightDeltaTime.setText(old_val)
old_val = self.getOldValue(self.config, "FLOGGER_QNH")
settings.FLOGGER_QNH = int(old_val)
self.AirfieldQNH.setText(old_val)
old_val = self.getOldValue(self.config, "FLOGGER_FLIGHTS_LOG")
settings.FLOGGER_FLIGHTS_LOG = old_val
self.FlightLogFolder.setText(old_val)
old_val = self.getOldValue(self.config, "FLOGGER_LANDOUT_MODE")
settings.FLOGGER_LANDOUT_MODE = old_val
self.LandoutMsgMode.setText(old_val)
old_val = self.getOldValue(self.config, "FLOGGER_MODE")
if old_val == "test":
print "Live/Test mode state is Test"
self.LiveTestButton.setChecked(True)
old_val = self.getOldValue(self.config, "FLOGGER_INCLUDE_TUG_FLIGHTS")
print "Include Tugs Button: " + old_val
if old_val == "Y":
print "Y"
self.IncludeTugsButton.setChecked(True)
else:
print "N"
settings.FLOGGER_FLEET_CHECK = old_val
# rowPosition = self.FleetListTable.rowCount()
# rowPosition = 1
# for aflight in flight_count:
# print "rowPosition: ", rowPosition, " Registration: ", registration, " Code: ", settings.FLOGGER_FLEET_LIST[registration]
# self.FlightLogTable.insertRow(rowPosition)
# self.FleetListTable.setItem(rowPosition , 0, QtGui.QTableWidgetItem(registration))
# self.FleetListTable.setItem(rowPosition , 1, QtGui.QTableWidgetItem(str(settings.FLOGGER_FLEET_LIST[registration])))
# rowPosition = rowPosition + 1
# self.floggerFleetCheckRadioButtonInit()
#
# GUI Initialisation end
#
#
# Actions Start. Menu Bar
#
def floggerStart(self):
print "flogger start"
settings.FLOGGER_RUN = True
flogger = flogger3()
# flogger.flogger_start(settings)
# print "settings.FLOGGER_SMTP_SERVER_URL: ", settings.FLOGGER_SMTP_SERVER_URL
# print "settings.FLOGGER_SMTP_SERVER_PORT: ", settings.FLOGGER_SMTP_SERVER_PORT
# print "settings.FLOGGER_DB_SCHEMA: ", settings.FLOGGER_DB_SCHEMA
self.RunningLabel.setStyleSheet("color: green")
self.RunningLabel.setText("Running...")
# self.RunningProgressBar.maximum(0)
self.RunningProgressBar.setProperty("maximum", 0)
flogger.flogger_run(settings)
def floggerStop(self):
settings.FLOGGER_RUN = False
self.RunningLabel.setStyleSheet("color: red")
self.RunningLabel.setText("Stopped")
self.RunningProgressBar.setProperty("maximum", 1)
print "flogger stop"
def floggerQuit(self):
print "flogger quit"
#
# Actions Start, update fields
#
def floggerUpdateConfig(self):
print "floggerUpdateConfig called"
self.floggerAirfieldEdit2(True)
self.floggerAPRSUserEdit2(True)
self.floggerAPRSPasscodeEdit2(True)
self.floggerAPRSServerhostEdit2(True)
self.floggerAPRSServerportEdit2(True)
self.floggerFlarmRadiusEdit2(True)
self.floggerLandoutRadiusEdit2(True)
self.floggerDataRetentionTimeEdit2(True)
self.floggerAirfieldDetailsEdit2(True)
self.floggerAirfieldLatLonEdit2(True)
self.floggerMinFlightTimeEdit2(True)
self.floggerMinTakeoffVelocityEdit2(True)
self.floggerMinLandingVelocityEdit2(True)
self.floggerMinFlightQFEEdit2(True)
self.floggerTugLaunchEdit2(True)
self.floggerKeepAliveTime2(True)
self.floggerDBSchemaFileEdit2(True)
self.floggerDBNameEdit2(True)
self.floggerFlarmnetURL2(True)
self.floggerOGNURL2(True)
self.floggerSMTPServerURLEdit2(True)
self.floggerSMTPServerPortEdit2(True)
self.floggerEmailSenderEdit2(True)
self.floggerEmailReceiverEdit2(True)
self.floggerAPRSBaseEdit2(True)
self.floggerLogTimeDeltaEdit2(True)
self.floggerHorizonAdjustmentEdit2(True)
self.floggerMinFlightDeltaTimeEdit2(True)
self.floggerMinFlightDeltaTimeEdit2(True)
self.floggerAirfieldQNHEdit2(True)
self.floggerFlightLogFolderEdit2(True)
self.floggerLandoutMsgModeEdit2(True)
# self.floggerIncludeTugFlightsEdit2(True)
return
def floggerCancelConfigUpdate(self):
print "floggerCancelConfigUpdate called"
self.floggerAirfieldEdit2(False)
self.floggerAPRSUserEdit2(False)
self.floggerAPRSPasscodeEdit2(False)
self.floggerAPRSServerhostEdit2(False)
self.floggerAPRSServerportEdit2(False)
self.floggerFlarmRadiusEdit2(False)
self.floggerLandoutRadiusEdit2(False)
self.floggerDataRetentionTimeEdit2(False)
self.floggerAirfieldDetailsEdit2(False)
self.floggerAirfieldLatLonEdit2(False)
self.floggerMinFlightTimeEdit2(False)
self.floggerMinTakeoffVelocityEdit2(False)
self.floggerMinLandingVelocityEdit2(False)
self.floggerMinFlightQFEEdit2(False)
self.floggerTugLaunchEdit2(False)
self.floggerKeepAliveTime2(False)
self.floggerDBSchemaFileEdit2(False)
self.floggerDBNameEdit2(False)
self.floggerFlarmnetURL2(False)
self.floggerOGNURL2(False)
self.floggerSMTPServerURLEdit2(False)
self.floggerSMTPServerPortEdit2(False)
self.floggerEmailSenderEdit2(False)
self.floggerEmailReceiverEdit2(False)
self.floggerAPRSBaseEdit2(False)
self.floggerLogTimeDeltaEdit2(False)
self.floggerHorizonAdjustmentEdit2(False)
self.floggerMinFlightDeltaTimeEdit2(False)
self.floggerAirfieldQNHEdit2(False)
self.floggerFlightLogFolderEdit2(False)
self.floggerLandoutMsgModeEdit2(False)
# self.floggerIncludeTugFlightsEdit2(False)
return
def floggerAirfieldEdit2(self, mode):
# Mode: True - update all fields, valraible to latest valuese
# False - restore all fields and variables to values from config (settings.txt) file
print "Base Airfield button clicked ", "Mode: ", mode
if mode:
# Values have been put into gui field from setting.txt and may then have been changed interactively
airfield_base = self.AirfieldBase.toPlainText()
else:
# Restore old values from settings.txt
old_val = self.getOldValue(self.config, "FLOGGER_AIRFIELD_NAME")
# settings.FLOGGER_AIRFIELD_NAME = old_val
print settings.FLOGGER_AIRFIELD_NAME
self.AirfieldBase.setText(old_val)
print "Airfield Base: " + old_val
airfield_base = old_val
# Put current value into settings.txt file for future use
self.editConfigField("flogger_settings_file.txt", "FLOGGER_AIRFIELD_NAME", airfield_base)
# Now update python variable to current value in gui and settings.txt
self.FLOGGER_AIRFIELD_NAME = airfield_base
def floggerAPRSUserEdit2(self, mode):
print "APRS User button clicked"
if mode:
APRSUser = self.APRSUser.toPlainText()
else:
old_val = self.getOldValue(self.config, "APRS_USER")
self.APRSUser.setText(old_val)
APRSUser = old_val
# print "Airfield B: " + airfield_base
self.editConfigField("flogger_settings_file.txt", "APRS_USER", APRSUser)
self.APRS_USER = APRSUser
def floggerAPRSPasscodeEdit2(self, mode):
print "APRS Passcode button clicked"
if mode:
APRSPasscode = self.APRSPasscode.toPlainText()
else:
old_val = self.getOldValue(self.config, "APRS_PASSCODE")
self.APRSPasscode.setText(old_val)
APRSPasscode = old_val
self.editConfigField("flogger_settings_file.txt", "APRS_PASSCODE", APRSPasscode)
self.APRS_PASSCODE = APRSPasscode
def floggerAPRSServerhostEdit2(self, mode):
print "APRS Server Host button clicked"
if mode:
APRSServerhost = self.APRSServerHostName.toPlainText()
else:
old_val = self.getOldValue(self.config, "APRS_SERVER_HOST")
self.APRSServerHostName.setText(old_val)
APRSServerhost = old_val
self.editConfigField("flogger_settings_file.txt", "APRS_SERVER_HOST", APRSServerhost)
self.APRS_SERVER_HOST = APRSServerhost
def floggerAPRSServerportEdit2(self, mode):
print "APRS Server Port button clicked"
if mode:
APRSServerport = self.APRSServerPort.toPlainText()
else:
old_val = self.getOldValue(self.config, "APRS_SERVER_PORT")
self.APRSServerPort.setText(old_val)
APRSServerport = old_val
self.editConfigField("flogger_settings_file.txt", "APRS_SERVER_PORT", APRSServerport)
self.APRS_SERVER_PORT = int(APRSServerport)
def floggerDataRetentionTimeEdit2(self, mode):
print "Data Retention TIme button clicked"
if mode:
DataRetentionTime = self.DataRetentionTime.toPlainText()
else:
old_val = self.getOldValue(self.config, "FLOGGER_DATA_RETENTION")
self.DataRetentionTime.setText(old_val)
DataRetentionTime = old_val
self.editConfigField("flogger_settings_file.txt", "FLOGGER_DATA_RETENTION", DataRetentionTime)
self.FLOGGER_DATA_RETENTION = int(DataRetentionTime)
def floggerLogTimeDeltaEdit2(self, mode):
print "Log Time Delta button clicked"
if mode:
LogTimeDelta = self.LogTimeDelta.toPlainText()
else:
old_val = self.getOldValue(self.config, "FLOGGER_LOG_TIME_DELTA")
self.LogTimeDelta.setText(old_val)
LogTimeDelta = old_val
self.editConfigField("flogger_settings_file.txt", "FLOGGER_LOG_TIME_DELTA", LogTimeDelta)
self.FLOGGER_LOG_TIME_DELTA = int(LogTimeDelta)
def floggerHorizonAdjustmentEdit2(self, mode):
print "Horizon Adjustment button clicked"
if mode:
HorizonAdjustment = self.HorizonAdjustment.toPlainText()
else:
old_val = self.getOldValue(self.config, "FLOGGER_LOCATION_HORIZON")
self.HorizonAdjustment.setText(old_val)
HorizonAdjustment = old_val
self.editConfigField("flogger_settings_file.txt", "FLOGGER_LOCATION_HORIZON", HorizonAdjustment)
self.FLOGGER_LOCATION_HORIZON = HorizonAdjustment
def floggerAirfieldQNHEdit2(self, mode):
print "QNH Setting button clicked"
if mode:
AirfieldQNH = self.AirfieldQNH.toPlainText()
else:
old_val = self.getOldValue(self.config, "FLOGGER_QNH")
self.AirfieldQNH.setText(old_val)
AirfieldQNH = old_val
self.editConfigField("flogger_settings_file.txt", "FLOGGER_QNH", AirfieldQNH)
self.FLOGGER_QNH = int(AirfieldQNH)
def floggerFlarmRadiusEdit2(self, mode):
print "Flarm Radius button clicked"
if mode:
FlarmRadius = self.AirfieldFlarmRadius.toPlainText()
else:
old_val = self.getOldValue(self.config, "FLOGGER_RAD")
self.AirfieldFlarmRadius.setText(old_val)
FlarmRadius = old_val
self.editConfigField("flogger_settings_file.txt", "FLOGGER_RAD", FlarmRadius)
self.FLOGGER_RAD = int(FlarmRadius)
def floggerLandoutRadiusEdit2(self, mode):
print "Flarm Radius button clicked"
if mode:
LandOutRadius = self.LandOutRadius.toPlainText()
else:
old_val = self.getOldValue(self.config, "FLOGGER_AIRFIELD_LIMIT")
self.LandOutRadius.setText(old_val)
LandOutRadius = old_val
self.editConfigField("flogger_settings_file.txt", "FLOGGER_AIRFIELD_LIMIT", LandOutRadius)
self.FLOGGER_AIRFIELD_LIMIT = int(LandOutRadius)
def floggerAirfieldDetailsEdit2(self, mode):
print "Airfield Details button clicked"
if mode:
airfield_details = self.AirfieldDetails.toPlainText()
else:
old_val = self.getOldValue(self.config, "FLOGGER_AIRFIELD_DETAILS")
self.AirfieldDetails.setText(old_val)
airfield_details = old_val
self.editConfigField("flogger_settings_file.txt", "FLOGGER_AIRFIELD_DETAILS", airfield_details)
def floggerAirfieldLatLonEdit2(self, mode):
print "Airfield latitude, longitude called"
if mode:
airfieldLat = self.AirfieldLatitude.toPlainText()
airfieldLon = self.AirfieldLongitude.toPlainText()
airfieldlatlon = string2latlon(str(airfieldLat), str(airfieldLon), 'D% %H')
print "Airfield lat/lon: ", airfieldlatlon
airfieldLatLonStr = airfieldlatlon.to_string("%D")
print "Update Lat/Lon: ", airfieldLatLonStr
print "Latlonstr: ", airfieldLatLonStr[0], " :", airfieldLatLonStr[1]
old_val_lat = airfieldLatLonStr[0]
old_val_lon = airfieldLatLonStr[1]
else:
old_val_lat = self.getOldValue(self.config, "FLOGGER_LATITUDE")
old_val_lon = self.getOldValue(self.config, "FLOGGER_LONGITUDE")
print "Old Lat: ", old_val_lat, " Old Lon: ", old_val_lon
airfieldlatlon = LatLon(Latitude(old_val_lat), Longitude(old_val_lon))
print "airfieldlatlon: ", airfieldlatlon
airfieldLatLonStr = airfieldlatlon.to_string('D% %H')
print "airfieldlatlonStr: ", airfieldLatLonStr
self.AirfieldLatitude.setText(airfieldLatLonStr[0])
self.AirfieldLongitude.setText(airfieldLatLonStr[1])
self.editConfigField("flogger_settings_file.txt", "FLOGGER_LATITUDE", old_val_lat)
self.editConfigField("flogger_settings_file.txt", "FLOGGER_LONGITUDE", old_val_lon)
return
def floggerMinFlightTimeEdit2(self, mode):
print "Min Flight Time button clicked"
# Note. Format is "HH:MM:SS" ie a string
if mode:
min_flight_time = self.MinFlightTime.toPlainText()
else:
old_val = self.getOldValue(self.config, "FLOGGER_MIN_FLIGHT_TIME")
self.MinFlightTime.setText(old_val)
min_flight_time = old_val
self.editConfigField("flogger_settings_file.txt", "FLOGGER_MIN_FLIGHT_TIME", min_flight_time)
def floggerMinTakeoffVelocityEdit2(self, mode):
print "Min Takeoff Velocity button clicked"
# Note. Format is "HH:MM:SS" ie a string
if mode:
min_takeoff_velocity = self.MinFlightTakeoffVelocity.toPlainText()
else:
old_val = self.getOldValue(self.config, "FLOGGER_V_TAKEOFF_MIN")
self.MinFlightTakeoffVelocity.setText(old_val)
min_takeoff_velocity = old_val
self.editConfigField("flogger_settings_file.txt", "FLOGGER_V_TAKEOFF_MIN", min_takeoff_velocity)
def floggerMinLandingVelocityEdit2(self, mode):
print "Min Landing Velocity button clicked"
# Note. Format is "HH:MM:SS" ie a string
if mode:
min_landing_velocity = self.MinFlightLandingVelocity.toPlainText()
else:
old_val = self.getOldValue(self.config, "FLOGGER_V_LANDING_MIN")
self.MinFlightLandingVelocity.setText(old_val)
min_landing_velocity = old_val
self.editConfigField("flogger_settings_file.txt", "FLOGGER_V_LANDING_MIN", min_landing_velocity)
def floggerMinFlightQFEEdit2(self, mode):
print "Min QFE button clicked"
# Note. Format is "HH:MM:SS" ie a string
if mode:
min_QFE = self.MinFlightQFE.toPlainText()
else:
old_val = self.getOldValue(self.config, "FLOGGER_QFE_MIN")
self.MinFlightQFE.setText(old_val)
min_QFE = int(old_val)
self.editConfigField("flogger_settings_file.txt", "FLOGGER_QFE_MIN", min_QFE)
self.FLOGGER_QFE_MIN = min_QFE
def floggerTugLaunchEdit2(self, mode):
print "Delta Tug Time button clicked"
# Note. Format is "HH:MM:SS" ie a string
if mode:
min_tug_time = self.MinTugLaunchTIme.toPlainText()
else:
old_val = self.getOldValue(self.config, "FLOGGER_DT_TUG_LAUNCH")
self.MinTugLaunchTIme.setText(old_val)
min_tug_time = int(old_val)
self.editConfigField("flogger_settings_file.txt", "FLOGGER_DT_TUG_LAUNCH", min_tug_time)
self.FLOGGER_DT_TUG_LAUNCH = min_tug_time
def floggerFleetCheckRadioButton(self):
print "Fleet Check Radio Button clicked"
if self.FleetCheckRadioButton.isChecked():
print "Fleet check checked"
self.FLOGGER_FLEET_CHECK = "Y"
self.editConfigField("flogger_settings_file.txt", "FLOGGER_FLEET_CHECK", "Y")
else:
print "Fleet check unchecked"
selfFLOGGER_FLEET_CHECK = "N"
self.editConfigField("flogger_settings_file.txt", "FLOGGER_FLEET_CHECK", "N")
# def floggerFleetCheckRadioButtonInit(self):
# print "Fleet Check Radio Button initialise"
# old_val = self.FLOGGER_FLEET_CHECK
# old_val = self.config["FLOGGER_FLEET_CHECK"]
# if old_val == "Y":
# if not self.FleetCheckRadioButton.isChecked():
# print "Settings say yes, button say no"
# self.FleetCheckRadioButton.toggle()
# else:
# print "Settings say yes, button says yes, leave "
# else:
# if self.FleetCheckRadioButton.isChecked():
# print "Settings say no, button says yes"
# self.FleetCheckRadioButton.toggle()
# else:
# print "Settings say no, button says no, leave"
# if old_val == "N" and self.FleetCheckRadioButton.isChecked():
# print "Settings say no, button say yes"
# self.FleetCheckRadioButton.toggle()
#
# if self.FleetCheckRadioButton.isChecked():
# print "Fleet check checked"
# self.FLOGGER_FLEET_CHECK = "Y"
# self.editConfigField("flogger_settings_file.txt", "FLOGGER_FLEET_CHECK", "Y")
# else:
# print "Fleet check unchecked"
# selfFLOGGER_FLEET_CHECK = "N"
# self.editConfigField("flogger_settings_file.txt", "FLOGGER_FLEET_CHECK", "N")
def floggerRecordTracksRadioButton(self):
print "Record Tracks Radio Button clicked"
if self.RecordTracksRadioButton.isChecked():
print "Record Tracks checked"
self.FLOGGER_TRACKS = "Y"
self.editConfigField("flogger_settings_file.txt", "FLOGGER_TRACKS", "Y")
else:
print "Record Tracks unchecked"
self.FLOGGER_TRACKS = "N"
self.editConfigField("flogger_settings_file.txt", "FLOGGER_TRACKS", "N")
def floggerLiveTestButton(self):
print "Live | Test Radio Button clicked"
if self.LiveTestButton.isChecked():
print "Live | Test mode checked: Test Mode"
self.FLOGGER_MODE = "Y"
self.editConfigField("flogger_settings_file.txt", "FLOGGER_MODE", "test")
else:
print "Live | Test mode unchecked: Live Mode"
self.FLOGGER_MODE = "live"
self.editConfigField("flogger_settings_file.txt", "FLOGGER_MODE", "live")
def floggerTakeoffEmailButton(self):
print "Record Takeoff Radio Button clicked"
if self.TakeoffEmailButton.isChecked():
print "Record Takeoff checked"
self.FLOGGER_TAKEOFF_EMAIL = "Y"
self.editConfigField("flogger_settings_file.txt", "FLOGGER_TAKEOFF_EMAIL", "Y")
else:
print "Takeoff Takeoff Button unchecked"
self.FLOGGER_TAKEOFF_EMAIL = "N"
self.editConfigField("flogger_settings_file.txt", "FLOGGER_TAKEOFF_EMAIL", "N")
def floggerLandingEmailButton(self):
print "Landing Email button clicked"
if self.LandingEmailButton.isChecked():
print "Landing Email button checked"
self.FLOGGER_TAKEOFF_EMAIL = "Y"
self.editConfigField("flogger_settings_file.txt", "FLOGGER_LANDING_EMAIL", "Y")
else:
print "Landing Email button unchecked"
self.FLOGGER_LANDING_EMAIL = "N"
self.editConfigField("flogger_settings_file.txt", "FLOGGER_LANDING_EMAIL", "N")
def floggerLaunchFailuresButton(self):
print "Launch Failures button clicked"
if self.LaunchFailuresButton.isChecked():
print "Launch Failures button checked"
self.FLOGGER_LOG_LAUNCH_FAILURES = "Y"
self.editConfigField("flogger_settings_file.txt", "FLOGGER_LOG_LAUNCH_FAILURES", "Y")
else:
print "Launch Failures button unchecked"
self.FLOGGER_LOG_LAUNCH_FAILURES = "N"
self.editConfigField("flogger_settings_file.txt", "FLOGGER_LOG_LAUNCH_FAILURES", "N")
def floggerLogTugsButton(self):
print "Log Tugs button clicked"
if self.LogTugsButton.isChecked():
print "Log Tugs button checked"
self.FLOGGER_LOG_TUGS = "Y"
self.editConfigField("flogger_settings_file.txt", "FLOGGER_LOG_TUGS", "Y")
else:
print "Log Tugs button unchecked"
self.FLOGGER_LOG_TUGS = "N"
self.editConfigField("flogger_settings_file.txt", "FLOGGER_LOG_TUGS", "N")
def floggerIGCFormatButton(self):
print "IGC Format Button clicked"
if self.IGCFormatButton.isChecked():
print "IGC Format button checked"
self.FLOGGER_TRACKS_IGC = "Y"
self.editConfigField("flogger_settings_file.txt", "FLOGGER_TRACKS_IGC", "Y")
else:
print "IGC Format button unchecked"
self.FLOGGER_TRACKS_IGC = "N"
self.editConfigField("flogger_settings_file.txt", "FLOGGER_TRACKS_IGC", "N")
def floggerIncludeTugsButton(self):
print "Include Tugs Radio Button clicked"
if self.IncludeTugsButton.isChecked():
print "Include Tugs Button checked"
self.FLOGGER_INCLUDE_TUG_FLIGHTS = "Y"
else:
print "Include Tugs Button unchecked"
self.FLOGGER_INCLUDE_TUG_FLIGHTS = "N"
self.editConfigField("flogger_settings_file.txt", "FLOGGER_INCLUDE_TUG_FLIGHTS", self.FLOGGER_INCLUDE_TUG_FLIGHTS)
def floggerKeepAliveTime2(self, mode):
print "Keep Alive Time button clicked"
if mode:
keep_alive_time = self.APRSKeepAliveTIme.toPlainText()
else:
old_val = self.getOldValue(self.config, "FLOGGER_KEEPALIVE_TIME")
self.APRSKeepAliveTIme.setText(old_val)
keep_alive_time = old_val
self.editConfigField("flogger_settings_file.txt", "FLOGGER_KEEPALIVE_TIME", keep_alive_time)
self.FLOGGER_KEEPALIVE_TIME = keep_alive_time
def floggerDBSchemaFileEdit2(self, mode):
print "DB Schema File button clicked"
if mode:
db_schema_file = self.DBSchemaFile.toPlainText()
else:
old_val = self.getOldValue(self.config, "FLOGGER_DB_SCHEMA")
self.DBSchemaFile.setText(old_val)
db_schema_file = old_val
self.editConfigField("flogger_settings_file.txt", "FLOGGER_DB_SCHEMA", db_schema_file)
self.FLOGGER_DB_SCHEMA = db_schema_file
def floggerDBNameEdit2(self, mode):
print "DB Schema File button clicked"
if mode:
db_name = self.DBName.toPlainText()
else:
old_val = self.getOldValue(self.config, "FLOGGER_DB_NAME")
self.DBName.setText(old_val)
db_name = old_val
self.editConfigField("flogger_settings_file.txt", "FLOGGER_DB_NAME", db_name)
self.FLOGGER_DB_NAME = db_name
def floggerFlarmnetURL2(self, mode):
print "Flarmnet URL button clicked"
if mode:
Flarmnet_URL = self.FlarmnetURL.toPlainText()
else:
old_val = self.getOldValue(self.config, "FLOGGER_FLARMNET_DB_URL")
self.FlarmnetURL.setText(old_val)
Flarmnet_URL = old_val
self.editConfigField("flogger_settings_file.txt", "FLOGGER_FLARMNET_DB_URL", Flarmnet_URL)
self.FLOGGER_FLARMNET_DB_URL = Flarmnet_URL
def floggerOGNURL2(self, mode):
print "OGN URL button clicked"
if mode:
OGNURL = self.OGNURL.toPlainText()
else:
old_val = self.getOldValue(self.config, "FLOGGER_OGN_DB_URL")
self.OGNURL.setText(old_val)
OGNURL = old_val
self.editConfigField("flogger_settings_file.txt", "FLOGGER_OGN_DB_URL", OGNURL)
self.FLOGGER_OGN_DB_URL = OGNURL
def floggerSMTPServerURLEdit(self):
print "SMTP Server URL button clicked"
smtp_server_URL = self.SMTPServerURL.toPlainText()
print "SMTP Server URL: " + smtp_server_URL
self.editConfigField("flogger_settings_file.txt", "FLOGGER_SMTP_SERVER_URL", smtp_server_URL)
smtp_server_URL = self.config["FLOGGER_SMTP_SERVER_URL"]
self.FLOGGER_SMTP_SERVER_URL = smtp_server_URL
def floggerSMTPServerURLEdit2(self, mode):
print "SMTP Server URL button clicked"
if mode:
smtp_server_URL = self.SMTPServerURL.toPlainText()
else:
old_val = self.getOldValue(self.config, "FLOGGER_SMTP_SERVER_URL")
self.SMTPServerURL.setText(old_val)
smtp_server_URL = old_val
self.editConfigField("flogger_settings_file.txt", "FLOGGER_SMTP_SERVER_URL", smtp_server_URL)