Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
artiq_experiments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nicolas Nunez Barreto
artiq_experiments
Commits
690792f0
Commit
690792f0
authored
Jun 08, 2021
by
Lucas Giardino
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
agrego applet realtime y su test correspondiente
parent
fc4cdd60
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
100 additions
and
0 deletions
+100
-0
realtime.py
artiq_master/repository/Examples/GUI/realtime.py
+55
-0
test_realtime_applet.py
artiq_master/repository/Examples/GUI/test_realtime_applet.py
+45
-0
No files found.
artiq_master/repository/Examples/GUI/realtime.py
0 → 100644
View file @
690792f0
#!/usr/bin/env python3
import
numpy
as
np
import
PyQt5
# make sure pyqtgraph imports Qt5
import
pyqtgraph
from
collections
import
deque
# CircularBuffer
from
artiq.applets.simple
import
TitleApplet
class
RTPlot
(
pyqtgraph
.
PlotWidget
):
def
__init__
(
self
,
args
):
pyqtgraph
.
PlotWidget
.
__init__
(
self
)
self
.
args
=
args
self
.
xs
=
None
self
.
ys
=
None
self
.
y2s
=
None
def
data_changed
(
self
,
data
,
mods
,
title
):
try
:
y
=
data
.
get
(
self
.
args
.
y
)[
1
]
except
KeyError
:
return
y2
=
data
.
get
(
self
.
args
.
y2
,
(
False
,
None
))[
1
]
if
self
.
xs
is
None
:
# Should be only first iteration
num
=
int
(
self
.
args
.
num
)
self
.
xs
=
np
.
arange
(
0.
,
num
)
# Fixed x-values
self
.
ys
=
deque
(
np
.
full
(
num
,
0.
),
num
)
# Y-vals are a CircBuff of len num
if
(
y2
is
not
None
):
# make extra one if y2 is passed
self
.
y2s
=
deque
(
np
.
full
(
num
,
0.0
),
num
)
return
self
.
ys
.
append
(
y
[
0
])
self
.
clear
()
self
.
plot
(
self
.
xs
,
self
.
ys
,
pen
=
None
,
symbol
=
"x"
)
if
y2
is
not
None
:
self
.
y2s
.
append
(
y2
[
0
])
self
.
plot
(
self
.
xs
,
self
.
y2s
,
pen
=
None
,
symbol
=
"+"
,
symbolPen
=
'r'
)
self
.
setTitle
(
title
)
def
main
():
applet
=
TitleApplet
(
RTPlot
)
applet
.
add_dataset
(
"num"
,
"Number of measures"
)
applet
.
add_dataset
(
"y"
,
"Y value"
)
applet
.
add_dataset
(
"y2"
,
"Second Y value"
,
required
=
False
)
applet
.
run
()
if
__name__
==
"__main__"
:
main
()
artiq_master/repository/Examples/GUI/test_realtime_applet.py
0 → 100644
View file @
690792f0
from
scipy.stats
import
poisson
from
artiq.experiment
import
*
import
time
import
numpy
as
np
class
MockPMT
():
def
__init__
(
self
):
pass
def
count_on
(
self
):
return
poisson
.
rvs
(
200
)
def
count_off
(
self
):
return
poisson
.
rvs
(
10
)
class
MedicionesReferencia
(
EnvExperiment
):
"""TEST DE REALTIME APPLET"""
def
build
(
self
):
self
.
setattr_device
(
"ccb"
)
# PAra armar el applet
self
.
setattr_argument
(
"tau"
,
NumberValue
(
1.
,
min
=
1e-3
,
max
=
1.
,
unit
=
"s"
,
scale
=
s
),
tooltip
=
"Tiempo de recolección de cuentas"
)
self
.
pmt
=
MockPMT
()
# Emulo el PMT prendido/apagado
def
create_applets
(
self
):
self
.
ccb
.
issue
(
"create_applet"
,
"cuentas_segundo"
,
"${artiq_applet}realtime "
"200 "
"count_on "
"--y2 count_off"
)
def
create_datasets
(
self
):
self
.
set_dataset
(
'count_on'
,
np
.
full
(
1
,
np
.
nan
),
broadcast
=
True
,
archive
=
False
)
self
.
set_dataset
(
'count_off'
,
np
.
full
(
1
,
np
.
nan
),
broadcast
=
True
,
archive
=
False
)
self
.
set_dataset
(
'xs'
,
np
.
full
(
1
,
0
),
broadcast
=
True
,
archive
=
False
)
def
run
(
self
):
self
.
create_datasets
()
self
.
create_applets
()
while
True
:
self
.
mutate_dataset
(
"count_on"
,
0
,
self
.
pmt
.
count_on
())
self
.
mutate_dataset
(
"count_off"
,
0
,
self
.
pmt
.
count_off
())
time
.
sleep
(
self
.
tau
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment