class GroundSystem(QtGui.QMainWindow):

    #
    # Init the class
    #
    def __init__(self, parent=None):
        QtGui.QMainWindow.__init__(self)

        # Init lists
        self.ipAddressesList = ['All']
        self.spacecraftNames = ['All']

        # Init GUI and set callback methods for buttons
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.ui.pushButtonStartTlm.clicked.connect(self.startTlmSystem)
        self.ui.pushButtonStartCmd.clicked.connect(self.startCmdSystem)

    def closeEvent(self, evnt):
        if self.RoutingService:
            self.RoutingService.stop()
            print("Stopped routing service")

        super(GroundSystem, self).closeEvent(evnt)

    # Read the selected spacecraft from combo box on GUI
    def getSelectedSpacecraftAddress(self):
        return str(self.ui.comboBoxIpAddresses.currentText())

    # Returns the name of the selected spacecraft
    def getSelectedSpacecraftName(self):
        return self.spacecraftNames[self.ipAddressesList.index(
            self.getSelectedSpacecraftAddress())]

    #
    # Display popup with error
    #
    def DisplayErrorMessage(self, message):
        print(message)
        alert = QtGui.QMessageBox()
        alert.setText(message)
        alert.setIcon(QtGui.QMessageBox.Warning)
        alert.exec_()

    # Start the telemetry system for the selected spacecraft
    def startTlmSystem(self):
        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 = '--sub=GroundSystem.' + selectedSpacecraft + '.TelemetryPackets'

        # Open Telemetry System
        system_call = '( cd Subsystems/tlmGUI/ && python3 TelemetrySystem.py ' + subscription + ' ) & '
        os.system(system_call)

    # Start command system
    def startCmdSystem(self):
        os.system('( cd Subsystems/cmdGui/ && python3 CommandSystem.py ) & ')

    # Start FDL-FUL gui system
    #def startFDLSystem(self):
    #    selectedSpacecraft = self.getSelectedSpacecraftName()
    #    if selectedSpacecraft == 'All':
    #        subscription = ''
    #        self.DisplayErrorMessage('Cannot open FDL manager.\nNo spacecraft selected.')
    #    else:
    #       subscription = '--sub=GroundSystem.' + selectedSpacecraft
    #       os.system('( cd Subsystems/fdlGui/ && python FdlSystem.py ' + subscription + ' ) & ')

    # Update the combo box list in gui
    def updateIpList(self, ip, name):
        self.ipAddressesList.append(ip)
        self.spacecraftNames.append(name)
        self.ui.comboBoxIpAddresses.addItem(ip)

    # Start the routing service (see RoutingService.py)
    def initRoutingService(self):
        self.RoutingService = RoutingService(self)
        self.connect(self.RoutingService,
                     self.RoutingService.signalUpdateIpList, self.updateIpList)
        self.RoutingService.start()
 def initRoutingService(self):
     self.RoutingService = RoutingService(self)
     self.connect(self.RoutingService,
                  self.RoutingService.signalUpdateIpList, self.updateIpList)
     self.RoutingService.start()
