Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
redpitaya-MCPHA
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Günter Quast
redpitaya-MCPHA
Commits
45e4907f
Commit
45e4907f
authored
1 year ago
by
Guenter Quast
Browse files
Options
Downloads
Patches
Plain Diff
rpOsci.py: more factorization
parent
4fa03c2c
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
rpOsci.py
+39
-21
39 additions, 21 deletions
rpOsci.py
with
39 additions
and
21 deletions
rpOsci.py
+
39
−
21
View file @
45e4907f
...
...
@@ -85,6 +85,9 @@ class rpControl(QMainWindow, Ui_MCPHA):
def
__init__
(
self
):
super
(
rpControl
,
self
).
__init__
()
# !gq additions
# get command line arguments
self
.
parse_args
()
# set physical units (for axis labels)
self
.
get_physical_units
()
# !gq end
self
.
setupUi
(
self
)
...
...
@@ -96,13 +99,9 @@ class rpControl(QMainWindow, Ui_MCPHA):
self
.
timers
=
self
.
status
[:
4
].
view
(
np
.
uint64
)
# create tabs
self
.
log
=
LogDisplay
()
# self.hst1 = HstDisplay(self, self.log, 0)
# self.hst2 = HstDisplay(self, self.log, 1)
self
.
osc
=
OscDisplay
(
self
,
self
.
log
)
self
.
gen
=
GenDisplay
(
self
,
self
.
log
)
self
.
tabWidget
.
addTab
(
self
.
log
,
"
Messages
"
)
# self.tabWidget.addTab(self.hst1, "Spectrum histogram 1")
# self.tabWidget.addTab(self.hst2, "Spectrum histogram 2")
self
.
tabWidget
.
addTab
(
self
.
osc
,
"
Oscilloscope
"
)
self
.
tabWidget
.
addTab
(
self
.
gen
,
"
Pulse generator
"
)
# configure controls
...
...
@@ -133,18 +132,19 @@ class rpControl(QMainWindow, Ui_MCPHA):
self
.
readTimer
=
QTimer
(
self
)
# for readout
self
.
readTimer
.
timeout
.
connect
(
self
.
read_osci
)
# get command line arguments
# !gq additions
self
.
parse_args
()
# set argument options
# !gq additions
# transfer command-line arguments to gui
self
.
osc
.
levelValue
.
setValue
(
self
.
trigger_level
)
self
.
osc
.
autoButton
.
setChecked
(
self
.
trigger_mode
)
self
.
osc
.
ch2Button
.
setChecked
(
self
.
trigger_source
)
self
.
osc
.
fallingButton
.
setChecked
(
self
.
trigger_slope
)
# automatically connect
if
self
.
ip_address
is
not
None
:
self
.
addrValue
.
setText
(
self
.
ip_address
)
self
.
start
()
else
:
self
.
addrValue
.
setStyleSheet
(
"
color: darkorange
"
)
# !gq end
# !gq end
# !gq get command line arguments
...
...
@@ -156,12 +156,23 @@ class rpControl(QMainWindow, Ui_MCPHA):
help
=
'
trigger level in ADC counts
'
)
parser
.
add_argument
(
'
-i
'
,
'
--interval
'
,
type
=
int
,
default
=
100
,
help
=
'
interval for readout (in ms)
'
)
parser
.
add_argument
(
'
-s
'
,
'
--sample_size
'
,
type
=
int
,
default
=
100000
,
help
=
'
size of waveform sample
'
)
parser
.
add_argument
(
'
-p
'
,
'
--pretrigger_fraction
'
,
type
=
float
,
default
=
0.05
,
help
=
'
pretrigger fraction
'
)
args
=
parser
.
parse_args
()
self
.
trigger_level
=
args
.
trigger_level
# all relevant parameters are here
self
.
ip_address
=
args
.
connect_ip
self
.
sample_size
=
args
.
sample_size
self
.
pretrigger_fraction
=
args
.
pretrigger_fraction
self
.
readInterval
=
args
.
interval
#
self
.
trigger_level
=
args
.
trigger_level
# other parameters
self
.
trigger_mode
=
0
# normal, 1 = auto
self
.
trigger_source
=
0
# channel 1, 1 = channel 2
self
.
trigger_slope
=
0
# rising, 1 = falling
def
get_physical_units
(
self
):
"""
get physical units corresponding to ADC units and channel numbers
"""
...
...
@@ -235,7 +246,7 @@ class rpControl(QMainWindow, Ui_MCPHA):
# check status
self
.
read_status
()
if
not
self
.
read_data
(
self
.
status
):
print
(
"
failed to read status
"
)
self
.
log
.
print
(
"
failed to read status
"
)
return
if
self
.
osc_waiting
and
not
self
.
status
[
8
]
&
1
:
self
.
command
(
20
,
0
,
0
)
...
...
@@ -244,7 +255,7 @@ class rpControl(QMainWindow, Ui_MCPHA):
self
.
reset_osc
()
self
.
start_osc
()
else
:
print
(
"
failed to read oscilloscope data
"
)
self
.
log
.
print
(
"
failed to read oscilloscope data
"
)
return
def
reset_osc
(
self
):
...
...
@@ -327,8 +338,8 @@ class OscDisplay(QWidget, Ui_OscDisplay):
# initialize variables
self
.
rpControl
=
rpControl
self
.
log
=
log
self
.
pre
=
5000
self
.
tot
=
100000
self
.
tot
=
self
.
rpControl
.
sample_size
self
.
pre
=
self
.
rpControl
.
pretrigger_fraction
*
self
.
tot
self
.
buffer
=
np
.
zeros
(
self
.
tot
*
2
,
np
.
int16
)
# create figure
self
.
figure
=
Figure
()
...
...
@@ -423,18 +434,25 @@ class OscDisplay(QWidget, Ui_OscDisplay):
def
start
(
self
):
if
self
.
rpControl
.
idle
:
return
self
.
rpControl
.
set_trg_mode
(
self
.
autoButton
.
isChecked
())
self
.
rpControl
.
set_trg_source
(
self
.
ch2Button
.
isChecked
())
self
.
rpControl
.
set_trg_slope
(
self
.
fallingButton
.
isChecked
())
self
.
rpControl
.
set_trg_level
(
self
.
levelValue
.
value
())
# extract parameters from gui
self
.
trg_mode
=
int
(
self
.
autoButton
.
isChecked
())
self
.
trg_source
=
int
(
self
.
ch2Button
.
isChecked
())
self
.
trg_slope
=
int
(
self
.
fallingButton
.
isChecked
())
self
.
trg_level
=
self
.
levelValue
.
value
()
self
.
rpControl
.
set_trg_mode
(
self
.
trg_mode
)
self
.
rpControl
.
set_trg_source
(
self
.
trg_source
)
self
.
rpControl
.
set_trg_slope
(
self
.
trg_slope
)
self
.
rpControl
.
set_trg_level
(
self
.
trg_level
)
self
.
rpControl
.
set_osc_pre
(
self
.
pre
)
self
.
rpControl
.
set_osc_tot
(
self
.
tot
)
self
.
rpControl
.
reset_osc
()
self
.
rpControl
.
start_osc
()
self
.
log
.
print
(
"
oscilloscope started
"
)
# toggle startButton: turn to 'Stop'
self
.
startButton
.
setText
(
"
Stop
"
)
self
.
startButton
.
clicked
.
disconnect
()
self
.
startButton
.
clicked
.
connect
(
self
.
stop
)
self
.
log
.
print
(
"
oscilloscope started
"
)
def
stop
(
self
):
self
.
rpControl
.
stop_osc
()
...
...
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