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
459c66f4
Commit
459c66f4
authored
Dec 10, 2019
by
bliss administrator
Browse files
* debug mot_findref / showref
* added mot_findrange
parent
1a6e4149
Changes
1
Hide whitespace changes
Inline
Side-by-side
id11/mot
orref
.py
→
id11/mot
utils
.py
View file @
459c66f4
...
...
@@ -2,10 +2,41 @@
from
bliss.controllers.motors.icepap
import
Icepap
from
bliss.shell.standard
import
wm
__all__
=
[
"find
mot
ref"
,
"
showmotref
"
]
__all__
=
[
"
mot_
findref"
,
"
mot_showref"
,
"mot_findrange
"
]
def
findmotref
(
axis
):
def
mot_findrange
(
axis
,
direction
=+
1
):
if
not
isinstance
(
axis
.
controller
,
Icepap
):
raise
RuntimeError
(
"findmotrange only implemented for icepap motors"
)
if
direction
<
0
:
lim_dir
=
-
1
else
:
lim_dir
=
+
1
# --- first limit
print
(
"Searching {0} hardware limit {1}"
.
format
(
axis
.
name
,
lim_dir
>
0
and
"positive"
or
"negative"
))
axis
.
hw_limit
(
lim_dir
)
lim_dial1
=
axis
.
limit_found_dial
()
lim_user1
=
axis
.
dial2user
(
lim_dial1
)
print
(
f
"First limit found at = dial:
{
lim_dial1
:
g
}
user:
{
lim_user1
:
g
}
"
)
print
()
# --- second limit
lim_dir
*=
-
1
print
(
"Searching {0} hardware limit {1}"
.
format
(
axis
.
name
,
lim_dir
>
0
and
"positive"
or
"negative"
))
axis
.
hw_limit
(
lim_dir
)
lim_dial2
=
axis
.
limit_found_dial
()
lim_user2
=
axis
.
dial2user
(
lim_dial2
)
print
(
f
"Second limit found at = dial:
{
lim_dial2
:
g
}
user:
{
lim_user2
:
g
}
"
)
print
()
# --- motor travel range
travel
=
abs
(
lim_dial2
-
lim_dial1
)
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"
)
...
...
@@ -45,7 +76,7 @@ def findmotref(axis):
offset
=
axis
.
dial
-
ref_pos
# --- resets dial at reference
ans
=
_yes_no
(
"Do you want to set reference dial position to {0:g}
??"
,
False
)
ans
=
_yes_no
(
"Do you want to set reference dial position to {0:g}
"
.
format
(
refcfg
[
"dial"
])
,
False
)
if
ans
is
True
:
axis
.
dial
=
refcfg
[
"dial"
]
+
offset
...
...
@@ -54,7 +85,7 @@ def findmotref(axis):
print
(
"Reference dial limits not configured. No change."
)
else
:
ans
=
_yes_no
(
"Do you want to set dial limits to ({0:g}, {1:g})
??
"
.
format
(
"Do you want to set dial limits to ({0:g}, {1:g})"
.
format
(
refcfg
[
"low_limit"
],
refcfg
[
"high_limit"
]
),
False
,
...
...
@@ -69,7 +100,7 @@ def findmotref(axis):
print
(
"Reference user position not configured. No change."
)
else
:
ans
=
_yes_no
(
"Do you want to set user position to {0:g}
??
"
.
format
(
refcfg
[
"user"
]),
False
"Do you want to set user position to {0:g}"
.
format
(
refcfg
[
"user"
]),
False
)
if
ans
is
True
:
user_pos
=
refcfg
[
"user"
]
+
axis
.
sign
*
offset
...
...
@@ -79,7 +110,7 @@ def findmotref(axis):
wm
(
axis
)
def
show
mot
ref
(
axis
):
def
mot_
showref
(
axis
):
refcfg
=
_get_motref_config
(
axis
)
for
(
key
,
val
)
in
refcfg
.
items
():
if
val
is
None
:
...
...
@@ -93,7 +124,11 @@ def showmotref(axis):
def
_yes_no
(
msg
,
flag
):
ans
=
input
(
msg
,
flag
is
True
and
"YES"
or
"NO"
)
defans
=
flag
is
True
and
"YES"
or
"NO"
ask
=
msg
+
f
" [
{
defans
}
] ? "
ans
=
input
(
ask
)
if
not
len
(
ans
):
ans
=
defans
if
ans
.
upper
()
in
(
"YES"
,
"Y"
):
return
True
return
False
...
...
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