Remote network interface to a ROOT session

Hi everyone,

I work with Labview data acquisition system (DAQ), but I want to use ROOT for data analysis. The DAQ writes large amounts of data so I prefer to write ROOT files directly (instead of writing some text files, e.g. XML, and then converting them).
Additionally, the data format is very complex/flexible requiring some level of flexibility also on the data writing side. The DAQ runs on a Windows machine.

Here are my attempts to implement the solution, I hope that someone can help me further:

  1. It seem to be beyond my capabilities to implement ROOT-file writing directly on the Labview side

  2. I tried to call Python from Labview (some libraries exist) and from there PyROOT. The combination did not really work…

  3. I wrote a dll called from Labvew. The functions of dll performed data interface to a ROOT session (started within the dll) and the ROOT file writing. It was a pain to debug it, but it worked. The main issue was non-flexibility, the data structure was hardwired in the dll. Also, I am forced to run 64bit Labview, but ROOT on windows (version 5) is only 32bit, So I cannot compile a 64bit dll library (required by Labview)

  4. Now I am thinking about a more general client-server solution. The Labview would be a client communicating over network (TCP/IP) with a “ROOT server”. The server would be a standalone application interfacing the TCP communication (string commands) with CINT or Cling session by gROOT->Processline(). The communication would allow to pass general string commands to the ROOT interpreter. Some specialized commands would allow to pass data back and forth. Such a server would be a great tool for interfacing ROOT with any other general application, not only Labview. So maybe a useful tool for the ROOT community (?)

I have rather good idea of how to implement the server, but I still have a feeling that there may be some solution existing already. However, none of the network communication classes in ROOT seem to do what I want (or at least I was unable to decode the communication protocol). Does anyone see a simpler solution here? I would even accept to run the server on a Linux machine…

Thank you!

Hi,

Probably you can use THttpServer class.
It provides easy possibility to execute arbitrary commands.
And you can invoke ProcessLine inside your commands.

See: https://root.cern.ch/root/htmldoc/guides/HttpServer/HttpServer.html#commands-execution
Example: tutotials/http/httpcontrol.C

Regards,
Sergey

Dear Sergey,

this is an interesting idea, thank you!
However, do you see an option to also transport data via network to and
from the ROOT session in this way?

Thank you!

Oldrich

Hi Oldrich,

However, do you see an option to also transport data via network to and
from the ROOT session in this way?

It depends how much you want to transport.
THttpServer provides easy way to request different kind of data from ROOT application through http protocol.
One needs very simple user code for that (or sometimes no any additional code at all).

But to submit large data amounts from client to ROOT application requires some extra work.
One needs to handle special kind of http requests (so-called POST requests), which may contain binary data inside.

And you should not forget, that http could have significant latency while for every new requests connection should be established. It most probably fail if you will try to submit 100K requests per seconds.

One could try to use websockets, but this even more work, especially with ROOT5 which you seems to be using.

Regards,
Sergey

that’s typically the kind of thing for which a Go-based server would probably shine: exposing websockets end-points and (for https) reduced latency HTTP/2 end-points (b/c it’s binary!) is the forte of Go.

(and it could work on windows, linux, macOS)

here is an example of a little web server written in Go that uses websockets to push data to the client:

(I have also a more sophisticated application with web-components, polymer-1.5, Go, etc… for the slow-control of a testbench for LSST)

Yes, websocket is most optimal solution in terms of performance and latency.
But usable interface for websockets handling with THttpServer was introduced first in ROOT 6.10

Hi Oldrich,

What are “large amounts of data” - Terabytes per hour?

Axel.

Hi Axel,

I am planning to transfer ~10 GB / hour.

Oldrich

Fine, that’s 22MBit/second. I’d say a TSocket should be more appropriate, also to get the data off the Labview machine, moving the actual data processing possibly even into a different machine.

@pcanal - what do you recommend? Do we have a tutorial of TSocket?

There are tutorials in $ROOTSYS/tutorials/net, in particular the pair tutorials/net/hserv.C, tutorials/net/hclient.C

Axel, pcanal,
thank you!

I saw the networking functionality before, but I am not sure how to use it with non-ROOT client. From the tutorials I understand how two ROOT sessions can communicate, sending even ROOT objects. However, I do not see how to write appropriate Labview client, i.e., what would be the low-level data structure to be sent so that the ROOT server accepts it? I need to send simple data types (string, integers, …) and possibly 1D arrays of simple data types.

Hi,

Right, so then this boils down to the question “how do I get data from labview to ROOT”. I suppose you have solved that already, as you mentioned the DLL. Can labview stream data over the network? If not, write a DLL that does it. Set up a program on the other side that picks up that data stream. So far no ROOT - because the data format is defined by labview. Then ROOT can “take over” :slight_smile: Would that make sense?

Cheers, Axel.

Hi Axel,

yes, this makes sense, and I should be able to do that. Though I was hoping that there already is some interface of ROOT to outside. I will also check the websocket options proposed above.

Thank you!

Hi,

22 Mbit/s is not that big for local communications.
If you search for simple solution - try to use basic THttpServer functionality
It allow to execute any object method and can returns arbitrary data in JSON form.

Just implement ROOT object, which buffers your data internally and can return them with function like GetNextDataPortion(). If you register such object to the THttpServer, you can regularly request such data with HTTP request like: http://localhost:port/objname/exe.json?method=GetNextDataPortion()

Like this link returns object title:

https://root.cern/js/latest/httpserver.C/Files/job1.root/hpxpy/exe.json?method=GetTitle

If method returns string - you will get JSON string, or JSON array if returning array, or just object.

Regards,
Sergey

P.S. websocket is more complex than plain TSocket and not good documented.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.