Hi,
I'm totally new to ROOT and I plan to use it to develop a program for
data-aquisition. For that the data display should be updated whenever
new data are available (rate: few/s to 1/10s).
The problem: the display should not be locked then i.e. it should be
possible to change ranges etc.
Is that possible - and how?
I made some tests by changing the samplemacro 'conditions' (see changed
part of the code below). But at the line ' h1->Draw(); ' it crashes with
'***break*** segmentation violation'.
Can anybody help?
Many thanks in advance,
Peter
--
part of modified 'conditions.cxx' :
....
/////////////////////////////////////////////
// functions used within second thread:
void *thread2(void *ptr)
{
Int_t count = 0;
Int_t meid=2;
Int_t n = 20;
Int_t wait=0;
Double_t x[n], y[n], x1[n], y1[n];
meid=TThread::SelfId();
TThread::CleanUpPush((void*) &clean2, (void*) NULL);
TThread::SetCancelOn(); // enable cancellation from thread1
TThread::SetCancelDeferred();
for (Int_t i=0;i<n;i++){
x[i]=i*0.5;
y[i]=5*cos(x[i]);
x1[i]=i*0.5;
y1[i]=5*sin(x[i]);
}
cout << "hier thread2 a" << endl;
TThread::Lock();
cout << "hier thread2 b" << endl;
TCanvas *c1 =new TCanvas("c1","graphtest",200,10,600,400);
cout << "hier thread2 c" << endl;
TH2D *h1 = new TH2D("h1","titelll",30,0,15,30,-2,5);
cout << "hier thread2 d" << endl;
cout << "hier thread2 e" << endl;
TGraph *gr1 = new TGraph(n,x,y);
cout << "hier thread2 f" << endl;
gr1->Draw("AL");
cout << "hier thread2 g" << endl;
c1->Update();
TThread::UnLock();
while(1) {
for (Int_t i=0;i<n;i++){
x[i]=i*0.5;
y[i]=5*cos(x[i]+count*0.1);
x1[i]=i*0.5;
y1[i]=5*sin(x[i]+count*0.1);
}
delete gr1;
TGraph *gr1 = new TGraph(n,x,y);
gr1->Draw("L");
c1->Update();
myCondition.Wait();
gSystem->Sleep(1000*count); // increase time to induce thread1
timeout..
myAckn.Signal(); //acknowledge myCondition
count++; // counter for correctly received conditions
cout << "\n\tthread2 "<<meid << ": got myCondition!
count:"<<count <<endl;
}
}
void clean2(void* arg)
{
// demonstrates cleanup stack
// this function will _not_ be executed if thread 2 is cancelled
cout << "\n## thread2 cleanup function"<<endl;
}
./////////////////////////////////////////////
// functions used within second thread:
void *thread2(void *ptr)
{
Int_t count = 0;
Int_t meid=2;
Int_t n = 20;
Int_t wait=0;
Double_t x[n], y[n], x1[n], y1[n];
meid=TThread::SelfId();
TThread::CleanUpPush((void*) &clean2, (void*) NULL);
TThread::SetCancelOn(); // enable cancellation from thread1
TThread::SetCancelDeferred();
for (Int_t i=0;i<n;i++){
x[i]=i*0.5;
y[i]=5*cos(x[i]);
x1[i]=i*0.5;
y1[i]=5*sin(x[i]);
}
cout << "hier thread2 a" << endl;
TThread::Lock();
cout << "hier thread2 b" << endl;
TCanvas *c1 =new TCanvas("c1","graphtest",200,10,600,400);
cout << "hier thread2 c" << endl;
TH2D *h1 = new TH2D("h1","titelll",30,0,15,30,-2,5);
cout << "hier thread2 d" << endl;
h1->Draw();
cout << "hier thread2 e" << endl;
TGraph *gr1 = new TGraph(n,x,y);
cout << "hier thread2 f" << endl;
gr1->Draw("AL");
cout << "hier thread2 g" << endl;
c1->Update();
TThread::UnLock();
while(1) {
for (Int_t i=0;i<n;i++){
x[i]=i*0.5;
y[i]=5*cos(x[i]+count*0.1);
x1[i]=i*0.5;
y1[i]=5*sin(x[i]+count*0.1);
}
delete gr1;
TGraph *gr1 = new TGraph(n,x,y);
gr1->Draw("L");
c1->Update();
myCondition.Wait();
gSystem->Sleep(1000*count); // increase time to induce thread1
timeout..
myAckn.Signal(); //acknowledge myCondition
count++; // counter for correctly received conditions
cout << "\n\tthread2 "<<meid << ": got myCondition!
count:"<<count <<endl;
}
}
void clean2(void* arg)
{
// demonstrates cleanup stack
// this function will _not_ be executed if thread 2 is cancelled
cout << "\n## thread2 cleanup function"<<endl;
}
....
_________________________________________________
Peter Christ
Max-Planck-Institut für Physik
(Werner-Heisenberg-Institut)
email: christ@mppmu.mpg.de
_________________________________________________
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:02 MET