MCA Data Server Reference

wxMCA Package

Introduction

Server interface

API layer

Driver layer

C-types to libusb0.1

Class constants

Supported Devices

Counter

MCA-1K

MCA-3K

eMorpho

Neutron-3K

MCA Server

Summary

The MCA Server (mca_server.py) is the recommended interface to the world. When using mca_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 mca_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".

For the MCA-1K devices and Counters, the ARM controller loads the device settings stored in the ARM non-volatile memory when the unit is powered up. In the MCA-3K and Neutron-3K devices, which have an FPGA, the ARM controller will also load the applicable settings into the FPGA RAM.

In the eMorpho, there is no ARM processor and the FPGA settings data are stored in an on-board non-volatile memory. In this case, the MDS has to read the contents of that memory and apply it to the FPGA in order to boot the eMorpho.

Server Operation

The server then enters an infinite loop listening to commands and processing them in the order received. Commands with a name of "mca_cmd" will be sent to mca_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 MCA Data Daemon (MDD), or a similar client agent, to manage the mca_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.

mca_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 MCA units; eg {'sn_list': ['1234xxx', '5678yyyy']}, where each serial number is 32 hex characters long.
exitForce the server to terminate. Before doing so, it will send back the message {"action": "exit"}
Commands to the service interface of the MCA Data Server.

Debugging

To test for interference of commands or other hard to trace bugs, the client can set mca_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".