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
BCU-Vercors
ID26
id26
Commits
773382de
Commit
773382de
authored
May 12, 2022
by
bliss administrator
Browse files
XMCD ID24 magnet control via wagobox
XMCD test - typo fixes
parent
1872dace
Changes
2
Hide whitespace changes
Inline
Side-by-side
id26/bcolor.py
0 → 100644
View file @
773382de
class
bcolor
:
PURPLE
=
"
\033
[95m"
CYAN
=
"
\033
[96m"
DARKCYAN
=
"
\033
[36m"
BLUE
=
"
\033
[94m"
GREEN
=
"
\033
[92m"
YELLOW
=
"
\033
[93m"
RED
=
"
\033
[91m"
BOLD
=
"
\033
[1m"
UNDERLINE
=
"
\033
[4m"
END
=
"
\033
[0m"
id26/controllers/xmcd.py
0 → 100644
View file @
773382de
import
gevent
from
bliss.controllers.motors.wago
import
WagoMotor
from
id26.bcolor
import
bcolor
class
XMCD
(
WagoMotor
):
def
initialize
(
self
):
super
().
initialize
()
self
.
_polkey
=
self
.
config
.
get
(
"polarity_key"
)
self
.
_itlckey
=
self
.
config
.
get
(
"interlock_key"
)
self
.
_curkey
=
self
.
config
.
get
(
"current_key"
)
self
.
scale
=
self
.
config
.
get
(
"scale"
,
1
)
if
self
.
scale
==
0
:
self
.
scale
=
1
def
read_position
(
self
,
axis
):
pos
=
super
().
read_position
(
axis
)
return
pos
*
self
.
polarity
*
self
.
scale
def
start_one
(
self
,
motion
):
self
.
check_interlock
()
logical_name
=
motion
.
axis
.
config
.
get
(
"logical_name"
)
logical_channel
=
int
(
motion
.
axis
.
config
.
get
(
"logical_channel"
))
polarity
=
self
.
polarity
if
(
motion
.
target_pos
<
0
and
polarity
>
0
)
or
(
motion
.
target_pos
>
0
and
polarity
<
0
):
print
(
"need to switch polarity, first go to 0"
)
self
.
wago
.
controller
.
devwritephys
(
(
self
.
wago
.
controller
.
devname2key
(
logical_name
),
logical_channel
,
0
,
)
)
gevent
.
sleep
(
0.5
)
self
.
polarity
=
-
polarity
self
.
wago
.
controller
.
devwritephys
(
(
self
.
wago
.
controller
.
devname2key
(
logical_name
),
logical_channel
,
abs
(
motion
.
target_pos
/
self
.
scale
),
)
)
#TODO
#def state(self, axis):
# return AxisState("READY")
#TODO do we need it ?
def
stop
(
self
,
axis
):
pass
#XMCD
@
property
def
polarity
(
self
):
#0 --> inverted ie -1
#1 --> normal ie +1
pol
=
self
.
wago
.
get
(
self
.
_polkey
)
if
pol
==
0
:
return
-
1
elif
pol
==
1
:
return
1
else
:
raise
Exception
(
f
'
{
pol
}
not significant wago
{
self
.
_polkey
}
value as a polarity'
)
@
polarity
.
setter
def
polarity
(
self
,
value
):
#0 --> inverted ie -1
#1 --> normal ie +1
cur
=
self
.
wago
.
get
(
self
.
_curkey
)
if
abs
(
cur
)
>
0.0001
:
raise
Exception
(
"impossible to set magnet polarity, current is on {cur} : first move current to 0"
)
self
.
wago
.
set
(
self
.
_polkey
,
1
if
value
>
0
else
0
)
def
check_interlock
(
self
):
itlck
=
self
.
wago
.
get
(
self
.
_itlckey
)
if
itlck
==
1
:
print
(
'MAGNET interlock is ok (SAFE)'
)
else
:
print
(
f
'
{
bcolor
.
RED
}
MAGNET interlock FAULT
{
bcolor
.
END
}
'
)
print
(
'moving current to zero'
)
self
.
wago
.
set
(
self
.
_curkey
,
0
)
raise
Exception
(
'MAGNET interlock Fault'
)
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