Cryomech CPA Agent

The Cryomech CPA compressor is a commonly used compressor model for the pulse tubes within SO. The CPA Agent interfaces with the compressor over ethernet to monitor the health of the unit, including stats such as Helium temperature and pressure, oil temperature, and more. The Agent can also remotely start and stop the compressor.

usage: python3 agent.py [-h] [--ip-address IP_ADDRESS] [--port PORT]
                        [--serial-number SERIAL_NUMBER] [--mode {init,acq}]
                        [--fake-errors FAKE_ERRORS]

Agent Options

--ip-address
--port

Default: 502

--serial-number
--mode

Possible choices: init, acq

--fake-errors

If True, randomly output ‘FAKE ERROR’ instead of data half of the time.

Default: False

Configuration File Examples

Below are configuration examples for the ocs config file and for running the Agent in a docker container.

OCS Site Config

To configure the Cryomech CPA Agent we need to add a CryomechCPAAgent block to our ocs configuration file. Here is an example configuration block using all of the available arguments:

{'agent-class': 'CryomechCPAAgent',
 'instance-id': 'ptc1',
 'arguments':[
   ['--ip-address', '10.10.10.111'],
   ['--serial-number', 'CPA1114W2FNCE-111111A'],
   ['--mode', 'acq'],
   ['--port', 502],
   ]}

A few things to keep in mind. You should assign your compressor a static IP, you’ll need to know that here. Port 502 is the default communication port. You should not need to change that unless you have reconfigured your compressor.

Docker Compose

The Cryomech CPA Agent should be configured to run in a Docker container. An example docker-compose service configuration is shown here:

ocs-ptc1:
  image: simonsobs/socs:latest
  hostname: ocs-docker
  network_mode: "host"
  environment:
    - INSTANCE_ID=ptc1
  volumes:
    - ${OCS_CONFIG_DIR}:/config

Since the agent within the container needs to communicate with hardware on the host network you must use network_mode: "host" in your compose file.

Example Clients

Below is an example client to start data acquisition:

from ocs.matched_client import MatchedClient

ptc1 = MatchedClient('ptc1', args=[])

ptc1.init.start()
ptc1.init.wait()

status, msg, session = ptc1.acq.start()

Note

If ['--mode', 'acq'] is specified in the ocs configuration file, acquisition will begin automatically upon agent startup, so there may be no need to run this client.

Agent API

class socs.agents.cryomech_cpa.agent.PTCAgent(agent, port, ip_address, f_sample=2.5, fake_errors=False)[source]

Agent to connect to a single cryomech compressor.

Parameters:
  • port (int) – TCP port to connect to.

  • ip_address (str) – IP Address for the compressor.

  • f_sample (float, optional) – Data acquisiton rate, defaults to 2.5 Hz.

  • fake_errors (bool, optional) – Generates fake errors in the string output 50% of the time.

init(auto_acquire=False)[source]

Task - Initializes the connection to the PTC.

Parameters:

auto_acquire (bool) – Automatically start acq process after initialization if True. Defaults to False.

power_ptc(state=None)[source]

Task - Remotely turn the PTC on or off.

Parameters:

state (str) – Desired power state of the PTC, either ‘on’, or ‘off’.

acq()[source]

Process - Starts acqusition of data from the PTC.

Parameters:

test_mode (bool, optional) – Run the Process loop only once. This is meant only for testing. Default is False.

Supporting APIs

class socs.agents.cryomech_cpa.agent.PTC(ip_address, port=502, timeout=10, fake_errors=False)[source]
get_data()[source]

Gets the raw data from the ptc and returns it in a usable format.

power(state)[source]

Turn the PTC on or off.

Parameters:

state (str) – Desired power state of the PTC, either ‘on’, or ‘off’.

breakdownReplyData(rawdata)[source]

Take in raw ptc data, and return a dictionary.

The dictionary keys are the data labels, the dictionary values are the data in floats or ints.

Returns:

  • data_flag (bool) – False if data is valid, True if output could not be interpretted.

  • data (dict) – Data dictionary already formatted for passing to OCS Feed.