Subversion Repositories f9daq

Compare Revisions

Ignore whitespace Rev 126 → Rev 127

/lab/sipmscan/trunk/windowed_test.C
66,6 → 66,12
void SetPosition();
void GetPosition();
void HomePosition();
 
void InitializeScope();
void StartScopeAcq();
void CustomScopeCommand();
void SelectedMeasType(int mtype);
 
void SaveFile();
void StartAcq();
 
101,6 → 107,7
double tdctimeconversion = 45.0909;
double lenconversion = 0.3595;
int oscOn;
const char *allMeasNames[11] = {"Amplitude","Area","Delay","Fall","Frequency","Maximum","Mean","Minimum","Peak-to-peak","Peak width","Rise"};
 
// ROOT file variable structure -----------
struct EventHeader {
119,9 → 126,17
int tdcdata[8];
} evtdata;
 
struct EventMeas {
double measdata;
} evtmeas;
 
TFile *inroot;
TFile *outroot;
 
// Test graphs for scope measurements
TCanvas *wCanvas;
TGraph *testgraph;
 
//---------------------------------------------------------------
// Global variables
 
134,6 → 149,7
TGNumberEntry *vHardlimit;
TGNumberEntry *NCH;
TGTextEntry *laserInfo;
TGNumberEntry *chtemp;
TGCheckButton *cleanOn;
 
TGTab *setTab;
197,6 → 213,16
TGNumberEntry *accError;
TGCheckButton *exfitplots;
 
//TGButtonGroup *sChangroup;
TGCheckButton *sCH[8];
TGComboBox *sMeasType;
TGCheckButton *sCamaclink;
TGTextEntry *scopeCommand;
TGTextEntry *scopeReturn;
TGTextButton *sendScopeCustom;
TGComboBox *sMeasgroup;
TGTextButton *scopeInit;
 
Bool_t firstrun = kTRUE;
Bool_t started;
Bool_t cleanPlots = kTRUE;
287,6 → 313,71
printf("Outfile (remove_from_last): %s\n", outname);
}
 
void SeqNumber(int innum, int maxnum, char *outstr)
{
int zeronum = 5;
 
// Check how many zeroes we need to add to get sequential numbers
if( (maxnum > 0) && (maxnum < 1000) )
zeronum = 2;
else if( (maxnum >= 1000) && (maxnum < 10000) )
zeronum = 3;
else if( (maxnum >= 10000) && (maxnum < 100000) )
zeronum = 4;
else if( (maxnum >= 100000) && (maxnum < 1000000) )
zeronum = 5;
 
// Make the sequence number depending on the number of zeroes
if(zeronum == 2)
{
if(innum < 10)
sprintf(outstr, "00%d", innum);
else if( (innum >= 10) && (innum < 100) )
sprintf(outstr, "0%d", innum);
else if( (innum >= 100) && (innum < 1000) )
sprintf(outstr, "%d", innum);
}
else if(zeronum == 3)
{
if(innum < 10)
sprintf(outstr, "000%d", innum);
else if( (innum >= 10) && (innum < 100) )
sprintf(outstr, "00%d", innum);
else if( (innum >= 100) && (innum < 1000) )
sprintf(outstr, "0%d", innum);
else if( (innum >= 1000) && (innum < 10000) )
sprintf(outstr, "%d", innum);
}
else if(zeronum == 4)
{
if(innum < 10)
sprintf(outstr, "0000%d", innum);
else if( (innum >= 10) && (innum < 100) )
sprintf(outstr, "000%d", innum);
else if( (innum >= 100) && (innum < 1000) )
sprintf(outstr, "00%d", innum);
else if( (innum >= 1000) && (innum < 10000) )
sprintf(outstr, "0%d", innum);
else if( (innum >= 10000) && (innum < 100000) )
sprintf(outstr, "%d", innum);
}
else if(zeronum == 5)
{
if(innum < 10)
sprintf(outstr, "00000%d", innum);
else if( (innum >= 10) && (innum < 100) )
sprintf(outstr, "0000%d", innum);
else if( (innum >= 100) && (innum < 1000) )
sprintf(outstr, "000%d", innum);
else if( (innum >= 1000) && (innum < 10000) )
sprintf(outstr, "00%d", innum);
else if( (innum >= 10000) && (innum < 100000) )
sprintf(outstr, "0%d", innum);
else if( (innum >= 100000) && (innum < 1000000) )
sprintf(outstr, "%d", innum);
}
}
 
// Peak detection function
int npeaks;
double FindPeaks(double *x, double *par)
385,7 → 476,6
int scopeState = -1;
char *IPaddr = (char*)oscIP->GetText();
int IPcorr = 0;
char buf[BSIZE];
 
if(oscOn == 0)
{
396,12 → 486,13
if( (IPaddr != NULL) && (IPcorr == 3) )
{
#if WORKSTAT == 'I'
#if WORKSTAT == 'I' || WORKSTAT == 'S'
printf("Connecting to oscilloscope.\n");
retTemp = gScopeDaq->connect(IPaddr);
scopeState = 1; // For testing instead of making a real connection
#else
scopeState = 1;
retTemp = 0;
#endif
}
else
410,39 → 501,70
printf("Please enter a valid scope IP address.\n");
}
}
else if(oscOn == 1)
else if(oscOn > 0)
{
#if WORKSTAT == 'I'
#if WORKSTAT == 'I' || WORKSTAT == 'S'
printf("Disconnecting from oscilloscope.\n");
retTemp = gScopeDaq->disconnect(IPaddr);
scopeState = -1; // For testing instead of making a real disconnection
#else
scopeState = -1;
retTemp = 0;
#endif
}
 
if(scopeState >= 0)
if(retTemp == 0)
{
setTab->SetEnabled(1, kTRUE);
setTab->SetEnabled(2, kTRUE);
oscIP->SetEnabled(kFALSE);
oscConnect->SetText("Disconnect");
oscConnect->SetTextJustify(36);
oscConnect->SetWrapLength(-1);
oscConnect->Resize(60,22);
oscOn = 1;
if(scopeState >= 0)
{
oscIP->SetEnabled(kFALSE);
oscConnect->SetText("Disconnect");
oscConnect->SetTextJustify(36);
oscConnect->SetWrapLength(-1);
oscConnect->Resize(60,22);
 
for(int i = 0; i < 8; i++)
{
sCH[i]->SetState(kButtonUp);
sCH[i]->SetEnabled(kFALSE);
}
sMeasType->SetEnabled(kTRUE);
sCamaclink->SetState(kButtonUp);
sCamaclink->SetEnabled(kFALSE);
scopeCommand->SetEnabled(kTRUE);
sendScopeCustom->SetEnabled(kTRUE);
sMeasgroup->SetEnabled(kFALSE);
scopeInit->SetEnabled(kFALSE);
oscOn = 1;
}
else
{
oscIP->SetEnabled(kTRUE);
oscConnect->SetText("Connect");
oscConnect->SetTextJustify(36);
oscConnect->SetWrapLength(-1);
oscConnect->Resize(60,22);
for(int i = 0; i < 8; i++)
{
sCH[i]->SetState(kButtonUp);
sCH[i]->SetEnabled(kFALSE);
}
sMeasType->Select(0);
sMeasType->SetEnabled(kFALSE);
sCamaclink->SetState(kButtonUp);
sCamaclink->SetEnabled(kFALSE);
scopeCommand->SetEnabled(kFALSE);
sendScopeCustom->SetEnabled(kFALSE);
sMeasgroup->SetEnabled(kFALSE);
scopeInit->SetEnabled(kFALSE);
oscOn = 0;
}
}
else
{
setTab->SetEnabled(1, kFALSE);
setTab->SetEnabled(2, kFALSE);
oscIP->SetEnabled(kTRUE);
oscConnect->SetText("Connect");
oscConnect->SetTextJustify(36);
oscConnect->SetWrapLength(-1);
oscConnect->Resize(60,22);
oscOn = 0;
}
printf("Error! Connecting/disconnecting failed.\n");
}
 
