eMorpho Data Server Reference

eMorpho

Introduction

USB driver

bpi_device

Data structures

Overview

Module Constants

Controls

Statistics

Results

Histogram

List Mode

Oscilloscope Trace

Summation Weights

Time Slices

Two-bank List Mode

API

Overview

Data Server

Overview

eMorpho Server

Summary

The eMorpho Server (emorpho_server.py) is the recommended interface to the world. When using emorpho_api.py directly, the client is bound to using the programming language Python and can avoid using TCP/IP and ZMQ as the protocol layer.

When using the emorpho_server.py the client gains network access via ZMQ and can now write their own code in over 40 different programming languages. Via ZMQ and network access, the MDS acts as a bridge between detectors on USB and the Internet. The server also acts a bridge between programming languages.

Server Start Up

On start up the server first reads some configuration data from "../rad_config/mds/mds_config.json". After that it boots all attached eMorpho units. This means the server transfers the content of the non-volatile memory from each unit into its fpga_ctrl registers. That way the detectors come alive with the last settings written to their nv-mem.

Server Operation

The server then enters an infinite loop listening to commands and processing them in the order received. Commands with a name of "em_cmd" will be sent to emorpho_api.process_cmd().

The server also has a service interface which responds to commands with a name of "server_cmd". The service interface is used by the Morpho Data Daemon (MDD), or a similar client agent, to manage the emorpho_server. The MDD can find out if the server is up and running, or if it has stalled or crashed. In that case, the MDD can kill an unresponsive server and spawn a new copy.

emorpho_server commands
CommandDescription
get_pidRespond with a json string of the form: {'version': '3.0', 'os': linux, 'pid': 5740}
ping Echo the data that were sent in the 'data' key of the command dictionary
helloReturn a json string with a list of the serial numbers of all attached eMorpho units; eg {'sn_list': ['eRC5000', 'eRC5001']}
exitForce the server to terminate. Before doing so, it will send back the message {"action": "exit"}
Commands to the emorpho server.

Debugging

To test for interference of commands or other hard to trace bugs, the client can set emorpho_server.MDS_DO_LOG to 1 or True. When this parameter is set, the MDS logs each incoming request and its own answer in a file named "log_path"+"mds_log.txt" where log_path points to the current director for logging data. Often that directory will be "../log/" and the logger data will reside in "../log/mds_log.txt".