Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
iexcode
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
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
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
29id
iexcode
Commits
a4b55126
Commit
a4b55126
authored
2 years ago
by
rodolakis
Browse files
Options
Downloads
Patches
Plain Diff
debugging slits
parent
889fc896
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
build/lib/iexcode/instruments/slits.py
+66
-45
66 additions, 45 deletions
build/lib/iexcode/instruments/slits.py
iexcode/instruments/slits.py
+66
-45
66 additions, 45 deletions
iexcode/instruments/slits.py
with
132 additions
and
90 deletions
build/lib/iexcode/instruments/slits.py
+
66
−
45
View file @
a4b55126
...
...
@@ -5,7 +5,7 @@ from epics import caget, caput
import
iexcode.instruments.cfg
as
iex
from
iexcode.instruments.shutters
import
main_shutter_close
from
iexcode.instruments.utilities
import
print_warning_message
from
iexcode.instruments.encoders
import
encoders_reset_zero
from
iexcode.instruments.encoders
import
encoders_reset_zero
,
_encoder_dictionary
,
encoder_sync
slit_ioc
=
"
29idb:
"
...
...
@@ -13,22 +13,21 @@ slit_ioc="29idb:"
def
_slits_dictionary
():
"""
dictionary of slit pv names for two and four blade slit assemblies
slit_name = slit1A, slit2B,
slit
3D
key = slit_name
val -
slit
HV
"""
#'slit3C' : (None, "uses a flexure stage so is different"),
d
=
{
'
slit1A
'
:
(
'
Slit1H
'
,
'
Slit1V
'
),
'
slit2B
'
:
(
'
Slit2H
'
,
'
Slit2V
'
),
'
slit3C
'
:
(
'
Slit3C
'
)
'
slit3D
'
:
(
'
Slit4V
'
)
'
slit1A
'
:
(
'
29idb:Slit1H
'
,
'
29idb:Slit1V
'
),
'
slit2B
'
:
(
'
29idb:Slit2H
'
,
'
29idb:Slit2V
'
),
'
slit3C
'
:
(
'
29idb:Slit3C
'
,),
'
slit3D
'
:
(
'
29idd:Slit4V
'
,),
}
return
d
def
slit_name_list
():
d
=
_slits_dictionary
d
=
_slits_dictionary
()
for
key
in
d
.
keys
():
print
(
key
)
...
...
@@ -41,41 +40,55 @@ def _slits_wide_open_dictionary():
'
slit1A
'
:
(
4.5
,
4.5
),
'
slit2B
'
:
(
6
,
8
),
'
slit3C
'
:
(
300
),
'
slit3D
'
:
(
2000
)
'
slit3D
'
:
(
2000
),
}
return
d
def
slits_pvs
(
slit_name
_HV
):
def
slits_pvs
(
slit_name
):
"""
returns the rbv and drive for the size,center
(rbv_size,val_size),(rvb_center,val_center)
"""
d
=
_slits_dictionary
()
size
=
[]
#H,V
center
=
[]
#H,V
if
slit_name
in
d
.
keys
():
if
slit_name
==
'
Slit3C
'
:
size_rbv
=
'
29idb:Slit3CRBV
'
size_val
=
'
29idb:Slit3CFit.A
'
if
slit_name
==
'
slit3C
'
:
size_val
=
d
[
slit_name
][
0
]
+
'
Fit.A
'
size_rbv
=
d
[
slit_name
][
0
]
+
'
RBV
'
center_val
=
None
center_rbv
=
None
center_val
=
None
size
.
append
((
size_val
,
size_rbv
))
center
.
append
((
center_val
,
center_rbv
))
else
:
slit_pv
=
slit_ioc
+
slit_name_HV
size_rbv
=
slit_pv
+
'
t2.D
'
size_val
=
slit_pv
+
'
center.VAL
'
center_rbv
=
slit_pv
+
'
t2.C
'
center_val
=
slit_pv
+
'
center.VAL
'
return
(
size_rbv
,
size_val
),(
center_rbv
,
center_val
)
for
slit_HV
in
d
[
slit_name
]:
size_val
=
slit_HV
+
'
size.VAL
'
size_rbv
=
slit_HV
+
'
t2.C
'
center_val
=
slit_HV
+
'
center.VAL
'
center_rbv
=
slit_HV
+
'
t2.D
'
size
.
append
((
size_val
,
size_rbv
))
center
.
append
((
center_val
,
center_rbv
))
else
:
print_warning_message
(
'
slit_name =
'
+
slit_name
+
'
not a valid slit, choose:
'
)
slit_name_list
()
return
size
,
center
def
slits_synch
(
slit_name
):
"""
synch the motor position and the slit table for all the beamline slits
"""
d
=
_slits_dictionary
()
if
slit_name
in
_encoder_dictionary
().
keys
():
encoder_sync
(
slit_name
)
if
slit_name
in
d
.
keys
():
if
slit_name
!=
'
slit3C
'
:
slit_pv
=
slit_ioc
+
slit_name
+
'
sync.PROC
'
caput
(
slit_pv
,
1
)
for
slit_HV
in
d
[
slit_name
]:
slit_pv
=
slit_HV
+
'
sync.PROC
'
caput
(
slit_pv
,
1
)
else
:
print_warning_message
(
'
slit_name =
'
+
slit_name
+
'
not a valid slit, choose:
'
)
slit_name_list
()
def
slits_sync_all
():
"""
...
...
@@ -94,10 +107,9 @@ def slits_get_all(verbose=True):
returns a dictionary with the current slit status
"""
vals
=
{}
vals
[
'
slit1A_size
'
],
vals
[
'
slit1A_center
'
]
=
slit1A_get
(
verbose
=
verbose
)
vals
[
'
slit2B_size
'
],
vals
[
'
slit2B_center
'
]
=
slit2B_get
(
verbose
=
verbose
)
vals
[
'
slit3C_size
'
]
=
slit3C_get
(
verbose
=
verbose
)
vals
[
'
slit3D_size
'
],
vals
[
'
slit3D_center
'
]
=
slit3D_get
(
verbose
=
verbose
)
for
slit_name
in
[
'
slit1A
'
,
'
slit2B
'
,
'
slit3C
'
,
'
slit3D
'
]:
vals
[
slit_name
+
'
_size
'
],
vals
[
slit_name
+
'
_center
'
]
=
slits_get
(
slit_name
,
verbose
=
verbose
)
def
slits_set
(
slit_name
,
size
,
center
,
verbose
=
True
):
"""
...
...
@@ -110,20 +122,25 @@ def slits_set(slit_name,size,center,verbose=True):
Previously: SetSlit
"""
d
=
_slits_dictionary
()
#syncing
slits_synch
(
slit_name
)
if
inf
in
size
:
size
=
_slits_wide_open_dictionary
()[
slit_name
]
if
d
[
slit_name
]
!=
None
:
for
i
,
slit_HV
in
enumerate
(
d
[
slit_name
]):
#H and V
(
size_rbv
,
size_val
),(
center_rbv
,
center_val
)
=
slits_pvs
(
slit_HV
)
if
center_rbv
!=
None
:
caput
(
center_val
,
center
[
i
],
timeout
=
180
)
if
size_rbv
!=
None
:
size_pvs
,
center_pvs
=
slits_pvs
(
slit_name
)
for
i
in
range
(
0
,
len
(
size_pvs
)):
size_val
,
size_rbv
,
=
size_pvs
[
i
]
center_val
,
center_rbv
=
center_pvs
[
i
]
if
center_rbv
!=
None
:
caput
(
center_val
,
center
[
i
],
timeout
=
180
)
if
size_rbv
!=
None
:
caput
(
size_val
,
size
[
i
],
timeout
=
180
)
else
:
print_warning_message
(
"
Not a valid slit_name
"
)
if
verbose
:
slits_get
(
slit_name
,
verbose
=
True
)
return
size
,
center
...
...
@@ -139,18 +156,22 @@ def slits_get(slit_name,verbose=True):
#syncing
slits_synch
(
slit_name
)
for
slit_HV
in
d
[
slit_name
]:
#H and V
(
size_rbv
,
size_val
),(
center_rbv
,
center_val
)
=
slits_pvs
(
slit_HV
)
if
size_rbv
!=
None
:
size
.
append
(
caget
(
size_rbv
))
if
center_rbv
!=
None
:
size_pvs
,
center_pvs
=
slits_pvs
(
slit_name
)
for
i
in
range
(
0
,
len
(
size_pvs
)):
size_val
,
size_rbv
,
=
size_pvs
[
i
]
center_val
,
center_rbv
=
center_pvs
[
i
]
if
center_rbv
!=
None
:
center
.
append
(
caget
(
center_rbv
))
else
:
center
.
append
(
0
)
if
size_rbv
!=
None
:
size
.
append
(
caget
(
size_rbv
))
if
verbose
:
if
(
d
[
slit_name
])
>
1
:
print
(
slit_name
+
"
= (
"
+
str
(
round
(
size
[
0
],
3
))
+
"
x
"
+
str
(
round
(
size
[
1
],
3
))
+
"
) @ (
"
+
str
(
center
[
0
])
+
"
,
"
+
str
(
center
[
1
])
+
"
)
"
)
if
len
(
d
[
slit_name
])
>
1
:
print
(
slit_name
+
"
= (
"
+
str
(
round
(
size
[
0
],
3
))
+
"
x
"
+
str
(
round
(
size
[
1
],
3
))
+
"
) @ (
"
+
str
(
round
(
center
[
0
]
,
3
)
)
+
"
,
"
+
str
(
round
(
center
[
1
]
,
3
)
)
+
"
)
"
)
else
:
print
(
slit_name
+
"
= (
"
+
str
(
round
(
size
[
0
],
3
))
+
"
) @ (
"
+
str
(
center
[
0
])
+
"
)
"
)
...
...
@@ -279,7 +300,7 @@ def slit2B_set(H_size,V_size,verbose=True,**kwargs):
size
=
(
H_size
,
V_size
)
center
=
kwargs
[
'
center
'
]
slits_set
(
slit_name
,
size
,
center
,
verbose
=
verbose
)
slits_set
(
slit_name
,
size
,
center
,
verbose
=
verbose
)
def
slit2B_get
(
verbose
=
True
):
"""
...
...
This diff is collapsed.
Click to expand it.
iexcode/instruments/slits.py
+
66
−
45
View file @
a4b55126
...
...
@@ -5,7 +5,7 @@ from epics import caget, caput
import
iexcode.instruments.cfg
as
iex
from
iexcode.instruments.shutters
import
main_shutter_close
from
iexcode.instruments.utilities
import
print_warning_message
from
iexcode.instruments.encoders
import
encoders_reset_zero
from
iexcode.instruments.encoders
import
encoders_reset_zero
,
_encoder_dictionary
,
encoder_sync
slit_ioc
=
"
29idb:
"
...
...
@@ -13,22 +13,21 @@ slit_ioc="29idb:"
def
_slits_dictionary
():
"""
dictionary of slit pv names for two and four blade slit assemblies
slit_name = slit1A, slit2B,
slit
3D
key = slit_name
val -
slit
HV
"""
#'slit3C' : (None, "uses a flexure stage so is different"),
d
=
{
'
slit1A
'
:
(
'
Slit1H
'
,
'
Slit1V
'
),
'
slit2B
'
:
(
'
Slit2H
'
,
'
Slit2V
'
),
'
slit3C
'
:
(
'
Slit3C
'
)
'
slit3D
'
:
(
'
Slit4V
'
)
'
slit1A
'
:
(
'
29idb:Slit1H
'
,
'
29idb:Slit1V
'
),
'
slit2B
'
:
(
'
29idb:Slit2H
'
,
'
29idb:Slit2V
'
),
'
slit3C
'
:
(
'
29idb:Slit3C
'
,),
'
slit3D
'
:
(
'
29idd:Slit4V
'
,),
}
return
d
def
slit_name_list
():
d
=
_slits_dictionary
d
=
_slits_dictionary
()
for
key
in
d
.
keys
():
print
(
key
)
...
...
@@ -41,41 +40,55 @@ def _slits_wide_open_dictionary():
'
slit1A
'
:
(
4.5
,
4.5
),
'
slit2B
'
:
(
6
,
8
),
'
slit3C
'
:
(
300
),
'
slit3D
'
:
(
2000
)
'
slit3D
'
:
(
2000
),
}
return
d
def
slits_pvs
(
slit_name
_HV
):
def
slits_pvs
(
slit_name
):
"""
returns the rbv and drive for the size,center
(rbv_size,val_size),(rvb_center,val_center)
"""
d
=
_slits_dictionary
()
size
=
[]
#H,V
center
=
[]
#H,V
if
slit_name
in
d
.
keys
():
if
slit_name
==
'
Slit3C
'
:
size_rbv
=
'
29idb:Slit3CRBV
'
size_val
=
'
29idb:Slit3CFit.A
'
if
slit_name
==
'
slit3C
'
:
size_val
=
d
[
slit_name
][
0
]
+
'
Fit.A
'
size_rbv
=
d
[
slit_name
][
0
]
+
'
RBV
'
center_val
=
None
center_rbv
=
None
center_val
=
None
size
.
append
((
size_val
,
size_rbv
))
center
.
append
((
center_val
,
center_rbv
))
else
:
slit_pv
=
slit_ioc
+
slit_name_HV
size_rbv
=
slit_pv
+
'
t2.D
'
size_val
=
slit_pv
+
'
center.VAL
'
center_rbv
=
slit_pv
+
'
t2.C
'
center_val
=
slit_pv
+
'
center.VAL
'
return
(
size_rbv
,
size_val
),(
center_rbv
,
center_val
)
for
slit_HV
in
d
[
slit_name
]:
size_val
=
slit_HV
+
'
size.VAL
'
size_rbv
=
slit_HV
+
'
t2.C
'
center_val
=
slit_HV
+
'
center.VAL
'
center_rbv
=
slit_HV
+
'
t2.D
'
size
.
append
((
size_val
,
size_rbv
))
center
.
append
((
center_val
,
center_rbv
))
else
:
print_warning_message
(
'
slit_name =
'
+
slit_name
+
'
not a valid slit, choose:
'
)
slit_name_list
()
return
size
,
center
def
slits_synch
(
slit_name
):
"""
synch the motor position and the slit table for all the beamline slits
"""
d
=
_slits_dictionary
()
if
slit_name
in
_encoder_dictionary
().
keys
():
encoder_sync
(
slit_name
)
if
slit_name
in
d
.
keys
():
if
slit_name
!=
'
slit3C
'
:
slit_pv
=
slit_ioc
+
slit_name
+
'
sync.PROC
'
caput
(
slit_pv
,
1
)
for
slit_HV
in
d
[
slit_name
]:
slit_pv
=
slit_HV
+
'
sync.PROC
'
caput
(
slit_pv
,
1
)
else
:
print_warning_message
(
'
slit_name =
'
+
slit_name
+
'
not a valid slit, choose:
'
)
slit_name_list
()
def
slits_sync_all
():
"""
...
...
@@ -94,10 +107,9 @@ def slits_get_all(verbose=True):
returns a dictionary with the current slit status
"""
vals
=
{}
vals
[
'
slit1A_size
'
],
vals
[
'
slit1A_center
'
]
=
slit1A_get
(
verbose
=
verbose
)
vals
[
'
slit2B_size
'
],
vals
[
'
slit2B_center
'
]
=
slit2B_get
(
verbose
=
verbose
)
vals
[
'
slit3C_size
'
]
=
slit3C_get
(
verbose
=
verbose
)
vals
[
'
slit3D_size
'
],
vals
[
'
slit3D_center
'
]
=
slit3D_get
(
verbose
=
verbose
)
for
slit_name
in
[
'
slit1A
'
,
'
slit2B
'
,
'
slit3C
'
,
'
slit3D
'
]:
vals
[
slit_name
+
'
_size
'
],
vals
[
slit_name
+
'
_center
'
]
=
slits_get
(
slit_name
,
verbose
=
verbose
)
def
slits_set
(
slit_name
,
size
,
center
,
verbose
=
True
):
"""
...
...
@@ -110,20 +122,25 @@ def slits_set(slit_name,size,center,verbose=True):
Previously: SetSlit
"""
d
=
_slits_dictionary
()
#syncing
slits_synch
(
slit_name
)
if
inf
in
size
:
size
=
_slits_wide_open_dictionary
()[
slit_name
]
if
d
[
slit_name
]
!=
None
:
for
i
,
slit_HV
in
enumerate
(
d
[
slit_name
]):
#H and V
(
size_rbv
,
size_val
),(
center_rbv
,
center_val
)
=
slits_pvs
(
slit_HV
)
if
center_rbv
!=
None
:
caput
(
center_val
,
center
[
i
],
timeout
=
180
)
if
size_rbv
!=
None
:
size_pvs
,
center_pvs
=
slits_pvs
(
slit_name
)
for
i
in
range
(
0
,
len
(
size_pvs
)):
size_val
,
size_rbv
,
=
size_pvs
[
i
]
center_val
,
center_rbv
=
center_pvs
[
i
]
if
center_rbv
!=
None
:
caput
(
center_val
,
center
[
i
],
timeout
=
180
)
if
size_rbv
!=
None
:
caput
(
size_val
,
size
[
i
],
timeout
=
180
)
else
:
print_warning_message
(
"
Not a valid slit_name
"
)
if
verbose
:
slits_get
(
slit_name
,
verbose
=
True
)
return
size
,
center
...
...
@@ -139,18 +156,22 @@ def slits_get(slit_name,verbose=True):
#syncing
slits_synch
(
slit_name
)
for
slit_HV
in
d
[
slit_name
]:
#H and V
(
size_rbv
,
size_val
),(
center_rbv
,
center_val
)
=
slits_pvs
(
slit_HV
)
if
size_rbv
!=
None
:
size
.
append
(
caget
(
size_rbv
))
if
center_rbv
!=
None
:
size_pvs
,
center_pvs
=
slits_pvs
(
slit_name
)
for
i
in
range
(
0
,
len
(
size_pvs
)):
size_val
,
size_rbv
,
=
size_pvs
[
i
]
center_val
,
center_rbv
=
center_pvs
[
i
]
if
center_rbv
!=
None
:
center
.
append
(
caget
(
center_rbv
))
else
:
center
.
append
(
0
)
if
size_rbv
!=
None
:
size
.
append
(
caget
(
size_rbv
))
if
verbose
:
if
(
d
[
slit_name
])
>
1
:
print
(
slit_name
+
"
= (
"
+
str
(
round
(
size
[
0
],
3
))
+
"
x
"
+
str
(
round
(
size
[
1
],
3
))
+
"
) @ (
"
+
str
(
center
[
0
])
+
"
,
"
+
str
(
center
[
1
])
+
"
)
"
)
if
len
(
d
[
slit_name
])
>
1
:
print
(
slit_name
+
"
= (
"
+
str
(
round
(
size
[
0
],
3
))
+
"
x
"
+
str
(
round
(
size
[
1
],
3
))
+
"
) @ (
"
+
str
(
round
(
center
[
0
]
,
3
)
)
+
"
,
"
+
str
(
round
(
center
[
1
]
,
3
)
)
+
"
)
"
)
else
:
print
(
slit_name
+
"
= (
"
+
str
(
round
(
size
[
0
],
3
))
+
"
) @ (
"
+
str
(
center
[
0
])
+
"
)
"
)
...
...
@@ -279,7 +300,7 @@ def slit2B_set(H_size,V_size,verbose=True,**kwargs):
size
=
(
H_size
,
V_size
)
center
=
kwargs
[
'
center
'
]
slits_set
(
slit_name
,
size
,
center
,
verbose
=
verbose
)
slits_set
(
slit_name
,
size
,
center
,
verbose
=
verbose
)
def
slit2B_get
(
verbose
=
True
):
"""
...
...
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