Skip to content
Snippets Groups Projects
Commit 5657a565 authored by Martin Högstedt's avatar Martin Högstedt
Browse files

added comments and small changes

parent 1a649721
No related branches found
No related tags found
Loading
Pipeline #101040 passed
...@@ -69,7 +69,7 @@ class BreakpointWindow(QWidget): ...@@ -69,7 +69,7 @@ class BreakpointWindow(QWidget):
""" """
Removes all list items from the breakpoint list. Removes all list items from the breakpoint list.
""" """
for row in range(self.breakpoint_list.count()): for _ in range(self.breakpoint_list.count()):
self.breakpoint_list.takeItem(0) self.breakpoint_list.takeItem(0)
def toggleEnabledClicked(self) -> None: def toggleEnabledClicked(self) -> None:
......
...@@ -37,6 +37,11 @@ class CpuGraphicsScene(QGraphicsScene): ...@@ -37,6 +37,11 @@ class CpuGraphicsScene(QGraphicsScene):
self.placeModuleGraphicsItemDefault(graphics_item) self.placeModuleGraphicsItemDefault(graphics_item)
def placeModuleGraphicsItemDefault(self, graphics_item: ModuleGraphicsItem) -> None: def placeModuleGraphicsItemDefault(self, graphics_item: ModuleGraphicsItem) -> None:
"""
Places a module graphics items at a position where the x value
is equal to the y value. Used to place all graphics items in a
diagonal.
"""
placement = len(self.module_graphics_items)*self.MODULE_SPACEING placement = len(self.module_graphics_items)*self.MODULE_SPACEING
graphics_item.setPos(placement, placement) graphics_item.setPos(placement, placement)
self.addItem(graphics_item) self.addItem(graphics_item)
...@@ -46,6 +51,9 @@ class CpuGraphicsScene(QGraphicsScene): ...@@ -46,6 +51,9 @@ class CpuGraphicsScene(QGraphicsScene):
pos_x: int, pos_x: int,
pos_y: int pos_y: int
) -> None: ) -> None:
"""
Changes the postions of an existing modules graphics item.
"""
graphics_item.setPos(pos_x*self.MODULE_SPACEING, graphics_item.setPos(pos_x*self.MODULE_SPACEING,
pos_y*self.MODULE_SPACEING) pos_y*self.MODULE_SPACEING)
...@@ -101,6 +109,9 @@ class CpuGraphicsScene(QGraphicsScene): ...@@ -101,6 +109,9 @@ class CpuGraphicsScene(QGraphicsScene):
super().mousePressEvent(event) super().mousePressEvent(event)
def load_layout_from_file(self, file_path: str) -> None: def load_layout_from_file(self, file_path: str) -> None:
"""
Loads a layout for a processor from a saved filed.
"""
file = open(file_path) file = open(file_path)
graphics_item_name = None graphics_item_name = None
......
...@@ -370,6 +370,10 @@ class GUI(QMainWindow): ...@@ -370,6 +370,10 @@ class GUI(QMainWindow):
""" """
@pyqtSlot(str, str, str) @pyqtSlot(str, str, str)
def editModuleState(self, module_name, state, value) -> None: def editModuleState(self, module_name, state, value) -> None:
"""
Tries to change the value of module to value given by user
through the dialog opened by editModuleStateDialog.
"""
try: try:
parsed_value = ast.literal_eval(value) parsed_value = ast.literal_eval(value)
except SyntaxError as e: except SyntaxError as e:
...@@ -383,6 +387,10 @@ class GUI(QMainWindow): ...@@ -383,6 +387,10 @@ class GUI(QMainWindow):
@pyqtSlot(str, str, str) @pyqtSlot(str, str, str)
def editMemoryContent(self, module_name: str, adress: str, value: str) -> None: def editMemoryContent(self, module_name: str, adress: str, value: str) -> None:
"""
Tries to change the value at adress to value given by user
through the dialog opened by editModuleStateDialog.
"""
try: try:
parsed_adress = int(adress, 16) parsed_adress = int(adress, 16)
parsed_value = ast.literal_eval(value) parsed_value = ast.literal_eval(value)
...@@ -402,6 +410,10 @@ class GUI(QMainWindow): ...@@ -402,6 +410,10 @@ class GUI(QMainWindow):
@pyqtSlot(str, str, str) @pyqtSlot(str, str, str)
def addStateBreakpoint(self, module_name: str, state: str, value: str) -> None: def addStateBreakpoint(self, module_name: str, state: str, value: str) -> None:
"""
Tries to add a breakpoint to the module through the dialog
opened by stateBreakpointDialog.
"""
try: try:
parsed_value = ast.literal_eval(value) parsed_value = ast.literal_eval(value)
self.cpu.add_state_breakpoint(module_name, state, parsed_value) self.cpu.add_state_breakpoint(module_name, state, parsed_value)
...@@ -411,6 +423,10 @@ class GUI(QMainWindow): ...@@ -411,6 +423,10 @@ class GUI(QMainWindow):
@pyqtSlot(str, str) @pyqtSlot(str, str)
def addLambdaBreakpoint(self, lambda_name, kwargs_str) -> None: def addLambdaBreakpoint(self, lambda_name, kwargs_str) -> None:
"""
Tries to add a breakpoint to the module through the dialog
opened by lambdaBreakpointDialog.
"""
try: try:
lambda_kwargs = {} lambda_kwargs = {}
for kwarg in kwargs_str.split(' '): for kwarg in kwargs_str.split(' '):
...@@ -423,6 +439,10 @@ class GUI(QMainWindow): ...@@ -423,6 +439,10 @@ class GUI(QMainWindow):
@pyqtSlot(str, str, str) @pyqtSlot(str, str, str)
def addMemoryBreakpoint(self, module_name: str, adress: str, value: str) -> None: def addMemoryBreakpoint(self, module_name: str, adress: str, value: str) -> None:
"""
Tries to add a breakpoint to the module through the dialog
opened by memoryBreakpointDialog.
"""
try: try:
parsed_adress = int(adress, 16) parsed_adress = int(adress, 16)
parsed_value = ast.literal_eval(value) parsed_value = ast.literal_eval(value)
...@@ -600,8 +620,8 @@ class GUI(QMainWindow): ...@@ -600,8 +620,8 @@ class GUI(QMainWindow):
def saveLayoutToolBarButtonClick(self) -> None: def saveLayoutToolBarButtonClick(self) -> None:
""" """
Saves the layout of all the modules in a human readable Saves the layout of all the modules in a (somewhat)
(and editable) format. human readable format.
Erases the previous content of the file before saving Erases the previous content of the file before saving
the data. the data.
""" """
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment