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
201a5fd0
Commit
201a5fd0
authored
2 years ago
by
Olle Hansson
Browse files
Options
Downloads
Patches
Plain Diff
FromFileInput added
parent
0be589c8
No related branches found
No related tags found
No related merge requests found
Pipeline
#90316
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
+30
-1
30 additions, 1 deletion
b_asic/GUI/signal_generator_input.py
b_asic/GUI/simulate_sfg_window.py
+4
-46
4 additions, 46 deletions
b_asic/GUI/simulate_sfg_window.py
b_asic/signal_generator.py
+27
-0
27 additions, 0 deletions
b_asic/signal_generator.py
with
61 additions
and
47 deletions
b_asic/GUI/signal_generator_input.py
+
30
−
1
View file @
201a5fd0
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
from
qtpy.QtWidgets
import
QGridLayout
,
QLabel
,
QLineEdit
,
QSpinBox
from
qtpy.QtWidgets
import
(
QFileDialog
,
QGridLayout
,
QLabel
,
QLineEdit
,
QPushButton
,
QSpinBox
,
)
from
b_asic.signal_generator
import
(
from
b_asic.signal_generator
import
(
Constant
,
Constant
,
FromFile
,
Gaussian
,
Gaussian
,
Impulse
,
Impulse
,
SignalGenerator
,
SignalGenerator
,
...
@@ -94,6 +102,26 @@ class ZeroPadInput(SignalGeneratorInput):
...
@@ -94,6 +102,26 @@ class ZeroPadInput(SignalGeneratorInput):
return
ZeroPad
(
input_values
)
return
ZeroPad
(
input_values
)
class
FromFileInput
(
SignalGeneratorInput
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
().
__init__
(
*
args
,
**
kwargs
)
self
.
file_label
=
QLabel
(
"
Browse
"
)
self
.
addWidget
(
self
.
file_label
,
0
,
0
)
self
.
file_browser
=
QPushButton
(
"
No file selected
"
)
self
.
file_browser
.
clicked
.
connect
(
lambda
i
:
self
.
get_input_file
(
i
,
self
.
file_browser
)
)
self
.
addWidget
(
self
.
file_browser
,
0
,
1
)
def
get_generator
(
self
)
->
SignalGenerator
:
return
FromFile
(
self
.
file_browser
.
text
())
def
get_input_file
(
self
,
i
,
file_browser
):
module
,
accepted
=
QFileDialog
().
getOpenFileName
()
file_browser
.
setText
(
module
)
return
class
SinusoidInput
(
SignalGeneratorInput
):
class
SinusoidInput
(
SignalGeneratorInput
):
"""
"""
Class for graphically configuring and generating a
Class for graphically configuring and generating a
...
@@ -272,4 +300,5 @@ _GENERATOR_MAPPING = {
...
@@ -272,4 +300,5 @@ _GENERATOR_MAPPING = {
"
Step
"
:
StepInput
,
"
Step
"
:
StepInput
,
"
Uniform
"
:
UniformInput
,
"
Uniform
"
:
UniformInput
,
"
ZeroPad
"
:
ZeroPadInput
,
"
ZeroPad
"
:
ZeroPadInput
,
"
FromFile
"
:
FromFileInput
,
}
}
This diff is collapsed.
Click to expand it.
b_asic/GUI/simulate_sfg_window.py
+
4
−
46
View file @
201a5fd0
...
@@ -25,6 +25,7 @@ from qtpy.QtWidgets import (
...
@@ -25,6 +25,7 @@ from qtpy.QtWidgets import (
)
)
from
b_asic.GUI.signal_generator_input
import
_GENERATOR_MAPPING
from
b_asic.GUI.signal_generator_input
import
_GENERATOR_MAPPING
from
b_asic.signal_generator
import
FromFile
class
SimulateSFGWindow
(
QDialog
):
class
SimulateSFGWindow
(
QDialog
):
...
@@ -40,6 +41,7 @@ class SimulateSFGWindow(QDialog):
...
@@ -40,6 +41,7 @@ class SimulateSFGWindow(QDialog):
self
.
setWindowTitle
(
"
Simulate SFG
"
)
self
.
setWindowTitle
(
"
Simulate SFG
"
)
self
.
dialog_layout
=
QVBoxLayout
()
self
.
dialog_layout
=
QVBoxLayout
()
self
.
simulate_btn
=
QPushButton
(
"
Simulate
"
)
self
.
simulate_btn
=
QPushButton
(
"
Simulate
"
)
self
.
simulate_btn
.
clicked
.
connect
(
self
.
save_properties
)
self
.
simulate_btn
.
clicked
.
connect
(
self
.
save_properties
)
self
.
dialog_layout
.
addWidget
(
self
.
simulate_btn
)
self
.
dialog_layout
.
addWidget
(
self
.
simulate_btn
)
...
@@ -89,15 +91,13 @@ class SimulateSFGWindow(QDialog):
...
@@ -89,15 +91,13 @@ class SimulateSFGWindow(QDialog):
self
.
input_grid
.
addWidget
(
input_label
,
i
,
0
)
self
.
input_grid
.
addWidget
(
input_label
,
i
,
0
)
input_dropdown
=
QComboBox
()
input_dropdown
=
QComboBox
()
input_dropdown
.
insertItems
(
input_dropdown
.
insertItems
(
0
,
list
(
_GENERATOR_MAPPING
.
keys
()))
0
,
list
(
_GENERATOR_MAPPING
.
keys
())
+
[
"
File
"
]
)
input_dropdown
.
currentTextChanged
.
connect
(
input_dropdown
.
currentTextChanged
.
connect
(
lambda
text
,
i
=
i
:
self
.
change_input_format
(
i
,
text
)
lambda
text
,
i
=
i
:
self
.
change_input_format
(
i
,
text
)
)
)
self
.
input_grid
.
addWidget
(
input_dropdown
,
i
,
1
,
alignment
=
Qt
.
AlignLeft
)
self
.
input_grid
.
addWidget
(
input_dropdown
,
i
,
1
,
alignment
=
Qt
.
AlignLeft
)
self
.
change_input_format
(
i
,
"
Impulse
"
)
self
.
change_input_format
(
i
,
"
Constant
"
)
y
+=
1
y
+=
1
...
@@ -125,14 +125,6 @@ class SimulateSFGWindow(QDialog):
...
@@ -125,14 +125,6 @@ class SimulateSFGWindow(QDialog):
if
text
in
_GENERATOR_MAPPING
:
if
text
in
_GENERATOR_MAPPING
:
param_grid
=
_GENERATOR_MAPPING
[
text
](
self
.
_window
.
logger
)
param_grid
=
_GENERATOR_MAPPING
[
text
](
self
.
_window
.
logger
)
elif
text
==
"
File
"
:
file_label
=
QLabel
(
"
Browse
"
)
param_grid
.
addWidget
(
file_label
,
0
,
0
)
file_browser
=
QPushButton
(
"
No file selected
"
)
file_browser
.
clicked
.
connect
(
lambda
i
=
i
:
self
.
get_input_file
(
i
,
file_browser
)
)
param_grid
.
addWidget
(
file_browser
,
0
,
1
)
else
:
else
:
raise
Exception
(
"
Input selection is not implemented
"
)
raise
Exception
(
"
Input selection is not implemented
"
)
...
@@ -140,30 +132,6 @@ class SimulateSFGWindow(QDialog):
...
@@ -140,30 +132,6 @@ class SimulateSFGWindow(QDialog):
return
return
def
get_input_file
(
self
,
i
,
file_browser
):
module
,
accepted
=
QFileDialog
().
getOpenFileName
()
file_browser
.
setText
(
module
)
return
def
parse_input_values
(
self
,
input_values
):
_input_values
=
[]
for
_list
in
input_values
:
_list_values
=
[]
for
val
in
_list
:
val
=
val
.
strip
()
try
:
if
not
val
:
val
=
0
_list_values
.
append
(
complex
(
val
))
except
ValueError
:
self
.
_window
.
logger
.
warning
(
f
"
Skipping value:
{
val
}
, not a digit.
"
)
continue
_input_values
.
append
(
_list_values
)
return
_input_values
def
save_properties
(
self
):
def
save_properties
(
self
):
for
sfg
,
_properties
in
self
.
input_fields
.
items
():
for
sfg
,
_properties
in
self
.
input_fields
.
items
():
ic_value
=
self
.
input_fields
[
sfg
][
"
iteration_count
"
].
value
()
ic_value
=
self
.
input_fields
[
sfg
][
"
iteration_count
"
].
value
()
...
@@ -178,16 +146,6 @@ class SimulateSFGWindow(QDialog):
...
@@ -178,16 +146,6 @@ class SimulateSFGWindow(QDialog):
if
in_format
in
_GENERATOR_MAPPING
:
if
in_format
in
_GENERATOR_MAPPING
:
tmp2
=
in_param
.
get_generator
()
tmp2
=
in_param
.
get_generator
()
elif
in_format
==
"
File
"
:
widget
=
in_param
.
itemAtPosition
(
0
,
1
).
widget
()
path
=
widget
.
text
()
try
:
tmp2
=
self
.
parse_input_values
(
np
.
loadtxt
(
path
,
dtype
=
str
).
tolist
()
)
except
FileNotFoundError
:
self
.
_window
.
logger
.
error
(
f
"
Selected input file not found.
"
)
continue
else
:
else
:
raise
Exception
(
"
Input selection is not implemented
"
)
raise
Exception
(
"
Input selection is not implemented
"
)
...
...
This diff is collapsed.
Click to expand it.
b_asic/signal_generator.py
+
27
−
0
View file @
201a5fd0
...
@@ -161,6 +161,33 @@ class ZeroPad(SignalGenerator):
...
@@ -161,6 +161,33 @@ class ZeroPad(SignalGenerator):
return
f
"
ZeroPad(
{
self
.
_data
}
)
"
return
f
"
ZeroPad(
{
self
.
_data
}
)
"
class
FromFile
(
SignalGenerator
):
"""
Signal generator that reads from file and pads a sequence with zeros.
Parameters
----------
path : string
Path to input file.
"""
def
__init__
(
self
,
path
)
->
None
:
try
:
data
=
np
.
loadtxt
(
path
,
dtype
=
complex
).
tolist
()
self
.
_data
=
data
self
.
_len
=
len
(
data
)
except
FileNotFoundError
:
self
.
_window
.
logger
.
error
(
f
"
Selected input file not found.
"
)
def
__call__
(
self
,
time
:
int
)
->
complex
:
if
0
<=
time
<
self
.
_len
:
return
self
.
_data
[
time
]
return
0.0
def
__repr__
(
self
)
->
str
:
return
f
"
ZeroPad(
{
self
.
_data
}
)
"
class
Sinusoid
(
SignalGenerator
):
class
Sinusoid
(
SignalGenerator
):
"""
"""
Signal generator that generates a sinusoid.
Signal generator that generates a sinusoid.
...
...
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