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
f619fd21
Commit
f619fd21
authored
2 years ago
by
Oscar Gustafsson
Browse files
Options
Downloads
Patches
Plain Diff
Refactor signal generation GUI
parent
fc3fa764
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#89884
passed
2 years ago
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
b_asic/GUI/signal_generator_input.py
+63
-0
63 additions, 0 deletions
b_asic/GUI/signal_generator_input.py
b_asic/GUI/simulate_sfg_window.py
+18
-48
18 additions, 48 deletions
b_asic/GUI/simulate_sfg_window.py
docs_sphinx/GUI.rst
+12
-0
12 additions, 0 deletions
docs_sphinx/GUI.rst
with
93 additions
and
48 deletions
b_asic/GUI/signal_generator_input.py
0 → 100644
+
63
−
0
View file @
f619fd21
# -*- coding: utf-8 -*-
from
qtpy.QtWidgets
import
(
QCheckBox
,
QComboBox
,
QDialog
,
QFileDialog
,
QFormLayout
,
QFrame
,
QGridLayout
,
QHBoxLayout
,
QLabel
,
QLineEdit
,
QPushButton
,
QShortcut
,
QSizePolicy
,
QSpinBox
,
QVBoxLayout
,
)
from
b_asic.signal_generator
import
Impulse
,
Step
class
SignalGeneratorInput
(
QGridLayout
):
"""
Abstract class for graphically configuring and generating signal generators.
"""
def
get_generator
(
self
):
raise
NotImplementedError
class
DelayInput
(
SignalGeneratorInput
):
"""
Abstract class for graphically configuring and generating signal generators that
have a single delay parameter.
"""
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
().
__init__
(
*
args
,
**
kwargs
)
self
.
delay_label
=
QLabel
(
"
Delay
"
)
self
.
addWidget
(
self
.
delay_label
,
0
,
0
)
self
.
delay_spin_box
=
QSpinBox
()
self
.
delay_spin_box
.
setRange
(
0
,
2147483647
)
self
.
addWidget
(
self
.
delay_spin_box
,
0
,
1
)
class
ImpulseInput
(
DelayInput
):
"""
Class for graphically configuring and generating a
:class:`~b_asic.signal_generators.Impulse` signal generator.
"""
def
get_generator
(
self
):
return
Impulse
(
self
.
delay_spin_box
.
value
())
class
StepInput
(
DelayInput
):
"""
Class for graphically configuring and generating a
:class:`~b_asic.signal_generators.Step` signal generator.
"""
def
get_generator
(
self
):
return
Step
(
self
.
delay_spin_box
.
value
())
This diff is collapsed.
Click to expand it.
b_asic/GUI/simulate_sfg_window.py
+
18
−
48
View file @
f619fd21
...
...
@@ -26,8 +26,11 @@ from qtpy.QtWidgets import (
QVBoxLayout
,
)
from
b_asic.GUI.signal_generator_input
import
ImpulseInput
,
StepInput
from
b_asic.signal_generator
import
Impulse
,
Step
,
ZeroPad
_GENERATOR_MAPPING
=
{
"
Impulse
"
:
ImpulseInput
,
"
Step
"
:
StepInput
}
class
SimulateSFGWindow
(
QDialog
):
simulate
=
Signal
()
...
...
@@ -58,12 +61,15 @@ class SimulateSFGWindow(QDialog):
spin_box
=
QSpinBox
()
spin_box
.
setRange
(
0
,
2147483647
)
spin_box
.
setValue
(
100
)
options_layout
.
addRow
(
"
Iteration count:
"
,
spin_box
)
check_box_plot
=
QCheckBox
()
check_box_plot
.
setCheckState
(
Qt
.
CheckState
.
Checked
)
options_layout
.
addRow
(
"
Plot results:
"
,
check_box_plot
)
check_box_all
=
QCheckBox
()
check_box_all
.
setCheckState
(
Qt
.
CheckState
.
Checked
)
options_layout
.
addRow
(
"
Get all results:
"
,
check_box_all
)
sfg_layout
.
addLayout
(
options_layout
)
...
...
@@ -124,18 +130,8 @@ class SimulateSFGWindow(QDialog):
param_grid
=
QGridLayout
()
if
text
==
"
Impulse
"
:
delay_label
=
QLabel
(
"
Delay
"
)
param_grid
.
addWidget
(
delay_label
,
0
,
0
)
delay_spin_box
=
QSpinBox
()
delay_spin_box
.
setRange
(
0
,
2147483647
)
param_grid
.
addWidget
(
delay_spin_box
,
0
,
1
)
elif
text
==
"
Step
"
:
delay_label
=
QLabel
(
"
Delay
"
)
param_grid
.
addWidget
(
delay_label
,
0
,
0
)
delay_spin_box
=
QSpinBox
()
delay_spin_box
.
setRange
(
0
,
2147483647
)
param_grid
.
addWidget
(
delay_spin_box
,
0
,
1
)
if
text
in
(
"
Impulse
"
,
"
Step
"
):
param_grid
=
_GENERATOR_MAPPING
[
text
]()
elif
text
==
"
Input
"
:
input_label
=
QLabel
(
"
Input
"
)
param_grid
.
addWidget
(
input_label
,
0
,
0
)
...
...
@@ -192,7 +188,7 @@ class SimulateSFGWindow(QDialog):
if
ic_value
==
0
:
self
.
_window
.
logger
.
error
(
"
Iteration count is set to zero.
"
)
tmp
=
[]
input_values
=
[]
for
i
in
range
(
self
.
input_grid
.
rowCount
()):
in_format
=
(
...
...
@@ -200,33 +196,22 @@ class SimulateSFGWindow(QDialog):
)
in_param
=
self
.
input_grid
.
itemAtPosition
(
i
,
2
)
tmp2
=
[]
if
in_format
==
"
Impulse
"
:
g
=
Impulse
(
in_param
.
itemAtPosition
(
0
,
1
).
widget
().
value
())
for
j
in
range
(
ic_value
):
tmp2
.
append
(
str
(
g
(
j
)))
elif
in_format
==
"
Step
"
:
g
=
Step
(
in_param
.
itemAtPosition
(
0
,
1
).
widget
().
value
())
for
j
in
range
(
ic_value
):
tmp2
.
append
(
str
(
g
(
j
)))
if
in_format
in
(
"
Impulse
"
,
"
Step
"
):
tmp2
=
in_param
.
get_generator
()
elif
in_format
==
"
Input
"
:
widget
=
in_param
.
itemAtPosition
(
0
,
1
).
widget
()
tmp3
=
widget
.
text
().
split
(
"
,
"
)
if
in_param
.
itemAtPosition
(
1
,
1
).
widget
().
isChecked
():
g
=
ZeroPad
(
tmp3
)
for
j
in
range
(
ic_value
):
tmp2
.
append
(
str
(
g
(
j
)))
tmp2
=
ZeroPad
(
tmp3
)
else
:
tmp2
=
tmp3
tmp2
=
self
.
parse_input_values
(
tmp3
)
elif
in_format
==
"
File
"
:
widget
=
in_param
.
itemAtPosition
(
0
,
1
).
widget
()
path
=
widget
.
text
()
try
:
tmp2
=
np
.
loadtxt
(
path
,
dtype
=
str
).
tolist
()
tmp2
=
self
.
parse_input_values
(
np
.
loadtxt
(
path
,
dtype
=
str
).
tolist
()
)
except
FileNotFoundError
:
self
.
_window
.
logger
.
error
(
f
"
Selected input file not found.
"
...
...
@@ -235,24 +220,9 @@ class SimulateSFGWindow(QDialog):
else
:
raise
Exception
(
"
Input selection is not implemented
"
)
tmp
.
append
(
tmp2
)
input_values
=
self
.
parse_input_values
(
tmp
)
max_len
=
max
(
len
(
list_
)
for
list_
in
input_values
)
min_len
=
min
(
len
(
list_
)
for
list_
in
input_values
)
input_values
.
append
(
tmp2
)
if
max_len
!=
min_len
:
self
.
_window
.
logger
.
error
(
"
Minimum length of input lists are not equal to maximum
"
f
"
length of input lists:
{
max_len
}
!=
{
min_len
}
.
"
)
elif
ic_value
>
min_len
:
self
.
_window
.
logger
.
error
(
"
Minimum length of input lists are less than the
"
f
"
iteration count:
{
ic_value
}
>
{
min_len
}
.
"
)
else
:
if
True
:
self
.
properties
[
sfg
]
=
{
"
iteration_count
"
:
ic_value
,
"
show_plot
"
:
self
.
input_fields
[
sfg
][
...
...
This diff is collapsed.
Click to expand it.
docs_sphinx/GUI.rst
+
12
−
0
View file @
f619fd21
...
...
@@ -76,6 +76,18 @@ GUI.show\_pc\_window module
:undoc-members:
:show-inheritance:
GUI.signal\_generator\_input module
-----------------------------------
.. inheritance-diagram:: b_asic.GUI.signal_generator_input
:parts: 1
:top-classes: b_asic.GUI.signal_generator_input.SignalGeneratorInput
.. automodule:: b_asic.GUI.signal_generator_input
:members:
:undoc-members:
:show-inheritance:
GUI.simulate\_sfg\_window module
--------------------------------
...
...
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