Skip to content

Getting Started

zjwall edited this page Mar 6, 2024 · 32 revisions

LabRAD Manager

The LabRAD Manager facilitates communication between servers (typically a wrapper for some device) and clients (typically a GUI or experimental script). Only one LabRAD Manager needs to run per experiment, but multiple managers can be run on multiple computers if desired (clients can choose which manager to register with on startup). When a server file is executed, it registers with the manager, allowing the manager access to all of the functions it contains. Clients, also register with the manager, giving them access to all server functions (on all running servers) that are registered. If you already have a running manager you want to communicate with, you only need to install the Python API, pylabrad, allowing you to write servers and clients in Python that can communicate with the manager. If that is the case proceed to the pylabrad section. If you'd like to install a manager, continue below.

LabRAD Manager installation

This guide explains how to install the LabRad Manager on a Windows 10 operating system as of 6/7/2020 (Last Updated 7/27/2023). First, every computer should contain a folder named "Code" in the home directory of the computer you're installing LabRAD on (barium exp only). If you don't have one, create it. The latest version of the manager is written in Scala, and binary distributions are kept on github. Download the most recent version (0.8.3 in this example) and extract all the files to the code folder.

Next you'll need to download and install Java 8 (64-bit). After installation you MUST restart your computer.

Next, try to run the LabRad Manager in a Windows Command Prompt. Why? If something doesn't work the error will print in the command prompt window. The easiest way to do this is by first opening a Windows File Explorer and navigating to the "bin" folder located in the "scalbrad-0.8.3" folder. In the location bar of the Windows file explorer, type "cmd" and press the Enter key. A new Command Prompt window should open. Type the name of the executable file "labrad.bat" in the window and press enter. If things work, then about a dozen lines of code print out, and somewhere you should see "now accepting LabRAD connections" in the last few lines:

18:26:51.833 [main] INFO  org.labrad.manager.Listener - now accepting labrad connections: port=7682, tlsPolicy=STARTTLS
18:26:51.834 [main] INFO  org.labrad.manager.Listener - now accepting labrad connections: port=7643, tlsPolicy=ON

If the "JAVA_HOME" environment variable could not be set correctly, you will get the following error:

'C:\Program' is not recognized as an internal or external command,
operable program or batch file.

To fix the error, create a new SYSTEM environment variable called "JAVA_HOME", and set the value to the installation folder: (note it may be in a different folder or named with a different version so check after the installation of java)

C:\Program Files (x86)\Java\jre1.8.0_251

You must open a new Command Prompt for the added variable to take effect. Try to run the "labrad.bat" command again to verify the problem has been fixed. If you are still experiencing trouble, please contact someone in the barium lab.

Environment Variables

LabRAD uses various environment variables to store useful information. You will need to set these before you go any further.

  1. LABRAD_TLS: Transport Layer Security (TLS) is a security protocol to encrypt information sent over the internet. LabRAD versions greater than 0.5.0 support using TLS to secure connections to LabRAD. Older LabRAD clients may have issues with the new protocol, and this feature can be turned off by starting the manager with the flag

    --tls-required=false.

    In our lab we set this variable to "off", and start the manager with the above flag.

  2. LABRAD_TLS_PORT: The port to use for TLS. We set this to "7643"

  3. LABRADNODE: The LabRAD node variable should always be set to the name of your computer. Every computer acts as a node in the sense that devices plugged in to i can be accessed by a LabRAD manager, even if the manager is running on a different machine.

  4. LABRAD_HOST: The LabRAD host defines which manager your servers should register with, or put another way, which manager to give access to your node. If the manager your giving access to is running on your computer, the variable is always set to "localhost". Otherwise, it should be set to the name of the computer with running the manager you want to give access to.

  5. LABRADPASSWORD: The LabRAD password gives a basic level of security for accessing the web client. When a new browser tries to connect to the manager, this password will be required. In the barium lab, every password is set to 'lab'. The client is a bit strange in that it always asks for a username and password when logging in. We never set a username, so leave that field blank when logging in. In addition, if you don't set a password, leave both fields blank and click "login" to access the client. Using the enter key doesn't work.

  6. LABRADPORT: This is the port LabRAD uses for connections over the network. It is always set to "7682".

Setting these is fairly straight forward, and lots of internet tutorials can tell you how. For Windows users the following Python script set_env.py can be used, but make sure to edit the file for your specifics. Download the file into the "code" folder, and then use a Windows File Explorer to start a command prompt there. Use the following command to run the script:

python set_env.py

After check to make sure the variable were properly set.

Also add the PYTHONPATH variable to the user variables, C:\Users\uclab\Code

LabRAD Web Interface

In order to view and manage connections to the LabRAD manager you use the LabRAD web interface. This is also written in Scala, and is designed to work with Google Chrome. Currently, there is a know issue, where Chrome versions 80.0 and greater do not properly display the manager interface. To get around this download Chromium Version 79.0.3945.0 (Developer Build) (64-bit) and use this to access the web interface.download

Use a Windows File Explorer and navigate to the "Code\scalabrad-web-server-2.0.6\bin" folder. Double click on the "labrad-web.bat" file to start the webserver. A terminal window should open and you should see the line:

now serving at http://localhost:7667

Now open your < 80.0 version Chrome browser and enter the above address. You should see a log in screen:

If you set a password using the environment variable enter it, and leave the username blank. You have to click on "login with password" to actually login. If you didn't set a password leave both fields blank and click the "login with password". You should now have access to the web interface.

pylabrad

First download and install the most recent version of python. Next it is necessary to install the pylabrad module, copy the file titled Labrad from the github and paste it into the site-packages repository of the python install. Typically this can be found in C:\Users\barium133\AppData\Local\Programs\Python\Python39\Lib\site-packages.

You will also need to install the necessary python dependencies:

  1. numpy
  2. Future
  3. Requests
  4. pyQt5
  5. Twisted
  6. pyparser
  7. pywin32
  8. pyOpenSSL
  9. service_identity
  10. qt5

Once this is complete open a command prompt with ipython, and run import labrad. It should compile without errors. Then in a new command prompt run py -m labrad.node. This will start the labrad node from here you can begin running labrad servers and clients. Note if import labrad is not working makesure the labrad file is in Code file.

Clone this wiki locally