Commit 03c0a559 authored by Emmanuel Papillon's avatar Emmanuel Papillon
Browse files

add manual operation on 3dxrd airpads

parent b93c9278
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(WagoHook, self)._add_axis(axis)
super(AirpadWagoPulseHook, 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)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment