Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ID11
id11
Commits
33c81201
Commit
33c81201
authored
Feb 13, 2020
by
Emmanuel Papillon
Browse files
added user_script_list in user_script
update txrd count preset
parent
ec79f666
Changes
7
Hide whitespace changes
Inline
Side-by-side
id11/controllers/airpad.py
View file @
33c81201
...
...
@@ -38,7 +38,6 @@ class AirpadWagoPulseHook(MotionHook):
if
phase
==
"premove"
:
self
.
__air_on
=
True
def
pre_move
(
self
,
motion_list
):
if
not
self
.
__air_on
:
self
.
set
(
"pre_move"
)
...
...
@@ -65,6 +64,6 @@ class AirpadWagoPulseHook(MotionHook):
start_time
=
time
.
time
()
gevent
.
sleep
(
timeout
*
60.0
)
while
True
:
elapsed
=
int
((
time
.
time
()
-
start_time
)
/
60.0
)
print
(
f
"
\n
!!! WARNING :
{
self
.
name
}
is ON since
{
elapsed
}
min. !!!"
)
gevent
.
sleep
(
60.0
)
elapsed
=
int
((
time
.
time
()
-
start_time
)
/
60.0
)
print
(
f
"
\n
!!! WARNING :
{
self
.
name
}
is ON since
{
elapsed
}
min. !!!"
)
gevent
.
sleep
(
60.0
)
id11/controllers/fshutter.py
View file @
33c81201
from
bliss.config.settings
import
HashObjSetting
#from bliss.common.shutter import BaseShutter, BaseShutterState
# from bliss.common.shutter import BaseShutter, BaseShutterState
from
bliss
import
current_session
...
...
@@ -78,12 +79,12 @@ class FastShutter:
@
property
def
state
(
self
):
return
self
.
__shutter_mux
.
getOutputStat
(
"SHUTTER"
)
@
property
def
mode
(
self
):
return
self
.
__shutter_mux
.
getOutputStat
(
"SHUTTER"
)
@
mode
.
setter
def
mode
(
self
,
value
):
self
.
__check_session
()
self
.
__shutter_mux
.
switch
(
"SHUTTER"
,
value
.
upper
())
id11/motutils.py
View file @
33c81201
...
...
@@ -3,7 +3,13 @@ from bliss.controllers.motors.icepap import Icepap
from
bliss.common.cleanup
import
error_cleanup
from
bliss.shell.standard
import
wm
__all__
=
[
"mot_findref"
,
"mot_showref"
,
"mot_findrange"
,
"mot_findhome"
,
"mot_findlimit"
]
__all__
=
[
"mot_findref"
,
"mot_showref"
,
"mot_findrange"
,
"mot_findhome"
,
"mot_findlimit"
,
]
def
mot_findrange
(
axis
,
direction
=+
1
):
...
...
@@ -15,7 +21,11 @@ def mot_findrange(axis, direction=+1):
lim_dir
=
+
1
# --- first limit
print
(
"Searching {0} hardware limit {1}"
.
format
(
axis
.
name
,
lim_dir
>
0
and
"positive"
or
"negative"
))
print
(
"Searching {0} hardware limit {1}"
.
format
(
axis
.
name
,
lim_dir
>
0
and
"positive"
or
"negative"
)
)
mot_findlimit
(
axis
,
lim_dir
)
lim_dial1
=
axis
.
limit_found_dial
()
lim_user1
=
axis
.
dial2user
(
lim_dial1
)
...
...
@@ -24,7 +34,11 @@ def mot_findrange(axis, direction=+1):
# --- second limit
lim_dir
*=
-
1
print
(
"Searching {0} hardware limit {1}"
.
format
(
axis
.
name
,
lim_dir
>
0
and
"positive"
or
"negative"
))
print
(
"Searching {0} hardware limit {1}"
.
format
(
axis
.
name
,
lim_dir
>
0
and
"positive"
or
"negative"
)
)
mot_findlimit
(
axis
,
lim_dir
)
lim_dial2
=
axis
.
limit_found_dial
()
lim_user2
=
axis
.
dial2user
(
lim_dial2
)
...
...
@@ -36,7 +50,7 @@ def mot_findrange(axis, direction=+1):
print
(
f
"Motor travel range =
{
travel
:
g
}
"
)
print
()
def
mot_findref
(
axis
):
if
not
isinstance
(
axis
.
controller
,
Icepap
):
raise
RuntimeError
(
"findmotref only implemented for icepap motors"
)
...
...
@@ -78,7 +92,10 @@ def mot_findref(axis):
# --- resets dial at reference
print
()
ans
=
_yes_no
(
"Do you want to set reference dial position to {0:g}"
.
format
(
refcfg
[
"dial"
]),
False
)
ans
=
_yes_no
(
"Do you want to set reference dial position to {0:g}"
.
format
(
refcfg
[
"dial"
]),
False
,
)
if
ans
is
True
:
print
(
"==> set dial position to {0:g}"
.
format
(
refcfg
[
"dial"
]))
axis
.
dial
=
refcfg
[
"dial"
]
+
offset
...
...
@@ -97,9 +114,11 @@ def mot_findref(axis):
False
,
)
if
ans
is
True
:
print
(
"==> set limits to ({0:g}, {1:g})"
.
format
(
refcfg
[
"low_limit"
],
refcfg
[
"high_limit"
]
))
print
(
"==> set limits to ({0:g}, {1:g})"
.
format
(
refcfg
[
"low_limit"
],
refcfg
[
"high_limit"
]
)
)
low_user
=
axis
.
dial2user
(
refcfg
[
"low_limit"
])
high_user
=
axis
.
dial2user
(
refcfg
[
"high_limit"
])
axis
.
limits
=
(
low_user
,
high_user
)
...
...
@@ -137,22 +156,32 @@ def mot_showref(axis):
print
(
"* user position at reference : {user}"
.
format
(
**
refcfg
))
print
()
def
mot_findhome
(
axis
,
direction
=
1
):
axis
.
home
(
direction
,
wait
=
False
)
mot_move_poll
(
axis
)
def
mot_move_poll
(
axis
):
with
error_cleanup
(
axis
.
stop
):
while
axis
.
is_moving
:
print
(
f
"
\r
{
axis
.
name
}
: dial=
{
axis
.
dial
:
g
}
user=
{
axis
.
position
:
g
}
"
,
end
=
""
,
flush
=
True
)
print
(
f
"
\r
{
axis
.
name
}
: dial=
{
axis
.
dial
:
g
}
user=
{
axis
.
position
:
g
}
"
,
end
=
""
,
flush
=
True
,
)
sleep
(
0.1
)
print
(
f
"
\r
{
axis
.
name
}
: dial=
{
axis
.
dial
:
g
}
user=
{
axis
.
position
:
g
}
"
,
end
=
""
,
flush
=
True
)
print
(
f
"
\r
{
axis
.
name
}
: dial=
{
axis
.
dial
:
g
}
user=
{
axis
.
position
:
g
}
"
,
end
=
""
,
flush
=
True
)
print
(
""
)
def
mot_findlimit
(
axis
,
direction
=
1
):
axis
.
hw_limit
(
direction
,
wait
=
False
)
mot_move_poll
(
axis
)
def
_yes_no
(
msg
,
flag
):
defans
=
flag
is
True
and
"YES"
or
"NO"
ask
=
msg
+
f
" [
{
defans
}
] ? "
...
...
id11/tdxrd/counts.py
View file @
33c81201
...
...
@@ -2,16 +2,19 @@ from bliss.config.static import get_config
from
bliss.common.scans
import
DEFAULT_CHAIN
from
bliss.scanning.chain
import
ChainPreset
def
set_frelon_trigger
():
config
=
get_config
()
chaincfg
=
config
.
get
(
"chain_3dxrd_trig"
)
DEFAULT_CHAIN
.
set_settings
(
chaincfg
[
"chain_config"
])
def
set_frelon_gate
():
config
=
get_config
()
chaincfg
=
config
.
get
(
"chain_3dxrd_gate"
)
DEFAULT_CHAIN
.
set_settings
(
chaincfg
[
"chain_config"
])
def
set_frelon_soft
():
DEFAULT_CHAIN
.
set_settings
({})
...
...
@@ -23,17 +26,16 @@ class CountMuxPreset(ChainPreset):
def
prepare
(
self
,
chain
):
# --- shutter
frelonnodes
=
[
node
for
node
in
chain
.
nodes_list
if
node
.
name
.
startswith
(
"frelon"
)
]
frelon2shutter
=
{
"frelon1"
:
"CAM1"
,
"frelon2"
:
"CAM2"
,
"frelon3"
:
"CAM3"
,
}
frelonnodes
=
[
node
for
node
in
chain
.
nodes_list
if
node
.
name
.
startswith
(
"frelon"
)
]
frelon2shutter
=
{
"frelon1"
:
"CAM1"
,
"frelon2"
:
"CAM2"
,
"frelon3"
:
"CAM3"
}
shutter_mode
=
"COUNTER"
for
node
in
frelonnodes
:
dev
=
node
.
device
if
dev
.
name
in
frelon2shutter
:
shutter_mode
=
frelon2shutter
[
dev
.
name
]
dev
.
shutter
.
mode
=
"AUTO_FRAME"
dev
.
shutter
.
close_time
=
self
.
fsh
.
shutter_time
break
self
.
fsh
.
mode
=
shutter_mode
...
...
id11/tfenergy.py
View file @
33c81201
import
math
from
bliss.setup_globals
import
*
def
tfenergy
(
nal
=
None
,
nbe
=
None
):
values
=
tfoh1
.
getlenses
()
if
nal
is
None
:
nal
=
values
[
"Al"
]
if
nbe
is
None
:
nbe
=
values
[
"Be"
]
neff
=
1.5682766
*
nal
+
nbe
print
(
"Energy for EH3 (96 m) : {0:.3f} keV"
.
format
(
math
.
sqrt
(
neff
/
0.013981957
)))
print
(
"Energy for EH1 (46 m) : {0:.3f} keV"
.
format
(
math
.
sqrt
(
neff
/
0.037651802
)))
print
(
"Energy for EH3 (96 m) : {0:.3f} keV"
.
format
(
math
.
sqrt
(
neff
/
0.013981957
)))
print
(
"Energy for EH1 (46 m) : {0:.3f} keV"
.
format
(
math
.
sqrt
(
neff
/
0.037651802
)))
def
tfguess
(
energy
,
hutch
=
"EH3"
):
if
hutch
.
upper
()
not
in
[
"EH1"
,
"EH3"
]:
...
...
@@ -44,4 +46,3 @@ def tfguess(energy, hutch="EH3"):
print
(
"{0:d} Al + {1:d} Be"
.
format
(
nal
,
int
(
nbe
)))
elif
energy
>
125
:
print
(
"Sorry, only focuses up to 125 keV !!"
)
id11/user_script.py
View file @
33c81201
import
importlib
import
os
.path
import
os
import
sys
from
bliss
import
current_session
...
...
@@ -10,7 +10,12 @@ USER_SCRIPT_HOME = SimpleSetting(
default_value
=
"%s/bliss_scripts"
%
os
.
getenv
(
"HOME"
),
)
__all__
=
[
"user_script_directory"
,
"user_script_run"
,
"user_script_load"
]
__all__
=
[
"user_script_directory"
,
"user_script_run"
,
"user_script_load"
,
"user_script_list"
,
]
def
user_script_directory
(
new_dir
=
None
):
...
...
@@ -22,12 +27,26 @@ def user_script_directory(new_dir=None):
return
USER_SCRIPT_HOME
.
get
()
def
user_script_list
():
rootdir
=
USER_SCRIPT_HOME
.
get
()
print
(
f
"Scripts found in [
{
rootdir
}
]:"
)
for
(
dirpath
,
dirnames
,
filenames
)
in
os
.
walk
(
rootdir
):
dirname
=
dirpath
.
replace
(
rootdir
,
""
)
dirname
=
dirname
.
lstrip
(
"/"
)
if
len
(
dirname
):
dirname
+=
"/"
for
filename
in
filenames
:
print
(
f
" -
{
dirname
}{
filename
}
"
)
def
user_script_load
(
scriptname
):
_user_script_exec
(
scriptname
,
export
=
True
)
def
user_script_run
(
scriptname
):
_user_script_exec
(
scriptname
,
export
=
False
)
def
_user_script_exec
(
scriptname
,
export
=
False
):
script_dir
=
os
.
path
.
abspath
(
USER_SCRIPT_HOME
.
get
())
(
filename
,
fileext
)
=
os
.
path
.
splitext
(
scriptname
)
...
...
id11/utils.py
View file @
33c81201
from
bliss.config.static
import
get_config
def
desc
(
*
objs
):
for
obj
in
objs
:
try
:
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment