Skip to content

Commit

Permalink
Merge pull request #100 from lbleier-GSFC/feature98-refactortotables
Browse files Browse the repository at this point in the history
Fix #98, Refactor individual UI elements to tables
  • Loading branch information
astrogeco authored Jun 23, 2020
2 parents 78c5766 + b8b70ab commit c7f9072
Show file tree
Hide file tree
Showing 25 changed files with 877 additions and 12,455 deletions.
1 change: 0 additions & 1 deletion GroundSystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ def startCmdSystem():
def startFDLSystem(self):
selectedSpacecraft = self.getSelectedSpacecraftName()
if selectedSpacecraft == 'All':
subscription = ''
self.DisplayErrorMessage(
'Cannot open FDL manager.\nNo spacecraft selected.')
else:
Expand Down
10 changes: 4 additions & 6 deletions Subsystems/cmdGui/CHeaderParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,11 @@ def getFileList(filename='CHeaderParser-hdr-paths.txt'):
l = l.strip()
if l and not l.startswith("#"):
paths.append(l)
print(f"Using header files found in {filename}")
# Send paths back to caller function
return paths
print(f"Using header files found in {filename}")
# Send paths back to caller function
return paths
except IOError:
print("Couldn't find default file. Check command line arguments.")
except:
print("Unexpected error:", sys.exc_info()[0])

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

# Add string length argument to parameter list
stringLens.append(array_size)
Expand Down
62 changes: 29 additions & 33 deletions Subsystems/cmdGui/CommandSystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@
import sys
from pathlib import Path

from PyQt5.QtWidgets import QApplication, QDialog
from PyQt5.QtWidgets import (QApplication, QDialog, QHeaderView, QPushButton,
QTableWidgetItem)

from CommandSystemDialog import Ui_CommandSystemDialog
from Ui_CommandSystemDialog import Ui_CommandSystemDialog

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

Expand All @@ -43,23 +44,13 @@ def __init__(self):
self.setupUi(self)
self.move(800, 100)

for n in range(21):
btn = getattr(self, f"pushButton_{n}")
btn.clicked.connect(lambda _, x=n: self.ProcessButtonGeneric(x))

for l in range(22):
btn = getattr(self, f"quickButton_{l+1}")
btn.clicked.connect(lambda _, x=l: self.ProcessQuickButton(x))

#
# Processes 'Display Page' button
#
def ProcessButtonGeneric(self, idx):
if cmdPageIsValid[idx]:
lePID = getattr(self, f'lineEditPktId_{idx}')
leAddr = getattr(self, f'lineEdit_{idx}')
pktId = lePID.text()
address = leAddr.text()
pktId = self.tblCmdSys.item(idx, 1).text()
address = self.tblCmdSys.item(idx, 2).text()
launch_string = (
f'python3 {ROOTDIR}/{cmdClass[0]} '
f'--title=\"{cmdPageDesc[idx]}\" --pktid={pktId} '
Expand Down Expand Up @@ -87,10 +78,8 @@ def checkParams(idx):
def ProcessQuickButton(self, idx):
if cmdPageIsValid[idx] and quickIndices[idx] >= 0:
qIdx = quickIndices[idx]
lePID = getattr(self, f'lineEditPktId_{idx}')
leAddr = getattr(self, f'lineEdit_{idx}')
pktId = lePID.text()
address = leAddr.text()
pktId = self.tblCmdSys.item(idx, 1).text()
address = self.tblCmdSys.item(idx, 2).text()

# if requires parameters
if self.checkParams(qIdx):
Expand Down Expand Up @@ -128,6 +117,7 @@ def ProcessQuickButton(self, idx):
#
app = QApplication(sys.argv)
Command = CommandSystem()
tbl = Command.tblCmdSys

#
# Read in the contents of the telemetry packet definition
Expand All @@ -141,7 +131,7 @@ def ProcessQuickButton(self, idx):
reader = csv.reader(cmdfile, skipinitialspace=True)
for cmdRow in reader:
try:
if cmdRow[0][0] != '#':
if not cmdRow[0].startswith('#'):
cmdPageIsValid.append(True)
cmdPageDesc.append(cmdRow[0])
cmdPageDefFile.append(cmdRow[1])
Expand All @@ -161,7 +151,7 @@ def ProcessQuickButton(self, idx):
#
# Mark the remaining values as invalid
#
for j in range(i, 22):
for _ in range(i, 22):
cmdPageAppid.append(0)
cmdPageIsValid.append(False)

Expand Down Expand Up @@ -190,24 +180,30 @@ def ProcessQuickButton(self, idx):
#
# fill the data fields on the page
#
for k in range(22):
subsysBrowser = getattr(Command, f'SubsysBrowser_{k}')
for k, desc in enumerate(cmdPageDesc):
if cmdPageIsValid[k]:
lineEditPktId = getattr(Command, f'lineEditPktId_{k}')
lineEditAddress = getattr(Command, f'lineEdit_{k}')
quickButton = getattr(Command, f'quickButton_{k+1}')
subsysBrowser.setText(cmdPageDesc[k])
lineEditPktId.setText(hex(cmdPageAppid[k]))
lineEditAddress.setText(cmdPageAddress[k])
tbl.insertRow(k)
for col, text in enumerate(
(desc, hex(cmdPageAppid[k]), cmdPageAddress[k])):
tblItem = QTableWidgetItem(text)
tbl.setItem(k, col, tblItem)
tblBtn = QPushButton("Display Page")
tblBtn.clicked.connect(
lambda _, x=k: Command.ProcessButtonGeneric(x))
tbl.setCellWidget(k, 3, tblBtn)
quickIdx = -1
try:
quickIdx = subsys.index(cmdPageDesc[k])
quickButton.setText(quickCmd[quickIdx])
quickIdx = subsys.index(desc)
except ValueError:
pass
pass # Ignore quick button
else:
quickBtn = QPushButton(quickCmd[quickIdx])
quickBtn.clicked.connect(
lambda _, x=k: Command.ProcessQuickButton(x))
tbl.setCellWidget(k, 4, quickBtn)
quickIndices.append(quickIdx)
else:
subsysBrowser.setText("(unused)")
tbl.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
tbl.horizontalHeader().setStretchLastSection(True)

#
# Display the page
Expand Down
Loading

0 comments on commit c7f9072

Please sign in to comment.