Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge into master for v2.1.0 release #251

Open
wants to merge 63 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
e5f2c8b
should fix the 15 min issue
jwuxx May 2, 2022
d605417
should fix 15 min issue
jwuxx May 2, 2022
6b3da20
Merge branch 'feat-fixing-dataviewer' into '83-summer-fix-dataviewer-…
jwuxx May 2, 2022
65eab14
kinda fixed 15 min problem but after 15 mins slider is janky
jwuxx May 3, 2022
6b5c3a3
aight it's fixed
jwuxx May 3, 2022
c46452d
Merge branch 'feat-fixing-dataviewer' into '83-summer-fix-dataviewer-…
jwuxx May 3, 2022
93dac19
changed back to 15 min data storage
jwuxx May 3, 2022
c1a9ed2
Merge branch 'feat-fixing-dataviewer' into '83-summer-fix-dataviewer-…
jwuxx May 3, 2022
4591092
Merge branch '83-summer-fix-dataviewer-slider-to-stop-growing-after-1…
jlvargasme May 4, 2022
2406f1a
enabled flight computer parser
ejakovm May 6, 2022
fbe3cee
added checkbox for tank property (doesn't modify tank yet)
jwuxx May 10, 2022
c011839
checkbox updates tank properties and overrides system indicator light…
jwuxx May 10, 2022
5e943ca
Merge branch '82-summer-fix-yellow-flag-for-non-lox-or-non-fuel-tanks…
jlvargasme May 13, 2022
2cb722f
added gui components (no functionality yet)
jwuxx May 28, 2022
ae52ff6
Update limits.py
prakharg55 Jun 16, 2022
f186c3c
Revert "Update limits.py"
prakharg55 Jun 16, 2022
252d62a
Update limits.py
prakharg55 Jun 16, 2022
83ee323
Revert "Update limits.py"
prakharg55 Jun 16, 2022
c70dcac
added functionality to range selection in limits
prakharg55 Jun 16, 2022
8373d46
Changed packet size to receive data, need to regenerate FC telem files
ejakovm Jun 27, 2022
cc71a90
Regenerated flight computer parser
ejakovm Jun 30, 2022
26cc32d
add signal noise ratio to telem
ejakovm Jul 1, 2022
de76d78
fixed range selection functionality in limits window
prakharg55 Jul 7, 2022
db5d329
disabling low/high textboxes when setting is changed to min/max in li…
prakharg55 Jul 11, 2022
b30f5ea
Increased gps accuracy
ejakovm Jul 12, 2022
e86cc2f
replaced max/min with +/-infinity in limits
prakharg55 Jul 23, 2022
c2c7afc
Merge branch '81-summer-expand-range-selection-in-limits-window' into…
jwuxx Jul 23, 2022
6a036e0
Almost the whole thing
jtalier Sep 2, 2022
7b3b4ae
fixed some things
Sep 3, 2022
f27e32f
autosequence not in updated server
jtalier Sep 5, 2022
92173ba
testing fixes
Sep 5, 2022
571552e
Updage style
jtalier Sep 9, 2022
d4f552a
Found few last bugs, rando updates and code improvments. Also added p…
jtalier Oct 6, 2022
4dbc42c
file name change
jtalier Oct 6, 2022
5dc0c78
Merge into dev
jtalier Oct 6, 2022
e9c46da
version update
jtalier Oct 6, 2022
c14fe7c
Fixed flight computer issues
ejakovm Nov 10, 2022
d712a93
Merge branch 'flightComputerIntegration' into flight-computer-integra…
ejakovm Nov 10, 2022
eece65e
made buttons work with flight computer
ejakovm Nov 10, 2022
c290678
Initial attempt
ejakovm Dec 22, 2022
beccd72
Functional keybinds
ejakovm Dec 24, 2022
b93d1e7
added keybind to saved configuration
ejakovm Dec 29, 2022
a438153
checkpoint while updating python version
Jan 14, 2023
9f159ec
GUI build theoretically works on 311
Jan 15, 2023
97c1911
bumped python version to 311 and fixed bugs
Jan 15, 2023
3180d75
merged solenoid-keybinds
Jan 15, 2023
0d49d06
fixed missing tank override initializer
Jan 15, 2023
169ce47
Lock file, switching branches
Jan 16, 2023
dc3ad24
fixed edit and configuration loading issues on 3.11
Jan 20, 2023
9c3d292
added synnax log to writer
Feb 2, 2023
4da7fbf
Initial implementation of synnax log
Feb 2, 2023
cb075da
removed development synnax dep
Feb 2, 2023
d817565
debugging
Feb 3, 2023
bf1adc8
formatting with black'
Feb 4, 2023
21e9c15
fixed auto manager. various changes for synnax driver
Feb 5, 2023
1bd5995
Fixed pt overflow
ejakovm Feb 12, 2023
08efc67
merged solenoid-keybinds
Feb 12, 2023
c254ba5
merged floating point precision change
Feb 12, 2023
27c9824
Motor and tank modifications
Feb 15, 2023
b60b0ac
fixed floating point conversion issue
Feb 15, 2023
6462142
fixed more floating point bugs
Feb 16, 2023
62a2502
fixed more floating point bugs
Feb 16, 2023
e9bf9d9
fixed synnax issue when running in campaign mode
Mar 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 65 additions & 36 deletions Python/ClientWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self, client, gui):
if client is not None:
self.client = client
else:
self.client = ClientWidget(commandable=False, gui=gui) # this needs a gui
self.client = ClientWidget(commandable=False, gui=gui) # this needs a gui
self.setWindowTitle("Connection")
self.layout = QtWidgets.QVBoxLayout()
self.layout.addWidget(self.client)
Expand All @@ -33,11 +33,11 @@ class ClientWidget(QtWidgets.QWidget):
gotConnectionToServerSignal = pyqtSignal()
serverDisconnectSignal = pyqtSignal()

