***
Wartungsfenster jeden ersten Mittwoch vormittag im Monat
***
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
leolab_devices
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Quantuminfo
Experiment Control
labscript-suite
leolab_devices
Commits
0e65f7d0
Commit
0e65f7d0
authored
2 years ago
by
Schabbauer, Johannes
Browse files
Options
Downloads
Patches
Plain Diff
Implement smart_programming in BLACS worker
parent
fbc62a91
No related branches found
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
user_devices/ADwinProII/blacs_workers.py
+36
-15
36 additions, 15 deletions
user_devices/ADwinProII/blacs_workers.py
with
36 additions
and
15 deletions
user_devices/ADwinProII/blacs_workers.py
+
36
−
15
View file @
0e65f7d0
...
...
@@ -27,6 +27,9 @@ class ADwinProIIWorker(Worker):
h5file
=
None
def
init
(
self
):
self
.
timing
=
None
self
.
smart_cache
=
{
"
AOUT
"
:
None
,
"
PIDs
"
:
None
,
"
AIN
"
:
None
}
self
.
smart_cache
.
update
({
DIO
:
None
for
DIO
in
self
.
DIO_ADwin_DataNo
})
global
ADwin
# The ADwin Python module must be either found in the path, or in the standard Windows location
try
:
...
...
@@ -69,8 +72,8 @@ class ADwinProIIWorker(Worker):
sleep
=
self
.
start_time
+
self
.
stop_time
-
time
.
time
()
if
sleep
>
0
:
time
.
sleep
(
sleep
)
while
self
.
adw
.
Get_Par
(
1
)
==
1
:
# Check if the 'busy' parameter in ADwin was set to 0
time
.
sleep
(
0.00001
)
#
while self.adw.Get_Par(1) == 1: # Check if the 'busy' parameter in ADwin was set to 0
#
time.sleep(0.00001)
return
self
.
adw
.
Get_Par
(
1
)
==
0
#time.sleep(timeout)
#return self.start_time + self.stop_time < time.time()
...
...
@@ -118,6 +121,13 @@ class ADwinProIIWorker(Worker):
def
transition_to_buffered
(
self
,
device_name
,
h5file
,
initial_values
,
fresh
):
print
(
"
Transition to buffered started.
"
,
end
=
""
)
if
self
.
timing
is
not
None
:
print
(
f
"
Time since last shot:
{
time
.
perf_counter
()
-
self
.
timing
}
s.
"
)
else
:
print
()
self
.
timing
=
time
.
perf_counter
()
self
.
logger
.
debug
(
"
ADwin called transition_to_buffered.
"
)
self
.
adw
.
Stop_Process
(
self
.
process_number_manual
)
self
.
h5file
=
h5file
...
...
@@ -128,23 +138,33 @@ class ADwinProIIWorker(Worker):
# Send stop time to ADwin
self
.
adw
.
Set_Par
(
2
,
int
(
self
.
stop_time
*
CLOCK_T12
/
self
.
PROCESSDELAY
))
# Send data to ADwin
if
fresh
:
# smart programming only seems to work out of the box with output
AOUT
=
group
[
"
ANALOG_OUT/VALUES
"
]
AOUT
=
group
[
"
ANALOG_OUT/VALUES
"
]
if
fresh
or
not
np
.
array_equal
(
AOUT
[:],
self
.
smart_cache
[
"
AOUT
"
]):
print
(
"
AOUT programmed.
"
)
self
.
smart_cache
[
"
AOUT
"
]
=
AOUT
[:]
self
.
adw
.
SetData_Long
(
AOUT
[
"
n_cycles
"
].
ctypes
,
1
,
1
,
AOUT
.
shape
[
0
])
self
.
adw
.
SetData_Long
(
AOUT
[
"
channel
"
].
ctypes
,
2
,
1
,
AOUT
.
shape
[
0
])
self
.
adw
.
SetData_Long
(
AOUT
[
"
value
"
].
ctypes
,
3
,
1
,
AOUT
.
shape
[
0
])
DOUT
=
group
[
"
DIGITAL_OUT
"
]
for
name
,
module
in
self
.
DIO_ADwin_DataNo
:
self
.
adw
.
SetData_Long
(
DOUT
[
name
][
"
n_cycles
"
].
ctypes
,
module
,
1
,
DOUT
[
name
].
shape
[
0
])
self
.
adw
.
SetData_Long
(
DOUT
[
name
][
"
bitfield
"
].
ctypes
,
module
+
1
,
1
,
DOUT
[
name
].
shape
[
0
])
for
name
,
module
in
self
.
DIO_ADwin_DataNo
:
DOUT
=
group
[
f
"
DIGITAL_OUT/
{
name
}
"
]
if
fresh
or
not
np
.
array_equal
(
DOUT
[:],
self
.
smart_cache
[
name
]):
print
(
f
"
{
name
}
programmed.
"
)
self
.
smart_cache
[
name
]
=
DOUT
[:]
self
.
adw
.
SetData_Long
(
DOUT
[
"
n_cycles
"
].
ctypes
,
module
,
1
,
DOUT
.
shape
[
0
])
self
.
adw
.
SetData_Long
(
DOUT
[
"
bitfield
"
].
ctypes
,
module
+
1
,
1
,
DOUT
.
shape
[
0
])
PIDs
=
group
[
"
ANALOG_OUT/PID_CHANNELS
"
]
self
.
adw
.
SetData_Long
(
PIDs
[
"
n_cycles
"
].
ctypes
,
4
,
1
,
PIDs
.
shape
[
0
])
self
.
adw
.
SetData_Long
(
PIDs
[
"
AOUT_channel
"
].
ctypes
,
5
,
1
,
PIDs
.
shape
[
0
])
self
.
adw
.
SetData_Long
(
PIDs
[
"
PID_channel
"
].
ctypes
,
6
,
1
,
PIDs
.
shape
[
0
])
if
fresh
or
not
np
.
array_equal
(
PIDs
[:],
self
.
smart_cache
[
"
PIDs
"
]):
print
(
"
PIDs programmed.
"
)
self
.
smart_cache
[
"
PIDs
"
]
=
PIDs
[:]
self
.
adw
.
SetData_Long
(
PIDs
[
"
n_cycles
"
].
ctypes
,
4
,
1
,
PIDs
.
shape
[
0
])
self
.
adw
.
SetData_Long
(
PIDs
[
"
AOUT_channel
"
].
ctypes
,
5
,
1
,
PIDs
.
shape
[
0
])
self
.
adw
.
SetData_Long
(
PIDs
[
"
PID_channel
"
].
ctypes
,
6
,
1
,
PIDs
.
shape
[
0
])
AIN
=
group
[
"
ANALOG_IN/TIMES
"
]
self
.
adw
.
SetData_Long
(
AIN
[
"
start_time
"
].
ctypes
,
7
,
1
,
AIN
.
shape
[
0
])
self
.
adw
.
SetData_Long
(
AIN
[
"
stop_time
"
].
ctypes
,
8
,
1
,
AIN
.
shape
[
0
])
if
fresh
or
not
np
.
array_equal
(
AIN
[:],
self
.
smart_cache
[
"
AIN
"
]):
print
(
"
AIN programmed.
"
)
self
.
smart_cache
[
"
AIN
"
]
=
AIN
[:]
self
.
adw
.
SetData_Long
(
AIN
[
"
start_time
"
].
ctypes
,
7
,
1
,
AIN
.
shape
[
0
])
self
.
adw
.
SetData_Long
(
AIN
[
"
stop_time
"
].
ctypes
,
8
,
1
,
AIN
.
shape
[
0
])
return
self
.
get_final_values
(
h5file
)
# return final values to show the right state after transition to manual
...
...
@@ -166,12 +186,13 @@ class ADwinProIIWorker(Worker):
raise
ADwin
.
ADwinError
(
f
"
TiCo process of module
{
name
}
was not running before at end main process.
"
)
# Stop buffered and start manual process in ADwin
self
.
adw
.
Stop_Process
(
self
.
process_number_buffered
)
self
.
adw
.
Start_Process
(
self
.
process_number_manual
)
#
self.adw.Start_Process(self.process_number_manual)
return
True
def
program_manual
(
self
,
values
):
print
(
"
ADwin Program Manual
"
)
if
self
.
adw
.
Process_Status
(
self
.
process_number_manual
)
!=
1
:
# 1 if process is running
self
.
adw
.
Start_Process
(
self
.
process_number_manual
)
# Convert dict of frontpanel values to format for ADwin
...
...
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