Hi6200 Agent

This agent uses Modbus TCP to communicate with the Hi6200 Weight Sensor. This agent uses ModbusClient from pyModbusTCP to facilitate the communication. The agent is able to communicate over ethernet to read and monitor the net and gross weights of the scale.

usage: python3 agent.py [-h] [--ip-address IP_ADDRESS] [--tcp-port TCP_PORT]

Agent Options

--ip-address
--tcp-port

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 Hi6200 Agent we need to add a block to our ocs configuration file. Here is an example configuration block using all of the available arguments:

{'agent-class': 'Hi6200Agent',
  'instance-id': 'hi6200',
  'arguments': [
    ['--ip-address', '192.168.11.43'],
    ['--tcp-port', '502']
    ]},

The Hi6200 Agent requires the IP address and ModbusTCP port of the Hi6200 in order to connect to the Hi6200. The default ModbusTCP port on the Hi6200 is 502.

Docker Compose

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

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

Agent API

class socs.agents.hi6200.agent.Hi6200Agent(agent, ip_address, tcp_port)[source]

Agent to connect to the Hi6200 weight controller that measures the weight of the LN2 dewar on the SAT platform.

Parameters:
  • ip_address (string) – IP address set on the Hi6200

  • tcp_port (int) – Modbus TCP port of the Hi6200. Default set on the device is 502.

  • scale (Hi6200Interface) – A driver object that allows for communication with the scale.

init()[source]

Task - Initialize connection to the Hi 6200 Weight Sensor.

monitor_weight(wait=1)[source]

Process - Continuously monitor scale gross and net weights.

Parameters:

wait (float, optional) – Time to wait between measurements [seconds].

Example Clients

Below is an example client demonstrating full agent functionality.:

from ocs.ocs_client import OCSClient

# Initialize the power supply
scale = OCSClient('hi6200')
scale.init.start()
scale.init.wait()

# Begin Monitoring Weight
scale.monitor_weight.start()

#Stop Monitoring Weight
scale.stop_monitoring.start()

Supporting APIs

class socs.agents.hi6200.drivers.Hi6200Interface(ip_address, tcp_port, verbose=False, **kwargs)[source]

Connects to the Hi6200 weight sensor using a TCP ModbusClient with pyModbusTCP. The Modbus Client uses a socket connection to facillitate Modbus communications. ModbusClient requires an IP address and port to connect.

The Gross and Net weight sensors are always available to read on the 8,9 and 6,7 registers respectively.

ModbusClient will not throw errors upon incorrect ip_address!

ModbusClient auto-reconnects upon socket failure if auto_open is True.

read_scale_gross_weight()[source]
Returns:

The current gross weight reading of the scale in the sensors chosen unit (kg).

Return type:

float

read_scale_net_weight()[source]
Returns:

The current net weight reading of the scale in the sensors chosen unit (kg).

Return type:

float