def __init__(self, commandable: bool=True, gui = None, *args, **kwargs):
def __init__(self, commandable: bool = True, gui=None, *args, **kwargs):

super().__init__(*args, **kwargs)
self.clientid = uuid.uuid4().hex
#self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.command_queue = queue.Queue()
self.is_commander = False
self.is_connected = False
Expand All @@ -53,20 +53,25 @@ def __init__(self, commandable: bool=True, gui = None, *args, **kwargs):
self.connection_layout = QtWidgets.QGridLayout()
self.connection_widget.setLayout(self.connection_layout)
self.host = QtWidgets.QComboBox()
self.host.addItems([socket.gethostbyname(
socket.gethostname()), '192.168.50.79', 'masadataserver'])
self.host.addItems(
[
socket.gethostbyname(socket.gethostname()),
"192.168.50.79",
"masadataserver",
]
)
self.host.setEditable(True)
self.connection_layout.addWidget(self.host, 0, 0)
self.port = QtWidgets.QLineEdit()
self.connection_layout.addWidget(self.port, 0, 2)
self.connection_layout.addWidget(QtGui.QLabel(":"), 0, 1)
self.connect_button = QtGui.QPushButton("Connect")
self.connection_layout.addWidget(QtWidgets.QLabel(":"), 0, 1)
self.connect_button = QtWidgets.QPushButton("Connect")
self.connection_layout.addWidget(self.connect_button, 0, 3)
self.connect_button.clicked.connect(lambda: self.connect())
self.disconnect_button = QtGui.QPushButton("Disconnect")
self.disconnect_button = QtWidgets.QPushButton("Disconnect")
self.connection_layout.addWidget(self.disconnect_button, 0, 4)
self.disconnect_button.clicked.connect(lambda: self.disconnect())
self.clientid_label = QtGui.QLabel("UUID: %s" % self.clientid)
self.clientid_label = QtWidgets.QLabel("UUID: %s" % self.clientid)
self.connection_layout.setColumnStretch(0, 4)
self.connection_layout.setColumnStretch(1, 0)
self.connection_layout.setColumnStretch(2, 2)
Expand All @@ -78,7 +83,7 @@ def __init__(self, commandable: bool=True, gui = None, *args, **kwargs):
self.command_layout = QtWidgets.QGridLayout()
self.command_widget.setLayout(self.command_layout)
self.command_layout.addWidget(self.clientid_label, 0, 0)
self.control_button = QtGui.QPushButton("Take/Give Control")
self.control_button = QtWidgets.QPushButton("Take/Give Control")
self.command_layout.addWidget(self.control_button, 0, 1)
self.control_button.clicked.connect(lambda: self.command_toggle())
self.led = LedIndicator(self)
Expand All @@ -99,23 +104,24 @@ def __init__(self, commandable: bool=True, gui = None, *args, **kwargs):
# self.host.setText(socket.gethostbyname(socket.gethostname()))
self.port.setText(str(6969))

def command(self, command: int, args: tuple=()):
def command(self, command: int, args: tuple = ()):
# build and add command to queue
command_dict = {
"clientid": self.clientid,
"command": command,
"args": args
}
command_dict = {"clientid": self.clientid, "command": command, "args": args}

msg = pickle.dumps(command_dict)
# print(msg)

if command != 0:
print(command_dict)
if command_dict["command"] == 3:
self._gui.setStatusBarMessage("Command sent to server: " + str(command_dict["args"]))
self._gui.setStatusBarMessage(
"Command sent to server: " + str(command_dict["args"])
)
else:
self._gui.setStatusBarMessage("Command sent to client: " + str(command_dict))
# TODO: What??
self._gui.setStatusBarMessage(
"Command sent to client: " + str(command_dict)
)

# add to queue
if self.is_connected:
Expand All @@ -127,19 +133,35 @@ def connect(self):
# setup socket interface
self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.s.settimeout(1)
self.s.connect((self.host.currentText(), int(
self.port.text()))) # connect to socket
self.s.settimeout(None) # from https://stackoverflow.com/questions/3432102/python-socket-connection-timeout to prevent blocking
self.s.connect(
(self.host.currentText(), int(self.port.text()))
) # connect to socket
self.s.settimeout(
None
) # from https://stackoverflow.com/questions/3432102/python-socket-connection-timeout to prevent blocking
self.is_connected = True # update status
self.command(11)
self.gotConnectionToServerSignal.emit()
print("Connected to server on " + self.host.currentText() + ":" + self.port.text())
self._gui.setStatusBarMessage("Connected to server on " + self.host.currentText() + ":" + self.port.text())
print(
"Connected to server on "
+ self.host.currentText()
+ ":"
+ self.port.text()
)
self._gui.setStatusBarMessage(
"Connected to server on "
+ self.host.currentText()
+ ":"
+ self.port.text()
)

except Exception as e:
print(traceback.format_exc())
self._gui.setStatusBarMessage("Error connecting to server, see terminal", True)
self._gui.setStatusBarMessage(
"Error connecting to server, see terminal", True
)
self.soft_disconnect()
#print(self.is_connected)
# print(self.is_connected)

def disconnect(self):
"""
Expand All @@ -149,20 +171,23 @@ def disconnect(self):
some client side actions for cleanup
:return: None
"""

self.command(4)
self.cycle() # need to get the last command out before saying we are disconnected
self.soft_disconnect()
self._gui.setStatusBarMessage("Disconnected from server")
# Make sure we are actually connected before we try to disconnect
if self.is_connected:
self.command(4)
self.cycle() # need to get the last command out before saying we are disconnected
self.soft_disconnect()

def soft_disconnect(self):
"""
Performs all the required steps when client and server are disconnected, however it does not send any commands
to the server that indicate the client is attempting to disconnect. See above disconnect for more
:return:
"""
self.s.close()
self.is_connected = False
self.serverDisconnectSignal.emit() # See gui class for what needs to be done
self._gui.setStatusBarMessage("Disconnected from server")
print("Disconnected from server")

def command_toggle(self):
# toggle to take/give up command
Expand Down Expand Up @@ -196,7 +221,7 @@ def cycle(self):
self.s.sendall(data)

# get data
data = self.s.recv(4096*4)
data = self.s.recv(4096 * 4)
packet = pickle.loads(data)
else:
packet = None
Expand All @@ -206,17 +231,21 @@ def cycle(self):
self.is_commander = False
elif packet["commander"] is None:
self.is_commander = False
elif packet["commander"] == hashlib.sha256(self.clientid.encode('utf-8')).hexdigest():
elif (
packet["commander"]
== hashlib.sha256(self.clientid.encode("utf-8")).hexdigest()
):
self.is_commander = True
else:
self.is_commander = False
self.led.setChecked(self.is_commander)

self.last_packet = packet
return self.last_packet

except Exception as e:
if not isinstance(e, EOFError):
traceback.print_exc()
except (EOFError, ConnectionResetError):
self.soft_disconnect()
return None
except Exception:
self.soft_disconnect()
traceback.print_exc()
return None
14 changes: 7 additions & 7 deletions Python/ColorButton.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

# color picker button based on: https://www.mfitzp.com/article/qcolorbutton-a-color-selector-tool-for-pyqt/
class ColorButton(QtWidgets.QPushButton):
'''
"""
Custom Qt Widget to show a chosen color.

Left-clicking the button shows the color-chooser, while
right-clicking resets the color to None (no-color).
'''
right-clicking resets the color to None (no-color).
"""

colorChanged = QtCore.pyqtSignal()

Expand All @@ -34,15 +34,15 @@ def color(self):
return self._color

def onColorPicker(self):
'''
"""
Show color-picker dialog to select color.

Qt will use the native dialog by default.

'''
"""
self.setStyleSheet("")
dlg = QtWidgets.QColorDialog(self)

if self._color:
dlg.setCurrentColor(QtGui.QColor(self._color))

Expand All @@ -53,4 +53,4 @@ def mousePressEvent(self, e):
if e.button() == Qt.RightButton:
self.setColor("#FF0000")

return super(ColorButton, self).mousePressEvent(e)
return super(ColorButton, self).mousePressEvent(e)
1 change: 1 addition & 0 deletions Python/Configurations/Configurations/limits.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"num_channels": 2, "limit_configs": [{"channel": "gse.e_batt", "low": "10", "high": "100"}, {"channel": "ec.e_batt", "low": "10", "high": "100"}]}
23 changes: 15 additions & 8 deletions Python/GUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@


class GUI(BaseGui): # Inherits QObject just so signals can be used

def __init__(self, qapp: QApplication):
super().__init__(qapp) # This calls above BaseGui __init__

# This variable holds the current Run class that is being used to conduct the test
self.campaign = Campaign(self)
#self.configuration = ConfigurationManager(self)
# self.configuration = ConfigurationManager(self)

# If in debug mode the gui overrides the command sending and instead shows what would happen if successful
self.debug_mode = False
Expand Down Expand Up @@ -58,7 +57,9 @@ def gotConnectionToServer(self):
else:
self.liveDataHandler.sendCommand(6, [str(self.campaign.saveName)])
if self.campaign.isTestActive:
self.liveDataHandler.sendCommand(10, [self.campaign.saveName, self.campaign.currentTestName, True])
self.liveDataHandler.sendCommand(
10, [self.campaign.saveName, self.campaign.currentTestName, True]
)

self.controlsWindow.centralWidget.controlsSidebarWidget.tabWidget.noteWidget.enableNoteCreation()

Expand All @@ -70,27 +71,33 @@ def serverDisconnect(self):
"""
super().serverDisconnect()
self.controlsWindow.startRunAct.setDisabled(True)
self.controlsWindow.centralWidget.controlsSidebarWidget.tabWidget.noteWidget.disableNoteCreation(True)
self.controlsWindow.centralWidget.controlsSidebarWidget.tabWidget.noteWidget.disableNoteCreation(
True
)


if __name__ == '__main__':
if __name__ == "__main__":

currentExitCode = GUI.EXIT_CODE_REBOOT
while currentExitCode == GUI.EXIT_CODE_REBOOT:

QApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True)
QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps, True)
os.environ["QT_ENABLE_HIGHDPI_SCALING"] = "1"
QApplication.setHighDpiScaleFactorRoundingPolicy(Qt.HighDpiScaleFactorRoundingPolicy.PassThrough)
QApplication.setHighDpiScaleFactorRoundingPolicy(
Qt.HighDpiScaleFactorRoundingPolicy.PassThrough
)
app = QApplication(sys.argv)
app.setApplicationName("MASA GUI")
app.setApplicationDisplayName("MASA GUI")

gui = GUI(app)

QTimer.singleShot(100, gui.postInit) # Need to call this after exec_ for proper screen placement
QTimer.singleShot(
100, gui.postInit
) # Need to call this after exec_ for proper screen placement
currentExitCode = app.exec_()
gui.savePreferences()
app = None

#https://stackoverflow.com/questions/8356336/how-to-capture-output-of-pythons-interpreter-and-show-in-a-text-widget
# https://stackoverflow.com/questions/8356336/how-to-capture-output-of-pythons-interpreter-and-show-in-a-text-widget
4 changes: 2 additions & 2 deletions Python/MathHelper.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

"""
Helper class with various mth functions
"""
class MathHelper:


class MathHelper:
@staticmethod
def mapValue(value, leftMin, leftMax, rightMin, rightMax):
"""
Expand Down
44 changes: 44 additions & 0 deletions Python/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

# Getting Started

```commandline
python --version
```

If you don't have 3.11 installed, you're a satanist. Install 3.11.

```commandline
pip --version
```

If this isn't pip for 3.11, see above. Then,

```commandline
pip install poetry
```

Then, in the root level of the repo, run

```commandline
poetry install
```

Then, open two terminals and start virtual environments:

```commandline
poetry shell
```

Then, cd into the `Python` directory and run

```commandline
python server.py
```

To start the server in one shell, and run

```commandline
python gui.py
```

To start the GUI in another
Loading