-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathTouchRTKStation.py
1186 lines (1025 loc) · 43.2 KB
/
TouchRTKStation.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
# -*- coding: utf-8 -*-
"""
@author: Yusuke Takahashi, Taro Suzuki, Waseda University
"""
import sys,os,shlex,glob,time,re
from subprocess import Popen,PIPE,check_output
from PyQt5.QtWidgets import (QWidget, QPushButton,QHBoxLayout, QVBoxLayout,QCheckBox,QGroupBox,QScrollArea,
QApplication,QSizePolicy,QMainWindow,QMessageBox,QDialog,QTabWidget,QComboBox,QLabel,QLineEdit,QFormLayout,QGridLayout)
from PyQt5.QtGui import QFont,QColor,QPixmap
from PyQt5 import QtCore
import telnetlib
# Main Window
class MainWindow(QMainWindow):
dirtrs = os.path.dirname(os.path.abspath(__file__))
dirrtk = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
# serial port settings
serial_port = (['serial0','serial1','ttyACM0','ttyACM1','ttyUSB0','ttyUSB1'])
serial_bitrate = (['300','600','1200','2400','4800','9600','19200','38400','57600','115200','230400'])
serial_bytesize = (['7 bits','8 bits']) #[7 8]
serial_parity = (['None','Even','Odd']) #[n e o]
serial_stopbits = (['1 bit','2 bits']) #[1 2]
serial_flowcontrol = (['None','RTS/CTS']) #[off rtscts]
# ublox command file for Base/Rover mode
ubxcmd = dirtrs+'/conf/ubx_m8t_bds_raw_1hz.cmd'
# Default Base position configuration
basepos_type = (['LLH','RTCM']) # for Rover
basepos_itype = 1 # for Rover
basepos_lat = '35.0'
basepos_lon = '139.0'
basepos_hgt = '50.0'
# Default Input stream configration
input_iport= 2 # ttyACM0
input_ibitrate = 9 # 115200 bps
input_ibytesize = 1 # 8 bit
input_iparity = 0 # None
input_istopbits = 0 # 1 bit
input_iflowcontrol = 0 # None
# Default Correction stream configration
corr_flag = False
corr_type = (['NTRIP Client','TCP Client'])
corr_itype = 0
corr_format = (['RTCM2','RTCM3','BINEX','UBX'])
corr_iformat = 1
corr_user = 'user'
corr_addr = 'test.net'
corr_port = '2101'
corr_pw = 'password'
corr_mp = 'RTCM'
# Default Correction(Serial) stream configration
corr2_flag = False
corr2_format = (['RTCM2','RTCM3','BINEX','UBX'])
corr2_iformat = 3
corr2_iport= 4 # ttyUSB0
corr2_ibitrate = 9 # 115200 bps
corr2_ibytesize = 1 # 8 bit
corr2_iparity = 0 # None
corr2_istopbits = 0 # 1 bit
corr2_iflowcontrol = 0 # None
# Default Log/Solution stream configration
log_flag = True
sol_flag = True
dir = glob.glob('/media/*/*/') # Find USB memory
if len(dir)==0:
dir = [dirtrs+'/']
sol_filename = dir[0]+'%Y-%m%d-%h%M%S.pos'
log_filename = dir[0]+'%Y-%m%d-%h%M%S.ubx'
# Default Output stream configration
output_flag = False
output_type=(['TCP Server','NTRIP Server','NTRIP Caster'])
output_itype = 0 # TCP Server
output_format = (['UBX','RTCM3'])
output_iformat = 0 # UBX
output_user = 'user'
output_addr = 'test.net'
output_port = '2101'
output_pw = 'password'
output_mp = 'TRS'
# Default Output(Serial) stream configration
output2_flag = False
output2_format = (['UBX','RTCM3'])
output2_iformat = 0 # UBX
output2_iport= 4 # ttyUSB0
output2_ibitrate = 9 # 115200 bps
output2_ibytesize = 1 # 8 bit
output2_iparity = 0 # None
output2_istopbits = 0 # 1 bit
output2_iflowcontrol = 0 # None
def __init__(self):
super().__init__()
self.initUI()
# Initialization
def initUI(self):
self.rover_timer = QtCore.QTimer(self)
self.rover_timer.timeout.connect(self.updateRover)
self.base_timer = QtCore.QTimer(self)
self.base_timer.timeout.connect(self.updateBase)
self.main_w = MainWidget()
self.setCentralWidget(self.main_w)
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
# self.setGeometry(100, 100, 480, 320) # For debug
self.showFullScreen()
self.show()
# Dispaly status in rover mode
def updateRover(self):
rawsol=self.main_w.rtkrcvCommand(self.main_w.tn,'solution')
print(rawsol)
if len(rawsol)>34:
soltypes=re.findall(r'\(.*\)',rawsol)
soltype=soltypes[0][1:-1].strip()
sols=re.findall(r'\d*\.\d*',rawsol)
self.main_w.lSol.setText(soltype)
if soltype=='SINGLE':
self.main_w.lSol.setStyleSheet('color: #ff0000; font-family: Helvetica; font-size: 11pt')
if soltype=='FLOAT':
self.main_w.lSol.setStyleSheet('color: #ffd700; font-family: Helvetica; font-size: 11pt')
if soltype=='FIX':
self.main_w.lSol.setStyleSheet('color: #008000; font-family: Helvetica; font-size: 11pt')
self.main_w.lLat.setText(sols[1])
self.main_w.lLon.setText(sols[2])
self.main_w.lAlt.setText(sols[3])
rawstream=self.main_w.rtkrcvCommand(self.main_w.tn,'stream')
rawstreams=rawstream.split('\n')
# print(rawstream)
statstr=''
for stream in rawstreams:
if stream.find('error')>0:
streams=stream.split()
statstr=streams[0]+' stream error'
if stream.find(' C ')>0:
streams=stream.split()
if streams[0]=='input':
statstr=statstr+streams[1]+':'+streams[6]+'bps '
elif streams[0]=='monitor':
pass
else:
statstr=statstr+streams[0]+':'+streams[8]+'bps '
self.main_w.status_rov.setText(statstr)
# Dispaly status in base mode
def updateBase(self):
rawstream = self.p.stderr.readline().decode('utf-8')
print(rawstream)
if (rawstream=='stream server start error'):
self.main_w.status_base.setText('stream server start error\n')
streams=rawstream.split()
if len(streams)==9:
self.main_w.status_base.setText(streams[0]+' '+streams[1]+' '+streams[5]+'bps '+streams[8])
if len(streams)>=10:
self.main_w.status_base.setText(streams[0]+' '+streams[1]+' '+streams[5]+'bps '+streams[8]+' '+streams[10])
# Main Widget Class
class MainWidget(QWidget):
# telnet port for rtkrcv
tnport=1234
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.setFont(QFont('Helvetica',11))
fig=QPixmap(MainWindow.dirtrs+'/img/banner.png')
bannar=QLabel(self)
bannar.setPixmap(fig)
self.tabs=QTabWidget()
self.tabRover=QWidget()
self.tabBase=QWidget()
self.tabs.addTab(self.tabRover,'Rover')
self.tabs.addTab(self.tabBase,'Base')
self.tabRoverUI()
self.tabBaseUI()
vbox=QVBoxLayout()
vbox.addWidget(bannar)
vbox.addWidget(self.tabs)
self.setLayout(vbox)
# Rover tab
def tabRoverUI(self):
# Start button
self.start_rov = QPushButton('Start',self)
self.start_rov.setCheckable(True)
self.start_rov.setSizePolicy(QSizePolicy.Expanding,QSizePolicy.Expanding)
self.start_rov.toggled.connect(self.startRoverToggled)
self.start_rov.setFont(QFont('Helvetica',16))
# Config button
self.config_rov = QPushButton('Config',self)
self.config_rov.setSizePolicy(QSizePolicy.Expanding,QSizePolicy.Expanding)
self.config_rov.clicked.connect(self.makeRoverConfig)
self.config_rov.setFont(QFont('Helvetica',16))
# Command window
self.status_rov = QLabel('')
self.status_rov.setFont(QFont('Helvetica',11))
scroll=QScrollArea()
scroll.setFrameShape(False)
scroll.setWidgetResizable(True)
scroll.setFixedHeight(25)
scroll.setWidget(self.status_rov)
# Icon
fig=QPixmap(MainWindow.dirtrs+'/img/rover.png')
icon=QLabel(self)
icon.setPixmap(fig)
# Layout
hbox1 = QHBoxLayout()
hbox2 = QHBoxLayout()
hbox3 = QHBoxLayout()
vbox1_1 = QVBoxLayout()
hbox1_1 = QHBoxLayout()
hbox1_2 = QHBoxLayout()
hbox1_3 = QHBoxLayout()
vbox = QVBoxLayout()
# hbox1
hbox1.addSpacing(10)
hbox1.addWidget(icon)
hbox1.addSpacing(10)
self.mode_spp = QPushButton('Single',self)
self.mode_spp.setCheckable(True)
self.mode_spp.toggle()
self.mode_spp.toggled.connect(self.sppToggled)
self.mode_spp.setSizePolicy(QSizePolicy.Expanding,QSizePolicy.Expanding)
self.mode_rtks = QPushButton('RTK\n(Static)',self)
self.mode_rtks.setCheckable(True)
self.mode_rtks.toggled.connect(self.rtksToggled)
self.mode_rtks.setSizePolicy(QSizePolicy.Expanding,QSizePolicy.Expanding)
self.mode_rtkk = QPushButton('RTK\n(Kinematic)',self)
self.mode_rtkk.setCheckable(True)
self.mode_rtkk.toggled.connect(self.rtkkToggled)
self.mode_rtkk.setSizePolicy(QSizePolicy.Expanding,QSizePolicy.Expanding)
hbox1_2.addWidget(self.mode_spp)
hbox1_2.addWidget(self.mode_rtks)
hbox1_2.addWidget(self.mode_rtkk)
vbox1_1.addLayout(hbox1_2)
hbox1_3.addWidget(self.start_rov)
hbox1_3.addWidget(self.config_rov)
vbox1_1.addLayout(hbox1_3)
hbox1.addLayout(vbox1_1)
# Positining results
lSol_=QLabel('Sol:')
lSol_.setAlignment(QtCore.Qt.AlignRight)
self.lSol=QLabel('')
lLat_=QLabel('Lat:')
lLat_.setAlignment(QtCore.Qt.AlignRight)
self.lLat=QLabel('')
lLon_=QLabel('Lon:')
lLon_.setAlignment(QtCore.Qt.AlignRight)
self.lLon=QLabel('')
lAlt_=QLabel('Alt:')
lAlt_.setAlignment(QtCore.Qt.AlignRight)
self.lAlt=QLabel('')
hbox2.addWidget(lSol_)
hbox2.addWidget(self.lSol)
hbox2.addWidget(lLat_)
hbox2.addWidget(self.lLat)
hbox2.addWidget(lLon_)
hbox2.addWidget(self.lLon)
hbox2.addWidget(lAlt_)
hbox2.addWidget(self.lAlt)
# hbox3
hbox3.addWidget(scroll)
# Add to layout
vbox.addLayout(hbox1,1)
vbox.addLayout(hbox2)
vbox.addLayout(hbox3)
# Show layout
self.tabRover.setLayout(vbox)
# Rover config window
def makeRoverConfig(self):
pass
subWindow=RoverConfigWindow(self)
subWindow.show()
# Base tab
def tabBaseUI(self):
# Start button
self.start_base = QPushButton('Start',self)
self.start_base.setCheckable(True)
self.start_base.setSizePolicy(QSizePolicy.Expanding,QSizePolicy.Expanding)
self.start_base.toggled.connect(self.startBaseToggled)
self.start_base.setFont(QFont('Helvetica',16))
# Config button
self.config_base = QPushButton('Config',self)
self.config_base.setSizePolicy(QSizePolicy.Expanding,QSizePolicy.Expanding)
self.config_base.clicked.connect(self.makeBaseConfig)
self.config_base.setFont(QFont('Helvetica',16))
# Command window
self.status_base = QLabel('')
self.status_base.setFont(QFont('Helvetica',11))
scroll=QScrollArea()
scroll.setFrameShape(False)
scroll.setWidgetResizable(True)
scroll.setFixedHeight(25)
scroll.setWidget(self.status_base)
# Icon
fig=QPixmap(MainWindow.dirtrs+'/img/base.png')
icon=QLabel(self)
icon.setPixmap(fig)
# Layout
hbox1 = QHBoxLayout()
hbox2 = QHBoxLayout()
vbox = QVBoxLayout()
# hbox1
hbox1.addSpacing(10)
hbox1.addWidget(icon)
hbox1.addSpacing(10)
hbox1.addWidget(self.start_base)
hbox1.addWidget(self.config_base)
# hbox2
hbox2.addWidget(scroll)
# Add to layout
vbox.addLayout(hbox1,1)
vbox.addLayout(hbox2)
# Show layout
self.tabBase.setLayout(vbox)
# Base config window
def makeBaseConfig(self):
subWindow=BaseConfigWindow(self)
subWindow.show()
# Send command to rtkrcv
def rtkrcvCommand(self,tn,cmd):
sendcmd=cmd+'\r\n'
tn.write(sendcmd.encode())
ret=tn.read_until(b'rtkrcv> ')
return ret.decode()
# Send option to rtkrcv
def rtkrcvOption(self,tn,opt,val):
cmd='set '+opt+' '+val
self.rtkrcvCommand(tn,cmd)
# Send stream information to rtkrcv
def rtkrcvSetStream(self,tn,name,stype,sformat,spath):
self.rtkrcvOption(tn,name+'-type',stype)
self.rtkrcvOption(tn,name+'-format',sformat)
self.rtkrcvOption(tn,name+'-path',spath)
# Start Rover button
def startRoverToggled(self,checked):
if checked:
self.start_rov.setText('Stop')
self.mode_spp.setDisabled(True)
self.mode_rtks.setDisabled(True)
self.mode_rtkk.setDisabled(True)
self.config_rov.setDisabled(True)
self.tabs.setTabEnabled(1, False)
exe = MainWindow.dirrtk+'/RTKLIB/app/rtkrcv/gcc/rtkrcv'
optfile='single.conf'
if self.mode_rtks.isChecked():
optfile='static.conf'
if self.mode_rtkk.isChecked():
optfile='kinematic.conf'
main.p = Popen(exe+' -o '+MainWindow.dirtrs+'/conf/'+optfile+' -p '+str(self.tnport)+' -m 52001', shell=True)
time.sleep(1)
self.tn = telnetlib.Telnet('localhost',self.tnport)
# login
self.tn.read_until(b'password: ')
self.rtkrcvCommand(self.tn,'admin')
# Stream setting
itype,iformat,ipath,otype,oformat,opath,ltype,lformat,lpath = self.makeCommandRover()
for i,path in enumerate(ipath):
self.rtkrcvSetStream(self.tn,'inpstr'+str(i+1),itype[i],iformat[i],path)
for i,path in enumerate(opath):
self.rtkrcvSetStream(self.tn,'outstr'+str(i+1),otype[i],oformat[i],path)
for i,path in enumerate(lpath):
self.rtkrcvSetStream(self.tn,'logstr'+str(i+1),ltype[i],lformat[i],path)
# Base position
basepos=(['llh','rtcm'])
self.rtkrcvOption(self.tn,'ant2-postype',basepos[MainWindow.basepos_itype])
self.rtkrcvOption(self.tn,'ant2-pos1',MainWindow.basepos_lat)
self.rtkrcvOption(self.tn,'ant2-pos2',MainWindow.basepos_lon)
self.rtkrcvOption(self.tn,'ant2-pos3',MainWindow.basepos_hgt)
# Receiver command
self.rtkrcvOption(self.tn,'file-cmdfile1',MainWindow.ubxcmd)
self.rtkrcvCommand(self.tn,'start')
main.rover_timer.start(1000)
else:
self.start_rov.setText('Start')
self.mode_spp.setDisabled(False)
self.mode_rtks.setDisabled(False)
self.mode_rtkk.setDisabled(False)
self.config_rov.setDisabled(False)
self.tabs.setTabEnabled(1, True)
main.rover_timer.stop()
main.p.terminate()
time.sleep(0.2)
# shutdown
self.tn.write('shutdown\r\n'.encode())
time.sleep(2)
self.status_rov.setText('')
self.lSol.setText('')
self.lLat.setText('')
self.lLon.setText('')
self.lAlt.setText('')
# Start Base button
def startBaseToggled(self,checked):
if checked:
self.start_base.setText('Stop')
self.config_base.setDisabled(True)
self.tabs.setTabEnabled(0, False)
exe = MainWindow.dirrtk+'/RTKLIB/app/str2str/gcc/str2str'
rcvcmd =' -c '+MainWindow.ubxcmd
llhcmd =' -p '+MainWindow.basepos_lat+' '+MainWindow.basepos_lon+' '+MainWindow.basepos_hgt
rtcmcmd=' -msg 1006(10),1004,1019'
opt = self.makeCommandBase()
cmd = shlex.split(exe+opt+rcvcmd+llhcmd+rtcmcmd)
main.p = Popen(cmd, stdin=PIPE, stderr=PIPE, bufsize=0)
main.base_timer.start(1000)
else:
self.start_base.setText('Start')
self.config_base.setDisabled(False)
self.tabs.setTabEnabled(0, True)
main.p.stderr.close()
main.base_timer.stop()
main.p.terminate()
self.status_base.setText('')
# Single button
def sppToggled(self,checked):
if checked:
self.mode_rtks.setChecked(False)
self.mode_rtkk.setChecked(False)
# RTK-Static button
def rtksToggled(self,checked):
if checked:
self.mode_spp.setChecked(False)
self.mode_rtkk.setChecked(False)
# RTK-Kinematic button
def rtkkToggled(self,checked):
if checked:
self.mode_spp.setChecked(False)
self.mode_rtks.setChecked(False)
# Generating Rover commands
def makeCommandRover(self):
corrtypes=['ntripcli','tcpcli']
corrformats=['rtcm2','rtcm3','binex','ubx']
# input
itype=[]
iformat=[]
ipath=[]
itype.append('serial')
iformat.append('ubx')
ipath.append(self.makeInputCmd(1))
# input(correction stream)
if MainWindow.corr_flag:
itype.append(corrtypes[MainWindow.corr_itype])
iformat.append(corrformats[MainWindow.corr_iformat])
if MainWindow.corr_itype==0: # NTRIP Client
ipath.append(self.makeNtripCliCmd())
elif MainWindow.corr_itype==1: # TCP Client
ipath.append(self.makeTcpCliCmd())
if MainWindow.corr2_flag:
itype.append('serial')
iformat.append(corrformats[MainWindow.corr2_iformat])
ipath.append(self.makeCorrectionSerialCmd())
# output
otype=[]
oformat=[]
opath=[]
if MainWindow.sol_flag:
otype.append('file')
oformat.append('llh')
opath.append(self.makeSolCmd())
# log
ltype=[]
lformat=[]
lpath=[]
if MainWindow.log_flag:
ltype.append('file')
lformat.append('')
lpath.append(self.makeLogCmd(1))
print(itype)
print(iformat)
print(ipath)
return itype,iformat,ipath,otype,oformat,opath,ltype,lformat,lpath
# Generating Base commands
def makeCommandBase(self):
outputformats=['ubx','rtcm3']
cmd=self.makeInputCmd(2)
if MainWindow.log_flag:
cmd=cmd+self.makeLogCmd(2)
if MainWindow.output_flag:
if MainWindow.output_itype==0:
cmd=cmd+self.makeTcpSvrCmd()
if MainWindow.output_itype==1:
cmd=cmd+self.makeNtripSvrCmd()
if MainWindow.output_itype==2:
cmd=cmd+self.makeNtripCasCmd()
# Format conversion
if MainWindow.output_iformat:
cmd=cmd+'#'+outputformats[MainWindow.output_iformat]
if MainWindow.output2_flag:
cmd=cmd+self.makeSerialOutputCmd()
# Format conversion
if MainWindow.output2_iformat:
cmd=cmd+'#'+outputformats[MainWindow.output2_iformat]
return cmd
# Generating Input command
def makeInputCmd(self,sta):
byte_s = (['7','8'])
parity_s = (['n','e','o'])
stopb_s =(['1','2'])
flwctr_s =(['off','rtscts'])
port =MainWindow.serial_port[MainWindow.input_iport]
bitrate =MainWindow.serial_bitrate[MainWindow.input_ibitrate]
byte = byte_s[MainWindow.input_ibytesize]
parity = parity_s[MainWindow.input_iparity]
stopb = stopb_s[MainWindow.input_istopbits]
flwctr = flwctr_s[MainWindow.input_iflowcontrol]
cmd = port+':'+bitrate+':'+byte+':'+parity+':'+stopb+':'+flwctr
if sta==2: # for str2str
cmd=' -in serial://'+cmd+'#ubx'
return cmd
# Generating CorrectionSerial command
def makeCorrectionSerialCmd(self):
byte_s = (['7','8'])
parity_s = (['n','e','o'])
stopb_s =(['1','2'])
flwctr_s =(['off','rtscts'])
port =MainWindow.serial_port[MainWindow.corr2_iport]
bitrate =MainWindow.serial_bitrate[MainWindow.corr2_ibitrate]
byte = byte_s[MainWindow.corr2_ibytesize]
parity = parity_s[MainWindow.corr2_iparity]
stopb = stopb_s[MainWindow.corr2_istopbits]
flwctr = flwctr_s[MainWindow.corr2_iflowcontrol]
cmd = port+':'+bitrate+':'+byte+':'+parity+':'+stopb+':'+flwctr
return cmd
# Generating TCP Client command
def makeTcpCliCmd(self):
addr=MainWindow.corr_addr
port=MainWindow.corr_port
return addr+':'+port
# Generating NTRIP Client command
def makeNtripCliCmd(self):
user= MainWindow.corr_user
pw = MainWindow.corr_pw
port= MainWindow.corr_port
mp = MainWindow.corr_mp
addr= MainWindow.corr_addr
return user+':'+pw+'@'+addr+':'+port+'/'+mp
# Generating Solution command
def makeSolCmd(self):
filename=MainWindow.sol_filename
return filename
def makeLogCmd(self,sta):
filename=MainWindow.log_filename
cmd=filename
if sta==2: # for str2str
cmd=' -out file://'+cmd
return cmd
# Generating TCP Server command
def makeTcpSvrCmd(self):
port=MainWindow.output_port
return ' -out tcpsvr://:'+port
# Generating NTRIP Sever command
def makeNtripSvrCmd(self):
pw = MainWindow.output_pw
port= MainWindow.output_port
mp = MainWindow.output_mp
addr= MainWindow.output_addr
return ' -out ntrips://:'+pw+'@'+addr+':'+port+'/'+mp
# Generating NTRIP Caster command
def makeNtripCasCmd(self):
user= MainWindow.output_user
pw = MainWindow.output_pw
port= MainWindow.output_port
mp = MainWindow.output_mp
return ' -out ntripc_c://'+user+':'+pw+'@:'+port+'/'+mp
# Generating Serial output command
def makeSerialOutputCmd(self):
byte_s = (['7','8'])
parity_s = (['n','e','o'])
stopb_s =(['1','2'])
flwctr_s =(['off','rtscts'])
port =MainWindow.serial_port[MainWindow.output2_iport]
bitrate =MainWindow.serial_bitrate[MainWindow.output2_ibitrate]
byte = byte_s[MainWindow.output2_ibytesize]
parity = parity_s[MainWindow.output2_iparity]
stopb = stopb_s[MainWindow.output2_istopbits]
flwctr = flwctr_s[MainWindow.output2_iflowcontrol]
return ' -out serial://'+port+':'+bitrate+':'+byte+':'+parity+':'+stopb+':'+flwctr
# Sub window (Rover Config)
class RoverConfigWindow:
def __init__(self, parent=None):
self.w = QDialog(parent)
self.w.setFont(QFont('Helvetica',11))
self.w.setWindowFlags(QtCore.Qt.FramelessWindowHint)
self.w.setGeometry(0, 0, 480, 320)
self.parent = parent
tabs = QTabWidget()
self.tab_input=InputConfig()
self.tab_corr1=CorrectionConfig()
self.tab_corr2=CorrectionSerialConfig()
self.tab_sol=SolConfig()
self.tab_log=LogConfig()
self.tab_basepos=BasePosConfig_Rover()
tabs.addTab(self.tab_input,"Input")
tabs.addTab(self.tab_corr1,"Correction1")
tabs.addTab(self.tab_corr2,"Correction2")
tabs.addTab(self.tab_sol,"Solution")
tabs.addTab(self.tab_log,"Log")
tabs.addTab(self.tab_basepos,"BasePos")
apply_button= QPushButton('Apply')
apply_button.clicked.connect(self.applyParam)
close_button= QPushButton('Close')
close_button.clicked.connect(self.w.close)
layout = QVBoxLayout()
layout.addWidget(tabs)
hbox = QHBoxLayout()
hbox.addWidget(apply_button,1)
hbox.addWidget(close_button,1)
layout.addLayout(hbox)
self.w.setLayout(layout)
# Apply button
def applyParam(self):
MainWindow.input_iport=self.tab_input.port_list.currentIndex()
MainWindow.input_ibitrate=self.tab_input.bitrate_list.currentIndex()
MainWindow.input_ibytesize=self.tab_input.bytesize_list.currentIndex()
MainWindow.input_iparity=self.tab_input.parity_list.currentIndex()
MainWindow.input_istopbits=self.tab_input.stopbits_list.currentIndex()
MainWindow.input_iflowcontrol=self.tab_input.flowcontrol_list.currentIndex()
MainWindow.corr_flag=self.tab_corr1.corr_b.isChecked()
MainWindow.corr_itype=self.tab_corr1.type_list.currentIndex()
MainWindow.corr_iformat=self.tab_corr1.format_list.currentIndex()
MainWindow.corr_addr=self.tab_corr1.addr_edit.text()
MainWindow.corr_port=self.tab_corr1.port_edit.text()
MainWindow.corr_mp=self.tab_corr1.mp_edit.text()
MainWindow.corr_user=self.tab_corr1.user_edit.text()
MainWindow.corr_pw=self.tab_corr1.pw_edit.text()
MainWindow.corr2_flag=self.tab_corr2.corr2_b.isChecked()
MainWindow.corr2_iport=self.tab_corr2.port_list.currentIndex()
MainWindow.corr2_ibitrate=self.tab_corr2.bitrate_list.currentIndex()
MainWindow.corr2_ibytesize=self.tab_corr2.bytesize_list.currentIndex()
MainWindow.corr2_iparity=self.tab_corr2.parity_list.currentIndex()
MainWindow.corr2_istopbits=self.tab_corr2.stopbits_list.currentIndex()
MainWindow.corr2_iflowcontrol=self.tab_corr2.flowcontrol_list.currentIndex()
MainWindow.sol_flag=self.tab_sol.sol_b.isChecked()
MainWindow.sol_filename=self.tab_sol.output_edit.text()
MainWindow.log_flag=self.tab_log.log_b.isChecked()
MainWindow.log_filename=self.tab_log.output_edit.text()
MainWindow.basepos_itype=self.tab_basepos.type_list.currentIndex()
MainWindow.basepos_lat=self.tab_basepos.lat_edit.text()
MainWindow.basepos_lon=self.tab_basepos.lon_edit.text()
MainWindow.basepos_hgt=self.tab_basepos.hgt_edit.text()
def show(self):
self.w.exec_()
# Sub window (Base config)
class BaseConfigWindow:
def __init__(self, parent=None):
self.w = QDialog(parent)
self.w.setFont(QFont('Helvetica',11))
self.w.setWindowFlags(QtCore.Qt.FramelessWindowHint)
self.w.setGeometry(0, 0, 480, 320)
self.parent = parent
tabs = QTabWidget()
self.tab_input=InputConfig()
self.tab_output1=OutputConfig()
self.tab_output2=OutputSerialConfig()
self.tab_log=LogConfig()
self.tab_basepos=BasePosConfig_Base()
tabs.addTab(self.tab_input,"Input")
tabs.addTab(self.tab_output1,"Output1")
tabs.addTab(self.tab_output2,"Output2")
tabs.addTab(self.tab_log,"Log")
tabs.addTab(self.tab_basepos,"BasePos")
apply_button= QPushButton('Apply')
apply_button.clicked.connect(self.applyParam)
close_button= QPushButton('Close')
close_button.clicked.connect(self.w.close)
layout = QVBoxLayout()
layout.addWidget(tabs)
hbox = QHBoxLayout()
hbox.addWidget(apply_button,1)
hbox.addWidget(close_button,1)
layout.addLayout(hbox)
self.w.setLayout(layout)
# Apply button
def applyParam(self):
MainWindow.input_iport=self.tab_input.port_list.currentIndex()
MainWindow.input_ibitrate=self.tab_input.bitrate_list.currentIndex()
MainWindow.input_ibytesize=self.tab_input.bytesize_list.currentIndex()
MainWindow.input_iparity=self.tab_input.parity_list.currentIndex()
MainWindow.input_istopbits=self.tab_input.stopbits_list.currentIndex()
MainWindow.input_iflowcontrol=self.tab_input.flowcontrol_list.currentIndex()
MainWindow.output_flag=self.tab_output1.output_b.isChecked()
MainWindow.output_itype=self.tab_output1.type_list.currentIndex()
MainWindow.output_iformat=self.tab_output1.format_list.currentIndex()
if self.tab_output1.addr_edit.isEnabled():
MainWindow.output_addr=self.tab_output1.addr_edit.text()
MainWindow.output_port=self.tab_output1.port_edit.text()
MainWindow.output_mp=self.tab_output1.mp_edit.text()
MainWindow.output_user=self.tab_output1.user_edit.text()
MainWindow.output_pw=self.tab_output1.pw_edit.text()
MainWindow.output2_flag=self.tab_output2.output2_b.isChecked()
MainWindow.output2_iport=self.tab_output2.port_list.currentIndex()
MainWindow.output2_ibitrate=self.tab_output2.bitrate_list.currentIndex()
MainWindow.output2_ibytesize=self.tab_output2.bytesize_list.currentIndex()
MainWindow.output2_iparity=self.tab_output2.parity_list.currentIndex()
MainWindow.output2_istopbits=self.tab_output2.stopbits_list.currentIndex()
MainWindow.output2_iflowcontrol=self.tab_output2.flowcontrol_list.currentIndex()
MainWindow.log_flag=self.tab_log.log_b.isChecked()
MainWindow.log_filename=self.tab_log.output_edit.text()
MainWindow.basepos_lat=self.tab_basepos.lat_edit.text()
MainWindow.basepos_lon=self.tab_basepos.lon_edit.text()
MainWindow.basepos_hgt=self.tab_basepos.hgt_edit.text()
def show(self):
self.w.exec_()
# Input tab (Rover/Base)
class InputConfig(QWidget):
def __init__(self,parent=None):
super().__init__()
self.initInputUI()
def initInputUI(self):
self.port_list=QComboBox(self)
self.port_list.addItems(MainWindow.serial_port)
self.port_list.setCurrentIndex(MainWindow.input_iport)
self.bitrate_list=QComboBox(self)
self.bitrate_list.addItems(MainWindow.serial_bitrate)
self.bitrate_list.setCurrentIndex(MainWindow.input_ibitrate)
self.bytesize_list=QComboBox(self)
self.bytesize_list.addItems(MainWindow.serial_bytesize)
self.bytesize_list.setCurrentIndex(MainWindow.input_ibytesize)
self.parity_list=QComboBox(self)
self.parity_list.addItems(MainWindow.serial_parity)
self.parity_list.setCurrentIndex(MainWindow.input_iparity)
self.stopbits_list=QComboBox(self)
self.stopbits_list.addItems(MainWindow.serial_stopbits)
self.stopbits_list.setCurrentIndex(MainWindow.input_istopbits)
self.flowcontrol_list=QComboBox(self)
self.flowcontrol_list.addItems(MainWindow.serial_flowcontrol)
self.flowcontrol_list.setCurrentIndex(MainWindow.input_iflowcontrol)
#add
grid=QGridLayout()
grid.addWidget(QLabel('Port'),0,0)
grid.addWidget(self.port_list,0,1)
grid.addWidget(QLabel('Bit Rate'),0,2)
grid.addWidget(self.bitrate_list,0,3)
grid.addWidget(QLabel('Byte Size'),1,0)
grid.addWidget(self.bytesize_list,1,1)
grid.addWidget(QLabel('Parity'),1,2)
grid.addWidget(self.parity_list,1,3)
grid.addWidget(QLabel('Stop Bits'),2,0)
grid.addWidget(self.stopbits_list,2,1)
grid.addWidget(QLabel('Flow Control'),2,2)
grid.addWidget(self.flowcontrol_list,2,3)
self.setLayout(grid)
# Correction tab (Rover)
class CorrectionConfig(QWidget):
def __init__(self,parent=None):
super().__init__()
self.initCorrectionUI()
def initCorrectionUI(self):
self.corr_b = QCheckBox("Enable",self)
self.type_list=QComboBox(self)
self.type_list.addItems(MainWindow.corr_type)
self.type_list.setCurrentIndex(MainWindow.corr_itype)
self.type_list.currentIndexChanged.connect(self.typeChanged)
self.format_list=QComboBox(self)
self.format_list.addItems(MainWindow.corr_format)
self.format_list.setCurrentIndex(MainWindow.corr_iformat)
self.corr_b.setChecked(MainWindow.corr_flag)
self.addr_edit=QLineEdit(MainWindow.corr_addr,self)
self.port_edit=QLineEdit(MainWindow.corr_port,self)
self.mp_edit=QLineEdit(MainWindow.corr_mp,self)
self.user_edit=QLineEdit(MainWindow.corr_user,self)
self.pw_edit=QLineEdit(MainWindow.corr_pw,self)
grid=QGridLayout()
grid.addWidget(self.corr_b,0,0)
grid.addWidget(QLabel('Type/Format'),0,1)
grid.addWidget(self.type_list,0,2)
grid.addWidget(self.format_list,0,3)
grid.addWidget(QLabel('Address'),1,0)
grid.addWidget(self.addr_edit,1,1,1,4)
grid.addWidget(QLabel('Port'),2,0)
grid.addWidget(self.port_edit,2,1)
grid.addWidget(QLabel('Mountpoint'),2,2)
grid.addWidget(self.mp_edit,2,3)
grid.addWidget(QLabel('User-ID'),3,0)
grid.addWidget(self.user_edit,3,1)
grid.addWidget(QLabel('Password'),3,2)
grid.addWidget(self.pw_edit,3,3)
self.setLayout(grid)
self.typeChanged(MainWindow.corr_itype)
def typeChanged(self,ind):
if ind==0: # TCP Client
self.mp_edit.setDisabled(False)
self.user_edit.setDisabled(False)
self.pw_edit.setDisabled(False)
elif ind==1: # NTRIP Client
self.mp_edit.setDisabled(True)
self.user_edit.setDisabled(True)
self.pw_edit.setDisabled(True)
# Correction(Serial) tab (Rover)
class CorrectionSerialConfig(QWidget):
def __init__(self,parent=None):
super().__init__()
self.initCorrectionSerialUI()
def initCorrectionSerialUI(self):
self.corr2_b = QCheckBox("Enable",self)
self.corr2_b.setChecked(MainWindow.corr2_flag)
self.format_list=QComboBox(self)
self.format_list.addItems(MainWindow.corr2_format)
self.format_list.setCurrentIndex(MainWindow.corr2_iformat)
self.port_list=QComboBox(self)
self.port_list.addItems(MainWindow.serial_port)
self.port_list.setCurrentIndex(MainWindow.corr2_iport)
self.bitrate_list=QComboBox(self)
self.bitrate_list.addItems(MainWindow.serial_bitrate)
self.bitrate_list.setCurrentIndex(MainWindow.corr2_ibitrate)
self.bytesize_list=QComboBox(self)
self.bytesize_list.addItems(MainWindow.serial_bytesize)
self.bytesize_list.setCurrentIndex(MainWindow.corr2_ibytesize)
self.parity_list=QComboBox(self)
self.parity_list.addItems(MainWindow.serial_parity)
self.parity_list.setCurrentIndex(MainWindow.corr2_iparity)
self.stopbits_list=QComboBox(self)
self.stopbits_list.addItems(MainWindow.serial_stopbits)
self.stopbits_list.setCurrentIndex(MainWindow.corr2_istopbits)
self.flowcontrol_list=QComboBox(self)
self.flowcontrol_list.addItems(MainWindow.serial_flowcontrol)
self.flowcontrol_list.setCurrentIndex(MainWindow.corr2_iflowcontrol)
#add
grid=QGridLayout()
grid.addWidget(self.corr2_b,0,0)
grid.addWidget(QLabel('Format'),0,2)
grid.addWidget(self.format_list,0,3)
grid.addWidget(QLabel('Port'),1,0)
grid.addWidget(self.port_list,1,1)
grid.addWidget(QLabel('Bit Rate'),1,2)
grid.addWidget(self.bitrate_list,1,3)
grid.addWidget(QLabel('Byte Size'),2,0)
grid.addWidget(self.bytesize_list,2,1)
grid.addWidget(QLabel('Parity'),2,2)
grid.addWidget(self.parity_list,2,3)
grid.addWidget(QLabel('Stop Bits'),3,0)
grid.addWidget(self.stopbits_list,3,1)
grid.addWidget(QLabel('Flow Control'),3,2)
grid.addWidget(self.flowcontrol_list,3,3)
self.setLayout(grid)
# Output tab (Rover/Base)
class OutputConfig(QWidget):
def __init__(self,parent=None):
super().__init__()
self.initOutputUI()
def initOutputUI(self):
self.output_b = QCheckBox("Enable",self)
self.type_list=QComboBox(self)
self.type_list.addItems(MainWindow.output_type)
self.type_list.setCurrentIndex(MainWindow.output_itype)
self.type_list.currentIndexChanged.connect(self.typeChanged)
self.format_list=QComboBox(self)
self.format_list.addItems(MainWindow.output_format)
self.format_list.setCurrentIndex(MainWindow.output_iformat)
self.output_b.setChecked(MainWindow.output_flag)
self.addr_edit=QLineEdit(MainWindow.output_addr,self)
self.port_edit=QLineEdit(MainWindow.output_port,self)
self.mp_edit=QLineEdit(MainWindow.output_mp,self)
self.user_edit=QLineEdit(MainWindow.output_user,self)
self.pw_edit=QLineEdit(MainWindow.output_pw,self)
grid=QGridLayout()
grid.addWidget(self.output_b,0,0)
grid.addWidget(QLabel('Type/Format'),0,1)
grid.addWidget(self.type_list,0,2)
grid.addWidget(self.format_list,0,3)
grid.addWidget(QLabel('Address'),1,0)
grid.addWidget(self.addr_edit,1,1,1,4)
grid.addWidget(QLabel('Port'),2,0)
grid.addWidget(self.port_edit,2,1)
grid.addWidget(QLabel('Mountpoint'),2,2)
grid.addWidget(self.mp_edit,2,3)
grid.addWidget(QLabel('User-ID'),3,0)
grid.addWidget(self.user_edit,3,1)
grid.addWidget(QLabel('Password'),3,2)
grid.addWidget(self.pw_edit,3,3)
self.setLayout(grid)
self.typeChanged(MainWindow.output_itype)
def typeChanged(self,ind):
if ind==0: # TCP Server
self.addr_edit.setText(self.getipadress())