MCA Data Server Reference

wxMCA Package

Introduction

MDS Description

Supported Devices

Counter

MCA-1K

MCA-2K

MCA-3K

eMorpho

Application Examples

Code Examples

MCA Server

Summary

The MCA-3K Server (mca_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 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, the ARM controller has immediate access to the device settings stored in the ARM non-volatile memory and no further steps are necessary. In the MCA-3K devices, which have an FPGA, the ARM controllare will load the applicable settings into the FPGA RAM.

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

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-3K 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".