Skip to content

Commit

Permalink
Enhancement nasa#103 - custom header mechanism
Browse files Browse the repository at this point in the history
Updated UI and backend to support custom header sizes.
Change only impacts tlm currently
  • Loading branch information
lbleier-GSFC committed Jun 16, 2020
1 parent 821f06c commit 7754c9f
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 172 deletions.
35 changes: 25 additions & 10 deletions GroundSystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
#cFS Ground System Version 2.0.0
# cFS Ground System Version 2.0.0
#
#!/usr/bin/env python3
#
Expand All @@ -28,8 +28,9 @@

from PyQt5.QtWidgets import QApplication, QMainWindow, QMessageBox

from MainWindow import Ui_MainWindow
import common.shareddata as shared
from RoutingService import RoutingService
from Ui_MainWindow import Ui_MainWindow

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

Expand All @@ -43,13 +44,15 @@ class GroundSystem(QMainWindow, Ui_MainWindow):
#
def __init__(self):
super().__init__()
self.setupUi((self))
self.setupUi(self)

self.RoutingService = None
self.alert = QMessageBox()

self.pushButtonStartTlm.clicked.connect(self.startTlmSystem)
self.pushButtonStartCmd.clicked.connect(self.startCmdSystem)
self.cbHeaderVer.currentIndexChanged.connect(self.setFixedOffset)
self.sbOffset.valueChanged.connect(self.getOffset)
# Init lists
self.ipAddressesList = ['All']
self.spacecraftNames = ['All']
Expand Down Expand Up @@ -81,14 +84,12 @@ def DisplayErrorMessage(self, message):

# Start the telemetry system for the selected spacecraft
def startTlmSystem(self):
# Setup the subscription (to let the telemetry
# system know the messages it will be receiving)
subscription = '--sub=GroundSystem'
selectedSpacecraft = self.getSelectedSpacecraftName()

# Setup the subscription (to let know the
# telemetry system the messages it will be receiving)
if selectedSpacecraft == 'All':
subscription = '--sub=GroundSystem'
else:
subscription = f'--sub=GroundSystem.{selectedSpacecraft}.TelemetryPackets'
if selectedSpacecraft != 'All':
subscription += f'.{selectedSpacecraft}.TelemetryPackets'

# Open Telemetry System
system_call = f'python3 {ROOTDIR}/Subsystems/tlmGUI/TelemetrySystem.py {subscription}'
Expand All @@ -114,6 +115,20 @@ def startFDLSystem(self):
subscription
])

def setFixedOffset(self):
selectedVer = self.cbHeaderVer.currentText().strip()
if selectedVer == "Custom":
self.sbOffset.setEnabled(True)
else:
self.sbOffset.setEnabled(False)
if selectedVer == "1":
self.sbOffset.setValue(0)
elif selectedVer == "2":
self.sbOffset.setValue(4)

def getOffset(self):
shared.offsetVal = self.sbOffset.value()

# Update the combo box list in gui
def updateIpList(self, ip, name):
self.ipAddressesList.append(ip)
Expand Down
121 changes: 0 additions & 121 deletions MainWindow.py

This file was deleted.

105 changes: 76 additions & 29 deletions MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>420</width>
<height>217</height>
<width>452</width>
<height>265</height>
</rect>
</property>
<property name="sizePolicy">
Expand All @@ -25,7 +25,7 @@
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="labelHomeTittle">
<widget class="QLabel" name="labelHomeTitle">
<property name="font">
<font>
<pointsize>22</pointsize>
Expand All @@ -49,21 +49,8 @@
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
Expand All @@ -78,14 +65,14 @@
</size>
</property>
<property name="text">
<string>Selected IP Address: </string>
<string>Selected IP Address</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBoxIpAddresses">
<property name="minimumSize">
<size>
Expand All @@ -106,18 +93,78 @@
</item>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeHint" stdset="0">
<property name="minimumSize">
<size>
<width>40</width>
<height>20</height>
<width>141</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Header version</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="cbHeaderVer">
<property name="minimumSize">
<size>
<width>132</width>
<height>0</height>
</size>
</property>
</spacer>
<property name="maximumSize">
<size>
<width>132</width>
<height>16777215</height>
</size>
</property>
<item>
<property name="text">
<string>1</string>
</property>
</item>
<item>
<property name="text">
<string>2</string>
</property>
</item>
<item>
<property name="text">
<string>Custom</string>
</property>
</item>
</widget>
</item>
<item row="1" column="2">
<widget class="QSpinBox" name="sbOffset">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Offset (in bytes) to be *added to* existing offsets listed in tlm/cmd text files&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label">
<property name="text">
<string>Offset (bytes)</string>
</property>
</widget>
</item>
</layout>
</item>
Expand Down
3 changes: 1 addition & 2 deletions RoutingService.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ def run(self):

# Handle errors
except socket.error:
print(
f'Ignored socket error for attempt {socketErrorCount}')
print('Ignored socket error for attempt', socketErrorCount)
socketErrorCount += 1
sleep(1)

Expand Down
5 changes: 3 additions & 2 deletions Subsystems/cmdGui/CommandSystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

from Ui_CommandSystemDialog import Ui_CommandSystemDialog

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


Expand Down Expand Up @@ -94,7 +95,7 @@ def ProcessQuickButton(self, idx):
# if doesn't require parameters
else:
launch_string = (
f'{ROOTDIR}/../cmdUtil/cmdUtil '
f'{ROOTDIR.parent}/cmdUtil/cmdUtil '
f'--host=\"{address}\" --port={quickPort[qIdx]} '
f'--pktid={pktId} --endian={quickEndian[qIdx]} '
f'--cmdcode={quickCode[qIdx]}')
Expand Down Expand Up @@ -166,7 +167,7 @@ def ProcessQuickButton(self, idx):
with open(f'{ROOTDIR}/{quickDefFile}') as subFile:
reader = csv.reader(subFile)
for fileRow in reader:
if fileRow[0][0] != '#':
if not fileRow[0].startswith('#'):
subsys.append(fileRow[0])
subsysFile.append(fileRow[1])
quickCmd.append(fileRow[2].strip())
Expand Down
Loading

0 comments on commit 7754c9f

Please sign in to comment.