Skip to main content

CryoCon library

CryoCon M24C

This library is used to control basic features of a CryoCon temperature controller. It is composed of a core library, an optional simulator and an optional tango device server.

It has been tested with M32 and M24C models, but should work with other models.

It can be used with either the ETH or the serial line connection (read below on the recommended way to setup a serial line connection)

Installation

From within your favorite python environment type:

$ pip install cryocon

Library

The core of the cryocon library consists of CryoCon object. To create a CryoCon object you need to pass a communication object.

The communication object can be any object that supports a simple API consisting of two methods (either the sync or async version is supported):

  • write_readline(buff: bytes) -> bytes or

    async write_readline(buff: bytes) -> bytes

  • write(buff: bytes) -> None or

    async write(buff: bytes) -> None

A library that supports this API is sockio (cryocon comes pre-installed so you don't have to worry about installing it).

This library includes both async and sync versions of the TCP object. It also supports a set of features like reconnection and timeout handling.

Here is how to connect to a cryocon controller:

import asyncio

from sockio.aio import TCP
from cryocon import CryoCon


async def main():
    tcp = TCP("192.168.1.123", 5000)  # use host name or IP
    cryo = CryoCon(tcp)

    idn = await cryo.idn()
    name = await cryo.name()
    print("Connected to {} ({})".format(idn, name))

    # channel access:
    temp_A = await cryo['A'].temperature()
    unit = await cryo['A'].unit()
    print("Channel A temperature: {}{}".format(temp_A, unit))

    # loop access:
    source_1 = await cryo[1].source()
    print("Loop 1 source: {}".format(source_1))

    # activate control
    await cryo.control(True)

    # hardware only accepts queries every 100ms. Yo can, however,
    # group queries in single request:
    async with cryo as group:
        cryo.idn()
        cryo.control()
        cryo['A'].temperature()
    idn, ctrl, temp_A = group.replies


asyncio.run(main())

Serial line

To access a serial line based CryoCon device it is strongly recommended you spawn a serial to tcp bridge using ser2net, ser2sock or socat

Assuming your device is connected to /dev/ttyS0 and the baudrate is set to 19200, here is how you could use socat to expose your device on the machine port 5000:

socat -v TCP-LISTEN:5000,reuseaddr,fork file:/dev/ttyS0,rawer,b19200,cs8,eol=10,icanon=1

It might be worth considering starting socat or ser2net as a service using supervisor or circus.

Simulator

A CryoCon simulator is provided.

Before using it, make sure everything is installed with:

$ pip install cryocon[simulator]

The sinstruments engine is used.

To start a simulator you need to write a YAML config file where you define how many devices you want to simulate and which properties they hold.

The following example exports 2 hardware devices. The first is a minimal configuration using default values and the second defines some initial values explicitly:

# config.yml

devices:
- class: CryoCon
  name: cryo1
  transports:
  - type: tcp
    url: :5000

- class: CryoCon
  name: cryo2
  transports:
    - type: tcp
      url: :5001
  channels:
    A:
      unit: K
    B:
      unit: K
  loops:
    1:
      source: A
      type: MAN
  distc: 4
  lockout: OFF
  remled: ON
  control: OFF

To start the simulator type:

$ sinstruments-server -c ./config.yml --log-level=DEBUG
2020-05-14 16:02:35,004 INFO  simulator: Bootstraping server
2020-05-14 16:02:35,004 INFO  simulator: no backdoor declared
2020-05-14 16:02:35,004 INFO  simulator: Creating device CryoCon ('CryoCon')
2020-05-14 16:02:35,080 INFO  simulator.CryoCon[('', 5000)]: listening on ('', 5000) (newline='\n') (baudrate=None)
2020-05-14 16:02:35,080 INFO  simulator: Creating device CryoCon ('CryoCon')
2020-05-14 16:02:35,081 INFO  simulator.CryoCon[('', 5001)]: listening on ('', 5001) (newline='\n') (baudrate=None)

(To see the full list of options type sinstruments-server --help)

You can access it as you would a real hardware:

$ nc localhost 5000
*IDN?
Cryo-con,24C,204683,1.01A

or using the library:

$ python
>>> from sockio.sio import TCP   # use synchronous socket in the CLI!
>>> from cryocon import CryoCon
>>> cryo = CryoCon(TCP('localhost', 5000))
>>> print(cryo.idn())
Cryo-con,24C,204683,1.01A

or, since python 3.8, it is possible to launch a natively async REPL:

$ python -m asyncio
>>> from sockio.aio import TCP
>>> from cryocon import CryoCon
>>> cryo = CryoCon(TCP('localhost', 5000))
>>> print(await cryo.idn())

Tango server

A tango device server is also provided.

Make sure everything is installed with:

$ pip install cryocon[tango-ds]

Register a cryocon tango server in the tango database:

$ tangoctl server add -s CryoCon/test -d CryoCon test/cryocon/1
$ tangoctl device property write -d test/cryocon/1 -p url -v "tcp://192.168.123:5000"

By default, loop output attributes are read-only. To allow manual output writes for selected loops, set the WritableManualOutputLoops device property:

$ tangoctl device property write -d test/cryocon/1 -p WritableManualOutputLoops -v "1,2"

With this property, writing loop1output or loop2output writes the loop manual output power (PMAN). Leave the property empty to keep the default read-only behavior. Loops listed in WritableManualOutputLoops but not in UsedLoops are ignored and reported in the device status.

(the above example uses tangoctl. You would need to install it with pip install tangoctl before using it. You are free to use any other tango tool like fandango or Jive)

Launch the server with:

$ CryoCon test

TODO

  • Add on_connection_made callback to initialize controller with:
    • unit=K
    • cache IDN, fw revision, hw revision
    • should we cache system:name? and input:name? in theory in could be modified directly with the hardware front panel

Metadata

Release files for cryocon 3.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cryocon 3.3.1
File Size Uploaded Provenance Actions
cryocon-3.3.1.tar.gz 16.2 kB Without provenance Details for cryocon-3.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cryocon 3.3.1
File Interpreter ABI Platform Actions
cryocon-3.3.1-py3-none-any.whl Python 3 none any Details for cryocon-3.3.1-py3-none-any.whl

Total release size: 30.3 kB

Release files / cryocon-3.3.1.tar.gz

Download URL cryocon-3.3.1.tar.gz
Size 16.2 kB
Tags Source
SHA-256 checksum
How to use checksums
42986ab399eaf42e98a0fe7d59d1e2c330fb5608f4b906ad4e224a47c56e9123
BLAKE2b-256 checksum
How to use checksums
269873a99a39c8ce0f8ef7fa1b8f2f72a653b98c739209009ada1b1df8fd4e05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.2

Release files / cryocon-3.3.1-py3-none-any.whl

Download URL cryocon-3.3.1-py3-none-any.whl
Size 14.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0eabd67cf2066d08f590d5a35dff1d72a4e321c5566b3d66d106e8253c9c1f52
BLAKE2b-256 checksum
How to use checksums
27a3a7822cad113afef47690ca211c8784bf55afba49cdebdc62bf7b584de6d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.2

Security for cryocon 3.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page