Dear Stefano Please try to build and learn $ROOTSYS/test/Aclock.cxx class. It is a good example of how TTImer class can be used. I wonder you can use the approach this class employs. With my regards, Valeri ----- Original Message ----- From: Stefano Argiro` <argiro@to.infn.it> To: <roottalk@pcroot.cern.ch> Sent: 13 марта 2001 г. 3:47 Subject: [ROOT] questions on TApplication's and TTimer's > > Hi, > > I would like to use a TTimer in a DAQ that has to read data every > 20 seconds. For this purpose I have implemented a class called, > say, Readout:public TObject{} with methods, Start() , Stop(), > ForceReadout() and overriding HandleTimer(). > > Class Readout has a TApplication as a data member, and upon Start() > TApplication::Run() is called. > Soon I realized that, after calling Start(), the event loop is started, > and I cannot communicate anymore with the class: I cannot tell it to > Stop() not to ForceReadout(). > > Is there a solution to this ? Will the signal/slot mechanism do it > (right now we are still using v2.25) ? > > Thanks > > I enclose an outline of the code. > > //////////////////////////////////////////// > class Readout:public TObject{ > private: > TApplication ftheApplication; > Int_t fEvents; // number of events > ... > > public: > Readout(); > void ForceReadout() > Bool_t HandleTimer(TTimer *timer); > void Start(); > void Stop(); > Int_t GetEvents() {return fEvents;}; > > }; > > Readout::Readout(){ > > ftheApplication = new TApplication("",&arc,argv,NULL,0); > ... > } > > void Readout::ForceReadout(){ > > // do the readout ... > > } > > void Readout::HandleTimer(TTimer *timer){ > // do the readout , save etc.... > } > > void Readout::Start(){ > TTimer * timer = new TTimer(this,20000); > timer->TurnOn(); > ftheApplication->Run(); > > return 0; > } > > Int_t CurrentMonitorRO::Stop(){ > > ftheApplication->Terminate(); > return 0; > } > ////////////////////////////////////////////////////////////////// > > int main(){ > > TROOT CMReadout("CMreadout","CM readout application"); > > Readout * readout = new CurrentMonitorRO(); > > readout->Start(); > > // of course it never gets here !! > if (readout->GetEvents() == 5) cout << "Done"<<endl; > return 0; > > } > > >
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:39 MET