Skip to content

Commit adf31d8

Browse files
committed
Squashed commit of the following:
commit 2a8911f Author: Leor Bleier <Leor.Z.Bleier@nasa.gov> Date: Fri Jun 26 17:34:54 2020 -0400 Enhancement nasa#103 - updates to allow user to select header version Updates GUI and backend to allow user to select header version offsets, or custom byte offsets commit 9d233eb Author: Leor Bleier <Leor.Z.Bleier@nasa.gov> Date: Thu Jun 25 17:12:31 2020 -0400 WIP: Enhancement nasa#103 - updates to miniCmdUtil and other files commit 6d3f7ed Author: Leor Bleier <Leor.Z.Bleier@nasa.gov> Date: Wed Jun 24 13:53:51 2020 -0400 WIP: Enhancement nasa#103 - updates to miniCmdUtil commit 8ad565c Author: Leor Bleier <Leor.Z.Bleier@nasa.gov> Date: Wed Jun 24 10:56:45 2020 -0400 WIP: Enhancement nasa#103 - updates to miniCmdUtil commit a0d1872 Author: Leor Bleier <Leor.Z.Bleier@nasa.gov> Date: Tue Jun 23 15:39:25 2020 -0400 WIP: Enhancement nasa#103 - Implemented native cmdUtil Native cmdUtil has only subset of full cmdUtil functionality Also implemented updates to GUI and backend to support custom byte offsets in tlm and cmd commit 09261e5 Author: Leor Bleier <Leor.Z.Bleier@nasa.gov> Date: Tue Jun 16 13:27:26 2020 -0400 Enhancement nasa#103 - custom header mechanism Fix for rebase merge error commit 7754c9f Author: Leor Bleier <Leor.Z.Bleier@nasa.gov> Date: Tue Jun 16 12:38:33 2020 -0400 Enhancement nasa#103 - custom header mechanism Updated UI and backend to support custom header sizes. Change only impacts tlm currently commit 821f06c Author: Leor Bleier <Leor.Z.Bleier@nasa.gov> Date: Mon Jun 1 09:57:02 2020 -0400 Feature nasa#98 - Refactor UI to table widgets Removed unnecessary file commit b0bd3fa Author: Leor Bleier <Leor.Z.Bleier@nasa.gov> Date: Mon Jun 1 09:06:45 2020 -0400 Feature nasa#98 - Refactor UI to use table widgets Backend updated accordingly. Other various tweaks/fixes as needed commit fb0ccb6 Author: Leor Bleier <Leor.Z.Bleier@nasa.gov> Date: Wed May 27 16:23:40 2020 -0400 Fix nasa#46 Recommended lgtm python issues Problems shown in this issue were fixed in nasa#72 as part of updates/refactoring. Other lgtm issues addressed here. Problems in auto-generated .py files not addressed. Auto-generated .py files renamed with Ui_ prefix. The lgtm.yml file must be updated to exclude these See nasa/cFS#92 commit b3d8039 Author: Leor Bleier <Leor.Z.Bleier@nasa.gov> Date: Wed May 20 07:54:39 2020 -0400 Fix nasa#88 - Modify GroundSystem to use JSON files generated by CCDD Also includes further updates and refinements to overall UI commit 26486cb Author: Leor Bleier <Leor.Z.Bleier@nasa.gov> Date: Thu May 14 11:37:11 2020 -0400 Fix nasa#72 - Upgrade PyQt4 to PyQt5 Further edits based on CCB feedback, and other fixes as necessary commit 876a39d Author: Leor Bleier <Leor.Z.Bleier@nasa.gov> Date: Mon May 11 17:08:21 2020 -0400 Fix nasa#72 - Upgrade PyQt4 to PyQt5 Includes code cleanup/refactoring. Also fixes nasa#71
1 parent 52f706b commit adf31d8

30 files changed

+1432
-12576
lines changed

GroundSystem.py

+47-11
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# See the License for the specific language governing permissions and
1818
# limitations under the License.
1919
#
20-
#cFS Ground System Version 2.0.0
20+
# cFS Ground System Version 2.0.0
2121
#
2222
#!/usr/bin/env python3
2323
#
@@ -28,8 +28,8 @@
2828

2929
from PyQt5.QtWidgets import QApplication, QMainWindow, QMessageBox
3030

