Re: [ROOT] using TTimer

From: Ivan Storgaard Vogelius (ivansv@ifa.au.dk)
Date: Thu May 10 2001 - 16:59:27 MEST


	Hi!
	We use the MBS-data acq. system from GSI, so its not any of the
root-objects. Some cuts from the code, in case somebody using the same
system knows what to do (rereading the code, I think the delay may only
be in the data transfer, but the effect is the same): 
      iStatus =buf->RevStatus (iOut);
      pSocket = buf->RevOpen (pcNode, iPort, iEvt);  //Open the connection
      iStatus = buf->RevStatus (iOut); 
      if (!pSocket) return 8; 
      pClock.Start(kTRUE); 
      time3=pClock.GetRealTime();  //set start time for buffer read
      for (;;)  // buffer loop
      {
	gSystem->ProcessEvents(); 
         if (ii > 0) ifl = 0;  // skip buffer only once per request
         piEvent = buf->RevGetI (pSocket, ifl);  // Reads event, ptr->nxt
         iStatus = buf->RevStatus (iOut); 
         if (!piEvent) 
         {
	   gSystem->ProcessEvents(); 
            pClock.Stop(); 
            if (iStatus == 3)  // currently no events from DAQ
            {                  //should pass here when no data
	      gSystem->ProcessEvents(); 
               ifl = 0;  // new buffer, needs not be specified
               continue;

As you see Ive more than plenty gSystem commands... In case somebody have
solved the problem already, give me a hint - otherwise I guess I have to
read mbs-manuals again.

	Ivan


On Mon, 7 May 2001, Fons Rademakers wrote:

> How are you waiting to for the server? With a TMonitor?
> 
> --Fons
> 
> 
> Ivan Storgaard Vogelius wrote:
> > 
> > Hmmm
> >         I have a problem then:
> > The programme waits on a line for a server to send a buffer, and while
> > that happens it obviously doesnt come by the gSystem->ProcessEvents()
> > lines, which means that I can interact with the canvas, but it is quite
> > annoying with sometimes very long breaks. Any Idea to get around that?
> >         Ivan
> > 
> > On Mon, 7 May 2001, Fons Rademakers wrote:
> > 
> > > Hi Ivan,
> > >
> > >   synchronous timers are only processed when the program processes
> > > events via gSystem->ProcessEvents(). So in your case there is a
> > > chicken and the egg problem. Best is just to regularly in your
> > > canvas update loop to call gSystem->ProcessEvents() or if you
> > > want it to be timer driven use an a-synch timer TProcessEventTimer
> > > (via TSystem.h) and for its use check TTreePlayer.cxx (see:
> > > http://root.cern.ch/lxr/source/treeplayer/src/TTreePlayer.cxx#1095)
> > >
> > >
> > > Cheers, Fons.
> > >
> > >
> > > Ivan Storgaard Vogelius wrote:
> > > >
> > > > Hi!
> > > >         I want to create a TTimer to update interactions with canvas
> > > > regularly. I tried to do the following:
> > > >   TTimer *timer= new TTimer(500, kTRUE);
> > > >   timer->SetCommand("gSystem->ProcessEvents()");
> > > >   timer->TurnOn();
> > > >
> > > > But It causes the programme to crash(in CINT or compiled). How should it
> > > > be done?
> > > >
> > > >         Thanks
> > > >         Ivan
> > >
> > > --
> > > Org:    CERN, European Laboratory for Particle Physics.
> > > Mail:   1211 Geneve 23, Switzerland
> > > E-Mail: Fons.Rademakers@cern.ch              Phone: +41 22 7679248
> > > WWW:    http://root.cern.ch/~rdm/            Fax:   +41 22 7677910
> > >
> 
> -- 
> Org:    CERN, European Laboratory for Particle Physics.
> Mail:   1211 Geneve 23, Switzerland
> E-Mail: Fons.Rademakers@cern.ch              Phone: +41 22 7679248
> WWW:    http://root.cern.ch/~rdm/            Fax:   +41 22 7677910
> 



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:44 MET