From e96b9f21e2d7716610936ab37e747db01dbd8c7b Mon Sep 17 00:00:00 2001 From: d-hoshino2626 Date: Fri, 8 Nov 2024 18:54:04 +0900 Subject: [PATCH] add posisition data in acq() --- socs/agents/wiregrid_actuator/agent.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/socs/agents/wiregrid_actuator/agent.py b/socs/agents/wiregrid_actuator/agent.py index 09b452fe6..02c639376 100644 --- a/socs/agents/wiregrid_actuator/agent.py +++ b/socs/agents/wiregrid_actuator/agent.py @@ -758,7 +758,9 @@ def acq(self, session, params=None): 'STR2': 0 or 1, (0: OFF, 1:ON) . . - } + }, + 'position': + 'inside' or 'outside' or 'unknown' }, 'timestamp':1601925677.6914878 } @@ -845,12 +847,26 @@ def acq(self, session, params=None): zip(onoff_st, self.actuator.st.io_names): data['data']['stopper_{}'.format(name)] = onoff onoff_dict_st[name] = onoff + # Data for position + if (onoff_dict_ls['LSR1'] == 1 or onoff_dict_ls['LSL1'] == 1) \ + and not (onoff_dict_ls['LSR2'] == 1 or onoff_dict_ls['LSL2'] == 1): + position = 'outside' + elif (onoff_dict_ls['LSR2'] == 1 or onoff_dict_ls['LSL2'] == 1) \ + and not (onoff_dict_ls['LSR1'] == 1 or onoff_dict_ls['LSL1'] == 1): + position = 'inside' + else: + position = 'unknown' + self.log.warn( + 'acq(): ' + 'Unknown position!') + data['data']['position'] = position # publish data self.agent.publish_to_feed('wgactuator', data) # store session.data field_dict = {'motor': onoff_mt, 'limitswitch': onoff_dict_ls, - 'stopper': onoff_dict_st} + 'stopper': onoff_dict_st, + 'position': position} session.data['timestamp'] = current_time session.data['fields'] = field_dict