Hi Xie, here is a very simple example how to read data from a named pipe and fill a histogram within root (e.g. for DAQ monitoring). Maybe it is of general interest (a priori it is not clear that it works), therefore I forward to roottalk, too. (1) create the named pipe # mknod pipename p (2) another process must be filling the pipe e.g. by stdin/stdout # daq_producer > pipename This process can actually run on a different server # rexec hostname daq_producer > pipename (3) start your root session and execute a daq_consumer macro similar to the following (it is shortened, just to show the principle) { FILE *fp; Float_t x; Int_t i=0; ... // open named pipe fp = fopen("pipename","r"); // open memory mapped file mfile = TMapFile::Create("mapname","RECREATE", 100000, "T805 output"); mfile->Print(); // create histogram // the histo is then automatically in the mapfile hpx = new TH1F("hpx","SOM output",100,0,1); // read x ascii float data from the named pipe // fill x data (range [0,1]) into 1-D histogram while ( fscanf(fp,"%f",&x) != EOF ){ hpx->Fill(x); if (!(i % 10)) { mfile->Update(); } i++; } } (4) You can start another root session on a different computer and access the shared mapfile without disturbing the concurrent filling process { ... // open memory mapped file, read mode is default mfile = TMapFile::Create("mapname"); mfile->Print(); mfile->ls(); // hpx is visible ... ... } and that's it. The (maybe obvious) advantages of using root for such purposes are given by * several root sessions can look at the same data at the same time * each DAQ online user can choose his favourite platform (among the root distribution platforms) Bye, soeren ------------------------------------------------------------------ Soeren.Lange@cern.ch http://tmubsun.center.metro-u.ac.jp/soeren CERN EP Bat. 892 2-A05 Phone +41-22-76-76441 CH-1211 Geneve 23 Fax +41-22-76-77910 ------------------------------------------------------------------
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:36 MET