Subversion Repositories f9daq

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
111 f9daq 1
// By ROOT version 5.17/02 on 2008-03-13 06:46:41
2
 
3
#ifndef ROOT_TGDockableFrame
4
#include "TGDockableFrame.h"
5
#endif
6
#ifndef ROOT_TGMenu
7
#include "TGMenu.h"
8
#endif
9
#ifndef ROOT_TGMdiDecorFrame
10
#include "TGMdiDecorFrame.h"
11
#endif
12
#ifndef ROOT_TG3DLine
13
#include "TG3DLine.h"
14
#endif
15
#ifndef ROOT_TGMdiFrame
16
#include "TGMdiFrame.h"
17
#endif
18
#ifndef ROOT_TGMdiMainFrame
19
#include "TGMdiMainFrame.h"
20
#endif
21
//#ifndef ROOT_TGuiBldHintsButton
22
//#include "TGuiBldHintsButton.h"
23
//#endif
24
#ifndef ROOT_TGMdiMenu
25
#include "TGMdiMenu.h"
26
#endif
27
#ifndef ROOT_TGListBox
28
#include "TGListBox.h"
29
#endif
30
#ifndef ROOT_TGNumberEntry
31
#include "TGNumberEntry.h"
32
#endif
33
#ifndef ROOT_TGScrollBar
34
#include "TGScrollBar.h"
35
#endif
36
//#ifndef ROOT_TGuiBldHintsEditor
37
//#include "TGuiBldHintsEditor.h"
38
//#endif
39
#ifndef ROOT_TRootBrowser
40
#include "TRootBrowser.h"
41
#endif
42
#ifndef ROOT_TGFrame
43
#include "TGFrame.h"
44
#endif
45
#ifndef ROOT_TGFileDialog
46
#include "TGFileDialog.h"
47
#endif
48
#ifndef ROOT_TGShutter
49
#include "TGShutter.h"
50
#endif
51
#ifndef ROOT_TGButtonGroup
52
#include "TGButtonGroup.h"
53
#endif
54
#ifndef ROOT_TGCanvas
55
#include "TGCanvas.h"
56
#endif
57
#ifndef ROOT_TGFSContainer
58
#include "TGFSContainer.h"
59
#endif
60
#ifndef ROOT_TGButton
61
#include "TGButton.h"
62
#endif
63
//#ifndef ROOT_TGuiBldEditor
64
//#include "TGuiBldEditor.h"
65
//#endif
66
#ifndef ROOT_TGTextEdit
67
#include "TGTextEdit.h"
68
#endif
69
#ifndef ROOT_TGFSComboBox
70
#include "TGFSComboBox.h"
71
#endif
72
#ifndef ROOT_TGLabel
73
#include "TGLabel.h"
74
#endif
75
#ifndef ROOT_TGView
76
#include "TGView.h"
77
#endif
78
//#ifndef ROOT_TRootGuiBuilder
79
//#include "TRootGuiBuilder.h"
80
//#endif
81
#ifndef ROOT_TGTab
82
#include "TGTab.h"
83
#endif
84
#ifndef ROOT_TGListView
85
#include "TGListView.h"
86
#endif
87
#ifndef ROOT_TGSplitter
88
#include "TGSplitter.h"
89
#endif
90
#ifndef ROOT_TGStatusBar
91
#include "TGStatusBar.h"
92
#endif
93
#ifndef ROOT_TGListTree
94
#include "TGListTree.h"
95
#endif
96
#ifndef ROOT_TGToolTip
97
#include "TGToolTip.h"
98
#endif
99
#ifndef ROOT_TGToolBar
100
#include "TGToolBar.h"
101
#endif
102
#ifndef ROOT_TRootEmbeddedCanvas
103
#include "TRootEmbeddedCanvas.h"
104
#endif
105
#ifndef ROOT_TCanvas
106
#include "TCanvas.h"
107
#endif
108
//#ifndef ROOT_TGuiBldDragManager
109
//#include "TGuiBldDragManager.h"
110
//#endif
111
 
112
#include "Riostream.h"
113
#include "TThread.h"
114
#include "TApplication.h"
115
#include "TROOT.h"
116
#include "TGraph.h"
117
#include "TStyle.h"
118
#include "TH1F.h"
119
#include "daq.h"
120
 
121
TGTextButton   *gTextButton[10];
122
TCanvas        *fCanvas;
123
TGMainFrame    *fMain;
124
TGTextEntry    *gFilename;
125
TGNumberEntry  *gThreshold;
126
TGNumberEntry  *gTimeSet;
127
TRootEmbeddedCanvas *gCanvas;
128
TH1F* gHisto;
129
 
130
daq * gDaq;
131
//----------------------------------------------------
132
 
133
void MyEventHandler(int i){
134
 char fname[200];
135
  switch (i) {
136
  case 0: // init
137
    gDaq->init();
138
    break;
139
  case 1: // start
140
    gDaq->start((int) gThreshold->GetNumber(),(int) gTimeSet->GetNumber() );
141
    break;
142
  case 2: // count
143
    gDaq->count();
144
    if (!gHisto) gHisto=new TH1F("h0","h0;Stevilka kanala;Stevilo zadetkov",16,0.5,16.5);
145
    if (gHisto) {
146
      for (int i=0;i<16;i++) gHisto->SetBinContent(i+1,gDaq->gData[i]);
147
      gCanvas->GetCanvas()->cd();
148
      gHisto->Draw();
149
      gHisto->Draw("text same");
150
      gCanvas->GetCanvas()->Modified();
151
      gCanvas->GetCanvas()->Update();
152
      printf("Vsota kanalov=%d\n",(int) gHisto->GetSum());
153
    }
154
    break;
155
  case 3: // save
156
    gDaq->save();
157
    break;
158
  case 4: // append
159
    sprintf ( fname,"%s",gFilename->GetText());
160
    gDaq->append(fname);
161
    break;
162
  case 5: // save
163
    gCanvas->GetCanvas()->SaveAs("uklonski_poskus.pdf");
164
    break;
165
  case 6: // exit
166
    gApplication->Terminate(0);
167
    break;
168
  }
169
}
170
 
171
//----------------------------------------------------
172
 
173
int gui(){
174
 
175
  gDaq= new daq();
176
  fMain = new TGMainFrame(0,800,800);
177
  TGHorizontalFrame *fH=new TGHorizontalFrame(fMain,800,400);
178
  //------------------------------------------------------------
179
  TGLayoutHints *f0= new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2);
180
  TGLayoutHints *layout2= new TGLayoutHints(kLHintsLeft | kLHintsTop,20,20,20,20);
181
 
182
 
183
  // gumbi
184
 
185
  int nbut=7;
186
  const char *names[10]={"Inicializacija","Start","Prestej","Shrani","Dodaj v datoteko", "Natisni" , "Konec"};
187
  for (int i=0;i<nbut;i++){
188
 
189
    gTextButton[i]= new TGTextButton(fH, names[i]);
190
    gTextButton[i]->SetTextJustify(36);
191
    gTextButton[i]->SetMargins(0,0,0,0);
192
    gTextButton[i]->SetWrapLength(-1);
193
    gTextButton[i]->Resize(50,22);
194
    fH->AddFrame(gTextButton[i], layout2);
195
    char cmd[50];
196
    sprintf(cmd,"MyEventHandler(=%d)",i);
197
    TQObject::Connect(gTextButton[i],"Clicked()",0,0,cmd);
198
  }
199
  fMain->AddFrame(fH    , f0);
200
  //---------------------------------------------------------
201
  // inputi
202
  fH=new TGHorizontalFrame(fMain,800,200);
203
 
204
  TGLabel *lab1 = new TGLabel( fH ,"Ime datoteke:");
205
  fH->AddFrame(lab1, f0);
206
  gFilename =  new TGTextEntry( fH,"datoteka.txt");
207
  fH->AddFrame(gFilename, f0);
208
 
209
  TGLabel *lab2 = new TGLabel( fH ,"Nivo prozenja (mV):");
210
  fH->AddFrame(lab2, f0);
211
  gThreshold =  new TGNumberEntry( fH,250);
212
  fH->AddFrame(gThreshold, f0);
213
  lab2 = new TGLabel( fH ,"Cas meritve (ms):");
214
  fH->AddFrame(lab2, f0);
215
  gTimeSet =  new TGNumberEntry( fH,1000);
216
  fH->AddFrame(gTimeSet, f0);
217
 
218
  fMain->AddFrame(fH    , f0);
219
  //---------------------------------------------------------
220
  // canvas
221
  fH=new TGHorizontalFrame(fMain,800,200);
222
  gCanvas = new TRootEmbeddedCanvas ("gCanvas",fH,800,400);
223
  fH->AddFrame(gCanvas, f0);
224
  fMain->AddFrame(fH   , f0);
225
 
226
 
227
  fMain->SetWindowName("Praktikum IV Uklonski poskus");
228
  fMain->MapSubwindows();
229
  fMain->Resize(fMain->GetDefaultSize());
230
  fMain->MapWindow();
231
  gStyle->SetOptStat(11111111);
232
  return 0;
233
}