Skip to content

Commit

Permalink
WIP Fix nasa#72 - Upgrade PyQt and implement fixes/cleanup/refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
lbleier-GSFC committed Apr 27, 2020
1 parent 725e8fa commit 41f5f00
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 113 deletions.
12 changes: 6 additions & 6 deletions GroundSystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def __init__(self):
self.setupUi((self))

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

self.pushButtonStartTlm.clicked.connect(self.startTlmSystem)
self.pushButtonStartCmd.clicked.connect(self.startCmdSystem)
Expand All @@ -73,13 +74,12 @@ def getSelectedSpacecraftName(self):
#
# Display popup with error
#
@staticmethod
def DisplayErrorMessage(message):
def DisplayErrorMessage(self, message):
print(message)
alert = QMessageBox()
alert.setText(message)
alert.setIcon(QMessageBox.Warning)
alert.exec_()
# alert = QMessageBox()
self.alert.setText(message)
self.alert.setIcon(QMessageBox.Warning)
self.alert.exec_()

# Start the telemetry system for the selected spacecraft
def startTlmSystem(self):
Expand Down
2 changes: 1 addition & 1 deletion Guide-GroundSystem.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Installing and running cFS Ground System on Ubuntu:
$ python3 GroundSystem.py


The historically included instructions for running on Mac or CentOS are inluded at the bottom of this document for referance.
The historically included instructions for running on Mac or CentOS are inluded at the bottom of this document for reference.
Please note that instructions have not been maintained.
Welcoming instruction contributions if any of these are your platform of choice.

Expand Down
54 changes: 2 additions & 52 deletions Subsystems/cmdGui/Parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ def ProcessSendButton(self):
while input_list[k]:
dataType = dataTypesNew[k]
if dataType == '--string':
param_list.append(f'{dataType}=\"{stringLen[k]}:{input_list[k]}\"')
param_list.append(
f'{dataType}=\"{stringLen[k]}:{input_list[k]}\"')
else:
param_list.append(f'{dataType}={input_list[k]}') # --byte=4
k += 1
Expand Down Expand Up @@ -145,57 +146,6 @@ def ProcessSendButton(self):
descrip.setText(paramDesc[i])
except IndexError:
pass
# try:
# param.paramName_1.setText(paramNames[0])
# param.descrip_1.setText(paramDesc[0])
# except IndexError:
# pass

# try:
# param.paramName_2.setText(paramNames[1])
# param.descrip_2.setText(paramDesc[1])
# except IndexError:
# pass
# try:
# param.paramName_3.setText(paramNames[2])
# param.descrip_3.setText(paramDesc[2])
# except IndexError:
# pass
# try:
# param.paramName_4.setText(paramNames[3])
# param.descrip_4.setText(paramDesc[3])
# except IndexError:
# pass
# try:
# param.paramName_5.setText(paramNames[4])
# param.descrip_5.setText(paramDesc[4])
# except IndexError:
# pass
# try:
# param.paramName_6.setText(paramNames[5])
# param.descrip_6.setText(paramDesc[5])
# except IndexError:
# pass
# try:
# param.paramName_7.setText(paramNames[6])
# param.descrip_7.setText(paramDesc[6])
# except IndexError:
# pass
# try:
# param.paramName_8.setText(paramNames[7])
# param.descrip_8.setText(paramDesc[7])
# except IndexError:
# pass
# try:
# param.paramName_9.setText(paramNames[8])
# param.descrip_9.setText(paramDesc[8])
# except IndexError:
# pass
# try:
# param.paramName_10.setText(paramNames[9])
# param.descrip_10.setText(paramDesc[9])
# except IndexError:
# pass

#
# Displays the dialog
Expand Down
2 changes: 0 additions & 2 deletions Subsystems/cmdGui/UdpCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
from PyQt5.QtWidgets import QApplication, QDialog

from GenericCommandDialog import Ui_GenericCommandDialog
from HTMLDocsParser import HTMLDocsParser

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

Expand All @@ -56,7 +55,6 @@ def __init__(self):
super().__init__()
self.setupUi(self)
self.setWindowTitle(pageTitle)
self.parser = HTMLDocsParser()

for j in range(25):
btn = getattr(self, f"SendButton_{j+1}")
Expand Down
24 changes: 13 additions & 11 deletions Subsystems/tlmGUI/EventMessage.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,28 +60,30 @@
# uint8 Spare1;
# uint8 Spare2;

import sys
import getopt
import zmq
import sys

from PyQt5.QtWidgets import QDialog, QApplication
import zmq
from PyQt5.QtCore import QThread, pyqtSignal
from PyQt5.QtWidgets import QApplication, QDialog

from EventMessageDialog import Ui_EventMessageDialog

# from struct import *


class EventMessageTelemetry(QDialog, Ui_EventMessageDialog):

pktCount = 0

def __init__(self, appId):
def __init__(self, aid):
super().__init__()
self.appId = appId
self.setupUi(self)
self.appId = aid

def initTlmReceiver(self, subscription):
self.setWindowTitle(f'{pageTitle} for: {subscription}')
self.thread = TlmReceiver(subscription, self.appId)
def initTlmReceiver(self, subscr):
self.setWindowTitle(f'{pageTitle} for: {subscr}')
self.thread = TlmReceiver(subscr, self.appId)
self.thread.signalTlmDatagram.connect(self.processPendingDatagrams)
self.thread.start()

Expand Down Expand Up @@ -113,15 +115,15 @@ class TlmReceiver(QThread):
# Setup signal to communicate with front-end GUI
signalTlmDatagram = pyqtSignal(object, name="TlmDatagram")

def __init__(self, subscription, appId):
def __init__(self, subscr, aid):
super().__init__()
self.appId = appId
self.appId = aid

# Init zeroMQ
self.context = zmq.Context()
self.subscriber = self.context.socket(zmq.SUB)
self.subscriber.connect("ipc:///tmp/GroundSystem")
subscriptionString = f"{str(subscription)}.Spacecraft1.TelemetryPackets.{str(appId)}"
subscriptionString = f"{str(subscr)}.Spacecraft1.TelemetryPackets.{str(appId)}"
self.subscriber.setsockopt_string(zmq.SUBSCRIBE, subscriptionString)

def run(self):
Expand Down
11 changes: 6 additions & 5 deletions Subsystems/tlmGUI/GenericTelemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

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


class SubsystemTelemetry(QDialog, Ui_GenericTelemetryDialog):

pktCount = 0
Expand Down Expand Up @@ -70,9 +71,9 @@ def displayTelemetryItem(datagram, tlmIndex, labelField, valueField):
labelField.setText("(unused)")

# Start the telemetry receiver (see TlmReceiver class)
def initTlmReceiver(self, subscription):
self.setWindowTitle(f"{pageTitle} for: {subscription}")
self.thread = TlmReceiver(self, subscription)
def initTlmReceiver(self, subscr):
self.setWindowTitle(f"{pageTitle} for: {subscr}")
self.thread = TlmReceiver(self, subscr)
self.thread.signalTlmDatagram.connect(self.processPendingDatagrams)
self.thread.start()

Expand Down Expand Up @@ -101,14 +102,14 @@ class TlmReceiver(QThread):
# Setup signal to communicate with front-end GUI
signalTlmDatagram = pyqtSignal(object, name="TlmDatagram")

def __init__(self, mainWindow, subscription):
def __init__(self, subscr):
super().__init__()

# Init zeroMQ
self.context = zmq.Context()
self.subscriber = self.context.socket(zmq.SUB)
self.subscriber.connect("ipc:///tmp/GroundSystem")
myTlmPgAPID = subscription.split(".", 1)
myTlmPgAPID = subscr.split(".", 1)
mySubscription = f"GroundSystem.Spacecraft1.TelemetryPackets.{myTlmPgAPID[1]}"
self.subscriber.setsockopt_string(zmq.SUBSCRIBE, mySubscription)

Expand Down
53 changes: 17 additions & 36 deletions Subsystems/tlmGUI/TelemetrySystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

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


class TelemetrySystem(QDialog, Ui_TelemetrySystemDialog):

pktCount = 0
Expand Down Expand Up @@ -63,7 +64,7 @@ def strToHex(aString):
hexStr = ""
for x in aString:
hexStr += f'{ord(x):02X} '
return hexStr
return hexStr.strip()

#
# Dump the telemetry packet
Expand All @@ -80,47 +81,27 @@ def ProcessButtonGeneric(self, idx):
tempSub = f"{self.subscription}.{hex(tlmPageAppid[idx])}"
if tlmPageIsValid[idx]:
# need to extract data from fields, then start page with right params
launch_string = (
f'python3 {ROOTDIR}/{tlmClass[idx]} '
f'--title=\"{tlmPageDesc[idx]}\" --appid={hex(tlmPageAppid[idx])} '
f'--port={tlmPagePort[idx]} --file={tlmPageDefFile[idx]} '
f'--endian={endian} --sub={tempSub}')
launch_string = (f'python3 {ROOTDIR}/{tlmClass[idx]} '
f'--title=\"{tlmPageDesc[idx]}\" '
f'--appid={hex(tlmPageAppid[idx])} '
f'--port={tlmPagePort[idx]} '
f'--file={tlmPageDefFile[idx]} '
f'--endian={endian} --sub={tempSub}')
cmd_args = shlex.split(launch_string)
subprocess.Popen(cmd_args)

# Start the telemetry receiver (see TlmReceiver class)
def initTlmReceiver(self, subscription):
self.setWindowTitle(f'Telemetry System page for: {subscription}')
self.subscription = subscription
self.thread = TlmReceiver(self, subscription)
def initTlmReceiver(self, subscr):
self.setWindowTitle(f'Telemetry System page for: {subscr}')
self.subscription = subscr
self.thread = TlmReceiver(subscr)
self.thread.signalTlmDatagram.connect(self.processPendingDatagrams)
self.thread.start()

#
# This method processes packets. Called when the TelemetryReceiver receives a message/packet
#
def processPendingDatagrams(self, datagram):

#
# convert a string of binary bytes to ascii hex
#
# def strToHex(aString):
# hexStr = ""
# for x in aString:
# hexStr += f'{ord(x):02X}'
# return hexStr

# #
# # Dump the telemetry packet
# #
# def dumpPacket(packetData):
# appIdString = f"{ord(packetData[0]):02X}"
# appIdString = f"{appIdString}{ord(packetData[1]):02X}"
# appId = (ord(packetData[0]) << 8) + (ord(packetData[1]))
# print("\nPacket: App ID =", hex(appId))
# print("\nPacket Data:", strToHex(packetData))
# print("\n-----------------------------------------------")

#
# Show number of packets received
#
Expand Down Expand Up @@ -148,25 +129,25 @@ def processPendingDatagrams(self, datagram):
# Maybe store a pointer to the field in the gui
#
if l < 15:
countBrowseri = getattr(self, f"countBrowser_{l}")
countBrowser_l = getattr(self, f"countBrowser_{l}")
else:
countBrowseri = getattr(self, f"countBrowser_{l+1}")
countBrowseri.setText(str(tlmPageCount[l]))
countBrowser_l = getattr(self, f"countBrowser_{l+1}")
countBrowser_l.setText(str(tlmPageCount[l]))


# Subscribes and receives zeroMQ messages
class TlmReceiver(QThread):
# Setup signal to communicate with front-end GUI
signalTlmDatagram = pyqtSignal(object, name="TlmDatagram")

def __init__(self, mainWindow, subscription):
def __init__(self, subscr):
super().__init__()

# Init zeroMQ
self.context = zmq.Context()
self.subscriber = self.context.socket(zmq.SUB)
self.subscriber.connect("ipc:///tmp/GroundSystem")
self.subscriber.setsockopt_string(zmq.SUBSCRIBE, subscription)
self.subscriber.setsockopt_string(zmq.SUBSCRIBE, subscr)

def run(self):
while True:
Expand Down

0 comments on commit 41f5f00

Please sign in to comment.