// Set the output voltage
633,6 → 755,195
#endif
}
 
// Initialize the currently connected scope for measurements
void TGAppMainFrame::InitializeScope()
{
int iTemp;
int chTemp[8];
for(int i = 0; i < 8; i++) chTemp[i] = -1;
gScopeDaq->scopeUseType = sMeasType->GetSelected();
 
// Check what channels are selected
iTemp = 0;
for(int i = 0; i < 8; i++)
{
if(sCH[i]->IsDown())
{
chTemp[iTemp] = i;
iTemp++;
}
}
if(iTemp == 0)
{
// If no channel is selected, we select the first one
chTemp[0] = 0;
iTemp++;
sCH[0]->SetState(kButtonDown);
}
// If measurement is used, only use the first selected channel
if(gScopeDaq->scopeUseType == 2)
{
for(int i = 1; i < iTemp; i++)
sCH[chTemp[i]]->SetState(kButtonUp);
iTemp = 1;
}
 
gScopeDaq->scopeChanNr = iTemp;
for(int i = 0; i < 8; i++) gScopeDaq->scopeChans[i] = chTemp[i];
 
// Check which measurement is selected
gScopeDaq->scopeMeasSel = sMeasgroup->GetSelected();
 
gScopeDaq->init();
}
 
// Run a scope measurement
void TGAppMainFrame::StartScopeAcq()
{
// Lock the scope front panel
gScopeDaq->lockunlock(true);
 
retTemp = gScopeDaq->event();
 
if(gScopeDaq->scopeUseType == 1)
{
char len[16];
int sval;
short *spoints;
 
if(retTemp == 0)
{
// Read the number of y bytes at beginning of CURVE binary data
memcpy(len, &gScopeDaq->eventbuf[1],1);
len[1] = 0;
sval = atoi(len);
// printf("Number of y bytes = %d\n", sval);
 
// Read the data
spoints = (short *)(&gScopeDaq->eventbuf[2+sval]);
// Read the number of data points
memcpy(len, &gScopeDaq->eventbuf[2],sval);
len[sval] = 0;
sval = atoi(len);
// printf("Number of data points = %d\n", sval/2);
 
double *grafx, *grafy;
grafx = new double[sval/2];
grafy = new double[sval/2];
// Parse data and graph it
for(int i = 0; i < sval/2; i++)
{
grafx[i] = i*gScopeDaq->tektime*10./(sval/2.);
grafy[i] = ((double)spoints[i]*5.*gScopeDaq->tekvolt/32767.) - (gScopeDaq->choffset*gScopeDaq->tekvolt);
}
wCanvas->cd();
testgraph = new TGraph(sval/2, grafx, grafy);
testgraph->GetXaxis()->SetTitle("Time [s]");
testgraph->GetXaxis()->SetRangeUser(grafx[0], grafx[(sval/2)-1]);
testgraph->GetYaxis()->SetTitle("Voltage [V]");
testgraph->Draw("AL");
wCanvas->Modified();
wCanvas->Update();
delete[] grafx;
delete[] grafy;
}
}
else if(gScopeDaq->scopeUseType == 2)
{
if(retTemp == 0)
{
if(gScopeDaq->measubuf < 1.e-4)
printf("Measurement: %le\n", gScopeDaq->measubuf);
else
printf("Measurement: %lf\n", gScopeDaq->measubuf);
}
}
 
// Unlock the scope front panel
gScopeDaq->lockunlock(false);
}
 
// Send a custom command to the scope
void TGAppMainFrame::CustomScopeCommand()
{
char *cmd = (char*)scopeCommand->GetText();
char ret[100000];
if( strchr(cmd, '?') == NULL)
{
printf("Sending command: %s\n", cmd);
#if WORKSTAT == 'I' || WORKSTAT == 'S'
gScopeDaq->customCommand(cmd, false, ret);
#endif
}
else
{
printf("Sending query: %s\n", cmd);
#if WORKSTAT == 'I' || WORKSTAT == 'S'
gScopeDaq->customCommand(cmd, true, ret);
#endif
}
 
#if WORKSTAT == 'I' || WORKSTAT == 'S'
scopeReturn->SetText(ret);
#endif
}
 
// When we select the measurement type, change other scope settings accordingly
void TGAppMainFrame::SelectedMeasType(int mtype)
{
// No waveform analysis
if(mtype == 0)
{
for(int i = 0; i < 8; i++)
{
sCH[i]->SetState(kButtonUp);
sCH[i]->SetEnabled(kFALSE);
}
sMeasType->SetEnabled(kTRUE);
sCamaclink->SetState(kButtonUp);
sCamaclink->SetEnabled(kFALSE);
scopeCommand->SetEnabled(kTRUE);
sendScopeCustom->SetEnabled(kTRUE);
sMeasgroup->SetEnabled(kFALSE);
scopeInit->SetEnabled(kFALSE);
oscOn = 1;
}
// Complete waveform acquisition
else if(mtype == 1)
{
for(int i = 0; i < 8; i++)
sCH[i]->SetEnabled(kTRUE);
sMeasType->SetEnabled(kTRUE);
sCamaclink->SetState(kButtonDown);
sCamaclink->SetEnabled(kTRUE);
scopeCommand->SetEnabled(kTRUE);
sendScopeCustom->SetEnabled(kTRUE);
sMeasgroup->SetEnabled(kFALSE);
scopeInit->SetEnabled(kTRUE);
oscOn = 2;
}
// Waveform measurements
else if(mtype == 2)
{
for(int i = 0; i < 8; i++)
sCH[i]->SetEnabled(kTRUE);
sMeasType->SetEnabled(kTRUE);
sCamaclink->SetState(kButtonUp);
sCamaclink->SetEnabled(kTRUE);
scopeCommand->SetEnabled(kTRUE);
sendScopeCustom->SetEnabled(kTRUE);
sMeasgroup->SetEnabled(kTRUE);
scopeInit->SetEnabled(kTRUE);
oscOn = 3;
}
}
 
// Make breakdown voltage plot
void TGAppMainFrame::MakeBreakdownPlot(int nrp, double *volt, double *volterr, double *psep1, double *pseperr1, double *psep2, double *pseperr2, double *psep3, double *pseperr3, char *plotfile)
{
1350,7 → 1661,9
float progVal;
 
char ctemp[256];
char ctemp2[256];
char fname[256];
int itemp = 0;
 
remove_ext((char*)fileName->GetText(), ctemp);
// printf("Save name: %s\nNo extension: %s\n", fileName->GetText(), ctemp);
1366,20 → 1679,55
{
if(zaxisscan == 0)
{
if(runCase < 10)
sprintf(fname, "%s_0000%d%s", ctemp, runCase, histExt);
else if( (runCase >= 10) && (runCase < 100) )
sprintf(fname, "%s_000%d%s", ctemp, runCase, histExt);
else if( (runCase >= 100) && (runCase < 1000) )
sprintf(fname, "%s_00%d%s", ctemp, runCase, histExt);
else if( (runCase >= 1000) && (runCase < 10000) )
sprintf(fname, "%s_0%d%s", ctemp, runCase, histExt);
else if( (runCase >= 10000) && (runCase < 100000) )
sprintf(fname, "%s_%d%s", ctemp, runCase, histExt);
if( (voltscanOn->IsOn()) && (vOutStep->GetNumber() > 0.) )
SeqNumber(runCase, (int)((vOutStop->GetNumber())-(vOutStart->GetNumber()))/(vOutStep->GetNumber()), ctemp2);
else if( surfscanOn->IsOn() )
{
if( xPosStep->GetNumber() == 0 )
itemp = 1;
else
itemp = (int)((xPosMax->GetNumber())-(xPosMin->GetNumber()))/(xPosStep->GetNumber());
 
if( yPosStep->GetNumber() == 0 )
itemp *= 1;
else
itemp *= (int)((yPosMax->GetNumber())-(yPosMin->GetNumber()))/(yPosStep->GetNumber());
SeqNumber(runCase, itemp, ctemp2);
}
sprintf(fname, "%s_%s%s", ctemp, ctemp2, histExt);
}
else if(zaxisscan == 1)
{
if(runCase < 10)
SeqNumber((int)zPos->GetNumber(), (int)zPosMax->GetNumber(), ctemp2);
 
if( (voltscanOn->IsOn()) && (vOutStep->GetNumber() > 0.) )
{
sprintf(fname, "%s_z%s_", ctemp, ctemp2);
SeqNumber(runCase, (int)((vOutStop->GetNumber())-(vOutStart->GetNumber()))/(vOutStep->GetNumber())+1, ctemp2);
strcat(fname, ctemp2);
strcat(fname, histExt);
}
else if( surfscanOn->IsOn() )
{
sprintf(fname, "%s_z%s_", ctemp, ctemp2);
 
if( xPosStep->GetNumber() == 0 )
itemp = 1;
else
itemp = (int)((xPosMax->GetNumber())-(xPosMin->GetNumber()))/(xPosStep->GetNumber())+1;
 
if( yPosStep->GetNumber() == 0 )
itemp *= 1;
else
itemp *= (int)((yPosMax->GetNumber())-(yPosMin->GetNumber()))/(yPosStep->GetNumber())+1;
SeqNumber(runCase, itemp, ctemp2);
strcat(fname, ctemp2);
strcat(fname, histExt);
}
else
sprintf(fname, "%s_z%s%s", ctemp, ctemp2, histExt);
 
/* if(runCase < 10)
sprintf(fname, "%s_z%d_0000%d%s", ctemp, (int)zPos->GetNumber(), runCase, histExt);
else if( (runCase >= 10) && (runCase < 100) )
sprintf(fname, "%s_z%d_000%d%s", ctemp, (int)zPos->GetNumber(), runCase, histExt);
1389,7 → 1737,7
sprintf(fname, "%s_z%d_0%d%s", ctemp, (int)zPos->GetNumber(), runCase, histExt);
else if( (runCase >= 10000) && (runCase < 100000) )
sprintf(fname, "%s_z%d_0%d%s", ctemp, (int)zPos->GetNumber(), runCase, histExt);
}
*/ }
}
else if( !voltscanOn->IsOn() && !surfscanOn->IsOn() )
sprintf(fname, "%s%s", ctemp, histExt);
1405,7 → 1753,8
outroot = new TFile(fname, "RECREATE");
 
TTree *header_data = new TTree("header_data", "Header information for the measurement.");
TTree *meas_data = new TTree("meas_data", "Saved measurement data.");
TTree *meas_data = new TTree("meas_data", "Saved ADC and TDC measurement data.");
TTree *scope_data = new TTree("scope_data", "Saved scope measurement data.");
 
// Branches for the header
header_data->Branch("nrch", &evtheader.nrch, "nrch/I");
1423,7 → 1772,7
evtheader.xpos = (int)xPos->GetNumber();
evtheader.ypos = (int)yPos->GetNumber();
evtheader.zpos = (int)zPos->GetNumber();
evtheader.temperature = 25.0; // Still to do!!!
evtheader.temperature = (double)chtemp->GetNumber();
sprintf(evtheader.laserinfo, "%s", laserInfo->GetText());
 
char histtime[256];
1451,6 → 1800,37
meas_data->Branch(ctemp, &evtdata.tdcdata[i], fname);
}
 
// Initialize the scope before measurement
if( sCamaclink->IsDown() )
InitializeScope();
 
// Branch for scope measurement data
if(gScopeDaq->scopeUseType == 2) // only if we select waveform measurement
{
if(gScopeDaq->scopeMeasSel == 0)
scope_data->Branch("amp", &evtmeas.measdata, "amp/D");
else if(gScopeDaq->scopeMeasSel == 1)
scope_data->Branch("area", &evtmeas.measdata, "area/D");
else if(gScopeDaq->scopeMeasSel == 2)
scope_data->Branch("delay", &evtmeas.measdata, "delay/D");
else if(gScopeDaq->scopeMeasSel == 3)
scope_data->Branch("fall", &evtmeas.measdata, "fall/D");
else if(gScopeDaq->scopeMeasSel == 4)
scope_data->Branch("freq", &evtmeas.measdata, "freq/D");
else if(gScopeDaq->scopeMeasSel == 5)
scope_data->Branch("max", &evtmeas.measdata, "max/D");
else if(gScopeDaq->scopeMeasSel == 6)
scope_data->Branch("mean", &evtmeas.measdata, "mean/D");
else if(gScopeDaq->scopeMeasSel == 7)
scope_data->Branch("min", &evtmeas.measdata, "min/D");
else if(gScopeDaq->scopeMeasSel == 8)
scope_data->Branch("pk2p", &evtmeas.measdata, "pk2p/D");
else if(gScopeDaq->scopeMeasSel == 9)
scope_data->Branch("pwidth", &evtmeas.measdata, "pwidth/D");
else if(gScopeDaq->scopeMeasSel == 10)
scope_data->Branch("rise", &evtmeas.measdata, "rise/D");
}
 
int neve = (int) evtNum->GetNumber();
int allEvt, zProg;
zProg = 1;
1500,8 → 1880,20
evtdata.tdcdata[i/2] = (int)adc;
else if(i % 2 == 1) // ADC
evtdata.adcdata[i/2] = (int)adc;
 
// Start plotting the scope waveform
if( (gScopeDaq->scopeUseType == 1) && (sCamaclink->IsDown()) )
StartScopeAcq();
}
meas_data->Fill();
 
// Start making a scope measurement
if( (gScopeDaq->scopeUseType == 2) && (sCamaclink->IsDown()) )
{
StartScopeAcq();
evtmeas.measdata = gScopeDaq->measubuf;
}
scope_data->Fill();
n++;
nc += evtheader.nrch;
1532,8 → 1924,10
 
header_data->Write();
meas_data->Write();
scope_data->Write();
delete header_data;
delete meas_data;
delete scope_data;
 
outroot->Close();
}
1608,7 → 2002,7
fflush(stdout);
printf("Waiting for voltage change...\n");
sleep(5);
sleep(3);
vOut->SetNumber(currentVoltage);
printf("Continuing...\n");
2792,6 → 3186,15
fH1->AddFrame(laserInfo, f2);
mdiFrame->AddFrame(fH1, f2);
 
// Chamber temperature (will only be manually set until we can get it directly from the chamber)
fH1 = new TGHorizontalFrame(mdiFrame, subgroup[0], 30);
lab = new TGLabel(fH1, "Chamber temp.:");
fH1->AddFrame(lab, f0center2d);
chtemp = new TGNumberEntry(fH1, 25.0, 6, 999, TGNumberFormat::kNESRealOne, TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELLimitMinMax, -70., 150.);
chtemp->Resize(60,22);
fH1->AddFrame(chtemp, f0center2d);
mdiFrame->AddFrame(fH1, f2);
 
mdiFrame->SetMdiHints(kMdiMinimize);
mdiFrame->SetWindowName("Settings pane");
mdiFrame->MapSubwindows();
3026,23 → 3429,121
fT1->AddFrame(fH1, f1);
 
// Waveform tab
fT1 = setTab->AddTab("Waveform");
fT1 = setTab->AddTab("Waveform analysis");
fH1 = new TGHorizontalFrame(fT1, subwin[0], subgroup[1], kFixedHeight);
lab = new TGLabel(fH1, "Waveform controls");
fH1->AddFrame(lab, f0center2d);
fT1->AddFrame(fH1, f0);
subgroup[0] = 1*subwin[0]/2-12;
fV1 = new TGVerticalFrame(fH1, subgroup[0], subgroup[1]/3, kFixedWidth);
 
// Wave measurements tab
fT1 = setTab->AddTab("Measurement");
fH1 = new TGHorizontalFrame(fT1, subwin[0], subgroup[1], kFixedHeight);
lab = new TGLabel(fH1, "Waveform measurement controls");
fH1->AddFrame(lab, f0center2d);
fT1->AddFrame(fH1, f0);
fG1 = new TGGroupFrame(fV1, "Acquisition channel");
 
// Selection of channels
fH2 = new TGHorizontalFrame(fG1, subgroup[0], 100);
sCH[0] = new TGCheckButton(fH2, "CH1");
sCH[0]->Resize(50,22);
sCH[0]->SetState(kButtonUp);
fH2->AddFrame(sCH[0], f0centerx);
sCH[1] = new TGCheckButton(fH2, "CH2");
sCH[1]->Resize(50,22);
sCH[1]->SetState(kButtonUp);
fH2->AddFrame(sCH[1], f0centerx);
sCH[2] = new TGCheckButton(fH2, "CH3");
sCH[2]->Resize(50,22);
sCH[2]->SetState(kButtonUp);
fH2->AddFrame(sCH[2], f0centerx);
sCH[3] = new TGCheckButton(fH2, "CH4");
sCH[3]->Resize(50,22);
sCH[3]->SetState(kButtonUp);
fH2->AddFrame(sCH[3], f0centerx);
fG1->AddFrame(fH2, f0centerx);
 
// Selection of MATH channels
fH2 = new TGHorizontalFrame(fG1, subgroup[0], 100);
sCH[4] = new TGCheckButton(fH2, "MATH1");
sCH[4]->Resize(50,22);
sCH[4]->SetState(kButtonUp);
fH2->AddFrame(sCH[4], f0centerx);
sCH[5] = new TGCheckButton(fH2, "MATH2");
sCH[5]->Resize(50,22);
sCH[5]->SetState(kButtonUp);
fH2->AddFrame(sCH[5], f0centerx);
sCH[6] = new TGCheckButton(fH2, "MATH3");
sCH[6]->Resize(50,22);
sCH[6]->SetState(kButtonUp);
fH2->AddFrame(sCH[6], f0centerx);
sCH[7] = new TGCheckButton(fH2, "MATH4");
sCH[7]->Resize(50,22);
sCH[7]->SetState(kButtonUp);
fH2->AddFrame(sCH[7], f0centerx);
fG1->AddFrame(fH2, f0centerx);
 
fV1->AddFrame(fG1, f2);
 
// Selection of measurement type
fH2 = new TGHorizontalFrame(fV1, subgroup[0], 30);
lab = new TGLabel(fH2, "Scope use type:");
fH2->AddFrame(lab, f0center2d);
sMeasType = new TGComboBox(fH2, 200);
sMeasType->AddEntry("No waveform analysis", 0);
sMeasType->AddEntry("Waveform acquisition", 1);
sMeasType->AddEntry("Measurement", 2);
sMeasType->Resize(150,22);
sMeasType->Select(0);
fH2->AddFrame(sMeasType, f0center2d);
fV1->AddFrame(fH2, f2);
 
