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 KIKUSUI PCR500MA AC power supply agent #818

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

dixilo
Copy link
Contributor

@dixilo dixilo commented Jan 20, 2025

Description

This pull request adds a new agent to operate KIKUSUI's PCR500MA AC power supply.

Motivation and Context

PCR500MA will be used as a power source to the stimulator heater to generate radiation.
Since the device will be connected to the site ethernet and be controlled from daq-pc, it should be included in this socs repository.

How Has This Been Tested?

Test was done using the actual PCR500MA device.
The device was connected to the lab network, and the ocs agent and client were run from a PC also connected to the same network.
Functions in the agent code was tested by checking the display and the light indicator of the device.
Torelance to the ethernet disconection was also tested by just unplugging the cable from the device.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@dixilo dixilo requested a review from BrianJKoopman January 20, 2025 11:00
@dixilo dixilo self-assigned this Jan 20, 2025
@BrianJKoopman BrianJKoopman added hardware: stimulator new agent New OCS agent needs to be created labels Jan 22, 2025
Copy link
Member

@BrianJKoopman BrianJKoopman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thanks for the PR! A few small comments below. I'm also going to push a commit with some packaging bits. Please pull before making further changes.


.. autoclass:: socs.agents.kikusui_pcr500ma.agent.PCRAgent
:members:

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add "Supporting APIs" header.

(I'm trying out this new-to-me suggested change feature, which I think you'll be able to just "accept". Though you can of course add independent of this too, if that's easier.)

Suggested change
Supporting APIs
---------------

@@ -55,6 +55,7 @@ API Reference Full API documentation for core parts of the SOCS library.
agents/holo_synth
agents/ibootbar
agents/ifm_sbn246_flowmeter
agents/kikusui_pcr500ma.rst
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works, but for consistency, drop the .rst extension.

Suggested change
agents/kikusui_pcr500ma.rst
agents/kikusui_pcr500ma

Comment on lines +2 to +3
'''OCS agent for dS378 ethernet relay
'''
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment from the dS378 relay agent. You can just drop this, many of the agents don't have a docstring like this, and this isn't used in any of the auto documentation.

Suggested change
'''OCS agent for dS378 ethernet relay
'''

ACQ_TIMEOUT = 20


class PCRAgent:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the communication the same across other "PRC*" models? If not, consider renaming to PCR500MAAgent.

It might also make sense to either include the manufacturer name here, or the fact that this is for the stimulator. For reference there are two other Kikusui power supplies supported in this repo, one is the HWPPMXAgent and the other is the WiregridKikusuiAgent. I know we already added the DS378Agent, but we should evaluate this as a group with the other open stimulator PRs.

Comment on lines +156 to +158
This function measures output voltage when turning off
and check setting voltage value when turning on by default
to avoid abrupt change in applied voltage.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wasn't clear to me when I read the comment, until I read the actual code. Can I suggest a rewording:

Suggested change
This function measures output voltage when turning off
and check setting voltage value when turning on by default
to avoid abrupt change in applied voltage.
This function measures the output voltage when turning off
and checks the voltage setting when turning on by default. If the
voltage is too high it will not change state to avoid an abrupt
change in applied voltage.

return True, f'Got AC voltage setting: {volt_set}'

@ocs_agent.param('_')
def meas(self, session, params=None):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why have a separate task to measure this? Isn't acq() grabbing these values too? (Except for f_ac -- should that be included in acq() for regular recording?)


LOCK_RELEASE_SEC = 1.
LOCK_RELEASE_TIMEOUT = 10
ACQ_TIMEOUT = 20
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a fairly high timeout. Does acq() take a long time to run? You might consider lowering this. Many other agents that set this get by with at most a 5 second timeout.

if not message[-1] == '\n':
message += '\n'

self.__w(message.encode())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why have this additional layer of wrapping instead of using send directly?

self.send(message.encode())

Same question for __r().

self._send(message)

def turn_on(self):
"""Trun on"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small typo -- "Trun" -> "Turn". (Same in the turn_off() docstring.)

pgroup = parser.add_argument_group('Agent Options')
pgroup.add_argument('--port', default=PORT_DEFAULT, type=int,
help='Port number for TCP communication.')
pgroup.add_argument('--ip_address',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change --ip_address to --ip-address. By convention we use '-' for a separator in these commandline arguments. (Don't forget to change it on the example config file in the docs page too.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hardware: stimulator new agent New OCS agent needs to be created
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants