diff --git a/b_asic/schedule.py b/b_asic/schedule.py index c74ac5f381115d2bfa12e9391c6d1c053f45d6a7..3cf35f4c0c7f049c743a468b08c8a7f2d26512a4 100644 --- a/b_asic/schedule.py +++ b/b_asic/schedule.py @@ -337,7 +337,10 @@ class Schedule: (backward_slack, forward_slack) = self.slacks(graph_id) if not -backward_slack <= time <= forward_slack: - raise ValueError + raise ValueError( + f"Operation {graph_id} got incorrect move: {time}. Must be" + f" between {-backward_slack} and {forward_slack}." + ) tmp_start = self._start_times[graph_id] + time new_start = tmp_start % self._schedule_time @@ -354,9 +357,16 @@ class Schedule: prev_available = tmp_prev_available % self._schedule_time laps = new_slack // self._schedule_time if new_usage < prev_available: + print("Incrementing input laps 1") + laps += 1 + if prev_available == 0 and new_usage == 0: + print("Incrementing input laps 2") laps += 1 print( [ + "Input", + time, + tmp_start, signal_slack, new_slack, old_laps, @@ -381,8 +391,23 @@ class Schedule: laps = new_slack // self._schedule_time if next_usage < new_available: laps += 1 - if new_available == 0 and new_slack > 0: + print("Incrementing output laps 1") + if new_available == 0 and (new_slack > 0 or next_usage == 0): + print("Incrementing output laps 2") laps += 1 + print( + [ + "Output", + signal_slack, + new_slack, + old_laps, + laps, + new_available, + next_usage, + tmp_available, + tmp_next_usage, + ] + ) self._laps[signal.graph_id] = laps # Set new start time diff --git a/b_asic/scheduler_gui/main_window.py b/b_asic/scheduler_gui/main_window.py index 80ff8ab7d9054fd68907e076d8cc643a9edde362..3e7457c934237b852388dc83ce4d97b84252d7b0 100644 --- a/b_asic/scheduler_gui/main_window.py +++ b/b_asic/scheduler_gui/main_window.py @@ -482,6 +482,9 @@ class MainWindow(QMainWindow, Ui_MainWindow): self._graph._signals.component_selected.connect( self.info_table_update_component ) + self._graph._signals.component_moved.connect( + self.info_table_update_component + ) self._graph._signals.schedule_time_changed.connect( self.info_table_update_schedule ) @@ -590,6 +593,22 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.info_table.setItem(si, 1, QTableWidgetItem(str(value))) si += 1 + self.info_table.insertRow(si) + self.info_table.setItem(si, 0, QTableWidgetItem("Forward slack")) + self.info_table.setItem( + si, 1, QTableWidgetItem(str(self.schedule.forward_slack(graph_id))) + ) + si += 1 + + self.info_table.insertRow(si) + self.info_table.setItem(si, 0, QTableWidgetItem("Backward slack")) + self.info_table.setItem( + si, + 1, + QTableWidgetItem(str(self.schedule.backward_slack(graph_id))), + ) + si += 1 + def info_table_clear(self) -> None: """Clears the info table.""" self.info_table_clear_component() diff --git a/b_asic/scheduler_gui/scheduler_event.py b/b_asic/scheduler_gui/scheduler_event.py index 5e2f1272251e871118822bc42175e30a2739d231..ea5131eead9ed5ba3a1c24586ec5019f0ff42bf2 100644 --- a/b_asic/scheduler_gui/scheduler_event.py +++ b/b_asic/scheduler_gui/scheduler_event.py @@ -42,6 +42,7 @@ class SchedulerEvent: # PyQt5 component_selected = Signal(str) schedule_time_changed = Signal() + component_moved = Signal(str) _axes: Optional[AxesItem] _current_pos: QPointF @@ -152,8 +153,10 @@ class SchedulerEvent: # PyQt5 f"from an '{type(item).__name__}' object." ) - handler(event) - return True + if handler is not None: + handler(event) + return True + return False ################################# # Event Handlers: OperationItem # @@ -256,7 +259,7 @@ class SchedulerEvent: # PyQt5 """Change the cursor to OpenHandCursor when releasing an object.""" item: OperationItem = self.scene().mouseGrabberItem() self.set_item_inactive(item) - self.set_new_starttime(item) + self.set_new_start_time(item) pos_x = item.x() redraw = False if pos_x < 0: @@ -268,6 +271,7 @@ class SchedulerEvent: # PyQt5 if redraw: item.setX(pos_x) self._redraw_lines(item) + self._signals.component_moved.emit(item.graph_id) def operation_mouseDoubleClickEvent( self, event: QGraphicsSceneMouseEvent