Skip to content
Snippets Groups Projects
Commit 7adb32c2 authored by Oscar Gustafsson's avatar Oscar Gustafsson :bicyclist:
Browse files

Show slack in scheduler GUI info and fix issues introduced yesterday

parent e006be9f
No related branches found
No related tags found
1 merge request!160Show slack in scheduler GUI info and fix issues introduced yesterday
Pipeline #88825 passed
...@@ -337,7 +337,10 @@ class Schedule: ...@@ -337,7 +337,10 @@ class Schedule:
(backward_slack, forward_slack) = self.slacks(graph_id) (backward_slack, forward_slack) = self.slacks(graph_id)
if not -backward_slack <= time <= forward_slack: 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 tmp_start = self._start_times[graph_id] + time
new_start = tmp_start % self._schedule_time new_start = tmp_start % self._schedule_time
...@@ -354,9 +357,16 @@ class Schedule: ...@@ -354,9 +357,16 @@ class Schedule:
prev_available = tmp_prev_available % self._schedule_time prev_available = tmp_prev_available % self._schedule_time
laps = new_slack // self._schedule_time laps = new_slack // self._schedule_time
if new_usage < prev_available: 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 laps += 1
print( print(
[ [
"Input",
time,
tmp_start,
signal_slack, signal_slack,
new_slack, new_slack,
old_laps, old_laps,
...@@ -381,8 +391,23 @@ class Schedule: ...@@ -381,8 +391,23 @@ class Schedule:
laps = new_slack // self._schedule_time laps = new_slack // self._schedule_time
if next_usage < new_available: if next_usage < new_available:
laps += 1 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 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 self._laps[signal.graph_id] = laps
# Set new start time # Set new start time
......
...@@ -482,6 +482,9 @@ class MainWindow(QMainWindow, Ui_MainWindow): ...@@ -482,6 +482,9 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self._graph._signals.component_selected.connect( self._graph._signals.component_selected.connect(
self.info_table_update_component self.info_table_update_component
) )
self._graph._signals.component_moved.connect(
self.info_table_update_component
)
self._graph._signals.schedule_time_changed.connect( self._graph._signals.schedule_time_changed.connect(
self.info_table_update_schedule self.info_table_update_schedule
) )
...@@ -590,6 +593,22 @@ class MainWindow(QMainWindow, Ui_MainWindow): ...@@ -590,6 +593,22 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.info_table.setItem(si, 1, QTableWidgetItem(str(value))) self.info_table.setItem(si, 1, QTableWidgetItem(str(value)))
si += 1 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: def info_table_clear(self) -> None:
"""Clears the info table.""" """Clears the info table."""
self.info_table_clear_component() self.info_table_clear_component()
......
...@@ -42,6 +42,7 @@ class SchedulerEvent: # PyQt5 ...@@ -42,6 +42,7 @@ class SchedulerEvent: # PyQt5
component_selected = Signal(str) component_selected = Signal(str)
schedule_time_changed = Signal() schedule_time_changed = Signal()
component_moved = Signal(str)
_axes: Optional[AxesItem] _axes: Optional[AxesItem]
_current_pos: QPointF _current_pos: QPointF
...@@ -152,8 +153,10 @@ class SchedulerEvent: # PyQt5 ...@@ -152,8 +153,10 @@ class SchedulerEvent: # PyQt5
f"from an '{type(item).__name__}' object." f"from an '{type(item).__name__}' object."
) )
handler(event) if handler is not None:
return True handler(event)
return True
return False
################################# #################################
# Event Handlers: OperationItem # # Event Handlers: OperationItem #
...@@ -256,7 +259,7 @@ class SchedulerEvent: # PyQt5 ...@@ -256,7 +259,7 @@ class SchedulerEvent: # PyQt5
"""Change the cursor to OpenHandCursor when releasing an object.""" """Change the cursor to OpenHandCursor when releasing an object."""
item: OperationItem = self.scene().mouseGrabberItem() item: OperationItem = self.scene().mouseGrabberItem()
self.set_item_inactive(item) self.set_item_inactive(item)
self.set_new_starttime(item) self.set_new_start_time(item)
pos_x = item.x() pos_x = item.x()
redraw = False redraw = False
if pos_x < 0: if pos_x < 0:
...@@ -268,6 +271,7 @@ class SchedulerEvent: # PyQt5 ...@@ -268,6 +271,7 @@ class SchedulerEvent: # PyQt5
if redraw: if redraw:
item.setX(pos_x) item.setX(pos_x)
self._redraw_lines(item) self._redraw_lines(item)
self._signals.component_moved.emit(item.graph_id)
def operation_mouseDoubleClickEvent( def operation_mouseDoubleClickEvent(
self, event: QGraphicsSceneMouseEvent self, event: QGraphicsSceneMouseEvent
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment