Skip to content

Commit

Permalink
Merge pull request #109 from nasa/integration-candidate
Browse files Browse the repository at this point in the history
Integration Candidate: 2020-06-24
  • Loading branch information
astrogeco authored Jul 26, 2020
2 parents defa816 + c22f00e commit 2cdf182
Show file tree
Hide file tree
Showing 15 changed files with 671 additions and 197 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
*.pyc
cmdUtil
!/Subsystems/cmdUtil
CMakeFiles
CMakeCache.txt
.DS_Store
68 changes: 57 additions & 11 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,14 @@

from PyQt5.QtWidgets import QApplication, QMainWindow, QMessageBox

from MainWindow import Ui_MainWindow
from RoutingService import RoutingService
from Ui_MainWindow import Ui_MainWindow

from _version import __version__ as _version
from _version import _version_string

__version__ = _version


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

Expand All @@ -38,18 +44,25 @@
# CFS Ground System: Setup and manage the main window
#
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.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']
Expand Down Expand Up @@ -81,14 +94,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 +125,37 @@ def startFDLSystem(self):
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)
Expand All @@ -131,7 +173,10 @@ def initRoutingService(self):
# Main
#
if __name__ == "__main__":


# Report Version Number upon startup
print(_version_string)

# Init app
app = QApplication(sys.argv)

Expand All @@ -144,6 +189,7 @@ def initRoutingService(self):

# Start the Routing Service
MainWindow.initRoutingService()
MainWindow.saveOffsets()

# Execute the app
sys.exit(app.exec_())
164 changes: 135 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>552</width>
<height>305</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,137 @@
</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="minimumSize">
<size>
<width>169</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Tlm header version</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="sizeHint" stdset="0">
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="cbTlmHeaderVer">
<property name="minimumSize">
<size>
<width>40</width>
<height>20</height>
<width>132</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>132</width>
<height>16777215</height>
</size>
</property>
</spacer>
<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="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Cmd header version</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QSpinBox" name="sbTlmOffset">
<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 &lt;span style=&quot; font-weight:600;&quot;&gt;added to&lt;/span&gt; existing offsets listed in telemetry 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="2" column="2">
<widget class="QSpinBox" name="sbCmdOffsetPri">
<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 &lt;span style=&quot; font-weight:600;&quot;&gt;after&lt;/span&gt; the &lt;span style=&quot; font-weight:600;&quot;&gt;primary&lt;/span&gt; header in a command packet&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="cbCmdHeaderVer">
<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="2" column="3">
<widget class="QSpinBox" name="sbCmdOffsetSec">
<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 &lt;span style=&quot; font-weight:600;&quot;&gt;after&lt;/span&gt; the &lt;span style=&quot; font-weight:600;&quot;&gt;secondary&lt;/span&gt; header in a command packet&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>Offsets</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="label_6">
<property name="text">
<string>(Hover for info)</string>
</property>
</widget>
</item>
</layout>
</item>
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ See [Guide-GroundSystem.md](https://github.com/nasa/cFS-GroundSystem/blob/master

## Version History

### Development Build: 2.1.0+dev76

- Fixes more lgtm warnings
- Allows users to change the byte offsets for sending commands and parsing telemetry, to support different header versions or other implementations of cFS
- Adds a file to store version information and reports version upon ground-system startup.
- See <https://github.com/nasa/cFS-GroundSystem/pull/109>

### Development Build: 2.1.12

- Change all individual UI elements to table widgets. Update backend code accordingly
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
Loading

0 comments on commit 2cdf182

Please sign in to comment.