// Link waveform analysis to CAMAC acquisition
sCamaclink = new TGCheckButton(fV1, "Link waveform to CAMAC acquisition");
sCamaclink->Resize(200,22);
sCamaclink->SetState(kButtonUp);
fV1->AddFrame(sCamaclink, f0centerx);
 
// Custom command interface for the scope
lab = new TGLabel(fV1, "Custom scope command:");
fV1->AddFrame(lab, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,10,2) );
fH2 = new TGHorizontalFrame(fV1, subgroup[0], 30);
scopeCommand = new TGTextEntry(fH2, "");
scopeCommand->Resize(subgroup[0]-45,22);
fH2->AddFrame(scopeCommand, f2);
sendScopeCustom = new TGTextButton(fH2, "Send");
sendScopeCustom->SetTextJustify(36);
sendScopeCustom->SetWrapLength(-1);
sendScopeCustom->Resize(80,22);
fH2->AddFrame(sendScopeCustom, f0centery);
fV1->AddFrame(fH2, f0);
 
// Return value for custom scope command
lab = new TGLabel(fV1, "Return:");
fV1->AddFrame(lab, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,10,2) );
scopeReturn = new TGTextEntry(fV1, "");
scopeReturn->Resize(subgroup[0],22);
fV1->AddFrame(scopeReturn, f2);
 
fH1->AddFrame(fV1, f0);
 
// Wave measurement type
fV1 = new TGVerticalFrame(fH1, subgroup[0], subgroup[1]/3, kFixedWidth);
fH2 = new TGHorizontalFrame(fV1, subgroup[0], 30);
lab = new TGLabel(fH2, "Meas. type:");
fH2->AddFrame(lab, f0center2d);
sMeasgroup = new TGComboBox(fH2, 200);
for(int i = 0; i < 11; i++)
sMeasgroup->AddEntry(allMeasNames[i], i);
sMeasgroup->Resize(150,22);
sMeasgroup->Select(4);
fH2->AddFrame(sMeasgroup, f0center2d);
fV1->AddFrame(fH2, f2);
 
// Initialize current acquisition settings
scopeInit = new TGTextButton(fV1, "Initialize scope");
scopeInit->SetTextJustify(36);
scopeInit->SetWrapLength(-1);
scopeInit->Resize(80,22);
fV1->AddFrame(scopeInit, f0centerx);
 
fH1->AddFrame(fV1, f0);
fT1->AddFrame(fH1, f1);
 
mdiFrame->AddFrame(setTab, f0);
// Disable the two tabs regarding the Scope if not connected to one
setTab->SetEnabled(1,kFALSE);
setTab->SetEnabled(2,kFALSE);
 
// Bottom pane (File controls)
subgroup[0] = subwin[0]-20;
3403,10 → 3904,26
logscale->Connect("Clicked()", "TGAppMainFrame", this, "SetHistRange()");
exportHist->Connect("Clicked()", "TGAppMainFrame", this, "HistogramExport()");
 
scopeInit->Connect("Clicked()", "TGAppMainFrame", this, "InitializeScope()");
sendScopeCustom->Connect("Clicked()", "TGAppMainFrame", this, "CustomScopeCommand()");
sMeasType->Connect("Selected(Int_t)", "TGAppMainFrame", this, "SelectedMeasType(Int_t)");
 
started = kFALSE;
 
for(int i = 0; i < 8; i++) sCH[i]->SetEnabled(kFALSE);
sMeasType->SetEnabled(kFALSE);
sCamaclink->SetEnabled(kFALSE);
scopeCommand->SetEnabled(kFALSE);
sendScopeCustom->SetEnabled(kFALSE);
sMeasgroup->SetEnabled(kFALSE);
scopeInit->SetEnabled(kFALSE);
 
EnableVoltScan();
EnableSurfScan();
EnableZaxisScan();
 
// Testing canvas for scope waveforms
wCanvas = new TCanvas("wCanvas", "Waveform canvas", 600, 300);
}
 
//---------------------------------------------------------------