Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add speedrate argument for insert/eject functions in wiregrid_actuator agent #573

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 26 additions & 14 deletions socs/agents/wiregrid_actuator/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,6 @@ def check_limitswitch(self, session, params=None):
if params is None:
params = {}
io_name = params.get('io_name', None)
onoffs = []
msg = ''
with self.lock.acquire_timeout(timeout=3, job='check_limitswitch') \
as acquired:
Expand All @@ -353,13 +352,20 @@ def check_limitswitch(self, session, params=None):
'check_limitswitch(): '\
'Could not acquire lock'

onoffs = self.actuator.ls.get_onoff(io_name)
io_names = self.actuator.ls.get_io_name(io_name)
io_labels = self.actuator.ls.get_label(io_name)
for i, io_name in enumerate(io_names):
io_label = io_labels[i]
onoff = self.actuator.ls.get_onoff(io_name)

if io_name is None:
io_name = self.actuator.ls.io_names
elif not hasattr(onoff, '__getitem__'):
io_name = [io_name]
onoff = [onoff]

label = self.actuator.ls.get_label(io_name)

for _io_name, _label, _onoff in zip(io_name, label, onoff):
msg += 'check_limitswitch(): {:10s} ({:20s}) : {}\n'\
.format(io_name, io_label, 'ON' if onoffs[i] else 'OFF')
.format(_io_name, _label, 'ON' if _onoff else 'OFF')

self.log.info(msg)
return True, msg

Expand All @@ -376,7 +382,6 @@ def check_stopper(self, session, params=None):
if params is None:
params = {}
io_name = params.get('io_name', None)
onoffs = []
msg = ''
with self.lock.acquire_timeout(timeout=3, job='check_stopper') \
as acquired:
Expand All @@ -387,13 +392,20 @@ def check_stopper(self, session, params=None):
.format(self.lock.job))
return False, 'check_stopper(): Could not acquire lock'

onoffs = self.actuator.st.get_onoff(io_name)
io_names = self.actuator.st.get_io_name(io_name)
io_labels = self.actuator.st.get_label(io_name)
for i, io_name in enumerate(io_names):
io_label = io_labels[i]
onoff = self.actuator.st.get_onoff(io_name)

if io_name is None:
io_name = self.actuator.st.io_names
elif not hasattr(onoff, '__getitem__'):
io_name = [io_name]
onoff = [onoff]

label = self.actuator.st.get_label(io_name)

for _io_name, _label, _onoff in zip(io_name, label, onoff):
msg += 'check_stopper(): {:10s} ({:20s}) : {}\n'\
.format(io_name, io_label, 'ON' if onoffs[i] else 'OFF')
.format(_io_name, _label, 'ON' if _onoff else 'OFF')

self.log.info(msg)
return True, msg

Expand Down
8 changes: 4 additions & 4 deletions socs/agents/wiregrid_actuator/drivers/DigitalIO.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def get_onoff(self, io_name=None):
io_name (str or list): A string of a IO name or list of IO names.

Returns:
list or str: A list of True/Falses or a single True/False depending
list or bool: A list of True/Falses or a single True/False depending
on the value of `io_name`. If `io_name` is None, return a list of
the ON/OFFs for all the IOs. If `io_name` is a list, return a list
of the ON/OFFs for asked IOs. If `io_name` is a string (one IO),
Expand Down Expand Up @@ -99,7 +99,7 @@ def get_onoff(self, io_name=None):
def get_label(self, io_name):
if io_name is None:
label = self.io_labels
elif isinstance(io_name, list):
elif hasattr(io_name, '__getitem__'):
if not all([(name in self.io_names) for name in io_name]):
msg = \
'DigitalIO[{}]:get_label(): ERROR!: '\
Expand All @@ -111,7 +111,7 @@ def get_label(self, io_name):
+ 'DigitalIO[{}]:get_label(): '\
'Asked IO names = {}'.format(self.name, io_name)
raise ValueError(msg)
label = [self.io_indices[name] for name in io_name]
label = [self.io_labels[self.io_indices[name]] for name in io_name]
else:
if not (io_name in self.io_names):
msg = \
Expand All @@ -121,7 +121,7 @@ def get_label(self, io_name):
+ 'DigitalIO[{}]:get_label(): '\
'Assigned IO names = {}'.format(self.name, self.io_names)
raise ValueError(msg)
label = self.io_label(io_name)
label = self.io_labels[self.io_indices[io_name]]
return label

def _set_onoff(self, onoff, io_name):
Expand Down