Skip to content

Commit

Permalink
(WIP) Fixes nasa#72, upgrade PyQt4 to PyQt5 and implement other fixes…
Browse files Browse the repository at this point in the history
… as needed
  • Loading branch information
lbleier-GSFC committed May 5, 2020
1 parent f05f03f commit 5faf1c1
Show file tree
Hide file tree
Showing 12 changed files with 1,645 additions and 1,765 deletions.
12 changes: 6 additions & 6 deletions Subsystems/cmdGui/GenericCommandDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ def setupUi(self, GenericCommandDialog):
self.subSystemCommandPageLabel.setAlignment(QtCore.Qt.AlignCenter)
self.subSystemCommandPageLabel.setObjectName("subSystemCommandPageLabel")
self.verticalLayout.addWidget(self.subSystemCommandPageLabel)
self.lineEdit = QtWidgets.QLineEdit(GenericCommandDialog)
self.lineEdit.setMinimumSize(QtCore.QSize(159, 31))
self.lineEdit.setMaximumSize(QtCore.QSize(300, 31))
self.lineEdit.setObjectName("lineEdit")
self.verticalLayout.addWidget(self.lineEdit)
self.subSystemLineEdit = QtWidgets.QLineEdit(GenericCommandDialog)
self.subSystemLineEdit.setMinimumSize(QtCore.QSize(159, 31))
self.subSystemLineEdit.setMaximumSize(QtCore.QSize(300, 31))
self.subSystemLineEdit.setObjectName("subSystemLineEdit")
self.verticalLayout.addWidget(self.subSystemLineEdit)
self.horizontalLayout.addLayout(self.verticalLayout)
self.verticalLayout_2 = QtWidgets.QVBoxLayout()
self.verticalLayout_2.setObjectName("verticalLayout_2")
Expand Down Expand Up @@ -81,7 +81,7 @@ def setupUi(self, GenericCommandDialog):
self.scrollArea.setWidgetResizable(True)
self.scrollArea.setObjectName("scrollArea")
self.scrollAreaWidgetContents = QtWidgets.QWidget()
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, -63, 515, 1000))
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 515, 1000))
self.scrollAreaWidgetContents.setMinimumSize(QtCore.QSize(0, 1000))
self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents")
self.verticalLayout_5 = QtWidgets.QVBoxLayout(self.scrollAreaWidgetContents)
Expand Down
4 changes: 2 additions & 2 deletions Subsystems/cmdGui/GenericCommandDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit">
<widget class="QLineEdit" name="subSystemLineEdit">
<property name="minimumSize">
<size>
<width>159</width>
Expand Down Expand Up @@ -165,7 +165,7 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-63</y>
<y>0</y>
<width>515</width>
<height>1000</height>
</rect>
Expand Down
4 changes: 2 additions & 2 deletions Subsystems/cmdGui/UdpCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

class SubsystemCommands(QDialog, Ui_GenericCommandDialog):

pktCount = 0
# pktCount = 0

#
# Init the class
Expand Down Expand Up @@ -164,7 +164,7 @@ def usage():
#
app = QApplication(sys.argv)
Commands = SubsystemCommands()
Commands.subSystemTextBrowser.setText(pageTitle)
Commands.subSystemLineEdit.setText(pageTitle)
Commands.packetId.display(pagePktId)
Commands.commandAddressLineEdit.setText(pageAddress)

Expand Down
11 changes: 7 additions & 4 deletions Subsystems/tlmGUI/EventMessage.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,12 @@


class EventMessageTelemetry(QDialog, Ui_EventMessageDialog):

pktCount = 0

def __init__(self, aid):
super().__init__()
self.setupUi(self)
self.appId = aid
self.pktCount = 0
self.btnClose.clicked.connect(self.closeWin)

def initEMTlmReceiver(self, subscr):
self.setWindowTitle(f'{pageTitle} for: {subscr}')
Expand All @@ -96,7 +95,7 @@ def processPendingDatagrams(self, datagram):
# uint16 Sequence; 2
# uint16 Length; 4
# PktSequence = unpack("<H",datagram[2:4])
self.sequenceCount.setText(str(self.pktCount))
self.packetCount.setValue(self.pktCount)

#
# Not accounting for endian right now!
Expand All @@ -108,6 +107,10 @@ def processPendingDatagrams(self, datagram):
eventString = f"EVENT ---> {appName} : {eventText}"
self.eventOutput.appendPlainText(eventString)

def closeWin(self):
self.thread.quit()
self.close()


# Subscribes and receives zeroMQ messages
class EMTlmReceiver(QThread):
Expand Down
30 changes: 10 additions & 20 deletions Subsystems/tlmGUI/EventMessageDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ def setupUi(self, EventMessageDialog):
self.label_2.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_2.setObjectName("label_2")
self.horizontalLayout.addWidget(self.label_2)
self.sequenceCount = QtWidgets.QLineEdit(EventMessageDialog)
self.sequenceCount.setMinimumSize(QtCore.QSize(81, 31))
self.sequenceCount.setMaximumSize(QtCore.QSize(31, 16777215))
self.sequenceCount.setReadOnly(True)
self.sequenceCount.setObjectName("sequenceCount")
self.horizontalLayout.addWidget(self.sequenceCount)
self.packetCount = QtWidgets.QSpinBox(EventMessageDialog)
self.packetCount.setReadOnly(True)
self.packetCount.setButtonSymbols(QtWidgets.QAbstractSpinBox.NoButtons)
self.packetCount.setMaximum(16384)
self.packetCount.setObjectName("packetCount")
self.horizontalLayout.addWidget(self.packetCount)
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem)
self.line = QtWidgets.QFrame(EventMessageDialog)
Expand All @@ -52,32 +52,22 @@ def setupUi(self, EventMessageDialog):
self.horizontalLayout.addItem(spacerItem1)
spacerItem2 = QtWidgets.QSpacerItem(81, 31, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem2)
self.buttonBox = QtWidgets.QDialogButtonBox(EventMessageDialog)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.buttonBox.sizePolicy().hasHeightForWidth())
self.buttonBox.setSizePolicy(sizePolicy)
self.buttonBox.setMinimumSize(QtCore.QSize(91, 32))
self.buttonBox.setMaximumSize(QtCore.QSize(91, 32))
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Close)
self.buttonBox.setObjectName("buttonBox")
self.horizontalLayout.addWidget(self.buttonBox)
self.btnClose = QtWidgets.QPushButton(EventMessageDialog)
self.btnClose.setObjectName("btnClose")
self.horizontalLayout.addWidget(self.btnClose)
self.verticalLayout.addLayout(self.horizontalLayout)
self.eventOutput = QtWidgets.QPlainTextEdit(EventMessageDialog)
self.eventOutput.setReadOnly(True)
self.eventOutput.setObjectName("eventOutput")
self.verticalLayout.addWidget(self.eventOutput)

self.retranslateUi(EventMessageDialog)
self.buttonBox.accepted.connect(EventMessageDialog.accept)
self.buttonBox.rejected.connect(EventMessageDialog.reject)
QtCore.QMetaObject.connectSlotsByName(EventMessageDialog)

def retranslateUi(self, EventMessageDialog):
_translate = QtCore.QCoreApplication.translate
EventMessageDialog.setWindowTitle(_translate("EventMessageDialog", "Event Messages"))
self.label_2.setText(_translate("EventMessageDialog", "Packet Count"))
self.label.setText(_translate("EventMessageDialog", "Events"))
self.btnClose.setText(_translate("EventMessageDialog", "Close"))

82 changes: 11 additions & 71 deletions Subsystems/tlmGUI/EventMessageDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,16 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="sequenceCount">
<property name="minimumSize">
<size>
<width>81</width>
<height>31</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>31</width>
<height>16777215</height>
</size>
</property>
<widget class="QSpinBox" name="packetCount">
<property name="readOnly">
<bool>true</bool>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
<property name="maximum">
<number>16384</number>
</property>
</widget>
</item>
<item>
Expand Down Expand Up @@ -127,30 +121,9 @@
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>91</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>91</width>
<height>32</height>
</size>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
<widget class="QPushButton" name="btnClose">
<property name="text">
<string>Close</string>
</property>
</widget>
</item>
Expand All @@ -166,38 +139,5 @@
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>EventMessageDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>EventMessageDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
<connections/>
</ui>
25 changes: 14 additions & 11 deletions Subsystems/tlmGUI/GenericTelemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import getopt
import sys
from pathlib import Path
from struct import unpack, error
from struct import unpack

import zmq
from PyQt5.QtCore import QThread, pyqtSignal
Expand All @@ -37,14 +37,14 @@

class SubsystemTelemetry(QDialog, Ui_GenericTelemetryDialog):

pktCount = 0

#
# Init the class
#
def __init__(self):
super().__init__()
self.setupUi(self)
self.pktCount = 0
self.btnClose.clicked.connect(self.closeWin)

#
# This method Decodes a telemetry item from the packet and displays it
Expand All @@ -66,9 +66,9 @@ def displayTelemetryItem(datagram, tlmIndex, labelField, valueField):
valueField.setText(tlmItemEnum[tlmIndex][int(TlmField[0])])
elif tlmItemDisplayType[tlmIndex] == 'Str':
valueField.setText(TlmField[0].decode('utf-8', 'ignore'))
labelField.setText(tlmItemDesc[tlmIndex])
labelField.setPlainText(tlmItemDesc[tlmIndex])
else:
labelField.setText("(unused)")
labelField.setPlainText("(unused)")

# Start the telemetry receiver (see GTTlmReceiver class)
def initGTTlmReceiver(self, subscr):
Expand All @@ -86,16 +86,19 @@ def processPendingDatagrams(self, datagram):
# Show number of packets received
#
self.pktCount += 1
self.sequenceCount.setText(str(self.pktCount))
self.sequenceCount.setValue(self.pktCount)

#
# Decode and display all packet elements
#
for k in range(40):
itemLabelTextBrowser = getattr(self, f"itemLabelTextBrowser_{k+1}")
itemValueTextBrowser = getattr(self, f"itemValueTextBrowser_{k+1}")
self.displayTelemetryItem(datagram, k, itemLabelTextBrowser,
itemValueTextBrowser)
itemLabelpte = getattr(self, f"itemLabelPlainTextEdit_{k+1}")
itemValuele = getattr(self, f"itemValueLineEdit_{k+1}")
self.displayTelemetryItem(datagram, k, itemLabelpte, itemValuele)

def closeWin(self):
self.thread.quit()
self.close()


# Subscribes and receives zeroMQ messages
Expand Down Expand Up @@ -186,7 +189,7 @@ def usage():
#
app = QApplication(sys.argv)
Telem = SubsystemTelemetry()
Telem.subSystemTextBrowser.setText(pageTitle)
Telem.subSystemLineEdit.setText(pageTitle)
Telem.packetId.display(appId)

#
Expand Down
Loading

0 comments on commit 5faf1c1

Please sign in to comment.