31-
from MainWindow import Ui_MainWindow
3231
from RoutingService import RoutingService
32+
from Ui_MainWindow import Ui_MainWindow
3333

3434
ROOTDIR = Path(sys.argv[0]).resolve().parent
3535

@@ -38,18 +38,25 @@
3838
# CFS Ground System: Setup and manage the main window
3939
#
4040
class GroundSystem(QMainWindow, Ui_MainWindow):
41+
HDR_VER_1_OFFSET = 0
42+
HDR_VER_2_OFFSET = 4
43+
4144
#
4245
# Init the class
4346
#
4447
def __init__(self):
4548
super().__init__()
46-
self.setupUi((self))
49+
self.setupUi(self)
4750

4851
self.RoutingService = None
4952
self.alert = QMessageBox()
5053

5154
self.pushButtonStartTlm.clicked.connect(self.startTlmSystem)
5255
self.pushButtonStartCmd.clicked.connect(self.startCmdSystem)
56+
self.cbTlmHeaderVer.currentIndexChanged.connect(self.setTlmOffset)
57+
self.cbCmdHeaderVer.currentIndexChanged.connect(self.setCmdOffsets)
58+
for sb in (self.sbTlmOffset, self.sbCmdOffsetPri, self.sbCmdOffsetSec):
59+
sb.valueChanged.connect(self.saveOffsets)
5360
# Init lists
5461
self.ipAddressesList = ['All']
5562
self.spacecraftNames = ['All']
@@ -81,14 +88,12 @@ def DisplayErrorMessage(self, message):
8188

8289
# Start the telemetry system for the selected spacecraft
8390
def startTlmSystem(self):
91+
# Setup the subscription (to let the telemetry
92+
# system know the messages it will be receiving)
93+
subscription = '--sub=GroundSystem'
8494
selectedSpacecraft = self.getSelectedSpacecraftName()
85-
86-
# Setup the subscription (to let know the
87-
# telemetry system the messages it will be receiving)
88-
if selectedSpacecraft == 'All':
89-
subscription = '--sub=GroundSystem'
90-
else:
91-
subscription = f'--sub=GroundSystem.{selectedSpacecraft}.TelemetryPackets'
95+
if selectedSpacecraft != 'All':
96+
subscription += f'.{selectedSpacecraft}.TelemetryPackets'
9297

9398
# Open Telemetry System
9499
system_call = f'python3 {ROOTDIR}/Subsystems/tlmGUI/TelemetrySystem.py {subscription}'
@@ -105,7 +110,6 @@ def startCmdSystem():
105110
def startFDLSystem(self):
106111
selectedSpacecraft = self.getSelectedSpacecraftName()
107112
if selectedSpacecraft == 'All':
108-
subscription = ''
109113
self.DisplayErrorMessage(
110114
'Cannot open FDL manager.\nNo spacecraft selected.')
111115
else:
@@ -115,6 +119,37 @@ def startFDLSystem(self):
115119
subscription
116120
])
117121

122+
def setTlmOffset(self):
123+
selectedVer = self.cbTlmHeaderVer.currentText().strip()
124+
if selectedVer == "Custom":
125+
self.sbTlmOffset.setEnabled(True)
126+
else:
127+
self.sbTlmOffset.setEnabled(False)
128+
if selectedVer == "1":
129+
self.sbTlmOffset.setValue(self.HDR_VER_1_OFFSET)
130+
elif selectedVer == "2":
131+
self.sbTlmOffset.setValue(self.HDR_VER_2_OFFSET)
132+
133+
def setCmdOffsets(self):
134+
selectedVer = self.cbCmdHeaderVer.currentText().strip()
135+
if selectedVer == "Custom":
136+
self.sbCmdOffsetPri.setEnabled(True)
137+
self.sbCmdOffsetSec.setEnabled(True)
138+
else:
139+
self.sbCmdOffsetPri.setEnabled(False)
140+
self.sbCmdOffsetSec.setEnabled(False)
141+
if selectedVer == "1":
142+
self.sbCmdOffsetPri.setValue(self.HDR_VER_1_OFFSET)
143+
elif selectedVer == "2":
144+
self.sbCmdOffsetPri.setValue(self.HDR_VER_2_OFFSET)
145+
self.sbCmdOffsetSec.setValue(self.HDR_VER_1_OFFSET)
146+
147+
def saveOffsets(self):
148+
offsets = bytes((self.sbTlmOffset.value(), self.sbCmdOffsetPri.value(),
149+
self.sbCmdOffsetSec.value()))
150+
with open("/tmp/OffsetData", "wb") as f:
151+
f.write(offsets)
152+
118153
# Update the combo box list in gui
119154
def updateIpList(self, ip, name):
120155
self.ipAddressesList.append(ip)
@@ -145,6 +180,7 @@ def initRoutingService(self):
145180

146181
# Start the Routing Service
147182
MainWindow.initRoutingService()
183+
MainWindow.saveOffsets()
148184

149185
# Execute the app
150186
sys.exit(app.exec_())

MainWindow.ui

+135-29
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
<rect>
1010
<x>0</x>
1111
<y>0</y>
12-
<width>420</width>
13-
<height>217</height>
12+
<width>552</width>
13+
<height>305</height>
1414
</rect>
1515
</property>
1616
<property name="sizePolicy">
@@ -25,7 +25,7 @@
2525
<widget class="QWidget" name="centralwidget">
2626
<layout class="QVBoxLayout" name="verticalLayout">
2727
<item>
28-
<widget class="QLabel" name="labelHomeTittle">
28+
<widget class="QLabel" name="labelHomeTitle">
2929
<property name="font">
3030
<font>
3131
<pointsize>22</pointsize>
@@ -49,21 +49,8 @@
4949
</widget>
5050
</item>
5151
<item>
52-
<layout class="QHBoxLayout" name="horizontalLayout">
53-
<item>
54-
<spacer name="horizontalSpacer">
55-
<property name="orientation">
56-
<enum>Qt::Horizontal</enum>
57-
</property>
58-
<property name="sizeHint" stdset="0">
59-
<size>
60-
<width>40</width>
61-
<height>20</height>
62-
</size>
63-
</property>
64-
</spacer>
65-
</item>
66-
<item>
52+
<layout class="QGridLayout" name="gridLayout">
53+
<item row="0" column="0">
6754
<widget class="QLabel" name="label_3">
6855
<property name="sizePolicy">
6956
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
@@ -78,14 +65,14 @@
7865
</size>
7966
</property>
8067
<property name="text">
81-
<string>Selected IP Address: </string>
68+
<string>Selected IP Address</string>
8269
</property>
8370
<property name="alignment">
84-
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
71+
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
8572
</property>
8673
</widget>
8774
</item>
88-
<item>
75+
<item row="0" column="1">
8976
<widget class="QComboBox" name="comboBoxIpAddresses">
9077
<property name="minimumSize">
9178
<size>
@@ -106,18 +93,137 @@
10693
</item>
10794
</widget>
10895
</item>
109-
<item>
110-
<spacer name="horizontalSpacer_2">
111-
<property name="orientation">
112-
<enum>Qt::Horizontal</enum>
96+
<item row="1" column="0">
97+
<widget class="QLabel" name="label_4">
98+
<property name="sizePolicy">
99+
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
100+
<horstretch>0</horstretch>
101+
<verstretch>0</verstretch>
102+
</sizepolicy>
103+
</property>
104+
<property name="minimumSize">
105+
<size>
106+
<width>169</width>
107+
<height>0</height>
108+
</size>
109+
</property>
110+
<property name="text">
111+
<string>Tlm header version</string>
112+
</property>
113+
<property name="alignment">
114+
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
113115
</property>
114-
<property name="sizeHint" stdset="0">
116+
</widget>
117+
</item>
118+
<item row="1" column="1">
119+
<widget class="QComboBox" name="cbTlmHeaderVer">
120+
<property name="minimumSize">
115121
<size>
116-
<width>40</width>
117-
<height>20</height>
122+
<width>132</width>
123+
<height>0</height>
124+
</size>
125+
</property>
126+
<property name="maximumSize">
127+
<size>
128+
<width>132</width>
129+
<height>16777215</height>
118130
</size>
119131
</property>
120-
</spacer>
132+
<item>
133+
<property name="text">
134+
<string>1</string>
135+
</property>
136+
</item>
137+
<item>
138+
<property name="text">
139+
<string>2</string>
140+
</property>
141+
</item>
142+
<item>
143+
<property name="text">
144+
<string>Custom</string>
145+
</property>
146+
</item>
147+
</widget>
148+
</item>
149+
<item row="2" column="0">
150+
<widget class="QLabel" name="label_2">
151+
<property name="text">
152+
<string>Cmd header version</string>
153+
</property>
154+
</widget>
155+
</item>
156+
<item row="1" column="2">
157+
<widget class="QSpinBox" name="sbTlmOffset">
158+
<property name="enabled">
159+
<bool>false</bool>
160+
</property>
161+
<property name="toolTip">
162+
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Offset (in bytes) to be &lt;span style=&quot; font-weight:600;&quot;&gt;added to&lt;/span&gt; existing offsets listed in telemetry text files&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
163+
</property>
164+
<property name="buttonSymbols">
165+
<enum>QAbstractSpinBox::NoButtons</enum>
166+
</property>
167+
</widget>
168+
</item>
169+
<item row="2" column="2">
170+
<widget class="QSpinBox" name="sbCmdOffsetPri">
171+
<property name="enabled">
172+
<bool>false</bool>
173+
</property>
174+
<property name="toolTip">
175+
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Offset (in bytes) to be added &lt;span style=&quot; font-weight:600;&quot;&gt;after&lt;/span&gt; the &lt;span style=&quot; font-weight:600;&quot;&gt;primary&lt;/span&gt; header in a command packet&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
176+
</property>
177+
<property name="buttonSymbols">
178+
<enum>QAbstractSpinBox::NoButtons</enum>
179+
</property>
180+
</widget>
181+
</item>
182+
<item row="2" column="1">
183+
<widget class="QComboBox" name="cbCmdHeaderVer">
184+
<item>
185+
<property name="text">
186+
<string>1</string>
187+
</property>
188+
</item>
189+
<item>
190+
<property name="text">
191+
<string>2</string>
192+
</property>
193+
</item>
194+
<item>
195+
<property name="text">
196+
<string>Custom</string>
197+
</property>
198+
</item>
199+
</widget>
200+
</item>
201+
<item row="2" column="3">
202+
<widget class="QSpinBox" name="sbCmdOffsetSec">
203+
<property name="enabled">
204+
<bool>false</bool>
205+
</property>
206+
<property name="toolTip">
207+
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Offset (in bytes) to be added &lt;span style=&quot; font-weight:600;&quot;&gt;after&lt;/span&gt; the &lt;span style=&quot; font-weight:600;&quot;&gt;secondary&lt;/span&gt; header in a command packet&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
208+
</property>
209+
<property name="buttonSymbols">
210+
<enum>QAbstractSpinBox::NoButtons</enum>
211+
</property>
212+
</widget>
213+
</item>
214+
<item row="0" column="2">
215+
<widget class="QLabel" name="label">
216+
<property name="text">
217+
<string>Offsets</string>
218+
</property>
219+
</widget>
220+
</item>
221+
<item row="0" column="3">
222+
<widget class="QLabel" name="label_6">
223+
<property name="text">
224+
<string>(Hover for info)</string>
225+
</property>
226+
</widget>
121227
</item>
122228
</layout>
123229
</item>

