-
Notifications
You must be signed in to change notification settings - Fork 1
/
ReceiverPlat.py
319 lines (298 loc) · 18.7 KB
/
ReceiverPlat.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
# -- ReceiverPlat.py as part of FERS XML File I/O as part of FERS Plugin
# -- Created by James Gripper
# -- November 2016
# -*- coding: utf-8 -*-#
from PyQt4 import QtCore, QtGui
from addNodes import *
from lxml import etree
import FERS_Input
import sys
import os
## reads in filename string
placeholder = open("filename.txt", "r")
filename = placeholder.read()
placeholder.close()
## creates parser object
parser = etree.XMLParser(remove_blank_text=True,ns_clean=True)
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_Receiver(QtGui.QMainWindow):
def __init__(self):
QtGui.QWidget.__init__(self)
self.setupUi(self)
def setupUi(self, Receiver):
Receiver.setObjectName(_fromUtf8("Receiver"))
Receiver.resize(541, 402)
self.centralwidget = QtGui.QWidget(Receiver)
self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
self.verticalLayout = QtGui.QVBoxLayout(self.centralwidget)
self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
self.horizontalLayout3 = QtGui.QHBoxLayout()
self.horizontalLayout3.setObjectName(_fromUtf8("horizontalLayout3"))
self.T_Pulse_label = QtGui.QLabel(self.centralwidget)
self.T_Pulse_label.setBaseSize(QtCore.QSize(7, 0))
self.T_Pulse_label.setObjectName(_fromUtf8("T_Pulse_label"))
self.horizontalLayout3.addWidget(self.T_Pulse_label)
self._2 = QtGui.QGridLayout()
self._2.setObjectName(_fromUtf8("_2"))
self.propcheck = QtGui.QCheckBox(self.centralwidget)
self.propcheck.setText(_fromUtf8(""))
self.propcheck.setObjectName(_fromUtf8("propcheck"))
self._2.addWidget(self.propcheck, 8, 1, 1, 1)
self.T_Pulse_Carrier_label_5 = QtGui.QLabel(self.centralwidget)
self.T_Pulse_Carrier_label_5.setObjectName(_fromUtf8("T_Pulse_Carrier_label_5"))
self._2.addWidget(self.T_Pulse_Carrier_label_5, 9, 0, 1, 1)
self.T_Pulse_power_label = QtGui.QLabel(self.centralwidget)
self.T_Pulse_power_label.setObjectName(_fromUtf8("T_Pulse_power_label"))
self._2.addWidget(self.T_Pulse_power_label, 5, 0, 1, 1)
self.T_Pulse_Carrier_label_4 = QtGui.QLabel(self.centralwidget)
self.T_Pulse_Carrier_label_4.setObjectName(_fromUtf8("T_Pulse_Carrier_label_4"))
self._2.addWidget(self.T_Pulse_Carrier_label_4, 11, 0, 1, 1)
self.T_Pulse_name_label = QtGui.QLabel(self.centralwidget)
self.T_Pulse_name_label.setObjectName(_fromUtf8("T_Pulse_name_label"))
self._2.addWidget(self.T_Pulse_name_label, 1, 0, 1, 1)
self.T_Pulse_file_label = QtGui.QLabel(self.centralwidget)
self.T_Pulse_file_label.setObjectName(_fromUtf8("T_Pulse_file_label"))
self._2.addWidget(self.T_Pulse_file_label, 4, 0, 1, 1)
self.Rx_name_input = QtGui.QLineEdit(self.centralwidget)
self.Rx_name_input.setObjectName(_fromUtf8("Rx_name_input"))
self._2.addWidget(self.Rx_name_input, 1, 1, 1, 1)
self.Rx_ad_btn = QtGui.QPushButton(self.centralwidget)
self.Rx_ad_btn.setObjectName(_fromUtf8("Rx_ad_btn"))
self._2.addWidget(self.Rx_ad_btn, 10, 1, 1, 1)
self.Rx_Antenna_name_input = QtGui.QLineEdit(self.centralwidget)
self.Rx_Antenna_name_input.setObjectName(_fromUtf8("Rx_Antenna_name_input"))
self._2.addWidget(self.Rx_Antenna_name_input, 2, 1, 1, 1)
self.T_Pulse_carrier_clear = QtGui.QPushButton(self.centralwidget)
self.T_Pulse_carrier_clear.setObjectName(_fromUtf8("T_Pulse_carrier_clear"))
self._2.addWidget(self.T_Pulse_carrier_clear, 6, 3, 1, 1)
self.T_Pulse_power_clear = QtGui.QPushButton(self.centralwidget)
self.T_Pulse_power_clear.setObjectName(_fromUtf8("T_Pulse_power_clear"))
self._2.addWidget(self.T_Pulse_power_clear, 5, 3, 1, 1)
self.T_Pulse_Carrier_label_2 = QtGui.QLabel(self.centralwidget)
self.T_Pulse_Carrier_label_2.setObjectName(_fromUtf8("T_Pulse_Carrier_label_2"))
self._2.addWidget(self.T_Pulse_Carrier_label_2, 7, 0, 1, 1)
self.Rx_PRF_input = QtGui.QLineEdit(self.centralwidget)
self.Rx_PRF_input.setObjectName(_fromUtf8("Rx_PRF_input"))
self._2.addWidget(self.Rx_PRF_input, 6, 1, 1, 1)
self.label_3 = QtGui.QLabel(self.centralwidget)
self.label_3.setObjectName(_fromUtf8("label_3"))
self._2.addWidget(self.label_3, 5, 2, 1, 1)
self.T_Pulse_filename_clear_4 = QtGui.QPushButton(self.centralwidget)
self.T_Pulse_filename_clear_4.setObjectName(_fromUtf8("T_Pulse_filename_clear_4"))
self._2.addWidget(self.T_Pulse_filename_clear_4, 3, 3, 1, 1)
self.T_Pulse_name_label_3 = QtGui.QLabel(self.centralwidget)
self.T_Pulse_name_label_3.setObjectName(_fromUtf8("T_Pulse_name_label_3"))
self._2.addWidget(self.T_Pulse_name_label_3, 2, 0, 1, 1)
self.ignorecheck = QtGui.QCheckBox(self.centralwidget)
self.ignorecheck.setText(_fromUtf8(""))
self.ignorecheck.setObjectName(_fromUtf8("ignorecheck"))
self._2.addWidget(self.ignorecheck, 9, 1, 1, 1)
self.T_Pulse_carrier_clear_2 = QtGui.QPushButton(self.centralwidget)
self.T_Pulse_carrier_clear_2.setObjectName(_fromUtf8("T_Pulse_carrier_clear_2"))
self._2.addWidget(self.T_Pulse_carrier_clear_2, 7, 3, 1, 1)
self.T_Pulse_name_clear = QtGui.QPushButton(self.centralwidget)
self.T_Pulse_name_clear.setObjectName(_fromUtf8("T_Pulse_name_clear"))
self._2.addWidget(self.T_Pulse_name_clear, 4, 3, 1, 1)
self.T_Pulse_Carrier_label_3 = QtGui.QLabel(self.centralwidget)
self.T_Pulse_Carrier_label_3.setInputMethodHints(QtCore.Qt.ImhHiddenText)
self.T_Pulse_Carrier_label_3.setObjectName(_fromUtf8("T_Pulse_Carrier_label_3"))
self._2.addWidget(self.T_Pulse_Carrier_label_3, 8, 0, 1, 1)
self.label_2 = QtGui.QLabel(self.centralwidget)
self.label_2.setObjectName(_fromUtf8("label_2"))
self._2.addWidget(self.label_2, 4, 2, 1, 1)
self.T_Pulse_filename_clear = QtGui.QPushButton(self.centralwidget)
self.T_Pulse_filename_clear.setObjectName(_fromUtf8("T_Pulse_filename_clear"))
self._2.addWidget(self.T_Pulse_filename_clear, 1, 3, 1, 1)
self.T_Pulse_Carrier_label = QtGui.QLabel(self.centralwidget)
self.T_Pulse_Carrier_label.setInputMethodHints(QtCore.Qt.ImhHiddenText)
self.T_Pulse_Carrier_label.setObjectName(_fromUtf8("T_Pulse_Carrier_label"))
self._2.addWidget(self.T_Pulse_Carrier_label, 6, 0, 1, 1)
self.Rx_Noise_temp_input = QtGui.QLineEdit(self.centralwidget)
self.Rx_Noise_temp_input.setObjectName(_fromUtf8("Rx_Noise_temp_input"))
self._2.addWidget(self.Rx_Noise_temp_input, 7, 1, 1, 1)
self.Rx_remove_btn = QtGui.QPushButton(self.centralwidget)
self.Rx_remove_btn.setObjectName(_fromUtf8("Rx_remove_btn"))
self._2.addWidget(self.Rx_remove_btn, 12, 1, 1, 1)
self.T_Pulse_carrier_clear_3 = QtGui.QPushButton(self.centralwidget)
self.T_Pulse_carrier_clear_3.setObjectName(_fromUtf8("T_Pulse_carrier_clear_3"))
self._2.addWidget(self.T_Pulse_carrier_clear_3, 11, 3, 1, 1)
self.T_Pulse_filename_clear_3 = QtGui.QPushButton(self.centralwidget)
self.T_Pulse_filename_clear_3.setObjectName(_fromUtf8("T_Pulse_filename_clear_3"))
self._2.addWidget(self.T_Pulse_filename_clear_3, 2, 3, 1, 1)
self.Rx_Timing_name_input = QtGui.QLineEdit(self.centralwidget)
self.Rx_Timing_name_input.setObjectName(_fromUtf8("Rx_Timing_name_input"))
self._2.addWidget(self.Rx_Timing_name_input, 3, 1, 1, 1)
self.T_Pulse_name_label_4 = QtGui.QLabel(self.centralwidget)
self.T_Pulse_name_label_4.setObjectName(_fromUtf8("T_Pulse_name_label_4"))
self._2.addWidget(self.T_Pulse_name_label_4, 3, 0, 1, 1)
self.Rx_remove_input = QtGui.QLineEdit(self.centralwidget)
self.Rx_remove_input.setObjectName(_fromUtf8("Rx_remove_input"))
self._2.addWidget(self.Rx_remove_input, 11, 1, 1, 1)
self.label_4 = QtGui.QLabel(self.centralwidget)
self.label_4.setObjectName(_fromUtf8("label_4"))
self._2.addWidget(self.label_4, 6, 2, 1, 1)
self.Rx_Window_skip_input = QtGui.QLineEdit(self.centralwidget)
self.Rx_Window_skip_input.setEnabled(True)
self.Rx_Window_skip_input.setInputMethodHints(QtCore.Qt.ImhHiddenText)
self.Rx_Window_skip_input.setObjectName(_fromUtf8("Rx_Window_skip_input"))
self._2.addWidget(self.Rx_Window_skip_input, 4, 1, 1, 1)
self.label = QtGui.QLabel(self.centralwidget)
self.label.setObjectName(_fromUtf8("label"))
self._2.addWidget(self.label, 7, 2, 1, 1)
self.Rx_window_leng_input = QtGui.QLineEdit(self.centralwidget)
self.Rx_window_leng_input.setObjectName(_fromUtf8("Rx_window_leng_input"))
self._2.addWidget(self.Rx_window_leng_input, 5, 1, 1, 1)
self.T_Pulse_name_label_2 = QtGui.QLabel(self.centralwidget)
self.T_Pulse_name_label_2.setObjectName(_fromUtf8("T_Pulse_name_label_2"))
self._2.addWidget(self.T_Pulse_name_label_2, 0, 0, 1, 1)
self.platform_sel = QtGui.QComboBox(self.centralwidget)
self.platform_sel.setObjectName(_fromUtf8("platform_sel"))
self._2.addWidget(self.platform_sel, 0, 1, 1, 3)
self._2.setColumnStretch(0, 8)
self.horizontalLayout3.addLayout(self._2)
self.verticalLayout.addLayout(self.horizontalLayout3)
self.Rx_view_btn = QtGui.QPushButton(self.centralwidget)
self.Rx_view_btn.setObjectName(_fromUtf8("Rx_view_btn"))
self.verticalLayout.addWidget(self.Rx_view_btn)
Receiver.setCentralWidget(self.centralwidget)
self.retranslateUi(Receiver)
QtCore.QObject.connect(self.T_Pulse_filename_clear, QtCore.SIGNAL(_fromUtf8("clicked()")), self.Rx_name_input.clear)
QtCore.QObject.connect(self.T_Pulse_name_clear, QtCore.SIGNAL(_fromUtf8("clicked()")), self.Rx_Window_skip_input.clear)
QtCore.QObject.connect(self.T_Pulse_power_clear, QtCore.SIGNAL(_fromUtf8("clicked()")), self.Rx_window_leng_input.clear)
QtCore.QObject.connect(self.T_Pulse_carrier_clear, QtCore.SIGNAL(_fromUtf8("clicked()")), self.Rx_PRF_input.clear)
QtCore.QObject.connect(self.T_Pulse_carrier_clear_2, QtCore.SIGNAL(_fromUtf8("clicked()")), self.Rx_Noise_temp_input.clear)
QtCore.QObject.connect(self.T_Pulse_filename_clear_3, QtCore.SIGNAL(_fromUtf8("clicked()")), self.Rx_Antenna_name_input.clear)
QtCore.QObject.connect(self.T_Pulse_filename_clear_4, QtCore.SIGNAL(_fromUtf8("clicked()")), self.Rx_Timing_name_input.clear)
QtCore.QObject.connect(self.T_Pulse_carrier_clear_3, QtCore.SIGNAL(_fromUtf8("clicked()")), self.Rx_remove_input.clear)
QtCore.QMetaObject.connectSlotsByName(Receiver)
Receiver.setTabOrder(self.Rx_name_input, self.Rx_Antenna_name_input)
Receiver.setTabOrder(self.Rx_Antenna_name_input, self.Rx_Timing_name_input)
Receiver.setTabOrder(self.Rx_Timing_name_input, self.Rx_Window_skip_input)
Receiver.setTabOrder(self.Rx_Window_skip_input, self.Rx_window_leng_input)
Receiver.setTabOrder(self.Rx_window_leng_input, self.Rx_PRF_input)
Receiver.setTabOrder(self.Rx_PRF_input, self.Rx_Noise_temp_input)
Receiver.setTabOrder(self.Rx_Noise_temp_input, self.propcheck)
Receiver.setTabOrder(self.propcheck, self.ignorecheck)
Receiver.setTabOrder(self.ignorecheck, self.Rx_ad_btn)
Receiver.setTabOrder(self.Rx_ad_btn, self.Rx_remove_input)
Receiver.setTabOrder(self.Rx_remove_input, self.Rx_remove_btn)
Receiver.setTabOrder(self.Rx_remove_btn, self.Rx_view_btn)
Receiver.setTabOrder(self.Rx_view_btn, self.T_Pulse_filename_clear)
Receiver.setTabOrder(self.T_Pulse_filename_clear, self.T_Pulse_filename_clear_3)
Receiver.setTabOrder(self.T_Pulse_filename_clear_3, self.T_Pulse_filename_clear_4)
Receiver.setTabOrder(self.T_Pulse_filename_clear_4, self.T_Pulse_name_clear)
Receiver.setTabOrder(self.T_Pulse_name_clear, self.T_Pulse_power_clear)
Receiver.setTabOrder(self.T_Pulse_power_clear, self.T_Pulse_carrier_clear)
Receiver.setTabOrder(self.T_Pulse_carrier_clear, self.T_Pulse_carrier_clear_2)
Receiver.setTabOrder(self.T_Pulse_carrier_clear_2, self.T_Pulse_carrier_clear_3)
def retranslateUi(self, Receiver):
Receiver.setWindowTitle(_translate("Receiver", "Receiver", None))
self.T_Pulse_label.setText(_translate("Receiver", "Receiver", None))
self.T_Pulse_Carrier_label_5.setText(_translate("Receiver", "Ignore Direct Signals", None))
self.T_Pulse_power_label.setText(_translate("Receiver", "Window Length", None))
self.T_Pulse_Carrier_label_4.setText(_translate("Receiver", "Remove existing receiver", None))
self.T_Pulse_name_label.setText(_translate("Receiver", "Receiver Name", None))
self.T_Pulse_file_label.setText(_translate("Receiver", "Window Skip", None))
self.Rx_name_input.setPlaceholderText(_translate("Receiver", "<Sample Name>", None))
self.Rx_ad_btn.setText(_translate("Receiver", "Add to XML", None))
self.Rx_Antenna_name_input.setPlaceholderText(_translate("Receiver", "<Sample Name>", None))
self.T_Pulse_carrier_clear.setText(_translate("Receiver", "Clear", None))
self.T_Pulse_power_clear.setText(_translate("Receiver", "Clear", None))
self.T_Pulse_Carrier_label_2.setText(_translate("Receiver", "Noise Temperature", None))
self.Rx_PRF_input.setPlaceholderText(_translate("Receiver", "<Sample Value>", None))
self.label_3.setText(_translate("Receiver", "seconds", None))
self.T_Pulse_filename_clear_4.setText(_translate("Receiver", "Clear", None))
self.T_Pulse_name_label_3.setText(_translate("Receiver", "Antenna", None))
self.T_Pulse_carrier_clear_2.setText(_translate("Receiver", "Clear", None))
self.T_Pulse_name_clear.setText(_translate("Receiver", "Clear", None))
self.T_Pulse_Carrier_label_3.setToolTip(_translate("Receiver", "<html><head/><body><p>true: propagation losses of received signal(s) will notbe taken into account</p></body></html>", None))
self.T_Pulse_Carrier_label_3.setText(_translate("Receiver", "Ignore Propagation Loss", None))
self.label_2.setText(_translate("Receiver", "seconds", None))
self.T_Pulse_filename_clear.setText(_translate("Receiver", "Clear", None))
self.T_Pulse_Carrier_label.setToolTip(_translate("Receiver", "<html><head/><body><p>Values will be rounded down to the closest even number.</p></body></html>", None))
self.T_Pulse_Carrier_label.setText(_translate("Receiver", "PRF", None))
self.Rx_Noise_temp_input.setPlaceholderText(_translate("Receiver", "<Sample Temp>", None))
self.Rx_remove_btn.setText(_translate("Receiver", "Remove from XML", None))
self.T_Pulse_carrier_clear_3.setText(_translate("Receiver", "Clear", None))
self.T_Pulse_filename_clear_3.setText(_translate("Receiver", "Clear", None))
self.Rx_Timing_name_input.setPlaceholderText(_translate("Receiver", "<Sample Name>", None))
self.T_Pulse_name_label_4.setText(_translate("Receiver", "Clock Name", None))
self.Rx_remove_input.setPlaceholderText(_translate("Receiver", "<Sample Name>", None))
self.label_4.setText(_translate("Receiver", "Hz", None))
self.Rx_Window_skip_input.setPlaceholderText(_translate("Receiver", "<Sample Value>", None))
self.label.setText(_translate("Receiver", "Kelvin", None))
self.Rx_window_leng_input.setPlaceholderText(_translate("Receiver", "<Sample Value>", None))
self.T_Pulse_name_label_2.setText(_translate("Receiver", "Platform Name", None))
self.Rx_view_btn.setText(_translate("Receiver", "view XML", None))
## connects functions to buttons
self.Rx_ad_btn.clicked.connect(self.callAppend)
self.Rx_view_btn.clicked.connect(self.showEntry)
self.Rx_remove_btn.clicked.connect(self.removeNode)
## adds platform names to selection boxs
self.platform_sel.clear()
names = []
doc = etree.parse(filename, parser)
sim = doc.getroot()
for plat in sim.findall('platform'):
name = plat.get('name')
names.append(name)
for name in names:
self.platform_sel.addItem(name)
## removes receiver from platform
def removeNode(self):
doc = etree.parse(filename, parser)
sim = doc.getroot()
for plat in sim.findall('platform'):
name = plat.get('name')
if name == str(self.platform_sel.currentText()):
for rec in plat.findall('receiver'):
name = rec.get('name')
if name == str(self.Rx_remove_input.text()):
plat.remove(rec)
doc.write(filename,pretty_print=True)
print '--Receiver removed from Platform--'
else:
print "--Receiver not found. Please Try Again--"
else:
print '--Invalid Platform. Please Try Again--'
## prints formatted xml to console
def showEntry(self):
doc = etree.parse(filename, parser)
print(etree.tostring(doc, pretty_print=True))
## adds receiver to platform
def callAppend(self):
name = str(self.Rx_name_input.text())
antenna_name = str(self.Rx_Antenna_name_input.text())
clock_name = str(self.Rx_Timing_name_input.text())
skip_time = str(self.Rx_Window_skip_input.text())
receiver_window_length = str(self.Rx_window_leng_input.text())
pulse_rf = str(self.Rx_PRF_input.text())
receiver_temp = str(self.Rx_Noise_temp_input.text())
plat_name = str(self.platform_sel.currentText())
nd_bool = 'false'
noploss_bool = 'false'
if (self.propcheck.isChecked()):
noploss_bool = 'true'
if (self.ignorecheck.isChecked()):
nd_bool = 'true'
appendRxToPlatform(filename, plat_name, name, antenna_name, clock_name, nd_bool, noploss_bool, skip_time, receiver_window_length, pulse_rf, receiver_temp)
print'--Receiver added to platorm--'
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
Receiver = QtGui.QMainWindow()
ui = Ui_Receiver()
ui.setupUi(Receiver)
Receiver.show()
sys.exit(app.exec_())