Example #3
0
class GroundSystem(QMainWindow, Ui_MainWindow):
    HDR_VER_1_OFFSET = 0
    HDR_VER_2_OFFSET = 4

    #
    # Init the class
    #
    def __init__(self):
        super().__init__()
        self.setupUi(self)

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

        self.pushButtonStartTlm.clicked.connect(self.startTlmSystem)
        self.pushButtonStartCmd.clicked.connect(self.startCmdSystem)
        self.cbTlmHeaderVer.currentIndexChanged.connect(self.setTlmOffset)
        self.cbCmdHeaderVer.currentIndexChanged.connect(self.setCmdOffsets)
        for sb in (self.sbTlmOffset, self.sbCmdOffsetPri, self.sbCmdOffsetSec):
            sb.valueChanged.connect(self.saveOffsets)
        # Init lists
        self.ipAddressesList = ['All']
        self.spacecraftNames = ['All']

    def closeEvent(self, evnt):
        if self.RoutingService:
            self.RoutingService.stop()
            print("Stopped routing service")

        super().closeEvent(evnt)

    # Read the selected spacecraft from combo box on GUI
    def getSelectedSpacecraftAddress(self):
        return self.comboBoxIpAddresses.currentText().strip()

    # Returns the name of the selected spacecraft
    def getSelectedSpacecraftName(self):
        return self.spacecraftNames[self.ipAddressesList.index(
            self.getSelectedSpacecraftAddress())].strip()

    #
    # Display popup with error
    #
    def DisplayErrorMessage(self, message):
        print(message)
        self.alert.setText(message)
        self.alert.setIcon(QMessageBox.Warning)
        self.alert.exec_()

    # 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()
        if selectedSpacecraft != 'All':
            subscription += f'.{selectedSpacecraft}.TelemetryPackets'

        # Open Telemetry System
        system_call = f'python3 {ROOTDIR}/Subsystems/tlmGUI/TelemetrySystem.py {subscription}'
        args = shlex.split(system_call)
        subprocess.Popen(args)

    # Start command system
    @staticmethod
    def startCmdSystem():
        subprocess.Popen(
            ['python3', f'{ROOTDIR}/Subsystems/cmdGui/CommandSystem.py'])

    # Start FDL-FUL gui system
    def startFDLSystem(self):
        selectedSpacecraft = self.getSelectedSpacecraftName()
        if selectedSpacecraft == 'All':
            self.DisplayErrorMessage(
                'Cannot open FDL manager.\nNo spacecraft selected.')
        else:
            subscription = f'--sub=GroundSystem.{selectedSpacecraft}'
            subprocess.Popen([
                'python3', f'{ROOTDIR}/Subsystems/fdlGui/FdlSystem.py',
                subscription
            ])

    def setTlmOffset(self):
        selectedVer = self.cbTlmHeaderVer.currentText().strip()
        if selectedVer == "Custom":
            self.sbTlmOffset.setEnabled(True)
        else:
            self.sbTlmOffset.setEnabled(False)
            if selectedVer == "1":
                self.sbTlmOffset.setValue(self.HDR_VER_1_OFFSET)
            elif selectedVer == "2":
                self.sbTlmOffset.setValue(self.HDR_VER_2_OFFSET)

    def setCmdOffsets(self):
        selectedVer = self.cbCmdHeaderVer.currentText().strip()
        if selectedVer == "Custom":
            self.sbCmdOffsetPri.setEnabled(True)
            self.sbCmdOffsetSec.setEnabled(True)
        else:
            self.sbCmdOffsetPri.setEnabled(False)
            self.sbCmdOffsetSec.setEnabled(False)
            if selectedVer == "1":
                self.sbCmdOffsetPri.setValue(self.HDR_VER_1_OFFSET)
            elif selectedVer == "2":
                self.sbCmdOffsetPri.setValue(self.HDR_VER_2_OFFSET)
            self.sbCmdOffsetSec.setValue(self.HDR_VER_1_OFFSET)

    def saveOffsets(self):
        offsets = bytes((self.sbTlmOffset.value(), self.sbCmdOffsetPri.value(),
                         self.sbCmdOffsetSec.value()))
        with open("/tmp/OffsetData", "wb") as f:
            f.write(offsets)

    # Update the combo box list in gui
    def updateIpList(self, ip, name):
        self.ipAddressesList.append(ip)
        self.spacecraftNames.append(name)
        self.comboBoxIpAddresses.addItem(ip)

    # Start the routing service (see RoutingService.py)
    def initRoutingService(self):
        self.RoutingService = RoutingService()
        self.RoutingService.signalUpdateIpList.connect(self.updateIpList)
        self.RoutingService.start()
 def initRoutingService(self):
     self.RoutingService = RoutingService(self)
     self.connect(self.RoutingService, self.RoutingService.signalUpdateIpList, self.updateIpList)
     self.RoutingService.start()
class GroundSystem(QtGui.QMainWindow):

    #
    # Init the class
    #
    def __init__(self, parent=None):
        QtGui.QMainWindow.__init__(self)

        # Init lists
        self.ipAddressesList = ['All']
        self.spacecraftNames = ['All']

        # Init GUI and set callback methods for buttons
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.ui.pushButtonStartTlm.clicked.connect(self.startTlmSystem)
        self.ui.pushButtonStartCmd.clicked.connect(self.startCmdSystem)

    def closeEvent(self, evnt):
        if self.RoutingService:
            self.RoutingService.stop()
            print "Stopped routing service"

        super(GroundSystem, self).closeEvent(evnt)

    # Read the selected spacecraft from combo box on GUI
    def getSelectedSpacecraftAddress(self):
        return str(self.ui.comboBoxIpAddresses.currentText())

    # Returns the name of the selected spacecraft
    def getSelectedSpacecraftName(self):
        return self.spacecraftNames[self.ipAddressesList.index(self.getSelectedSpacecraftAddress())]

    #
    # Display popup with error
    #
    def DisplayErrorMessage(self, message):
        print message
        alert = QtGui.QMessageBox()
        alert.setText(message)
        alert.setIcon(QtGui.QMessageBox.Warning)
        alert.exec_()

    # Start the telemetry system for the selected spacecraft
    def startTlmSystem(self):
        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 = '--sub=GroundSystem.' + selectedSpacecraft + '.TelemetryPackets'

        # Open Telemetry System
        system_call = '( cd Subsystems/tlmGUI/ && python TelemetrySystem.py ' + subscription + ' ) & '
        os.system(system_call)

    # Start command system
    def startCmdSystem(self):
        os.system('( cd Subsystems/cmdGui/ && python CommandSystem.py ) & ')

    # Start FDL-FUL gui system
    #def startFDLSystem(self):
    #    selectedSpacecraft = self.getSelectedSpacecraftName()
    #    if selectedSpacecraft == 'All':
    #        subscription = ''
    #        self.DisplayErrorMessage('Cannot open FDL manager.\nNo spacecraft selected.')
    #    else:
    #       subscription = '--sub=GroundSystem.' + selectedSpacecraft
    #       os.system('( cd Subsystems/fdlGui/ && python FdlSystem.py ' + subscription + ' ) & ')

    # Update the combo box list in gui
    def updateIpList(self, ip, name):
        self.ipAddressesList.append(ip)
        self.spacecraftNames.append(name)
        self.ui.comboBoxIpAddresses.addItem(ip)

    # Start the routing service (see RoutingService.py)
    def initRoutingService(self):
        self.RoutingService = RoutingService(self)
        self.connect(self.RoutingService, self.RoutingService.signalUpdateIpList, self.updateIpList)
        self.RoutingService.start()
Example #6
0
class GroundSystem(QMainWindow, Ui_MainWindow):
    #
    # Init the class
    #
    def __init__(self):
        super().__init__()
        self.setupUi((self))

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

        self.pushButtonStartTlm.clicked.connect(self.startTlmSystem)
        self.pushButtonStartCmd.clicked.connect(self.startCmdSystem)
        # Init lists
        self.ipAddressesList = ['All']
        self.spacecraftNames = ['All']

    def closeEvent(self, evnt):
        if self.RoutingService:
            self.RoutingService.stop()
            print("Stopped routing service")

        super().closeEvent(evnt)

    # Read the selected spacecraft from combo box on GUI
    def getSelectedSpacecraftAddress(self):
        return self.comboBoxIpAddresses.currentText().strip()

    # Returns the name of the selected spacecraft
    def getSelectedSpacecraftName(self):
        return self.spacecraftNames[self.ipAddressesList.index(
            self.getSelectedSpacecraftAddress())].strip()

    #
    # Display popup with error
    #
    def DisplayErrorMessage(self, message):
        print(message)
        self.alert.setText(message)
        self.alert.setIcon(QMessageBox.Warning)
        self.alert.exec_()

    # Start the telemetry system for the selected spacecraft
    def startTlmSystem(self):
        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'

        # Open Telemetry System
        system_call = f'python3 {ROOTDIR}/Subsystems/tlmGUI/TelemetrySystem.py {subscription}'
        args = shlex.split(system_call)
        subprocess.Popen(args)

    # Start command system
    @staticmethod
    def startCmdSystem():
        subprocess.Popen(
            ['python3', f'{ROOTDIR}/Subsystems/cmdGui/CommandSystem.py'])

    # Start FDL-FUL gui system
    def startFDLSystem(self):
        selectedSpacecraft = self.getSelectedSpacecraftName()
        if selectedSpacecraft == 'All':
            subscription = ''
            self.DisplayErrorMessage(
                'Cannot open FDL manager.\nNo spacecraft selected.')
        else:
            subscription = f'--sub=GroundSystem.{selectedSpacecraft}'
            subprocess.Popen([
                'python3', f'{ROOTDIR}/Subsystems/fdlGui/FdlSystem.py',
                subscription
            ])

    # Update the combo box list in gui
    def updateIpList(self, ip, name):
        self.ipAddressesList.append(ip)
        self.spacecraftNames.append(name)
        self.comboBoxIpAddresses.addItem(ip)

    # Start the routing service (see RoutingService.py)
    def initRoutingService(self):
        self.RoutingService = RoutingService()
        self.RoutingService.signalUpdateIpList.connect(self.updateIpList)
        self.RoutingService.start()