RoutingService.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ def run(self):
100100

101101
# Handle errors
102102
except socket.error:
103-
print(
104-
f'Ignored socket error for attempt {socketErrorCount}')
103+
print('Ignored socket error for attempt', socketErrorCount)
105104
socketErrorCount += 1
106105
sleep(1)
107106

Subsystems/cmdGui/CHeaderParser.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,11 @@ def getFileList(filename='CHeaderParser-hdr-paths.txt'):
103103
l = l.strip()
104104
if l and not l.startswith("#"):
105105
paths.append(l)
106-
print(f"Using header files found in {filename}")
107-
# Send paths back to caller function
108-
return paths
106+
print(f"Using header files found in {filename}")
107+
# Send paths back to caller function
108+
return paths
109109
except IOError:
110110
print("Couldn't find default file. Check command line arguments.")
111-
except:
112-
print("Unexpected error:", sys.exc_info()[0])
113111

114112
print("No header files found. Please make sure to provide the\n"
115113
"default file for loading headers (CHeaderParser-hdr-paths.txt)")
@@ -449,7 +447,7 @@ def getFileList(filename='CHeaderParser-hdr-paths.txt'):
449447
input((f"Please enter the defined value for "
450448
f"{array_name_size[1]} (0 - 128): ")))
451449
except ValueError:
452-
pass
450+
pass # Ignore non-integer and try again
453451

454452
# Add string length argument to parameter list
455453
stringLens.append(array_size)

0 commit comments

Comments
 (0)