Node Server - syue99/Lab_control GitHub Wiki

Introduction

An advanced experiment requires use of multiple concurrently running LabRAD servers. To help manage the complexity, it is convenient to be able to easily start all of the required servers and to be able to restart or stop them. This functionality is provided by the node server. One node server should run on every computer used in the experiment, facilitating starting and stopping other servers running on that machine.

Starting the node

The node server is started with the command

twistd -n labradnode

Then the node server should then appear in the list of running servers of the Manager. The node server should never need to be restarted. Even if the Manager is restarted, the node server will reconnect automatically.

Executable file

On Windows you can create a file that runs "twistd -n labradnode". To do this open a basic text file. Put

twistd -n labradnode

on the first line. Then save the file with a name such as "start labradnode" and make the ending .bat. Files that end in .bat in Windows sequentially try and run each line on effectively the command prompt, so double click "start labradnode.bat" should startup the node client.

On Windows, we explicitly specify the path to twistd.py:

python C:\Python27\Scripts\twistd.py -n labradnode

On the Mac if you followed the installation instructions, use:

twistd-2.7 -n labradnode

Using the node server

First, we need to provide the node server with a list of directories to scan for launchable servers.The list of scanned directories for each node is set list of strings in the Registry under the key directories in /Node/node-name/. The Node Server looks for launchable servers by scanning a list of directories from .ini files and any .py files containing the expected Node Header. These are the default scanned extensions and may also be changed in the registry.

The list of launchable servers can be checked by calling.

node.available_servers()

If a server appears among the available servers, it can be launched with the method

node.start()

Try starting the Python Test Server by running ```node.start('Python Test Server'). Once the server is started, it should be appear in the list of running servers:

running = node.running_servers()

The servers can also be stopped. For example to stop the Python Test Server, use

node.stop('Python Test Server')

In order to easily start all of the required servers, one could use a simple LabRAD script iterating over which servers should be started.

Node Header

The node header is a text entry that provides the node with the information about the server including how the server can be launched. For an example of a node header, see the /serialdevices/serial_server.py. A detailed description of the node header is provided in site-packages/labrad/node/launchable-server.ini.

Caveats

There is an error message on startup .Could not flatten 'LABRADNODE' to _. This is a known bug and does not harm the functionality in any way.

Advanced Description

The problem turns out to be related to type parsing. It occurs on the line

dispatcher.send('status', servers=self.status())

where self.status() is a list of tuples [tuple_a, tuple_b, ...] where the tuple_a[4] is cls.environVars. This item can either be an empty list [], or a list of strings i.e ['LABRADNODE']

The issue with type parsing is that the type returned by labrad.types.getType for this object has '_' for the cls.environVars entry and then ['LABRADNODE'] can't be flattened to '_'.

Not sure what the expected functionality is for such a case. Should the node server return [''] instead of [], or is this a bug in labrad.types.getType? Right nowgetType(['str', None']) returns *s but getType([None, 'str']) returns *_

Back to Main Wiki

⚠️ **GitHub.com Fallback** ⚠️