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
F-CRG
BM07
bm07
Commits
31e3f37f
Commit
31e3f37f
authored
Aug 27, 2021
by
Yoann Sallaz Damaz
Browse files
correction
parent
0ffabbf9
Pipeline
#53492
failed with stages
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
bm07/actuator_multiwago_interlocked.py
View file @
31e3f37f
...
...
@@ -8,16 +8,17 @@ class Actuator_Multiwago_Interlocked(Actuator):
self
.
controller_state
=
config
.
get
(
"controller_state"
)
self
.
in_name
=
config
.
get
(
"in_name"
)
self
.
out_name
=
config
.
get
(
"out_name"
)
self
.
grob
=
config
.
get
(
"grob"
)
self
.
grob_state_ok
=
config
.
get
(
"grob_state_ok"
)
self
.
grob
=
None
#
config.get("grob")
self
.
grob_state_ok
=
[]
#
config.get("grob_state_ok")
self
.
controller_state_interlock
=
config
.
get
(
"controller_state_interlock"
)
self
.
controller_state_interlock_ok
=
config
.
get
(
"controller_state_interlock_ok"
)
#create dynamic method from in/out name
setattr
(
self
,
self
.
in_name
,
self
.
set_in
)
setattr
(
self
,
self
.
out_name
,
self
.
set_out
)
setattr
(
self
,
"force_"
+
self
.
in_name
,
self
.
_force_in
)
setattr
(
self
,
"force_"
+
self
.
out_name
,
self
.
_force_out
)
setattr
(
self
,
"is_"
+
self
.
in_name
,
self
.
_is_in
)
setattr
(
self
,
"is_"
+
self
.
out_name
,
self
.
_is_out
)
def
__repr__
(
self
):
txt
=
""
...
...
@@ -39,35 +40,37 @@ class Actuator_Multiwago_Interlocked(Actuator):
txt
+=
"%s value is NOT good to allow this device movement
\n
"
%
self
.
controller_state_interlock
return
txt
def
_set_in_out
(
self
,
ask_in
):
if
(
ask_in
==
False
and
self
.
_is_in
())
or
(
ask_in
==
True
and
self
.
_is_out
()):
if
self
.
grob
:
if
self
.
grob
.
Status
in
self
.
grob_state_ok
:
if
ask_in
:
super
(
Actuator
,
self
).
set_in
()
else
:
super
(
Actuator
,
self
).
set_out
()
else
:
print
(
"Grob is not in the good state : move forbidden"
)
elif
self
.
controller_state_interlock
:
if
(
self
.
controller_state
.
get
(
self
.
controller_state_interlock
)
==
self
.
controller_state_interlock_ok
):
if
ask_in
:
super
(
Actuator
,
self
).
set_in
()
else
:
super
(
Actuator
,
self
).
set_out
()
else
:
print
(
"%s set an interlock : move forbidden"
%
self
.
controller_state_interlock
)
else
:
if
ask_in
:
super
(
Actuator
,
self
).
set_in
()
else
:
super
(
Actuator
,
self
).
set_out
()
def
set_in
(
self
,
timeout
=
None
):
if
self
.
grob
:
if
self
.
grob
.
Status
in
self
.
grob_state_ok
:
super
(
Actuator
,
self
).
set_in
()
else
:
print
(
"Grob is not in the good state : move forbidden"
)
elif
self
.
controller_state_interlock
:
if
(
self
.
controller_state
.
get
(
self
.
controller_state_interlock
)
==
self
.
controller_state_interlock_ok
):
super
(
Actuator
,
self
).
set_in
()
else
:
print
(
"%s set an interlock : move forbidden"
%
self
.
controller_state_interlock
)
else
:
super
(
Actuator
,
self
).
set_in
()
self
.
_set_in_out
(
ask_in
=
True
)
def
set_out
(
self
,
timeout
=
None
):
if
self
.
grob
:
if
self
.
grob
.
Status
in
self
.
grob_state_ok
:
super
(
Actuator
,
self
).
set_out
()
else
:
print
(
"Grob is not in the good state : move forbidden"
)
elif
self
.
controller_state_interlock
:
if
(
self
.
controller_state
.
get
(
self
.
controller_state_interlock
)
==
self
.
controller_state_interlock_ok
):
super
(
Actuator
,
self
).
set_out
()
else
:
print
(
"%s set an interlock : move forbidden"
%
self
.
controller_state_interlock
)
self
.
_set_in_out
(
ask_in
=
False
)
else
:
super
(
Actuator
,
self
).
set_out
()
def
_is_in
(
self
):
if
self
.
key_in
:
...
...
bm07/grob_FIP.py
View file @
31e3f37f
from
bliss.config
import
static
as
static
_config
from
bliss.config
.static
import
get
_config
from
bliss.comm.modbus
import
ModbusTcp
from
bliss.config.channels
import
Cache
,
Channel
import
gevent
...
...
@@ -49,6 +49,9 @@ import time
#<GENERAL_PARAMETERS TopicName="TANGOCOM" TCP_Port="502" ConnectionNumber="4"/>
#</TOPICSLIST>
CRED
=
'
\033
[91m'
CGRE
=
'
\033
[92m'
CEND
=
'
\033
[0m'
def
float_to_word
(
val
):
if
val
>
327.67
:
...
...
@@ -117,6 +120,9 @@ class grob_FIP(object):
def
__init__
(
self
,
name
,
config
,
config_objects
=
None
):
self
.
_config_objects
=
config_objects
self
.
config
=
config
self
.
real_device_init
=
False
ip
=
config
.
get
(
"ip"
)
port
=
config
.
get
(
"port"
)
self
.
client
=
ModbusTcp
(
ip
,
port
=
int
(
port
))
...
...
@@ -204,17 +210,6 @@ class grob_FIP(object):
self
.
ErrorMsg
=
None
self
.
currentPuckType
=
None
#real device
self
.
omega
=
config
[
"gonio_omega"
]
self
.
xomega
=
config
[
"gonio_xomega"
]
self
.
zomega
=
config
[
"gonio_zomega"
]
self
.
x
=
config
[
"gonio_x"
]
self
.
y
=
config
[
"gonio_y"
]
self
.
z
=
config
[
"gonio_z"
]
self
.
kappa
=
config
[
"gonio_kappa"
]
self
.
detfw
=
config
[
"det_move"
]
self
.
wago
=
config
[
"wago"
]
#geometry
#mount sample
self
.
omega_mountsample
=
config
[
"omega_mountsample"
]
...
...
@@ -224,6 +219,7 @@ class grob_FIP(object):
self
.
z_mountsample
=
config
[
"z_mountsample"
]
self
.
xomega_mountsample
=
config
[
"xomega_mountsample"
]
self
.
zomega_mountsample
=
config
[
"zomega_mountsample"
]
self
.
detfwd_mountsample
=
config
[
"detfwd_mountsample"
]
#collect sample
self
.
omega_collectsample
=
config
[
"omega_collectsample"
]
self
.
kappa_collectsample
=
config
[
"kappa_collectsample"
]
...
...
@@ -254,7 +250,29 @@ class grob_FIP(object):
param
.
insert
(
0
,
self
.
command
.
get
(
cmd
))
print
(
param
)
self
.
client
.
write_registers
(
cominfo
.
get
(
"addr"
),
cominfo
.
get
(
"struct_format"
),
param
)
def
init_real_device
(
self
):
if
not
(
self
.
real_device_init
):
self
.
omega
=
self
.
config
[
"gonio_omega"
]
self
.
xomega
=
self
.
config
[
"gonio_xomega"
]
self
.
zomega
=
self
.
config
[
"gonio_zomega"
]
self
.
x
=
self
.
config
[
"gonio_x"
]
self
.
y
=
self
.
config
[
"gonio_y"
]
self
.
z
=
self
.
config
[
"gonio_z"
]
self
.
kappa
=
self
.
config
[
"gonio_kappa"
]
self
.
detfwd
=
self
.
config
[
"detfwd"
]
self
.
detcover
=
get_config
().
get
(
self
.
config
[
"detcover"
])
self
.
bstop1
=
get_config
().
get
(
self
.
config
[
"bstop1"
])
self
.
cryoshort
=
get_config
().
get
(
self
.
config
[
"cryoshort"
])
self
.
cryolong
=
get_config
().
get
(
self
.
config
[
"cryolong"
])
self
.
dewar
=
get_config
().
get
(
self
.
config
[
"dewar"
])
self
.
mca
=
get_config
().
get
(
self
.
config
[
"mca"
])
self
.
dstop
=
get_config
().
get
(
self
.
config
[
"dstop"
])
self
.
wago
=
self
.
config
[
"wago"
]
self
.
keyence
=
get_config
().
get
(
self
.
config
[
"keyence"
])
self
.
real_device_init
=
True
def
_move_gonio
(
self
,
motor_list_first
,
target_list_first
,
motor_list_next
,
target_list_next
,
checkonly
=
False
):
...
...
@@ -283,24 +301,159 @@ class grob_FIP(object):
def
force_gripper
(
self
,
gripper_number
):
#0 rien, 3 Pince double
self
.
send_command
(
"force_gripper"
,[
nu
gripper_number
m
])
self
.
send_command
(
"force_gripper"
,[
gripper_number
])
def
force_mounted_sample
(
self
,
sample_number
):
self
.
send_command
(
"force_mounted_sample"
,
[
sample_number
])
def
move_gonio_in_sample_mount_geo
(
self
,
checkonly
=
False
):
def
move_accessories_in_sample_mount_geo
(
self
,
checkonly
=
False
):
self
.
init_real_device
()
if
not
(
self
.
SIMU
):
self
.
dewar
.
open
()
self
.
detcover
.
close
()
self
.
cryolong
.
down
()
self
.
mca
.
remove
()
self
.
bstop1
.
down
()
self
.
dstop
.
down
()
self
.
cryoshort
.
up
()
self
.
keyence
.
on
()
for
retry
in
range
(
0
,
10
):
if
self
.
SIMU
:
return
True
else
:
ok
=
True
txt
=
""
if
self
.
mca
.
is_remove
():
txt
+=
"MCA removed
\t\t
"
+
CGRE
+
"[OK]
\n
"
+
CEND
else
:
txt
+=
"MCA removed
\t\t
"
+
CRED
+
"[NOK]
\n
"
+
CEND
ok
=
False
if
self
.
bstop1
.
is_down
():
txt
+=
"BStop1 down
\t\t
"
+
CGRE
+
"[OK]
\n
"
+
CEND
else
:
txt
+=
"BStop1 down
\t\t
"
+
CRED
+
"[NOK]
\n
"
+
CEND
ok
=
False
if
self
.
dstop
.
is_down
():
txt
+=
"DStop down
\t\t
"
+
CGRE
+
"[OK]
\n
"
+
CEND
else
:
txt
+=
"DStop down
\t\t
"
+
CRED
+
"[NOK]
\n
"
+
CEND
ok
=
False
if
self
.
cryoshort
.
is_up
():
txt
+=
"Cryo Short up
\t\t
"
+
CGRE
+
"[OK]
\n
"
+
CEND
else
:
txt
+=
"Cryo Short up
\t\t
"
+
CRED
+
"[NOK]
\n
"
+
CEND
ok
=
False
if
self
.
cryolong
.
is_down
():
txt
+=
"Cryo Long down
\t\t
"
+
CGRE
+
"[OK]
\n
"
+
CEND
else
:
txt
+=
"Cryo Long down
\t\t
"
+
CRED
+
"[NOK]
\n
"
+
CEND
ok
=
False
if
self
.
detcover
.
is_close
():
txt
+=
"Detector Cover closed
\t
"
+
CGRE
+
"[OK]
\n
"
+
CEND
else
:
txt
+=
"Detector Cover closed
\t
"
+
CRED
+
"[NOK]
\n
"
+
CEND
ok
=
False
if
self
.
keyence
.
is_on
():
txt
+=
"Keyence Light on
\t
"
+
CGRE
+
"[OK]
\n
"
+
CEND
else
:
txt
+=
"Keyence Light on
\t
"
+
CRED
+
"[NOK]
\n
"
+
CEND
ok
=
False
if
self
.
dewar
.
is_open
():
txt
+=
"Dewar Lid open
\t
"
+
CGRE
+
"[OK]
\n
"
+
CEND
else
:
txt
+=
"Dewar Lid open
\t\t
"
+
CRED
+
"[NOK]
\n
"
+
CEND
ok
=
False
if
ok
:
print
(
txt
)
return
True
else
:
time
.
sleep
(
1
)
return
False
def
move_accessories_in_sample_collect_geo
(
self
,
checkonly
=
False
):
self
.
init_real_device
()
if
not
(
self
.
SIMU
):
self
.
dewar
.
close
()
self
.
detcover
.
open
()
self
.
cryolong
.
down
()
self
.
mca
.
remove
()
self
.
bstop1
.
up
()
self
.
dstop
.
down
()
self
.
cryoshort
.
down
()
self
.
keyence
.
off
()
for
retry
in
range
(
0
,
10
):
if
self
.
SIMU
:
return
True
else
:
ok
=
True
txt
=
""
if
self
.
mca
.
is_remove
():
txt
+=
"MCA removed
\t\t
"
+
CGRE
+
"[OK]
\n
"
+
CEND
else
:
txt
+=
"MCA removed
\t\t
"
+
CRED
+
"[NOK]
\n
"
+
CEND
ok
=
False
if
self
.
bstop1
.
is_up
():
txt
+=
"BStop1 up
\t\t
"
+
CGRE
+
"[OK]
\n
"
+
CEND
else
:
txt
+=
"BStop1 up
\t\t
"
+
CRED
+
"[NOK]
\n
"
+
CEND
ok
=
False
if
self
.
dstop
.
is_down
():
txt
+=
"DStop down
\t\t
"
+
CGRE
+
"[OK]
\n
"
+
CEND
else
:
txt
+=
"DStop down
\t\t
"
+
CRED
+
"[NOK]
\n
"
+
CEND
ok
=
False
if
self
.
cryoshort
.
is_down
():
txt
+=
"Cryo Short down
\t\t
"
+
CGRE
+
"[OK]
\n
"
+
CEND
else
:
txt
+=
"Cryo Short down
\t\t
"
+
CRED
+
"[NOK]
\n
"
+
CEND
ok
=
False
if
self
.
cryolong
.
is_down
():
txt
+=
"Cryo Long down
\t\t
"
+
CGRE
+
"[OK]
\n
"
+
CEND
else
:
txt
+=
"Cryo Long down
\t\t
"
+
CRED
+
"[NOK]
\n
"
+
CEND
ok
=
False
if
self
.
detcover
.
is_open
():
txt
+=
"Detector Cover opened
\t
"
+
CGRE
+
"[OK]
\n
"
+
CEND
else
:
txt
+=
"Detector Cover opened
\t
"
+
CRED
+
"[NOK]
\n
"
+
CEND
ok
=
False
if
self
.
keyence
.
is_off
():
txt
+=
"Keyence Light off
\t
"
+
CGRE
+
"[OK]
\n
"
+
CEND
else
:
txt
+=
"Keyence Light off
\t
"
+
CRED
+
"[NOK]
\n
"
+
CEND
ok
=
False
if
self
.
dewar
.
is_close
():
txt
+=
"Dewar Lid close
\t
"
+
CGRE
+
"[OK]
\n
"
+
CEND
else
:
txt
+=
"Dewar Lid close
\t\t
"
+
CRED
+
"[NOK]
\n
"
+
CEND
ok
=
False
if
ok
:
print
(
txt
)
return
True
else
:
time
.
sleep
(
1
)
return
False
def
move_motors_in_sample_mount_geo
(
self
,
checkonly
=
False
):
self
.
init_real_device
()
motor_list_first
=
[
self
.
omega
,
self
.
y
]
target_list_first
=
[
self
.
omega_mountsample
,
self
.
y_mountsample
]
motor_list_next
=
[
self
.
kappa
,
self
.
x
,
self
.
z
,
self
.
xomega
,
self
.
zomega
]
self
.
zomega
,
self
.
detfwd
]
target_list_next
=
[
self
.
kappa_mountsample
,
self
.
x_mountsample
,
self
.
z_mountsample
,
self
.
xomega_mountsample
,
self
.
zomega_mountsample
]
self
.
zomega_mountsample
,
self
.
detfwd_mountsample
]
#first y and omega to be sure no collision
if
self
.
SIMU
:
return
self
.
state_gonio
==
2
...
...
@@ -309,7 +462,9 @@ class grob_FIP(object):
motor_list_next
,
target_list_next
,
checkonly
)
def
move_gonio_in_sample_collect_geo
(
self
,
checkonly
=
False
):
def
move_motors_in_sample_collect_geo
(
self
,
checkonly
=
False
):
self
.
init_real_device
()
motor_list_first
=
[
self
.
kappa
,
self
.
x
,
self
.
z
,
...
...
@@ -348,9 +503,12 @@ class grob_FIP(object):
if
self
.
SIMU
:
self
.
state_gonio
=
2
time
.
sleep
(
1
)
else
:
if
not
self
.
move_accessories_in_sample_mount_geo
():
return
False
if
not
self
.
move_
gonio
_in_sample_mount_geo
():
return
False
if
not
self
.
move_
motors
_in_sample_mount_geo
():
return
False
#robot mount
if
sample_number
==
0
:
...
...
@@ -383,6 +541,10 @@ class grob_FIP(object):
else
:
self
.
wago
.
set
(
"magnet_boost"
,
0
)
self
.
wago
.
set
(
"magnet_degauss"
,
0
)
if
self
.
CryoShort
==
1
:
self
.
kappa
.
reset_pos
()
if
self
.
kappa
.
position
<
10
:
self
.
cryoshort
.
down
()
time
.
sleep
(
0.1
)
if
self
.
NumSampleMounted
!=
sample_number
:
...
...
@@ -391,10 +553,16 @@ class grob_FIP(object):
self
.
state_grob
=
1
time
.
sleep
(
1
)
self
.
state_gonio
=
1
#gonio position for collecting sample
#if not self.move_gonio_in_sample_collect_geo():
# return False
else
:
#gonio position for collecting sample
if
self
.
Status
==
1
:
if
not
self
.
move_motors_in_sample_collect_geo
():
return
False
if
not
self
.
move_accessories_in_sample_collect_geo
():
return
False
return
True
else
:
return
True
def
dismount_sample
(
self
):
self
.
mount_sample
(
0
)
...
...
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