From c40d3f5124e43b624d220f048b11bf4f18f48ad6 Mon Sep 17 00:00:00 2001 From: ykyohei <38639108+ykyohei@users.noreply.github.com> Date: Wed, 11 Dec 2024 10:44:31 -0500 Subject: [PATCH 1/3] add check tasks etc --- socs/agents/hwp_pmx/agent.py | 76 +++++++++++++++++++-- socs/agents/hwp_pmx/drivers/PMX_ethernet.py | 24 ++++--- 2 files changed, 88 insertions(+), 12 deletions(-) diff --git a/socs/agents/hwp_pmx/agent.py b/socs/agents/hwp_pmx/agent.py index d52eb90e2..cf0c2dc9b 100644 --- a/socs/agents/hwp_pmx/agent.py +++ b/socs/agents/hwp_pmx/agent.py @@ -58,6 +58,18 @@ class CancelShutdown(BaseAction): def process(self, module): self.log.info("Cancel shutdown...") + @dataclass + class CheckI(BaseAction): + def process(self, module): + msg, val = module.check_current() + self.log.info(msg + "...") + + @dataclass + class CheckV(BaseAction): + def process(self, module): + msg, val = module.check_voltage() + self.log.info(msg + "...") + @dataclass class SetI(BaseAction): curr: float @@ -74,6 +86,18 @@ def process(self, module): msg, val = module.set_voltage(self.volt) self.log.info(msg + "...") + @dataclass + class CheckILim(BaseAction): + def process(self, module): + msg, val = module.check_current_limit() + self.log.info(msg + "...") + + @dataclass + class CheckVLim(BaseAction): + def process(self, module): + msg, val = module.check_voltage_limit() + self.log.info(msg + "...") + @dataclass class SetILim(BaseAction): curr: float @@ -184,7 +208,27 @@ def ign_ext(self, session, params): return True, 'Set PMX Kikusui to direct control' @defer.inlineCallbacks - @ocs_agent.param('curr', default=0, type=float, check=lambda x: 0 <= x <= 3) + def check_i(self, session, params): + """check_i() + **Task** - Set the current setting. + """ + action = Actions.CheckI(**params) + self.action_queue.put(action) + session.data = yield action.deferred + return True, 'Check current is done' + + @defer.inlineCallbacks + def check_v(self, session, params): + """check_v() + **Task** - Set the voltage setting. + """ + action = Actions.CheckV(**params) + self.action_queue.put(action) + session.data = yield action.deferred + return True, 'Check voltage is done' + + @defer.inlineCallbacks + @ocs_agent.param('curr', default=0, type=float) def set_i(self, session, params): """set_i(curr=0) **Task** - Set the current. @@ -198,7 +242,7 @@ def set_i(self, session, params): return True, 'Set current is done' @defer.inlineCallbacks - @ocs_agent.param('volt', default=0, type=float, check=lambda x: 0 <= x <= 35) + @ocs_agent.param('volt', default=0, type=float) def set_v(self, session, params): """set_v(volt=0) **Task** - Set the voltage. @@ -212,7 +256,27 @@ def set_v(self, session, params): return True, 'Set voltage is done' @defer.inlineCallbacks - @ocs_agent.param('curr', default=1., type=float, check=lambda x: 0. <= x <= 3.) + def check_i_lim(self, session, params): + """check_i_lim() + **Task** - Check the current protection limit. + """ + action = Actions.CheckILim(**params) + self.action_queue.put(action) + session.data = yield action.deferred + return True, 'Check current protection limit is done' + + @defer.inlineCallbacks + def check_v_lim(self, session, params): + """check_v_lim() + **Task** - Check the voltage protection limit. + """ + action = Actions.CheckVLim(**params) + self.action_queue.put(action) + session.data = yield action.deferred + return True, 'Check voltage protection limit is done' + + @defer.inlineCallbacks + @ocs_agent.param('curr', default=1.3, type=float) def set_i_lim(self, session, params): """set_i_lim(curr=1) **Task** - Set the drive current limit. @@ -226,7 +290,7 @@ def set_i_lim(self, session, params): return True, 'Set voltage limit is done' @defer.inlineCallbacks - @ocs_agent.param('volt', default=32., type=float, check=lambda x: 0. <= x <= 35.) + @ocs_agent.param('volt', default=37., type=float) def set_v_lim(self, session, params): """set_v_lim(volt=32) **Task** - Set the drive voltage limit. @@ -475,8 +539,12 @@ def main(args=None): agent.register_task('set_on', PMX.set_on, blocking=False) agent.register_task('set_off', PMX.set_off, blocking=False) agent.register_task('clear_alarm', PMX.clear_alarm, blocking=False) + agent.register_task('check_i', PMX.check_i, blocking=False) + agent.register_task('check_v', PMX.check_v, blocking=False) agent.register_task('set_i', PMX.set_i, blocking=False) agent.register_task('set_v', PMX.set_v, blocking=False) + agent.register_task('check_i_lim', PMX.check_i_lim, blocking=False) + agent.register_task('check_v_lim', PMX.check_v_lim, blocking=False) agent.register_task('set_i_lim', PMX.set_i_lim, blocking=False) agent.register_task('set_v_lim', PMX.set_v_lim, blocking=False) agent.register_task('use_ext', PMX.use_ext, blocking=False) diff --git a/socs/agents/hwp_pmx/drivers/PMX_ethernet.py b/socs/agents/hwp_pmx/drivers/PMX_ethernet.py index f24816667..6637760e4 100644 --- a/socs/agents/hwp_pmx/drivers/PMX_ethernet.py +++ b/socs/agents/hwp_pmx/drivers/PMX_ethernet.py @@ -154,21 +154,29 @@ def ign_external_voltage(self): self.wait() return self.check_source() + def check_current_limit(self): + """ Check the PMX current protection limit """ + val = float(self.send_message(b'curr:prot?\n')) + msg = "Current protection limit = {:.3f} A".format(val) + return msg, val + + def check_voltage_limit(self): + """ Check the PMX voltage protection limit """ + val = float(self.send_message(b'volt:prot?\n')) + msg = "Voltage protection limit = {:.3f} V".format(val) + return msg, val + def set_current_limit(self, curr_lim): - """ Set the PMX current limit """ + """ Set the PMX current protection limit """ self.send_message(b'curr:prot %a\n' % curr_lim, read=False) self.wait() - val = float(self.send_message(b'curr:prot?\n')) - msg = "Current Limit: {:.3f} A".format(val) - return msg + return self.check_current_limit() def set_voltage_limit(self, vol_lim): - """ Set the PMX voltage limit """ + """ Set the PMX voltage protection limit """ self.send_message(b'volt:prot %a\n' % vol_lim, read=False) self.wait() - val = float(self.send_message(b'volt:prot?\n')) - msg = "Voltage Limit: {:.3f} V".format(val) - return msg + return self.check_voltage_limit() def check_prot(self): """ Check the protection status From b0bc179efa65f06ded974b38102292c057930de8 Mon Sep 17 00:00:00 2001 From: ykyohei <38639108+ykyohei@users.noreply.github.com> Date: Sat, 21 Dec 2024 15:23:48 +0000 Subject: [PATCH 2/3] fix --- socs/agents/hwp_pmx/agent.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/socs/agents/hwp_pmx/agent.py b/socs/agents/hwp_pmx/agent.py index cf0c2dc9b..a959ab1d7 100644 --- a/socs/agents/hwp_pmx/agent.py +++ b/socs/agents/hwp_pmx/agent.py @@ -103,7 +103,7 @@ class SetILim(BaseAction): curr: float def process(self, module): - msg = module.set_current_limit(self.curr) + msg, val = module.set_current_limit(self.curr) self.log.info(msg + "...") @dataclass @@ -111,7 +111,7 @@ class SetVLim(BaseAction): volt: float def process(self, module): - msg = module.set_voltage_limit(self.volt) + msg, val = module.set_voltage_limit(self.volt) self.log.info(msg + "...") From f4a1f83ea0cb9a709e148d28009a9e1a47870d73 Mon Sep 17 00:00:00 2001 From: ykyohei <38639108+ykyohei@users.noreply.github.com> Date: Thu, 13 Feb 2025 13:46:40 -0500 Subject: [PATCH 3/3] fix docs --- socs/agents/hwp_pmx/agent.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/socs/agents/hwp_pmx/agent.py b/socs/agents/hwp_pmx/agent.py index a959ab1d7..74e4fc4c6 100644 --- a/socs/agents/hwp_pmx/agent.py +++ b/socs/agents/hwp_pmx/agent.py @@ -278,7 +278,7 @@ def check_v_lim(self, session, params): @defer.inlineCallbacks @ocs_agent.param('curr', default=1.3, type=float) def set_i_lim(self, session, params): - """set_i_lim(curr=1) + """set_i_lim(curr=1.3) **Task** - Set the drive current limit. Parameters: @@ -292,7 +292,7 @@ def set_i_lim(self, session, params): @defer.inlineCallbacks @ocs_agent.param('volt', default=37., type=float) def set_v_lim(self, session, params): - """set_v_lim(volt=32) + """set_v_lim(volt=37) **Task** - Set the drive voltage limit. Parameters: