Subversion Repositories f9daq

Compare Revisions

Ignore whitespace Rev 126 → Rev 127

/lab/sipmscan/trunk/libxxusb.h
File deleted
/lab/sipmscan/trunk/usb.h
File deleted
/lab/sipmscan/trunk/README
0,0 → 1,105
SOFTWARE FOR SIPM CHARACTERIZATION WITH CAMAC, SCOPE, BIAS VOLTAGE AND TABLE POSITION SUPPORT
=============================================================================================
By Gasper Kukec Mezek, April 2015.
 
________________
1. Installation:
 
Installation is done through the usual "./configure" and "make" commands to enable the use of this software with 32 bit and 64 bit systems.
 
Configure takes two arguments:
- First argument is the configure option (help, nomake, all, clean, compress).
- Second argument is the online/offline configure setting (only used when first argument is nomake or all), that enables the software to work with a connected CAMAC and scope (I), only a connected scope (S) or with no connected devices (O).
Running "./configure" or "./configure help" will give more information on specific uses.
Example:
./configure all I
 
Makefile:
Once configuration is done, a Makefile will be generated and further installation is done by running "make". Running "make relib" will only recreate the libraries in case something has been edited in them.
Example:
make
 
________________________
2. Running the software:
 
The software requires an installation of ROOT with set environment variable $ROOTSYS and $LD_LIBRARY_PATH. Once installation is performed, use
./start.sh
to start the software. Once the software starts it will let you know (in the terminal) if the CAMAC connection was correctly established.
 
_______________
3. Short guide:
 
The main window is divided into 5 subwindows:
a) Settings window:
- ON/OFF switches for voltage and surface scans.
- a voltage limiter -> sets the maximum output voltage for safety reasons
- clean plots toggle switch -> when ON, no additional stats will be displayed on plots/histograms
- scope IP -> sets the oscilloscope IP address
- LASER settings info panel -> this will be written to the output file and is used for supplying additional information
- chamber temperature -> the chamber temperature to be written to the output file
 
b) Main measurement window:
- settings for table position and bias voltage
- when scans are enabled, additional settings for scans
- number of events -> setting for the number of events to gather in a measurement
- time stamp -> informational time (start time of measurement is written to output file)
- file selector (for scans, the filenames will be appended sequential numbers to distinguish them)
- start acquisition button -> starts the measurement based on selected settings
- waveform analysis settings (channel, measurement type)
- possibility to send custom one-line commands
 
c) Histogram file selection window:
- open past measurements for analysis
- if using multiple files, use multiple file select or select all listed files
- files will be used in order displayed on the list
- to clear the complete list, use the clear list button
 
d) Histogram window:
- displays the currently selected histogram in the histogram file selection window
 
e) Histogram controls window:
- directly linked to the histogram window, it enables plotting options
- can set ranges on histogram plots
- can change between different histogram types (ADC, TDC, ADC vs. TDC, 2D surface plot)
- for the 2D surface plot, the relevant files need to be selected in the histogram file selection window
- toggle for logarithmic Y scale
- the currently selected histogram can be manually exported with the export button
- fit settings used when running "Fit spectrum" and "Fit all selected" options in the Analysis menu
 
On the top, there are 4 menus:
a) File:
- New Measurement -> not working
- Exit -> exit the software (shortkey x)
 
b) Analysis:
- Histogram type -> change between histogram types (same as in histogram controls window)
- Fit spectrum -> fit the currently open spectrum for peaks
- Fit all selected -> fit all the selected ADC spectra selected in the histogram file selection window for peaks and display the breakdown voltage plots
- Integrate spectrum (X, Y) -> integrate the ADC spectrum for multiple files with an X or Y scan (used for edge scans)
 
c) Windows:
- Specific tiling
- Switch between active windows
 
d) Help information
 
Important!
When using any analysis method (surface 2D plot, fitting, integration, ADC spectra display) only events inside the selected TDC window will be used so set the TDC range accordingly.
 
______________
4. Change log:
 
9.4.2015:
a) Added communications panel for connecting to a Tektronix scope.
b) Added limited support for waveform analysis with a Tektronix scope. For now it only works when linking it to CAMAC acquisition.
c) Added a manual chamber temperature entry field.
 
16.3.2015:
a) First version of sipmscan.
b) Added support for CAMAC, bias voltage settings and table position settings.
c) Added support for opening measured histograms.
d) Added support for analysis:
- making surface plots
- fitting the ADC spectrum
- creating breakdown voltage plots
- integrating the ADC spectrum with changing X or Y direction (edge scans)
/lab/sipmscan/trunk/configure
10,14 → 10,15
echo ""
echo "[option] = Option for configure:"
echo " - help = Display configure instructions."
echo " - nomake = Only prepare workstation.h file (base directory and online/offline mode)."
echo " - all = Prepare workstation.h file and set used libraries."
echo " - clean = Clean the installation directory."
echo " - nomake = Only prepare system dependent files (base directory and online/offline mode)."
echo " - all = Prepare system dependent files and make used libraries."
echo " - clean = Clean the installation directory. Does not clean the results directory."
echo " - compress = Compress the source code in a tar-ball."
echo ""
echo "[type] = Configure for use in online or offline mode (only needed in nomake and all):"
echo " - I = Online mode."
echo " - O = Offline mode (no connection to CAMAC, motor, voltage supply and scope)."
echo " - S = Offline mode with scope connection (no connection to CAMAC, motor and voltage supply)."
echo ""
echo "#------------------------------"
}
64,7 → 65,7
mkdir $startdir/camac_gui_windowed
mkdir $startdir/camac_gui_windowed/results
echo "Copying source files to temporary directory $startdir/camac_gui_windowed..."
cp -r configure daq.h daqscope.h GuiLinkDef.h libxxusb.cpp libxxusb.h libxxusb.o root_include.h start.cxx usb.h windowed_test.C windowed_test.h wusbcc.h wusbxx_dll.c wusbxx_dll.h wusbxx_dll.o mpod/ MIKRO/ vxi11_x86_64/ vxi11_i686/ input/ ./camac_gui_windowed/
cp -r configure daq.h daqscope.h GuiLinkDef.h libxxusb.cpp root_include.h start.cxx windowed_test.C windowed_test.h wusbcc.h wusbxx_dll.c wusbxx_dll.h mpod/ MIKRO/ vxi11_x86_64/ vxi11_i686/ input/ ./camac_gui_windowed/
cd $startdir/camac_gui_windowed
echo "Cleaning the base directory in $startdir/camac_gui_windowed..."
rm -f *.bak
95,7 → 96,7
basedir=$(echo $startdir | sed 's/\//\\\//g')
 
if [ "$1" == "nomake" ] || [ "$1" == "all" ]; then
if [ "$2" == "O" ] || [ "$2" == "I" ]; then
if [ "$2" == "O" ] || [ "$2" == "I" ] || [ "$2" == "S" ]; then
grep -q "#define WORKSTAT 'N'" $startdir/input/workstation.h.in
if [ $? == 0 ]; then
sed "s/define WORKSTAT 'N'/define WORKSTAT '$2'/" $startdir/input/workstation.h.in > $startdir/workstation.h.mid
120,17 → 121,20
if [ "$2" == "I" ]; then
sed "s/CAMLIB = \$(LIBFILE)/CAMLIB = \$(LIBFILE) -lusb/g" $startdir/Makefile.mid > $startdir/Makefile
rm $startdir/Makefile.mid
elif [ "$2" == "O" ]; then
elif [ "$2" == "O" ] || [ "$2" == "S" ]; then
cp $startdir/input/Makefile.in $startdir/Makefile
fi
fi
 
if [ "$2" == "O" ]; then
if [ "$2" == "O" ] || [ "$2" == "S" ]; then
cp $startdir/input/daqusb.C.offline $startdir/daqusb.C
cp $startdir/input/start.sh.offline $startdir/start.sh
cp $startdir/input/libxxusb.h.offline $startdir/libxxusb.h
cp $startdir/input/usb.h.offline $startdir/usb.h
elif [ "$2" == "I" ]; then
cp $startdir/input/daqusb.C.online $startdir/daqusb.C
cp $startdir/input/start.sh.online $startdir/start.sh
cp $startdir/input/libxxusb.h.online $startdir/libxxusb.h
fi
fi
fi
151,7 → 155,7
make clean
rm -f Makefile
else
if [ "$2" == "O" ] || [ "$2" == "I" ]; then
if [ "$2" == "O" ] || [ "$2" == "I" ] || [ "$2" == "S" ]; then
make
else
echo "Error! No configuration type selected (second argument)."
176,7 → 180,7
make clean
rm -f Makefile
else
if [ "$2" == "O" ] || [ "$2" == "I" ]; then
if [ "$2" == "O" ] || [ "$2" == "I" ] || [ "$2" == "S" ]; then
make
else
echo "Error! No installation type selected (second argument)."
/lab/sipmscan/trunk/daqscope.h
6,10 → 6,32
//class VmUsbStack;
class daqscope {
public:
int scopeUseType;
int scopeChanNr;
int scopeChans[8];
char scopeChanstring[256];
int scopeMeasSel;
char eventbuf[WAVE_LEN];
double measubuf;
double tektime, tekvolt;
double choffset;
 
int fStop;
double tekunit(char *prefix);
 
int init();
int event();
int customCommand(char *command, bool query, char *sReturn);
int connect(char* IPaddr);
int disconnect(char* IPaddr);
int lockunlock(bool lockit);
daqscope();
~daqscope();
 
// VmUsbStack * fStack;
// VmUsbStack * fInit;
 
int OSrepetition;
/* int OSrepetition;
int OSmeasu;
int OSmeasuchan;
int OSgating;
27,8 → 49,8
char multibuf[WAVE_LEN];
char eventbuf[WAVE_LEN];
double tektime,tekvolt,lctime,lcvolt;
int fastacqstate; /* GKM - variable that saves the fastacq state */
double choffset; /* GKM - position offset for signal */
int fastacqstate; // GKM - variable that saves the fastacq state
double choffset; // GKM - position offset for signal
 
int fPoints;
int fStop;
47,7 → 69,7
void fileopen(const char*);
void fileclose();
void countcontrol();
void fastacq(int setting); /* GKM - gets tek out of fastacq*/
void fastacq(int setting); // GKM - gets tek out of fastacq
void header();
void measuheader();
void lecroyheader();
56,7 → 78,7
double lcunit(char*);
daqscope();
// daqscope(const char *);
~daqscope();
~daqscope();*/
};
 
#endif
/lab/sipmscan/trunk/input/Makefile.in
41,7 → 41,7
$(TARGET): $(FILES) workstation.h daq.h library $(SHLIB)
@echo "Generating dictionary Dict.C..."
rootcint -f GuiDict.C -c $(INC) $(CPPFLAGS) windowed_test.h GuiLinkDef.h
$(CXX) $(INC) -DG__DICTIONARY -fPIC -g -Wall $(FILES) GuiDict.C $(CPPFLAGS) $(VXI_OBJECT) -o $(TARGET) $(SHLIB) $(LIBS1) -lstdc++ -lSpectrum
$(CXX) $(INC) -fPIC -g -Wall $(FILES) GuiDict.C $(CPPFLAGS) $(VXI_OBJECT) -o $(TARGET) $(SHLIB) $(LIBS1) -lstdc++ -lSpectrum
# -----------------------------------------------------------------------------
 
# CAMAC DAQ library rules -----------------------------------------------------
73,7 → 73,7
libdaqusb.so: $(DAQFILE) $(LIBFILE)
@echo "Generating dictionary Dict.C..."
rootcint -f Dict.C -c $(INC) $(CPPFLAGS) $(HEADER) GuiLinkDef.h
$(CXX) -DG__DICTIONARY $(CPPFLAGS) $(INC) -fPIC -g -Wall $(DAQFILE) Dict.C $(CAMLIB) -shared -o $@
$(CXX) $(CPPFLAGS) $(INC) -fPIC -g -Wall $(DAQFILE) Dict.C $(CAMLIB) -shared -o $@
 
# Rule for making the CAMAC DAQ library (libdaqusb.a)
$(LIBFILE): $(OBJ_FILES)
85,7 → 85,7
libvxi11.so: libvxi11.a
@echo "Generating dictionary VxiDict.C..."
rootcint -f VxiDict.C -c $(INC) $(CPPFLAGS) daqscope.h GuiLinkDef.h
$(CXX) -DG__DICTIONARY $(CPPFLAGS) $(INC) -fPIC -g -Wall daqscope.C VxiDict.C -L. libvxi11.a -shared -o $@
$(CXX) $(CPPFLAGS) $(INC) -fPIC -g -Wall daqscope.C VxiDict.C -L. libvxi11.a -shared -o $@
 
libvxi11.a: $(VXI_OBJECT)
ar r $@ $^
95,5 → 95,5
 
# Rule for cleaning the installation
clean:
rm -f Dict.C Dict.h GuiDict.C GuiDict.h windowed_test windowed_test_C.d windowed_test_C.so curpos.txt curvolt.txt workstation.h VxiDict.C VxiDict.h daqscope.C daqusb.C start.sh
rm -f Dict.C Dict.h GuiDict.C GuiDict.h windowed_test windowed_test_C.d windowed_test_C.so curpos.txt curvolt.txt workstation.h VxiDict.C VxiDict.h daqscope.C daqusb.C start.sh usb.h libxxusb.h libdaqusb.a libdaqusb.so libvxi11.a libvxi11.so *.o finish_sig.txt
# -----------------------------------------------------------------------------
/lab/sipmscan/trunk/input/daqscope.C.in
1,16 → 1,58
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
#include "vxi11_user.h"
#include "daqscope.h"
#include "workstation.h"
 
CLINK *clink;
char *savedIP;
const char *allChans[8] = {"CH1","CH2","CH3","CH4","MATH1","MATH2","MATH3","MATH4"};
const char *measType[11] = {"AMP","ARE","DEL","FALL","FREQ","MAX","MEAN","MINI","PK2P","PWI","RIS"};
char *bbq;
 
// Query and command functions to simplify analysis --------------
int vxi11_query(CLINK *clink, const char *mycmd)
{
char buf[WAVE_LEN];
memset(buf, 0, WAVE_LEN);
vxi11_send(clink, mycmd);
int bytes_returned = vxi11_receive(clink, buf, WAVE_LEN);
if (bytes_returned > 0)
{
printf("%s\n", buf);
}
else if (bytes_returned == -15)
printf("*** [ NOTHING RECEIVED ] ***\n");
 
return 0;
}
 
void vxi11_command(CLINK *clink,char *mycmd)
{
char buf[WAVE_LEN];
memset(buf, 0, WAVE_LEN);
vxi11_send(clink, mycmd);
}
// ---------------------------------------------------------------
 
// Tektronix unit conversion -------------------------------------
double daqscope::tekunit(char *prefix)
{
if (strcmp(prefix,"m")==0) return 0.001;
else if (strcmp(prefix,"u")==0) return 0.000001;
else if (strcmp(prefix,"n")==0) return 0.000000001;
else return 1;
}
// ---------------------------------------------------------------
 
// Connect to a scope through IP address IPaddr ------------------
int daqscope::connect(char *IPaddr)
{
int iTemp;
char buf[WAVE_LEN];
printf("daqscope::connect(%s)\n", IPaddr);
clink = new CLINK;
iTemp = vxi11_open_device(IPaddr, clink);
if(iTemp == 0)
24,17 → 66,319
else
return iTemp;
}
// ---------------------------------------------------------------
 
// Disconnect from scope with IP address IPaddr ------------------
int daqscope::disconnect(char *IPaddr)
{
int iTemp;
printf("daqscope::disconnect(%s)\n", IPaddr);
iTemp = vxi11_close_device(IPaddr, clink);
if(iTemp == 0)
{
printf("Disconnected from device (%s).\n", IPaddr);
delete clink;
delete clink;
}
return iTemp;
}
// ---------------------------------------------------------------
 
// Initialize the scope for waveform or measurement --------------
int daqscope::init()
{
int iTemp;
char cmd[512];
char cTemp[256];
printf("daqscope::init()\n");
 
printf("Measurement type is: %d\n", scopeUseType);
 
// For measurements, only one channel can be used (rise, fall, period,...)
if(scopeUseType == 2) scopeChanNr = 1;
printf("Nr. of channels selected: %d\n", scopeChanNr);
 
// Only use scope if measurement is different than 0
if(scopeUseType == 0)
return 0;
else
{
// Combine all selected channels into a comma separated string
for(int i = 0; i < scopeChanNr; i++)
{
if(i == scopeChanNr-1)
{
if(i == 0) sprintf(scopeChanstring, "%s", allChans[scopeChans[i]]);
else sprintf(cTemp, "%s", allChans[scopeChans[i]]);
}
else
{
if(i == 0) sprintf(scopeChanstring, "%s,", allChans[scopeChans[i]]);
else sprintf(cTemp, "%s,", allChans[scopeChans[i]]);
}
if(i > 0)
strcat(scopeChanstring, cTemp);
}
printf("Selected channels: %s\n", scopeChanstring);
 
// Check scope ID and turn the header display on
#if WORKSTAT == 'I' || WORKSTAT == 'S'
vxi11_query(clink, "*IDN?");
vxi11_command(clink,(char*)"HEADER ON");
#else
printf("Identify Tek (*IDN?, HEADER ON)\n");
#endif
 
// Set the scope data sources
sprintf(cmd, "DATA:SOURCE %s", scopeChanstring);
#if WORKSTAT == 'I' || WORKSTAT == 'S'
vxi11_command(clink,cmd);
#else
printf("Set data source (DATA:SOURCE): %s\n", cmd);
#endif
 
// Set to fast acquisition and set encoding
#if WORKSTAT == 'I' || WORKSTAT == 'S'
vxi11_command(clink,(char*)"FASTACQ:STATE 0");
vxi11_command(clink,(char*)"DATA:ENCDG SRIBINARY");
vxi11_command(clink,(char*)"WFMO:BYT_N 2");
 
// Set gating (currently not used)
vxi11_command(clink,(char*)"GAT OFF");
#else
printf("Set fastacq, encoding and gating (FASTACQ:STATE 0, DATA:ENCDG SRIBINARY, WFMO:BYT_N 2, MEASU:GAT OFF).\n");
#endif
 
// Check scale on each of selected channels (is this even needed?)
bbq = strtok(scopeChanstring,",");
while(bbq != NULL)
{
sprintf(cmd,"%s:SCALE?",bbq);
#if WORKSTAT == 'I' || WORKSTAT == 'S'
vxi11_query(clink,cmd);
#else
printf("Return the scale of channel: %s\n", cmd);
#endif
bbq = strtok(NULL, ",");
}
 
// Check waveform and data options/settings
char buf[WAVE_LEN];
memset(buf, 0, WAVE_LEN);
#if WORKSTAT == 'I' || WORKSTAT == 'S'
vxi11_send(clink, "WFMO:WFID?");
iTemp = vxi11_receive(clink, buf, WAVE_LEN);
printf("Init out (length = %d): %s\n", iTemp, buf);
#else
printf("Get acquisition parameters (WFMOUTPRE:WFID?).\n");
sprintf(buf, ":WFMOUTPRE:WFID \"Ch1, DC coupling, 20.0mV/div, 10.0ns/div, 500 points, Sample mode\"");
iTemp = strlen(buf);
#endif
if (iTemp == -15)
printf("\n*** [ NOTHING RECEIVED ] ***\n");
else
{
bbq = strtok(buf,","); // break WFID out into substrings
for (int k = 0; k < 5; k++)
{
// info on voltage per division setting
if (k == 2)
{
memcpy(cTemp, &bbq[1], 5);
cTemp[5] = 0;
bbq[7] = 0;
tekvolt = atoi(cTemp)*tekunit(&bbq[6]);
printf("Voltage per division: %lf\n", tekvolt);
}
// info on time per division setting
if (k == 3)
{
memcpy(cTemp, &bbq[1], 5);
cTemp[5] = 0;
bbq[7] = 0;
tektime = atoi(cTemp)*tekunit(&bbq[6]);
printf("Time per division: %lf\n", tektime);
}
// info on last point to be transfered by CURVE?
if (k == 4)
{
bbq[strlen(bbq)-7] = 0;
sprintf(cmd, "DATA:STOP %d", atoi(bbq));
#if WORKSTAT == 'I' || WORKSTAT == 'S'
vxi11_command(clink, cmd);
#else
printf("Stop data collection (DATA:STOP): %s\n", cmd);
#endif
}
// printf("bbq = %s\n",bbq);
bbq = strtok (NULL, ",");
}
}
 
// Recheck waveform and data options/settings, turn off header
#if WORKSTAT == 'I' || WORKSTAT == 'S'
vxi11_query(clink,"WFMO:WFID?");
vxi11_query(clink,"DATA?");
vxi11_command(clink,(char*)"HEADER OFF");
#else
printf("Data format query (WFMOUTPRE:WFID?, DATA?, HEADER OFF).\n");
#endif
 
// Get the channel y-axis offset (only for one CH so far)
char posoff[WAVE_LEN];
#if WORKSTAT == 'I' || WORKSTAT == 'S'
sprintf(cmd, "%s:POS?", allChans[scopeChans[0]]);
vxi11_command(clink, cmd);
vxi11_receive(clink, posoff, WAVE_LEN);
choffset = (double)atof(posoff);
#else
printf("Check for channel position offset (CHx:POS?)\n");
#endif
 
// If measurements are to be performed
if(scopeUseType == 2)
{
sprintf(cmd, "MEASU:IMM:SOURCE1 %s", scopeChanstring);
#if WORKSTAT == 'I' || WORKSTAT == 'S'
vxi11_command(clink, cmd);
#else
printf("Set immediate measurement source (MEASU:IMM:SOURCE1): %s\n", cmd);
#endif
 
sprintf(cmd, "MEASU:IMM:TYP %s", measType[scopeMeasSel]);
#if WORKSTAT == 'I' || WORKSTAT == 'S'
vxi11_command(clink, cmd);
#else
printf("Set immediate measurement type (MEASU:IMM:TYP): %s\n", cmd);
#endif
}
 
return 0;
}
}
// ---------------------------------------------------------------
 
// Send a custom command to the scope ----------------------------
int daqscope::customCommand(char *command, bool query, char *sReturn)
{
if(query)
{
char buf[WAVE_LEN];
memset(buf, 0, WAVE_LEN);
vxi11_send(clink, command);
int bytes_returned = vxi11_receive(clink, buf, WAVE_LEN);
if (bytes_returned > 0)
{
printf("%s\n", buf);
sprintf(sReturn, "%s", buf);
 
// For testing purposes
/* if( strcmp(command, "CURVE?") == 0 )
{
FILE *fp;
char tst[2];
fp = fopen("./curve_return.txt","w");
for(int i = 6; i < bytes_returned; i++)
{
if(i%2 == 1)
{
tst[0] = buf[i];
tst[1] = buf[i-1];
fprintf(fp, "bytes returned = %d\tbyte %d = %d\treturn = %s\n", bytes_returned, i, buf[i], tst);
}
else
fprintf(fp, "bytes returned = %d\tbyte %d = %d\n", bytes_returned, i, buf[i]);
}
fclose(fp);
}*/
}
else if (bytes_returned == -15)
{
printf("*** [ NOTHING RECEIVED ] ***\n");
sprintf(sReturn, "*** [ NOTHING RECEIVED ] ***");
}
}
else
{
vxi11_command(clink, command);
sprintf(sReturn, "*** [ COMMAND NOT QUERY - NO RETURN ] ***");
}
 
return 0;
}
// ---------------------------------------------------------------
 
// Get a measuring event (either waveform or measure) ------------
int daqscope::lockunlock(bool lockit)
{
// Lock the scope front panel for measurements
if(lockit)
{
#if WORKSTAT == 'I' || WORKSTAT == 'S'
vxi11_command(clink,(char*)"LOCK ALL");
return 0;
#else
// printf("Locking the front panel (LOCK ALL).\n");
return -1;
#endif
}
// Unlock the scope front panel after measurements
else
{
#if WORKSTAT == 'I' || WORKSTAT == 'S'
vxi11_command(clink,(char*)"LOCK NONE");
return 0;
#else
// printf("Unlocking the front panel (LOCK ALL).\n");
return -1;
#endif
}
}
// ---------------------------------------------------------------
 
// Get a measuring event (either waveform or measure) ------------
int daqscope::event()
{
int bytes_returned;
 
if(scopeUseType == 0)
return -1;
else if(scopeUseType == 1)
{
#if WORKSTAT == 'I' || WORKSTAT == 'S'
memset(eventbuf, 0, WAVE_LEN);
vxi11_send(clink, "CURVE?");
bytes_returned = vxi11_receive(clink, eventbuf, WAVE_LEN);
#else
printf("Ask to return the waveform (CURVE?)\n");
bytes_returned = 0;
#endif
 
if(bytes_returned > 0) return 0;
else return -1;
}
else if(scopeUseType == 2)
{
#if WORKSTAT == 'I' || WORKSTAT == 'S'
char buf[WAVE_LEN];
memset(buf, 0, WAVE_LEN);
vxi11_send(clink, "MEASU:IMMED:VALUE?");
bytes_returned = vxi11_receive(clink, buf, WAVE_LEN);
measubuf = (double)atof(buf);
#else
// printf("Ask to return the measurement (MEASU:IMMED:VALUE?)\n");
bytes_returned = 0;
measubuf = (double)rand()/(double)RAND_MAX;
#endif
 
if(bytes_returned > 0) return 0;
else return -1;
}
else
return -1;
}
// ---------------------------------------------------------------
 
// daqscope class constructor and destructor ---------------------
daqscope::daqscope() {
fStop=0;
}
42,3 → 386,4
daqscope::~daqscope() {
disconnect(savedIP);
}
// ---------------------------------------------------------------
/lab/sipmscan/trunk/input/daqusb.C.offline
25,7 → 25,7
//#define NADC 2 /* ADC */
//#define NADCCH 8
int ctrlc=0;
char *ccserial="CC0126";
char *ccserial=(char*)"CC0126";
int devDetect; // variable to tell if we detect any devices
 
int daq::connect(){
50,8 → 50,8
 
int daq::init(){
 
int i;
long k;
// int i;
// long k;
 
/* DBGFUNI(xxusb_register_write(udev,1,0x0)); // Stop DAQ mode
while (xxusb_usbfifo_read(udev, (int*) stackdump,BUFF_L,100)>0);
119,7 → 119,8
}
 
int daq::event(unsigned int *data, int maxn){
int i,ib,count;
// int i,ib,count;
int count;
/* int events,evsize;
short ret;
 
/lab/sipmscan/trunk/input/daqusb.C.online
25,7 → 25,7
//#define NADC 2 /* ADC */
//#define NADCCH 8
int ctrlc=0;
char *ccserial="CC0126";
char *ccserial=(char*)"CC0126";
int devDetect; // variable to tell if we detect any devices
 
int daq::connect(){
/lab/sipmscan/trunk/input/libxxusb.h.offline
0,0 → 1,111
#include "usb.h"
 
 
#define XXUSB_WIENER_VENDOR_ID 0x16DC /* Wiener, Plein & Baus */
#define XXUSB_VMUSB_PRODUCT_ID 0x000B /* VM-USB */
#define XXUSB_CCUSB_PRODUCT_ID 0x0001 /* CC-USB */
#define XXUSB_ENDPOINT_OUT 2 /* Endpoint 2 Out*/
#define XXUSB_ENDPOINT_IN 0x86 /* Endpoint 6 In */
#define XXUSB_FIRMWARE_REGISTER 0
#define XXUSB_GLOBAL_REGISTER 1
#define XXUSB_ACTION_REGISTER 10
#define XXUSB_DELAYS_REGISTER 2
#define XXUSB_WATCHDOG_REGISTER 3
#define XXUSB_SELLEDA_REGISTER 6
#define XXUSB_SELNIM_REGISTER 7
#define XXUSB_SELLEDB_REGISTER 4
#define XXUSB_SERIAL_REGISTER 15
#define XXUSB_LAMMASK_REGISTER 8
#define XXUSB_LAM_REGISTER 12
#define XXUSB_READOUT_STACK 2
#define XXUSB_SCALER_STACK 3
#define XXUSB_NAF_DIRECT 12
 
struct XXUSB_STACK
{
long Data;
short Hit;
short APatt;
short Num;
short HitMask;
};
 
struct XXUSB_CC_COMMAND_TYPE
{
short Crate;
short F;
short A;
short N;
long Data;
short NoS2;
short LongD;
short HitPatt;
short QStop;
short LAMMode;
short UseHit;
short Repeat;
short AddrScan;
short FastCam;
short NumMod;
short AddrPatt;
long HitMask[4];
long Num;
};
 
struct xxusb_device_typ
{
struct usb_device *usbdev;
char SerialString[7];
};
 
typedef struct xxusb_device_typ xxusb_device_type;
typedef unsigned char UCHAR;
typedef struct usb_bus usb_busx;
 
 
int xxusb_longstack_execute(usb_dev_handle *hDev, void *DataBuffer, int lDataLen, int timeout);
int xxusb_bulk_read(usb_dev_handle *hDev, void *DataBuffer, int lDataLen, int timeout);
int xxusb_bulk_write(usb_dev_handle *hDev, void *DataBuffer, int lDataLen, int timeout);
int xxusb_usbfifo_read(usb_dev_handle *hDev, int *DataBuffer, int lDataLen, int timeout);
 
short xxusb_register_read(usb_dev_handle *hDev, short RegAddr, long *RegData);
short xxusb_stack_read(usb_dev_handle *hDev, short StackAddr, long *StackData);
short xxusb_stack_write(usb_dev_handle *hDev, short StackAddr, long *StackData);
short xxusb_stack_execute(usb_dev_handle *hDev, long *StackData);
short xxusb_register_write(usb_dev_handle *hDev, short RegAddr, long RegData);
short xxusb_reset_toggle(usb_dev_handle *hDev);
 
short xxusb_devices_find(xxusb_device_type *xxusbDev);
short xxusb_device_close(usb_dev_handle *hDev);
usb_dev_handle* xxusb_device_open(struct usb_device *dev);
short xxusb_flash_program(usb_dev_handle *hDev, char *config, short nsect);
short xxusb_flashblock_program(usb_dev_handle *hDev, UCHAR *config);
usb_dev_handle* xxusb_serial_open(char *SerialString);
 
short VME_register_write(usb_dev_handle *hdev, long VME_Address, long Data);
short VME_register_read(usb_dev_handle *hdev, long VME_Address, long *Data);
short VME_LED_settings(usb_dev_handle *hdev, int LED, int code, int invert, int latch);
short VME_DGG(usb_dev_handle *hdev, unsigned short channel, unsigned short trigger,unsigned short output, long delay, unsigned short gate, unsigned short invert, unsigned short latch);
 
short VME_Output_settings(usb_dev_handle *hdev, int Channel, int code, int invert, int latch);
 
short VME_read_16(usb_dev_handle *hdev,short Address_Modifier, long VME_Address, long *Data);
short VME_read_32(usb_dev_handle *hdev, short Address_Modifier, long VME_Address, long *Data);
short VME_BLT_read_32(usb_dev_handle *hdev, short Address_Modifier, int count, long VME_Address, long Data[]);
short VME_write_16(usb_dev_handle *hdev, short Address_Modifier, long VME_Address, long Data);
short VME_write_32(usb_dev_handle *hdev, short Address_Modifier, long VME_Address, long Data);
 
short CAMAC_DGG(usb_dev_handle *hdev, short channel, short trigger, short output, int delay, int gate, short invert, short latch);
short CAMAC_register_read(usb_dev_handle *hdev, int A, long *Data);
short CAMAC_register_write(usb_dev_handle *hdev, int A, long Data);
short CAMAC_LED_settings(usb_dev_handle *hdev, int LED, int code, int invert, int latch);
short CAMAC_Output_settings(usb_dev_handle *hdev, int Channel, int code, int invert, int latch);
short CAMAC_read_LAM_mask(usb_dev_handle *hdev, long *Data);
short CAMAC_write_LAM_mask(usb_dev_handle *hdev, long Data);
 
short CAMAC_write(usb_dev_handle *hdev, int N, int A, int F, long Data, int *Q, int *X);
short CAMAC_read(usb_dev_handle *hdev, int N, int A, int F, long *Data, int *Q, int *X);
short CAMAC_Z(usb_dev_handle *hdev);
short CAMAC_C(usb_dev_handle *hdev);
short CAMAC_I(usb_dev_handle *hdev, int inhibit);
 
/lab/sipmscan/trunk/input/libxxusb.h.online
0,0 → 1,111
#include <usb.h>
 
 
#define XXUSB_WIENER_VENDOR_ID 0x16DC /* Wiener, Plein & Baus */
#define XXUSB_VMUSB_PRODUCT_ID 0x000B /* VM-USB */
#define XXUSB_CCUSB_PRODUCT_ID 0x0001 /* CC-USB */
#define XXUSB_ENDPOINT_OUT 2 /* Endpoint 2 Out*/
#define XXUSB_ENDPOINT_IN 0x86 /* Endpoint 6 In */
#define XXUSB_FIRMWARE_REGISTER 0
#define XXUSB_GLOBAL_REGISTER 1
#define XXUSB_ACTION_REGISTER 10
#define XXUSB_DELAYS_REGISTER 2
#define XXUSB_WATCHDOG_REGISTER 3
#define XXUSB_SELLEDA_REGISTER 6
#define XXUSB_SELNIM_REGISTER 7
#define XXUSB_SELLEDB_REGISTER 4
#define XXUSB_SERIAL_REGISTER 15
#define XXUSB_LAMMASK_REGISTER 8
#define XXUSB_LAM_REGISTER 12
#define XXUSB_READOUT_STACK 2
#define XXUSB_SCALER_STACK 3
#define XXUSB_NAF_DIRECT 12
 
struct XXUSB_STACK
{
long Data;
short Hit;
short APatt;
short Num;
short HitMask;
};
 
struct XXUSB_CC_COMMAND_TYPE
{
short Crate;
short F;
short A;
short N;
long Data;
short NoS2;
short LongD;
short HitPatt;
short QStop;
short LAMMode;
short UseHit;
short Repeat;
short AddrScan;
short FastCam;
short NumMod;
short AddrPatt;
long HitMask[4];
long Num;
};
 
struct xxusb_device_typ
{
struct usb_device *usbdev;
char SerialString[7];
};
 
typedef struct xxusb_device_typ xxusb_device_type;
typedef unsigned char UCHAR;
typedef struct usb_bus usb_busx;
 
 
int xxusb_longstack_execute(usb_dev_handle *hDev, void *DataBuffer, int lDataLen, int timeout);
int xxusb_bulk_read(usb_dev_handle *hDev, void *DataBuffer, int lDataLen, int timeout);
int xxusb_bulk_write(usb_dev_handle *hDev, void *DataBuffer, int lDataLen, int timeout);
int xxusb_usbfifo_read(usb_dev_handle *hDev, int *DataBuffer, int lDataLen, int timeout);
 
short xxusb_register_read(usb_dev_handle *hDev, short RegAddr, long *RegData);
short xxusb_stack_read(usb_dev_handle *hDev, short StackAddr, long *StackData);
short xxusb_stack_write(usb_dev_handle *hDev, short StackAddr, long *StackData);
short xxusb_stack_execute(usb_dev_handle *hDev, long *StackData);
short xxusb_register_write(usb_dev_handle *hDev, short RegAddr, long RegData);
short xxusb_reset_toggle(usb_dev_handle *hDev);
 
short xxusb_devices_find(xxusb_device_type *xxusbDev);
short xxusb_device_close(usb_dev_handle *hDev);
usb_dev_handle* xxusb_device_open(struct usb_device *dev);
short xxusb_flash_program(usb_dev_handle *hDev, char *config, short nsect);
short xxusb_flashblock_program(usb_dev_handle *hDev, UCHAR *config);
usb_dev_handle* xxusb_serial_open(char *SerialString);
 
short VME_register_write(usb_dev_handle *hdev, long VME_Address, long Data);
short VME_register_read(usb_dev_handle *hdev, long VME_Address, long *Data);
short VME_LED_settings(usb_dev_handle *hdev, int LED, int code, int invert, int latch);
short VME_DGG(usb_dev_handle *hdev, unsigned short channel, unsigned short trigger,unsigned short output, long delay, unsigned short gate, unsigned short invert, unsigned short latch);
 
short VME_Output_settings(usb_dev_handle *hdev, int Channel, int code, int invert, int latch);
 
short VME_read_16(usb_dev_handle *hdev,short Address_Modifier, long VME_Address, long *Data);
short VME_read_32(usb_dev_handle *hdev, short Address_Modifier, long VME_Address, long *Data);
short VME_BLT_read_32(usb_dev_handle *hdev, short Address_Modifier, int count, long VME_Address, long Data[]);
short VME_write_16(usb_dev_handle *hdev, short Address_Modifier, long VME_Address, long Data);
short VME_write_32(usb_dev_handle *hdev, short Address_Modifier, long VME_Address, long Data);
 
short CAMAC_DGG(usb_dev_handle *hdev, short channel, short trigger, short output, int delay, int gate, short invert, short latch);
short CAMAC_register_read(usb_dev_handle *hdev, int A, long *Data);
short CAMAC_register_write(usb_dev_handle *hdev, int A, long Data);
short CAMAC_LED_settings(usb_dev_handle *hdev, int LED, int code, int invert, int latch);
short CAMAC_Output_settings(usb_dev_handle *hdev, int Channel, int code, int invert, int latch);
short CAMAC_read_LAM_mask(usb_dev_handle *hdev, long *Data);
short CAMAC_write_LAM_mask(usb_dev_handle *hdev, long Data);
 
short CAMAC_write(usb_dev_handle *hdev, int N, int A, int F, long Data, int *Q, int *X);
short CAMAC_read(usb_dev_handle *hdev, int N, int A, int F, long *Data, int *Q, int *X);
short CAMAC_Z(usb_dev_handle *hdev);
short CAMAC_C(usb_dev_handle *hdev);
short CAMAC_I(usb_dev_handle *hdev, int inhibit);
 
/lab/sipmscan/trunk/input/usb.h.offline
0,0 → 1,344
/*
* Prototypes, structure definitions and macros.
*
* Copyright (c) 2000-2003 Johannes Erdfelt <johannes@erdfelt.com>
*
* This library is covered by the LGPL, read LICENSE for details.
*
* This file (and only this file) may alternatively be licensed under the
* BSD license as well, read LICENSE for details.
*/
#ifndef __USB_H__
#define __USB_H__
 
#include <unistd.h>
#include <stdlib.h>
#include <stdint.h>
#include <limits.h>
 
#include <sys/param.h>
#include <dirent.h>
 
/*
* USB spec information
*
* This is all stuff grabbed from various USB specs and is pretty much
* not subject to change
*/
 
/*
* Device and/or Interface Class codes
*/
#define USB_CLASS_PER_INTERFACE 0 /* for DeviceClass */
#define USB_CLASS_AUDIO 1
#define USB_CLASS_COMM 2
#define USB_CLASS_HID 3
#define USB_CLASS_PRINTER 7
#define USB_CLASS_PTP 6
#define USB_CLASS_MASS_STORAGE 8
#define USB_CLASS_HUB 9
#define USB_CLASS_DATA 10
#define USB_CLASS_VENDOR_SPEC 0xff
 
/*
* Descriptor types
*/
#define USB_DT_DEVICE 0x01
#define USB_DT_CONFIG 0x02
#define USB_DT_STRING 0x03
#define USB_DT_INTERFACE 0x04
#define USB_DT_ENDPOINT 0x05
 
#define USB_DT_HID 0x21
#define USB_DT_REPORT 0x22
#define USB_DT_PHYSICAL 0x23
#define USB_DT_HUB 0x29
 
/*
* Descriptor sizes per descriptor type
*/
#define USB_DT_DEVICE_SIZE 18
#define USB_DT_CONFIG_SIZE 9
#define USB_DT_INTERFACE_SIZE 9
#define USB_DT_ENDPOINT_SIZE 7
#define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */
#define USB_DT_HUB_NONVAR_SIZE 7
 
/* All standard descriptors have these 2 fields in common */
struct usb_descriptor_header {
uint8_t bLength;
uint8_t bDescriptorType;
} __attribute__ ((packed));
 
/* String descriptor */
struct usb_string_descriptor {
uint8_t bLength;
uint8_t bDescriptorType;
uint16_t wData[1];
} __attribute__ ((packed));
 
/* HID descriptor */
struct usb_hid_descriptor {
uint8_t bLength;
uint8_t bDescriptorType;
uint16_t bcdHID;
uint8_t bCountryCode;
uint8_t bNumDescriptors;
/* uint8_t bReportDescriptorType; */
/* uint16_t wDescriptorLength; */
/* ... */
} __attribute__ ((packed));
 
/* Endpoint descriptor */
#define USB_MAXENDPOINTS 32
struct usb_endpoint_descriptor {
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bEndpointAddress;
uint8_t bmAttributes;
uint16_t wMaxPacketSize;
uint8_t bInterval;
uint8_t bRefresh;
uint8_t bSynchAddress;
 
unsigned char *extra; /* Extra descriptors */
int extralen;
};
 
#define USB_ENDPOINT_ADDRESS_MASK 0x0f /* in bEndpointAddress */
#define USB_ENDPOINT_DIR_MASK 0x80
 
#define USB_ENDPOINT_TYPE_MASK 0x03 /* in bmAttributes */
#define USB_ENDPOINT_TYPE_CONTROL 0
#define USB_ENDPOINT_TYPE_ISOCHRONOUS 1
#define USB_ENDPOINT_TYPE_BULK 2
#define USB_ENDPOINT_TYPE_INTERRUPT 3
 
/* Interface descriptor */
#define USB_MAXINTERFACES 32
struct usb_interface_descriptor {
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bInterfaceNumber;
uint8_t bAlternateSetting;
uint8_t bNumEndpoints;
uint8_t bInterfaceClass;
uint8_t bInterfaceSubClass;
uint8_t bInterfaceProtocol;
uint8_t iInterface;
 
struct usb_endpoint_descriptor *endpoint;
 
unsigned char *extra; /* Extra descriptors */
int extralen;
};
 
#define USB_MAXALTSETTING 128 /* Hard limit */
struct usb_interface {
struct usb_interface_descriptor *altsetting;
 
int num_altsetting;
};
 
/* Configuration descriptor information.. */
#define USB_MAXCONFIG 8
struct usb_config_descriptor {
uint8_t bLength;
uint8_t bDescriptorType;
uint16_t wTotalLength;
uint8_t bNumInterfaces;
uint8_t bConfigurationValue;
uint8_t iConfiguration;
uint8_t bmAttributes;
uint8_t MaxPower;
 
struct usb_interface *interface;
 
unsigned char *extra; /* Extra descriptors */
int extralen;
};
 
/* Device descriptor */
struct usb_device_descriptor {
uint8_t bLength;
uint8_t bDescriptorType;
uint16_t bcdUSB;
uint8_t bDeviceClass;
uint8_t bDeviceSubClass;
uint8_t bDeviceProtocol;
uint8_t bMaxPacketSize0;
uint16_t idVendor;
uint16_t idProduct;
uint16_t bcdDevice;
uint8_t iManufacturer;
uint8_t iProduct;
uint8_t iSerialNumber;
uint8_t bNumConfigurations;
} __attribute__ ((packed));
 
struct usb_ctrl_setup {
uint8_t bRequestType;
uint8_t bRequest;
uint16_t wValue;
uint16_t wIndex;
uint16_t wLength;
} __attribute__ ((packed));
 
/*
* Standard requests
*/
#define USB_REQ_GET_STATUS 0x00
#define USB_REQ_CLEAR_FEATURE 0x01
/* 0x02 is reserved */
#define USB_REQ_SET_FEATURE 0x03
/* 0x04 is reserved */
#define USB_REQ_SET_ADDRESS 0x05
#define USB_REQ_GET_DESCRIPTOR 0x06
#define USB_REQ_SET_DESCRIPTOR 0x07
#define USB_REQ_GET_CONFIGURATION 0x08
#define USB_REQ_SET_CONFIGURATION 0x09
#define USB_REQ_GET_INTERFACE 0x0A
#define USB_REQ_SET_INTERFACE 0x0B
#define USB_REQ_SYNCH_FRAME 0x0C
 
#define USB_TYPE_STANDARD (0x00 << 5)
#define USB_TYPE_CLASS (0x01 << 5)
#define USB_TYPE_VENDOR (0x02 << 5)
#define USB_TYPE_RESERVED (0x03 << 5)
 
#define USB_RECIP_DEVICE 0x00
#define USB_RECIP_INTERFACE 0x01
#define USB_RECIP_ENDPOINT 0x02
#define USB_RECIP_OTHER 0x03
 
/*
* Various libusb API related stuff
*/
 
#define USB_ENDPOINT_IN 0x80
#define USB_ENDPOINT_OUT 0x00
 
/* Error codes */
#define USB_ERROR_BEGIN 500000
 
/*
* This is supposed to look weird. This file is generated from autoconf
* and I didn't want to make this too complicated.
*/
#if 0
#define USB_LE16_TO_CPU(x) do { x = ((x & 0xff) << 8) | ((x & 0xff00) >> 8); } while(0)
#else
#define USB_LE16_TO_CPU(x)
#endif
 
/* Data types */
struct usb_device;
struct usb_bus;
 
/*
* To maintain compatibility with applications already built with libusb,
* we must only add entries to the end of this structure. NEVER delete or
* move members and only change types if you really know what you're doing.
*/
#ifdef PATH_MAX
#define LIBUSB_PATH_MAX PATH_MAX
#else
#define LIBUSB_PATH_MAX 4096
#endif
struct usb_device {
struct usb_device *next, *prev;
 
char filename[LIBUSB_PATH_MAX + 1];
 
struct usb_bus *bus;
 
struct usb_device_descriptor descriptor;
struct usb_config_descriptor *config;
 
void *dev; /* Darwin support */
 
uint8_t devnum;
 
unsigned char num_children;
struct usb_device **children;
};
 
struct usb_bus {
struct usb_bus *next, *prev;
 
char dirname[LIBUSB_PATH_MAX + 1];
 
struct usb_device *devices;
uint32_t location;
 
struct usb_device *root_dev;
};
 
struct usb_dev_handle;
typedef struct usb_dev_handle usb_dev_handle;
 
/* Variables */
extern struct usb_bus *usb_busses;
 
#ifdef __cplusplus
extern "C" {
#endif
 
/* Function prototypes */
 
/* usb.c */
usb_dev_handle *usb_open(struct usb_device *dev);
int usb_close(usb_dev_handle *dev);
int usb_get_string(usb_dev_handle *dev, int index, int langid, char *buf,
size_t buflen);
int usb_get_string_simple(usb_dev_handle *dev, int index, char *buf,
size_t buflen);
 
/* descriptors.c */
int usb_get_descriptor_by_endpoint(usb_dev_handle *udev, int ep,
unsigned char type, unsigned char index, void *buf, int size);
int usb_get_descriptor(usb_dev_handle *udev, unsigned char type,
unsigned char index, void *buf, int size);
 
/* <arch>.c */
int usb_bulk_write(usb_dev_handle *dev, int ep, const char *bytes, int size,
int timeout);
int usb_bulk_read(usb_dev_handle *dev, int ep, char *bytes, int size,
int timeout);
int usb_interrupt_write(usb_dev_handle *dev, int ep, const char *bytes, int size,
int timeout);
int usb_interrupt_read(usb_dev_handle *dev, int ep, char *bytes, int size,
int timeout);
int usb_control_msg(usb_dev_handle *dev, int requesttype, int request,
int value, int index, char *bytes, int size, int timeout);
int usb_set_configuration(usb_dev_handle *dev, int configuration);
int usb_claim_interface(usb_dev_handle *dev, int interface);
int usb_release_interface(usb_dev_handle *dev, int interface);
int usb_set_altinterface(usb_dev_handle *dev, int alternate);
int usb_resetep(usb_dev_handle *dev, unsigned int ep);
int usb_clear_halt(usb_dev_handle *dev, unsigned int ep);
int usb_reset(usb_dev_handle *dev);
 
#if 1
#define LIBUSB_HAS_GET_DRIVER_NP 1
int usb_get_driver_np(usb_dev_handle *dev, int interface, char *name,
unsigned int namelen);
#define LIBUSB_HAS_DETACH_KERNEL_DRIVER_NP 1
int usb_detach_kernel_driver_np(usb_dev_handle *dev, int interface);
#endif
 
char *usb_strerror(void);
 
void usb_init(void);
void usb_set_debug(int level);
int usb_find_busses(void);
int usb_find_devices(void);
struct usb_device *usb_device(usb_dev_handle *dev);
struct usb_bus *usb_get_busses(void);
 
#ifdef __cplusplus
}
#endif
 
#endif /* __USB_H__ */
 
/lab/sipmscan/trunk/libxxusb.cpp
6,7 → 6,7
 
#include <string.h>
#include <malloc.h>
#include "usb.h"
//#include "usb.h"
#include "libxxusb.h"
#include <time.h>
 
/lab/sipmscan/trunk/vxi11_i686/Makefile.old
File deleted
/lab/sipmscan/trunk/vxi11_x86_64/Makefile.old
File deleted
/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);
}
 
//---------------------------------------------------------------