Package: cryocon
CryoCon libraryThis library is used to control basic features of a CryoCon temperature
controller. It is composed of a core library, an optional simulator and
an optionaltangodevice 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)InstallationFrom within your favorite python environment type:$ pip install cryoconLibraryThe 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) -> bytesorasync write_readline(buff: bytes) -> byteswrite(buff: bytes) -> Noneorasync write(buff: bytes) -> NoneA library that supports this API issockio(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:importasynciofromsockio.aioimportTCPfromcryoconimportCryoConasyncdefmain():tcp=TCP("192.168.1.123",5000)# use host name or IPcryo=CryoCon(tcp)idn=awaitcryo.idn()name=awaitcryo.name()print("Connected to{}({})".format(idn,name))# channel access:temp_A=awaitcryo['A'].temperature()unit=awaitcryo['A'].unit()print("Channel A temperature:{}{}".format(temp_A,unit))# loop access:source_1=awaitcryo[1].source()print("Loop 1 source:{}".format(source_1))# activate controlawaitcryo.control(True)# hardware only accepts queries every 100ms. Yo can, however,# group queries in single request:asyncwithcryoasgroup:cryo.idn()cryo.control()cryo['A'].temperature()idn,ctrl,temp_A=group.repliesasyncio.run(main())Serial lineTo access a serial line based CryoCon device it is strongly recommended you spawn
a serial to tcp bridge usingser2netorsocatAssuming your device is connected to/dev/ttyS0and 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=1It might be worth considering starting socat or ser2net as a service usingsupervisororcircus.SimulatorA CryoCon simulator is provided.Before using it, make sure everything is installed with:$ pip install cryocon[simulator]Thesinstrumentsengine 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.ymldevices:-class:CryoConname:cryo1transports:-type:tcpurl::5000-class:CryoConname:cryo2transports:-type:tcpurl::5001channels:A:unit:KB:unit:Kloops:1:source:Atype:MANdistc:4lockout:OFFremled:ONcontrol:OFFTo 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 typesinstruments-server --help)You can access it as you would a real hardware:$ nc localhost 5000
*IDN?
Cryo-con,24C,204683,1.01Aor using the library:$python>>>fromsockio.sioimportTCP# use synchronous socket in the CLI!>>>fromcryoconimportCryoCon>>>cryo=CryoCon(TCP('localhost',5000))>>>print(cryo.idn())Cryo-con,24C,204683,1.01Aor, since python 3.8, it is possible to launch a natively async REPL:$python-masyncio>>>fromsockio.aioimportTCP>>>fromcryoconimportCryoCon>>>cryo=CryoCon(TCP('localhost',5000))>>>print(awaitcryo.idn())Tango serverAtangodevice 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"(the above example usestangoctl. You would need
to install it withpip install tangoctlbefore using it. You are free to use any other
tango tool likefandangoor Jive)Launch the server with:$ CryoCon testTODOAddon_connection_madecallback to initialize controller with:unit=Kcache IDN, fw revision, hw revisionshould we cache system:name? and input:name? in theory in could be modified
directly with the hardware front panel