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
03c0a559
Commit
03c0a559
authored
Feb 05, 2020
by
Emmanuel Papillon
Browse files
add manual operation on 3dxrd airpads
parent
b93c9278
Changes
1
Hide whitespace changes
Inline
Side-by-side
id11/controllers/airpad.py
View file @
03c0a559
from
gevent
import
sleep
import
gevent
import
time
from
bliss.common.hook
import
MotionHook
from
bliss.common.logtools
import
log_debug
...
...
@@ -10,6 +11,9 @@ class AirpadWagoPulseHook(MotionHook):
self
.
name
=
name
self
.
wago
=
config
[
"wago"
]
super
(
AirpadWagoPulseHook
,
self
).
__init__
()
self
.
__air_on
=
False
self
.
__manual_set
=
False
self
.
__manual_task
=
None
def
_add_axis
(
self
,
axis
):
if
len
(
self
.
axes
):
...
...
@@ -20,19 +24,47 @@ class AirpadWagoPulseHook(MotionHook):
self
.
name
,
axis
.
name
,
axis_name
)
)
super
(
Wago
Hook
,
self
).
_add_axis
(
axis
)
super
(
AirpadWagoPulse
Hook
,
self
).
_add_axis
(
axis
)
def
set
(
self
,
phase
):
self
.
__air_on
=
False
channel
=
self
.
config
[
phase
][
"channel"
]
wait
=
self
.
config
[
phase
].
get
(
"wait"
,
0.1
)
log_debug
(
self
,
f
"start
{
phase
}
, pulse on
{
channel
}
for
{
wait
}
sec."
)
self
.
wago
.
set
(
channel
,
1
)
sleep
(
wait
)
gevent
.
sleep
(
wait
)
self
.
wago
.
set
(
channel
,
0
)
log_debug
(
self
,
f
"finished
{
phase
}
"
)
if
phase
==
"premove"
:
self
.
__air_on
=
True
def
pre_move
(
self
,
motion_list
):
self
.
set
(
"pre_move"
)
if
not
self
.
__air_on
:
self
.
set
(
"pre_move"
)
def
post_move
(
self
,
motion_list
):
if
not
self
.
__manual_set
:
self
.
set
(
"post_move"
)
def
on
(
self
,
alert_timeout
=
10
):
if
not
self
.
__air_on
:
self
.
set
(
"pre_move"
)
self
.
__manual_set
=
True
if
self
.
__manual_task
is
not
None
:
self
.
__manual_task
.
kill
()
self
.
__manual_task
=
gevent
.
spawn
(
self
.
__manual_check
,
alert_timeout
)
def
off
(
self
):
self
.
__manual_set
=
False
self
.
set
(
"post_move"
)
if
self
.
__manual_task
is
not
None
:
self
.
__manual_task
.
kill
()
def
__manual_check
(
self
,
timeout
):
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
)
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