Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B-ASIC - Better ASIC Toolbox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Computer Engineering
B-ASIC - Better ASIC Toolbox
Commits
0ccb061b
Commit
0ccb061b
authored
2 years ago
by
Andreas Bolin
Browse files
Options
Downloads
Patches
Plain Diff
import Schedule object from python script
parent
f70876e6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!78
Add scheduler GUI
Pipeline
#72746
passed
2 years ago
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
b_asic/scheduler-gui/__init__.py
+3
-2
3 additions, 2 deletions
b_asic/scheduler-gui/__init__.py
b_asic/scheduler-gui/main_window.py
+83
-17
83 additions, 17 deletions
b_asic/scheduler-gui/main_window.py
b_asic/scheduler-gui/main_window.ui
+4
-4
4 additions, 4 deletions
b_asic/scheduler-gui/main_window.ui
with
90 additions
and
23 deletions
b_asic/scheduler-gui/__init__.py
+
3
−
2
View file @
0ccb061b
...
...
@@ -3,8 +3,9 @@
Graphical user interface for B-ASIC scheduler.
"""
from
.main_window
import
*
from
.scheduler
import
*
from
logger
import
*
from
main_window
import
*
from
scheduler
import
*
#__all__ = ['main_window', 'scheduler']
__version__
=
'
0.1
'
...
...
This diff is collapsed.
Click to expand it.
b_asic/scheduler-gui/main_window.py
+
83
−
17
View file @
0ccb061b
...
...
@@ -8,35 +8,49 @@ Start main-window with start_gui().
import
os
,
sys
import
os
import
sys
from
pathlib
import
Path
from
types
import
ModuleType
from
typing
import
Any
from
pprint
import
pprint
#from matplotlib.pyplot import bar
#from diagram import *
import
logger
from
importlib.machinery
import
SourceFileLoader
import
inspect
# Qt/qtpy
import
qtpy
from
qtpy
import
uic
,
QtCore
,
QtGui
,
QtWidgets
from
qtpy.QtCore
import
Qt
,
Slot
,
QSettings
from
qtpy.QtCore
import
Qt
,
Slot
,
QSettings
,
QStandardPaths
from
qtpy.QtGui
import
QCloseEvent
from
qtpy.QtWidgets
import
QApplication
,
QMainWindow
,
QMessageBox
,
QAbstractButton
from
qtpy.QtWidgets
import
(
QApplication
,
QMainWindow
,
QMessageBox
,
QFileDialog
,
QInputDialog
)
# QGraphics and QPainter imports
from
qtpy.QtWidgets
import
(
QGraphicsView
,
QGraphicsScene
,
QGraphicsWidget
,
QGraphicsLayout
,
QGraphicsLinearLayout
,
QGraphicsGridLayout
,
QGraphicsLayoutItem
,
QGraphicsAnchorLayout
,
QGraphicsItem
,
QGraphicsItemGroup
,
QGraphicsItemAnimation
)
QGraphicsItem
,
QGraphicsItemGroup
,
QGraphicsItemAnimation
)
from
qtpy.QtGui
import
(
QPaintEvent
,
QPainter
,
QPainterPath
,
QColor
,
QBrush
,
QPen
,
QFont
,
QPolygon
,
QLinearGradient
)
from
qtpy.QtCore
import
(
QRect
)
# B-ASIC
import
logger
#import b_asic.schedule
from
b_asic.schedule
import
Schedule
log
=
logger
.
getLogger
()
# Debug struff
if
__debug__
:
log
.
setLevel
(
'
DEBUG
'
)
if
__debug__
:
# Print some system version information
QT_API
=
os
.
environ
.
get
(
'
QT_API
'
)
...
...
@@ -89,27 +103,29 @@ class MainWindow(QMainWindow, Ui_MainWindow):
"""
Schedule of an SFG with scheduled Operations.
"""
_settings
:
QSettings
_schedules
:
dict
def
__init__
(
self
):
"""
Initialize Schedule-gui.
"""
super
(
MainWindow
,
self
).
__init__
()
self
.
_settings
=
QSettings
()
self
.
_schedules
=
{}
self
.
_init_ui
()
self
.
_init_graphics_view
()
def
_init_ui
(
self
)
->
None
:
"""
Initialize the ui
"""
self
.
_settings
=
QSettings
()
self
.
setupUi
(
self
)
# Connect signals to slots
self
.
pushbutton_add
.
clicked
.
connect
(
self
.
callback_pushButton
)
self
.
menu_load_
sfg
.
triggered
.
connect
(
self
.
open
)
self
.
menu_save_schedule
.
triggered
.
connect
(
self
.
save
)
self
.
menu_quit
.
triggered
.
connect
(
self
.
close
)
self
.
menu_node_info
.
triggered
.
connect
(
self
.
toggle_component_info
)
self
.
splitter_center
.
splitterMoved
.
connect
(
self
.
_splitter_center_moved
)
self
.
pushbutton_add
.
clicked
.
connect
(
self
.
callback_pushButton
)
self
.
menu_load_
from_file
.
triggered
.
connect
(
self
.
_load_schedule_from_pyfile
)
self
.
menu_save_schedule
.
triggered
.
connect
(
self
.
save
)
self
.
menu_quit
.
triggered
.
connect
(
self
.
close
)
self
.
menu_node_info
.
triggered
.
connect
(
self
.
toggle_component_info
)
self
.
splitter_center
.
splitterMoved
.
connect
(
self
.
_splitter_center_moved
)
# Setup event member functions
self
.
closeEvent
=
self
.
_close_event
...
...
@@ -141,10 +157,59 @@ class MainWindow(QMainWindow, Ui_MainWindow):
@Slot
()
def
callback_pushButton
(
self
)
->
None
:
#diagram = Diagram()
self
.
printButtonPressed
(
self
.
tr
(
'
callback_pushButton
'
))
pass
@Slot
()
def
open
(
self
)
->
None
:
def
_load_schedule_from_pyfile
(
self
)
->
None
:
abs_path_filename
=
QFileDialog
.
getOpenFileName
(
self
,
self
.
tr
(
"
Open python file
"
),
QStandardPaths
.
standardLocations
(
QStandardPaths
.
HomeLocation
)[
0
],
self
.
tr
(
"
Python Files (*.py *.py3)
"
))
abs_path_filename
=
abs_path_filename
[
0
]
if
not
abs_path_filename
:
# return if empty filename (QFileDialog was canceled)
return
log
.
debug
(
'
abs_path_filename = {}.
'
.
format
(
abs_path_filename
))
module_name
=
inspect
.
getmodulename
(
abs_path_filename
)
if
not
module_name
:
# return if empty module name
log
.
error
(
'
Could not load module from file
\'
{}
\'
.
'
.
format
(
abs_path_filename
))
return
try
:
module
=
SourceFileLoader
(
module_name
,
abs_path_filename
).
load_module
()
except
:
log
.
exception
(
'
Exception occurred. Could not load module from file
\'
{}
\'
.
'
.
format
(
abs_path_filename
))
return
schedule_obj_list
=
dict
(
inspect
.
getmembers
(
module
,
(
lambda
x
:
type
(
x
)
==
Schedule
)))
if
not
schedule_obj_list
:
# return if no Schedule objects in script
QMessageBox
.
warning
(
self
,
self
.
tr
(
'
File not found
'
),
self
.
tr
(
'
Could not find any Schedule object in file
\'
{}
\'
.
'
)
.
format
(
os
.
path
.
basename
(
abs_path_filename
)))
log
.
info
(
'
Could not find any Schedule object in file
\'
{}
\'
.
'
.
format
(
os
.
path
.
basename
(
abs_path_filename
)))
return
ret_tuple
=
QInputDialog
.
getItem
(
self
,
self
.
tr
(
'
Load object
'
),
self
.
tr
(
'
Found the following Schedule object(s) in file.)
\n\n
'
'
Select an object to proceed:
'
),
schedule_obj_list
.
keys
(),
0
,
False
)
if
not
ret_tuple
[
1
]:
# User canceled the operation
log
.
debug
(
'
Load schedule operation: user canceled
'
)
return
#TODO: Unique hash keys
#TODO: self.open(schedule_obj_list[ret_tuple[0])
self
.
_schedules
[
ret_tuple
[
0
]]
=
schedule_obj_list
[
ret_tuple
[
0
]]
pprint
(
self
.
_schedules
)
#@Slot()
def
open
(
self
,
schedule
:
Schedule
)
->
None
:
"""
This method loads an SFG and create a base schedule in gui.
"""
#TODO: all
self
.
printButtonPressed
(
'
load_sfg()
'
)
...
...
@@ -199,6 +264,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
ret
=
box
.
exec_
()
if
ret
==
QMessageBox
.
StandardButton
.
Yes
:
log
.
info
(
'
Exit: {}
'
.
format
(
os
.
path
.
basename
(
__file__
)))
event
.
accept
()
else
:
event
.
ignore
()
...
...
This diff is collapsed.
Click to expand it.
b_asic/scheduler-gui/main_window.ui
+
4
−
4
View file @
0ccb061b
...
...
@@ -86,7 +86,7 @@
<property
name=
"title"
>
<string>
&
File
</string>
</property>
<addaction
name=
"menu_load_
sfg
"
/>
<addaction
name=
"menu_load_
from_file
"
/>
<addaction
name=
"menu_save_schedule"
/>
<addaction
name=
"separator"
/>
<addaction
name=
"menu_quit"
/>
...
...
@@ -160,13 +160,13 @@
<attribute
name=
"toolBarBreak"
>
<bool>
false
</bool>
</attribute>
<addaction
name=
"menu_load_
sfg
"
/>
<addaction
name=
"menu_load_
from_file
"
/>
<addaction
name=
"menu_save_schedule"
/>
<addaction
name=
"menu_node_info"
/>
</widget>
<action
name=
"menu_load_
sfg
"
>
<action
name=
"menu_load_
from_file
"
>
<property
name=
"text"
>
<string>
&
Load
SFG
...
</string>
<string>
&
Load
schedule from file
...
</string>
</property>
<property
name=
"toolTip"
>
<string>
Load Signal Flow Graph
</string>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment