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 check tasks to hwp-pmx #801

Merged
merged 4 commits into from
Feb 13, 2025
Merged
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
84 changes: 76 additions & 8 deletions socs/agents/hwp_pmx/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -74,20 +86,32 @@ 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

def process(self, module):
msg = module.set_current_limit(self.curr)
msg, val = module.set_current_limit(self.curr)
self.log.info(msg + "...")

@dataclass
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 + "...")


Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -212,9 +256,29 @@ 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)
"""set_i_lim(curr=1.3)
**Task** - Set the drive current limit.

Parameters:
Expand All @@ -226,9 +290,9 @@ 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)
"""set_v_lim(volt=37)
**Task** - Set the drive voltage limit.

Parameters:
Expand Down Expand Up @@ -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)
Expand Down
24 changes: 16 additions & 8 deletions socs/agents/hwp_pmx/drivers/PMX_ethernet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down