Lakeshore 240 Simulator

The Lakeshore 240 Simulator is meant to mock a 240 Series Input Module from Lakeshore Cryotronics. This is useful for testing code when you do not have access to a Lakeshore 240.

The simulator opens a socket port and interprets commands and queries in a similar manner to the real device. Not all Lakeshore 240 commands actually do something currently, but you can set and read channel variables (even though they don’t change anything) and read data from channels, which will currently return white noise centered around zero.

usage: python3 ls240_simulator [-h] [-p PORT] [--num-channels NUM_CHANNELS]
                               [--sn SN] [--log-file LOG_FILE]
                               [--log-level {debug,info,warning,error}] [-o]

Named Arguments

-p, --port

Port which simulator will wait for a connection.If taken, it will test several consecutive portsuntil it finds one that is free.

Default: 1094

--num-channels

Number of channels which the simulator will have.

Default: 8

--sn

Serial number for the device

Default: “LS_SIM”

--log-file

File where logs are written

--log-level

Possible choices: debug, info, warning, error

Minimum log level to be displayed

Default: “info”

-o, --log-stdout

Log to stdout

Default: False

Configuration File Examples

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

ocs-config

The LS240 Simulator is not an OCS Agent, however, to connect to it you will need a Lakeshore240Agent configured to communicate with the simulator. We can do this by passing a full address to the –port argument on a Lakeshore240Agent. This address must match the container name for the simulator:

{'agent-class': 'Lakeshore240Agent',
 'instance-id': 'LSSIM',
 'arguments': [['--serial-number', 'LSSIM'],
               ['--port', 'tcp://ls240-sim:1094'],
               ['--mode', 'acq']]},

Docker

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

ls240-sim:
  image: simonsobs/ocs-lakeshore240-simulator:latest
  hostname: ocs-docker

It is helpful to have other live monitor components such as Grafana and an InfluxDB container for quickly visualizing whether the 240 Agent is getting data from the simulator.

Running Outside of Docker

Running python3 ls240_simulator.py will start the simulator and it will wait for a connection. To connect to it, you can use the same Lakeshore240.py module that is used to connect to the real device, but by providing port=`tcp::/<address>:<port>' instead of the device port. For instance, if you run python3 ls240_simulator.py -p 1000, you can connect by providing the Lakeshore240 module with port="tcp://localhost:1000". You can specify the port for a LS240 agent in the site-file or through the command line.