Skip to content

Commit 6fb6e96

Browse files
lbleier-GSFCGerardo E. Cruz-Ortiz
authored and
Gerardo E. Cruz-Ortiz
committed
Resolve #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 Also removed the shareddata.py file; no longer needed at this time
1 parent aa15da9 commit 6fb6e96

12 files changed

+630
-971
lines changed

GroundSystem.py

+47-10
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}'
@@ -114,6 +119,37 @@ def startFDLSystem(self):
114119
subscription
115120
])
116121

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+
117153
# Update the combo box list in gui
118154
def updateIpList(self, ip, name):
119155
self.ipAddressesList.append(ip)
@@ -144,6 +180,7 @@ def initRoutingService(self):
144180

145181
# Start the Routing Service
146182
MainWindow.initRoutingService()
183+
MainWindow.saveOffsets()
147184

148185
# Execute the app
149186
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/CommandSystem.py

+21-8
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@
2929
from PyQt5.QtWidgets import (QApplication, QDialog, QHeaderView, QPushButton,
3030
QTableWidgetItem)
3131

32+
from MiniCmdUtil import MiniCmdUtil
3233
from Ui_CommandSystemDialog import Ui_CommandSystemDialog
3334

35+
## ../cFS/tools/cFS-GroundSystem/Subsystems/cmdGui/
3436
ROOTDIR = Path(sys.argv[0]).resolve().parent
3537

3638

@@ -43,6 +45,7 @@ def __init__(self):
4345
super().__init__()
4446
self.setupUi(self)
4547
self.move(800, 100)
48+
self.mcu = None
4649

4750
#
4851
# Processes 'Display Page' button
@@ -91,15 +94,25 @@ def ProcessQuickButton(self, idx):
9194
f'--port={quickPort[qIdx]} '
9295
f'--pktid={pktId} --endian={quickEndian[qIdx]} '
9396
f'--cmdcode={quickCode[qIdx]} --file={quickParam[qIdx]}')
97+
cmd_args = shlex.split(launch_string)
98+
subprocess.Popen(cmd_args)
9499
# if doesn't require parameters
95100
else:
96-
launch_string = (
97-
f'{ROOTDIR}/../cmdUtil/cmdUtil '
98-
f'--host=\"{address}\" --port={quickPort[qIdx]} '
99-
f'--pktid={pktId} --endian={quickEndian[qIdx]} '
100-
f'--cmdcode={quickCode[qIdx]}')
101-
cmd_args = shlex.split(launch_string)
102-
subprocess.Popen(cmd_args)
101+
self.mcu = MiniCmdUtil(address, quickPort[qIdx],
102+
quickEndian[qIdx], pktId,
103+
quickCode[qIdx])
104+
sendSuccess = self.mcu.sendPacket()
105+
print("Command sent successfully:", sendSuccess)
106+
# launch_string = (
107+
# f'{ROOTDIR.parent}/cmdUtil/cmdUtil '
108+
# f'--host=\"{address}\" --port={quickPort[qIdx]} '
109+
# f'--pktid={pktId} --endian={quickEndian[qIdx]} '
110+
# f'--cmdcode={quickCode[qIdx]}')
111+
112+
def closeEvent(self, event):
113+
if self.mcu:
114+
self.mcu.mm.close()
115+
super().closeEvent(event)
103116

104117

105118
#
@@ -166,7 +179,7 @@ def ProcessQuickButton(self, idx):
166179
with open(f'{ROOTDIR}/{quickDefFile}') as subFile:
167180
reader = csv.reader(subFile)
168181
for fileRow in reader:
169-
if fileRow[0][0] != '#':
182+
if not fileRow[0].startswith('#'):
170183
subsys.append(fileRow[0])
171184
subsysFile.append(fileRow[1])
172185
quickCmd.append(fileRow[2].strip())

0 commit comments

Comments
 (0)