Subversion Repositories f9daq

Compare Revisions

Ignore whitespace Rev 145 → Rev 146

/lab/sipmscan/trunk/.rootrc
0,0 → 1,13
#Rint.Logon: /afs/p-ng.si/home/gkukec/private/Gasper/Programi/rootlogon.C
Gui.DefaultFont: -*-helvetica-medium-r-normal-*-12-*-*-*-*-*-iso8859-1
Gui.MenuFont: -*-helvetica-medium-r-normal-*-12-*-*-*-*-*-iso8859-1
Gui.MenuHiFont: -*-helvetica-bold-r-normal-*-12-*-*-*-*-*-iso8859-1
Gui.DocFixedFont: -*-courier-medium-r-normal-*-12-*-*-*-*-*-iso8859-1
Gui.DocPropFont: -*-helvetica-medium-r-normal-*-12-*-*-*-*-*-iso8859-1
Gui.IconFont: -*-helvetica-medium-r-normal-*-10-*-*-*-*-*-iso8859-1
Gui.StatusFont: -*-helvetica-medium-r-normal-*-10-*-*-*-*-*-iso8859-1
Root.MemStat: 1
Root.ObjectStat: 1
Root.UseTTFonts: true
Root.TTFontPath: $(ROOTSYS)/fonts
X11.UseXft: yes
/lab/sipmscan/trunk/configure
0,0 → 1,295
#!/bin/bash
 
function colorecho
{
echo -e$2 "\033[33m$1\033[39m"
}
 
function errorecho
{
echo -e "\031[33m$1\033[39m"
}
 
function helptext()
{
colorecho "#------------------------------"
colorecho "# Configure instructions: -----"
colorecho "#------------------------------"
colorecho ""
colorecho "./configure [option] [type] [install directories] [ostype]"
colorecho ""
colorecho "[option] = Option for configure:"
colorecho " help Display configure instructions."
colorecho " nomake Only prepare system dependent files (base directory and online/offline mode)."
colorecho " all Prepare system dependent files and make used libraries."
colorecho " clean Clean the installation directory. Does not clean the results directory."
colorecho " compress Compress the source code in a tar-ball."
colorecho ""
colorecho "[type] = Configure for use in online or offline mode (only needed in nomake and all):"
colorecho " I Online mode."
colorecho " O Offline mode (no connection to CAMAC, motor, voltage supply and scope)."
colorecho " S Offline mode with scope connection (no connection to CAMAC, motor and voltage supply)."
colorecho ""
colorecho "[install directories] = Directories where ROOT and NET-SNMP are installed (when running with superuser, this is important, otherwise optional):"
colorecho " --root-install=/root/install/directory"
colorecho " --snmp-install=/snmp/install/directory"
colorecho ""
colorecho "[ostype] = Specific setting for 64bit or 32bit version of OS (optional):"
colorecho " --ostype=i686 32bit OS type"
colorecho " --ostype=x86_64 64bit OS type"
colorecho ""
colorecho "Example:"
colorecho " ./configure all I --root-install=/home/user/root --snmp-install=/home/user/snmp"
colorecho ""
colorecho "#------------------------------"
}
 
# Check for arguments
if [ "$1" == "" ]; then
errorecho "Error! No arguments supplied."
echo ""
helptext
exit 1
else
# When using help, only display help and then exit
if [ "$1" == "help" ]; then
helptext
exit 0
fi
 
# Print help and exit if we give a wrong first argument
if [ "$1" != "nomake" ] && [ "$1" != "all" ] && [ "$1" != "clean" ] && [ "$1" != "compress" ]; then
errorecho "Error! Wrong configuration option selected (first argument)."
echo ""
helptext
exit 1
fi
 
startdir=$PWD
 
# Check for ROOT and NET-SNMP install directories and for OS type
snmpsearch="--snmp-install="
rootsearch="--root-install="
ossearch="--ostype="
snmpdirectory=-1
rootdirectory=-1
osmanual=-1
for var in $@
do
case $var in
"$snmpsearch"*)
snmpdirectory=${var#$snmpsearch}
echo "NET-SNMP directory: $snmpdirectory";;
"$rootsearch"*)
rootdirectory=${var#$rootsearch}
echo "ROOT directory: $rootdirectory";;
"$ossearch"*)
osmanual=${var#$ossearch};;
*) ;;
esac
done
# If not supplied, check automatically for OS type
if [ $osmanual == -1 ]; then
ostype=`uname -p`
if [ "$ostype" != "x86_64" ] && [ "$ostype" != "i686" ]; then
ostype=`uname -i`
if [ "$ostype" != "x86_64" ] && [ "$ostype" != "i686" ]; then
ostype=`uname -m`
fi
fi
else
ostype=$osmanual
fi
# Check for installation directory of ROOT - if variables not currently set, remind user to set them before running make
if [ "$1" != "clean" ] && [ "$1" != "compress" ]; then
if [ $rootdirectory != -1 ]; then
printenv ROOTSYS > /dev/null
if [ $? != 0 ]; then
colorecho "ROOT environment variables not set. Please run \"source $rootdirectory/bin/thisroot.sh\", before using make."
fi
else
colorecho "Before running make, please make sure ROOT environment variables are set."
fi
fi
 
# Compiles the table microcontroller program
if [ "$1" == "all" ]; then
if [ -d $startdir/src/MIKRO ]; then
cd $startdir/src/MIKRO
rm -f $startdir/src/MIKRO/mikro_ctrl
make
cd $startdir
fi
fi
 
# When using compress, only create a tar-ball and then exit
if [ "$1" == "compress" ]; then
cd $startdir
if [ ! -d $startdir/sipmscan_trunk ]; then
mkdir $startdir/sipmscan_trunk
mkdir $startdir/sipmscan_trunk/results
mkdir $startdir/sipmscan_trunk/layout
mkdir $startdir/sipmscan_trunk/settings
echo "Copying files to temporary directory $startdir/sipmscan_trunk..."
cp -r configure ./dict ./doc ./include ./input ./src ./sipmscan_trunk/
cp -r ./layout/default.layout ./sipmscan_trunk/layout/
echo "default.layout" > ./sipmscan_trunk/layout/selected_layout.txt
# TODO - Settings default files
cd $startdir/sipmscan_trunk
echo "Cleaning the base directory in $startdir/sipmscan_trunk..."
rm -f ./*.bak
echo "Cleaning the subdirectories of $startdir/sipmscan_trunk..."
rm -f ./*/*.bak
cd $startdir/sipmscan_trunk/src
rm -f ./*/*.bak
cd $startdir/sipmscan_trunk/include/vxi11_x86_64
echo "Cleaning the 64 bit VXI11 directory in $startdir/sipmscan_trunk/include/vxi11_x86_64..."
rm -f ./*.bak
make clean
cd $startdir/sipmscan_trunk/include/vxi11_i686
echo "Cleaning the 32 bit VXI11 directory in $startdir/sipmscan_trunk/include/vxi11_i686..."
rm -f ./*.bak
make clean
cd $startdir
echo "Creating a tar-ball sipmscan_trunk.tar.gz..."
tar czf $startdir/sipmscan_trunk.tar.gz ./sipmscan_trunk
echo "Removing the temporary directory $startdir/sipmscan_trunk..."
rm -fr $startdir/sipmscan_trunk
exit 0
else
errorecho "Error! Directory ./sipmscan_trunk already exists."
exit 1
fi
fi
 
# Configure the workstation information and directory of program (0 if we find something and 1 otherwise)
basedir=$(echo $startdir | sed 's/\//\\\//g')
 
if [ "$1" == "nomake" ] || [ "$1" == "all" ]; then
if [ "$2" == "O" ] || [ "$2" == "I" ] || [ "$2" == "S" ]; then
# Setting up the current working computer
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/input/workstation.h.mid
fi
grep -q "#define rootdir \"path-to-installation\"" $startdir/input/workstation.h.in
if [ $? == 0 ]; then
sed "s/path-to-installation/$basedir/g" $startdir/input/workstation.h.mid > $startdir/input/workstation.h.mid2
rm $startdir/input/workstation.h.mid
fi
# Check if we are connected to IJS network
etnet=$(ifconfig | grep "178.172.43.")
if [ "$etnet" == "" ]; then
sed "s/define IJSNET 1/define IJSNET 0/" $startdir/input/workstation.h.mid2 > $startdir/include/workstation.h
rm $startdir/input/workstation.h.mid2
else
cp $startdir/input/workstation.h.mid2 $startdir/include/workstation.h
rm $startdir/input/workstation.h.mid2
fi
# Setting up the OS type specific files
grep -q "#include \"vxi11_user.h\"" $startdir/input/daqscope.C.in
if [ $? == 0 ]; then
sed "s/vxi11_user.h/..\/include\/vxi11_$ostype\/vxi11_user.h/g" $startdir/input/daqscope.C.in > $startdir/src/daqscope.C
fi
grep -q "SHLIB = \$(LIBFILE) \$(LDIR)\/libvxi11.a" $startdir/input/Makefile.in
if [ $? == 0 ]; then
if [ "$2" == "I" ]; then
sed "s/SHLIB = \$(LIBFILE) \$(LDIR)\/libvxi11.a/SHLIB = \$(LIBFILE) \$(LDIR)\/libvxi11.a -lusb/g" $startdir/input/Makefile.in > $startdir/Makefile.mid
fi
fi
grep -q "CAMLIB = \$(LIBFILE)" $startdir/input/Makefile.in
if [ $? == 0 ]; then
if [ "$2" == "I" ]; then
sed "s/CAMLIB = \$(LIBFILE)/CAMLIB = \$(LIBFILE) -lusb/g" $startdir/Makefile.mid > $startdir/Makefile.mid2
rm $startdir/Makefile.mid
elif [ "$2" == "O" ] || [ "$2" == "S" ]; then
cp $startdir/input/Makefile.in $startdir/Makefile.mid2
fi
fi
sed "s/OSTYPE=none/OSTYPE=$ostype/g" $startdir/Makefile.mid2 > $startdir/Makefile
rm $startdir/Makefile.mid2
 
if [ "$2" == "O" ] || [ "$2" == "S" ]; then
cp $startdir/input/daqusb.C.offline $startdir/src/daqusb.C
cp $startdir/input/libxxusb.h.offline $startdir/include/libxxusb.h
cp $startdir/input/usb.h.offline $startdir/include/usb.h
elif [ "$2" == "I" ]; then
cp $startdir/input/daqusb.C.online $startdir/src/daqusb.C
cp $startdir/input/libxxusb.h.online $startdir/include/libxxusb.h
fi
 
echo "#!/bin/bash" > $startdir/start.sh
echo "dir=\`dirname \$0\`" >> $startdir/start.sh
echo "" >> $startdir/start.sh
echo "snmpdirectory=$snmpdirectory" >> $startdir/start.sh
echo "rootdirectory=$rootdirectory" >> $startdir/start.sh
echo "" >> $startdir/start.sh
cat $startdir/input/start.sh.in >> $startdir/start.sh
chmod ug+x $startdir/start.sh
fi
fi
 
# In case we just want to set the workstation information, exit here
if [ "$1" == "nomake" ]; then
exit 0
fi
 
# 64 bit configuration rules
if [ $ostype == "x86_64" ]; then
vxidir=$startdir/include/vxi11_$ostype
if [ -d $vxidir ]; then
cd $vxidir
if [ "$1" == "clean" ]; then
make clean
cd $startdir
make clean
rm -f Makefile
else
if [ "$2" == "O" ] || [ "$2" == "I" ] || [ "$2" == "S" ]; then
make
else
errorecho "Error! No configuration type selected (second argument)."
echo ""
helptext
exit 1
fi
fi
cd $startdir
else
errorecho "No 64 bit VXI11 source folder."
exit 1
fi
# 32 bit configuration rules
elif [ $ostype == "i686" ]; then
vxidir=$startdir/include/vxi11_$ostype
if [ -d $vxidir ]; then
cd $vxidir
if [ "$1" == "clean" ]; then
make clean
cd $startdir
make clean
rm -f Makefile
else
if [ "$2" == "O" ] || [ "$2" == "I" ] || [ "$2" == "S" ]; then
make
else
errorecho "Error! No installation type selected (second argument)."
echo ""
helptext
exit 1
fi
fi
cd $startdir
else
errorecho "No 32 bit VXI11 source folder."
exit 1
fi
else
errorecho "No OS type information found."
exit 1
fi
fi
 
exit 0
Property changes:
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: sipmscan/trunk/dict/GuiLinkDef.h
===================================================================
--- sipmscan/trunk/dict/GuiLinkDef.h (nonexistent)
+++ sipmscan/trunk/dict/GuiLinkDef.h (revision 146)
@@ -0,0 +1,18 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+//#pragma link C++ class TGMdiSubwindow+;
+#pragma link C++ class TGAppMainFrame+;
+
+//#pragma link C++ function MyEventHandler;
+//#pragma link C++ function GetDebug;
+//#pragma link C++ function MyRedraw;
+//#pragma link C++ function MyTimer;
+
+//#pragma link C++ class daq;
+
+#endif
+
Index: sipmscan/trunk/dict/LibLinkDef.h
===================================================================
--- sipmscan/trunk/dict/LibLinkDef.h (nonexistent)
+++ sipmscan/trunk/dict/LibLinkDef.h (revision 146)
@@ -0,0 +1,8 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#endif
+
Index: sipmscan/trunk/dict/TestLinkDef.h
===================================================================
--- sipmscan/trunk/dict/TestLinkDef.h (nonexistent)
+++ sipmscan/trunk/dict/TestLinkDef.h (revision 146)
@@ -0,0 +1,9 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class TSubStructure+;
+
+#endif
Index: sipmscan/trunk/doc/INSTALL
===================================================================
--- sipmscan/trunk/doc/INSTALL (nonexistent)
+++ sipmscan/trunk/doc/INSTALL (revision 146)
@@ -0,0 +1,56 @@
+SOFTWARE FOR SIPM CHARACTERIZATION WITH CAMAC, SCOPE, BIAS VOLTAGE AND TABLE POSITION SUPPORT
+=============================================================================================
+By Gasper Kukec Mezek, April 2015.
+
+________________
+1. Installation:
+
+Pre-requisites for offline and online modes:
+a) Offline mode (support for histogramming and analysis):
+ - A newer (5.34 or higher, support for version 6 not added yet) pro version of ROOT (https://root.cern.ch).
+b) Online mode (support for histogramming, analysis and data acquisition):
+ - Perl developer package libperl-dev for installation of net-snmp (sudo apt-get install libperl-dev).
+ - Current version of net-snmp (http://www.net-snmp.org).
+ - A newer (5.34 or higher, support for version 6 not added yet) pro version of ROOT (https://root.cern.ch).
+ - USB developer package libusb-dev (sudo apt-get install libusb-dev).
+
+Installation is done through the usual "./configure" and "make" commands to enable the use of this software with 32 bit or 64 bit systems.
+
+Configure takes the following arguments:
+- First argument is the configure option (help, nomake, all, clean, compress):
+ help = shows configure help
+ all = prepares OS dependent files and makes the needed usb daq libraries
+ nomake = only prepares OS dependent files
+ clean = cleans the installation to the base file structure (keeps the results directory)
+ compress = compresses the base installation into a tar-ball
+- 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) = Online mode
+ only a connected scope (S) = Offline mode with oscilloscope connection
+ with no connected devices (O) = Offline mode
+- The following arguments set specific computer details and can be entered in any order:
+ a) --root-install=/path/to/root/directory -> The ROOT install directory, if it is not installed in a standard location (especially needed when running the program with superuser, since it usually does not have the required environment variables).
+ b) --snmp-install=/path/to/snmp/directory -> The NET-SNMP install directory, if it is not installed in a standard location.
+ c) --ostype=YYYY -> Optional argument to specifically set the OS type to either 32bit (YYYY = i686) or 64bit (YYYY = x86_64). If argument not supplied, the configure script will try to get this information automatically through uname.
+
+Running "./configure" or "./configure help" will give more information on specific uses.
+Example:
+ ./configure all I --root-install=/opt/root --snmp-install=/opt/net-snmp --ostype=i686
+
+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
+
+On first run of the program, make sure to copy the ./mpod/WIENER-CRATE-MIB.txt to the MIB directory in your installation of net-snmp. This can be in:
+ ~/.snmp/mibs
+or
+ [/snmp/install/directory]/share/snmp/mibs
+
+________________________
+2. Running the software:
+
+Once installation is performed, use
+ ./start.sh
+to start the software in offline mode or
+ sudo ./start.sh
+to start the software in online mode. Once the software starts, it will let you know (in the terminal) if connection to CAMAC was correctly established.
Index: sipmscan/trunk/doc/README
===================================================================
--- sipmscan/trunk/doc/README (nonexistent)
+++ sipmscan/trunk/doc/README (revision 146)
@@ -0,0 +1,576 @@
+SOFTWARE FOR SIPM CHARACTERIZATION WITH CAMAC, SCOPE, BIAS VOLTAGE AND TABLE POSITION SUPPORT
+=============================================================================================
+By Gasper Kukec Mezek, April 2015.
+
+==============
+= Contents ===
+==============
+
+ 1. Installation
+ 2. Running the software
+ 3. Program feature overview
+ 3a. Current program version (trunk)
+ 3b. Old program version (trunk_v0.9)
+ 4. Preparing for measurements
+ 4a. Pre-software checks
+ 4b. Experimental setup pre-measurement checks
+ 4c. Software pre-measurement checks
+ 5. Measurements
+ 5a. Measurement settings
+ 5b. Temperature chamber considerations
+ 5c. Movement table
+ 5d. Bias voltage supply
+ 6. Measurement files
+ 6a. ROOT file structure
+ 6b. Opening measurement files
+ 7. Analysis
+ 8. Change log
+
+=====================
+= 1. Installation ===
+=====================
+
+See $sipmscan/doc/INSTALL for installation instructions or use "./configure help".
+
+=============================
+= 2. Running the software ===
+=============================
+
+Once installation is performed, use
+ ./start.sh
+to start the software in offline mode or
+ sudo ./start.sh
+to start the software in online mode. Once the software starts, it will let you know (in the terminal) if connection to CAMAC
+was correctly established.
+
+=================================
+= 3. Program feature overview ===
+=================================
+
+This part describes the different parts of the software and a short description on what they do.
+____________________________________
+3a. Current program version (trunk):
+
+The main window is divided into 4 tabs and then further into subwindows:
+1) Measurement tab:
+ a) Settings pane:
+ - ON/OFF switches for voltage, surface, Z axis and rotation scans (ON when checked).
+ - A voltage limiter -> Sets the maximum output voltage that can be set under Output voltage (sample safety reasons).
+ - Nr. of channels -> The number of channels to measure. Each channel corresponds to an ADC/TDC pair.
+ - Position units -> For display, use either movement table native units or micrometers (table units default).
+ - Rotation units -> For display, use either rotation table native units or degrees (degrees default).
+ - Scope IP -> Sets the oscilloscope IP address for connections to a device.
+ - LASER settings info panel -> Additional information to be written to the output file header (most generally used for
+ laser information).
+ - Chamber temperature -> Chamber temperature to be written to the output file (temperature not directly taken from the
+ fieldpoint sensor).
+ - Live histogram ON/OFF -> ON/OFF switch for live histogram update. Offers quick overview of the current measurement.
+ Should be avoided for scans.
+ b) Display: Display of the live histogram, when it is turned on.
+ c) Main measurement window:
+ - Settings for bias voltage, table position and incidence angle measurements.
+ - Additional settings enabled, when scans are enabled.
+ - If only one directional scan in X or Y direction is needed, set measurement to a surface scan and leave the other
+ step size to 0.
+ - Number of events -> Number of events gathered in one measurement.
+ - Time stamp -> Date and time of measurement that is written to the header of the output file.
+ - Save to file -> Selecting of output file filename. For scans, sequential numbers are appended to the end of the
+ selected filename (i.e. /path/to/test.root will in a scan have /path/to/test_001.root, /path/to/test_002.root,...).
+ - Start acquisition -> Starts the measurement based on currently selected settings.
+ - Current measurement progress bar -> Determines the status of the current measurement.
+
+2) Analysis tab:
+ a) Histogram file selection:
+ - Open past measurements for analysis. Additional display of header information for quicker reference.
+ - If using multiple files for the analysis, use multiple file select or select all listed files. They will be used in
+ order displayed on the list.
+ - Use the Clear list button to clear all entries in from the list.
+ - Use the edit header button to update any information inside the headers of entries selected on the list.
+ b) Histogram: Displays the currently selected histogram from the histogram file selection subwindow.
+ c) Histogram controls:
+ - Enables plotting options for the currently selected histogram and to setup spectral options for analysis.
+ - ADC range -> Sets the range of the ADC spectrum. Ranges are automatic, when set to (0,0).
+ - TDC range -> Sets the range of the TDC spectrum. TDC spectrum determines the events used for plotting the ADC spectrum.
+ - Y range -> Sets the range of the Y axis on the spectrum. Ranges are automatic, when set to (0,0).
+ - Display channel -> Selects the channel to plot, when opening a multichannel measurement file.
+ - Plot type buttons -> Buttons to change between ADC, TDC or ADC/TDC type of plot.
+ - Logarithmic scale ON/OFF -> Toggle for logarithmic Y axis scale.
+ - Clean plots ON/OFF -> Toggle for hiding plot information or not (such as plot title, fitting information, statistics
+ information).
+ - Export -> Exports the currently selected histograms (ADC, TDC or ADC/TDC form selected files) into the .pdf format.
+ - Edit -> UNDER DEVELOPMENT! Opens the currently visible plot in the Histogram subwindow in a new tab to enable editing.
+ d) Analysis:
+ - Options for specific analysis types (integrate spectrum, relative PDE, breakdown voltage, surface scan, timing). When
+ using Start button, analysis starts, saves results and quits. When using Start and edit button, analysis starts and gives
+ options to further edit the results.
+ - General fit settings (Peak sigma, S/N ratio, background interpolation, ADC spectrum offset, Maximum acceptable peak
+ fit error, pedestal lower limit, background subtraction, export fits). Settings for analysis based on fitting of peaks
+ on the ADC spectra (breakdown voltage and relative PDE). The current progress of the analysis is displayed on the
+ progress bar.
+
+3) Monitoring tab: UNDER DEVELOPMENT! Fieldpoint temperature sensor data view.
+
+4) Help tab: Displays the contents of this help file.
+
+On the top, there are 3 menus:
+a) File:
+ - Set user layout -> Set a user saved layout of the program subwindows or use the default.
+ - Save current layout -> Save the program subwindow layout to be used later. This will remember the sizes of each subwindow
+ (Settings pane, Main measurement window, Display, Histogram file selection,...) and the overall size of the program window.
+ - Save current measurement settings -> UNDER DEVELOPMENT! Will evantually save the entered values from the Measurement tab.
+ - Save current analysis settings -> UNDER DEVELOPMENT! Will eventually save the entered values from the Analysis tab.
+ - Exit -> Exit the software (shortkey x)
+
+b) Analysis (each takes you to the appropriate options for the analysis):
+ - Histogram type -> Change between histogram types (same as in histogram controls window).
+ - Fit spectrum -> UNDER DEVELOPMENT! Will produce a fit of ADC spectrum peak structure of the current file/files.
+ - Integrate spectrum -> Integrate the ADC spectrum of the current file/files inside the selected ADC range.
+ - Integrate spectrum (X direction) -> Same as Integrate spectrum, but the selected files were produced as X axis scans.
+ Makes the determination of an X directional edge scan and produces a 2D plot if Z axis scan was also enabled.
+ - Integrate spectrum (Y direction) -> Same as Integrate spectrum (X direction), but the selected files were produced as
+ Y axis scans.
+ - Relative PDE -> Produce a relative PDE plot, where selected files were produced as incidence angle scans.
+ - Surface 2D scan -> Produce an integral of the ADC spectrum, where selected files were produced as surface scans (in
+ X and Y directions).
+ - Timing analysis -> UNDER DEVELOPMENT! Will make an analysis on the TDC spectrum of measurements.
+
+c) Help information
+
+Important!
+When using any analysis method, only events inside the selected TDC window will be used (set the TDC range accordingly).
+
+_____________________________________
+3b. Old program version (trunk_v0.9):
+
+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
+ - incidence angle -> the angle at which the sample is rotated around its axis, relative to the LASER beam (0 degrees is
+ perpendicular to LASER beam)
+
+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
+ - to edit the header information of currently selected files, use the edit header button
+ - any opened measurement has an info display of its header at the bottom for easier navigation
+
+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)
+ - Relative PDE -> calculation of the relative PDE for the currently selected files
+
+c) Tools:
+ - Fieldpoint temperature sensor -> direct graphing of the fieldpoint temperature sensor (with settings for fieldpoint channel,
+ start time and end time), output is a graph (if exporting) and a comma separated list saved to folder ./fieldpoint. Updating
+ the graph can cause unstable behavior. If possible, use ~/sipmscan/fieldpoint_standalone instead.
+
+d) Windows:
+ - Specific window tiling
+ - Switch between active windows
+
+e) 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. Preparing for measurements ===
+===================================
+
+General information for preparing the experimental setup and software for measurements.
+
+________________________
+4a. Pre-software checks:
+
+Before running the Online version of the program, make sure that CAMAC (Computer Automated Measurement And Control) is turned
+on and is connected to the computer via a USB cable. If upon starting, the program gives the following message:
+
+ daq::connect() - No devices were detected!
+
+then CAMAC was not started or the program did not properly register it.
+
+In addition, for the Online version of the program, make sure that all movement table controllers are turned on and are connected
+to the computer via a USB cable.
+
+For the connection with the oscilloscope (Online and Offline with scope control versions of the program), make sure it is
+connected to the same network with a UTP cable and that the VXI software is started on it.
+
+______________________________________________
+4b. Experimental setup pre-measurement checks:
+
+When making changes inside the setup, make sure that no cables are hindering the movement of any of the movement tables. For
+the X, Y and Z axis table, the most critical are motor control cables (white, flat, multiwire cables) and the optical cable
+for laser optics (yellow or orange optical fibre). For the rotation table, the most critical are voltage supply cable (marked
+with BIAS) and signal cables (the same as bias cable, but unmarked or marked with SIGNAL).
+
+Additionally, whenever putting the experimental setup back together, note the distance between the laser optics and the sample.
+The sample should be placed out of harms way from the collimator of the optics (check it by setting Z axis position to 0).
+
+____________________________________
+4c. Software pre-measurement checks:
+
+Before starting any measurement, it is suggested to set the Voltage limit (Settings pane, Measurement tab) in order to avoid
+any unwanted mistakes in bias voltage settings (to avoid any irreparable damage to the sample). Also, make sure to note the
+output channel for bias voltage supply and not change any other channels (since they could be connected to other experimental
+setups).
+
+=====================
+= 5. Measurements ===
+=====================
+
+Information on the settings for performing measurements available in this program and information on the movement tables.
+
+_________________________
+5a. Measurement settings:
+
+On the Settings pane in the Measurement tab, the type of measurement can be selected:
+- None is checked: The program will perform a single measurement (useful for quickly determining the state of the setup).
+- Voltage scan is checked: The program will enable V(min), V(max) and V(step) settings and perform multiple measurements at
+different bias voltages. The number of measurements is equal to:
+
+ Floor( [V(max) - V(min)]/V(step) )
+
+ The last measurement is at a voltage always lower or equal to V(max) for safety reasons. Whenever V(step) is 0, only one
+measurement will be performed at V(min).
+
+- Surface scan is checked: The program will enable X(min), X(max) and X(step), and Y(min), Y(max) and Y(step) settings and
+perform multiple measurements at different table positions (surface scan). The number of measurements is equal to:
+
+ Floor( [X(max) - X(min)]/X(step) ) Floor( [Y(max) - Y(min)]/Y(step) )
+
+ The last measurement is at a position always smaller or equal to X(max) or Y(max). Whenever X(step) is 0, only one measurement
+will be performed at X(min) and equally in the Y axis direction. By setting one axis step size to 0, only scans along one axis
+are performed (for example for edge scans).
+
+- Z-axis scan is checked: The program will enable Z(min), Z(max) and Z(step) settings and perform multiple measurements at
+different distances between laser optics and the sample (Z axis). The number of measurements is equal to:
+
+ Floor( [Z(max) - Z(min)]/Z(step) )
+
+ The last measurement is at a position always smaller or equal to Z(max). Whenever Z(step) is 0, only one measurement will be
+performed at Z(min).
+
+- Rotation scan is checked: The program will enable Angle(min), Angle(max) and Angle(step) settings and perform multiple
+measurements at different incidence angles (angle away from perpendicular incidence of laser light on the sample). The number
+of measurements is equal to:
+
+ Floor( [Angle(max) - Angle(min)]/Angle(step) )
+
+ The last measurement is at an angle always smaller or equal to Angle(max). Whenever Angle(step) is 0, only one measurement
+will be performed at Angle(min).
+
+Surface scan and Z axis scan can be combined to perform edge scans at different distances between optics and sample (useful
+for finding the focal point of the laser).
+
+_______________________________________
+5b. Temperature chamber considerations:
+
+Whenever using the temperature chamber, be careful about the set temperature. SiPM samples have a specific operational and
+storage temperatures that should not be exceeded. The temperature chamber, however, has slight overshoots when increasing
+the temperature, thus heating slightly above the set temperature (sometimes as much as 5 degrees) and then cooling back down.
+
+The chamber also has some problems cooling after previous heating (ex. coming from 0 degrees to 25 degrees and then again
+cooling the chamber). In this case, it will seem to remain around some temperature, although it is supposed to be cooling
+down. Sometimes this can be solved by turning off the chamber and waiting for some time or by making a large temperature
+jump from higher to lower temperature (taking into consideration the sample temperature range).
+
+Opening the chamber after measurements at low temperatures should be very short, since condensation forms very quickly that
+can then lead to the water droplets freezing at low temperatures. Ideally, the chamber should be warmed close to room
+temperature before opening, but any very short changes to the setup can still be performed when at lower temperatures.
+
+___________________
+5c. Movement table:
+
+The movement tables are controlled by National Aperture MicroMini controllers through a subprogram found in
+$sipmscan/trunk/src/MIKRO. Sometimes special measures are needed (in case of problems) that are not available inside the
+sipmscan software, but can be achieved by going directly to the subprogram. The subprogram can be run, by going directly
+to its directory and running:
+
+ ./mikro_ctrl [arguments]
+
+The arguments can be (only running ./mikro_ctrl will bring up help information):
+- Node select: -n [node nr]. The [nodenr] is the address number of the controller as set on the front of the MicroMini
+controller.
+- Initialize node: -i [init type]. The [inittype] is the initialization type that can be 3M Linear (1), 3M Rotational (2),
+4M Linear (3) or 4M Rotational (4). 3M are the smaller/shorter versions, while 4M are the larger/longer versions (all three
+axis are 4M Linear and the angle is 3M Rotational). Always needs the node select argument (-n).
+- Node homing: -h. Sets the node to a predetermined 0 value (home). Always needs the node select argument (-n). IMPORTANT: The
+rotational table must never be set to home! It does not have a predetemined zero, so the table will infinitely spin and can
+cause harm to the sample or attached cables.
+- Reset node: -r. Does a complete reset of the controller. Always needs the node select argument (-n). After reset, the
+controller needs to be initialized in order to work properly.
+- Node status: -a. Returns the current status of the controller. Can be used with node select argument (-n) to target specific
+controller or without to display status from all.
+- Node position: -p. Returns the current position of the controller. Always needs the node select argument (-n).
+- Node get command: -g [command]. Get return value from the issued command. Always needs the node select argument (-n). For
+possible commands, see the MicroMini user manual.
+- Node set command: -v [value] -s [command]. Set a value with an issued command. Always needs the node select argument (-n).
+For possible commands and values, see the MicroMini user manual.
+- Custom node command: -c [command]. Run one of the node commands without setting a value. Always needs the node select
+argument (-n). For possible commands and values, see the MicroMini user manual.
+
+Example commands:
+- Reset node 1:
+ ./mikro_ctrl -n 1 -r
+- Initialize node 2 as a 4M Linear type:
+ ./mikro_ctrl -n 2 -i 3
+- Home node 3:
+ ./mikro_ctrl -n 3 -h
+- Determine node 1 position:
+ ./mikro_ctrl -n 1 -p
+- Prepare to move node 2 to an absolute position of 1000 and move it:
+ ./mikro_ctrl -n 2 -v 500 -s la
+ ./mikro_ctrl -c m
+- Prepare to move node 3 relative to current position for -500 and move it:
+ ./mikro_ctrl -n 2 -v -500 -s lr
+ ./mikro_ctrl -c m
+- Abort the current movement of node 4:
+ ./mikro_ctrl -n 4 -c ab
+
+Documentation:
+- MicroMini controller manual: http://www-f9.ijs.si/~rok/detectors/oprema/national_aperture_stages/MicroMini_Manual.pdf
+- 4M Linear table: http://www.naimotion.com/mm4mex.htm
+- 3M Rotational table: http://www.naimotion.com/mm3mr.htm
+
+________________________
+5d. Bias voltage supply:
+
+The bias voltage is supplied by the MPOD HV & LV power supply system through a subscript found in $sipmscan/trunk/src/mpod
+(using the snmp software). Sometimes special measures are needed (in case of problems) that are not available inside the
+sipmscan software, but can be achieved by going directly to the subprogram. The subprogram can be run, by going directly to
+its directory and running:
+
+ ./mpod_voltage.sh [arguments]
+
+The arguments can be:
+- Reset all output channels: --resetall
+- Reset a selected output channel: -r [channel]
+- Selects an output channel: -o [channel]
+- Sets the output channel voltage: -v [voltage]
+- Turns the output on/off: -s [0/1]
+- Get the current output channel voltage: -g
+
+Example commands:
+- Get the set bias voltage on channel 1 (U0):
+ ./mpod_voltage.sh -o 1 -g
+- Turn the bias voltage off on channel 2 (U1):
+ ./mpod_voltage.sh -o 2 -s 0
+- Turn the bias voltage on and set it to 24.5V on channel 1 (U0):
+ ./mpod_voltage.sh -o 1 -v 24.5 -s 1
+- Reset channel 2 (U1):
+ ./mpod_voltage.sh -o 2 -r
+
+In its complete state, the command used in the script mpod_voltage.sh for setting for example an output voltage of 24.5 to
+channel 1 (U0):
+ snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru [IP address] outputVoltage.1 F 24.5
+
+Documentation:
+- Net-SNMP: http://www.net-snmp.org/docs/man/
+- MPOD: http://file.wiener-d.com/documentation/MPOD/Manual_MPOD_LV-HV_2.9.pdf
+
+==========================
+= 6. Measurement files ===
+==========================
+
+The measurement files, used for saving results, are constructed in native ROOT format to increase the read/write speeds while
+reading and saving data.
+________________________
+6a. ROOT file structure:
+
+The output ROOT files are structured in this way:
+
+ ROOT file (TFile)
+ |
+ |== header_data (TTree): Header information (same for all events)
+ | |
+ | |== nrch (TBranch): Number of channels (ADC + TDC channels)
+ | |== timestamp (TBranch): Unix timestamp for start of measurement
+ | |== biasvolt (TBranch): Measurement bias voltage
+ | |== xpos (TBranch): X axis position in table units
+ | |== ypos (TBranch): Y axis position in table units
+ | |== zpos (TBranch): Z axis position in table units
+ | |== temperature (TBranch): Chamber temperature
+ | |== angle (TBranch): Incidence angle of measurement
+ | |== laserinfo (TBranch): Additional info for measurement
+ |
+ |== meas_data (TTree): Measured values from ADC and TDC (all events)
+ | |
+ | |== ADC0 (TBranch): All events from ADC channel 0 saved in order
+ | |== TDC0 (TBranch): All events from TDC channel 0 saved in order
+ | |== ADC1 (TBranch): All events from ADC channel 1 saved in order
+ | |== TDC1 (TBranch): All events from TDC channel 1 saved in order
+ | |== ... (TBranch): Additional channels up to 8 (0-7) in total
+ |
+ |== scope_data (TTree, optional): Measured values from the oscilloscope
+ |
+ |== measdata (TBranch): Currently in development
+
+
+The easiest way to get the data is to create structures:
+
+ struct EventHeader {
+ int nrch;
+ int timestamp;
+ double biasvolt;
+ int xpos;
+ int ypos;
+ int zpos;
+ double temperature;
+ double angle;
+ char laserinfo[256];
+ } evtheader;
+
+ struct EventData {
+ int adcdata[8];
+ int tdcdata[8];
+ } evtdata;
+
+ struct EventMeas {
+ double measdata;
+ } evtmeas;
+
+
+Then opening the file:
+
+ TFile* inputfile = TFile::Open("filename.root","READ");
+
+Then getting separate information:
+- for instance for reading the bias voltage from header:
+
+ TTree* sometree;
+ inputfile->GetObject("header_data", sometree);
+ sometree->SetBranchAddress("biasvolt", &evtheader.biasvolt);
+ sometree->GetEntry(0);
+
+- for instance for reading all ADC and TDC events in a file from channel 1 (ADC0):
+
+ TTree* sometree;
+ inputfile->GetObject("meas_data", sometree);
+ char selectedCh[256];
+ for(int i = 0; i < sometree->GetEntries(); i++)
+ {
+ sprintf(selectedCh, "ADC%d", 0);
+ sometree->SetBranchAddress(selectedCh, &evtdata.adcdata[i]);
+ sometree->GetEntry(i);
+
+ sprintf(selectedCh, "TDC%d", 0);
+ sometree->SetBranchAddress(selectedCh, &evtdata.tdcdata[i]);
+ sometree->GetEntry(i);
+ }
+
+______________________________
+6b. Opening measurement files:
+
+The sipmscan software has internal handling for saving and opening measurement files. To open these files for an analysis, use
+the File selection button in the Histogram file selection window (Analysis tab). Once the file or files are opened, it is possible
+to double click a file on the list to display its histogram. The histogram can then be manipulated by changing ADC or TDC ranges,
+or changing the type of displayed histogram (ADC, TDC ADC versus TDC).
+
+Each of the selected files has a display of its header below the file list in order to quickly determine at what conditions and
+when this measurement was taken. If there are any problems with the header, modifications can be performed with the Edit header
+button.
+
+After that analysis on the measurements can be performed, based on the selected ranges for ADC and TDC (note that each measured
+event has a ADC and TDC channel value saved to the file).
+
+=================
+= 7. Analysis ===
+=================
+
+The sipmscan software already includes a number of analysis options:
+- Plotting ADC (Analog-to-Digital Converter) spectrum, TDC (Time-to-Digital Converter) spectrum and ADC versus TDC 2D plots.
+- Fitting of ADC spectrum photon equivalent peaks.
+- ADC spectrum integration: Single or along X or Y directions (for edge scans).
+- Relative Photon Detection Efficiency: Efficiency of sample relative to incidence angle.
+- Breakdown voltage: Determination of silicon detector breakdown voltage through ADC spectrum photon peak separation (gain).
+- Surface scan: Production of a 2D plot by integrating the ADC spectrum in each laser position.
+
+Still to come...
+
+===================
+= 8. Change log ===
+===================
+
+4.4.2016 (Current Rev):
+a) Complete restructure of the program, so that it now runs seperately, not through ROOT (libraries are constructed pre-run).
+Program is now split into multiple tabs for easier use, three of which are Measurement, Analysis and Help.
+b) Added support for relative PDE measurements with included sample rotation table.
+c) Improvement of analysis part of the program (includes ADC spectrum integration, breakdown voltage characterization, surface
+scans, relative PDE characterization,...).
+d) Added tooltips for different parts of the program for quick reference. Use them by hovering over any text entries, number
+entries, check boxes or buttons.
+e) Connection to temperature data and oscilloscope currently under development.
+f) Older version of program moved to https://f9pc00.ijs.si/svn/f9daq/lab/sipmscan/trunk_v0.9 and will no longer be in development.
+
+17.7.2015 (Rev 129):
+a) Fixed a problem with ADC peak fitting (peak fitting returning a segmentation fault).
+b) Added support to edit file headers (in case, some were created at an older date and did not include some header information or
+there was a mistake in writing them).
+c) Temperature data can only be retrieved when connected to the IJS network (IP = 178.172.43.xxx) and is disabled otherwise.
+d) The relative PDE measurement now takes the incidence angle value directly from input files.
+e) Currently, data acquisition only works on 32bit computers.
+f) Fixed issue with program not correctly writting multiple channels.
+
+5.5.2015 (Rev 128):
+a) Added a header display for opened files in the histogram file selection window. This enables a quicker view of the measurement
+information.
+b) Added an incidence angle input to be able to save sample rotation angle to headers of files.
+c) Added support for the fieldpoint temperature sensor (FP RTD 122). Can now plot and export data from the sensor for a specific
+channel and specific time range. For now, this option only works if the PC you are using this program on is connected to an
+internet/ethernet connection at IJS.
+d) Added a limited relative PDE analysis option. At this time, it takes the selected files and calculates the PDE, relative to
+the first selected file. The first file should be measured at incidence angle 0, with others having an incidence angle shift of
++15 (1st file -> 0, 2nd file -> 15, 3rd file -> 30,...).
+
+9.4.2015 (Rev 127):
+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 (Rev 117):
+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)
Index: sipmscan/trunk/doc/configuration.txt
===================================================================
--- sipmscan/trunk/doc/configuration.txt (nonexistent)
+++ sipmscan/trunk/doc/configuration.txt (revision 146)
@@ -0,0 +1,61 @@
+$BASE/.rootrc:
+This file is for setting ROOT environment. See the following to properly use it:
+https://root.cern.ch/root/html/TAttText.html
+ftp://root.cern.ch/root/doc/ROOTUsersGuideHTML/ch02s07.html
+https://root.cern.ch/root/roottalk/roottalk01/2867.html
+
+Here is an example of a .rootrc file:
+Gui.DefaultFont: -*-helvetica-medium-r-normal-*-14-*-*-*-*-*-iso8859-1
+Gui.MenuFont: -*-helvetica-medium-r-normal-*-14-*-*-*-*-*-iso8859-1
+Gui.MenuHiFont: -*-helvetica-bold-r-normal-*-14-*-*-*-*-*-iso8859-1
+Gui.DocFixedFont: -*-courier-medium-r-normal-*-14-*-*-*-*-*-iso8859-1
+Gui.DocPropFont: -*-helvetica-medium-r-normal-*-14-*-*-*-*-*-iso8859-1
+Gui.IconFont: -*-helvetica-medium-r-normal-*-12-*-*-*-*-*-iso8859-1
+Gui.StatusFont: -*-helvetica-medium-r-normal-*-12-*-*-*-*-*-iso8859-1
+Root.MemStat: 1
+Root.ObjectStat: 1
+
+If needed we can also add additional instructions in a C file and run it on each ROOT login:
+Rint.Logon: /path/to/rootlogon.C
+
+/---------------------------
+/--- rootlogon.C -----------
+/---------------------------
+{
+ TStyle *mystyle = new TStyle("mystyle", "My own ROOT style");
+
+ mystyle->SetCanvasBorderMode(0);
+ mystyle->SetFrameBorderMode(0);
+ mystyle->SetPalette(1,0);
+ mystyle->SetOptTitle(0);
+ mystyle->SetCanvasColor(0);
+
+ mystyle->SetStatFontSize(0.024);
+ mystyle->SetStatBorderSize(1);
+ mystyle->SetStatColor(kGray);
+ mystyle->SetStatX(0.925);
+ mystyle->SetStatY(0.925);
+ mystyle->SetStatW(0.13);
+
+ mystyle->SetTextFont(132);
+ mystyle->SetTextSize(0.08);
+
+ mystyle->SetLabelSize(0.03,"xyz");
+ mystyle->SetLabelOffset(0.01,"xyz");
+ mystyle->SetPadTickX(1);
+ mystyle->SetPadTickY(1);
+
+ mystyle->SetCanvasDefX(100);
+ mystyle->SetCanvasDefY(50);
+ mystyle->SetCanvasDefW(900);
+ mystyle->SetCanvasDefH(600);
+ mystyle->SetPadBottomMargin(0.1);
+ mystyle->SetPadTopMargin(0.04);
+ mystyle->SetPadLeftMargin(0.125);
+ mystyle->SetPadRightMargin(0.04);
+
+ gROOT->SetStyle("mystyle");
+ cout << "Setting custom style from /path/to/.rootlogon.C" << endl;
+ return;
+}
+
Index: sipmscan/trunk/doc/documentation.html
===================================================================
--- sipmscan/trunk/doc/documentation.html (nonexistent)
+++ sipmscan/trunk/doc/documentation.html (revision 146)
@@ -0,0 +1,568 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
+ <title>Software for SiPM characterization</title>
+ <link rel="stylesheet" type="text/css" href="style_sheet.css">
+</head>
+
+<body>
+
+<h1 id="#top">Software for SiPM characterization with CAMAC, scope, bias voltage and table position support</h1>
+
+<div>
+ <h2>Contents</h2>
+ <ol>
+ <li><a href="#install">Installation</a></li>
+ <li><a href="#softrun">Running the software</a></li>
+ <li><a href="#featall">Program feature overview</a></li>
+ <ol type="a">
+ <li><a href="#featnew">Current program version (trunk)</a></li>
+ <li><a href="#featold">Old program version (trunk_v0.9)</a></li>
+ </ol>
+ <li><a href="#prepmeasure">Preparing for measurements</a></li>
+ <ol type="a">
+ <li><a href="#presoft">Pre-software checks</a></li>
+ <li><a href="#exppremeasure">Experimental setup pre-measurement checks</a></li>
+ <li><a href="#softpremeasure">Software pre-measurement checks</a></li>
+ </ol>
+ <li><a href="#measures">Measurements</a></li>
+ <ol type="a">
+ <li><a href="#meassettings">Measurement settings</a></li>
+ <li><a href="#tempchamber">Temperature chamber considerations</a></li>
+ <li><a href="#movement">Movement table</a></li>
+ <li><a href="#biasvolt">Bias voltage supply</a></li>
+ </ol>
+ <li><a href="#measfiles">Measurement files</a></li>
+ <ol type="a">
+ <li><a href="#rootfile">ROOT file structure</a></li>
+ <li><a href="#fileopen">Opening measurement files</a></li>
+ </ol>
+ <li><a href="#analysis">Analysis</a></li>
+ <li><a href="#changelog">Change log</a></li>
+ </ol>
+
+ <h2 id="install">1. Installation</h2>
+ <p>Pre-requisites for offline and online modes:</p>
+ <ol type="a">
+ <li>Offline mode (support for histogramming and analysis):</li>
+ <ul>
+ <li>A newer (5.34 or higher, support for version 6 not added yet) pro version of ROOT (<a href="https://root.cern.ch" target="_blank">https://root.cern.ch</a>).</li>
+ </ul>
+ <li>Online mode (support for histogramming, analysis and data acquisition):</li>
+ <ul>
+ <li>Perl developer package libperl-dev for installation of net-snmp (<tt>sudo apt-get install libperl-dev</tt>).</li>
+ <li>Current version of net-snmp (<a href="http://www.net-snmp.org" target="_blank">http://www.net-snmp.org</a>).</li>
+ <li>A newer (5.34 or higher, support for version 6 not added yet) pro version of ROOT (<a href="https://root.cern.ch" target="_blank">https://root.cern.ch</a>).</li>
+ <li>USB developer package libusb-dev (<tt>sudo apt-get install libusb-dev</tt>).</li>
+ </ul>
+ </ol>
+
+ <p>Installation is done through the usual <tt>./configure</tt> and <tt>make</tt> commands to enable the use of this software with 32 bit or 64 bit systems.</p>
+
+ <p>Configure takes the following arguments:</p>
+ <ul>
+ <li>First argument is the configure option (help, nomake, all, clean, compress):</li>
+ <ul style="list-style-type:none">
+ <li><tt>help</tt> = shows configure help</li>
+ <li><tt>all</tt> = prepares OS dependent files and makes the needed usb daq libraries</li>
+ <li><tt>nomake</tt> = only prepares OS dependent files</li>
+ <li><tt>clean</tt> = cleans the installation to the base file structure (keeps the results directory)</li>
+ <li><tt>compress</tt> = compresses the base installation into a tar-ball</li>
+ </ul>
+ <li>Second argument is the online/offline configure setting (only used when first argument is nomake or all), that enables the software to work with:</li>
+ <ul style="list-style-type:none">
+ <li><tt>I</tt> = a connected CAMAC and scope (Online mode)</li>
+ <li><tt>S</tt> = only a connected scope (Offline mode with oscilloscope connection)</li>
+ <li><tt>O</tt> = with no connected devices (Offline mode)</li>
+ </ul>
+ <li>The following arguments set specific computer details and can be entered in any order:</li>
+ <ol type="a">
+ <li><tt>--root-install=/path/to/root/directory</tt> = The ROOT install directory, if it is not installed in a standard location (especially needed when running the program with superuser, since it usually does not have the required environment variables).</li>
+ <li><tt>--snmp-install=/path/to/snmp/directory</tt> = The NET-SNMP install directory, if it is not installed in a standard location.</li>
+ <li><tt>--ostype=YYYY</tt> = Optional argument to specifically set the OS type to either 32bit (<tt>YYYY = i686</tt>) or 64bit (<tt>YYYY = x86_64</tt>). If argument not supplied, the configure script will try to get this information automatically through uname.</li>
+ </ol>
+ </ul>
+
+ <p>Running <tt>./configure</tt> or <tt>./configure help</tt> will give more information on specific uses.</p>
+ <p>Example:</p>
+ <div class="codeback"><pre><code>./configure all I --root-install=/opt/root --snmp-install=/opt/net-snmp --ostype=i686</code></pre></div>
+
+ <p>Once configuration is done, a Makefile will be generated and further installation is done by running <tt>make</tt>. Running <tt>make relib</tt> will only recreate the libraries in case something has been edited in them.</p>
+ <p>Example:</p>
+ <div class="codeback"><pre><code>make</code></pre></div>
+
+ <p>On first run of the program, make sure to copy the <tt>./mpod/WIENER-CRATE-MIB.txt</tt> to the MIB directory in your installation of net-snmp. This can be in <tt>~/.snmp/mibs</tt> or <tt>[/snmp/install/directory]/share/snmp/mibs</tt>.</p>
+ <div class="backtop"><a href="#top">Back to top</a></div>
+
+ <h2 id="softrun">2. Running the software</h2>
+ <p>Once installation is performed, use</p>
+ <div class="codeback"><pre><code>./start.sh</code></pre></div>
+ <p>to start the software in offline mode or</p>
+ <div class="codeback"><pre><code>sudo ./start.sh</code></pre></div>
+ <p>to start the software in online mode. Once the software starts, it will let you know (in the terminal) if connection to CAMAC was correctly established.</p>
+ <div class="backtop"><a href="#top">Back to top</a></div>
+
+ <h2 id="featall">3. Program feature overview</h2>
+ <p>This part describes the different parts of the software and a short description on what they do.</p>
+
+ <h3 id="featnew">3a. Current program version (trunk)</h3>
+ <p>The main window is divided into 4 tabs and then further into subwindows:</p>
+ <ol>
+ <li>Measurement tab:</li>
+ <ol type="a">
+ <li>Settings pane:</li>
+ <ul>
+ <li>ON/OFF switches for voltage, surface, Z axis and rotation scans (ON when checked).</li>
+ <li>A voltage limiter: Sets the maximum output voltage that can be set under Output voltage (sample safety reasons).</li>
+ <li>Nr. of channels: The number of channels to measure. Each channel corresponds to an ADC/TDC pair.</li>
+ <li>Position units: For display, use either movement table native units or micrometers (table units default).</li>
+ <li>Rotation units: For display, use either rotation table native units or degrees (degrees default).</li>
+ <li>Scope IP: Sets the oscilloscope IP address for connections to a device.</li>
+ <li>LASER settings info panel: Additional information to be written to the output file header (most generally used for laser information).</li>
+ <li>Chamber temperature: Chamber temperature to be written to the output file (temperature not directly taken from the fieldpoint sensor).</li>
+ <li>Live histogram ON/OFF: ON/OFF switch for live histogram update. Offers quick overview of the current measurement. Should be avoided for scans.</li>
+ </ul>
+ <li>Display: Display of the live histogram, when it is turned on.</li>
+ <li>Main measurement window:</li>
+ <ul>
+ <li>Settings for bias voltage, table position and incidence angle measurements.</li>
+ <li>Additional settings enabled, when scans are enabled.</li>
+ <li>If only one directional scan in X or Y direction is needed, set measurement to a surface scan and leave the other step size to 0.</li>
+ <li>Number of events: Number of events gathered in one measurement.</li>
+ <li>Time stamp: Date and time of measurement that is written to the header of the output file.</li>
+ <li>Save to file: Selecting of output file filename. For scans, sequential numbers are appended to the end of the selected filename (i.e. <tt>/path/to/test.root</tt> will in a scan have <tt>/path/to/test_001.root</tt>, <tt>/path/to/test_002.root</tt>,...).</li>
+ <li>Start acquisition: Starts the measurement based on currently selected settings.</li>
+ <li>Current measurement progress bar: Determines the status of the current measurement.</li>
+ </ul>
+ </ol><br/>
+
+ <li>Analysis tab:</li>
+ <ol type="a">
+ <li>Histogram file selection:</li>
+ <ul>
+ <li>Open past measurements for analysis. Additional display of header information for quicker reference.</li>
+ <li>If using multiple files for the analysis, use multiple file select or select all listed files. They will be used in order displayed on the list.</li>
+ <li>Use the Clear list button to clear all entries in from the list.</li>
+ <li>Use the edit header button to update any information inside the headers of entries selected on the list.</li>
+ </ul>
+ <li>Histogram: Displays the currently selected histogram from the histogram file selection subwindow.</li>
+ <li>Histogram controls:</li>
+ <ul>
+ <li>Enables plotting options for the currently selected histogram and to setup spectral options for analysis.</li>
+ <li>ADC range: Sets the range of the ADC spectrum. Ranges are automatic, when set to (0,0).</li>
+ <li>TDC range: Sets the range of the TDC spectrum. TDC spectrum determines the events used for plotting the ADC spectrum.</li>
+ <li>Y range: Sets the range of the Y axis on the spectrum. Ranges are automatic, when set to (0,0).</li>
+ <li>Display channel: Selects the channel to plot, when opening a multichannel measurement file.</li>
+ <li>Plot type buttons: Buttons to change between ADC, TDC or ADC/TDC type of plot.</li>
+ <li>Logarithmic scale ON/OFF: Toggle for logarithmic Y axis scale.</li>
+ <li>Clean plots ON/OFF: Toggle for hiding plot information or not (such as plot title, fitting information, statistics information).</li>
+ <li>Export: Exports the currently selected histograms (ADC, TDC or ADC/TDC form selected files) into the .pdf format.</li>
+ <li>Edit: UNDER DEVELOPMENT! Opens the currently visible plot in the Histogram subwindow in a new tab to enable editing.</li>
+ </ul>
+ <li>Analysis:</li>
+ <li>Options for specific analysis types (integrate spectrum, relative PDE, breakdown voltage, surface scan, timing). When using Start button, analysis starts, saves results and quits. When using Start and edit button, analysis starts and gives options to further edit the results.</li>
+ <li>General fit settings (Peak sigma, S/N ratio, background interpolation, ADC spectrum offset, Maximum acceptable peak fit error, pedestal lower limit, background subtraction, export fits). Settings for analysis based on fitting of peaks on the ADC spectra (breakdown voltage and relative PDE). The current progress of the analysis is displayed on the progress bar.</li>
+ </ol><br/>
+
+ <li>Monitoring tab: UNDER DEVELOPMENT! Fieldpoint temperature sensor data view.</li><br/>
+ <li>Help tab: Displays the contents of this help file.</li><br/>
+ </ol>
+
+ <p>On the top, there are 3 menus:</p>
+ <ol>
+ <li>File:</li>
+ <ul>
+ <li>Set user layout: Set a user saved layout of the program subwindows or use the default.</li>
+ <li>Save current layout: Save the program subwindow layout to be used later. This will remember the sizes of each subwindow (Settings pane, Main measurement window, Display, Histogram file selection,...) and the overall size of the program window.</li>
+ <li>Save current measurement settings: UNDER DEVELOPMENT! Will evantually save the entered values from the Measurement tab.</li>
+ <li>Save current analysis settings: UNDER DEVELOPMENT! Will eventually save the entered values from the Analysis tab.</li>
+ <li>Exit: Exit the software (shortkey x)</li>
+ </ul>
+ <li>Analysis (each takes you to the appropriate options for the analysis):</li>
+ <ul>
+ <li>Histogram type: Change between histogram types (same as in histogram controls window).</li>
+ <li>Fit spectrum: UNDER DEVELOPMENT! Will produce a fit of ADC spectrum peak structure of the current file/files.</li>
+ <li>Integrate spectrum: Integrate the ADC spectrum of the current file/files inside the selected ADC range.</li>
+ <li>Integrate spectrum (X direction): Same as Integrate spectrum, but the selected files were produced as X axis scans. Makes the determination of an X directional edge scan and produces a 2D plot if Z axis scan was also enabled.</li>
+ <li>Integrate spectrum (Y direction): Same as Integrate spectrum (X direction), but the selected files were produced as Y axis scans.</li>
+ <li>Relative PDE: Produce a relative PDE plot, where selected files were produced as incidence angle scans.</li>
+ <li>Surface 2D scan: Produce an integral of the ADC spectrum, where selected files were produced as surface scans (in X and Y directions).</li>
+ <li>Timing analysis: UNDER DEVELOPMENT! Will make an analysis on the TDC spectrum of measurements.</li>
+ </ul>
+
+ <li>Help information</li>
+ </ol>
+
+ <p><span>Important!</span> When using any analysis method, only events inside the selected TDC window will be used (set the TDC range accordingly).</p>
+
+ <h3 id="featold">3b. Old program version (trunk_v0.9)</h3>
+ <p>The main window is divided into 5 subwindows:</p>
+ <ol>
+ <li>Settings window:</li>
+ <ul>
+ <li>ON/OFF switches for voltage and surface scans</li>
+ <li>a voltage limiter: sets the maximum output voltage for safety reasons</li>
+ <li>clean plots toggle switch: when ON, no additional stats will be displayed on plots/histograms</li>
+ <li>scope IP: sets the oscilloscope IP address</li>
+ <li>LASER settings info panel: this will be written to the output file and is used for supplying additional information</li>
+ <li>chamber temperature: the chamber temperature to be written to the output file</li>
+ <li>incidence angle: the angle at which the sample is rotated around its axis, relative to the LASER beam (0 degrees is perpendicular to LASER beam)</li>
+ </ul></br>
+
+ <li>Main measurement window:</li>
+ <ul>
+ <li>settings for table position and bias voltage</li>
+ <li>when scans are enabled, additional settings for scans</li>
+ <li>number of events: setting for the number of events to gather in a measurement</li>
+ <li>time stamp: informational time (start time of measurement is written to output file)</li>
+ <li>file selector (for scans, the filenames will be appended sequential numbers to distinguish them)</li>
+ <li>start acquisition button: starts the measurement based on selected settings</li>
+ <li>waveform analysis settings (channel, measurement type)</li>
+ <li>possibility to send custom one-line commands</li>
+ </ul><br/>
+
+ <li>Histogram file selection window:</li>
+ <ul>
+ <li>open past measurements for analysis</li>
+ <li>if using multiple files, use multiple file select or select all listed files</li>
+ <li>files will be used in order displayed on the list</li>
+ <li>to clear the complete list, use the clear list button</li>
+ <li>to edit the header information of currently selected files, use the edit header button</li>
+ <li>any opened measurement has an info display of its header at the bottom for easier navigation</li>
+ </ul><br/>
+ <li>Histogram window: displays the currently selected histogram in the histogram file selection window</li><br/>
+
+ <li>Histogram controls window:</li>
+ <ul>
+ <li>directly linked to the histogram window, it enables plotting options</li>
+ <li>can set ranges on histogram plots</li>
+ <li>can change between different histogram types (ADC, TDC, ADC vs. TDC, 2D surface plot)</li>
+ <li>for the 2D surface plot, the relevant files need to be selected in the histogram file selection window</li>
+ <li>toggle for logarithmic Y scale</li>
+ <li>the currently selected histogram can be manually exported with the export button</li>
+ <li>fit settings used when running "Fit spectrum" and "Fit all selected" options in the Analysis menu</li>
+ </ul><br/>
+ </ol>
+
+ <p>On the top, there are 4 menus:</p>
+ <ol>
+ <li>File:</li>
+ <ul>
+ <li>New Measurement: not working</li>
+ <li>Exit: exit the software (shortkey x)</li>
+ </ul>
+
+ <li>Analysis:</li>
+ <ul>
+ <li>Histogram type: change between histogram types (same as in histogram controls window)</li>
+ <li>Fit spectrum: fit the currently open spectrum for peaks</li>
+ <li>Fit all selected: fit all the selected ADC spectra selected in the histogram file selection window for peaks and display the breakdown voltage plots</li>
+ <li>Integrate spectrum (X, Y): integrate the ADC spectrum for multiple files with an X or Y scan (used for edge scans)</li>
+ <li>Relative PDE: calculation of the relative PDE for the currently selected files</li>
+ </ul>
+
+ <li>Tools:</li>
+ <ul>
+ <li>Fieldpoint temperature sensor: direct graphing of the fieldpoint temperature sensor (with settings for fieldpoint channel, start time and end time), output is a graph (if exporting) and a comma separated list saved to folder <tt>./fieldpoint</tt>. Updating the graph can cause unstable behavior. If possible, use <tt>~/sipmscan/fieldpoint_standalone</tt> instead.</li>
+ </ul>
+
+ <li>Windows:</li>
+ <ul>
+ <li>Specific window tiling</li>
+ <li>Switch between active windows</li>
+ </ul>
+
+ <li>Help information</li>
+ </ol>
+
+ <p><span>Important!</span> 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.</p>
+ <div class="backtop"><a href="#top">Back to top</a></div>
+
+ <h2 id="prepmeasure">4. Preparing for measurements</h2>
+ <p>General information for preparing the experimental setup and software for measurements.</p>
+
+ <h3 id="presoft">4a. Pre-software checks</h3>
+ <p>Before running the Online version of the program, make sure that CAMAC (Computer Automated Measurement And Control) is turned on and is connected to the computer via a USB cable. If upon starting, the program gives the following message:</p>
+ <div class="codeback"><pre><code>daq::connect() - No devices were detected!</code></pre></div>
+ <p>then CAMAC was not started or the program did not properly register it.</p>
+ <p>In addition, for the Online version of the program, make sure that all movement table controllers are turned on and are connected to the computer via a USB cable.</p>
+ <p>For the connection with the oscilloscope (Online and Offline with scope control versions of the program), make sure it is connected to the same network with a UTP cable and that the VXI software is started on it.</p>
+
+ <h3 id="exppremeasure">4b. Experimental setup pre-measurement checks</h3>
+ <p>When making changes inside the setup, make sure that no cables are hindering the movement of any of the movement tables. For the X, Y and Z axis table, the most critical are motor control cables (white, flat, multiwire cables) and the optical cable for laser optics (yellow or orange optical fibre). For the rotation table, the most critical are voltage supply cable (marked with BIAS) and signal cables (the same as bias cable, but unmarked or marked with SIGNAL).</p>
+ <p>Additionally, whenever putting the experimental setup back together, note the distance between the laser optics and the sample. The sample should be placed out of harms way from the collimator of the optics (check it by setting Z axis position to 0).</p>
+
+ <h3 id="softpremeasure">4c. Software pre-measurement checks</h3>
+ <p>Before starting any measurement, it is suggested to set the Voltage limit (Settings pane, Measurement tab) in order to avoid any unwanted mistakes in bias voltage settings (to avoid any irreparable damage to the sample). Also, make sure to note the output channel for bias voltage supply and not change any other channels (since they could be connected to other experimental setups).</p>
+
+ <div class="backtop"><a href="#top">Back to top</a></div>
+
+ <h2 id="measures">5. Measurements</h2>
+ <p>Information on the settings for performing measurements available in this program and information on the movement tables.</p>
+
+ <h3 id="meassettings">5a. Measurement settings</h3>
+ <p>On the Settings pane in the Measurement tab, the type of measurement can be selected:</p>
+ <ul>
+ <li>None is checked: The program will perform a single measurement (useful for quickly determining the state of the setup).</li><br/>
+ <li>Voltage scan is checked: The program will enable <tt>V(min)</tt>, <tt>V(max)</tt> and <tt>V(step)</tt> settings and perform multiple measurements at different bias voltages. The number of measurements is equal to:
+ <div class="codeback"><pre><code>Floor( [V(max) - V(min)]/V(step) )</code></pre></div>
+ The last measurement is at a voltage always lower or equal to <tt>V(max)</tt> for safety reasons. Whenever <tt>V(step)</tt> is 0, only one measurement will be performed at <tt>V(min).</tt></li><br/>
+ <li>Surface scan is checked: The program will enable <tt>X(min)</tt>, <tt>X(max)</tt> and <tt>X(step)</tt>, and <tt>Y(min)</tt>, <tt>Y(max)</tt> and <tt>Y(step)</tt> settings and perform multiple measurements at different table positions (surface scan). The number of measurements is equal to:
+ <div class="codeback"><pre><code>Floor( [X(max) - X(min)]/X(step) )
+Floor( [Y(max) - Y(min)]/Y(step) )</code></pre></div>
+ The last measurement is at a position always smaller or equal to <tt>X(max)</tt> or <tt>Y(max)</tt>. Whenever <tt>X(step)</tt> is 0, only one measurement will be performed at <tt>X(min)</tt> and equally in the Y axis direction. By setting one axis step size to 0, only scans along one axis are performed (for example for edge scans).</li><br/>
+ <li>Z-axis scan is checked: The program will enable <tt>Z(min)</tt>, <tt>Z(max)</tt> and <tt>Z(step)</tt> settings and perform multiple measurements at different distances between laser optics and the sample (Z axis). The number of measurements is equal to:
+ <div class="codeback"><pre><code>Floor( [Z(max) - Z(min)]/Z(step) )</code></pre></div>
+ The last measurement is at a position always smaller or equal to <tt>Z(max)</tt>. Whenever <tt>Z(step)</tt> is 0, only one measurement will be performed at <tt>Z(min)</tt>.</li><br/>
+ <li>Rotation scan is checked: The program will enable <tt>Angle(min)</tt>, <tt>Angle(max)</tt> and <tt>Angle(step)</tt> settings and perform multiple measurements at different incidence angles (angle away from perpendicular incidence of laser light on the sample). The number of measurements is equal to:
+ <div class="codeback"><pre><code>Floor( [Angle(max) - Angle(min)]/Angle(step) )</code></pre></div>
+ The last measurement is at an angle always smaller or equal to <tt>Angle(max)</tt>. Whenever <tt>Angle(step)</tt> is 0, only one measurement will be performed at <tt>Angle(min)</tt>.</li>
+ </ul>
+
+ <p>Surface scan and Z axis scan can be combined to perform edge scans at different distances between optics and sample (useful for finding the focal point of the laser).</p>
+
+ <h3 id="tempchamber">5b. Temperature chamber considerations</h3>
+ <p>Whenever using the temperature chamber, be careful about the set temperature. SiPM samples have a specific operational and storage temperatures that should not be exceeded. The temperature chamber, however, has slight overshoots when increasing the temperature, thus heating slightly above the set temperature (sometimes as much as 5 degrees) and then cooling back down.</p>
+ <p>The chamber also has some problems cooling after previous heating (ex. coming from 0 degrees to 25 degrees and then again cooling the chamber). In this case, it will seem to remain around some temperature, although it is supposed to be cooling down. Sometimes this can be solved by turning off the chamber and waiting for some time or by making a large temperature jump from higher to lower temperature (taking into consideration the sample temperature range).</p>
+ <p>Opening the chamber after measurements at low temperatures should be very short, since condensation forms very quickly that can then lead to the water droplets freezing at low temperatures. Ideally, the chamber should be warmed close to room temperature before opening, but any very short changes to the setup can still be performed when at lower temperatures.</p>
+
+ <h3 id="movement">5c. Movement table</h3>
+ <p>The movement tables are controlled by National Aperture MicroMini controllers through a subprogram found in <tt>$sipmscan/trunk/src/MIKRO</tt>. Sometimes special measures are needed (in case of problems) that are not available inside the sipmscan software, but can be achieved by going directly to the subprogram. The subprogram can be run, by going directly to its directory and running:</p>
+ <div class="codeback"><pre><code>./mikro_ctrl [arguments]</code></pre></div>
+ <p>The arguments can be (only running <tt>./mikro_ctrl</tt> will bring up help information):</p>
+ <ul>
+ <li>Node select: <tt>-n [node nr]</tt>. The <tt>[nodenr]</tt> is the address number of the controller as set on the front of the MicroMini controller.</li>
+ <li>Initialize node: <tt>-i [init type]</tt>. The <tt>[inittype]</tt> is the initialization type that can be 3M Linear (1), 3M Rotational (2), 4M Linear (3) or 4M Rotational (4). 3M are the smaller/shorter versions, while 4M are the larger/longer versions (all three axis are 4M Linear and the angle is 3M Rotational). Always needs the node select argument (<tt>-n</tt>).</li>
+ <li>Node homing: <tt>-h</tt>. Sets the node to a predetermined 0 value (home). Always needs the node select argument (<tt>-n</tt>). <span>IMPORTANT:</span> The rotational table must never be set to home! It does not have a predetemined zero, so the table will infinitely spin and can cause harm to the sample or attached cables.</li>
+ <li>Reset node: <tt>-r</tt>. Does a complete reset of the controller. Always needs the node select argument (<tt>-n</tt>). After reset, the controller needs to be initialized in order to work properly.</li>
+ <li>Node status: <tt>-a</tt>. Returns the current status of the controller. Can be used with node select argument (<tt>-n</tt>) to target specific controller or without to display status from all.</li>
+ <li>Node position: <tt>-p</tt>. Returns the current position of the controller. Always needs the node select argument (<tt>-n</tt>).</li>
+ <li>Node get command: <tt>-g [command]</tt>. Get return value from the issued command. Always needs the node select argument (<tt>-n</tt>). For possible commands, see the MicroMini user manual.</li>
+ <li>Node set command: <tt>-v [value] -s [command]</tt>. Set a value with an issued command. Always needs the node select argument (<tt>-n</tt>). For possible commands and values, see the MicroMini user manual.</li>
+ <li>Custom node command: <tt>-c [command]</tt>. Run one of the node commands without setting a value. Always needs the node select argument (<tt>-n</tt>). For possible commands and values, see the MicroMini user manual.</li>
+ </ul>
+
+ <p>Example commands:</p>
+ <ul>
+ <li>Reset node 1:</li>
+ <div class="codeback"><pre><code>./mikro_ctrl -n 1 -r</code></pre></div>
+ <li>Initialize node 2 as a 4M Linear type:</li>
+ <div class="codeback"><pre><code>./mikro_ctrl -n 2 -i 3</code></pre></div>
+ <li>Home node 3:</li>
+ <div class="codeback"><pre><code>./mikro_ctrl -n 3 -h</code></pre></div>
+ <li>Determine node 1 position:</li>
+ <div class="codeback"><pre><code>./mikro_ctrl -n 1 -p</code></pre></div>
+ <li>Prepare to move node 2 to an absolute position of 1000 and move it:</li>
+ <div class="codeback"><pre><code>./mikro_ctrl -n 2 -v 500 -s la
+./mikro_ctrl -c m</code></pre></div>
+ <li>Prepare to move node 3 relative to current position for -500 and move it:</li>
+ <div class="codeback"><pre><code>./mikro_ctrl -n 2 -v -500 -s lr
+./mikro_ctrl -c m</code></pre></div>
+ <li>Abort the current movement of node 4:</li>
+ <div class="codeback"><pre><code>./mikro_ctrl -n 4 -c ab</code></pre></div>
+ </ul>
+
+ <p>Documentation:</p>
+ <ul>
+ <li><a href="http://www-f9.ijs.si/~rok/detectors/oprema/national_aperture_stages/MicroMini_Manual.pdf" target="_blank">MicroMini controller manual</a></li>
+ <li><a href="http://www.naimotion.com/mm4mex.htm" target="_blank">4M Linear table information</a></li>
+ <li><a href="http://www.naimotion.com/mm3mr.htm" target="_blank">3M Rotational table information</a></li>
+ </ul>
+
+ <h3 id="biasvolt">5d. Bias voltage supply</h3>
+ <p>The bias voltage is supplied by the MPOD HV & LV power supply system through a subscript found in <tt>$sipmscan/trunk/src/mpod</tt> (using the snmp software). Sometimes special measures are needed (in case of problems) that are not available inside the sipmscan software, but can be achieved by going directly to the subprogram. The subprogram can be run, by going directly to its directory and running:</p>
+ <div class="codeback"><pre><code>./mpod_voltage.sh [arguments]</code></pre></div>
+ <p>The arguments can be:</p>
+ <ul>
+ <li>Reset all output channels: <tt>--resetall</tt></li>
+ <li>Reset a selected output channel: <tt>-r [channel]</tt></li>
+ <li>Selects an output channel: <tt>-o [channel]</tt></li>
+ <li>Sets the output channel voltage: <tt>-v [voltage]</tt></li>
+ <li>Turns the output on/off: <tt>-s [0/1]</tt></li>
+ <li>Get the current output channel voltage: <tt>-g</tt></li>
+ </ul>
+
+ <p>Example commands:</p>
+ <ul>
+ <li>Get the set bias voltage on channel 1 (U0):</li>
+ <div class="codeback"><pre><code>./mpod_voltage.sh -o 1 -g</code></pre></div>
+ <li>Turn the bias voltage off on channel 2 (U1):</li>
+ <div class="codeback"><pre><code>./mpod_voltage.sh -o 2 -s 0</code></pre></div>
+ <li>Turn the bias voltage on and set it to 24.5V on channel 1 (U0):</li>
+ <div class="codeback"><pre><code>./mpod_voltage.sh -o 1 -v 24.5 -s 1</code></pre></div>
+ <li>Reset channel 2 (U1):</li>
+ <div class="codeback"><pre><code>./mpod_voltage.sh -o 2 -r</code></pre></div>
+ </ul>
+
+ <p>In its complete state, the command used in the script mpod_voltage.sh for setting for example an output voltage of 24.5 to channel 1 (U0):</p>
+ <div class="codeback"><pre><code>snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru [IP address] outputVoltage.1 F 24.5</code></pre></div>
+
+ <p>Documentation:</p>
+ <ul>
+ <li><a href="http://www.net-snmp.org/docs/man/" target="_blank">Net-SNMP</a></li>
+ <li><a href="http://file.wiener-d.com/documentation/MPOD/Manual_MPOD_LV-HV_2.9.pdf" target="_blank">MPOD documentation</a></li>
+ </ul>
+
+ <div class="backtop"><a href="#top">Back to top</a></div>
+
+ <h2 id="measfiles">6. Measurement files</h2>
+ <p>The measurement files, used for saving results, are constructed in native ROOT format to increase the read/write speeds while reading and saving data.</p>
+
+ <h3 id="rootfile">6a. ROOT file structure</h3>
+ <p>The output ROOT files are structured in this way:</p>
+ <div class="codeback"><div class="codename">ROOT file structure</div>
+ <pre><code>ROOT file (TFile)
+ |
+ |== header_data (TTree): Header information (same for all events)
+ | |
+ | |== nrch (TBranch): Number of channels (ADC + TDC channels)
+ | |== timestamp (TBranch): Unix timestamp for start of measurement
+ | |== biasvolt (TBranch): Measurement bias voltage
+ | |== xpos (TBranch): X axis position in table units
+ | |== ypos (TBranch): Y axis position in table units
+ | |== zpos (TBranch): Z axis position in table units
+ | |== temperature (TBranch): Chamber temperature
+ | |== angle (TBranch): Incidence angle of measurement
+ | |== laserinfo (TBranch): Additional info for measurement
+ |
+ |== meas_data (TTree): Measured values from ADC and TDC (all events)
+ | |
+ | |== ADC0 (TBranch): All events from ADC channel 0 saved in order
+ | |== TDC0 (TBranch): All events from TDC channel 0 saved in order
+ | |== ADC1 (TBranch): All events from ADC channel 1 saved in order
+ | |== TDC1 (TBranch): All events from TDC channel 1 saved in order
+ | |== ... (TBranch): Additional channels up to 8 (0-7) in total
+ |
+ |== scope_data (TTree, optional): Measured values from the oscilloscope
+ |
+ |== measdata (TBranch): Currently in development
+ </code></pre></div>
+
+ <p>The easiest way to get the data is to create structures:</p>
+ <div class="codeback"><div class="codename">Output file structure</div>
+ <pre><code>struct EventHeader {
+ int nrch;
+ int timestamp;
+ double biasvolt;
+ int xpos;
+ int ypos;
+ int zpos;
+ double temperature;
+ double angle;
+ char laserinfo[256];
+} evtheader;
+
+struct EventData {
+ int adcdata[8];
+ int tdcdata[8];
+} evtdata;
+
+struct EventMeas {
+ double measdata;
+} evtmeas;
+ </code></pre></div>
+
+ <p>Then opening the file:</p>
+ <div class="codeback"><pre><code>TFile* inputfile = TFile::Open("filename.root","READ");</code></pre></div>
+
+ <p>And getting separate information:</p>
+ <ul>
+ <li>for instance for reading the bias voltage from header:</li>
+ <div class="codeback"><pre><code>TTree* sometree;
+inputfile->GetObject("header_data", sometree);
+sometree->SetBranchAddress("biasvolt", &evtheader.biasvolt);
+sometree->GetEntry(0);</code></pre></div>
+
+ <li>for instance for reading all ADC and TDC events in a file from channel 1 (ADC0):</li>
+ <div class="codeback"><pre><code>TTree* sometree;
+inputfile->GetObject("meas_data", sometree);
+char selectedCh[256];
+for(int i = 0; i < sometree->GetEntries(); i++)
+{
+ sprintf(selectedCh, "ADC%d", 0);
+ sometree->SetBranchAddress(selectedCh, &evtdata.adcdata[i]);
+ sometree->GetEntry(i);
+
+ sprintf(selectedCh, "TDC%d", 0);
+ sometree->SetBranchAddress(selectedCh, &evtdata.tdcdata[i]);
+ sometree->GetEntry(i);
+}</code></pre></div>
+ </ul>
+
+ <h3 id="fileopen">6b. Opening measurement files</h3>
+ <p>The sipmscan software has internal handling for saving and opening measurement files. To open these files for an analysis, use the File selection button in the Histogram file selection window (Analysis tab). Once the file or files are opened, it is possible to double click a file on the list to display its histogram. The histogram can then be manipulated by changing ADC or TDC ranges, or changing the type of displayed histogram (ADC, TDC ADC versus TDC).</p>
+ <p>Each of the selected files has a display of its header below the file list in order to quickly determine at what conditions and when this measurement was taken. If there are any problems with the header, modifications can be performed with the Edit header button.</p>
+ <p>After that analysis on the measurements can be performed, based on the selected ranges for ADC and TDC (note that each measured event has a ADC and TDC channel value saved to the file).</p>
+
+ <div class="backtop"><a href="#top">Back to top</a></div>
+
+ <h2 id="analysis">7. Analysis</h2>
+ <p>The sipmscan software already includes a number of analysis options:</p>
+ <ul>
+ <li>Plotting ADC (Analog-to-Digital Converter) spectrum, TDC (Time-to-Digital Converter) spectrum and ADC versus TDC 2D plots.</li>
+ <li>Fitting of ADC spectrum photon equivalent peaks.</li>
+ <li>ADC spectrum integration: Single or along X or Y directions (for edge scans).</li>
+ <li>Relative Photon Detection Efficiency: Efficiency of sample relative to incidence angle.</li>
+ <li>Breakdown voltage: Determination of silicon detector breakdown voltage through ADC spectrum photon peak separation (gain).</li>
+ <li>Surface scan: Production of a 2D plot by integrating the ADC spectrum in each laser position.</li>
+ </ul>
+ <p>Still to come...</p>
+ <div class="backtop"><a href="#top">Back to top</a></div>
+
+ <h2 id="changelog">8. Change log</h2>
+ <p>4.4.2016 (Current Rev):</p>
+ <ol type="a">
+ <li>Complete restructure of the program, so that it now runs seperately, not through ROOT (libraries are constructed pre-run). Program is now split into multiple tabs for easier use, three of which are Measurement, Analysis and Help.</li>
+ <li>Added support for relative PDE measurements with included sample rotation table.</li>
+ <li>Improvement of analysis part of the program (includes ADC spectrum integration, breakdown voltage characterization, surface scans, relative PDE characterization,...).</li>
+ <li>Added tooltips for different parts of the program for quick reference. Use them by hovering over any text entries, number entries, check boxes or buttons.</li>
+ <li>Connection to temperature data and oscilloscope currently under development.</li>
+ <li>Older version of program moved to <a href="https://f9pc00.ijs.si/svn/f9daq/lab/sipmscan/trunk_v0.9">https://f9pc00.ijs.si/svn/f9daq/lab/sipmscan/trunk_v0.9</a> and will no longer be in development.</li>
+ </ol><br/>
+
+ <p>17.7.2015 (Rev 129):</p>
+ <ol type="a">
+ <li>Fixed a problem with ADC peak fitting (peak fitting returning a segmentation fault).</li>
+ <li>Added support to edit file headers (in case, some were created at an older date and did not include some header information or there was a mistake in writing them).</li>
+ <li>Temperature data can only be retrieved when connected to the IJS network (IP = 178.172.43.xxx) and is disabled otherwise.</li>
+ <li>The relative PDE measurement now takes the incidence angle value directly from input files.</li>
+ <li>Currently, data acquisition only works on 32bit computers.</li>
+ <li>Fixed issue with program not correctly writting multiple channels.</li>
+ </ol><br/>
+
+ <p>5.5.2015 (Rev 128):</p>
+ <ol type="a">
+ <li>Added a header display for opened files in the histogram file selection window. This enables a quicker view of the measurement information.</li>
+ <li>Added an incidence angle input to be able to save sample rotation angle to headers of files.</li>
+ <li>Added support for the fieldpoint temperature sensor (FP RTD 122). Can now plot and export data from the sensor for a specific channel and specific time range. For now, this option only works if the PC you are using this program on is connected to an internet/ethernet connection at IJS.</li>
+ <li>Added a limited relative PDE analysis option. At this time, it takes the selected files and calculates the PDE, relative to the first selected file. The first file should be measured at incidence angle 0, with others having an incidence angle shift of +15 (1st file -> 0, 2nd file -> 15, 3rd file -> 30,...).</li>
+ </ol><br/>
+
+ <p>9.4.2015 (Rev 127):</p>
+ <ol type="a">
+ <li>Added communications panel for connecting to a Tektronix scope.</li>
+ <li>Added limited support for waveform analysis with a Tektronix scope. For now, it only works when linking it to CAMAC acquisition.</li>
+ <li>Added a manual chamber temperature entry field.</li>
+ </ol><br/>
+
+ <p>16.3.2015 (Rev 117):</p>
+ <ol type="a">
+ <li>First version of sipmscan.</li>
+ <li>Added support for CAMAC, bias voltage settings and table position settings.</li>
+ <li>Added support for opening measured histograms.</li>
+ <li>Added support for analysis:</li>
+ <ul>
+ <li>making surface plots</li>
+ <li>fitting the ADC spectrum</li>
+ <li>creating breakdown voltage plots</li>
+ <li>integrating the ADC spectrum with changing X or Y direction (edge scans)</li>
+ </ul>
+ </ol><br/>
+
+ <div class="backtop"><a href="#top">Back to top</a></div>
+
+</div>
+
+</body>
+</html>
Index: sipmscan/trunk/doc/style_sheet.css
===================================================================
--- sipmscan/trunk/doc/style_sheet.css (nonexistent)
+++ sipmscan/trunk/doc/style_sheet.css (revision 146)
@@ -0,0 +1,224 @@
+a:link
+{
+ text-decoration: underline;
+ color: blue;
+ opacity: 1;
+ filter: alpha(opacity=100);
+}
+
+a:visited, a:active
+{
+ text-decoration: none;
+ color: blue;
+ opacity: 1;
+ filter: alpha(opacity=100);
+}
+
+a:hover
+{
+ text-decoration: none;
+ color: blue;
+ opacity: 0.6;
+ filter: alpha(opacity=60);
+}
+
+h1
+{
+ font-size: 21pt;
+}
+
+h2
+{
+ font-size: 18pt;
+}
+
+p span, li span
+{
+ color: red;
+ font-weight: bold;
+}
+
+p tt, li tt, ul tt, ol tt
+{
+ background-color: #FFDDEE;
+}
+
+.midpic
+{
+ display: block;
+ margin: 0 auto;
+}
+
+pre
+{
+ padding-left: 5em;
+}
+
+.codeback
+{
+ background-color: #FFC;
+}
+
+.tabindent
+{
+ padding-left: 2em;
+}
+
+.codename
+{
+ text-align: right;
+ color: #666;
+ font-weight: bold;
+ font-size: 10pt;
+ padding-right: 1em;
+ padding-top: 0.5em;
+}
+
+.backtop
+{
+ text-align: center;
+ color: #666;
+ font-size: 10pt;
+ text-decoration: underline;
+}
+
+.offhome
+{
+ position: fixed;
+ top: 5px;
+ right: 5px;
+ text-align: right;
+ color: #141;
+ font-size: 10pt;
+ padding: 5px;
+ border: 2px solid black;
+ background-color: #EEEEFF;
+}
+
+.offhome a
+{
+ color: #141;
+}
+
+#footer
+{
+ position: fixed;
+ bottom: 0px;
+ width: 100%;
+ color: #444;
+ font-size: 9pt;
+ background-color: #EEEEFF;
+ padding: 5px;
+}
+
+#mod
+{
+/* border: 1px solid red;*/
+ float: left;
+ width: 49%;
+ text-align: left;
+}
+
+#contact
+{
+/* border: 1px solid blue;*/
+ float: left;
+ width: 49%;
+ text-align: right;
+}
+
+#contact a
+{
+ color: #444;
+ cursor: pointer;
+}
+
+#add
+{
+ padding-top: 10pt;
+ padding-bottom: 10pt;
+/* background-color: #EEEEFF;*/
+}
+
+.indexlist
+{
+ font-size: 14pt;
+}
+
+.indexlist li
+{
+ padding-top: 3px;
+ padding-bottom: 3px;
+}
+
+#date
+{
+ margin-bottom: 5px;
+}
+
+#cores span
+{
+ font-weight: bold;
+}
+
+#nodes
+{
+ text-align: center;
+ border: 3px solid black;
+ border-collapse: collapse;
+ margin: 8px 0px;
+ width: 50%;
+ cursor: default;
+}
+
+#nodes td
+{
+ border: 2px solid #555555;
+ padding: 2px 0px;
+}
+
+[tooltip]:before
+{
+ position: absolute;
+ content: attr(tooltip);
+ opacity: 0;
+ background-color: #EEEEFF;
+ border: 2px solid black;
+ font-weight: normal;
+ font-size: 10pt;
+ color: #141;
+ padding: 5px;
+ margin-top: -5px;
+ left: 51%;
+ width: 20%;
+}
+
+[tooltip]:hover:before
+{
+ opacity: 1;
+}
+
+.upnode
+{
+ background-color: #77FF77;
+}
+
+.downnode
+{
+ background-color: #FF7777;
+}
+
+.allocnode
+{
+ background-color: #BBBBBB;
+}
+
+.tableheader
+{
+ background-color: #EEEEFF;
+}
+
+.tableheader th
+{
+ border: 2px solid black;
+}
Index: sipmscan/trunk/include/daq.h
===================================================================
--- sipmscan/trunk/include/daq.h (nonexistent)
+++ sipmscan/trunk/include/daq.h (revision 146)
@@ -0,0 +1,36 @@
+#ifndef _daq_h_
+#define _daq_h_
+
+#define BUFF_L 2048
+
+// Number of channels we are using (used only if we run daqusb.C, not the GUI version)
+//#define NTDC 1 /* TDC */
+//#define NTDCCH 1
+//#define NADC 2 /* ADC */
+//#define NADCCH 1
+
+// Class for measurement process (DAQ for CAMAC)
+class daq
+{
+private:
+// Number of channels we are using
+ int NTDC;
+ int NTDCCH;
+ int NADC;
+ int NADCCH;
+
+ int devDetect; // variable to tell if we detect any devices
+public:
+ unsigned long stackwrite[BUFF_L],stackdata[10000],stackdump[27000];
+ int fStop;
+ int connect();
+ int init(int);
+ int start();
+ int event(unsigned int *, int);
+ int stop();
+ int disconnect();
+ daq();
+ ~daq();
+};
+
+#endif
Index: sipmscan/trunk/include/daqscope.h
===================================================================
--- sipmscan/trunk/include/daqscope.h (nonexistent)
+++ sipmscan/trunk/include/daqscope.h (revision 146)
@@ -0,0 +1,84 @@
+#ifndef _daqscope_h_
+#define _daqscope_h_
+
+#define WAVE_LEN 100000
+
+//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 OSmeasu;
+ int OSmeasuchan;
+ int OSgating;
+ int OSsaving;
+ int OSinf;
+ int nmeaslc;
+ char OSchannels[1024];
+ char IP[1024];
+ char lecroycmd[1024];
+ char lecroycmd2[1024];
+ char lecroywfm[1024];
+ int lecroystate;
+ char pch[1024];
+ char lecroyadd[1024];
+ 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 fPoints;
+ int fStop;
+ int fMode;
+ int clear();
+ int end();
+ int event();
+ int lecroyevent();
+ void measurement(float&);
+ void measulecroy(float&);
+ void measumult();
+ int init();
+ int initlecroy();
+ int connect(char* IPaddr);
+ int disconnect(char* IPaddr);
+ void fileopen(const char*);
+ void fileclose();
+ void countcontrol();
+ void fastacq(int setting); // GKM - gets tek out of fastacq
+ void header();
+ void measuheader();
+ void lecroyheader();
+ void lecroywave();
+ double tekunit(char*);
+ double lcunit(char*);
+ daqscope();
+// daqscope(const char *);
+ ~daqscope();*/
+};
+
+#endif
Index: sipmscan/trunk/include/libxxusb.h
===================================================================
--- sipmscan/trunk/include/libxxusb.h (nonexistent)
+++ sipmscan/trunk/include/libxxusb.h (revision 146)
@@ -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);
+
Index: sipmscan/trunk/include/root_include.h
===================================================================
--- sipmscan/trunk/include/root_include.h (nonexistent)
+++ sipmscan/trunk/include/root_include.h (revision 146)
@@ -0,0 +1,237 @@
+#ifndef _root_include_h_
+#define _root_include_h_
+
+// ROOT base includes
+#ifndef ROOT_TRootBrowser
+#include "TRootBrowser.h"
+#endif
+#ifndef ROOT_IOstream
+#include "Riostream.h"
+#endif
+#ifndef ROOT_TSystem
+#include "TSystem.h"
+#endif
+#ifndef ROOT_TApplication
+#include "TApplication.h"
+#endif
+#ifndef ROOT_TROOT
+#include "TROOT.h"
+#endif
+#ifndef ROOT_TQObject
+#include "TQObject.h"
+#endif
+#ifndef ROOT_RQ_Object
+#include "RQ_OBJECT.h"
+#endif
+#ifndef ROOT_TGClient
+#include "TGClient.h"
+#endif
+#ifndef ROOT_TGResourcePool
+#include "TGResourcePool.h"
+#endif
+#ifndef ROOT_TEnv
+#include "TEnv.h"
+#endif
+#ifndef ROOT_TObjectTable
+#include "TObjectTable.h"
+#endif
+
+// ROOT GUI frame includes
+#ifndef ROOT_TGFrame
+#include "TGFrame.h"
+#endif
+#ifndef ROOT_TGDockableFrame
+#include "TGDockableFrame.h"
+#endif
+#ifndef ROOT_TGMenu
+#include "TGMenu.h"
+#endif
+#ifndef ROOT_TGMdiDecorFrame
+#include "TGMdiDecorFrame.h"
+#endif
+#ifndef ROOT_TGMdiFrame
+#include "TGMdiFrame.h"
+#endif
+#ifndef ROOT_TGMdiMainFrame
+#include "TGMdiMainFrame.h"
+#endif
+#ifndef ROOT_TGMdiMenu
+#include "TGMdiMenu.h"
+#endif
+#ifndef ROOT_TGMdi
+#include "TGMdi.h"
+#endif
+#ifndef ROOT_TG3DLine
+#include "TG3DLine.h"
+#endif
+#ifndef ROOT_TGStatusBar
+#include "TGStatusBar.h"
+#endif
+
+// ROOT GUI builder incudes (not needed)
+#ifndef ROOT_TRootGuiBuilder
+#include "TRootGuiBuilder.h"
+#endif
+#ifndef ROOT_TGuiBldHintsButton
+#include "TGuiBldHintsButton.h"
+#endif
+#ifndef ROOT_TGuiBldHintsEditor
+#include "TGuiBldHintsEditor.h"
+#endif
+#ifndef ROOT_TGuiBldEditor
+#include "TGuiBldEditor.h"
+#endif
+#ifndef ROOT_TGuiBldDragManager
+#include "TGuiBldDragManager.h"
+#endif
+
+// ROOT GUI object includes
+#ifndef ROOT_TGListBox
+#include "TGListBox.h"
+#endif
+#ifndef ROOT_TGNumberEntry
+#include "TGNumberEntry.h"
+#endif
+#ifndef ROOT_TGScrollBar
+#include "TGScrollBar.h"
+#endif
+#ifndef ROOT_TGFileDialog
+#include "TGFileDialog.h"
+#endif
+#ifndef ROOT_TGShutter
+#include "TGShutter.h"
+#endif
+#ifndef ROOT_TGButtonGroup
+#include "TGButtonGroup.h"
+#endif
+#ifndef ROOT_TGCanvas
+#include "TGCanvas.h"
+#endif
+#ifndef ROOT_TGButton
+#include "TGButton.h"
+#endif
+#ifndef ROOT_TGTextEdit
+#include "TGTextEdit.h"
+#endif
+#ifndef ROOT_TGLabel
+#include "TGLabel.h"
+#endif
+#ifndef ROOT_TGView
+#include "TGView.h"
+#endif
+#ifndef ROOT_TGTab
+#include "TGTab.h"
+#endif
+#ifndef ROOT_TGListView
+#include "TGListView.h"
+#endif
+#ifndef ROOT_TGSplitter
+#include "TGSplitter.h"
+#endif
+#ifndef ROOT_TGListTree
+#include "TGListTree.h"
+#endif
+#ifndef ROOT_TGToolTip
+#include "TGToolTip.h"
+#endif
+#ifndef ROOT_TGToolBar
+#include "TGToolBar.h"
+#endif
+#ifndef ROOT_TRootEmbeddedCanvas
+#include "TRootEmbeddedCanvas.h"
+#endif
+#ifndef ROOT_TCanvas
+#include "TCanvas.h"
+#endif
+#ifndef ROOT_TGComboBox
+#include "TGComboBox.h"
+#endif
+#ifndef ROOT_TGProgressBar
+#include "TGProgressBar.h"
+#endif
+#ifndef ROOT_TGTextEntry
+#include "TGTextEntry.h"
+#endif
+#ifndef ROOT_TGMsgBox
+#include "TGMsgBox.h"
+#endif
+#ifndef ROOT_TGSlider
+#include "TGSlider.h"
+#endif
+#ifndef ROOT_TGFSContainer
+#include "TGFSContainer.h"
+#endif
+#ifndef ROOT_TGFSComboBox
+#include "TGFSComboBox.h"
+#endif
+
+// ROOT File browser includes
+#ifndef ROOT_TSystemDir
+#include "TSystemDirectory.h"
+#endif
+#ifndef ROOT_TTree
+#include "TTree.h"
+#endif
+#ifndef ROOT_TFile
+#include "TFile.h"
+#endif
+
+// ROOT plotting includes
+#ifndef ROOT_TPaveStats
+#include "TPaveStats.h"
+#endif
+#ifndef ROOT_TGraph2D
+#include "TGraph2D.h"
+#endif
+#ifndef ROOT_TLatex
+#include "TLatex.h"
+#endif
+#ifndef ROOT_TGraphErrors
+#include "TGraphErrors.h"
+#endif
+#ifndef ROOT_TStyle
+#include "TStyle.h"
+#endif
+#ifndef ROOT_TPaletteAxis
+#include "TPaletteAxis.h"
+#endif
+#ifndef ROOT_TGraph
+#include "TGraph.h"
+#endif
+#ifndef ROOT_TH1F
+#include "TH1F.h"
+#endif
+#ifndef ROOT_TH2F
+#include "TH2F.h"
+#endif
+#ifndef ROOT_TF1
+#include "TF1.h"
+#endif
+#ifndef ROOT_TSpectrum
+#include "TSpectrum.h"
+#endif
+#ifndef ROOT_TVirtualFitter
+#include "TVirtualFitter.h"
+#endif
+#ifndef ROOT_TMath
+#include "TMath.h"
+#endif
+#ifndef ROOT_TRandom
+#include "TRandom.h"
+#endif
+#ifndef ROOT_TLatex
+#include "TLatex.h"
+#endif
+
+// ROOT MYSQL includes
+#ifndef ROOT_TSQLServer
+#include <TSQLServer.h>
+#endif
+#ifndef ROOT_TSQLResult
+#include <TSQLResult.h>
+#endif
+#ifndef ROOT_TSQLRow
+#include <TSQLRow.h>
+#endif
+
+#endif
Index: sipmscan/trunk/include/sipmscan.h
===================================================================
--- sipmscan/trunk/include/sipmscan.h (nonexistent)
+++ sipmscan/trunk/include/sipmscan.h (revision 146)
@@ -0,0 +1,345 @@
+#ifndef __ROOT_APP_H__
+#define __ROOT_APP_H__
+
+//#define winWidth 1240
+//#define winHeight 800
+#define WINDOW_NAME "CAMAC/MPOD/4MM DAQ software"
+#define measwin 3
+#define analysiswin 4
+#define BSIZE 10000
+
+#include "root_include.h"
+#include "substructure.h"
+#include "daq.h"
+#include "daqscope.h"
+#include <iostream>
+#include <fstream>
+#include <cmath>
+#include <time.h>
+
+enum EMenuIds {
+ M_FILE_SET_LAYOUT,
+ M_FILE_SAVE_LAYOUT,
+ M_FILE_SAVE_MSETTINGS,
+ M_FILE_SAVE_ASETTINGS,
+ M_FILE_CHECK_WIDTH,
+ M_FILE_EXIT,
+
+ M_ANALYSIS_HISTTYPE_1DADC,
+ M_ANALYSIS_HISTTYPE_1DTDC,
+ M_ANALYSIS_HISTTYPE_2D,
+ M_ANALYSIS_INTEG,
+ M_ANALYSIS_INTEGX,
+ M_ANALYSIS_INTEGY,
+ M_ANALYSIS_PHOTMU,
+ M_ANALYSIS_BREAKDOWN,
+ M_ANALYSIS_SURFSCAN,
+ M_ANALYSIS_TIMING,
+
+ M_HELP_WEBHELP,
+ M_HELP_ABOUT
+};
+
+// Separate functions -----------------------------------------
+void GetTime(int intime, char *outtime);
+void remove_ext(char *inname, char *outname);
+void remove_from_last(char *inname, char search, char *outname);
+void remove_before_last(char *inname, char search, char *outname);
+void layoutMainWindow(int *w, int *h);
+void SeqNumber(int innum, int maxnum, char *outstr);
+void TimeEstimate(clock_t stopw0, time_t time0, float progress, char *retEstim, int offset);
+void NormateSet(int file, int nrpoint, double *min, double *max, double *setCount, double *setAcc);
+double PointEstimate(int nrp, double *points);
+// Separate functions -----------------------------------------
+
+
+// Window classes ----------------------------------------------------
+//class TGWindow;
+//class TGMainFrame;
+
+// Subwindow layout class
+/*class TGMdiSubwindow
+{
+RQ_OBJECT("TGMdiSubwindow")
+
+protected:
+ TGMdiFrame *fMdiFrame;
+
+public:
+ TGMdiSubwindow(TGMdiMainFrame *main, int w, int h);
+ TGMdiFrame *GetMdiFrame() const { return fMdiFrame; }
+ // layoutchange is 0 when we close a subwindow and 1 when we change the layout (close multiple subwindows)
+ virtual Bool_t CloseWindow(int layoutchange);
+
+ // unique id is set for each subwindow
+ // settingsPane->id = 0
+ int id;
+};*/
+
+// Main window class
+class TGAppMainFrame
+{
+RQ_OBJECT("TGAppMainFrame")
+
+protected:
+ TGMainFrame *fMain;
+// TGMdiMainFrame *fMainFrame;
+// TGMdiMenuBar *fMenuBar;
+ TGMenuBar *fMenuBar;
+ TGLayoutHints *fMenuBarItemLayout;
+ TGPopupMenu *fMenuFile, *fMenuAnalysis, *fMenuHelp, *fMenuHisttype;
+ TGTab *fTab, *analTab;
+ int winWidth;
+ int winHeight;
+// TGMdiSubwindow *settingsPane;
+
+ // Variables for frame layouts and titles
+ TGCompositeFrame *fLayout[2];
+ TGHorizontalFrame *fTitle;
+
+ void InitMenu();
+ void AppLayout();
+ void OpenWindow(int winid);
+ void CloseWindow();
+ Bool_t About();
+
+ int idtotal;
+ bool cleanPlots;
+ int logChange;
+ int selChannel;
+ bool acqStarted;
+ unsigned int gBuf[BSIZE];
+ clock_t clkt0;
+ time_t timet0;
+ bool liveUpdate;
+ int npeaks;
+
+public:
+ TGAppMainFrame(const TGWindow *p, int w, int h);
+ virtual ~TGAppMainFrame();
+
+ void HandleMenu(Int_t id);
+
+ // Splitter to a set number of frames
+ bool TGSplitter(TGWindow *parent, const char *majorSplit, int *vertSplits, int *horSplits, const char *frameTitles[512], TGCompositeFrame **frames, int *frameWidth, int *frameHeight);
+ void TGTitleLabel(TGWindow *parent, TGHorizontalFrame *fTitle, const char *title, Pixel_t foreColor, Pixel_t backColor, const char *font);
+
+ // Layout setup
+ void LayoutRead(int nrframes, int *w, int *h);
+ void LayoutSave();
+ void LayoutSet();
+ void ToolTipSet();
+
+ // Subframes where we display everything
+ TGCompositeFrame *measLayout[measwin];
+ TGCompositeFrame *analysisLayout[analysiswin];
+
+ // Substructures for Settings pane (measurement layout)
+ TSubStructure *scansOn;
+ TSubStructure *vHardlimit;
+ TSubStructure *NCH;
+ TSubStructure *posUnits;
+ TSubStructure *rotUnits;
+ TSubStructure *oscConnect;
+ TSubStructure *laserInfo;
+ TSubStructure *chtemp;
+ TSubStructure *liveDisp;
+
+ // Substructures for Measurement pane (measurement layout)
+ TSubStructure *vOutCh;
+ TSubStructure *vOut;
+ TSubStructure *vOutOpt;
+ TSubStructure *vOutButtons;
+ TSubStructure *vOutStart;
+ TSubStructure *vOutStop;
+ TSubStructure *vOutStep;
+ TSubStructure *xPos;
+ TSubStructure *yPos;
+ TSubStructure *zPos;
+ TSubStructure *zPosMin;
+ TSubStructure *zPosMax;
+ TSubStructure *zPosStep;
+ TSubStructure *posButtons;
+ TSubStructure *xPosMin;
+ TSubStructure *xPosMax;
+ TSubStructure *xPosStep;
+ TSubStructure *yPosMin;
+ TSubStructure *yPosMax;
+ TSubStructure *yPosStep;
+ TSubStructure *rotPos;
+ TSubStructure *rotButtons;
+ TSubStructure *rotPosMin;
+ TSubStructure *rotPosMax;
+ TSubStructure *rotPosStep;
+ TSubStructure *evtNum;
+ TSubStructure *timeStamp;
+ TSubStructure *fileName;
+ TSubStructure *measProgress;
+
+ // Substructures for Display pane (measurement layout)
+ TRootEmbeddedCanvas *measCanvas;
+
+ // Action connections for Settings pane (measurement layout)
+ void EnableScan(int type);
+ void VoltageLimit();
+ void ChangeUnits(int type);
+ void ChangeUnitsRot(int type);
+ void EnableLiveUpdate();
+
+ // Action connections for Measurement pane (measurement layout)
+ int GetChannel();
+ void NegativePolarity();
+ void VoltOut(int opt);
+ void PositionSet(int opt);
+ void RotationSet(int opt);
+ void SaveFile();
+ void StartAcq();
+
+ // Substructures for Histogram selection pane (analysis layout)
+ TSubStructure *selectDir;
+ TGListBox *fileList;
+ TSubStructure *multiSelect;
+ TSubStructure *fileListCtrl;
+ TSubStructure *dispTime;
+ TSubStructure *dispBias;
+ TSubStructure *dispPos;
+ TSubStructure *dispTemp;
+ TSubStructure *dispAngle;
+ TSubStructure *dispLaser;
+
+ // Substructures for Histogram pane (analysis layout)
+ TRootEmbeddedCanvas *analysisCanvas;
+
+ // Substructures for Histogram controls pane (analysis layout)
+ TSubStructure *adcRange;
+ TSubStructure *tdcRange;
+ TSubStructure *yRange;
+ TSubStructure *selectCh;
+ TSubStructure *plotType;
+ TSubStructure *histOpt;
+ TSubStructure *exportHist;
+ TSubStructure *editSelHist;
+
+ // Substructures for analysis pane (analysis layout)
+ TSubStructure *intSpect;
+ TSubStructure *resol2d;
+ TSubStructure *intSpectButtons;
+
+ TSubStructure *relPde;
+ TSubStructure *midPeak;
+ TSubStructure *darkRun;
+ TSubStructure *zeroAngle;
+ TSubStructure *relPdeButtons;
+
+ TSubStructure *minPeak;
+ TSubStructure *peakSepCalc;
+ TSubStructure *brDownButtons;
+
+ TSubStructure *surfScanOpt;
+ TSubStructure *resolSurf;
+ TSubStructure *surfButtons;
+
+ TSubStructure *fitSigma;
+ TSubStructure *fitTresh;
+ TSubStructure *fitInter;
+ TSubStructure *adcOffset;
+ TSubStructure *accError;
+ TSubStructure *pedesLow;
+ TSubStructure *fitChecks;
+ TSubStructure *analysisProgress;
+
+ // Action connections for Histogram file selection pane (analysis layout)
+ void SelectDirectory();
+ void ListMultiSelect(int opt);
+ void FileListNavigation(int opt);
+ void HeaderEdit();
+ void ClearHistogramList();
+
+ // Action connections for Histogram controls pane (analysis layout)
+ void UpdateHistogram(int opt);
+ void HistogramOptions(int opt);
+ void ChangeHisttype(int type);
+
+ // Action connections for analysis pane (analysis layout)
+ void SelectDarkHist();
+ void AnalysisDefaults();
+ void AnalysisHandle(int type);
+ void IntegSpectrum(TList *files, int direction, int edit);
+ void PhotonMu(TList *files, int edit);
+ void PlotEdgeDistribution(TList *files, int filenr, int points, double *min, double *max, double *xy, double *integAcc, int axis, bool edge2d, int edit);
+ void BreakdownVolt(TList *files, int edit);
+ void SurfaceScan(TList *files, int edit);
+
+ // Substructures for Edit file header window (new tab)
+ TGListBox *editList;
+ TSubStructure *timeEditDisplay;
+ TSubStructure *biasEdit;
+ TSubStructure *xPosEdit;
+ TSubStructure *yPosEdit;
+ TSubStructure *zPosEdit;
+ TSubStructure *tempEdit;
+ TSubStructure *angleEdit;
+ TSubStructure *laserEdit;
+ TSubStructure *editHead;
+ TSubStructure *editMulti;
+ TGLabel *selectWarn;
+
+ // Action connections for Edit file header window (new tab)
+ void SetWarnings();
+ void EditTickToggle(int type);
+ void StartHeaderEdit();
+ void ShowHeaderEdit(int id);
+ void HeaderChange(char *histfile, bool *changetype);
+ void CloseEditTab(int tabval);
+
+ // Substructures for temporary analysis edit window (new tab)
+ TRootEmbeddedCanvas *tempAnalysisCanvas;
+ TSubStructure *runningAver;
+ TSubStructure *runningOff;
+ TSubStructure *secondAxis;
+ TSubStructure *exportExitAnalysis;
+
+ // Action connections for temporary analysis edit window (new tab)
+ void ApplyRunningAver();
+ void CloseTempAnalysisTab(int tabval);
+
+ // Additional functions
+ void DisplayHistogram(char *histfile, int histtype, int opt);
+ void HeaderEditTab(TGTab *mainTab, bool create, int *tabid);
+ void TempAnalysisTab(TGTab *mainTab, bool create, int *tabid, int analtype);
+ void RunMeas(void *ptr, int runCase, int &scanon);
+ int MyTimer();
+
+// ROOT file variable structure -------------------------------
+ struct EventHeader {
+ int nrch;
+ int timestamp;
+ double biasvolt;
+ int xpos;
+ int ypos;
+ int zpos;
+ double temperature;
+ double angle;
+ char laserinfo[256];
+ } evtheader;
+
+ struct EventData {
+ int adcdata[8];
+ int tdcdata[8];
+ } evtdata;
+
+ struct EventMeas {
+ double measdata;
+ } evtmeas;
+
+ TFile *inroot;
+ TFile *outroot;
+// ROOT file variable structure -------------------------------
+
+ daq *gDaq;
+ daqscope *gScopeDaq;
+};
+
+// -------------------------------------------------------------------
+
+#endif
Index: sipmscan/trunk/include/substructure.h
===================================================================
--- sipmscan/trunk/include/substructure.h (nonexistent)
+++ sipmscan/trunk/include/substructure.h (revision 146)
@@ -0,0 +1,67 @@
+#ifndef __TEST_H__
+#define __TEST_H__
+
+#include "root_include.h"
+#include <string.h>
+
+// Format for Number Entry fields:
+// [digit space] [num type] [neg-pos] [limit] [min limit], [max limit]
+//
+// [digit space]: Number of spaces for the entered digits (width)
+// [num type]: 0 = Integer, 1 = Real one digit, 2 = Real two digits, 3 = Real three digits, 4 = Real four digits, -1 = Arbitrary real
+// [neg-pos]: 0 = Any number, 1 = Positive numbers, 2 = Nonnegative numbers
+// [limit]: 0 = No limits, 1 = Maximum limit, 2 = Min and Max limits, -1 = Minimum limit
+// [min limit], [max limit]: Min and Max limits, if applicable
+
+class TSubStructure
+{
+RQ_OBJECT("TSubStructure")
+
+protected:
+ TGLabel *lab;
+ TGHorizontalFrame *fH1;
+ TGLayoutHints *f0, *f0expandX, *f1, *f2, *f3;
+public:
+ TSubStructure();
+ virtual ~TSubStructure();
+
+ // Label + Text Entry -> layout can be "oneline", "twoline"
+ bool TGLabelTEntry(TGWindow *parent, int w, int h, const char *label, const char *deftext, const char *layout);
+ // Label + Text Entry + Button -> layout can be "oneline", "twoline"
+ bool TGLabelTEntryButton(TGWindow *parent, int w, int h, const char *label, const char *deftext, const char *buttext, const char *layout);
+ // Label + Button
+ bool TGLabelButton(TGWindow *parent, int w, int h, const char *label, const char *buttext, const char *pos);
+ // Label + Number Entry
+ bool TGLabelNEntry(TGWindow *parent, int w, int h, const char *label, double defval, double *format, const char *pos);
+ // Text Entry + Button
+ bool TGTEntryButton(TGWindow *parent, int w, int h, const char *deftext, const char *buttext);
+ // Label + Dropdown menu
+ bool TGLabelDrop(TGWindow *parent, int w, int h, const char *label, int nrentries, const char *entrytext[512], const char *selecttext);
+ // 2 or more buttons
+ bool TGMultiButton(TGWindow *parent, int w, int h, int nrbuttons, const char *buttext[512], const char *pos);
+ // Label + 2 Number Entries
+ bool TGLabelDoubleNEntry(TGWindow *parent, int w, int h, const char *label, double defval1, double *format1, double defval2, double *format2, const char *pos);
+ // Checkbutton list (1 - 9) -> layout can be "horizontal", "vertical", "twoline", "threeline"
+ bool TGCheckList(TGWindow *parent, int w, int h, int nrchecks, const char *labels[512], int *onoff, const char *layout, const char *pos);
+ // Button + Horizontal progress bar
+ bool TGButtonProgress(TGWindow *parent, int w, int h, const char *buttext);
+ // Label + Horizontal progress bar
+ bool TGLabelProgress(TGWindow *parent, int w, int h, const char *label);
+ // Button + Horizontal progress bar + Text Entry
+ bool TGButtonProgressTEntry(TGWindow *parent, int w, int h, const char *buttext, const char *deftext);
+ // Checkbutton + Number entry
+ bool TGCheckNEntry(TGWindow *parent, int w, int h, const char *label, int onoff, double defval, double *format, const char *pos);
+ // Checkbutton + Text entry
+ bool TGCheckTEntry(TGWindow *parent, int w, int h, const char *label, int onoff, const char *deftext, const char *layout);
+
+ TGTextEntry *widgetTE;
+ TGTextButton *widgetTB[6];
+ TGNumberEntry *widgetNE[2];
+ TGComboBox *widgetCB;
+ TGCompositeFrame *outsidebox;
+ TGCheckButton *widgetChBox[9];
+ TGHProgressBar *widgetPB;
+ int id;
+};
+
+#endif
Index: sipmscan/trunk/include/usb.h
===================================================================
--- sipmscan/trunk/include/usb.h (nonexistent)
+++ sipmscan/trunk/include/usb.h (revision 146)
@@ -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__ */
+
Index: sipmscan/trunk/include/vxi11_i686/CHANGELOG.txt
===================================================================
--- sipmscan/trunk/include/vxi11_i686/CHANGELOG.txt (nonexistent)
+++ sipmscan/trunk/include/vxi11_i686/CHANGELOG.txt (revision 146)
@@ -0,0 +1,199 @@
+------------------------------------------------------------------------------
+vxi11_1.08 - 3/09/2009
+
+Added a sanity check for link->maxRecvSize to make sure it's >0. This gets
+around a bug in some versions of the Agilent Infiniium scope software.
+
+Changed the erroneous strncpy() to memcpy() in vxi11_send, as we could be
+sending binary data (not just strings).
+
+Changed a lot of char *'s to const char *'s in an attempt to get rid of
+pedantic gcc compiler warnings.
+
+------------------------------------------------------------------------------
+vxi11_1.07 - 9/10/2007
+
+Minor change to vxi11_receive_data_block(), this fn now copes with instruments
+that return just "#0" (for whatever reason). Suggestion by Jarek Sadowski,
+gratefully received.
+
+------------------------------------------------------------------------------
+vxi11_1.06 - 31/08/2007
+
+Bug fix in vxi11_receive(), to ensure that no more than "len" bytes are ever
+received (and so avoiding a segmentation fault). This was a bug introduced in
+release 1.04 whilst making some other changes to the vxi11_receive() fn.
+
+Many thanks to Rob Penny for spotting the bug and providing a patch.
+
+------------------------------------------------------------------------------
+vxi11_1.05 - 11/07/2007
+
+Added the ability to specify a "device name" when calling vxi11_open_device().
+For regular VXI11-based instruments, such as scopes and AFGs, the device name
+is usually "hard wired" to be "inst0", and up to now this has been hard wired
+into the vxi11_user code. However, devices such as LAN to GPIB gateways need
+some way of distinguishing between different devices... they are a single
+client (one IP address), with multiple devices.
+
+The vxi11_user fn, vxi11_open_device(), now takes a third argument
+(char *device).
+This gets passed to the core vxi11_open_device() fn (the one that deals with
+separate clients and links), and the core vxi11_open_link() fn; these two
+core functions have also had an extra parameter added accordingly. In order
+to not break the API, a wrapper function is provided in the form of the
+original vxi11_open_device() fn, that just takes 2 arguments
+(char *ip, CLINK *clink), this then passes "inst0" as the device argument.
+Backwards-compatible wrappers for the core functions have NOT been provided.
+These are generally not used from userland anyway. Hopefully this won't
+upset anyone!
+
+vxi11_cmd, the simple test utility, has also been updated. You can now,
+optionally, pass the device_name as a second argument (after the ip
+address). The source has been renamed to vxi11_cmd.cc (from vxi11_cmd.c), as
+it is C++ code not C.
+
+Some minor tidying up in vxi11_user.h
+
+With thanks to Oliver Schulz for bringing LAN to GPIB gateways to my
+attention, for suggesting changes to the vxi11_user library to allow them to
+be accommodated, and for tidying some things up.
+
+------------------------------------------------------------------------------
+vxi11_1.04 - 10/07/2007
+
+Patch applied, which was kindly provided by Robert Larice. This sorts out
+the confusion (on my part) about the structures returned by the rpcgen
+generated *_1() functions... these are statically allocated temporary structs,
+apparently. In the words of Robert Larice:
+
+******
+Hello Dr. Sharples,
+
+ I'm sending some patches for your nice gem "vxi11_1.03"
+
+ In the source code there were some strange comments, concerning
+ a commented free() around ... Manfred S. ...
+ and some notes, suggesting you had trouble to get more than one link
+ working.
+
+ I think thats caused by some misuse of the rpcgen generated subroutines.
+ 1) those rpcgen generated *_1 functions returned pointers to
+ statically allocated temporary structs.
+ those where meant to be instantly copied to the user's space,
+ which wasn't done
+ thus instead of
+ Device_ReadResp *read_resp;
+ read_resp = device_read_1(...)
+ one should have written someting like:
+ Device_ReadResp *read_resp;
+ read_resp = malloc(...)
+ memcpy(read_resp, device_read_1(...), ...)
+ 2) but a better fix is to use the rpcgen -M Flag
+ which allows to pass the memory space as a third argument
+ so one can write
+ Device_ReadResp *read_resp;
+ read_resp = malloc(...)
+ device_read_1(..., read_resp, ...)
+ furthermore this is now automatically thread save
+ 3) the rpcgen function device_read_1
+ expects a target buffer to be passed via read_resp
+ which was not done.
+ 4) the return value of vxi11_receive() was computed incorrectly
+ 5) minor, Makefile typo's
+ CFLAGS versus
+ CLFAGS
+
+******
+
+Robert didn't have more than one device to try the patch with, but I've just
+tried it and everything seems fine. So I've removed all references to the
+VXI11_ENABLE_MULTIPLE_CLIENTS global variable, and removed the call to
+vxi11_open_link() from the vxi11_send() fn. There has been an associated
+tidying of functions, and removal of some comments.
+
+Thanks once again to Robert Larice for the patch and the explanation!
+
+------------------------------------------------------------------------------
+vxi11_1.03 - 29/01/2007
+
+Some bug-fixes (thanks to Manfred S.), and extra awareness of the
+possibility that instruments could time out after receiving a query WITHOUT
+causing an error condition. In some cases (prior to these changes) this
+could have resulted in a segmentation fault.
+
+Specifically:
+
+(1) removed call to ANSI free() fn in vxi11_receive, which according to
+ Manfred S. "is not necessary and wrong (crashes)".
+
+(2) added extra check in vxi11_receive() to see if read_resp==NULL.
+ read_resp can apparently be NULL if (eg) you send an instrument a
+ query, but the instrument is so busy with something else for so long
+ that it forgets the original query. So this extra check is for that
+ situation, and vxi11_receive returns -VXI11_NULL_READ_RESP to the
+ calling function.
+
+(3) vxi11_send_and_receive() is now aware of the possibility of being
+ returned -VXI11_NULL_READ_RESP. If so, it re-sends the query, until
+ either getting a "regular" read error (read_resp->error!=0) or a
+ successful read.
+
+(4) Similar to (2)... added extra check in vxi11_send() to see if
+ write_resp==NULL. If so, return -VXI11_NULL_WRITE_RESP. As with (3),
+ send_and_receive() is now aware of this possibility.
+
+------------------------------------------------------------------------------
+vxi11_1.02 - 25/08/2006
+
+Important changes to the core vxi11_send() function, which should be
+invisible to the user.
+
+For those interested, the function now takes note of the value of
+link->maxRecvSize, which is the maximum number of bytes that the vxi11
+intrument you're talking to can receive in one go. For many instruments
+this may be a few kB, which isn't a problem for sending short commands;
+however, sending large chunks of data (for example sending waveforms
+to instruments) may exceed this maxRecvSize. The core vxi11_send() function
+has been re-written to ensure that only a maximum of [maxRecvSize] bytes are
+written in one go... the function sits in a loop until all the message/
+data is written.
+
+Also tidied up some of the return values (specifically with regard to
+vxi11_send() and vxi11_send_data_block() ).
+
+------------------------------------------------------------------------------
+vxi11_1.01 - 06/07/2006
+
+Fair few changes since v1.00, all in vxi11_user.c and vxi11_user.h
+
+Found I was having problems talking to multiple links on the same
+client, if I created a different client for each one. So introduced
+a few global variables to keep track of all the ip addresses of
+clients that the library is asked to create, and only creating new
+clients if the ip address is different. This puts a limit of how
+many unique ip addresses (clients) a single process can connect to.
+Set this value at 256 (should hopefully be enough!).
+
+Next I found that talking to different clients on different ip
+addresses didn't work. It turns out that create_link_1() creates
+a static structure. This this link is associated with a given
+client (and hence a given IP address), then the only way I could
+think of making things work was to add a call to an
+vxi11_open_link() function before each send command (no idea what
+this adds to overheads and it's very messy!) - at least I was
+able to get this to only happen when we are using more than one
+client/ip address.
+
+Also, while I was at it, I re-ordered the functions a little -
+starts with core user functions, extra user functions, then core
+library functions at the end. Added a few more comments. Tidied
+up. Left some debugging info in, but commented out.
+
+------------------------------------------------------------------------------
+vxi11_1.00 - 23/06/2006
+
+Initial release.
+
+------------------------------------------------------------------------------
+
Index: sipmscan/trunk/include/vxi11_i686/GNU_General_Public_License.txt
===================================================================
--- sipmscan/trunk/include/vxi11_i686/GNU_General_Public_License.txt (nonexistent)
+++ sipmscan/trunk/include/vxi11_i686/GNU_General_Public_License.txt (revision 146)
@@ -0,0 +1,340 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
Index: sipmscan/trunk/include/vxi11_i686/Makefile
===================================================================
--- sipmscan/trunk/include/vxi11_i686/Makefile (nonexistent)
+++ sipmscan/trunk/include/vxi11_i686/Makefile (revision 146)
@@ -0,0 +1,18 @@
+VERSION=1.08
+
+#CFLAGS = -Wall -g
+CFLAGS = -g
+CXX = g++
+
+.PHONY: clean objs
+
+objs: vxi11.h
+ $(CXX) -c -fPIC $(CFLAGS) vxi11_user.cc
+ $(CXX) -c -fPIC $(CFLAGS) vxi11_clnt.c
+ $(CXX) -c -fPIC $(CFLAGS) vxi11_xdr.c
+
+vxi11.h: vxi11.x
+ rpcgen -M vxi11.x
+
+clean:
+ rm -f *.o vxi11_cmd vxi11.h vxi11_svc.c vxi11_xdr.c vxi11_clnt.c #TAGS
Index: sipmscan/trunk/include/vxi11_i686/vxi11.x
===================================================================
--- sipmscan/trunk/include/vxi11_i686/vxi11.x (nonexistent)
+++ sipmscan/trunk/include/vxi11_i686/vxi11.x (revision 146)
@@ -0,0 +1,317 @@
+/* This file, vxi11.x, is the amalgamation of vxi11core.rpcl and vxi11intr.rpcl
+ * which are part of the asynDriver (R4-5) EPICS module, which, at time of
+ * writing, is available from:
+ * http://www.aps.anl.gov/epics/modules/soft/asyn/index.html
+ * More general information about EPICS is available from:
+ * http://www.aps.anl.gov/epics/
+ * This code is open source, and is covered under the copyright notice and
+ * software license agreement shown below, and also at:
+ * http://www.aps.anl.gov/epics/license/open.php
+ *
+ * In order to comply with section 4.3 of the software license agreement, here
+ * is a PROMINENT NOTICE OF CHNAGES TO THE SOFTWARE
+ * ===========================================
+ * (1) This file, vxi11.x, is the concatenation of the files vxi11core.rpcl and
+ * vxi11intr.rpcl
+ * (2) Tab spacing has been tidied up
+ *
+ * It is intended as a lightweight base for the vxi11 rpc protocol. If you
+ * run rpcgen on this file, it will generate C files and headers, from which
+ * it is relatively simple to write C programs to communicate with a range
+ * of ethernet-enabled instruments, such as oscilloscopes and function
+ * generated by manufacturers such as Agilent and Tektronix (amongst many
+ * others).
+ *
+ * For what it's worth, this concatenation was done by Steve Sharples at
+ * the University of Nottingham, UK, on 1 June 2006.
+ *
+ * Copyright notice and software license agreement follow, then the
+ * original comments from vxi11core.rpcl etc.
+ *
+ ******************************************************************************
+ * Copyright © 2006 <University of Chicago and other copyright holders>. All
+ * rights reserved.
+ ******************************************************************************
+ *
+ ******************************************************************************
+ * vxi11.x is distributed subject to the following license conditions:
+ * SOFTWARE LICENSE AGREEMENT
+ * Software: vxi11.x
+ *
+ * 1. The "Software", below, refers to vxi11.x (in either source code, or
+ * binary form and accompanying documentation). Each licensee is addressed
+ * as "you" or "Licensee."
+ *
+ * 2. The copyright holders shown above and their third-party licensors hereby
+ * grant Licensee a royalty-free nonexclusive license, subject to the
+ * limitations stated herein and U.S. Government license rights.
+ *
+ * 3. You may modify and make a copy or copies of the Software for use within
+ * your organization, if you meet the following conditions:
+ * 1. Copies in source code must include the copyright notice and this
+ * Software License Agreement.
+ * 2. Copies in binary form must include the copyright notice and this
+ * Software License Agreement in the documentation and/or other
+ * materials provided with the copy.
+ *
+ * 4. You may modify a copy or copies of the Software or any portion of it,
+ * thus forming a work based on the Software, and distribute copies of such
+ * work outside your organization, if you meet all of the following
+ * conditions:
+ * 1. Copies in source code must include the copyright notice and this
+ * Software License Agreement;
+ * 2. Copies in binary form must include the copyright notice and this
+ * Software License Agreement in the documentation and/or other
+ * materials provided with the copy;
+ * 3. Modified copies and works based on the Software must carry
+ * prominent notices stating that you changed specified portions of
+ * the Software.
+ *
+ * 5. Portions of the Software resulted from work developed under a U.S.
+ * Government contract and are subject to the following license: the
+ * Government is granted for itself and others acting on its behalf a
+ * paid-up, nonexclusive, irrevocable worldwide license in this computer
+ * software to reproduce, prepare derivative works, and perform publicly
+ * and display publicly.
+ *
+ * 6. WARRANTY DISCLAIMER. THE SOFTWARE IS SUPPLIED "AS IS" WITHOUT WARRANTY OF
+ * ANY KIND. THE COPYRIGHT HOLDERS, THEIR THIRD PARTY LICENSORS, THE UNITED
+ * STATES, THE UNITED STATES DEPARTMENT OF ENERGY, AND THEIR EMPLOYEES: (1)
+ * DISCLAIM ANY WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
+ * ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ * PURPOSE, TITLE OR NON-INFRINGEMENT, (2) DO NOT ASSUME ANY LEGAL LIABILITY
+ * OR RESPONSIBILITY FOR THE ACCURACY, COMPLETENESS, OR USEFULNESS OF THE
+ * SOFTWARE, (3) DO NOT REPRESENT THAT USE OF THE SOFTWARE WOULD NOT INFRINGE
+ * PRIVATELY OWNED RIGHTS, (4) DO NOT WARRANT THAT THE SOFTWARE WILL FUNCTION
+ * UNINTERRUPTED, THAT IT IS ERROR-FREE OR THAT ANY ERRORS WILL BE CORRECTED.
+ *
+ * 7. LIMITATION OF LIABILITY. IN NO EVENT WILL THE COPYRIGHT HOLDERS, THEIR
+ * THIRD PARTY LICENSORS, THE UNITED STATES, THE UNITED STATES DEPARTMENT OF
+ * ENERGY, OR THEIR EMPLOYEES: BE LIABLE FOR ANY INDIRECT, INCIDENTAL,
+ * CONSEQUENTIAL, SPECIAL OR PUNITIVE DAMAGES OF ANY KIND OR NATURE,
+ * INCLUDING BUT NOT LIMITED TO LOSS OF PROFITS OR LOSS OF DATA, FOR ANY
+ * REASON WHATSOEVER, WHETHER SUCH LIABILITY IS ASSERTED ON THE BASIS OF
+ * CONTRACT, TORT (INCLUDING NEGLIGENCE OR STRICT LIABILITY), OR OTHERWISE,
+ * EVEN IF ANY OF SAID PARTIES HAS BEEN WARNED OF THE POSSIBILITY OF SUCH
+ * LOSS OR DAMAGES.
+ ******************************************************************************
+ */
+
+/******************************************************************************
+ *
+ * vxi11core.rpcl
+ *
+ * This file is best viewed with a tabwidth of 4
+ *
+ ******************************************************************************
+ *
+ * TODO:
+ *
+ ******************************************************************************
+ *
+ * Original Author: someone from VXIbus Consortium
+ * Current Author: Benjamin Franksen
+ * Date: 03-06-97
+ *
+ * RPCL description of the core- and abort-channel of the TCP/IP Instrument
+ * Protocol Specification.
+ *
+ *
+ * Modification Log:
+ * -----------------
+ * .00 03-06-97 bfr created this file
+ *
+ ******************************************************************************
+ *
+ * Notes:
+ *
+ * This stuff is literally from
+ *
+ * VXI-11, Ref 1.0 : TCP/IP Instrument Protocol Specification
+ *
+ */
+
+typedef long Device_Link;
+
+enum Device_AddrFamily
+{
+ DEVICE_TCP,
+ DEVICE_UDP
+};
+
+typedef long Device_Flags;
+
+typedef long Device_ErrorCode;
+
+struct Device_Error
+{
+ Device_ErrorCode error;
+};
+
+struct Create_LinkParms
+{
+ long clientId; /* implementation specific value */
+ bool lockDevice; /* attempt to lock the device */
+ unsigned long lock_timeout; /* time to wait for lock */
+ string device<>; /* name of device */
+};
+struct Create_LinkResp
+{
+ Device_ErrorCode error;
+ Device_Link lid;
+ unsigned short abortPort; /* for the abort RPC */
+ unsigned long maxRecvSize; /* max # of bytes accepted on write */
+};
+struct Device_WriteParms
+{
+ Device_Link lid; /* link id from create_link */
+ unsigned long io_timeout; /* time to wait for I/O */
+ unsigned long lock_timeout; /* time to wait for lock */
+ Device_Flags flags; /* flags with options */
+ opaque data<>; /* the data length and the data itself */
+};
+struct Device_WriteResp
+{
+ Device_ErrorCode error;
+ unsigned long size; /* # of bytes written */
+};
+struct Device_ReadParms
+{
+ Device_Link lid; /* link id from create_link */
+ unsigned long requestSize; /* # of bytes requested */
+ unsigned long io_timeout; /* time to wait for I/O */
+ unsigned long lock_timeout; /* time to wait for lock */
+ Device_Flags flags; /* flags with options */
+ char termChar; /* valid if flags & termchrset */
+};
+struct Device_ReadResp
+{
+ Device_ErrorCode error;
+ long reason; /* why read completed */
+ opaque data<>; /* the data length and the data itself */
+};
+struct Device_ReadStbResp
+{
+ Device_ErrorCode error;
+ unsigned char stb; /* the returned status byte */
+};
+struct Device_GenericParms
+{
+ Device_Link lid; /* link id from create_link */
+ Device_Flags flags; /* flags with options */
+ unsigned long lock_timeout; /* time to wait for lock */
+ unsigned long io_timeout; /* time to wait for I/O */
+};
+struct Device_RemoteFunc
+{
+ unsigned long hostAddr; /* host servicing interrupt */
+ unsigned long hostPort; /* valid port # on client */
+ unsigned long progNum; /* DEVICE_INTR */
+ unsigned long progVers; /* DEVICE_INTR_VERSION */
+ Device_AddrFamily progFamily; /* DEVICE_UDP | DEVICE_TCP */
+};
+struct Device_EnableSrqParms
+{
+ Device_Link lid; /* link id from create_link */
+ bool enable; /* enable or disable intr's */
+ opaque handle<40>; /* host specific data */
+};
+struct Device_LockParms
+{
+ Device_Link lid; /* link id from create_link */
+ Device_Flags flags; /* contains the waitlock flag */
+ unsigned long lock_timeout; /* time to wait for lock */
+};
+struct Device_DocmdParms
+{
+ Device_Link lid; /* link id from create_link */
+ Device_Flags flags; /* flags with options */
+ unsigned long io_timeout; /* time to wait for I/O */
+ unsigned long lock_timeout; /* time to wait for lock */
+ long cmd; /* which command to execute */
+ bool network_order; /* client's byte order */
+ long datasize; /* size of individual data elements */
+ opaque data_in<>; /* docmd data parameters */
+};
+struct Device_DocmdResp
+{
+ Device_ErrorCode error;
+ opaque data_out<>; /* returned data parameters */
+};
+
+program DEVICE_ASYNC
+{
+ version DEVICE_ASYNC_VERSION
+ {
+ Device_Error device_abort (Device_Link) = 1;
+ } = 1;
+} = 0x0607B0;
+
+program DEVICE_CORE
+{
+ version DEVICE_CORE_VERSION
+ {
+ Create_LinkResp create_link (Create_LinkParms) = 10;
+ Device_WriteResp device_write (Device_WriteParms) = 11;
+ Device_ReadResp device_read (Device_ReadParms) = 12;
+ Device_ReadStbResp device_readstb (Device_GenericParms) = 13;
+ Device_Error device_trigger (Device_GenericParms) = 14;
+ Device_Error device_clear (Device_GenericParms) = 15;
+ Device_Error device_remote (Device_GenericParms) = 16;
+ Device_Error device_local (Device_GenericParms) = 17;
+ Device_Error device_lock (Device_LockParms) = 18;
+ Device_Error device_unlock (Device_Link) = 19;
+ Device_Error device_enable_srq (Device_EnableSrqParms) = 20;
+ Device_DocmdResp device_docmd (Device_DocmdParms) = 22;
+ Device_Error destroy_link (Device_Link) = 23;
+ Device_Error create_intr_chan (Device_RemoteFunc) = 25;
+ Device_Error destroy_intr_chan (void) = 26;
+ } = 1;
+} = 0x0607AF;
+
+/******************************************************************************
+ *
+ * vxi11intr.rpcl
+ *
+ * This file is best viewed with a tabwidth of 4
+ *
+ ******************************************************************************
+ *
+ * TODO:
+ *
+ ******************************************************************************
+ *
+ * Original Author: someone from VXIbus Consortium
+ * Current Author: Benjamin Franksen
+ * Date: 03-06-97
+ *
+ * RPCL description of the intr-channel of the TCP/IP Instrument Protocol
+ * Specification.
+ *
+ *
+ * Modification Log:
+ * -----------------
+ * .00 03-06-97 bfr created this file
+ *
+ ******************************************************************************
+ *
+ * Notes:
+ *
+ * This stuff is literally from
+ *
+ * "VXI-11, Ref 1.0 : TCP/IP Instrument Protocol Specification"
+ *
+ */
+
+struct Device_SrqParms
+{
+ opaque handle<>;
+};
+
+program DEVICE_INTR
+{
+ version DEVICE_INTR_VERSION
+ {
+ void device_intr_srq (Device_SrqParms) = 30;
+ } = 1;
+} = 0x0607B1;
Index: sipmscan/trunk/include/vxi11_i686/vxi11_cmd.cc
===================================================================
--- sipmscan/trunk/include/vxi11_i686/vxi11_cmd.cc (nonexistent)
+++ sipmscan/trunk/include/vxi11_i686/vxi11_cmd.cc (revision 146)
@@ -0,0 +1,237 @@
+/*Predelava vmesnika vxi11 za lastne potrebe IJS F9*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include "vxi11_user.h"
+#define BUF_LEN 100000
+
+CLINK *clink;
+FILE *test,*test1;
+
+int query(char *mycmd){
+char buf[BUF_LEN];
+
+memset(buf, 0, BUF_LEN);
+vxi11_send(clink, mycmd);
+int bytes_returned = vxi11_receive(clink, buf, BUF_LEN);
+if (bytes_returned > 0) {
+ printf("%s\n",buf);
+} else if (bytes_returned == -15) printf("*** [ NOTHING RECEIVED ] ***\n");
+
+return 0;
+}
+
+int command(char *mycmd){
+char buf[BUF_LEN];
+
+memset(buf, 0, BUF_LEN);
+vxi11_send(clink, mycmd);
+
+return 0;
+}
+
+int queryrep(char *mycmd,char *mycmp,int i){
+char buf[BUF_LEN];
+
+memset(buf, 0, BUF_LEN);
+vxi11_send(clink, mycmd);
+int bytes_returned = vxi11_receive(clink, buf, BUF_LEN);
+
+if(strcmp(buf,mycmp)!=0){
+ if (bytes_returned > 0) fprintf(test1,"%d %s",i,buf);
+ else if (bytes_returned == -15) printf("*** [ NOTHING RECEIVED ] ***\n");
+
+ }
+ strcpy(mycmp,buf);
+
+return 0;
+}
+
+/*float *fbuf;
+fbuf= (float *) buf;
+if (bytes_returned > 0){
+ for (int j=1;j<3;j++) printf("%f\n",fbuf[j]);
+ }
+*/
+
+int main(void) {
+
+static char *device_ip;
+static char *device_name;
+char cmd[256],ukaz[256],end[256];
+char buf[BUF_LEN],pr1[BUF_LEN],pr2[BUF_LEN];
+int ret;
+long bytes_returned;
+
+int i,m,vnos;
+
+clink = new CLINK;
+time_t t1,t2;
+
+/*
+ fread(buf,1,size,fp);
+ float *fbuf=(float *) buf;
+ fbuf[0]
+
+*/
+ memset(ukaz, 0, 256);
+ printf("\nIJS F9 - September 2010 - Pripravil: Jaka Mur - Beta verzija\n\nProgram za povezavo in nadzor Tektronix ali LeCroy osciloskopa.\nAvtomatsko se program poveze z IP naslovom 194.249.156.91.\nVnesi 'a' za nadaljevanje, 'q' za izhod ali IP za drugo napravo: ");
+
+ while(1){
+ scanf("%s",&ukaz);
+
+ if (strncasecmp(ukaz, "q",1) == 0) return 0;
+
+ else if (strncasecmp(ukaz, "a",1) != 0) ret=vxi11_open_device(ukaz,clink);
+ else ret=vxi11_open_device("194.249.156.91",clink); //privzeti IP naprave
+
+ printf("\nPovezan z ");
+
+ memset(buf, 0, BUF_LEN);
+ vxi11_send(clink, "*IDN?");
+ bytes_returned = vxi11_receive(clink, buf, BUF_LEN);
+ if (bytes_returned > 0) {
+ printf("%s",buf);
+ break;}
+ else if (bytes_returned == -15) {
+ printf("Error.");
+ if (strncasecmp(ukaz, "a",1) == 0) ret=vxi11_close_device("194.249.156.91",clink);
+ else ret=vxi11_close_device(ukaz,clink);
+ return 0;
+ }
+
+ }
+
+ printf("\nNekatere pomembnejse nastavitve:\n");
+ command("HEADER ON");
+ command("DATA:SOURCE CH1");
+ query("DAT?");
+
+ char odg[256];
+ printf("Zelite spreminjati nastavitve? y/n/q: ");
+ scanf("%s",&odg);
+ fgets(cmd,256,stdin);
+
+ if (strncasecmp(odg, "q",1) == 0) {
+ if (strncasecmp(ukaz, "a",1) == 0) ret=vxi11_close_device("194.249.156.91",clink);
+ else ret=vxi11_close_device(ukaz,clink);
+ return 0;
+ }
+ else if (strncasecmp(odg, "y",1) == 0){
+ printf("\nSpisek komand je v Programmer Manualu!\n");
+ while(1){
+ memset(cmd, 0, 256);
+ memset(buf, 0, BUF_LEN);
+
+ printf("Vnesi ukaz, vprasanje, 'q' za izhod ali 'x' za nadaljevanje: ");
+ fgets(cmd,256,stdin);
+ cmd[strlen(cmd)-1] = 0;
+ if (strncasecmp(cmd, "q",1) == 0) {
+ if (strncasecmp(ukaz, "a",1) == 0) ret=vxi11_close_device("194.249.156.91",clink);
+ else ret=vxi11_close_device(ukaz,clink);
+ return 0;
+ }
+ if (strncasecmp(cmd, "x",1) == 0) break;
+
+ if (vxi11_send(clink, cmd) < 0) break;
+ if (strstr(cmd, "?") != 0) {
+ bytes_returned = vxi11_receive(clink, buf, BUF_LEN);
+ if (bytes_returned > 0) {
+ printf("%s\n",buf);
+ }
+ else if (bytes_returned == -15) {
+ printf("*** [ NOTHING RECEIVED ] ***\n");
+ }
+ else break;
+ }
+ }
+ }
+
+ command("HEADER OFF");
+
+ printf("\nIzbor serije meritev\n1 = za zapis waveformov v binarnem formatu\n2 = MEASU:IMM test\n3 = Shenanigans\nVnesi #: ");
+ scanf("%d",&vnos);
+//prva opcija
+ if (vnos==1){
+
+ printf("\nTrenutno je nastavljeno zapisovanje celotnih waveformov iz CH1 v datoteko 'test.txt'. Vnesite zeljeno stevilo ponovitev: ");
+ scanf("%d",&m);
+
+ test=fopen("/media/disk/vxi11_1.08/test.txt","w");
+ command("DATA:SOURCE CH1");
+ command("DATA:START 1");
+ command("DATA:STOP 1000");
+ command("DATA:ENCDG RPBINARY");
+
+(void) time(&t1);
+ query("ACQUIRE:NUMFRAMESACQUIRED?");
+
+ for(i=1;i<m+1;i++) { //zajem binarnih podatkov
+
+ memset(buf, 0, BUF_LEN);
+ vxi11_send(clink, "CURVE?");
+ int bytes_returned = vxi11_receive(clink, buf, BUF_LEN);
+
+ if (bytes_returned > 0) fwrite(buf,1,bytes_returned,test);
+ if(strcmp(buf,pr1)!=0){
+ if (bytes_returned > 0) fwrite(buf,1,1000,test);
+ else if (bytes_returned == -15) printf("*** [ NOTHING RECEIVED ] ***\n");
+ }
+ strcpy(pr1,buf);
+ }
+
+ query("ACQUIRE:NUMFRAMESACQUIRED?");
+(void) time(&t2);
+
+ printf("Koncano!\n");
+ printf("Trajanje: %ld s\n",(int)t2-t1);
+ fclose(test);
+
+ }
+//druga opcija
+ else if (vnos==2){
+
+ test1=fopen("/media/disk/vxi11_1.08/test1.txt","w");
+
+ printf("Vnesi zeljeno stevilo meritev minimuma LeCroy: ");
+ scanf("%d",&m);
+
+ for (i=0;i<m;i++) queryrep("C1:PAVA? MIN",pr2,i);
+
+ fclose(test1);
+ }
+//tretja opcija
+ else if (vnos==3){
+
+ test1=fopen("/media/disk/vxi11_1.08/test1.txt","w");
+
+ printf("Vnesi zeljeno stevilo zajemov: ");
+ scanf("%d",&m);
+
+ command("DATA:SOURCE CH1, CH2");
+ command("DATA:START 1");
+ command("DATA:STOP 1000");
+ command("DATA:ENCDG ASCII");
+
+ query("ACQUIRE:NUMFRAMESACQUIRED?");
+
+ for (i=0;i<m;i++) queryrep("CURVE?",pr2,i);
+
+ query("ACQUIRE:NUMFRAMESACQUIRED?");
+
+ fclose(test1);
+ }
+
+ if (strncasecmp(ukaz, "a",1) == 0) ret=vxi11_close_device("194.249.156.91",clink);
+ else ret=vxi11_close_device(ukaz,clink);
+
+ printf("Meritve opravljene!\nZa zakljucek pritisni 'q'! ");
+ scanf("%s",&end);
+
+ if (strcmp(end,"q")==0);
+
+ return 0;
+}
+
Index: sipmscan/trunk/include/vxi11_i686/vxi11_user.cc
===================================================================
--- sipmscan/trunk/include/vxi11_i686/vxi11_user.cc (nonexistent)
+++ sipmscan/trunk/include/vxi11_i686/vxi11_user.cc (revision 146)
@@ -0,0 +1,728 @@
+/* Revision history: */
+/* $Id: vxi11_user.cc,v 1.17 2008/10/20 07:59:54 sds Exp $ */
+/*
+ * $Log: vxi11_user.cc,v $
+ * Revision 1.17 2008/10/20 07:59:54 sds
+ * Removed Manfred's surname at his request from the comments/acknowledgments.
+ *
+ * Revision 1.16 2008/09/03 14:30:13 sds
+ * added sanity check for link->maxRecvSize to make sure it's >0.
+ * This got around a bug in some versions of the Agilent Infiniium
+ * scope software.
+ *
+ * Revision 1.15 2007/10/30 12:55:15 sds
+ * changed the erroneous strncpy() to memcpy() in vxi11_send,
+ * as we could be sending binary data (not just strings).
+ *
+ * Revision 1.14 2007/10/30 12:46:48 sds
+ * changed a lot of char *'s to const char *'s in an attempt to get
+ * rid of pedantic gcc compiler warnings.
+ *
+ * Revision 1.13 2007/10/09 08:42:57 sds
+ * Minor change to vxi11_receive_data_block(), this fn now
+ * copes with instruments that return just "#0" (for whatever
+ * reason). Suggestion by Jarek Sadowski.
+ *
+ * Revision 1.12 2007/08/31 10:32:39 sds
+ * Bug fix in vxi11_receive(), to ensure that no more than "len"
+ * bytes are ever received (and so avoiding a segmentation fault).
+ * This was a bug introduced in release 1.04 (RCS 1.10) whilst
+ * making some other changes to the vxi11_receive() fn. Many thanks
+ * to Rob Penny for spotting the bug and providing a patch.
+ *
+ * Revision 1.11 2007/07/10 13:49:18 sds
+ * Changed the vxi11_open_device() fn to accept a third argument, char *device.
+ * This gets passed to the core vxi11_open_device() fn (the one that deals with
+ * separate clients and links), and the core vxi11_open_link() fn; these two
+ * core functions have also had an extra parameter added accordingly. In order
+ * to not break the API, a wrapper function is provided in the form of the
+ * original vxi11_open_device() fn, that just takes 2 arguments
+ * (char *ip, CLINK *clink), this then passes "inst0" as the device argument.
+ * Backwards-compatible wrappers for the core functions have NOT been provided.
+ * These are generally not used from userland anyway. Hopefully this won't
+ * upset anyone!
+ *
+ * Revision 1.10 2007/07/10 11:12:12 sds
+ * Patches provided by Robert Larice. This basically solves the problem
+ * of having to recreate a link each time you change client. In the words
+ * of Robert:
+ *
+ * ---------
+ * In the source code there were some strange comments, suggesting
+ * you had trouble to get more than one link working.
+ *
+ * I think thats caused by some misuse of the rpcgen generated subroutines.
+ * 1) those rpcgen generated *_1 functions returned pointers to
+ * statically allocated temporary structs.
+ * those where meant to be instantly copied to the user's space,
+ * which wasn't done, thus instead of
+ * Device_ReadResp *read_resp;
+ * read_resp = device_read_1(...)
+ * one should have written someting like:
+ * Device_ReadResp *read_resp;
+ * read_resp = malloc(...)
+ * memcpy(read_resp, device_read_1(...), ...)
+ * 2) but a better fix is to use the rpcgen -M Flag
+ * which allows to pass the memory space as a third argument
+ * so one can write
+ * Device_ReadResp *read_resp;
+ * read_resp = malloc(...)
+ * device_read_1(..., read_resp, ...)
+ * furthermore this is now automatically thread save
+ * 3) the rpcgen function device_read_1
+ * expects a target buffer to be passed via read_resp
+ * which was not done.
+ * 4) the return value of vxi11_receive() was computed incorrectly
+ * 5) minor, Makefile typo's
+ * ---------
+ * So big thanks to Robert Larice for the patch! I've tested it
+ * (briefly) on more than one scope, and with multiple links per
+ * client, and it seems to work fine. I've thus removed all references
+ * to VXI11_ENABLE_MULTIPLE_CLIENTS, and deleted the vxi11_open_link()
+ * function that WASN'T passed an ip address (that was only called
+ * from the vxi11_send() fn, when there was more than one client).
+ *
+ * Revision 1.9 2006/12/08 12:06:58 ijc
+ * Basically the same changes as revision 1.8, except replace all
+ * references to "vxi11_receive" with "vxi11_send" and all references
+ * to "-VXI11_NULL_READ_RESP" with "-VXI11_NULL_WRITE_RESP".
+ *
+ * Revision 1.8 2006/12/07 12:22:20 sds
+ * Couple of changes, related.
+ * (1) added extra check in vxi11_receive() to see if read_resp==NULL.
+ * read_resp can apparently be NULL if (eg) you send an instrument a
+ * query, but the instrument is so busy with something else for so long
+ * that it forgets the original query. So this extra check is for that
+ * situation, and vxi11_receive returns -VXI11_NULL_READ_RESP to the
+ * calling function.
+ * (2) vxi11_send_and_receive() is now aware of the possibility of
+ * being returned -VXI11_NULL_READ_RESP. If so, it re-sends the query,
+ * until either getting a "regular" read error (read_resp->error!=0) or
+ * a successful read.
+ *
+ * Revision 1.7 2006/12/06 16:27:47 sds
+ * removed call to ANSI free() fn in vxi11_receive, which according to
+ * Manfred S. "is not necessary and wrong (crashes)".
+ *
+ * Revision 1.6 2006/08/25 13:45:12 sds
+ * Major improvements to the vxi11_send function. Now takes
+ * link->maxRecvSize into account, and writes a chunk at a time
+ * until the entire message is sent. Important for sending large
+ * data sets, because the data you want to send may be larger than
+ * the instrument's "input buffer."
+ *
+ * Revision 1.5 2006/08/25 13:06:44 sds
+ * tidied up some of the return values, and made sure that if a
+ * sub-function returned an error value, this would also be
+ * returned by the calling function.
+ *
+ * Revision 1.4 2006/07/06 13:04:59 sds
+ * Lots of changes this revision.
+ * Found I was having problems talking to multiple links on the same
+ * client, if I created a different client for each one. So introduced
+ * a few global variables to keep track of all the ip addresses of
+ * clients that the library is asked to create, and only creating new
+ * clients if the ip address is different. This puts a limit of how
+ * many unique ip addresses (clients) a single process can connect to.
+ * Set this value at 256 (should hopefully be enough!).
+ * Next I found that talking to different clients on different ip
+ * addresses didn't work. It turns out that create_link_1() creates
+ * a static structure. This this link is associated with a given
+ * client (and hence a given IP address), then the only way I could
+ * think of making things work was to add a call to an
+ * vxi11_open_link() function before each send command (no idea what
+ * this adds to overheads and it's very messy!) - at least I was
+ * able to get this to only happen when we are using more than one
+ * client/ip address.
+ * Also, while I was at it, I re-ordered the functions a little -
+ * starts with core user functions, extra user functions, then core
+ * library functions at the end. Added a few more comments. Tidied
+ * up. Left some debugging info in, but commented out.
+ *
+ * Revision 1.3 2006/06/26 12:40:56 sds
+ * Introduced a new CLINK structure, to reduce the number of arguments
+ * passed to functions. Wrote wrappers for open(), close(), send()
+ * and receieve() functions, then adjusted all the other functions built
+ * on those to make use of the CLINK structure.
+ *
+ * Revision 1.2 2006/06/26 10:29:48 sds
+ * Added GNU GPL and copyright notices.
+ *
+ */
+
+/* vxi11_user.cc
+ * Copyright (C) 2006 Steve D. Sharples
+ *
+ * User library for opening, closing, sending to and receiving from
+ * a device enabled with the VXI11 RPC ethernet protocol. Uses the files
+ * generated by rpcgen vxi11.x.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The author's email address is steve.sharples@nottingham.ac.uk
+ */
+
+#include "vxi11_user.h"
+
+/*****************************************************************************
+ * GENERAL NOTES
+ *****************************************************************************
+ *
+ * There are four functions at the heart of this library:
+ *
+ * int vxi11_open_device(char *ip, CLIENT **client, VXI11_LINK **link)
+ * int vxi11_close_device(char *ip, CLIENT *client, VXI11_LINK *link)
+ * int vxi11_send(CLIENT *client, VXI11_LINK *link, char *cmd, unsigned long len)
+ * long vxi11_receive(CLIENT *client, VXI11_LINK *link, char *buffer, unsigned long len, unsigned long timeout)
+ *
+ * Note that all 4 of these use separate client and link structures. All the
+ * other functions are built on these four core functions, and the first layer
+ * of abstraction is to combine the CLIENT and VXI11_LINK structures into a
+ * single entity, which I've called a CLINK. For the send and receive
+ * functions, this is just a simple wrapper. For the open and close functions
+ * it's a bit more complicated, because we somehow have to keep track of
+ * whether we've already opened a device with the same IP address before (in
+ * which case we need to recycle a previously created client), or whether
+ * we've still got any other links to a given IP address left when we are
+ * asked to close a clink (in which case we can sever the link, but have to
+ * keep the client open). This is so the person using this library from
+ * userland does not have to keep track of whether they are talking to a
+ * different physical instrument or not each time they establish a connection.
+ *
+ * So the base functions that the user will probably want to use are:
+ *
+ * int vxi11_open_device(char *ip, CLINK *clink)
+ * int vxi11_close_device(char *ip, CLINK *clink)
+ * int vxi11_send(CLINK *clink, char *cmd, unsigned long len)
+ * --- or --- (if sending just text)
+ * int vxi11_send(CLINK *clink, char *cmd)
+ * long vxi11_receive(CLINK *clink, char *buffer, unsigned long len, unsigned long timeout)
+ *
+ * There are then useful (to me, anyway) more specific functions built on top
+ * of these:
+ *
+ * int vxi11_send_data_block(CLINK *clink, char *cmd, char *buffer, unsigned long len)
+ * long vxi11_receive_data_block(CLINK *clink, char *buffer, unsigned long len, unsigned long timeout)
+ * long vxi11_send_and_receive(CLINK *clink, char *cmd, char *buf, unsigned long buf_len, unsigned long timeout)
+ * long vxi11_obtain_long_value(CLINK *clink, char *cmd, unsigned long timeout)
+ * double vxi11_obtain_double_value(CLINK *clink, char *cmd, unsigned long timeout)
+ *
+ * (then there are some shorthand wrappers for the above without specifying
+ * the timeout due to sheer laziness---explore yourself)
+ */
+
+
+/* Global variables. Keep track of multiple links per client. We need this
+ * because:
+ * - we'd like the library to be able to cope with multiple links to a given
+ * client AND multiple links to multiple clients
+ * - we'd like to just refer to a client/link ("clink") as a single
+ * entity from user land, we don't want to worry about different
+ * initialisation procedures, depending on whether it's an instrument
+ * with the same IP address or not
+ */
+char VXI11_IP_ADDRESS[VXI11_MAX_CLIENTS][20];
+CLIENT *VXI11_CLIENT_ADDRESS[VXI11_MAX_CLIENTS];
+int VXI11_DEVICE_NO = 0;
+int VXI11_LINK_COUNT[VXI11_MAX_CLIENTS];
+
+/*****************************************************************************
+ * KEY USER FUNCTIONS - USE THESE FROM YOUR PROGRAMS OR INSTRUMENT LIBRARIES *
+ *****************************************************************************/
+
+/* OPEN FUNCTIONS *
+ * ============== */
+
+/* Use this function from user land to open a device and create a link. Can be
+ * used multiple times for the same device (the library will keep track).*/
+int vxi11_open_device(const char *ip, CLINK *clink, char *device) {
+int ret;
+int l;
+int device_no=-1;
+
+// printf("before doing anything, clink->link = %ld\n", clink->link);
+ /* Have a look to see if we've already initialised an instrument with
+ * this IP address */
+ for (l=0; l<VXI11_MAX_CLIENTS; l++){
+ if (strcmp(ip,VXI11_IP_ADDRESS[l]) == 0 ) {
+ device_no=l;
+// printf("Open function, search, found ip address %s, device no %d\n",ip,device_no);
+ }
+ }
+
+ /* Couldn't find a match, must be a new IP address */
+ if (device_no < 0) {
+ /* Uh-oh, we're out of storage space. Increase the #define
+ * for VXI11_MAX_CLIENTS in vxi11_user.h */
+ if (VXI11_DEVICE_NO >= VXI11_MAX_CLIENTS) {
+ printf("Error: maximum of %d clients allowed\n",VXI11_MAX_CLIENTS);
+ ret = -VXI11_MAX_CLIENTS;
+ }
+ /* Create a new client, keep a note of where the client pointer
+ * is, for this IP address. Because it's a new client, this
+ * must be link number 1. Keep track of how many devices we've
+ * opened so we don't run out of storage space. */
+ else {
+ ret = vxi11_open_device(ip, &(clink->client), &(clink->link), device);
+ strncpy(VXI11_IP_ADDRESS[VXI11_DEVICE_NO],ip,20);
+ VXI11_CLIENT_ADDRESS[VXI11_DEVICE_NO] = clink->client;
+ VXI11_LINK_COUNT[VXI11_DEVICE_NO]=1;
+// printf("Open function, could not find ip address %s.\n",ip);
+// printf("So now, VXI11_IP_ADDRESS[%d]=%s,\n",VXI11_DEVICE_NO,VXI11_IP_ADDRESS[VXI11_DEVICE_NO]);
+// printf("VXI11_CLIENT_ADDRESS[%d]=%ld,\n",VXI11_DEVICE_NO,VXI11_CLIENT_ADDRESS[VXI11_DEVICE_NO]);
+// printf(" clink->client=%ld,\n",clink->client);
+// printf("VXI11_LINK_COUNT[%d]=%d.\n",VXI11_DEVICE_NO,VXI11_LINK_COUNT[VXI11_DEVICE_NO]);
+ VXI11_DEVICE_NO++;
+ }
+ }
+ /* already got a client for this IP address */
+ else {
+ /* Copy the client pointer address. Just establish a new link
+ * (not a new client). Add one to the link count */
+ clink->client = VXI11_CLIENT_ADDRESS[device_no];
+ ret = vxi11_open_link(ip, &(clink->client), &(clink->link), device);
+// printf("Found an ip address, copying client from VXI11_CLIENT_ADDRESS[%d]\n",device_no);
+ VXI11_LINK_COUNT[device_no]++;
+// printf("Have just incremented VXI11_LINK_COUNT[%d], it's now %d\n",device_no,VXI11_LINK_COUNT[device_no]);
+ }
+// printf("after creating link, clink->link = %ld\n", clink->link);
+ return ret;
+ }
+
+/* This is a wrapper function, used for the situations where there is only one
+ * "device" per client. This is the case for most (if not all) VXI11
+ * instruments; however, it is _not_ the case for devices such as LAN to GPIB
+ * gateways. These are single clients that communicate to many instruments
+ * (devices). In order to differentiate between them, we need to pass a device
+ * name. This gets used in the vxi11_open_link() fn, as the link_parms.device
+ * value. */
+int vxi11_open_device(const char *ip, CLINK *clink) {
+ char device[6];
+ strncpy(device,"inst0",6);
+ return vxi11_open_device(ip, clink, device);
+ }
+
+
+
+/* CLOSE FUNCTION *
+ * ============== */
+
+/* Use this function from user land to close a device and/or sever a link. Can
+ * be used multiple times for the same device (the library will keep track).*/
+int vxi11_close_device(const char *ip, CLINK *clink) {
+int l,ret;
+int device_no = -1;
+
+ /* Which instrument are we referring to? */
+ for (l=0; l<VXI11_MAX_CLIENTS; l++){
+ if (strcmp(ip,VXI11_IP_ADDRESS[l]) == 0 ) {
+ device_no=l;
+ }
+ }
+ /* Something's up if we can't find the IP address! */
+ if (device_no == -1) {
+ printf("vxi11_close_device: error: I have no record of you ever opening device\n");
+ printf(" with IP address %s\n",ip);
+ ret = -4;
+ }
+ else { /* Found the IP, there's more than one link to that instrument,
+ * so keep track and just close the link */
+ if (VXI11_LINK_COUNT[device_no] > 1 ) {
+ ret = vxi11_close_link(ip,clink->client, clink->link);
+ VXI11_LINK_COUNT[device_no]--;
+ }
+ /* Found the IP, it's the last link, so close the device (link
+ * AND client) */
+ else {
+ ret = vxi11_close_device(ip, clink->client, clink->link);
+ }
+ }
+ return ret;
+ }
+
+
+/* SEND FUNCTIONS *
+ * ============== */
+
+/* A _lot_ of the time we are sending text strings, and can safely rely on
+ * strlen(cmd). */
+int vxi11_send(CLINK *clink, const char *cmd) {
+ return vxi11_send(clink, cmd, strlen(cmd));
+ }
+
+/* We still need the version of the function where the length is set explicitly
+ * though, for when we are sending fixed length data blocks. */
+int vxi11_send(CLINK *clink, const char *cmd, unsigned long len) {
+ return vxi11_send(clink->client, clink->link, cmd, len);
+ }
+
+
+/* RECEIVE FUNCTIONS *
+ * ================= */
+
+/* Lazy wrapper for when I can't be bothered to specify a read timeout */
+long vxi11_receive(CLINK *clink, char *buffer, unsigned long len) {
+ return vxi11_receive(clink, buffer, len, VXI11_READ_TIMEOUT);
+ }
+
+long vxi11_receive(CLINK *clink, char *buffer, unsigned long len, unsigned long timeout) {
+ return vxi11_receive(clink->client, clink->link, buffer, len, timeout);
+ }
+
+
+
+/*****************************************************************************
+ * USEFUL ADDITIONAL HIGHER LEVER USER FUNCTIONS - USE THESE FROM YOUR *
+ * PROGRAMS OR INSTRUMENT LIBRARIES *
+ *****************************************************************************/
+
+/* SEND FIXED LENGTH DATA BLOCK FUNCTION *
+ * ===================================== */
+int vxi11_send_data_block(CLINK *clink, const char *cmd, char *buffer, unsigned long len) {
+char *out_buffer;
+int cmd_len=strlen(cmd);
+int ret;
+
+ out_buffer=new char[cmd_len+10+len];
+ sprintf(out_buffer,"%s#8%08lu",cmd,len);
+ memcpy(out_buffer+cmd_len+10,buffer,(unsigned long) len);
+ ret = vxi11_send(clink, out_buffer, (unsigned long) (cmd_len+10+len));
+ delete[] out_buffer;
+ return ret;
+ }
+
+
+/* RECEIVE FIXED LENGTH DATA BLOCK FUNCTION *
+ * ======================================== */
+
+/* This function reads a response in the form of a definite-length block, such
+ * as when you ask for waveform data. The data is returned in the following
+ * format:
+ * #800001000<1000 bytes of data>
+ * ||\______/
+ * || |
+ * || \---- number of bytes of data
+ * |\--------- number of digits that follow (in this case 8, with leading 0's)
+ * \---------- always starts with #
+ */
+long vxi11_receive_data_block(CLINK *clink, char *buffer, unsigned long len, unsigned long timeout) {
+/* I'm not sure what the maximum length of this header is, I'll assume it's
+ * 11 (#9 + 9 digits) */
+unsigned long necessary_buffer_size;
+char *in_buffer;
+int ret;
+int ndigits;
+unsigned long returned_bytes;
+int l;
+char scan_cmd[20];
+ necessary_buffer_size=len+12;
+ in_buffer=new char[necessary_buffer_size];
+ ret=vxi11_receive(clink, in_buffer, necessary_buffer_size, timeout);
+ if (ret < 0) return ret;
+ if (in_buffer[0] != '#') {
+ printf("vxi11_user: data block error: data block does not begin with '#'\n");
+ printf("First 20 characters received were: '");
+ for(l=0;l<20;l++) {
+ printf("%c",in_buffer[l]);
+ }
+ printf("'\n");
+ return -3;
+ }
+
+ /* first find out how many digits */
+ sscanf(in_buffer,"#%1d",&ndigits);
+ /* some instruments, if there is a problem acquiring the data, return only "#0" */
+ if (ndigits > 0) {
+ /* now that we know, we can convert the next <ndigits> bytes into an unsigned long */
+ sprintf(scan_cmd,"#%%1d%%%dlu",ndigits);
+ sscanf(in_buffer,scan_cmd,&ndigits,&returned_bytes);
+ memcpy(buffer, in_buffer+(ndigits+2), returned_bytes);
+ delete[] in_buffer;
+ return (long) returned_bytes;
+ }
+ else return 0;
+ }
+
+
+/* SEND AND RECEIVE FUNCTION *
+ * ========================= */
+
+/* This is mainly a useful function for the overloaded vxi11_obtain_value()
+ * fn's, but is also handy and useful for user and library use */
+long vxi11_send_and_receive(CLINK *clink, const char *cmd, char *buf, unsigned long buf_len, unsigned long timeout) {
+int ret;
+long bytes_returned;
+ do {
+ ret = vxi11_send(clink, cmd);
+ if (ret != 0) {
+ if (ret != -VXI11_NULL_WRITE_RESP) {
+ printf("Error: vxi11_send_and_receive: could not send cmd.\n");
+ printf(" The function vxi11_send returned %d. ",ret);
+ return -1;
+ }
+ else printf("(Info: VXI11_NULL_WRITE_RESP in vxi11_send_and_receive, resending query)\n");
+ }
+
+ bytes_returned = vxi11_receive(clink, buf, buf_len, timeout);
+ if (bytes_returned <= 0) {
+ if (bytes_returned >-VXI11_NULL_READ_RESP) {
+ printf("Error: vxi11_send_and_receive: problem reading reply.\n");
+ printf(" The function vxi11_receive returned %ld. ",bytes_returned);
+ return -2;
+ }
+ else printf("(Info: VXI11_NULL_READ_RESP in vxi11_send_and_receive, resending query)\n");
+ }
+ } while (bytes_returned == -VXI11_NULL_READ_RESP || ret == -VXI11_NULL_WRITE_RESP);
+ return 0;
+ }
+
+
+/* FUNCTIONS TO RETURN A LONG INTEGER VALUE SENT AS RESPONSE TO A QUERY *
+ * ==================================================================== */
+long vxi11_obtain_long_value(CLINK *clink, const char *cmd, unsigned long timeout) {
+char buf[50]; /* 50=arbitrary length... more than enough for one number in ascii */
+ memset(buf, 0, 50);
+ if (vxi11_send_and_receive(clink, cmd, buf, 50, timeout) != 0) {
+ printf("Returning 0\n");
+ return 0;
+ }
+ return strtol(buf, (char **)NULL, 10);
+ }
+
+/* Lazy wrapper function with default read timeout */
+long vxi11_obtain_long_value(CLINK *clink, const char *cmd) {
+ return vxi11_obtain_long_value(clink, cmd, VXI11_READ_TIMEOUT);
+ }
+
+
+/* FUNCTIONS TO RETURN A DOUBLE FLOAT VALUE SENT AS RESPONSE TO A QUERY *
+ * ==================================================================== */
+double vxi11_obtain_double_value(CLINK *clink, const char *cmd, unsigned long timeout) {
+char buf[50]; /* 50=arbitrary length... more than enough for one number in ascii */
+double val;
+ memset(buf, 0, 50);
+ if (vxi11_send_and_receive(clink, cmd, buf, 50, timeout) != 0) {
+ printf("Returning 0.0\n");
+ return 0.0;
+ }
+ val = strtod(buf, (char **)NULL);
+ return val;
+ }
+
+/* Lazy wrapper function with default read timeout */
+double vxi11_obtain_double_value(CLINK *clink, const char *cmd) {
+ return vxi11_obtain_double_value(clink, cmd, VXI11_READ_TIMEOUT);
+ }
+
+
+/*****************************************************************************
+ * CORE FUNCTIONS - YOU SHOULDN'T NEED TO USE THESE FROM YOUR PROGRAMS OR *
+ * INSTRUMENT LIBRARIES *
+ *****************************************************************************/
+
+/* OPEN FUNCTIONS *
+ * ============== */
+int vxi11_open_device(const char *ip, CLIENT **client, VXI11_LINK **link, char *device) {
+
+ *client = clnt_create(ip, DEVICE_CORE, DEVICE_CORE_VERSION, "tcp");
+
+ if (*client == NULL) {
+ clnt_pcreateerror(ip);
+ return -1;
+ }
+
+ return vxi11_open_link(ip, client, link, device);
+ }
+
+int vxi11_open_link(const char *ip, CLIENT **client, VXI11_LINK **link, char *device) {
+
+Create_LinkParms link_parms;
+
+ /* Set link parameters */
+ link_parms.clientId = (long) *client;
+ link_parms.lockDevice = 0;
+ link_parms.lock_timeout = VXI11_DEFAULT_TIMEOUT;
+ link_parms.device = device;
+
+ *link = (Create_LinkResp *) calloc(1, sizeof(Create_LinkResp));
+
+ if (create_link_1(&link_parms, *link, *client) != RPC_SUCCESS) {
+ clnt_perror(*client, ip);
+ return -2;
+ }
+ return 0;
+ }
+
+
+/* CLOSE FUNCTIONS *
+ * =============== */
+int vxi11_close_device(const char *ip, CLIENT *client, VXI11_LINK *link) {
+int ret;
+
+ ret = vxi11_close_link(ip, client, link);
+
+ clnt_destroy(client);
+
+ return ret;
+ }
+
+int vxi11_close_link(const char *ip, CLIENT *client, VXI11_LINK *link) {
+Device_Error dev_error;
+ memset(&dev_error, 0, sizeof(dev_error));
+
+ if (destroy_link_1(&link->lid, &dev_error, client) != RPC_SUCCESS) {
+ clnt_perror(client,ip);
+ return -1;
+ }
+
+ return 0;
+ }
+
+
+/* SEND FUNCTIONS *
+ * ============== */
+
+/* A _lot_ of the time we are sending text strings, and can safely rely on
+ * strlen(cmd). */
+int vxi11_send(CLIENT *client, VXI11_LINK *link, const char *cmd) {
+ return vxi11_send(client, link, cmd, strlen(cmd));
+ }
+
+/* We still need the version of the function where the length is set explicitly
+ * though, for when we are sending fixed length data blocks. */
+int vxi11_send(CLIENT *client, VXI11_LINK *link, const char *cmd, unsigned long len) {
+Device_WriteParms write_parms;
+int bytes_left = (int)len;
+char *send_cmd;
+
+ send_cmd = new char[len];
+ memcpy(send_cmd, cmd, len);
+
+ write_parms.lid = link->lid;
+ write_parms.io_timeout = VXI11_DEFAULT_TIMEOUT;
+ write_parms.lock_timeout = VXI11_DEFAULT_TIMEOUT;
+
+/* We can only write (link->maxRecvSize) bytes at a time, so we sit in a loop,
+ * writing a chunk at a time, until we're done. */
+
+ do {
+ Device_WriteResp write_resp;
+ memset(&write_resp, 0, sizeof(write_resp));
+
+ if (bytes_left <= link->maxRecvSize) {
+ write_parms.flags = 8;
+ write_parms.data.data_len = bytes_left;
+ }
+ else {
+ write_parms.flags = 0;
+ /* We need to check that maxRecvSize is a sane value (ie >0). Believe it
+ * or not, on some versions of Agilent Infiniium scope firmware the scope
+ * returned "0", which breaks Rule B.6.3 of the VXI-11 protocol. Nevertheless
+ * we need to catch this, otherwise the program just hangs. */
+ if (link->maxRecvSize > 0) {
+ write_parms.data.data_len = link->maxRecvSize;
+ }
+ else {
+ write_parms.data.data_len = 4096; /* pretty much anything should be able to cope with 4kB */
+ }
+ }
+ write_parms.data.data_val = send_cmd + (len - bytes_left);
+
+ if(device_write_1(&write_parms, &write_resp, client) != RPC_SUCCESS) {
+ delete[] send_cmd;
+ return -VXI11_NULL_WRITE_RESP; /* The instrument did not acknowledge the write, just completely
+ dropped it. There was no vxi11 comms error as such, the
+ instrument is just being rude. Usually occurs when the instrument
+ is busy. If we don't check this first, then the following
+ line causes a seg fault */
+ }
+ if (write_resp . error != 0) {
+ printf("vxi11_user: write error: %d\n",write_resp . error);
+ delete[] send_cmd;
+ return -(write_resp . error);
+ }
+ bytes_left -= write_resp . size;
+ } while (bytes_left > 0);
+
+ delete[] send_cmd;
+ return 0;
+ }
+
+
+/* RECEIVE FUNCTIONS *
+ * ================= */
+
+// It appeared that this function wasn't correctly dealing with more data available than specified in len.
+// This patch attempts to fix this issue. RDP 2007/8/13
+
+/* wrapper, for default timeout */ long vxi11_receive(CLIENT *client, VXI11_LINK *link, char *buffer, unsigned long len) { return vxi11_receive(client, link, buffer, len, VXI11_READ_TIMEOUT);
+ }
+
+#define RCV_END_BIT 0x04 // An end indicator has been read
+#define RCV_CHR_BIT 0x02 // A termchr is set in flags and a character which matches termChar is transferred
+#define RCV_REQCNT_BIT 0x01 // requestSize bytes have been transferred. This includes a request size of zero.
+
+long vxi11_receive(CLIENT *client, VXI11_LINK *link, char *buffer, unsigned long len, unsigned long timeout) {
+Device_ReadParms read_parms;
+Device_ReadResp read_resp;
+long curr_pos = 0;
+
+ read_parms.lid = link->lid;
+ read_parms.requestSize = len;
+ read_parms.io_timeout = timeout; /* in ms */
+ read_parms.lock_timeout = timeout; /* in ms */
+ read_parms.flags = 0;
+ read_parms.termChar = 0;
+
+ do {
+ memset(&read_resp, 0, sizeof(read_resp));
+
+ read_resp.data.data_val = buffer + curr_pos;
+ read_parms.requestSize = len - curr_pos; // Never request more total data than originally specified in len
+
+ if(device_read_1(&read_parms, &read_resp, client) != RPC_SUCCESS) {
+ return -VXI11_NULL_READ_RESP; /* there is nothing to read. Usually occurs after sending a query
+ which times out on the instrument. If we don't check this first,
+ then the following line causes a seg fault */
+ }
+ if (read_resp . error != 0) {
+ /* Read failed for reason specified in error code.
+ * 0 no error
+ * 4 invalid link identifier
+ * 11 device locked by another link
+ * 15 I/O timeout
+ * 17 I/O error
+ * 23 abort
+ */
+
+ printf("vxi11_user: read error: %d\n",read_resp . error);
+ return -(read_resp . error);
+ }
+
+ if((curr_pos + read_resp . data.data_len) <= len) {
+ curr_pos += read_resp . data.data_len;
+ }
+ if( (read_resp.reason & RCV_END_BIT) || (read_resp.reason & RCV_CHR_BIT) ) {
+ break;
+ }
+ else if( curr_pos == len ) {
+ printf("xvi11_user: read error: buffer too small. Read %d bytes without hitting terminator.\n", curr_pos );
+ return -100;
+ }
+ } while(1);
+ return (curr_pos); /*actual number of bytes received*/
+
+ }
+
Index: sipmscan/trunk/include/vxi11_i686/vxi11_user.h
===================================================================
--- sipmscan/trunk/include/vxi11_i686/vxi11_user.h (nonexistent)
+++ sipmscan/trunk/include/vxi11_i686/vxi11_user.h (revision 146)
@@ -0,0 +1,136 @@
+/* Revision history: */
+/* $Id: vxi11_user.h,v 1.10 2007/10/30 12:47:33 sds Exp $ */
+/*
+ * $Log: vxi11_user.h,v $
+ * Revision 1.10 2007/10/30 12:47:33 sds
+ * changed a lot of char *'s to const char *'s in an attempt to get
+ * rid of pedantic gcc compiler warnings.
+ *
+ * Revision 1.9 2007/07/11 14:20:56 sds
+ * removed #include <iostream> as not needed
+ * removed using namespace std
+ *
+ * Revision 1.8 2007/07/10 13:54:11 sds
+ * Added extra function:
+ * int vxi11_open_device(char *ip, CLINK *clink, char *device);
+ * This replaces the original vxi11_open_device fn, which did not pass
+ * a char *device. Wrapper fn used for backwards compatibility.
+ *
+ * Revision 1.7 2007/07/10 11:20:43 sds
+ * removed the following function:
+ * int vxi11_open_link(CLIENT **client, VXI11_LINK **link);
+ * ...since it was no longer needed, following the patch by
+ * Robert Larice.
+ *
+ * Revision 1.6 2006/12/08 11:47:14 ijc
+ * error on last ci, sorted.
+ *
+ * Revision 1.5 2006/12/08 11:45:29 ijc
+ * added #define VXI11_NULL_READ_RESP
+ *
+ * Revision 1.4 2006/12/07 12:26:17 sds
+ * added VXI11_NULL_READ_RESP #define
+ *
+ * Revision 1.3 2006/07/06 13:03:28 sds
+ * Surrounded the whole header with #ifndef __VXI11_USER__.
+ * Added a couple of vxi11_open_link() fns and a vxi11_close_link() fn, to
+ * separate the link stuff from the client stuff.
+ *
+ * Revision 1.2 2006/06/26 12:42:54 sds
+ * Introduced a new CLINK structure, to reduce the number of arguments
+ * passed to functions. Wrote wrappers for open(), close(), send()
+ * and receieve() functions, then adjusted all the other functions built
+ * on those to make use of the CLINK structure.
+ *
+ * Revision 1.1 2006/06/26 10:36:02 sds
+ * Initial revision
+ *
+ */
+
+/* vxi11_user.h
+ * Copyright (C) 2006 Steve D. Sharples
+ *
+ * User library for opening, closing, sending to and receiving from
+ * a device enabled with the VXI11 RPC ethernet protocol. Uses the files
+ * generated by rpcgen vxi11.x.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The author's email address is steve.sharples@nottingham.ac.uk
+ */
+
+#ifndef __VXI11_USER__
+#define __VXI11_USER__
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <rpc/rpc.h>
+#include "vxi11.h"
+
+#define VXI11_DEFAULT_TIMEOUT 10000 /* in ms */
+#define VXI11_READ_TIMEOUT 2000 /* in ms */
+#define VXI11_CLIENT CLIENT
+#define VXI11_LINK Create_LinkResp
+#define VXI11_MAX_CLIENTS 256 /* maximum no of unique IP addresses/clients */
+#define VXI11_NULL_READ_RESP 50 /* vxi11_receive() return value if a query
+ * times out ON THE INSTRUMENT (and so we have
+ * to resend the query again) */
+#define VXI11_NULL_WRITE_RESP 51 /* vxi11_send() return value if a sent command
+ * times out ON THE INSTURMENT. */
+
+struct CLINK {
+ VXI11_CLIENT *client;
+ VXI11_LINK *link;
+ } ;
+typedef struct CLINK CLINK;
+
+/* The four main functions: open, close, send, receieve (plus a couple of wrappers) */
+/* In fact all 6 of these are wrappers to the original functions listed at the
+ * bottom, that use separate CLIENT and VXI11_LINK structures. It was easier to
+ * write wrappers for these functions than to re-write the original functions
+ * themselves. These are the 4 (or 6 if you like) key user functions that you
+ * should probably be using. They all use the CLINK structure. */
+int vxi11_open_device(const char *ip, CLINK *clink);
+int vxi11_open_device(const char *ip, CLINK *clink, char *device);
+int vxi11_close_device(const char *ip, CLINK *clink);
+int vxi11_send(CLINK *clink, const char *cmd);
+int vxi11_send(CLINK *clink, const char *cmd, unsigned long len);
+long vxi11_receive(CLINK *clink, char *buffer, unsigned long len);
+long vxi11_receive(CLINK *clink, char *buffer, unsigned long len, unsigned long timeout);
+int vxi11_queryxx(CLINK *clink, char *mycmd);
+/* Utility functions, that use send() and receive(). Use these too. */
+int vxi11_send_data_block(CLINK *clink, const char *cmd, char *buffer, unsigned long len);
+long vxi11_receive_data_block(CLINK *clink, char *buffer, unsigned long len, unsigned long timeout);
+long vxi11_send_and_receive(CLINK *clink, const char *cmd, char *buf, unsigned long buf_len, unsigned long timeout);
+long vxi11_obtain_long_value(CLINK *clink, const char *cmd, unsigned long timeout);
+double vxi11_obtain_double_value(CLINK *clink, const char *cmd, unsigned long timeout);
+long vxi11_obtain_long_value(CLINK *clink, const char *cmd);
+double vxi11_obtain_double_value(CLINK *link, const char *cmd);
+
+/* When I first wrote this library I used separate client and links. I've
+ * retained the original functions and just written clink wrappers for them
+ * (see above) as it's perhaps a little clearer this way. Probably not worth
+ * delving this deep in use, but it's where the real nitty gritty is. */
+int vxi11_open_device(const char *ip, CLIENT **client, VXI11_LINK **link, char *device);
+int vxi11_open_link(const char *ip, CLIENT **client, VXI11_LINK **link, char *device);
+int vxi11_close_device(const char *ip, CLIENT *client, VXI11_LINK *link);
+int vxi11_close_link(const char *ip, CLIENT *client, VXI11_LINK *link);
+int vxi11_send(CLIENT *client, VXI11_LINK *link, const char *cmd);
+int vxi11_send(CLIENT *client, VXI11_LINK *link, const char *cmd, unsigned long len);
+long vxi11_receive(CLIENT *client, VXI11_LINK *link, char *buffer, unsigned long len);
+long vxi11_receive(CLIENT *client, VXI11_LINK *link, char *buffer, unsigned long len, unsigned long timeout);
+
+#endif
Index: sipmscan/trunk/include/vxi11_x86_64/CHANGELOG.txt
===================================================================
--- sipmscan/trunk/include/vxi11_x86_64/CHANGELOG.txt (nonexistent)
+++ sipmscan/trunk/include/vxi11_x86_64/CHANGELOG.txt (revision 146)
@@ -0,0 +1,218 @@
+------------------------------------------------------------------------------
+vxi11_1.10 - 9/09/2010
+
+Bug fix (thanks to Stephan Mahr): in vxi11_close(), remove the IP address
+from the global array that keeps track of them so that if the same device
+is opened again, then a new client is created, rather than it attempting
+to use the old one (which was destroyed on the previous close).
+
+------------------------------------------------------------------------------
+vxi11_1.09 - 7/06/2010
+
+Moved over to bazaar VCS (from RCS).
+
+Makefile cleanups. Fixed signed/unsigned comparisons. Use consistent (and
+sane) struct separator spacing in code.
+
+Fix int casting on printf statements to fix new compiler warnings/errors
+(thanks to Shouri Chatterjee for pointing this out).
+
+------------------------------------------------------------------------------
+vxi11_1.08 - 3/09/2009
+
+Added a sanity check for link->maxRecvSize to make sure it's >0. This gets
+around a bug in some versions of the Agilent Infiniium scope software.
+
+Changed the erroneous strncpy() to memcpy() in vxi11_send, as we could be
+sending binary data (not just strings).
+
+Changed a lot of char *'s to const char *'s in an attempt to get rid of
+pedantic gcc compiler warnings.
+
+------------------------------------------------------------------------------
+vxi11_1.07 - 9/10/2007
+
+Minor change to vxi11_receive_data_block(), this fn now copes with instruments
+that return just "#0" (for whatever reason). Suggestion by Jarek Sadowski,
+gratefully received.
+
+------------------------------------------------------------------------------
+vxi11_1.06 - 31/08/2007
+
+Bug fix in vxi11_receive(), to ensure that no more than "len" bytes are ever
+received (and so avoiding a segmentation fault). This was a bug introduced in
+release 1.04 whilst making some other changes to the vxi11_receive() fn.
+
+Many thanks to Rob Penny for spotting the bug and providing a patch.
+
+------------------------------------------------------------------------------
+vxi11_1.05 - 11/07/2007
+
+Added the ability to specify a "device name" when calling vxi11_open_device().
+For regular VXI11-based instruments, such as scopes and AFGs, the device name
+is usually "hard wired" to be "inst0", and up to now this has been hard wired
+into the vxi11_user code. However, devices such as LAN to GPIB gateways need
+some way of distinguishing between different devices... they are a single
+client (one IP address), with multiple devices.
+
+The vxi11_user fn, vxi11_open_device(), now takes a third argument
+(char *device).
+This gets passed to the core vxi11_open_device() fn (the one that deals with
+separate clients and links), and the core vxi11_open_link() fn; these two
+core functions have also had an extra parameter added accordingly. In order
+to not break the API, a wrapper function is provided in the form of the
+original vxi11_open_device() fn, that just takes 2 arguments
+(char *ip, CLINK *clink), this then passes "inst0" as the device argument.
+Backwards-compatible wrappers for the core functions have NOT been provided.
+These are generally not used from userland anyway. Hopefully this won't
+upset anyone!
+
+vxi11_cmd, the simple test utility, has also been updated. You can now,
+optionally, pass the device_name as a second argument (after the ip
+address). The source has been renamed to vxi11_cmd.cc (from vxi11_cmd.c), as
+it is C++ code not C.
+
+Some minor tidying up in vxi11_user.h
+
+With thanks to Oliver Schulz for bringing LAN to GPIB gateways to my
+attention, for suggesting changes to the vxi11_user library to allow them to
+be accommodated, and for tidying some things up.
+
+------------------------------------------------------------------------------
+vxi11_1.04 - 10/07/2007
+
+Patch applied, which was kindly provided by Robert Larice. This sorts out
+the confusion (on my part) about the structures returned by the rpcgen
+generated *_1() functions... these are statically allocated temporary structs,
+apparently. In the words of Robert Larice:
+
+******
+Hello Dr. Sharples,
+
+ I'm sending some patches for your nice gem "vxi11_1.03"
+
+ In the source code there were some strange comments, concerning
+ a commented free() around ... Manfred S. ...
+ and some notes, suggesting you had trouble to get more than one link
+ working.
+
+ I think thats caused by some misuse of the rpcgen generated subroutines.
+ 1) those rpcgen generated *_1 functions returned pointers to
+ statically allocated temporary structs.
+ those where meant to be instantly copied to the user's space,
+ which wasn't done
+ thus instead of
+ Device_ReadResp *read_resp;
+ read_resp = device_read_1(...)
+ one should have written someting like:
+ Device_ReadResp *read_resp;
+ read_resp = malloc(...)
+ memcpy(read_resp, device_read_1(...), ...)
+ 2) but a better fix is to use the rpcgen -M Flag
+ which allows to pass the memory space as a third argument
+ so one can write
+ Device_ReadResp *read_resp;
+ read_resp = malloc(...)
+ device_read_1(..., read_resp, ...)
+ furthermore this is now automatically thread save
+ 3) the rpcgen function device_read_1
+ expects a target buffer to be passed via read_resp
+ which was not done.
+ 4) the return value of vxi11_receive() was computed incorrectly
+ 5) minor, Makefile typo's
+ CFLAGS versus
+ CLFAGS
+
+******
+
+Robert didn't have more than one device to try the patch with, but I've just
+tried it and everything seems fine. So I've removed all references to the
+VXI11_ENABLE_MULTIPLE_CLIENTS global variable, and removed the call to
+vxi11_open_link() from the vxi11_send() fn. There has been an associated
+tidying of functions, and removal of some comments.
+
+Thanks once again to Robert Larice for the patch and the explanation!
+
+------------------------------------------------------------------------------
+vxi11_1.03 - 29/01/2007
+
+Some bug-fixes (thanks to Manfred S.), and extra awareness of the
+possibility that instruments could time out after receiving a query WITHOUT
+causing an error condition. In some cases (prior to these changes) this
+could have resulted in a segmentation fault.
+
+Specifically:
+
+(1) removed call to ANSI free() fn in vxi11_receive, which according to
+ Manfred S. "is not necessary and wrong (crashes)".
+
+(2) added extra check in vxi11_receive() to see if read_resp==NULL.
+ read_resp can apparently be NULL if (eg) you send an instrument a
+ query, but the instrument is so busy with something else for so long
+ that it forgets the original query. So this extra check is for that
+ situation, and vxi11_receive returns -VXI11_NULL_READ_RESP to the
+ calling function.
+
+(3) vxi11_send_and_receive() is now aware of the possibility of being
+ returned -VXI11_NULL_READ_RESP. If so, it re-sends the query, until
+ either getting a "regular" read error (read_resp->error!=0) or a
+ successful read.
+
+(4) Similar to (2)... added extra check in vxi11_send() to see if
+ write_resp==NULL. If so, return -VXI11_NULL_WRITE_RESP. As with (3),
+ send_and_receive() is now aware of this possibility.
+
+------------------------------------------------------------------------------
+vxi11_1.02 - 25/08/2006
+
+Important changes to the core vxi11_send() function, which should be
+invisible to the user.
+
+For those interested, the function now takes note of the value of
+link->maxRecvSize, which is the maximum number of bytes that the vxi11
+intrument you're talking to can receive in one go. For many instruments
+this may be a few kB, which isn't a problem for sending short commands;
+however, sending large chunks of data (for example sending waveforms
+to instruments) may exceed this maxRecvSize. The core vxi11_send() function
+has been re-written to ensure that only a maximum of [maxRecvSize] bytes are
+written in one go... the function sits in a loop until all the message/
+data is written.
+
+Also tidied up some of the return values (specifically with regard to
+vxi11_send() and vxi11_send_data_block() ).
+
+------------------------------------------------------------------------------
+vxi11_1.01 - 06/07/2006
+
+Fair few changes since v1.00, all in vxi11_user.c and vxi11_user.h
+
+Found I was having problems talking to multiple links on the same
+client, if I created a different client for each one. So introduced
+a few global variables to keep track of all the ip addresses of
+clients that the library is asked to create, and only creating new
+clients if the ip address is different. This puts a limit of how
+many unique ip addresses (clients) a single process can connect to.
+Set this value at 256 (should hopefully be enough!).
+
+Next I found that talking to different clients on different ip
+addresses didn't work. It turns out that create_link_1() creates
+a static structure. This this link is associated with a given
+client (and hence a given IP address), then the only way I could
+think of making things work was to add a call to an
+vxi11_open_link() function before each send command (no idea what
+this adds to overheads and it's very messy!) - at least I was
+able to get this to only happen when we are using more than one
+client/ip address.
+
+Also, while I was at it, I re-ordered the functions a little -
+starts with core user functions, extra user functions, then core
+library functions at the end. Added a few more comments. Tidied
+up. Left some debugging info in, but commented out.
+
+------------------------------------------------------------------------------
+vxi11_1.00 - 23/06/2006
+
+Initial release.
+
+------------------------------------------------------------------------------
+
Index: sipmscan/trunk/include/vxi11_x86_64/GNU_General_Public_License.txt
===================================================================
--- sipmscan/trunk/include/vxi11_x86_64/GNU_General_Public_License.txt (nonexistent)
+++ sipmscan/trunk/include/vxi11_x86_64/GNU_General_Public_License.txt (revision 146)
@@ -0,0 +1,340 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
Index: sipmscan/trunk/include/vxi11_x86_64/Makefile
===================================================================
--- sipmscan/trunk/include/vxi11_x86_64/Makefile (nonexistent)
+++ sipmscan/trunk/include/vxi11_x86_64/Makefile (revision 146)
@@ -0,0 +1,18 @@
+VERSION=1.08
+
+#CFLAGS = -Wall -g
+CFLAGS = -g
+CXX = g++
+
+.PHONY: clean objs
+
+objs: vxi11.h
+ $(CXX) -c -fPIC $(CFLAGS) vxi11_user.cc
+ $(CXX) -c -fPIC $(CFLAGS) vxi11_clnt.c
+ $(CXX) -c -fPIC $(CFLAGS) vxi11_xdr.c
+
+vxi11.h: vxi11.x
+ rpcgen -M vxi11.x
+
+clean:
+ rm -f *.o vxi11_cmd vxi11.h vxi11_svc.c vxi11_xdr.c vxi11_clnt.c #TAGS
Index: sipmscan/trunk/include/vxi11_x86_64/README.txt
===================================================================
--- sipmscan/trunk/include/vxi11_x86_64/README.txt (nonexistent)
+++ sipmscan/trunk/include/vxi11_x86_64/README.txt (revision 146)
@@ -0,0 +1,98 @@
+RPC PROTOCOL FOR COMMUNICATING WITH VXI11-ENABLED DEVICES OVER ETHERNET FROM LINUX
+==================================================================================
+(including instruments such as oscilloscopes, by manufacturers such as
+Agilent and Tektronix, amongst others).
+
+By Steve D. Sharples, June 2006.
+
+This is a collection of source code that will allow you to talk to ethernet-
+enabled instruments that use the VXI11 protocol, from Linux. This includes
+a wide range of instruments (including oscilloscopes, logic analysers,
+function generators etc) by a wide range of manufacturers (including
+Tektronix and Agilent to name just a couple). An interactive "send and
+receive" utility is included as an example.
+
+You may want to build on to this libraries for your specific instruments -
+I'm currently working on libraries for talking to Agilent Infiniium scopes,
+and will probably do the same for Tektronix scopes too. Basically if you've
+got a Programmer's Reference for your instrument, and this code, you should
+be able to cobble something together.
+
+This collection of code has been produced because I grew frustrated at how
+difficult it seemed to be to do a relatively simple task. None of the
+major manufacturers had any "out of the box" Linux solutions to talking to
+their instruments (although often I would talk to technical folks who would
+try their best to help). One of the solutions offered was to use something
+called NI VISA; parts of this are closed source, it was enormous, and I had
+worries about legacy issues with changing PC hardware.
+
+Via Guy McBride at Agilent, I obtained a copy of a vxi11.x RPC file similar
+to the one included here (although no-one at Agilent seemed to know or care
+where it came from). After lots of searching on the information superhighway
+I located what I believe is the original source (or something like it); see
+the section on vxi11.x below. This source seems to have literally been written
+from the published VXI11 protocol. I also received from Agilent a simple
+example program that showed you how to use the protocol; working from this
+and the (open) source that uses the vxi11.x that is included here, I wrote
+vxi11_cmd and the user libraries.
+
+This collection of source code consists of:
+
+(1) vxi11.x
+This file, vxi11.x, is the amalgamation of vxi11core.rpcl and vxi11intr.rpcl
+which are part of the asynDriver (R4-5) EPICS module, which, at time of
+writing, is available from:
+http://www.aps.anl.gov/epics/modules/soft/asyn/index.html
+More general information about EPICS is available from:
+http://www.aps.anl.gov/epics/
+This code is open source, and is covered under the copyright notice and
+software license agreement shown below, and also at:
+http://www.aps.anl.gov/epics/license/open.php
+
+It is intended as a lightweight base for the vxi11 rpc protocol. If you
+run rpcgen on this file, it will generate C files and headers, from which
+it is relatively simple to write C programs to communicate with a range
+of ethernet-enabled instruments, such as oscilloscopes and function
+generators by manufacturers such as Agilent and Tektronix (amongst many
+others).
+
+(2) vxi11_user.cc (and vxi11_user.h)
+These are (fairly) friendly user libraries. At the core are 4 key functions:
+vxi11_open(), vxi11_close(), vxi11_send() and vxi11_receive(). These allow
+you to talk to your device. There are also some other functions that I
+considered to be generally useful (send_and_receive, functions for sending
+and receiving fixed length data blocks etc) that are all non-instrument-
+specific.
+
+(3) vxi11_cmd.c
+This is a fairly simple interactive utility that allows you to send
+commands and queries to your vxi11-enabled instrument, which you
+locate by way of IP address. I recommend you start with *IDN? It shows you
+how the vxi11_user library works
+
+(4) Makefile
+Type "make" to compile the source above. Type "make clean" to remove
+old object files and ./vxi11_cmd. Type "make install" to copy
+./vxi11_cmd to /usr/local/bin/
+
+(5) GNU_General_Public_License.txt
+Fairly obvious. All programs, source, readme files etc NOT covered by any
+other license (e.g. vxi11.x, which is covered by its own open source
+license) are covered by this license.
+
+These programs are free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+These programs are distributed in the hope that they will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+The author's email address is steve.no.spam.sharples@nottingham.ac.uk
+(you can work it out!)
Index: sipmscan/trunk/include/vxi11_x86_64/vxi11.x
===================================================================
--- sipmscan/trunk/include/vxi11_x86_64/vxi11.x (nonexistent)
+++ sipmscan/trunk/include/vxi11_x86_64/vxi11.x (revision 146)
@@ -0,0 +1,317 @@
+/* This file, vxi11.x, is the amalgamation of vxi11core.rpcl and vxi11intr.rpcl
+ * which are part of the asynDriver (R4-5) EPICS module, which, at time of
+ * writing, is available from:
+ * http://www.aps.anl.gov/epics/modules/soft/asyn/index.html
+ * More general information about EPICS is available from:
+ * http://www.aps.anl.gov/epics/
+ * This code is open source, and is covered under the copyright notice and
+ * software license agreement shown below, and also at:
+ * http://www.aps.anl.gov/epics/license/open.php
+ *
+ * In order to comply with section 4.3 of the software license agreement, here
+ * is a PROMINENT NOTICE OF CHNAGES TO THE SOFTWARE
+ * ===========================================
+ * (1) This file, vxi11.x, is the concatenation of the files vxi11core.rpcl and
+ * vxi11intr.rpcl
+ * (2) Tab spacing has been tidied up
+ *
+ * It is intended as a lightweight base for the vxi11 rpc protocol. If you
+ * run rpcgen on this file, it will generate C files and headers, from which
+ * it is relatively simple to write C programs to communicate with a range
+ * of ethernet-enabled instruments, such as oscilloscopes and function
+ * generated by manufacturers such as Agilent and Tektronix (amongst many
+ * others).
+ *
+ * For what it's worth, this concatenation was done by Steve Sharples at
+ * the University of Nottingham, UK, on 1 June 2006.
+ *
+ * Copyright notice and software license agreement follow, then the
+ * original comments from vxi11core.rpcl etc.
+ *
+ ******************************************************************************
+ * Copyright © 2006 <University of Chicago and other copyright holders>. All
+ * rights reserved.
+ ******************************************************************************
+ *
+ ******************************************************************************
+ * vxi11.x is distributed subject to the following license conditions:
+ * SOFTWARE LICENSE AGREEMENT
+ * Software: vxi11.x
+ *
+ * 1. The "Software", below, refers to vxi11.x (in either source code, or
+ * binary form and accompanying documentation). Each licensee is addressed
+ * as "you" or "Licensee."
+ *
+ * 2. The copyright holders shown above and their third-party licensors hereby
+ * grant Licensee a royalty-free nonexclusive license, subject to the
+ * limitations stated herein and U.S. Government license rights.
+ *
+ * 3. You may modify and make a copy or copies of the Software for use within
+ * your organization, if you meet the following conditions:
+ * 1. Copies in source code must include the copyright notice and this
+ * Software License Agreement.
+ * 2. Copies in binary form must include the copyright notice and this
+ * Software License Agreement in the documentation and/or other
+ * materials provided with the copy.
+ *
+ * 4. You may modify a copy or copies of the Software or any portion of it,
+ * thus forming a work based on the Software, and distribute copies of such
+ * work outside your organization, if you meet all of the following
+ * conditions:
+ * 1. Copies in source code must include the copyright notice and this
+ * Software License Agreement;
+ * 2. Copies in binary form must include the copyright notice and this
+ * Software License Agreement in the documentation and/or other
+ * materials provided with the copy;
+ * 3. Modified copies and works based on the Software must carry
+ * prominent notices stating that you changed specified portions of
+ * the Software.
+ *
+ * 5. Portions of the Software resulted from work developed under a U.S.
+ * Government contract and are subject to the following license: the
+ * Government is granted for itself and others acting on its behalf a
+ * paid-up, nonexclusive, irrevocable worldwide license in this computer
+ * software to reproduce, prepare derivative works, and perform publicly
+ * and display publicly.
+ *
+ * 6. WARRANTY DISCLAIMER. THE SOFTWARE IS SUPPLIED "AS IS" WITHOUT WARRANTY OF
+ * ANY KIND. THE COPYRIGHT HOLDERS, THEIR THIRD PARTY LICENSORS, THE UNITED
+ * STATES, THE UNITED STATES DEPARTMENT OF ENERGY, AND THEIR EMPLOYEES: (1)
+ * DISCLAIM ANY WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
+ * ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ * PURPOSE, TITLE OR NON-INFRINGEMENT, (2) DO NOT ASSUME ANY LEGAL LIABILITY
+ * OR RESPONSIBILITY FOR THE ACCURACY, COMPLETENESS, OR USEFULNESS OF THE
+ * SOFTWARE, (3) DO NOT REPRESENT THAT USE OF THE SOFTWARE WOULD NOT INFRINGE
+ * PRIVATELY OWNED RIGHTS, (4) DO NOT WARRANT THAT THE SOFTWARE WILL FUNCTION
+ * UNINTERRUPTED, THAT IT IS ERROR-FREE OR THAT ANY ERRORS WILL BE CORRECTED.
+ *
+ * 7. LIMITATION OF LIABILITY. IN NO EVENT WILL THE COPYRIGHT HOLDERS, THEIR
+ * THIRD PARTY LICENSORS, THE UNITED STATES, THE UNITED STATES DEPARTMENT OF
+ * ENERGY, OR THEIR EMPLOYEES: BE LIABLE FOR ANY INDIRECT, INCIDENTAL,
+ * CONSEQUENTIAL, SPECIAL OR PUNITIVE DAMAGES OF ANY KIND OR NATURE,
+ * INCLUDING BUT NOT LIMITED TO LOSS OF PROFITS OR LOSS OF DATA, FOR ANY
+ * REASON WHATSOEVER, WHETHER SUCH LIABILITY IS ASSERTED ON THE BASIS OF
+ * CONTRACT, TORT (INCLUDING NEGLIGENCE OR STRICT LIABILITY), OR OTHERWISE,
+ * EVEN IF ANY OF SAID PARTIES HAS BEEN WARNED OF THE POSSIBILITY OF SUCH
+ * LOSS OR DAMAGES.
+ ******************************************************************************
+ */
+
+/******************************************************************************
+ *
+ * vxi11core.rpcl
+ *
+ * This file is best viewed with a tabwidth of 4
+ *
+ ******************************************************************************
+ *
+ * TODO:
+ *
+ ******************************************************************************
+ *
+ * Original Author: someone from VXIbus Consortium
+ * Current Author: Benjamin Franksen
+ * Date: 03-06-97
+ *
+ * RPCL description of the core- and abort-channel of the TCP/IP Instrument
+ * Protocol Specification.
+ *
+ *
+ * Modification Log:
+ * -----------------
+ * .00 03-06-97 bfr created this file
+ *
+ ******************************************************************************
+ *
+ * Notes:
+ *
+ * This stuff is literally from
+ *
+ * VXI-11, Ref 1.0 : TCP/IP Instrument Protocol Specification
+ *
+ */
+
+typedef long Device_Link;
+
+enum Device_AddrFamily
+{
+ DEVICE_TCP,
+ DEVICE_UDP
+};
+
+typedef long Device_Flags;
+
+typedef long Device_ErrorCode;
+
+struct Device_Error
+{
+ Device_ErrorCode error;
+};
+
+struct Create_LinkParms
+{
+ long clientId; /* implementation specific value */
+ bool lockDevice; /* attempt to lock the device */
+ unsigned long lock_timeout; /* time to wait for lock */
+ string device<>; /* name of device */
+};
+struct Create_LinkResp
+{
+ Device_ErrorCode error;
+ Device_Link lid;
+ unsigned short abortPort; /* for the abort RPC */
+ unsigned long maxRecvSize; /* max # of bytes accepted on write */
+};
+struct Device_WriteParms
+{
+ Device_Link lid; /* link id from create_link */
+ unsigned long io_timeout; /* time to wait for I/O */
+ unsigned long lock_timeout; /* time to wait for lock */
+ Device_Flags flags; /* flags with options */
+ opaque data<>; /* the data length and the data itself */
+};
+struct Device_WriteResp
+{
+ Device_ErrorCode error;
+ unsigned long size; /* # of bytes written */
+};
+struct Device_ReadParms
+{
+ Device_Link lid; /* link id from create_link */
+ unsigned long requestSize; /* # of bytes requested */
+ unsigned long io_timeout; /* time to wait for I/O */
+ unsigned long lock_timeout; /* time to wait for lock */
+ Device_Flags flags; /* flags with options */
+ char termChar; /* valid if flags & termchrset */
+};
+struct Device_ReadResp
+{
+ Device_ErrorCode error;
+ long reason; /* why read completed */
+ opaque data<>; /* the data length and the data itself */
+};
+struct Device_ReadStbResp
+{
+ Device_ErrorCode error;
+ unsigned char stb; /* the returned status byte */
+};
+struct Device_GenericParms
+{
+ Device_Link lid; /* link id from create_link */
+ Device_Flags flags; /* flags with options */
+ unsigned long lock_timeout; /* time to wait for lock */
+ unsigned long io_timeout; /* time to wait for I/O */
+};
+struct Device_RemoteFunc
+{
+ unsigned long hostAddr; /* host servicing interrupt */
+ unsigned long hostPort; /* valid port # on client */
+ unsigned long progNum; /* DEVICE_INTR */
+ unsigned long progVers; /* DEVICE_INTR_VERSION */
+ Device_AddrFamily progFamily; /* DEVICE_UDP | DEVICE_TCP */
+};
+struct Device_EnableSrqParms
+{
+ Device_Link lid; /* link id from create_link */
+ bool enable; /* enable or disable intr's */
+ opaque handle<40>; /* host specific data */
+};
+struct Device_LockParms
+{
+ Device_Link lid; /* link id from create_link */
+ Device_Flags flags; /* contains the waitlock flag */
+ unsigned long lock_timeout; /* time to wait for lock */
+};
+struct Device_DocmdParms
+{
+ Device_Link lid; /* link id from create_link */
+ Device_Flags flags; /* flags with options */
+ unsigned long io_timeout; /* time to wait for I/O */
+ unsigned long lock_timeout; /* time to wait for lock */
+ long cmd; /* which command to execute */
+ bool network_order; /* client's byte order */
+ long datasize; /* size of individual data elements */
+ opaque data_in<>; /* docmd data parameters */
+};
+struct Device_DocmdResp
+{
+ Device_ErrorCode error;
+ opaque data_out<>; /* returned data parameters */
+};
+
+program DEVICE_ASYNC
+{
+ version DEVICE_ASYNC_VERSION
+ {
+ Device_Error device_abort (Device_Link) = 1;
+ } = 1;
+} = 0x0607B0;
+
+program DEVICE_CORE
+{
+ version DEVICE_CORE_VERSION
+ {
+ Create_LinkResp create_link (Create_LinkParms) = 10;
+ Device_WriteResp device_write (Device_WriteParms) = 11;
+ Device_ReadResp device_read (Device_ReadParms) = 12;
+ Device_ReadStbResp device_readstb (Device_GenericParms) = 13;
+ Device_Error device_trigger (Device_GenericParms) = 14;
+ Device_Error device_clear (Device_GenericParms) = 15;
+ Device_Error device_remote (Device_GenericParms) = 16;
+ Device_Error device_local (Device_GenericParms) = 17;
+ Device_Error device_lock (Device_LockParms) = 18;
+ Device_Error device_unlock (Device_Link) = 19;
+ Device_Error device_enable_srq (Device_EnableSrqParms) = 20;
+ Device_DocmdResp device_docmd (Device_DocmdParms) = 22;
+ Device_Error destroy_link (Device_Link) = 23;
+ Device_Error create_intr_chan (Device_RemoteFunc) = 25;
+ Device_Error destroy_intr_chan (void) = 26;
+ } = 1;
+} = 0x0607AF;
+
+/******************************************************************************
+ *
+ * vxi11intr.rpcl
+ *
+ * This file is best viewed with a tabwidth of 4
+ *
+ ******************************************************************************
+ *
+ * TODO:
+ *
+ ******************************************************************************
+ *
+ * Original Author: someone from VXIbus Consortium
+ * Current Author: Benjamin Franksen
+ * Date: 03-06-97
+ *
+ * RPCL description of the intr-channel of the TCP/IP Instrument Protocol
+ * Specification.
+ *
+ *
+ * Modification Log:
+ * -----------------
+ * .00 03-06-97 bfr created this file
+ *
+ ******************************************************************************
+ *
+ * Notes:
+ *
+ * This stuff is literally from
+ *
+ * "VXI-11, Ref 1.0 : TCP/IP Instrument Protocol Specification"
+ *
+ */
+
+struct Device_SrqParms
+{
+ opaque handle<>;
+};
+
+program DEVICE_INTR
+{
+ version DEVICE_INTR_VERSION
+ {
+ void device_intr_srq (Device_SrqParms) = 30;
+ } = 1;
+} = 0x0607B1;
Index: sipmscan/trunk/include/vxi11_x86_64/vxi11_cmd.cc
===================================================================
--- sipmscan/trunk/include/vxi11_x86_64/vxi11_cmd.cc (nonexistent)
+++ sipmscan/trunk/include/vxi11_x86_64/vxi11_cmd.cc (revision 146)
@@ -0,0 +1,83 @@
+/* vxi11_cmd.c
+ * Copyright (C) 2006 Steve D. Sharples
+ *
+ * A simple interactive utility that allows you to send commands and queries to
+ * a device enabled with the VXI11 RPC ethernet protocol. Uses the files
+ * generated by rpcgen vxi11.x, and the vxi11_user.h user libraries.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The author's email address is steve.sharples@nottingham.ac.uk
+ */
+
+#include "vxi11_user.h"
+#define BUF_LEN 100000
+
+int main(int argc, char *argv[]) {
+
+static char *device_ip;
+static char *device_name;
+char cmd[256];
+char buf[BUF_LEN];
+int ret;
+long bytes_returned;
+CLINK *clink;
+
+ clink = new CLINK;
+
+ if (argc < 2) {
+ printf("usage: %s your.inst.ip.addr [device_name]\n",argv[0]);
+ exit(1);
+ }
+
+ device_ip = argv[1];
+ if (argc > 2) {
+ device_name = argv[2];
+ ret=vxi11_open_device(device_ip,clink,device_name);
+ }
+ else {
+ ret=vxi11_open_device(device_ip,clink);
+ }
+
+ if (ret != 0) {
+ printf("Error: could not open device %s, quitting\n",device_ip);
+ exit(2);
+ }
+
+ while(1){
+ memset(cmd, 0, 256); // initialize command string
+ memset(buf, 0, BUF_LEN); // initialize buffer
+ printf("Input command or query ('q' to exit): ");
+ fgets(cmd,256,stdin);
+ cmd[strlen(cmd)-1] = 0; // just gets rid of the \n
+ if (strncasecmp(cmd, "q",1) == 0) break;
+
+ if (vxi11_send(clink, cmd) < 0) break;
+ if (strstr(cmd, "?") != 0) {
+ bytes_returned = vxi11_receive(clink, buf, BUF_LEN);
+ if (bytes_returned > 0) {
+ printf("%s\n",buf);
+ }
+ else if (bytes_returned == -15) {
+ printf("*** [ NOTHING RECEIVED ] ***\n");
+ }
+ else break;
+ }
+ }
+
+ ret=vxi11_close_device(device_ip,clink);
+ return 0;
+ }
+
Index: sipmscan/trunk/include/vxi11_x86_64/vxi11_user.cc
===================================================================
--- sipmscan/trunk/include/vxi11_x86_64/vxi11_user.cc (nonexistent)
+++ sipmscan/trunk/include/vxi11_x86_64/vxi11_user.cc (revision 146)
@@ -0,0 +1,589 @@
+/* vxi11_user.cc
+ * Copyright (C) 2006 Steve D. Sharples
+ *
+ * User library for opening, closing, sending to and receiving from
+ * a device enabled with the VXI11 RPC ethernet protocol. Uses the files
+ * generated by rpcgen vxi11.x.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The author's email address is steve.sharples@nottingham.ac.uk
+ */
+
+#include "vxi11_user.h"
+
+/*****************************************************************************
+ * GENERAL NOTES
+ *****************************************************************************
+ *
+ * There are four functions at the heart of this library:
+ *
+ * int vxi11_open_device(char *ip, CLIENT **client, VXI11_LINK **link)
+ * int vxi11_close_device(char *ip, CLIENT *client, VXI11_LINK *link)
+ * int vxi11_send(CLIENT *client, VXI11_LINK *link, char *cmd, unsigned long len)
+ * long vxi11_receive(CLIENT *client, VXI11_LINK *link, char *buffer, unsigned long len, unsigned long timeout)
+ *
+ * Note that all 4 of these use separate client and link structures. All the
+ * other functions are built on these four core functions, and the first layer
+ * of abstraction is to combine the CLIENT and VXI11_LINK structures into a
+ * single entity, which I've called a CLINK. For the send and receive
+ * functions, this is just a simple wrapper. For the open and close functions
+ * it's a bit more complicated, because we somehow have to keep track of
+ * whether we've already opened a device with the same IP address before (in
+ * which case we need to recycle a previously created client), or whether
+ * we've still got any other links to a given IP address left when we are
+ * asked to close a clink (in which case we can sever the link, but have to
+ * keep the client open). This is so the person using this library from
+ * userland does not have to keep track of whether they are talking to a
+ * different physical instrument or not each time they establish a connection.
+ *
+ * So the base functions that the user will probably want to use are:
+ *
+ * int vxi11_open_device(char *ip, CLINK *clink)
+ * int vxi11_close_device(char *ip, CLINK *clink)
+ * int vxi11_send(CLINK *clink, char *cmd, unsigned long len)
+ * --- or --- (if sending just text)
+ * int vxi11_send(CLINK *clink, char *cmd)
+ * long vxi11_receive(CLINK *clink, char *buffer, unsigned long len, unsigned long timeout)
+ *
+ * There are then useful (to me, anyway) more specific functions built on top
+ * of these:
+ *
+ * int vxi11_send_data_block(CLINK *clink, char *cmd, char *buffer, unsigned long len)
+ * long vxi11_receive_data_block(CLINK *clink, char *buffer, unsigned long len, unsigned long timeout)
+ * long vxi11_send_and_receive(CLINK *clink, char *cmd, char *buf, unsigned long buf_len, unsigned long timeout)
+ * long vxi11_obtain_long_value(CLINK *clink, char *cmd, unsigned long timeout)
+ * double vxi11_obtain_double_value(CLINK *clink, char *cmd, unsigned long timeout)
+ *
+ * (then there are some shorthand wrappers for the above without specifying
+ * the timeout due to sheer laziness---explore yourself)
+ */
+
+
+/* Global variables. Keep track of multiple links per client. We need this
+ * because:
+ * - we'd like the library to be able to cope with multiple links to a given
+ * client AND multiple links to multiple clients
+ * - we'd like to just refer to a client/link ("clink") as a single
+ * entity from user land, we don't want to worry about different
+ * initialisation procedures, depending on whether it's an instrument
+ * with the same IP address or not
+ */
+char VXI11_IP_ADDRESS[VXI11_MAX_CLIENTS][20];
+CLIENT *VXI11_CLIENT_ADDRESS[VXI11_MAX_CLIENTS];
+int VXI11_DEVICE_NO = 0;
+int VXI11_LINK_COUNT[VXI11_MAX_CLIENTS];
+
+/*****************************************************************************
+ * KEY USER FUNCTIONS - USE THESE FROM YOUR PROGRAMS OR INSTRUMENT LIBRARIES *
+ *****************************************************************************/
+
+/* OPEN FUNCTIONS *
+ * ============== */
+
+/* Use this function from user land to open a device and create a link. Can be
+ * used multiple times for the same device (the library will keep track).*/
+int vxi11_open_device(const char *ip, CLINK *clink, char *device) {
+int ret;
+int l;
+int device_no=-1;
+
+// printf("before doing anything, clink->link = %ld\n", clink->link);
+ /* Have a look to see if we've already initialised an instrument with
+ * this IP address */
+ for (l=0; l<VXI11_MAX_CLIENTS; l++){
+ if (strcmp(ip,VXI11_IP_ADDRESS[l]) == 0 ) {
+ device_no=l;
+// printf("Open function, search, found ip address %s, device no %d\n",ip,device_no);
+ }
+ }
+
+ /* Couldn't find a match, must be a new IP address */
+ if (device_no < 0) {
+ /* Uh-oh, we're out of storage space. Increase the #define
+ * for VXI11_MAX_CLIENTS in vxi11_user.h */
+ if (VXI11_DEVICE_NO >= VXI11_MAX_CLIENTS) {
+ printf("Error: maximum of %d clients allowed\n",VXI11_MAX_CLIENTS);
+ ret = -VXI11_MAX_CLIENTS;
+ }
+ /* Create a new client, keep a note of where the client pointer
+ * is, for this IP address. Because it's a new client, this
+ * must be link number 1. Keep track of how many devices we've
+ * opened so we don't run out of storage space. */
+ else {
+ ret = vxi11_open_device(ip, &(clink->client), &(clink->link), device);
+ strncpy(VXI11_IP_ADDRESS[VXI11_DEVICE_NO],ip,20);
+ VXI11_CLIENT_ADDRESS[VXI11_DEVICE_NO] = clink->client;
+ VXI11_LINK_COUNT[VXI11_DEVICE_NO]=1;
+// printf("Open function, could not find ip address %s.\n",ip);
+// printf("So now, VXI11_IP_ADDRESS[%d]=%s,\n",VXI11_DEVICE_NO,VXI11_IP_ADDRESS[VXI11_DEVICE_NO]);
+// printf("VXI11_CLIENT_ADDRESS[%d]=%ld,\n",VXI11_DEVICE_NO,VXI11_CLIENT_ADDRESS[VXI11_DEVICE_NO]);
+// printf(" clink->client=%ld,\n",clink->client);
+// printf("VXI11_LINK_COUNT[%d]=%d.\n",VXI11_DEVICE_NO,VXI11_LINK_COUNT[VXI11_DEVICE_NO]);
+ VXI11_DEVICE_NO++;
+ }
+ }
+ /* already got a client for this IP address */
+ else {
+ /* Copy the client pointer address. Just establish a new link
+ * (not a new client). Add one to the link count */
+ clink->client = VXI11_CLIENT_ADDRESS[device_no];
+ ret = vxi11_open_link(ip, &(clink->client), &(clink->link), device);
+// printf("Found an ip address, copying client from VXI11_CLIENT_ADDRESS[%d]\n",device_no);
+ VXI11_LINK_COUNT[device_no]++;
+// printf("Have just incremented VXI11_LINK_COUNT[%d], it's now %d\n",device_no,VXI11_LINK_COUNT[device_no]);
+ }
+// printf("after creating link, clink->link = %ld\n", clink->link);
+ return ret;
+ }
+
+/* This is a wrapper function, used for the situations where there is only one
+ * "device" per client. This is the case for most (if not all) VXI11
+ * instruments; however, it is _not_ the case for devices such as LAN to GPIB
+ * gateways. These are single clients that communicate to many instruments
+ * (devices). In order to differentiate between them, we need to pass a device
+ * name. This gets used in the vxi11_open_link() fn, as the link_parms.device
+ * value. */
+int vxi11_open_device(const char *ip, CLINK *clink) {
+ char device[6];
+ strncpy(device,"inst0",6);
+ return vxi11_open_device(ip, clink, device);
+ }
+
+
+
+/* CLOSE FUNCTION *
+ * ============== */
+
+/* Use this function from user land to close a device and/or sever a link. Can
+ * be used multiple times for the same device (the library will keep track).*/
+int vxi11_close_device(const char *ip, CLINK *clink) {
+int l,ret;
+int device_no = -1;
+
+ /* Which instrument are we referring to? */
+ for (l=0; l<VXI11_MAX_CLIENTS; l++){
+ if (strcmp(ip,VXI11_IP_ADDRESS[l]) == 0 ) {
+ device_no=l;
+ }
+ }
+ /* Something's up if we can't find the IP address! */
+ if (device_no == -1) {
+ printf("vxi11_close_device: error: I have no record of you ever opening device\n");
+ printf(" with IP address %s\n",ip);
+ ret = -4;
+ }
+ else { /* Found the IP, there's more than one link to that instrument,
+ * so keep track and just close the link */
+ if (VXI11_LINK_COUNT[device_no] > 1 ) {
+ ret = vxi11_close_link(ip,clink->client, clink->link);
+ VXI11_LINK_COUNT[device_no]--;
+ }
+ /* Found the IP, it's the last link, so close the device (link
+ * AND client) */
+ else {
+ ret = vxi11_close_device(ip, clink->client, clink->link);
+ /* Remove the IP address, so that if we re-open the same device
+ * we do it properly */
+ memset(VXI11_IP_ADDRESS[device_no], 0, 20);
+ }
+ }
+ return ret;
+ }
+
+
+/* SEND FUNCTIONS *
+ * ============== */
+
+/* A _lot_ of the time we are sending text strings, and can safely rely on
+ * strlen(cmd). */
+int vxi11_send(CLINK *clink, const char *cmd) {
+ return vxi11_send(clink, cmd, strlen(cmd));
+ }
+
+/* We still need the version of the function where the length is set explicitly
+ * though, for when we are sending fixed length data blocks. */
+int vxi11_send(CLINK *clink, const char *cmd, unsigned long len) {
+ return vxi11_send(clink->client, clink->link, cmd, len);
+ }
+
+
+/* RECEIVE FUNCTIONS *
+ * ================= */
+
+/* Lazy wrapper for when I can't be bothered to specify a read timeout */
+long vxi11_receive(CLINK *clink, char *buffer, unsigned long len) {
+ return vxi11_receive(clink, buffer, len, VXI11_READ_TIMEOUT);
+ }
+
+long vxi11_receive(CLINK *clink, char *buffer, unsigned long len, unsigned long timeout) {
+ return vxi11_receive(clink->client, clink->link, buffer, len, timeout);
+ }
+
+
+
+/*****************************************************************************
+ * USEFUL ADDITIONAL HIGHER LEVER USER FUNCTIONS - USE THESE FROM YOUR *
+ * PROGRAMS OR INSTRUMENT LIBRARIES *
+ *****************************************************************************/
+
+/* SEND FIXED LENGTH DATA BLOCK FUNCTION *
+ * ===================================== */
+int vxi11_send_data_block(CLINK *clink, const char *cmd, char *buffer, unsigned long len) {
+char *out_buffer;
+int cmd_len=strlen(cmd);
+int ret;
+
+ out_buffer=new char[cmd_len+10+len];
+ sprintf(out_buffer,"%s#8%08lu",cmd,len);
+ memcpy(out_buffer+cmd_len+10,buffer,(unsigned long) len);
+ ret = vxi11_send(clink, out_buffer, (unsigned long) (cmd_len+10+len));
+ delete[] out_buffer;
+ return ret;
+ }
+
+
+/* RECEIVE FIXED LENGTH DATA BLOCK FUNCTION *
+ * ======================================== */
+
+/* This function reads a response in the form of a definite-length block, such
+ * as when you ask for waveform data. The data is returned in the following
+ * format:
+ * #800001000<1000 bytes of data>
+ * ||\______/
+ * || |
+ * || \---- number of bytes of data
+ * |\--------- number of digits that follow (in this case 8, with leading 0's)
+ * \---------- always starts with #
+ */
+long vxi11_receive_data_block(CLINK *clink, char *buffer, unsigned long len, unsigned long timeout) {
+/* I'm not sure what the maximum length of this header is, I'll assume it's
+ * 11 (#9 + 9 digits) */
+unsigned long necessary_buffer_size;
+char *in_buffer;
+int ret;
+int ndigits;
+unsigned long returned_bytes;
+int l;
+char scan_cmd[20];
+ necessary_buffer_size=len+12;
+ in_buffer=new char[necessary_buffer_size];
+ ret=vxi11_receive(clink, in_buffer, necessary_buffer_size, timeout);
+ if (ret < 0) return ret;
+ if (in_buffer[0] != '#') {
+ printf("vxi11_user: data block error: data block does not begin with '#'\n");
+ printf("First 20 characters received were: '");
+ for(l=0;l<20;l++) {
+ printf("%c",in_buffer[l]);
+ }
+ printf("'\n");
+ return -3;
+ }
+
+ /* first find out how many digits */
+ sscanf(in_buffer,"#%1d",&ndigits);
+ /* some instruments, if there is a problem acquiring the data, return only "#0" */
+ if (ndigits > 0) {
+ /* now that we know, we can convert the next <ndigits> bytes into an unsigned long */
+ sprintf(scan_cmd,"#%%1d%%%dlu",ndigits);
+ sscanf(in_buffer,scan_cmd,&ndigits,&returned_bytes);
+ memcpy(buffer, in_buffer+(ndigits+2), returned_bytes);
+ delete[] in_buffer;
+ return (long) returned_bytes;
+ }
+ else return 0;
+ }
+
+
+/* SEND AND RECEIVE FUNCTION *
+ * ========================= */
+
+/* This is mainly a useful function for the overloaded vxi11_obtain_value()
+ * fn's, but is also handy and useful for user and library use */
+long vxi11_send_and_receive(CLINK *clink, const char *cmd, char *buf, unsigned long buf_len, unsigned long timeout) {
+int ret;
+long bytes_returned;
+ do {
+ ret = vxi11_send(clink, cmd);
+ if (ret != 0) {
+ if (ret != -VXI11_NULL_WRITE_RESP) {
+ printf("Error: vxi11_send_and_receive: could not send cmd.\n");
+ printf(" The function vxi11_send returned %d. ",ret);
+ return -1;
+ }
+ else printf("(Info: VXI11_NULL_WRITE_RESP in vxi11_send_and_receive, resending query)\n");
+ }
+
+ bytes_returned = vxi11_receive(clink, buf, buf_len, timeout);
+ if (bytes_returned <= 0) {
+ if (bytes_returned >-VXI11_NULL_READ_RESP) {
+ printf("Error: vxi11_send_and_receive: problem reading reply.\n");
+ printf(" The function vxi11_receive returned %ld. ",bytes_returned);
+ return -2;
+ }
+ else printf("(Info: VXI11_NULL_READ_RESP in vxi11_send_and_receive, resending query)\n");
+ }
+ } while (bytes_returned == -VXI11_NULL_READ_RESP || ret == -VXI11_NULL_WRITE_RESP);
+ return 0;
+ }
+
+
+/* FUNCTIONS TO RETURN A LONG INTEGER VALUE SENT AS RESPONSE TO A QUERY *
+ * ==================================================================== */
+long vxi11_obtain_long_value(CLINK *clink, const char *cmd, unsigned long timeout) {
+char buf[50]; /* 50=arbitrary length... more than enough for one number in ascii */
+ memset(buf, 0, 50);
+ if (vxi11_send_and_receive(clink, cmd, buf, 50, timeout) != 0) {
+ printf("Returning 0\n");
+ return 0;
+ }
+ return strtol(buf, (char **)NULL, 10);
+ }
+
+/* Lazy wrapper function with default read timeout */
+long vxi11_obtain_long_value(CLINK *clink, const char *cmd) {
+ return vxi11_obtain_long_value(clink, cmd, VXI11_READ_TIMEOUT);
+ }
+
+
+/* FUNCTIONS TO RETURN A DOUBLE FLOAT VALUE SENT AS RESPONSE TO A QUERY *
+ * ==================================================================== */
+double vxi11_obtain_double_value(CLINK *clink, const char *cmd, unsigned long timeout) {
+char buf[50]; /* 50=arbitrary length... more than enough for one number in ascii */
+double val;
+ memset(buf, 0, 50);
+ if (vxi11_send_and_receive(clink, cmd, buf, 50, timeout) != 0) {
+ printf("Returning 0.0\n");
+ return 0.0;
+ }
+ val = strtod(buf, (char **)NULL);
+ return val;
+ }
+
+/* Lazy wrapper function with default read timeout */
+double vxi11_obtain_double_value(CLINK *clink, const char *cmd) {
+ return vxi11_obtain_double_value(clink, cmd, VXI11_READ_TIMEOUT);
+ }
+
+
+/*****************************************************************************
+ * CORE FUNCTIONS - YOU SHOULDN'T NEED TO USE THESE FROM YOUR PROGRAMS OR *
+ * INSTRUMENT LIBRARIES *
+ *****************************************************************************/
+
+/* OPEN FUNCTIONS *
+ * ============== */
+int vxi11_open_device(const char *ip, CLIENT **client, VXI11_LINK **link, char *device) {
+
+ *client = clnt_create(ip, DEVICE_CORE, DEVICE_CORE_VERSION, "tcp");
+
+ if (*client == NULL) {
+ clnt_pcreateerror(ip);
+ return -1;
+ }
+
+ return vxi11_open_link(ip, client, link, device);
+ }
+
+int vxi11_open_link(const char *ip, CLIENT **client, VXI11_LINK **link, char *device) {
+
+Create_LinkParms link_parms;
+
+ /* Set link parameters */
+ link_parms.clientId = (long) *client;
+ link_parms.lockDevice = 0;
+ link_parms.lock_timeout = VXI11_DEFAULT_TIMEOUT;
+ link_parms.device = device;
+
+ *link = (Create_LinkResp *) calloc(1, sizeof(Create_LinkResp));
+
+ if (create_link_1(&link_parms, *link, *client) != RPC_SUCCESS) {
+ clnt_perror(*client, ip);
+ return -2;
+ }
+ return 0;
+ }
+
+
+/* CLOSE FUNCTIONS *
+ * =============== */
+int vxi11_close_device(const char *ip, CLIENT *client, VXI11_LINK *link) {
+int ret;
+
+ ret = vxi11_close_link(ip, client, link);
+
+ clnt_destroy(client);
+
+ return ret;
+ }
+
+int vxi11_close_link(const char *ip, CLIENT *client, VXI11_LINK *link) {
+Device_Error dev_error;
+ memset(&dev_error, 0, sizeof(dev_error));
+
+ if (destroy_link_1(&link->lid, &dev_error, client) != RPC_SUCCESS) {
+ clnt_perror(client,ip);
+ return -1;
+ }
+
+ return 0;
+ }
+
+
+/* SEND FUNCTIONS *
+ * ============== */
+
+/* A _lot_ of the time we are sending text strings, and can safely rely on
+ * strlen(cmd). */
+int vxi11_send(CLIENT *client, VXI11_LINK *link, const char *cmd) {
+ return vxi11_send(client, link, cmd, strlen(cmd));
+ }
+
+/* We still need the version of the function where the length is set explicitly
+ * though, for when we are sending fixed length data blocks. */
+int vxi11_send(CLIENT *client, VXI11_LINK *link, const char *cmd, unsigned long len) {
+Device_WriteParms write_parms;
+unsigned int bytes_left = len;
+char *send_cmd;
+
+ send_cmd = new char[len];
+ memcpy(send_cmd, cmd, len);
+
+ write_parms.lid = link->lid;
+ write_parms.io_timeout = VXI11_DEFAULT_TIMEOUT;
+ write_parms.lock_timeout = VXI11_DEFAULT_TIMEOUT;
+
+/* We can only write (link->maxRecvSize) bytes at a time, so we sit in a loop,
+ * writing a chunk at a time, until we're done. */
+
+ do {
+ Device_WriteResp write_resp;
+ memset(&write_resp, 0, sizeof(write_resp));
+
+ if (bytes_left <= link->maxRecvSize) {
+ write_parms.flags = 8;
+ write_parms.data.data_len = bytes_left;
+ }
+ else {
+ write_parms.flags = 0;
+ /* We need to check that maxRecvSize is a sane value (ie >0). Believe it
+ * or not, on some versions of Agilent Infiniium scope firmware the scope
+ * returned "0", which breaks Rule B.6.3 of the VXI-11 protocol. Nevertheless
+ * we need to catch this, otherwise the program just hangs. */
+ if (link->maxRecvSize > 0) {
+ write_parms.data.data_len = link->maxRecvSize;
+ }
+ else {
+ write_parms.data.data_len = 4096; /* pretty much anything should be able to cope with 4kB */
+ }
+ }
+ write_parms.data.data_val = send_cmd + (len - bytes_left);
+
+ if(device_write_1(&write_parms, &write_resp, client) != RPC_SUCCESS) {
+ delete[] send_cmd;
+ return -VXI11_NULL_WRITE_RESP; /* The instrument did not acknowledge the write, just completely
+ dropped it. There was no vxi11 comms error as such, the
+ instrument is just being rude. Usually occurs when the instrument
+ is busy. If we don't check this first, then the following
+ line causes a seg fault */
+ }
+ if (write_resp.error != 0) {
+ printf("vxi11_user: write error: %d\n", (int)write_resp.error);
+ delete[] send_cmd;
+ return -(write_resp.error);
+ }
+ bytes_left -= write_resp.size;
+ } while (bytes_left > 0);
+
+ delete[] send_cmd;
+ return 0;
+ }
+
+
+/* RECEIVE FUNCTIONS *
+ * ================= */
+
+// It appeared that this function wasn't correctly dealing with more data available than specified in len.
+// This patch attempts to fix this issue. RDP 2007/8/13
+
+/* wrapper, for default timeout */ long vxi11_receive(CLIENT *client, VXI11_LINK *link, char *buffer, unsigned long len) { return vxi11_receive(client, link, buffer, len, VXI11_READ_TIMEOUT);
+ }
+
+#define RCV_END_BIT 0x04 // An end indicator has been read
+#define RCV_CHR_BIT 0x02 // A termchr is set in flags and a character which matches termChar is transferred
+#define RCV_REQCNT_BIT 0x01 // requestSize bytes have been transferred. This includes a request size of zero.
+
+long vxi11_receive(CLIENT *client, VXI11_LINK *link, char *buffer, unsigned long len, unsigned long timeout) {
+Device_ReadParms read_parms;
+Device_ReadResp read_resp;
+unsigned long curr_pos = 0;
+
+ read_parms.lid = link->lid;
+ read_parms.requestSize = len;
+ read_parms.io_timeout = timeout; /* in ms */
+ read_parms.lock_timeout = timeout; /* in ms */
+ read_parms.flags = 0;
+ read_parms.termChar = 0;
+
+ do {
+ memset(&read_resp, 0, sizeof(read_resp));
+
+ read_resp.data.data_val = buffer + curr_pos;
+ read_parms.requestSize = len - curr_pos; // Never request more total data than originally specified in len
+
+ if(device_read_1(&read_parms, &read_resp, client) != RPC_SUCCESS) {
+ return -VXI11_NULL_READ_RESP; /* there is nothing to read. Usually occurs after sending a query
+ which times out on the instrument. If we don't check this first,
+ then the following line causes a seg fault */
+ }
+ if (read_resp.error != 0) {
+ /* Read failed for reason specified in error code.
+ * (From published VXI-11 protocol, section B.5.2)
+ * 0 no error
+ * 1 syntax error
+ * 3 device not accessible
+ * 4 invalid link identifier
+ * 5 parameter error
+ * 6 channel not established
+ * 8 operation not supported
+ * 9 out of resources
+ * 11 device locked by another link
+ * 12 no lock held by this link
+ * 15 I/O timeout
+ * 17 I/O error
+ * 21 invalid address
+ * 23 abort
+ * 29 channel already established
+ */
+
+ printf("vxi11_user: read error: %d\n", (int)read_resp.error);
+ return -(read_resp.error);
+ }
+
+ if((curr_pos + read_resp.data.data_len) <= len) {
+ curr_pos += read_resp.data.data_len;
+ }
+ if( (read_resp.reason & RCV_END_BIT) || (read_resp.reason & RCV_CHR_BIT) ) {
+ break;
+ }
+ else if( curr_pos == len ) {
+ printf("xvi11_user: read error: buffer too small. Read %d bytes without hitting terminator.\n", (int)curr_pos );
+ return -100;
+ }
+ } while(1);
+ return (curr_pos); /*actual number of bytes received*/
+
+ }
+
Index: sipmscan/trunk/include/vxi11_x86_64/vxi11_user.h
===================================================================
--- sipmscan/trunk/include/vxi11_x86_64/vxi11_user.h (nonexistent)
+++ sipmscan/trunk/include/vxi11_x86_64/vxi11_user.h (revision 146)
@@ -0,0 +1,87 @@
+/* vxi11_user.h
+ * Copyright (C) 2006 Steve D. Sharples
+ *
+ * User library for opening, closing, sending to and receiving from
+ * a device enabled with the VXI11 RPC ethernet protocol. Uses the files
+ * generated by rpcgen vxi11.x.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The author's email address is steve.sharples@nottingham.ac.uk
+ */
+
+#ifndef __VXI11_USER__
+#define __VXI11_USER__
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <rpc/rpc.h>
+#include "vxi11.h"
+
+#define VXI11_DEFAULT_TIMEOUT 10000 /* in ms */
+#define VXI11_READ_TIMEOUT 2000 /* in ms */
+#define VXI11_CLIENT CLIENT
+#define VXI11_LINK Create_LinkResp
+#define VXI11_MAX_CLIENTS 256 /* maximum no of unique IP addresses/clients */
+#define VXI11_NULL_READ_RESP 50 /* vxi11_receive() return value if a query
+ * times out ON THE INSTRUMENT (and so we have
+ * to resend the query again) */
+#define VXI11_NULL_WRITE_RESP 51 /* vxi11_send() return value if a sent command
+ * times out ON THE INSTURMENT. */
+
+struct CLINK {
+ VXI11_CLIENT *client;
+ VXI11_LINK *link;
+ } ;
+typedef struct CLINK CLINK;
+
+/* The four main functions: open, close, send, receieve (plus a couple of wrappers) */
+/* In fact all 6 of these are wrappers to the original functions listed at the
+ * bottom, that use separate CLIENT and VXI11_LINK structures. It was easier to
+ * write wrappers for these functions than to re-write the original functions
+ * themselves. These are the 4 (or 6 if you like) key user functions that you
+ * should probably be using. They all use the CLINK structure. */
+int vxi11_open_device(const char *ip, CLINK *clink);
+int vxi11_open_device(const char *ip, CLINK *clink, char *device);
+int vxi11_close_device(const char *ip, CLINK *clink);
+int vxi11_send(CLINK *clink, const char *cmd);
+int vxi11_send(CLINK *clink, const char *cmd, unsigned long len);
+long vxi11_receive(CLINK *clink, char *buffer, unsigned long len);
+long vxi11_receive(CLINK *clink, char *buffer, unsigned long len, unsigned long timeout);
+
+/* Utility functions, that use send() and receive(). Use these too. */
+int vxi11_send_data_block(CLINK *clink, const char *cmd, char *buffer, unsigned long len);
+long vxi11_receive_data_block(CLINK *clink, char *buffer, unsigned long len, unsigned long timeout);
+long vxi11_send_and_receive(CLINK *clink, const char *cmd, char *buf, unsigned long buf_len, unsigned long timeout);
+long vxi11_obtain_long_value(CLINK *clink, const char *cmd, unsigned long timeout);
+double vxi11_obtain_double_value(CLINK *clink, const char *cmd, unsigned long timeout);
+long vxi11_obtain_long_value(CLINK *clink, const char *cmd);
+double vxi11_obtain_double_value(CLINK *link, const char *cmd);
+
+/* When I first wrote this library I used separate client and links. I've
+ * retained the original functions and just written clink wrappers for them
+ * (see above) as it's perhaps a little clearer this way. Probably not worth
+ * delving this deep in use, but it's where the real nitty gritty is. */
+int vxi11_open_device(const char *ip, CLIENT **client, VXI11_LINK **link, char *device);
+int vxi11_open_link(const char *ip, CLIENT **client, VXI11_LINK **link, char *device);
+int vxi11_close_device(const char *ip, CLIENT *client, VXI11_LINK *link);
+int vxi11_close_link(const char *ip, CLIENT *client, VXI11_LINK *link);
+int vxi11_send(CLIENT *client, VXI11_LINK *link, const char *cmd);
+int vxi11_send(CLIENT *client, VXI11_LINK *link, const char *cmd, unsigned long len);
+long vxi11_receive(CLIENT *client, VXI11_LINK *link, char *buffer, unsigned long len);
+long vxi11_receive(CLIENT *client, VXI11_LINK *link, char *buffer, unsigned long len, unsigned long timeout);
+
+#endif
Index: sipmscan/trunk/include/workstation.h
===================================================================
--- sipmscan/trunk/include/workstation.h (nonexistent)
+++ sipmscan/trunk/include/workstation.h (revision 146)
@@ -0,0 +1,33 @@
+#ifndef _workstation_h_
+#define _workstation_h_
+
+// Debug signal (0 = no debug, 1 = printout debug, 2 = structure + printout debug)
+#define DBGSIG 0
+
+// Define the working computer (O=offline, S=offline with scope, I=IJS/online) and the base directory
+#define WORKSTAT 'O'
+
+// Define if working computer is connected to IJS ethernet network (for fieldpoint)
+#define IJSNET 0
+
+#ifdef WORKSTAT
+ #define rootdir "/home/gasper/Gasper/Delo/ijs_sipm/sipmscan_standalone"
+#endif
+
+// Title colors and font
+#define FORECOLOR 0xfcfcfc
+#define BACKCOLOR 0x2e5a86
+#define FONT "-*-helvetica-bold-r-normal-*-13-*-*-*-*-*-iso8859-"
+#define HELPFONT "-*-courier-bold-r-normal-*-13-*-*-*-*-*-iso8859-"
+
+// Global variables
+#define histext ".root"
+#define histextall "*.root"
+#define tdctimeconversion 45.0909
+#define lenconversion 0.3595
+#define rotconversion (6.3281/3600.)
+#define histname "hdata"
+#define singlewait 3
+#define doublewait 2
+
+#endif
Index: sipmscan/trunk/include/wusbcc.h
===================================================================
--- sipmscan/trunk/include/wusbcc.h (nonexistent)
+++ sipmscan/trunk/include/wusbcc.h (revision 146)
@@ -0,0 +1,15 @@
+#ifndef _WUSBCC_H
+#define _WUSBCC_H
+
+#define NAF(N,A,F) 0x4000+(N)*0x200+(A)*0x20+(F)
+#define NAFS(N,A,F) (N)*0x200+(A)*0x20+(F)
+
+#define CSSA_RQX(N,A,F,DATA,Q,X) CAMAC_read(udev,(N),(A),(F),(DATA),(Q),(X))
+#define CSSA_WQX(N,A,F,DATA,Q,X) CAMAC_write(udev,(N),(A),(F),(DATA),(Q),(X))
+
+#define CCCZ CAMAC_Z(udev)
+#define CCCC CAMAC_C(udev)
+#define CSET_I CAMAC_I(udev,1)
+#define CREM_I CAMAC_I(udev,0)
+
+#endif
Index: sipmscan/trunk/include/wusbxx_dll.h
===================================================================
--- sipmscan/trunk/include/wusbxx_dll.h (nonexistent)
+++ sipmscan/trunk/include/wusbxx_dll.h (revision 146)
@@ -0,0 +1,19 @@
+#ifndef _WUSBXX_DLL_H
+#define _WUSBXX_DLL_H
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "libxxusb.h"
+#include "wusbcc.h"
+#define _VI_FUNC
+extern usb_dev_handle *udev;
+
+void _VI_FUNC WUSBXX_load (char *module_path);
+void _VI_FUNC WUSBXX_open (char *serial);
+void _VI_FUNC WUSBXX_close (void);
+int _VI_FUNC WUSBXX_CCread (int n, int a, int f, unsigned long *data);
+int _VI_FUNC WUSBXX_CCwrite (int n, int a, int f, unsigned long data);
+
+#endif
+
Index: sipmscan/trunk/input/Makefile.in
===================================================================
--- sipmscan/trunk/input/Makefile.in (nonexistent)
+++ sipmscan/trunk/input/Makefile.in (revision 146)
@@ -0,0 +1,149 @@
+# Makefile tutorial: https://www.gnu.org/software/make/manual/html_node/index.html#SEC_Contents
+
+# Make variables ----------------------------------------------------
+
+# ROOT include and libraries
+ROOTINC=$(shell root-config --incdir)
+ROOTLIB=$(shell root-config --libs)
+GRROOTLIB=$(shell root-config --cflags --glibs)
+
+# Source and debug directories
+SRC=./src
+DBG=./dbg
+IDIR=./include
+BIN=./bin
+DICT=./dict
+LDIR=./lib
+
+# Includes and libraries, 32 vs. 64 bit type, libraries
+INC=-I. -I$(ROOTINC)
+OSTYPE=none
+LIBS=$(ROOTLIB) -L. -lm
+
+# Compiler options
+COMPOPT=-fPIC -g -Wno-unused-value
+#COMPOPT=-fPIC -g -Wall
+
+# CAMAC DAQ library variables
+OBJ_FILES = $(SRC)/wusbxx_dll.o $(SRC)/libxxusb.o
+LIBFILE = $(LDIR)/libdaqusb.a
+
+# Specific variables for the main program
+TARGET=sipmscan
+#FILES=$(SRC)/sipmscan.cpp $(SRC)/substructure.cpp $(SRC)/connections.cpp $(SRC)/window_layout.cpp $(SRC)/separate_functions.cpp $(SRC)/tooltips.cpp
+DAQFILE = $(SRC)/daqusb.C
+#FILES=$(wildcard $(SRC)/*.cpp) $(SRC)/daqusb.C $(SRC)/daqscope.C
+FILES=$(shell find $(SRC)/ ! -name "libxxusb.cpp" -name "*.cpp") $(SRC)/daqusb.C $(SRC)/daqscope.C
+HEADER=$(IDIR)/daq.h $(IDIR)/workstation.h $(IDIR)/sipmscan.h $(IDIR)/root_include.h
+CAMLIB = $(LIBFILE)
+SHLIB = $(LIBFILE) $(LDIR)/libvxi11.a
+
+# VXI scope connection variables, Scope DAQ library variables
+VXIDIR = $(IDIR)/vxi11_$(OSTYPE)
+#VXI_FILES = $(VXIDIR)/vxi11_user.o $(VXIDIR)/vxi11.h $(VXIDIR)/vxi11_clnt.c $(VXIDIR)/vxi11_xdr.c
+VXI_OBJECT = $(VXIDIR)/vxi11_user.o $(VXIDIR)/vxi11_clnt.o $(VXIDIR)/vxi11_xdr.o
+
+# -------------------------------------------------------------------
+
+# Base rules --------------------------------------------------------
+
+# Make the main program and libraries
+all: libsubstr.so $(LDIR)/libdaqusb.so $(LDIR)/libvxi11.so $(TARGET)
+
+# Rules for making the main program
+$(TARGET): $(FILES) library
+ @echo "\n# Generating dictionary GuiDict.C ---------------------------"
+ rootcint -f $(DICT)/GuiDict.C -c -p $(INC) $(CPPFLAGS) $(IDIR)/sipmscan.h $(DICT)/GuiLinkDef.h
+ @echo "\n# Checking to see if bin directory already exists -----------"
+ if [ ! -d "$(BIN)" ];then mkdir $(BIN); fi
+ @echo "\n# Compiling main program ------------------------------------"
+ $(CXX) $(INC) $(COMPOPT) $(FILES) $(DICT)/GuiDict.C $(CPPFLAGS) $(VXI_OBJECT) -o $(BIN)/$(TARGET) $(SHLIB) $(GRROOTLIB) -lstdc++ -lSpectrum -L$(LDIR)/libsubstr.so -L$(LDIR)/libdaqusb.so -L$(LDIR)/libvxi11.so
+ @echo "\n# Compilation successful ------------------------------------"
+ @echo "# Use ./start.sh to run the program -------------------------"
+
+# -------------------------------------------------------------------
+
+# CAMAC DAQ library rules -----------------------------------------------------
+
+# Rules for making CAMAC DAQ library source files (wusbxx_dll and libxxusb)
+library: $(OBJ_FILES)
+
+$(OBJ_FILES): $(SRC)/wusbxx_dll.c $(IDIR)/wusbxx_dll.h $(SRC)/libxxusb.cpp $(IDIR)/libxxusb.h
+ @echo "\n# Compiling CAMAC USB source files --------------------------"
+ $(CXX) $(CPPFLAGS) $(INC) -c $(SRC)/wusbxx_dll.c -o $(SRC)/wusbxx_dll.o
+ $(CXX) $(CPPFLAGS) $(INC) -c $(SRC)/libxxusb.cpp -o $(SRC)/libxxusb.o
+
+.cc.o:
+ @echo "\n# Creating a static CAMAC USB library (libdaqusb.a) ---------"
+ $(CXX) -fPIC -c $<
+ ar r $(LIBFILE) $@
+
+.cpp.o:
+ @echo "\n# Creating a static CAMAC USB library (libdaqusb.a) ---------"
+ $(CXX) -fPIC -c $<
+ ar r $(LIBFILE) $@
+
+.c.o:
+ @echo "\n# Creating a static CAMAC USB library (libdaqusb.a) ---------"
+ $(CXX) -fPIC -c $<
+ ar r $(LIBFILE) $@
+
+# Rule for making the CAMAC DAQ library (libdaqusb.so)
+$(LDIR)/libdaqusb.so: $(LIBFILE) $(DAQFILE)
+ @echo "\n# Generating dictionary Dict.C ------------------------------"
+ rootcint -f $(DICT)/Dict.C -c $(INC) $(CPPFLAGS) $(HEADER) $(DICT)/LibLinkDef.h
+ @echo "\n# Checking to see if lib directory already exists -----------"
+ if [ ! -d "$(LDIR)" ];then mkdir $(LDIR); fi
+ @echo "\n# Compiling CAMAC DAQ library (libdaqusb.so) ----------------"
+ $(CXX) $(CPPFLAGS) $(INC) -fPIC -g -Wall $(DAQFILE) $(DICT)/Dict.C $(CAMLIB) -shared -o $@
+
+# Rule for making the CAMAC DAQ library (libdaqusb.a)
+$(LIBFILE): $(OBJ_FILES)
+ @echo "\n# Creating a static CAMAC USB library (libdaqusb.a) ---------"
+ ar r $@ $^
+# -----------------------------------------------------------------------------
+
+# Scope DAQ library rules -----------------------------------------------------
+
+$(LDIR)/libvxi11.so: $(LDIR)/libvxi11.a
+ @echo "\n# Generating dictionary VxiDict.C ---------------------------"
+ rootcint -f $(DICT)/VxiDict.C -c $(INC) $(CPPFLAGS) $(IDIR)/daqscope.h $(DICT)/LibLinkDef.h
+ @echo "\n# Checking to see if lib directory already exists -----------"
+ if [ ! -d "$(LDIR)" ];then mkdir $(LDIR); fi
+ @echo "\n# Compiling scope VXI library (libvxi11.so) -----------------"
+ $(CXX) $(CPPFLAGS) $(INC) -fPIC -g -Wall $(SRC)/daqscope.C $(DICT)/VxiDict.C -L. $(LDIR)/libvxi11.a -shared -o $@
+
+$(LDIR)/libvxi11.a: $(VXI_OBJECT)
+ ar r $@ $^
+# -----------------------------------------------------------------------------
+
+# Substructue library rules ---------------------------------------------------
+
+# Rules for making user defined libraries
+libsubstr.so: libsubstr.a
+ @echo "\n# Creating a shared testing library -------------------------"
+ rootcint -f $(DICT)/TestDict.C -c $(INC) $(CPPFLAGS) $(IDIR)/substructure.h $(DICT)/TestLinkDef.h
+ $(CXX) $(CPPFLAGS) $(INC) $(COMPOPT) $(SRC)/substructure.cpp $(DICT)/TestDict.C libsubstr.a -shared -o $@
+ @echo "\n# Checking to see if lib directory already exists -----------"
+ if [ ! -d "$(LDIR)" ];then mkdir $(LDIR); fi
+ mv $@ $^ $(LDIR)/
+
+libsubstr.a: $(SRC)/substructure.o
+ @echo "\n# Creating a static testing library -------------------------"
+ ar r $@ $^
+
+$(SRC)/substructure.o: $(SRC)/substructure.cpp $(IDIR)/substructure.h
+ @echo "\n# Compiling separate source files ---------------------------"
+ $(CXX) $(CPPFLAGS) $(INC) -c $(SRC)/substructure.cpp -o $(SRC)/substructure.o
+
+# -------------------------------------------------------------------
+
+# Cleaning rules ----------------------------------------------------
+
+# Rules for cleaning the installation
+clean:
+ @echo "# Cleaning the installation directory -------------------------"
+ rm -fr $(DICT)/*Dict.C $(DICT)/*Dict.h $(BIN) $(LDIR) start.sh *.o $(SRC)/*.o
+ rm -fr $(IDIR)/workstation.h $(SRC)/daqscope.C $(SRC)/daqusb.C $(IDIR)/usb.h $(IDIR)/libxxusb.h $(DBG)/finish_sig.txt
+
+# -------------------------------------------------------------------
Index: sipmscan/trunk/input/daqscope.C.in
===================================================================
--- sipmscan/trunk/input/daqscope.C.in (nonexistent)
+++ sipmscan/trunk/input/daqscope.C.in (revision 146)
@@ -0,0 +1,390 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "vxi11_user.h"
+#include "../include/daqscope.h"
+#include "../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)
+ {
+ vxi11_send(clink, "*IDN?");
+ vxi11_receive(clink, buf, WAVE_LEN);
+ printf("Connected to device (%s): %s\n", IPaddr, buf);
+ savedIP = IPaddr;
+ return iTemp;
+ }
+ 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;
+ }
+ 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
+ sprintf(posoff, "Just some temporary string info.");
+ 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;
+}
+
+daqscope::~daqscope() {
+ disconnect(savedIP);
+}
+// ---------------------------------------------------------------
Index: sipmscan/trunk/input/daqusb.C.offline
===================================================================
--- sipmscan/trunk/input/daqusb.C.offline (nonexistent)
+++ sipmscan/trunk/input/daqusb.C.offline (revision 146)
@@ -0,0 +1,258 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <errno.h>
+#include <signal.h>
+#include <ctype.h>
+#include <time.h>
+//#include "../include/wusbxx_dll.h" /* the header of the shared library */
+#include "../include/daq.h"
+
+//#define DEBUG /* vkljuci dodatni izpis */
+#ifdef DEBUG
+ #define DBG(X) X
+ #define DBGFUNI(X) printf(">>> %s -> %d\n",#X,(X))
+#else
+ #define DBG(X)
+ #define DBGFUNI(X) X
+#endif
+
+/* definiram lokacije enot*/
+//#define NTDC 1 /* TDC */
+//#define NTDCCH 8
+//#define NADC 2 /* ADC */
+//#define NADCCH 8
+int ctrlc=0;
+char *ccserial=(char*)"CC0126";
+int devDetect; // variable to tell if we detect any devices
+
+int daq::connect(){
+// odpri daq
+/* xxusb_device_type devices[100];
+ //struct usb_device *dev;
+ devDetect = xxusb_devices_find(devices);
+// printf("Detected devices: %d\n", devDetect);
+ //dev = devices[0].usbdev;
+ //udev = xxusb_device_open(dev);
+
+ if(devDetect > 0)
+ {
+ WUSBXX_load(NULL);
+ WUSBXX_open(ccserial);
+ printf("daq::connect()\n");
+ }
+ else
+*/ printf("daq::connect() - No devices were detected!\n");
+ return 0;
+}
+
+int daq::init(int chan = 0){
+
+// 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);
+
+ CCCZ;
+ CCCC;
+ CREM_I;
+
+ NTDC = 1;
+ NADC = 2;
+ if(chan != 0)
+ {
+ NTDCCH = chan/2;
+ NADCCH = chan/2;
+ }
+ else
+ {
+ NTDCCH = 1;
+ NADCCH = 1;
+ }
+ printf("after: NTDCCH = %d, NADCCH = %d\n", NTDCCH, NADCCH);
+
+// create command stack for the TDC and ADC
+ k=1;
+ for(i=0;(i<NTDCCH)&&(i<NADCCH);i++) { stackwrite[k++]=NAF(NTDC,i,0); stackwrite[k++]=NAF(NADC,i,0); }
+// for(i=0;i<NADCCH;i++) stackwrite[k++]=NAF(NADC,i,0);
+ stackwrite[k++]=NAF(NTDC,0,9);
+ stackwrite[k++]=NAF(NADC,0,9);
+ stackwrite[k++]=NAFS(0,0,16); // insert next word to data
+ stackwrite[k++]=0xfafb; // event termination word
+ stackwrite[0]=k-1;
+// upload stack #2
+ xxusb_stack_write(udev,0x2,(long int *)stackwrite);
+ xxusb_stack_read(udev,0x2,(long int *) stackdata);
+ DBG(for(i=0;i<k;i++) printf("0x%04x\n",stackdata[i]);)
+
+ int ret[10];
+
+ CAMAC_LED_settings(udev, 1,1,0,0);
+ ret[0] = CAMAC_register_read(udev,0,&k);
+ printf("Firmware ID (return %d) -> 0x%08lX\n",ret[0],k); // GKM: Firmware ID (i.e. 0x72000001 = 0111 0010 0000 0000 0000 0000 0000 0001)
+ ret[1] = CAMAC_register_read(udev,1,&k);
+ printf("Global Mode (return %d) -> 0x%08lX\n",ret[1],k);
+ k=(k&0xF000)|0x0005; // set buffer length: n=0..6 -> 0x10000 >> n, n=7 -> single event
+ ret[0] = CAMAC_register_write(udev,1,k); // GKM: sets the buffer length (i.e. k=5 -> buf length=128 words)
+ ret[1] = CAMAC_register_write(udev,2,0x80); // wait 0x80 us after trigger // GKM: delay settings in microseconds
+ ret[2] = CAMAC_register_write(udev,3,0x0); // Scaler Readout Control Register // GKM: scaler readout settings - sets the frequency of readout (if 0, it is disabled)
+ ret[3] = CAMAC_register_write(udev,9,0x0); // Lam Mask Register // GKM: When 0, readout is triggered by the signal on NIM input
+ ret[4] = CAMAC_register_write(udev,14,0x0); // USB Bulk Transfer Setup Register
+
+ // CAMAC_DGG(udev,1,2,3,0,200,0,0);
+ // CAMAC_DGG(udev,0,0,0,0,100,0,0);
+ ret[5] = CAMAC_register_write(udev,5,(0x06<<16)+(0x04<<8)+0x00); // output // GKM: NIM outputs (i.e. 0x060400 = 00 0110 0000 0100 0000 0000 -> NIM O2=DGG_B, NIM O3=DGG_A)
+ ret[6] = CAMAC_register_write(udev,6,(0x01<<24)+(0x01<<16)+(0x0<<8)+0x0); // SCLR & DGG // GKM: device source selector (i.e. 0x01010000 = 00 0000 0001 0000 0001 0000 0000 0000 0000 -> DGG_A=NIM I1, DGG_B=NIM I1, SCLR=disabled)
+ ret[7] = CAMAC_register_write(udev,7,(100<<16)+0); // output // GKM: Delay and Gate Generator A registers (i.e. 0x00640000 = 0000 0000 0110 0100 0000 0000 0000 0000 -> DDG_A [gate=100, delay=0])
+ ret[8] = CAMAC_register_write(udev,8,(10000<<16)+0); // output // GKM: Delay and Gate Generator B registers (i.e. 0x27100000 = 0010 0111 0001 0000 0000 0000 0000 0000 -> DDG_B [gate=10000, delay=0])
+ ret[9] = CAMAC_register_write(udev,13,0); // output // GKM: Extended (course) delay (i.e. 0x00000000 = 0 -> DDG_A ext=0, DDG_B ext=0)
+
+// for(i = 0; i < 10; i++) printf("Setting %d? -> return = %d\n",i,ret[i]);
+
+// ret[0] = CAMAC_register_read(udev,1,&k);
+// printf("k (return %d) -> 0x%08lX\n",ret[0],k);
+
+*/ printf("daq::init()\n");
+ return 0;
+}
+
+int daq::start(){
+// xxusb_register_write(udev,1,0x1); // Start DAQ mode
+ printf("daq::start()\n");
+ return 0;
+}
+
+int daq::stop(){
+// xxusb_register_write(udev,1,0x0); // Stop DAQ mode
+// while (xxusb_usbfifo_read(udev,(int *)stackdump,BUFF_L,30)>0);
+ printf("daq::stop()\n");
+ return 0;
+}
+
+int daq::event(unsigned int *data, int maxn){
+// int ib,count;
+ int count;
+/* int events,evsize;
+ short ret;
+
+ ib=0;
+ ret=xxusb_usbfifo_read(udev,(int *) stackdata,BUFF_L,500);
+ events=stackdata[ib++];
+ DBG(printf("ret=%d,events=0x%08x\n",ret,events);)
+ if ((ret<0)||(ret!=(((NTDCCH+NADCCH)*4+4)*events+4))) return 0;
+
+ count=0;
+ while (ib<(ret/2-1)){
+ evsize = stackdata[ib++]&0xffff;
+ DBG(printf("Event:%d EvSize:%d\n", events, evsize);)
+ for (int i=0;i<(NTDCCH+NADCCH);i++,ib++) data[count++] =stackdata[ib++]&0xffff;
+ if (stackdata[ib++]!=0xfafb){
+ printf("Error!\n");,
+ return 0;
+ }
+ events--;
+ if (fStop) return 0;
+ }
+ if (stackdata[ib++]!=0xffff){
+ printf("Error!\n");
+ return 0;
+ }
+*/
+ count = 1;
+ return count;
+}
+
+int daq::disconnect(){
+// zapri daq
+// WUSBXX_close();
+ printf("daq::disconnect()\n");
+ return 0;
+}
+
+daq::daq(){
+ fStop=0;
+ connect();
+// if(devDetect > 0)
+// init();
+}
+
+daq::~daq(){
+disconnect();
+}
+
+#ifdef MAIN
+void CatchSig (int signumber)
+{
+ ctrlc = 1;
+}
+
+
+int main (int argc, char **argv){
+
+ int neve=1000000;
+ char *fname="test.dat";
+ if (argc==1) {
+ printf("Uporaba: %s stevilo_dogodkov ime_datoteke\n",argv[0]);
+ printf("Meritev prekini s Ctrl-C, ce je nabranih dogodkov ze dovolj\n");
+ exit(0);
+ }
+ if (argc>1) neve = atoi(argv[1]);
+ if (argc>2) fname = argv[2];
+
+
+// intercept routine
+ if (signal (SIGINT, CatchSig) == SIG_E,RR) perror ("sigignore");
+
+#define BSIZE 10000
+ int i,ieve,nc,nb;
+// int hdr[4]={1,(NTDCCH+4)*sizeof(int)}; // hdr[0]=1, hdr[1]=(NTDCCH+4)*4
+ int hdr[4]={1,(NTDCCH+NADCCH+4)*sizeof(int)};
+ unsigned short adc;
+ unsigned int data[BSIZE];
+ daq *d= new daq();,
+ time_t time_check;,
+
+// odpremo datoteko za pisanje
+ FILE *fp=fopen(fname,"w");
+
+ d->start();
+ ieve=0;
+
+ while((ieve<neve)&&(!ctrlc)){
+ nc=d->event(data,BSIZE);
+ nb=0;
+ while((nc>0)&&(ieve++<neve)&&(!ctrlc)){
+ // zapis v datoteko
+ hdr[2]=time(NULL);
+ hdr[3]=ieve;
+ fwrite(hdr,sizeof(int),4 ,fp);
+ fwrite(&data[nb],sizeof(int),(NTDCCH+NADCCH),fp);
+// DBG(
+ for(i=0;i<(NTDCCH+NADCCH);i++){
+ adc=data[nb+i]&0xFFFF;
+ if(i % 2 == 0)
+printf(/*"nev=%4d %d. TDC data=%d\n"*/"%d\t"/*,ieve,i*//*/2*/,adc);
+// printf("nev=%4d %d. TDC data=%d\n",ieve,i/2,adc);
+ else if(i % 2 == 1)
+printf(/*"nev=%4d %d. TDC data=%d\n"*/"%d\t"/*,ieve,i*//*/2*/,adc);
+// printf("nev=%4d %d. ADC data=%d\n",ieve,i/2,adc);
+ }
+printf("\n");
+// )
+ nb+=(NTDCCH+NADCCH);
+ nc-=(NTDCCH+NADCCH);
+ if (!(ieve%1000)) printf("event no. -> %d\n",ieve);
+ };
+ };
+
+ d->stop();
+ fclose(fp);
+ printf("Podatki so v datoteki %s\n", fname);
+ delete d;
+
+ return 0;
+}
+#endif
Index: sipmscan/trunk/input/daqusb.C.online
===================================================================
--- sipmscan/trunk/input/daqusb.C.online (nonexistent)
+++ sipmscan/trunk/input/daqusb.C.online (revision 146)
@@ -0,0 +1,257 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <errno.h>
+#include <signal.h>
+#include <ctype.h>
+#include <time.h>
+#include "../include/wusbxx_dll.h" /* the header of the shared library */
+#include "../include/daq.h"
+
+//#define DEBUG /* vkljuci dodatni izpis */
+#ifdef DEBUG
+ #define DBG(X) X
+ #define DBGFUNI(X) printf(">>> %s -> %d\n",#X,(X))
+#else
+ #define DBG(X)
+ #define DBGFUNI(X) X
+#endif
+
+/* definiram lokacije enot*/
+//#define NTDC 1 /* TDC */
+//#define NTDCCH 8
+//#define NADC 2 /* ADC */
+//#define NADCCH 8
+int ctrlc=0;
+char *ccserial=(char*)"CC0126";
+//int devDetect; // variable to tell if we detect any devices
+
+int daq::connect(){
+// odpri daq
+ xxusb_device_type devices[100];
+ //struct usb_device *dev;
+ devDetect = xxusb_devices_find(devices);
+// printf("Detected devices: %d\n", devDetect);
+ //dev = devices[0].usbdev;
+ //udev = xxusb_device_open(dev);
+
+ if(devDetect > 0)
+ {
+ WUSBXX_load(NULL);
+ WUSBXX_open(ccserial);
+ printf("daq::connect()\n");
+ }
+ else
+ printf("daq::connect() - No devices were detected!\n");
+ return 0;
+}
+
+int daq::init(int chan = 0){
+
+ 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);
+
+ CCCZ;
+ CCCC;
+ CREM_I;
+
+ NTDC = 1;
+ NADC = 2;
+ if(chan != 0)
+ {
+ NTDCCH = chan/2;
+ NADCCH = chan/2;
+ }
+ else
+ {
+ NTDCCH = 1;
+ NADCCH = 1;
+ }
+ printf("after: NTDCCH = %d, NADCCH = %d\n", NTDCCH, NADCCH);
+
+// create command stack for the TDC and ADC
+ k=1;
+ for(i=0;(i<NTDCCH)&&(i<NADCCH);i++) { stackwrite[k++]=NAF(NTDC,i,0); stackwrite[k++]=NAF(NADC,i,0); }
+// for(i=0;i<NADCCH;i++) stackwrite[k++]=NAF(NADC,i,0);
+ stackwrite[k++]=NAF(NTDC,0,9);
+ stackwrite[k++]=NAF(NADC,0,9);
+ stackwrite[k++]=NAFS(0,0,16); // insert next word to data
+ stackwrite[k++]=0xfafb; // event termination word
+ stackwrite[0]=k-1;
+// upload stack #2
+ xxusb_stack_write(udev,0x2,(long int *)stackwrite);
+ xxusb_stack_read(udev,0x2,(long int *) stackdata);
+ DBG(for(i=0;i<k;i++) printf("0x%04x\n",stackdata[i]);)
+
+ int ret[10];
+
+ CAMAC_LED_settings(udev, 1,1,0,0);
+ ret[0] = CAMAC_register_read(udev,0,&k);
+ printf("Firmware ID (return %d) -> 0x%08lX\n",ret[0],k); // GKM: Firmware ID (i.e. 0x72000001 = 0111 0010 0000 0000 0000 0000 0000 0001)
+ ret[1] = CAMAC_register_read(udev,1,&k);
+ printf("Global Mode (return %d) -> 0x%08lX\n",ret[1],k);
+ k=(k&0xF000)|0x0005; // set buffer length: n=0..6 -> 0x10000 >> n, n=7 -> single event
+ ret[0] = CAMAC_register_write(udev,1,k); // GKM: sets the buffer length (i.e. k=5 -> buf length=128 words)
+ ret[1] = CAMAC_register_write(udev,2,0x80); // wait 0x80 us after trigger // GKM: delay settings in microseconds
+ ret[2] = CAMAC_register_write(udev,3,0x0); // Scaler Readout Control Register // GKM: scaler readout settings - sets the frequency of readout (if 0, it is disabled)
+ ret[3] = CAMAC_register_write(udev,9,0x0); // Lam Mask Register // GKM: When 0, readout is triggered by the signal on NIM input
+ ret[4] = CAMAC_register_write(udev,14,0x0); // USB Bulk Transfer Setup Register
+
+ // CAMAC_DGG(udev,1,2,3,0,200,0,0);
+ // CAMAC_DGG(udev,0,0,0,0,100,0,0);
+ ret[5] = CAMAC_register_write(udev,5,(0x06<<16)+(0x04<<8)+0x00); // output // GKM: NIM outputs (i.e. 0x060400 = 00 0110 0000 0100 0000 0000 -> NIM O2=DGG_B, NIM O3=DGG_A)
+ ret[6] = CAMAC_register_write(udev,6,(0x01<<24)+(0x01<<16)+(0x0<<8)+0x0); // SCLR & DGG // GKM: device source selector (i.e. 0x01010000 = 00 0000 0001 0000 0001 0000 0000 0000 0000 -> DGG_A=NIM I1, DGG_B=NIM I1, SCLR=disabled)
+ ret[7] = CAMAC_register_write(udev,7,(100<<16)+0); // output // GKM: Delay and Gate Generator A registers (i.e. 0x00640000 = 0000 0000 0110 0100 0000 0000 0000 0000 -> DDG_A [gate=100, delay=0])
+ ret[8] = CAMAC_register_write(udev,8,(10000<<16)+0); // output // GKM: Delay and Gate Generator B registers (i.e. 0x27100000 = 0010 0111 0001 0000 0000 0000 0000 0000 -> DDG_B [gate=10000, delay=0])
+ ret[9] = CAMAC_register_write(udev,13,0); // output // GKM: Extended (course) delay (i.e. 0x00000000 = 0 -> DDG_A ext=0, DDG_B ext=0)
+
+// for(i = 0; i < 10; i++) printf("Setting %d? -> return = %d\n",i,ret[i]);
+
+// ret[0] = CAMAC_register_read(udev,1,&k);
+// printf("k (return %d) -> 0x%08lX\n",ret[0],k);
+
+ printf("daq::init()\n");
+ return 0;
+}
+
+int daq::start(){
+ xxusb_register_write(udev,1,0x1); // Start DAQ mode
+ printf("daq::start()\n");
+ return 0;
+}
+
+int daq::stop(){
+ xxusb_register_write(udev,1,0x0); // Stop DAQ mode
+ while (xxusb_usbfifo_read(udev,(int *)stackdump,BUFF_L,30)>0);
+ printf("daq::stop()\n");
+ return 0;
+}
+
+int daq::event(unsigned int *data, int maxn){
+ int ib,count;
+ int events,evsize;
+ short ret;
+
+ ib=0;
+ ret=xxusb_usbfifo_read(udev,(int *) stackdata,BUFF_L,500);
+ events=stackdata[ib++];
+ DBG(printf("ret=%d,events=0x%08x\n",ret,events);)
+ if ((ret<0)||(ret!=(((NTDCCH+NADCCH)*4+4)*events+4))) return 0;
+
+ count=0;
+ while (ib<(ret/2-1)){
+ evsize = stackdata[ib++]&0xffff;
+ DBG(printf("Event:%d EvSize:%d\n", events, evsize);)
+ for (int i=0;i<(NTDCCH+NADCCH);i++,ib++) data[count++] =stackdata[ib++]&0xffff;
+ if (stackdata[ib++]!=0xfafb){
+ printf("Error!\n");
+ return 0;
+ }
+ events--;
+ if (fStop) return 0;
+ }
+ if (stackdata[ib++]!=0xffff){
+ printf("Error!\n");
+ return 0;
+ }
+
+// count = 1;
+ return count;
+}
+
+int daq::disconnect(){
+// zapri daq
+ WUSBXX_close();
+ printf("daq::disconnect()\n");
+ return 0;
+}
+
+daq::daq(){
+ fStop=0;
+ connect();
+// if(devDetect > 0)
+// init();
+}
+
+daq::~daq(){
+disconnect();
+}
+
+#ifdef MAIN
+void CatchSig (int signumber)
+{
+ ctrlc = 1;
+}
+
+
+int main (int argc, char **argv){
+
+ int neve=1000000;
+ char *fname="test.dat";
+ if (argc==1) {
+ printf("Uporaba: %s stevilo_dogodkov ime_datoteke\n",argv[0]);
+ printf("Meritev prekini s Ctrl-C, ce je nabranih dogodkov ze dovolj\n");
+ exit(0);
+ }
+ if (argc>1) neve = atoi(argv[1]);
+ if (argc>2) fname = argv[2];
+
+
+// intercept routine
+ if (signal (SIGINT, CatchSig) == SIG_ERR) perror ("sigignore");
+
+#define BSIZE 10000
+ int i,ieve,nc,nb;
+// int hdr[4]={1,(NTDCCH+4)*sizeof(int)}; // hdr[0]=1, hdr[1]=(NTDCCH+4)*4
+ int hdr[4]={1,(NTDCCH+NADCCH+4)*sizeof(int)};
+ unsigned short adc;
+ unsigned int data[BSIZE];
+ daq *d= new daq();
+ time_t time_check;
+
+// odpremo datoteko za pisanje
+ FILE *fp=fopen(fname,"w");
+
+ d->start();
+ ieve=0;
+
+ while((ieve<neve)&&(!ctrlc)){
+ nc=d->event(data,BSIZE);
+ nb=0;
+ while((nc>0)&&(ieve++<neve)&&(!ctrlc)){
+ // zapis v datoteko
+ hdr[2]=time(NULL);
+ hdr[3]=ieve;
+ fwrite(hdr,sizeof(int),4 ,fp);
+ fwrite(&data[nb],sizeof(int),(NTDCCH+NADCCH),fp);
+// DBG(
+ for(i=0;i<(NTDCCH+NADCCH);i++){
+ adc=data[nb+i]&0xFFFF;
+ if(i % 2 == 0)
+printf(/*"nev=%4d %d. TDC data=%d\n"*/"%d\t"/*,ieve,i*//*/2*/,adc);
+// printf("nev=%4d %d. TDC data=%d\n",ieve,i/2,adc);
+ else if(i % 2 == 1)
+printf(/*"nev=%4d %d. TDC data=%d\n"*/"%d\t"/*,ieve,i*//*/2*/,adc);
+// printf("nev=%4d %d. ADC data=%d\n",ieve,i/2,adc);
+ }
+printf("\n");
+// )
+ nb+=(NTDCCH+NADCCH);
+ nc-=(NTDCCH+NADCCH);
+ if (!(ieve%1000)) printf("event no. -> %d\n",ieve);
+ };
+ };
+
+ d->stop();
+ fclose(fp);
+ printf("Podatki so v datoteki %s\n", fname);
+ delete d;
+
+ return 0;
+}
+#endif
Index: sipmscan/trunk/input/libxxusb.h.offline
===================================================================
--- sipmscan/trunk/input/libxxusb.h.offline (nonexistent)
+++ sipmscan/trunk/input/libxxusb.h.offline (revision 146)
@@ -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);
+
Index: sipmscan/trunk/input/libxxusb.h.online
===================================================================
--- sipmscan/trunk/input/libxxusb.h.online (nonexistent)
+++ sipmscan/trunk/input/libxxusb.h.online (revision 146)
@@ -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);
+
Index: sipmscan/trunk/input/start.sh.in
===================================================================
--- sipmscan/trunk/input/start.sh.in (nonexistent)
+++ sipmscan/trunk/input/start.sh.in (revision 146)
@@ -0,0 +1,21 @@
+if [ $rootdirectory != -1 ]; then
+ printenv ROOTSYS > /dev/null
+ if [ $? != 0 ]; then
+ echo "Preparing ROOT..."
+ source $rootdirectory/bin/thisroot.sh
+ fi
+fi
+
+if [ $snmpdirectory != -1 ]; then
+ printenv PATH | grep "snmp" > /dev/null
+ if [ $? != 0 ]; then
+ echo "Preparing NET-SNMP..."
+ export PATH=$snmpdirectory/bin:$PATH
+ fi
+fi
+
+if [ ! -d results ]; then
+ mkdir results
+fi
+
+./bin/sipmscan
/sipmscan/trunk/input/start.sh.in
Property changes:
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: sipmscan/trunk/input/usb.h.offline
===================================================================
--- sipmscan/trunk/input/usb.h.offline (nonexistent)
+++ sipmscan/trunk/input/usb.h.offline (revision 146)
@@ -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__ */
+
Index: sipmscan/trunk/input/workstation.h.in
===================================================================
--- sipmscan/trunk/input/workstation.h.in (nonexistent)
+++ sipmscan/trunk/input/workstation.h.in (revision 146)
@@ -0,0 +1,33 @@
+#ifndef _workstation_h_
+#define _workstation_h_
+
+// Debug signal (0 = no debug, 1 = printout debug, 2 = structure + printout debug)
+#define DBGSIG 0
+
+// Define the working computer (O=offline, S=offline with scope, I=IJS/online) and the base directory
+#define WORKSTAT 'N'
+
+// Define if working computer is connected to IJS ethernet network (for fieldpoint)
+#define IJSNET 1
+
+#ifdef WORKSTAT
+ #define rootdir "path-to-installation"
+#endif
+
+// Title colors and font
+#define FORECOLOR 0xfcfcfc
+#define BACKCOLOR 0x2e5a86
+#define FONT "-*-helvetica-bold-r-normal-*-13-*-*-*-*-*-iso8859-"
+#define HELPFONT "-*-courier-bold-r-normal-*-13-*-*-*-*-*-iso8859-"
+
+// Global variables
+#define histext ".root"
+#define histextall "*.root"
+#define tdctimeconversion 45.0909
+#define lenconversion 0.3595
+#define rotconversion (6.3281/3600.)
+#define histname "hdata"
+#define singlewait 3
+#define doublewait 2
+
+#endif
Index: sipmscan/trunk/layout/default.layout
===================================================================
--- sipmscan/trunk/layout/default.layout (nonexistent)
+++ sipmscan/trunk/layout/default.layout (revision 146)
@@ -0,0 +1,21 @@
+# Default layout file:
+# - comment lines start with #
+# - each frame layout is separated by a comment
+# - any blank lines are skipped
+# - the splitted subwindows are regarded as follows:
+# > when major split is horizontal, start on left side (top to bottom) and move towards right
+# > when major split is vertical, start from top (left to right) and move to the bottom
+
+# Whole window width and height
+1240 800 main
+
+# Measurement subwindows width and height
+248 480 settings
+248 261 display
+984 745 mainmeasure
+
+# Analysis subwindows width and height
+826 480 histfile
+826 261 analysis
+406 400 histogram
+406 341 histctrl
Index: sipmscan/trunk/layout/selected_layout.txt
===================================================================
--- sipmscan/trunk/layout/selected_layout.txt (nonexistent)
+++ sipmscan/trunk/layout/selected_layout.txt (revision 146)
@@ -0,0 +1 @@
+default.layout
Index: sipmscan/trunk/src/MIKRO/MIKRO.c
===================================================================
--- sipmscan/trunk/src/MIKRO/MIKRO.c (nonexistent)
+++ sipmscan/trunk/src/MIKRO/MIKRO.c (revision 146)
@@ -0,0 +1,296 @@
+#include "rs232.h"
+#include "MIKRO.h"
+
+//#define DEBUG
+
+#define COMWAIT 0.5
+#define COMDELAY 0.1
+
+static char MIKRO_Send[100], MIKRO_Receive[100];
+static char MIKRO_Device, MIKRO_Axes, MIKRO_Response;
+static int MIKRO_Port;
+static int nin, nout, rstat;
+static int MIKRO_type[100];
+
+int MIKRO_Cmd (int node, char *cmd)
+{
+ printf("Command: %1d %s\n",node,cmd);
+ Delay(COMDELAY);
+ FlushInQ (MIKRO_Port);
+ nout = sprintf (MIKRO_Send, "%1d %s\r", node, cmd);
+ ComWrt (MIKRO_Port, MIKRO_Send, nout);
+ if ((nin = ComRdTerm (MIKRO_Port, MIKRO_Receive, 30, 0xa))==0) {
+ nin = ComRdTerm (MIKRO_Port, MIKRO_Receive, 30, 0xa);
+ if (nin==2) return (0);
+ }
+ return (-1);
+}
+
+int MIKRO_Set (int node, char cmd[], int val)
+{
+ printf("Command: %1d %s %d\n",node,cmd, val);
+ Delay(COMDELAY);
+ FlushInQ (MIKRO_Port);
+ nout = sprintf (MIKRO_Send, "%1d %s %d\r", node, cmd, val);
+ ComWrt (MIKRO_Port, MIKRO_Send, nout);
+ if ((nin = ComRdTerm (MIKRO_Port, MIKRO_Receive, 30, 0xa))==0) {
+ nin = ComRdTerm (MIKRO_Port, MIKRO_Receive, 30, 0xa);
+ if (nin==2) return (0);
+ }
+ return (-1);
+}
+
+int MIKRO_Get (int node, char cmd[], int *val)
+{
+ short int stmp;
+
+ Delay(COMDELAY);
+ FlushInQ (MIKRO_Port);
+ nout = sprintf (MIKRO_Send, "%1d %s\r", node, cmd);
+ ComWrt (MIKRO_Port, MIKRO_Send, nout);
+ if ((nin = ComRdTerm (MIKRO_Port, MIKRO_Receive, 30, 0xa))==0) {
+ nin = ComRdTerm (MIKRO_Port, MIKRO_Receive, 30, 0xa);
+ if (nin>0){
+// MIKRO_Receive[--nin]=0;
+ switch (nin) {
+ case 9:
+ sscanf (MIKRO_Receive, "%*x %hx",&stmp);
+ *val=stmp;
+ return (0);
+ case 13:
+ sscanf (MIKRO_Receive, "%*x %x",val);
+ return (0);
+ default:
+ printf("Node %d Com error => bytes rcved=0x%02x buf=%s\n",node,nin,MIKRO_Receive);
+ break;
+ }
+ }
+ }
+ return (-1);
+}
+
+int MIKRO_GetStat (int node)
+{
+ int tmp;
+
+ Delay(COMDELAY);
+ FlushInQ (MIKRO_Port);
+ nout = sprintf (MIKRO_Send, "%1d st\r", node);
+ ComWrt (MIKRO_Port, MIKRO_Send, nout);
+ if ((nin = ComRdTerm (MIKRO_Port, MIKRO_Receive, 30, 0xa))==0) {
+ nin = ComRdTerm (MIKRO_Port, MIKRO_Receive, 30, 0xa);
+// if (nin>0) nin--;
+ MIKRO_Receive[nin]=0;
+ if (nin==9) {
+ tmp=0;
+ sscanf (MIKRO_Receive, "%*x %hx",(short int *)&tmp);
+ return (tmp);
+ }
+ }
+ return (-1);
+}
+
+int _VI_FUNC MIKRO_Open (char * dev)
+{
+
+
+ MIKRO_Port=OpenComConfig (dev, "", 38400, 0, 8, 1, 512, 512);
+// SetXMode (MIKRO_Port, 0);
+// SetCTSMode (MIKRO_Port, LWRS_HWHANDSHAKE_OFF);
+// SetComTime (MIKRO_Port, COMWAIT);
+
+ return 0;
+}
+
+int _VI_FUNC MIKRO_Init (int node, int type)
+{
+ MIKRO_type[node]=type;
+ Delay(0.1);
+ MIKRO_Cmd(node,"ok 1");
+ MIKRO_Cmd(node,"ab");
+ switch (type){
+ case 1: // 3M Linear
+ MIKRO_Cmd(node,"k 1");
+ MIKRO_Cmd(node,"ad 200");
+ MIKRO_Cmd(node,"aa 2");
+ MIKRO_Cmd(node,"fa 1");
+ MIKRO_Cmd(node,"fd 3000"); // Set Max Dynamic Following Error (1000)
+ MIKRO_Cmd(node,"sr 1000");
+ MIKRO_Cmd(node,"sp 750");
+ MIKRO_Cmd(node,"ac 100");
+ MIKRO_Cmd(node,"dc 200");
+ MIKRO_Cmd(node,"por 28000");
+ MIKRO_Cmd(node,"i 600");
+ MIKRO_Cmd(node,"ano 2350");
+ MIKRO_Cmd(node,"ls 1");
+ MIKRO_Cmd(node,"hp 1");
+ MIKRO_Cmd(node,"hf 1");
+ break;
+ case 2: // 3M Rotary
+ MIKRO_Cmd(node,"k 1");
+ MIKRO_Cmd(node,"ad 200");
+ MIKRO_Cmd(node,"aa 1");
+ MIKRO_Cmd(node,"fa 1");
+ MIKRO_Cmd(node,"fd 3000"); // Set Max Dynamic Following Error (1000)
+ MIKRO_Cmd(node,"sr 1000");
+ MIKRO_Cmd(node,"sp 550");
+ MIKRO_Cmd(node,"ac 100");
+ MIKRO_Cmd(node,"dc 200");
+ MIKRO_Cmd(node,"por 28000");
+ MIKRO_Cmd(node,"i 600");
+ MIKRO_Cmd(node,"ano 2350");
+ MIKRO_Cmd(node,"ls 99");
+ MIKRO_Cmd(node,"hp 1");
+ MIKRO_Cmd(node,"hf 1");
+ break;
+ case 3: // 4M Linear
+ MIKRO_Cmd(node,"k 1");
+ MIKRO_Cmd(node,"ad 1000");
+ MIKRO_Cmd(node,"aa 2");
+ MIKRO_Cmd(node,"fa 1");
+ MIKRO_Cmd(node,"fd 3000"); // Set Max Dynamic Following Error (1000)
+ MIKRO_Cmd(node,"sr 1000");
+ MIKRO_Cmd(node,"sp 1000");
+ MIKRO_Cmd(node,"ac 100");
+ MIKRO_Cmd(node,"dc 200");
+ MIKRO_Cmd(node,"por 28000");
+ MIKRO_Cmd(node,"i 600");
+ MIKRO_Cmd(node,"ano 2600");
+ MIKRO_Cmd(node,"ls 1");
+ MIKRO_Cmd(node,"hp 1");
+ MIKRO_Cmd(node,"hf 1");
+ break;
+ case 4: // 4M Rotary
+ MIKRO_Cmd(node,"k 1");
+ MIKRO_Cmd(node,"ad 100");
+ MIKRO_Cmd(node,"aa 1");
+ MIKRO_Cmd(node,"fa 1");
+ MIKRO_Cmd(node,"fd 3000"); // Set Max Dynamic Following Error (1000)
+ MIKRO_Cmd(node,"sp 800");
+ MIKRO_Cmd(node,"sr 1000");
+ MIKRO_Cmd(node,"ac 100");
+ MIKRO_Cmd(node,"dc 200");
+ MIKRO_Cmd(node,"por 28000");
+ MIKRO_Cmd(node,"i 600");
+ MIKRO_Cmd(node,"ano 2600");
+ MIKRO_Cmd(node,"ls 99");
+ break;
+ default:
+ break;
+ }
+ MIKRO_Cmd(node,"rd 0");
+ MIKRO_Cmd(node,"n 2");
+ MIKRO_Cmd(node,"en");
+ if (type != 0){
+ MIKRO_Cmd(node,"eeboot 1");
+ MIKRO_Cmd(node,"eepsav 1");
+ Delay(0.1);
+ }
+ return 0;
+}
+
+int _VI_FUNC MIKRO_Reset (int node)
+{
+
+ MIKRO_Cmd(node,"di"); // disables the node
+
+ Delay(COMDELAY);
+ nout = sprintf (MIKRO_Send, "%1d rn\r", node); // resets the node
+ ComWrt (MIKRO_Port, MIKRO_Send, nout);
+
+ SetComTime (MIKRO_Port, 20);
+ nin = ComRdTerm (MIKRO_Port, MIKRO_Receive, 30, 0xa);
+ SetComTime (MIKRO_Port, COMWAIT);
+ nin = ComRdTerm (MIKRO_Port, MIKRO_Receive, 30, 0xa);
+// if (nin!=0) nin--;
+// MIKRO_Receive[nin]=0;
+ printf("%s\n",MIKRO_Receive);
+ nin = ComRdTerm (MIKRO_Port, MIKRO_Receive, 30, 0xa);
+ nin = ComRdTerm (MIKRO_Port, MIKRO_Receive, 30, 0xa);
+// if (nin!=0) nin--;
+// MIKRO_Receive[nin]=0;
+ printf("%s\n",MIKRO_Receive);
+ MIKRO_Init(node,0);
+ return 0;
+}
+
+int _VI_FUNC MIKRO_ReferenceMove (int node)
+{
+ int fac=10;
+ int n2,as;
+
+ MIKRO_Cmd(node,"ab");
+ MIKRO_Cmd(node,"en");
+ MIKRO_Set(node,"ll",-1000000);
+ MIKRO_Set(node,"ll",1000000);
+
+ if (!(MIKRO_GetStat(node)&0x8000)){
+ MIKRO_Set(node,"v", -100*fac);
+ do {
+ MIKRO_GetPosition(node,&n2);
+ MIKRO_Get(node,"as",&as);
+ printf("Approaching N-limit node=%d pos=%d speed=%d\n",node,n2,as);
+ } while (MIKRO_GetStat(node)&0x1 );
+ if (!(MIKRO_GetStat(node)&0x8000)){
+ printf("N-limit not reached! Trying with half speed.\n");
+ MIKRO_Set(node,"v", -50*fac);
+ do {
+ MIKRO_GetPosition(node,&n2);
+ MIKRO_Get(node,"as",&as);
+ printf("Approaching N-limit node=%d pos=%d speed=%d\n",node,n2,as);
+ } while (MIKRO_GetStat(node)&0x1 );
+ if (!(MIKRO_GetStat(node)&0x8000)){
+ printf("N-limit not reached! Aborting ...\n");
+ MIKRO_Cmd(node,"ab");
+ return -1;
+ }
+ }
+ }
+ MIKRO_MoveFor(node,1000);
+ MIKRO_Set(node,"v", -10*fac);
+ do {
+ MIKRO_GetPosition(node,&n2);
+ MIKRO_Get(node,"as",&as);
+ printf("Fine tuning 0: node=%d pos=%d speed=%d\n",node,n2, as);
+ } while (MIKRO_GetStat(node)&0x1);
+ if (!(MIKRO_GetStat(node)&0x8000)){
+ printf("N-limit not reached! Aborting ...\n");
+ MIKRO_Cmd(node,"ab");
+ return -1;
+ }
+
+ MIKRO_MoveFor(node,1000);
+ MIKRO_Set(node,"ho",0);
+ MIKRO_Set(node,"ll",-100);
+ MIKRO_Set(node,"ll",500100);
+ return 0;
+}
+
+int _VI_FUNC MIKRO_MoveFor (int node, int dist)
+{
+ MIKRO_Set(node,"lr", dist);
+ MIKRO_Cmd(node,"mv");
+ while (MIKRO_GetStat(node)&1) Delay(0.1);
+ return 0;
+}
+
+int _VI_FUNC MIKRO_MoveTo (int node, int dest)
+{
+// printf("-> MIKRO_MoveTo \n");
+ MIKRO_Set(node,"la", dest);
+ MIKRO_Cmd(node,"mv");
+ while (MIKRO_GetStat(node)&1) Delay(0.1);
+ return 0;
+}
+
+int _VI_FUNC MIKRO_GetPosition (int node, int pos[])
+{
+ MIKRO_Get(node,"pos",pos);
+ return 0;
+}
+
+void _VI_FUNC MIKRO_Close (void)
+{
+CloseCom (MIKRO_Port);
+}
+
Index: sipmscan/trunk/src/MIKRO/MIKRO.h
===================================================================
--- sipmscan/trunk/src/MIKRO/MIKRO.h (nonexistent)
+++ sipmscan/trunk/src/MIKRO/MIKRO.h (revision 146)
@@ -0,0 +1,21 @@
+
+#define _VI_FUNC
+int _VI_FUNC MIKRO_Open (char *dev);
+
+int _VI_FUNC MIKRO_Reset (int node);
+
+int _VI_FUNC MIKRO_Init (int node, int type);
+
+int _VI_FUNC MIKRO_ReferenceMove (int node);
+
+int _VI_FUNC MIKRO_MoveFor (int node, int dist);
+
+int _VI_FUNC MIKRO_MoveTo (int node, int dest);
+
+int _VI_FUNC MIKRO_GetPosition (int node, int pos[]);
+
+int _VI_FUNC MIKRO_SetZero (char axes);
+
+int _VI_FUNC MIKRO_SetPlain (char axes);
+
+void _VI_FUNC MIKRO_Close (void);
Index: sipmscan/trunk/src/MIKRO/Makefile
===================================================================
--- sipmscan/trunk/src/MIKRO/Makefile (nonexistent)
+++ sipmscan/trunk/src/MIKRO/Makefile (revision 146)
@@ -0,0 +1,4 @@
+mikro_ctrl: mikro_ctrl.c rs232.c rs232.h MIKRO.c
+ gcc mikro_ctrl.c rs232.c MIKRO.c -o mikro_ctrl -lm
+mikro_ctrl_d: mikro_ctrl.c rs232.c rs232.h MIKRO.c
+ gcc mikro_ctrl.c rs232.c MIKRO.c -o mikro_ctrl_d -lm -DDEBUG
Index: sipmscan/trunk/src/MIKRO/mikro_ctrl
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/sipmscan/trunk/src/MIKRO/mikro_ctrl
Property changes:
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: sipmscan/trunk/src/MIKRO/mikro_ctrl.c
===================================================================
--- sipmscan/trunk/src/MIKRO/mikro_ctrl.c (nonexistent)
+++ sipmscan/trunk/src/MIKRO/mikro_ctrl.c (revision 146)
@@ -0,0 +1,148 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include "MIKRO.h"
+
+
+#include <getopt.h>
+
+#define MIKRO_COM "/dev/ttyUSB0"
+
+int help(){
+ fprintf(stderr,"Usage: mikro [-i node][-n node] [-u up] [-d down] [-r node] [-h node] [-a] [-g] [-m pos]\n");
+ fprintf(stderr," Options:\n");
+ fprintf(stderr,"[-n node] -i type .. initialize node + save to EEPROM\n");
+ fprintf(stderr," (1=3MLin,2=3MRot,3=4MLin,4=4MRot,0=skip\n");
+ fprintf(stderr," -n node -h .. homing procedure for node\n");
+ fprintf(stderr," -n node -r .. reset node\n");
+ fprintf(stderr," -n node -u .. move node for +1000\n");
+ fprintf(stderr," -n node -d .. move node for -1000\n");
+ fprintf(stderr,"[-n node] -a .. current status of the nodes\n");
+ fprintf(stderr," -n node -v value -s cmd .. set value of the cmd on the node\n");
+ fprintf(stderr," -n node -g cmd .. get value of the cmd on the node\n");
+ fprintf(stderr," -n node -m position .. move node to position\n");
+ fprintf(stderr," -l delaysec .. loop test with the delay delaysec\n");
+ return 0;
+}
+
+int main (int argc, char ** argv){
+ int i,j,k;
+ int node=0,opt,value=0,itype=0;
+ int nr_nodes=3;
+ int ierr;
+ int pos,xpos,ypos,zpos;
+ char custcmd[20];
+ char statbits[16][10]={"Moving","In-Pos","Mode","AMN Mode","%Done","DNet","DNErr","FD-Error",
+ "Disable","R-Lim","Local","Estop","Event1","P-Lim","Event2","N-Lim"};
+
+ MIKRO_Open (MIKRO_COM);
+
+ // ":" just indicates that this option needs an argument
+ while ((opt = getopt(argc, argv, "i:av:s:l:udn:c:pm:g:hre")) != -1) {
+ switch (opt) {
+ case 'i':
+ itype = atoi(optarg);
+ if(node != 0)
+ MIKRO_Init (node,itype);
+ else
+ for(i=1; i<nr_nodes+1; i++) MIKRO_Init (i,itype);
+ break;
+ case 'a':
+ if(node != 0) {
+ pos=0;
+ ierr=MIKRO_GetStat(node);
+ MIKRO_GetPosition (node, &pos);
+ printf("node %d position %d status =%04x\n",node,pos,ierr);
+ for(i=0; i<16; i++){
+ printf("%d: %s\n", (ierr&1),statbits[i]);
+ ierr>>=1;
+ }
+ }else{
+ pos=0;
+ for (j=1;j<nr_nodes+1;j++){
+ ierr=MIKRO_GetStat(j);
+ MIKRO_GetPosition (j, &pos);
+ printf("node %d position %d status =%04x\n",j,pos,ierr);
+ for(i=0; i<16; i++){
+ printf("%d: %s\n", (ierr&1),statbits[i]);
+ ierr>>=1;
+ }
+ }
+ }
+ break;
+ case 'l':
+ printf("MIKRO_MoveTo Loop\n");
+ for (i=0;i<5;i++){
+ xpos=i*1000+10000;
+ MIKRO_MoveTo (1, xpos);
+ for (j=0;j<5;j++){
+ ypos=j*1000+10000;
+ MIKRO_MoveTo (2, ypos);
+ for (k=0;k<50;k++){
+ zpos=k*1000+10000;
+ MIKRO_MoveTo (3, zpos);
+ printf("x=%d y=%d z=%d\n",xpos,ypos,zpos);
+ Delay(atof(optarg));
+ }
+ }
+ }
+ break;
+ case 'n':
+ node = atoi(optarg);
+ break;
+ case 'm':
+ MIKRO_MoveTo (node, atoi(optarg));
+ printf("MIKRO_MoveTo node=%d pos=%d \n",node,atoi(optarg));
+ MIKRO_GetPosition (node, &i);
+ printf("node %d position %d \n",node,i);
+ break;
+ case 'v':
+ value=atoi(optarg);
+ break;
+ case 's':
+ MIKRO_Set (node,optarg,value);
+ printf("MIKRO_Set node %d cmd=%s val=%d\n",node,optarg, value);
+ break;
+ case 'g':
+ MIKRO_Get (node,optarg,&i);
+ printf("MIKRO_Get node %d cmd=%s val=%d\n",node,optarg, i);
+ break;
+ case 'h':
+ printf("MIKRO_ReferenceMove node=%d\n",node);
+ MIKRO_ReferenceMove (node);
+ break;
+ case 'r':
+ printf("MIKRO_Reset node=%d\n",node);
+ MIKRO_Reset (node);
+ break;
+ case 'u':
+ MIKRO_Set(node,"lr", 1000);
+ MIKRO_Cmd(node,"mv");
+ break;
+ case 'd':
+ MIKRO_Set(node,"lr", -1000);
+ MIKRO_Cmd(node,"mv");
+ break;
+ case 'e':
+ MIKRO_Cmd(node,"ab");
+ MIKRO_Cmd(node,"n 2");
+ MIKRO_Cmd(node,"en");
+ break;
+ case 'c': // cust. com.
+ sprintf(custcmd,"%s",optarg);
+ MIKRO_Cmd(node,custcmd);
+ break;
+ case 'p': // get pos.
+ if(node != 0){
+ MIKRO_GetPosition (node, &pos);
+ printf("%d\n",pos);
+ }
+ break;
+ default: // '?'
+ help();
+ break;
+ }
+ }
+ if (argc==1) help();
+ MIKRO_Close ();
+ return 0;
+}
Index: sipmscan/trunk/src/MIKRO/mikro_ctrl_d
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/sipmscan/trunk/src/MIKRO/mikro_ctrl_d
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: sipmscan/trunk/src/MIKRO/quick_scan.sh
===================================================================
--- sipmscan/trunk/src/MIKRO/quick_scan.sh (nonexistent)
+++ sipmscan/trunk/src/MIKRO/quick_scan.sh (revision 146)
@@ -0,0 +1,15 @@
+#! /bin/bash
+
+#fname=$1
+#num_events=$2
+
+#./addheader $fname 1 $num_events 0 0 0 0 0 0
+#./addheader $fname 3 0 0 0 0 0 0
+#./daq $fname $num_events
+#./addheader $fname 2
+
+position=`./mikro_ctrl -a | grep -o '[[:digit:]]*' | awk -F : '{if(NR==2 || NR==5){print $1}}'`
+#pos_x=${position}[0]
+#pos_y=${position}[1]
+#echo "position x = " $pos_x " position y = " $pos_y
+echo $position >> test.txt
Index: sipmscan/trunk/src/MIKRO/rs232.c
===================================================================
--- sipmscan/trunk/src/MIKRO/rs232.c (nonexistent)
+++ sipmscan/trunk/src/MIKRO/rs232.c (revision 146)
@@ -0,0 +1,125 @@
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <string.h>
+#include <termios.h>
+
+#include "rs232.h"
+//#define DEBUG
+
+const int debug=0;
+
+struct termios tattr;
+
+int Delay(double sec){
+ return usleep((int) (sec*1e6) );
+}
+
+int SetComTime(int fd, double timeout_seconds){
+
+ int ntenth;
+
+ ntenth = (int)(timeout_seconds*10);
+ tattr.c_cc[VTIME] = ntenth;
+ tcsetattr(fd, TCSANOW, &tattr);
+#ifdef DEBUG
+ printf("SetComTime: %d\n", ntenth);
+#endif
+ return 0;
+}
+
+int FlushInQ(int fd){
+ return 0;
+}
+
+int FlushOutQ(int fd){
+ return 0;
+}
+
+int ComWrt (int fd, char* cmd, int Count ){
+
+ int nwr;
+
+ nwr=write(fd, cmd, Count);
+#ifdef DEBUG
+ printf ( "ComWrt: %d, %d, %s\n", Count, nwr, cmd);
+#endif
+ return nwr;
+}
+
+int ComRdTerm (int fd, char *response, int nb, int termchar)
+{
+
+ int nread, nloop;
+
+ nread=0;
+ nloop=0;
+
+#ifdef DEBUG
+ printf ( "ComRdTerm start\n") ;
+#endif
+// rewind(fpr);
+ while (1) {
+ if (nloop++ == nb) return -1;
+// nread += read ( fd, response+nread, nb-nread );
+ nread += read ( fd, response+nread, 1 );
+#ifdef DEBUG
+ response[nread]=0;
+ printf ("ComRdTerm nread: %d %d %s\n", nloop, nread, response) ;
+#endif
+ if (nread>1) if(response[nread-1] == termchar) break;
+ }
+
+ nread = nread - 2;
+ response[nread]=0;
+#ifdef DEBUG
+ printf("CmdRdTerm: %s\n",response);
+#endif
+ return nread;
+}
+
+int OpenComConfig( char *dev, char * device_name, long Baud_Rate, int Parity, int Data_Bits,
+ int Stop_Bits, int Input_Queue_Size, int Output_Queue_Size ){
+
+ int fd;
+
+ memset (&tattr, 0, sizeof tattr);
+
+ fd=open(dev, O_RDWR | O_NOCTTY | O_SYNC);
+// see 'man tcsetattr'
+ tcgetattr (fd, &tattr);
+ cfmakeraw(&tattr);
+ cfsetspeed(&tattr, B38400);
+// cfsetispeed(&tattr, B38400);
+// cfsetospeed(&tattr, B38400);
+// input modes
+ tattr.c_iflag&=~IGNBRK;
+ tattr.c_iflag&=~(IGNCR | ICRNL | INLCR);
+ tattr.c_iflag&=~(IXON | IXOFF | IXANY);
+// output modess
+ tattr.c_oflag=0;
+// local modes
+ tattr.c_lflag=0;
+ tattr.c_lflag &= ~(ICANON|ECHO) ; // canonical mode and echo input char
+// control modes
+ tattr.c_cflag |= (CLOCAL | CREAD); // ignore modem controls,
+ // enable reading
+ tattr.c_cflag &= ~(PARENB | PARODD); // shut off parity
+ tattr.c_cflag &= ~CSTOPB; // set two stop bits
+ tattr.c_cflag &= ~CRTSCTS; // enable RTS/CTS flow control
+
+ tattr.c_cc[VMIN] = 0;
+ tattr.c_cc[VTIME] = 2;
+ tcsetattr(fd, TCSAFLUSH, &tattr);
+
+#ifdef DEBUG
+ printf("OpenComConfig\n");
+#endif
+ return fd; ;
+}
+
+
+int CloseCom (int fd){
+
+ close(fd);
+ return;
+}
Index: sipmscan/trunk/src/MIKRO/rs232.h
===================================================================
--- sipmscan/trunk/src/MIKRO/rs232.h (nonexistent)
+++ sipmscan/trunk/src/MIKRO/rs232.h (revision 146)
@@ -0,0 +1,20 @@
+#ifndef _RS232_H_
+#define _RS232_H_
+#include <stdlib.h>
+#include <stdio.h>
+
+#define LWRS_HWHANDSHAKE_OFF 0
+#define LWRS_HWHANDSHAKE_CTS_RTS_DTR 1
+#define LWRS_HWHANDSHAKE_CTS_RTS 2
+
+int Delay(double seconds);
+int FlushInQ(int fd);
+int FlushOutQ(int fd);
+int ComWrt (int fd, char* cmd, int Count ) ;
+int ComRdTerm (int fd, char* result, int count, int termchar );
+int OpenComConfig(char *dev, char * device_name, long Baud_Rate, int Parity, int Data_Bits,
+ int Stop_Bits, int Input_Queue_Size, int Output_Queue_Size );
+int CloseCom (int fd);
+int SetComTime(int fd, double timeout_seconds);
+#endif
+
Index: sipmscan/trunk/src/analysis.cpp
===================================================================
--- sipmscan/trunk/src/analysis.cpp (nonexistent)
+++ sipmscan/trunk/src/analysis.cpp (revision 146)
@@ -0,0 +1,1699 @@
+#include "../include/sipmscan.h"
+#include "../include/workstation.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+// Peak detection function
+int npeaks = 20;
+double FindPeaks(double *x, double *par)
+{
+ double result = 0;
+ for(int i = 0; i < npeaks; i++)
+ {
+ double norm = par[3*i];
+ double mean = par[3*i+1];
+ double sigma = par[3*i+2];
+ result += norm*TMath::Gaus(x[0], mean, sigma);
+ }
+ return result;
+}
+
+// File browser for selecting the dark run histogram
+void TGAppMainFrame::SelectDarkHist()
+{
+ TGFileInfo file_info;
+ const char *filetypes[] = {"Histograms",histextall,0,0};
+ char *cTemp;
+ file_info.fFileTypes = filetypes;
+ cTemp = new char[1024];
+ sprintf(cTemp, "%s/results", rootdir);
+ file_info.fIniDir = StrDup(cTemp);
+ file_info.fMultipleSelection = kFALSE;
+ new TGFileDialog(gClient->GetDefaultRoot(), fMain, kFDOpen, &file_info);
+ delete[] cTemp;
+
+ if(file_info.fFilename != NULL)
+ {
+ darkRun->widgetTE->SetText(file_info.fFilename);
+ fileList->AddEntry(file_info.fFilename, fileList->GetNumberOfEntries());
+ fileList->Layout();
+ }
+ else
+ darkRun->widgetTE->SetText("");
+}
+
+// Reset analysis defaults for the current analysis type (0 = Integrate spectrum, 1 = Relative PDE, 2 = Breakdown voltage, 3 = Surface scan, 4 = Timing analysis)
+void TGAppMainFrame::AnalysisDefaults()
+{
+ printf("AnalysisDefaults(): Current analysis tab = %d\n", analTab->GetCurrent());
+ if(analTab->GetCurrent() == 0) // Integrate spectrum
+ {
+ intSpect->widgetChBox[0]->SetState(kButtonUp);
+ intSpect->widgetChBox[1]->SetState(kButtonUp);
+ intSpect->widgetChBox[2]->SetState(kButtonDown);
+ resol2d->widgetNE[0]->SetNumber(40);
+ resol2d->widgetNE[1]->SetNumber(40);
+ }
+ else if(analTab->GetCurrent() == 1) // Relative PDE
+ {
+ relPde->widgetChBox[1]->SetState(kButtonDown);
+ midPeak->widgetChBox[0]->SetState(kButtonUp);
+ zeroAngle->widgetNE[0]->SetNumber(0.00);
+ }
+ else if(analTab->GetCurrent() == 2) // Breakdown voltage
+ {
+ minPeak->widgetNE[0]->SetNumber(2);
+ minPeak->widgetNE[0]->SetNumber(1);
+ }
+ else if(analTab->GetCurrent() == 3) // Surface scan
+ {
+ surfScanOpt->widgetChBox[0]->SetState(kButtonDown);
+ surfScanOpt->widgetChBox[1]->SetState(kButtonUp);
+ resolSurf->widgetNE[0]->SetNumber(40);
+ resolSurf->widgetNE[1]->SetNumber(40);
+ }
+}
+
+// Analysis handle function
+void TGAppMainFrame::AnalysisHandle(int type)
+{
+ TList *files;
+ bool createTab = true;
+ int tabid = -1;
+ int analtab = analTab->GetCurrent();
+
+ int analtype;
+ if( (analtab == 0) && (!intSpect->widgetChBox[0]->IsDown() && !intSpect->widgetChBox[1]->IsDown()) )
+ analtype = 0;
+ else if( (analtab == 0) && (intSpect->widgetChBox[0]->IsDown() || intSpect->widgetChBox[1]->IsDown()) )
+ analtype = 1;
+ else if( analtab == 1 )
+ analtype = 2;
+ else if( analtab == 2 )
+ analtype = 3;
+ else if( analtab == 3 )
+ analtype = 4;
+
+ // Only integrate spectrum or make relative PDE
+ if(type == 0)
+ {
+ files = new TList();
+ fileList->GetSelectedEntries(files);
+
+ if( analtype == 0 )
+ IntegSpectrum(files, 0, 0);
+
+ if( intSpect->widgetChBox[0]->IsDown() )
+ IntegSpectrum(files, 1, 0);
+
+ if( intSpect->widgetChBox[1]->IsDown() )
+ IntegSpectrum(files, 2, 0);
+
+ if( analtype == 2 )
+ PhotonMu(files, 0);
+
+ if( analtype == 3 )
+ BreakdownVolt(files, 0);
+
+ if( analtype == 4 )
+ SurfaceScan(files, 0);
+ }
+ // Integrate spectrum or make relative PDE and open edit window
+ else if(type == 1)
+ {
+ files = new TList();
+ fileList->GetSelectedEntries(files);
+
+ // Prepare a new analysis edit tab, if we want to edit plots
+ for(int i = 0; i < fTab->GetNumberOfTabs(); i++)
+ {
+ if(strcmp("Analysis edit", fTab->GetTabTab(i)->GetString() ) == 0)
+ {
+ createTab = false;
+ tabid = i;
+ }
+
+ if(DBGSIG) printf("AnalysisHandle(): Name of tab = %s\n", fTab->GetTabTab(i)->GetString() );
+ }
+
+ if(files->GetSize() > 0)
+ {
+ TempAnalysisTab(fTab, createTab, &tabid, analtype);
+
+ // Integrate spectra
+ if( analtype == 0 )
+ IntegSpectrum(files, 0, 1);
+
+ if( intSpect->widgetChBox[0]->IsDown() )
+ IntegSpectrum(files, 1, 1);
+
+ if( intSpect->widgetChBox[1]->IsDown() )
+ IntegSpectrum(files, 2, 1);
+
+ if( analtype == 2 )
+ PhotonMu(files, 1);
+
+ if( analtype == 3 )
+ BreakdownVolt(files, 1);
+
+ if( analtype == 4 )
+ SurfaceScan(files, 1);
+
+ fTab->SetTab(tabid);
+ }
+ }
+
+ delete files;
+}
+
+// Analysis functions ----------------------------------
+void TGAppMainFrame::IntegSpectrum(TList *files, int direction, int edit)
+{
+ unsigned int nrfiles = files->GetSize();
+ char ctemp[1024];
+ char exportname[1024];
+ int j, k = 0, m = 0;
+
+ TTree *header_data, *meas_data;
+ double *integralCount, *integralAcc;
+ integralCount = new double[nrfiles];
+ integralAcc = new double[nrfiles];
+ double *surfxy, *surfz;
+ surfxy = new double[nrfiles];
+ surfz = new double[nrfiles];
+ double minInteg, maxInteg;
+ bool norm = intSpect->widgetChBox[2]->IsDown();
+ double curzval;
+ bool edge2d = false;
+ TCanvas *gCanvas;
+
+ float progVal = 0;
+ analysisProgress->widgetPB->SetPosition(progVal);
+ gVirtualX->Update(1);
+
+ // Zero the integral count and accumulated vaules
+ for(int i = 0; i < (int)nrfiles; i++) {integralCount[i] = 0; integralAcc[i] = 0; }
+
+ // Start if we select at least one file
+ if(nrfiles > 0)
+ {
+ for(int i = 0; i < (int)nrfiles; i++)
+ {
+ if(files->At(i))
+ {
+ // Read the X,Y and Z positions from header and ADC and TDC values from the measurements
+ sprintf(ctemp, "%s", files->At(i)->GetTitle());
+ inroot = new TFile(ctemp, "READ");
+
+ inroot->GetObject("header_data", header_data);
+ inroot->GetObject("meas_data", meas_data);
+
+ header_data->SetBranchAddress("xpos", &evtheader.xpos);
+ header_data->GetEntry(0);
+ header_data->SetBranchAddress("ypos", &evtheader.ypos);
+ header_data->GetEntry(0);
+ header_data->SetBranchAddress("zpos", &evtheader.zpos);
+ header_data->GetEntry(0);
+
+ char rdc[256];
+ j = selectCh->widgetNE[0]->GetNumber();
+ double rangetdc[2];
+ rangetdc[0] = tdcRange->widgetNE[0]->GetNumber();
+ rangetdc[1] = tdcRange->widgetNE[1]->GetNumber();
+
+ k = 0;
+ m = 0;
+
+ // Reading the data
+ for(int e = 0; e < meas_data->GetEntries(); e++)
+ {
+ sprintf(rdc, "ADC%d", j);
+ meas_data->SetBranchAddress(rdc, &evtdata.adcdata[j]);
+ meas_data->GetEntry(e);
+
+ sprintf(rdc, "TDC%d", j);
+ meas_data->SetBranchAddress(rdc, &evtdata.tdcdata[j]);
+ meas_data->GetEntry(e);
+
+ // Use data point only if it is inside the TDC window
+ if( ((double)evtdata.tdcdata[j]/tdctimeconversion >= rangetdc[0]) && ((double)evtdata.tdcdata[j]/tdctimeconversion <= rangetdc[1]) )
+ {
+ k++;
+ m += evtdata.adcdata[j];
+ }
+ }
+
+ // X, Y and Z values from each file (table units or microns)
+ if(posUnits->widgetCB->GetSelected() == 0)
+ {
+ if(direction == 1)
+ surfxy[i] = (double)(evtheader.xpos);
+ else if(direction == 2)
+ surfxy[i] = (double)(evtheader.ypos);
+ surfz[i] = (double)(evtheader.zpos);
+ }
+ else if(posUnits->widgetCB->GetSelected() == 1)
+ {
+ if(direction == 1)
+ surfxy[i] = (double)(evtheader.xpos*lenconversion);
+ else if(direction == 2)
+ surfxy[i] = (double)(evtheader.ypos*lenconversion);
+ surfz[i] = (double)(evtheader.zpos*lenconversion);
+ }
+
+ // Check if we have different Z values: if no, just make the edge plots; if yes, save edge plots and make a 2d edge plot
+ if(i == 0) curzval = surfz[i];
+ else
+ {
+ if(surfz[i] != curzval)
+ edge2d = true;
+ }
+
+ // Print the calculated integral, if no X or Y direction edge plots are enabled; otherwise, just save for later plotting
+ if(direction == 0)
+ {
+ if(norm)
+ {
+ integralCount[i] += ((double)m)/((double)k);
+ printf("IntegSpectrum(): %s: The integral is: %lf\n", ctemp, integralCount[i]);
+ }
+ else
+ {
+ integralCount[i] += m;
+ printf("IntegSpectrum(): %s: The integral is: %d\n", ctemp, (int)integralCount[i]);
+ }
+ }
+ else
+ {
+ if(norm)
+ integralCount[i] += ((double)m)/((double)k);
+ else
+ integralCount[i] += m;
+ }
+
+ inroot->Close();
+ delete inroot;
+ }
+
+ // Update the progress bar
+ progVal = (float)(75.00/nrfiles)*i;
+ analysisProgress->widgetPB->SetPosition(progVal);
+ gVirtualX->Update(1);
+ }
+
+ printf("IntegSpectrum(): %d files were selected.\n", nrfiles);
+
+ // If only an integral is needed, do not plot and exit here
+ if( direction == 0 )
+ {
+ delete[] integralCount;
+ delete[] surfxy;
+ delete[] surfz;
+ return;
+ }
+
+ // Current z value and the accumulated counter
+ curzval = surfz[0];
+ j = 0;
+ int acc = 0;
+ int zb;
+ for(int i = 0; i <= (int)nrfiles; i++)
+ {
+ // Collect the accumulated integral in order to produce a PDF from a CDF
+ // While we are at the same Z value, save under one set
+ if( (surfz[i] == curzval) && (acc != nrfiles) )
+ {
+ integralAcc[j] = integralCount[i];
+ if(DBGSIG) printf("IntegSpectrum(): Integral check 1 (i=%d,j=%d,z=%.2lf): %lf\t%lf\n", i, j, surfz[i], integralCount[i], integralAcc[j]);
+ j++;
+ acc++;
+ }
+ // When we switch to a new set of Z values and at the end, we must save the previous ones to make 1D edge plots
+ else
+ {
+ // Find minimal and maximal integral values to subtract the offset and normate PDF to 1
+ NormateSet(i, j, &minInteg, &maxInteg, integralCount, integralAcc);
+
+ if(acc != nrfiles)
+ {
+ curzval = surfz[i];
+ // PDF and CDF plot
+ PlotEdgeDistribution(files, i, j, &minInteg, &maxInteg, surfxy, integralAcc, direction, edge2d, edit);
+ i--;
+ j = 0;
+ }
+ else
+ {
+ // PDF and CDF plot
+ PlotEdgeDistribution(files, i, j, &minInteg, &maxInteg, surfxy, integralAcc, direction, edge2d, edit);
+ i--;
+ break;
+ }
+ }
+
+ // Update the progress bar
+ progVal = (float)(15.00/nrfiles)*i+75.00;
+ analysisProgress->widgetPB->SetPosition(progVal);
+ gVirtualX->Update(1);
+ }
+
+ // Make the 2D edge plot
+ if(edge2d)
+ {
+ if(edit == 0)
+ gCanvas = new TCanvas("canv","canv",900,900);
+ else
+ gCanvas = tempAnalysisCanvas->GetCanvas();
+
+ double range[4];
+ TGraph2D *gScan2D;
+ gScan2D = new TGraph2D();
+ range[0] = TMath::MinElement(nrfiles, surfxy);
+ range[1] = TMath::MaxElement(nrfiles, surfxy);
+ range[2] = TMath::MinElement(nrfiles, surfz);
+ range[3] = TMath::MaxElement(nrfiles, surfz);
+
+ for(int i = 0; i < nrfiles; i++)
+ {
+ if(DBGSIG)
+ printf("IntegSpectrum(): %.2lf\t%.2lf\t%lf\n", surfxy[i], surfz[i], integralCount[i]);
+ gScan2D->SetPoint(i, surfxy[i], surfz[i], integralCount[i]);
+
+ // Update the progress bar
+ progVal = (float)(9.00/nrfiles)*i+90.00;
+ analysisProgress->widgetPB->SetPosition(progVal);
+ gVirtualX->Update(1);
+ }
+
+ gCanvas->cd();
+ gStyle->SetPalette(1);
+ gCanvas->SetLeftMargin(0.15);
+ gCanvas->SetRightMargin(0.126);
+ gCanvas->SetTopMargin(0.077);
+ gScan2D->Draw("COLZ");
+
+ gCanvas->Modified();
+ gCanvas->Update();
+
+ gScan2D->SetNpx((int)resol2d->widgetNE[0]->GetNumber());
+ gScan2D->SetNpy((int)resol2d->widgetNE[1]->GetNumber());
+
+ gCanvas->Modified();
+ gCanvas->Update();
+
+ if(direction == 1)
+ gScan2D->GetXaxis()->SetTitle("X [#mum]");
+ else if(direction == 2)
+ gScan2D->GetXaxis()->SetTitle("Y [#mum]");
+
+
+ gScan2D->GetXaxis()->SetTitleOffset(1.3);
+ gScan2D->GetXaxis()->CenterTitle(kTRUE);
+ gScan2D->GetXaxis()->SetLabelSize(0.027);
+ gScan2D->GetXaxis()->SetLabelOffset(0.02);
+ gScan2D->GetXaxis()->SetRangeUser(range[0], range[1]);
+ gScan2D->GetXaxis()->SetNoExponent(kTRUE);
+ gScan2D->GetYaxis()->SetTitleOffset(1.9);
+ gScan2D->GetYaxis()->CenterTitle(kTRUE);
+ gScan2D->GetYaxis()->SetLabelSize(0.027);
+ gScan2D->GetXaxis()->SetLabelOffset(0.02);
+ gScan2D->GetYaxis()->SetRangeUser(range[2], range[3]);
+ gScan2D->GetYaxis()->SetNoExponent(kTRUE);
+
+/* TGaxis *yax = (TGaxis*)gScan2D->GetYaxis();
+ yax->SetMaxDigits(4);*/
+
+ if(!cleanPlots)
+ {
+ if(direction == 1)
+ {
+ if(posUnits->widgetCB->GetSelected() == 0)
+ gScan2D->SetTitle("Laser focal point;X [table units];Z [table units]");
+ else if(posUnits->widgetCB->GetSelected() == 1)
+ gScan2D->SetTitle("Laser focal point;X [#mum];Z [#mum]");
+ }
+ else if(direction == 2)
+ {
+ if(posUnits->widgetCB->GetSelected() == 0)
+ gScan2D->SetTitle("Laser focal point;Y [table units];Z [table units]");
+ else if(posUnits->widgetCB->GetSelected() == 1)
+ gScan2D->SetTitle("Laser focal point;Y [#mum];Z [#mum]");
+ }
+ }
+ else
+ {
+ if(direction == 1)
+ {
+ if(posUnits->widgetCB->GetSelected() == 0)
+ gScan2D->SetTitle(";X [table units];Z [table units]");
+ else if(posUnits->widgetCB->GetSelected() == 1)
+ gScan2D->SetTitle(";X [#mum];Z [#mum]");
+ }
+ else if(direction == 2)
+ {
+ if(posUnits->widgetCB->GetSelected() == 0)
+ gScan2D->SetTitle(";Y [table units];Z [table units]");
+ else if(posUnits->widgetCB->GetSelected() == 1)
+ gScan2D->SetTitle(";Y [#mum];Z [#mum]");
+ }
+ }
+
+ gCanvas->Modified();
+ gCanvas->Update();
+
+ remove_from_last((char*)files->At(0)->GetTitle(), '_', ctemp);
+ sprintf(exportname, "%s", ctemp);
+ remove_from_last(exportname, '_', ctemp);
+ if(direction == 1)
+ sprintf(exportname, "%s_xdir_focalpoint.pdf", ctemp);
+ else if(direction == 2)
+ sprintf(exportname, "%s_ydir_focalpoint.pdf", ctemp);
+ gCanvas->SaveAs(exportname);
+
+ // Update the progress bar
+ analysisProgress->widgetPB->SetPosition(100.0);
+ gVirtualX->Update(1);
+
+ if(edit == 0)
+ {
+ delete gScan2D;
+ delete gCanvas;
+ }
+ }
+ else
+ {
+ // Update the progress bar
+ analysisProgress->widgetPB->SetPosition(100.0);
+ gVirtualX->Update(1);
+ }
+ }
+}
+
+void TGAppMainFrame::PlotEdgeDistribution(TList *files, int filenr, int points, double *min, double *max, double *xy, double *integAcc, int axis, bool edge2d, int edit)
+{
+ TGraph *gScan[2];
+ int pdfmax = -1;
+ int count = 0;
+ char ctemp[1024];
+ char exportname[1024];
+ TCanvas *gCanvas;
+
+ // Prepare the CDF plot
+ gScan[1] = new TGraph();
+ for(int i = 0; i < points; i++)
+ {
+ count = filenr - points + i;
+ gScan[1]->SetPoint(i, (double)xy[count], (double)integAcc[i]/(*max));
+ if(DBGSIG) printf("PlotEdgeDistribution(): CDF %d: %lf, %lf\n", i, (double)xy[count], (double)integAcc[i]/(*max));
+
+ if( ((integAcc[i+1]-integAcc[i])/(*max) > pdfmax) && (i < points-1) )
+ pdfmax = (integAcc[i+1]-integAcc[i])/(*max);
+ }
+
+ pdfmax = (TMath::Ceil(pdfmax*10))/10.;
+
+ // Prepare the PDF plot
+ gScan[0] = new TGraph();
+ for(int i = points-1; i >= 0; i--)
+ {
+ count = (filenr-1) - (points-1) + i;
+ // Set any negative values of the PDF to 0
+ if( (integAcc[i]-integAcc[i-1])/(*max) < 0 )
+ gScan[0]->SetPoint(i, (double)xy[count], 0);
+ else
+ gScan[0]->SetPoint(i, (double)xy[count], (integAcc[i]-integAcc[i-1])/(*max));
+ if(DBGSIG) printf("PlotEdgeDistribution(): PDF %d: %lf, %lf\n", i, (double)xy[count], (integAcc[i+1]-integAcc[i])/(*max));
+ }
+
+ remove_from_last((char*)files->At(filenr-1)->GetTitle(), '_', ctemp);
+ sprintf(exportname, "%s_edge.pdf", ctemp);
+
+ if(edit == 0)
+ gCanvas = new TCanvas("canv1d","canv1d",1200,900);
+ else
+ gCanvas = tempAnalysisCanvas->GetCanvas();
+
+ // Fit the PDF with a gaussian
+ gScan[0]->Fit("gaus","Q");
+ gScan[0]->GetFunction("gaus")->SetNpx(400);
+
+ gStyle->SetOptFit(1);
+
+ gScan[1]->Draw("AL");
+ gPad->Update();
+ gScan[0]->Draw("LP");
+
+ gCanvas->Modified();
+ gCanvas->Update();
+
+ TPaveStats *stats = (TPaveStats*)gScan[0]->FindObject("stats");
+ if(!cleanPlots)
+ {
+ stats->SetX1NDC(0.86); stats->SetX2NDC(1.0);
+ stats->SetY1NDC(0.87); stats->SetY2NDC(1.0);
+ }
+ else
+ {
+ stats->SetX1NDC(1.1); stats->SetX2NDC(1.3);
+ stats->SetY1NDC(1.1); stats->SetY2NDC(1.3);
+ }
+
+ gCanvas->SetGridx(1);
+ gCanvas->SetGridy(1);
+ if(axis == 1)
+ gScan[1]->GetXaxis()->SetTitle("X [#mum]");
+ else if(axis == 2)
+ gScan[1]->GetXaxis()->SetTitle("Y [#mum]");
+ gScan[1]->GetXaxis()->SetTitleOffset(1.3);
+ gScan[1]->GetXaxis()->CenterTitle(kTRUE);
+ gScan[1]->GetXaxis()->SetLabelSize(0.027);
+ gScan[1]->GetXaxis()->SetLabelOffset(0.02);
+ gScan[1]->GetXaxis()->SetNoExponent(kTRUE);
+ gScan[1]->GetYaxis()->SetTitle("Normalized ADC integral");
+
+ gScan[1]->GetYaxis()->CenterTitle(kTRUE);
+ gScan[1]->GetYaxis()->SetLabelSize(0.027);
+ gScan[1]->GetYaxis()->SetLabelOffset(0.02);
+ gScan[1]->GetYaxis()->SetRangeUser(0,1);
+ gScan[1]->GetYaxis()->SetTitleOffset(1.4);
+ gScan[1]->GetYaxis()->SetTitleSize(0.030);
+
+ if(!cleanPlots)
+ {
+ if(axis == 1)
+ {
+ if(posUnits->widgetCB->GetSelected() == 0)
+ gScan[1]->SetTitle("SiPM edge detection;X [table units];Normalized ADC integral");
+ else if(posUnits->widgetCB->GetSelected() == 1)
+ gScan[1]->SetTitle("SiPM edge detection;X [#mum];Normalized ADC integral");
+ }
+ else if(axis == 2)
+ {
+ if(posUnits->widgetCB->GetSelected() == 0)
+ gScan[1]->SetTitle("SiPM edge detection;Y [table units];Normalized ADC integral");
+ else if(posUnits->widgetCB->GetSelected() == 1)
+ gScan[1]->SetTitle("SiPM edge detection;Y [#mum];Normalized ADC integral");
+ }
+ }
+ else
+ {
+ if(axis == 1)
+ {
+ if(posUnits->widgetCB->GetSelected() == 0)
+ gScan[1]->SetTitle(";X [table units];Normalized ADC integral");
+ else if(posUnits->widgetCB->GetSelected() == 1)
+ gScan[1]->SetTitle(";X [#mum];Normalized ADC integral");
+ }
+ else if(axis == 2)
+ {
+ if(posUnits->widgetCB->GetSelected() == 0)
+ gScan[1]->SetTitle(";Y [table units];Normalized ADC integral");
+ else if(posUnits->widgetCB->GetSelected() == 1)
+ gScan[1]->SetTitle(";Y [#mum];Normalized ADC integral");
+ }
+ }
+ gScan[1]->SetLineColor(kBlue);
+ gScan[0]->SetLineWidth(2);
+ gScan[1]->SetLineWidth(2);
+
+ gCanvas->Modified();
+ gCanvas->Update();
+
+ gCanvas->SaveAs(exportname);
+
+ // If 2D edge plot, delete the 1D edge plots as we go
+ if(edge2d)
+ {
+ delete gScan[0];
+ delete gScan[1];
+ if(edit == 0)
+ delete gCanvas;
+ }
+ else
+ {
+ if(edit == 0)
+ {
+ delete gScan[0];
+ delete gScan[1];
+ delete gCanvas;
+ }
+ }
+}
+
+void TGAppMainFrame::PhotonMu(TList *files, int edit)
+{
+ unsigned int nrfiles = files->GetSize();
+ char ctemp[1024];
+ char exportname[1024];
+ int j, k = 0, m = 0, n = 0, k2 = 0, m2 = 0;
+
+ TCanvas *gCanvas;
+ TTree *header_data, *meas_data;
+ double *integralCount, *integralPedestal;
+ integralCount = new double[nrfiles];
+ integralPedestal = new double[nrfiles];
+ double *angle, *pdeval, *muval;
+ angle = new double[nrfiles];
+ pdeval = new double[nrfiles];
+ muval = new double[nrfiles];
+
+ // Zero the integral count and accumulated vaules
+ for(int i = 0; i < (int)nrfiles; i++) {integralCount[i] = 0; integralPedestal[i] = 0; }
+
+ // Fitting variables
+ TSpectrum *spec;
+ TH1F *histtemp;
+ TH1 *histback;
+ TH1F *h2;
+ float *xpeaks;
+ TF1 *fit;
+ TF1 *fittingfunc;
+ double *fparam, *fparamerr;
+ double meansel[20];
+ double sigmasel[20];
+ double meanparam, paramsigma;
+ int sortindex[20];
+ int adcpedestal[2];
+ int zeromu = 0;
+ int darkhist = -1;
+
+ double pointest[12];
+ bool exclude = false;
+
+ // Zero the parameter values
+ for(int i = 0; i < 20; i++) {meansel[i] = 0; sigmasel[i] = 0; }
+
+ float progVal = 0;
+ analysisProgress->widgetPB->SetPosition(progVal);
+ gVirtualX->Update(1);
+
+ // Start if we select at least one file
+ if(nrfiles > 0)
+ {
+ for(int i = 0; i < (int)nrfiles; i++)
+ {
+ if(files->At(i))
+ {
+ if(strcmp(files->At(i)->GetTitle(),darkRun->widgetTE->GetText()) == 0)
+ {
+ printf("PhotonMu(): %s is the dark histogram file.\n", files->At(i)->GetTitle());
+ darkhist = i;
+ }
+
+ // Replot the spectrum on analysisCanvas and do not close the input file
+ DisplayHistogram( (char*)(files->At(i)->GetTitle()), 0, 1);
+ analysisCanvas->GetCanvas()->Modified();
+ analysisCanvas->GetCanvas()->Update();
+
+ // Get the spectrum
+ histtemp = (TH1F*)analysisCanvas->GetCanvas()->GetPrimitive(histname);
+ npeaks = 15;
+ double par[300];
+ spec = new TSpectrum(npeaks);
+ // Find spectrum background
+ histback = spec->Background(histtemp, (int)fitInter->widgetNE[0]->GetNumber(), "same");
+ // Clone histogram and subtract background from it if we select that option
+ h2 = (TH1F*)histtemp->Clone("h2");
+ if(fitChecks->widgetChBox[0]->IsDown())
+ h2->Add(histback, -1);
+ // Search for the peaks
+ int found = spec->Search(h2, fitSigma->widgetNE[0]->GetNumber(), "goff", fitTresh->widgetNE[0]->GetNumber() );
+ printf("PhotonMu(): Found %d candidates to fit.\n",found);
+ npeaks = found;
+
+ // Set initial peak parameters
+ xpeaks = spec->GetPositionX();
+ for(j = 0; j < found; j++)
+ {
+ float xp = xpeaks[j];
+ int bin = h2->GetXaxis()->FindBin(xp);
+ float yp = h2->GetBinContent(bin);
+ par[3*j] = yp;
+ par[3*j+1] = xp;
+ par[3*j+2] = (double)fitSigma->widgetNE[0]->GetNumber();
+ }
+
+ // Fit the histogram
+ fit = new TF1("fit", FindPeaks, adcRange->widgetNE[0]->GetNumber(), adcRange->widgetNE[1]->GetNumber(), 3*npeaks);
+ TVirtualFitter::Fitter(histtemp, 3*npeaks);
+ fit->SetParameters(par);
+ fit->SetNpx(300);
+ h2->Fit("fit","Q");
+ // Get the fitted parameters
+ fittingfunc = h2->GetFunction("fit");
+ fparam = fittingfunc->GetParameters();
+ fparamerr = fittingfunc->GetParErrors();
+
+ // Gather the parameters (mean peak value for now)
+ int j = 1;
+ int nrfit = 0;
+ while(1)
+ {
+ if( (fparam[j] < 1.E-30) || (nrfit > 8) )
+ break;
+ else
+ {
+ // Check if pedestal is above the lower limit and sigma is smaller than the mean
+ if( (fparam[j] > pedesLow->widgetNE[0]->GetNumber()) && ((double)fparamerr[j]/fparam[j] < accError->widgetNE[0]->GetNumber()) )
+ {
+ // With the additional ADC offset, we can shift the mean values slightly, so they are not close to the X.5, but to the X.0 values
+ meansel[nrfit] = fparam[j]+(adcOffset->widgetNE[0]->GetNumber());
+ sigmasel[nrfit] = fparam[j+1];
+ nrfit++;
+ }
+ }
+
+ j+=3;
+ }
+ TMath::Sort(nrfit, meansel, sortindex, kFALSE);
+
+ meanparam = meansel[sortindex[0]];
+ paramsigma = sigmasel[sortindex[0]];
+
+ for(j = 0; j < nrfit; j++)
+ if(DBGSIG)
+ printf("PhotonMu(): %d: peak mean = %lf\n", j, meansel[sortindex[j]]);
+
+ j = 0;
+ adcpedestal[0] = 0;
+ adcpedestal[1] = -1;
+
+ while(1)
+ {
+ int bin = histtemp->GetXaxis()->FindBin((int)(j+meanparam+paramsigma));
+ int yp = histtemp->GetBinContent(bin);
+
+ // Check where we get to first minimum after pedestal peak or where we get to the half maximum of the pedestal peak (in case there is only a pedestal peak)
+ if(adcpedestal[1] == -1)
+ {
+ adcpedestal[0] = j+meanparam+paramsigma;
+ adcpedestal[1] = yp;
+ }
+ else
+ {
+ if( (npeaks > 1) && (adcpedestal[1] >= yp) )
+ {
+ adcpedestal[0] = j+meanparam+paramsigma;
+ adcpedestal[1] = yp;
+ }
+ else if( (npeaks == 1) && (adcpedestal[0] < meanparam+5*paramsigma) ) // TODO -> Determining the pedestal when only one peak
+ {
+ adcpedestal[0] = j+meanparam+paramsigma;
+ adcpedestal[1] = yp;
+ }
+ else
+ break;
+ }
+
+ j++;
+ if(j > 50) break;
+ }
+
+ if(npeaks > 1)
+ {
+ int bin = histtemp->GetXaxis()->FindBin((int)(meanparam+meansel[sortindex[1]])/2);
+ adcpedestal[0] = (meanparam+meansel[sortindex[1]])/2;
+ printf("PhotonMu(): multipeak x = %d, ", adcpedestal[0]);
+ adcpedestal[1] = histtemp->GetBinContent(bin);
+ }
+
+ if(midPeak->widgetChBox[0]->IsDown())
+ {
+ if( (meanparam - (int)meanparam >= 0.) && (meanparam - (int)meanparam < 0.5) )
+ m = TMath::Floor(meanparam);
+ else if( (meanparam - (int)meanparam >= 0.5) && (meanparam - (int)meanparam < 1.) )
+ m = TMath::Ceil(meanparam);
+ int bin = histtemp->GetXaxis()->FindBin(m);
+ adcpedestal[0] = m;
+ printf("midpeak x = %d, ", adcpedestal[0]);
+ adcpedestal[1] = histtemp->GetBinContent(bin);
+ }
+
+/* // Option to show the fit
+ fittingfunc->Draw("L SAME");
+ analysisCanvas->GetCanvas()->Modified();
+ analysisCanvas->GetCanvas()->Update();*/
+
+ printf("Pedestal ends = %d and nr. of counts = %d\n", adcpedestal[0], adcpedestal[1]);
+
+ // Delete the opened histogram and spectrum
+ delete spec;
+ delete inroot;
+
+ // Open the input file and read header, ADC and TDC values
+ sprintf(ctemp, "%s", files->At(i)->GetTitle());
+ inroot = new TFile(ctemp, "READ");
+
+ inroot->GetObject("header_data", header_data);
+ inroot->GetObject("meas_data", meas_data);
+
+ // Reading the header
+ if( header_data->FindBranch("angle") )
+ {
+ header_data->SetBranchAddress("angle", &evtheader.angle);
+ header_data->GetEntry(0);
+ }
+ else
+ {
+ printf("PhotonMu(): Error! Selected file has no angle header value. Please edit header to add the angle header value.\n");
+ break;
+ }
+
+ char rdc[256];
+ j = selectCh->widgetNE[0]->GetNumber();
+ double rangetdc[2];
+ rangetdc[0] = tdcRange->widgetNE[0]->GetNumber();
+ rangetdc[1] = tdcRange->widgetNE[1]->GetNumber();
+
+ k = 0;
+ k2 = 0;
+ m = 0;
+ m2 = 0;
+
+ // Reading the data
+ for(int e = 0; e < meas_data->GetEntries(); e++)
+ {
+ sprintf(rdc, "ADC%d", j);
+ meas_data->SetBranchAddress(rdc, &evtdata.adcdata[j]);
+ meas_data->GetEntry(e);
+
+ sprintf(rdc, "TDC%d", j);
+ meas_data->SetBranchAddress(rdc, &evtdata.tdcdata[j]);
+ meas_data->GetEntry(e);
+
+ // If our data point is inside the TDC window
+ if( ((double)evtdata.tdcdata[j]/tdctimeconversion >= rangetdc[0]) && ((double)evtdata.tdcdata[j]/tdctimeconversion <= rangetdc[1]) )
+ {
+ // Gather only the integral of the pedestal
+ if((double)evtdata.adcdata[j] < (double)adcpedestal[0]+0.5 )
+ {
+ k2++;
+ m2 += evtdata.adcdata[j];
+ }
+
+ // Gather the complete integral
+ k++;
+ m += evtdata.adcdata[j];
+ }
+ }
+
+ // Determine the angle, mu and relative PDE
+ angle[i] = (double)(evtheader.angle);
+ integralCount[i] += (double)m;
+ printf("PhotonMu(): %lf: Complete integral (%d evts) = %lf\n", angle[i], k, integralCount[i]);
+ integralPedestal[i] += (double)m2;
+ printf("PhotonMu(): %lf: Pedestal integral (%d evts) = %lf\n", angle[i], k2, integralPedestal[i]);
+ if( (angle[i] == zeroAngle->widgetNE[0]->GetNumber()) && (darkhist != i) )
+ zeromu = i;
+
+ muval[i] = -TMath::Log((double)k2/(double)k);
+ printf("PhotonMu(): %lf: muval = %lf\n", angle[i], muval[i]);
+
+ inroot->Close();
+ delete inroot;
+ }
+
+ // Update the progress bar
+ progVal = (float)(90.00/nrfiles)*i;
+ analysisProgress->widgetPB->SetPosition(progVal);
+ gVirtualX->Update(1);
+ }
+
+ printf("PhotonMu(): %d files were selected.\n", nrfiles);
+
+ printf("PhotonMu(): angle\tmu\trelative PDE\n");
+ m = 0;
+
+ // Set the 0 degree muval, reuse meansel[1]
+ meansel[1] = muval[zeromu];
+ printf("Zero value (id=%d, angle=%lf) = %lf\n", zeromu, angle[zeromu], meansel[1]);
+
+ // TODO - point estimation still not working correctly!
+ for(int i = 0; i < (int)nrfiles; i++)
+ {
+ // Estimate next point and check error (5 point least square fit estimation)
+ if( ((i > 4) && (m == i)) || ((i > 5) && (m < i)) )
+ {
+ // Set exclude signal to false
+ exclude = false;
+
+ // Get next point values (if zero value -> need to add the dark hist value again)
+ pointest[10] = angle[i];
+ pointest[11] = muval[i];
+
+ // Check if next point has larger error than acceptable (if yes, set exclude signal to true), reuse meansel[0]
+ meansel[0] = PointEstimate(5, pointest); // PointEstimate only works with very small step size
+ if(meansel[0] > accError->widgetNE[0]->GetNumber())
+ {
+ printf("PhotonMu(): Point (%lf, %lf) excluded due to error: %lf\n", pointest[10], pointest[11], meansel[0]);
+ exclude = true;
+ }
+
+ // Value with 0 angle and dark histogram are always needed, so should not be excluded
+ if(i == darkhist)
+ exclude = false;
+
+ // If nothing excluded, pass the points in pointest variable like in a FIFO
+ if(!exclude)
+ {
+ for(int j = 0; j < 10; j++)
+ {
+ if(DBGSIG) printf("PhotonMu(): j = %d: Old X value = %lf\n", j, pointest[j]);
+ pointest[j] = pointest[j+2];
+ }
+ }
+ else
+ {
+ for(int j = 0; j < 10; j++)
+ if(DBGSIG) printf("PhotonMu(): No j = %d: Old X value = %lf\n", j, pointest[j]);
+ }
+ }
+ else
+ {
+ // First 5 points act as estimator points for next one
+ pointest[2*m] = angle[i];
+ pointest[2*m+1] = muval[i];
+ }
+
+ // Run only if we have a dark run histogram and middle pedestal peak estimation
+ if( (darkhist != -1) && midPeak->widgetChBox[0]->IsDown() )
+ {
+ if(DBGSIG) printf("PhotonMu(): m = %d, i = %d: muval = %lf, ", m, i, muval[i]);
+
+ // Subtract the dark value from all values
+ angle[m] = angle[i];
+ muval[m] = muval[i] - muval[darkhist];
+
+ if(DBGSIG) printf("angle = %lf, newmuval = %lf, darkmuval = %lf, ", angle[m], muval[m], muval[darkhist]);
+
+ // Calculate relative PDE
+// pdeval[m] = muval[m]/(muval[zeromu]*TMath::Cos(angle[m]*TMath::ACos(-1.)/180.));
+ pdeval[m] = muval[m]/((meansel[1]-muval[darkhist])*TMath::Cos(angle[m]*TMath::ACos(-1.)/180.));
+ if(DBGSIG) printf("pdeval = %lf\n", pdeval[m]);
+
+ // Only increase counter if error is not too big
+ if( (darkhist != i) && (!exclude) )
+ m++;
+ }
+ else
+ {
+ // Relative PDE calculation
+ angle[m] = angle[i];
+ muval[m] = muval[i];
+// pdeval[m] = muval[m]/(muval[zeromu]*TMath::Cos(angle[m]*TMath::ACos(-1.)/180.));
+ pdeval[m] = muval[m]/(meansel[1]*TMath::Cos(angle[m]*TMath::ACos(-1.)/180.));
+
+ // Only increase counter if error is not too big
+ if(!exclude)
+ m++;
+ }
+ printf("PhotonMu(): %lf\t%lf\t%lf\n", angle[i], muval[i], pdeval[i]);
+ }
+
+ if(DBGSIG) printf("\n");
+ if(darkhist != -1)
+ printf("PhotonMu(): Number of excluded points: %d\n", (nrfiles-1-m));
+ else
+ printf("PhotonMu(): Number of excluded points: %d\n", (nrfiles-m));
+
+ // Plot mu and PDE angle dependance plots
+ if(edit == 0)
+ gCanvas = new TCanvas("canv","canv",1200,900);
+ else if(edit == 1)
+ gCanvas = tempAnalysisCanvas->GetCanvas();
+ gCanvas->cd();
+ gCanvas->SetGrid();
+
+ TGraph *pde = new TGraph(m, angle, pdeval);
+ pde->SetMarkerStyle(21);
+ pde->SetMarkerSize(0.7);
+ pde->SetMarkerColor(2);
+ pde->SetLineWidth(1);
+ pde->SetLineColor(2);
+ pde->GetXaxis()->SetLabelSize(0.030);
+ pde->GetXaxis()->CenterTitle();
+// pde->GetXaxis()->SetRange(angle[0],angle[nrfiles-1]);
+// pde->GetXaxis()->SetRangeUser(angle[0],angle[nrfiles-1]);
+ pde->GetXaxis()->SetRange(-90,90);
+ pde->GetXaxis()->SetRangeUser(-90,90);
+ pde->GetXaxis()->SetLimits(-90,90);
+ pde->GetYaxis()->SetTitleOffset(1.2);
+ pde->GetYaxis()->SetLabelSize(0.030);
+ pde->GetYaxis()->CenterTitle();
+ pde->GetYaxis()->SetRangeUser(0., 1.2);
+ pde->SetName("pde");
+ pde->Draw("ALP");
+
+ pde->SetTitle(";Incidence angle (#circ);Relative PDE(#theta) / #mu(#theta)");
+
+ TGraph *mugr = new TGraph(m, angle, muval);
+ mugr->SetMarkerStyle(20);
+ mugr->SetMarkerSize(0.7);
+ mugr->SetMarkerColor(4);
+ mugr->SetLineWidth(1);
+ mugr->SetLineColor(4);
+ mugr->SetName("muval");
+ mugr->Draw("SAME;LP");
+
+ gCanvas->Modified();
+ gCanvas->Update();
+
+ if(edit == 0)
+ {
+ remove_from_last((char*)files->At(0)->GetTitle(), '_', ctemp);
+ sprintf(exportname, "%s_pde.pdf", ctemp);
+ gCanvas->SaveAs(exportname);
+
+ delete mugr;
+ delete pde;
+ delete gCanvas;
+ }
+ else if(edit == 1)
+ {
+ gCanvas->Modified();
+ gCanvas->Update();
+ }
+
+ // Update the progress bar
+ analysisProgress->widgetPB->SetPosition(100.);
+ gVirtualX->Update(1);
+ }
+}
+
+void TGAppMainFrame::BreakdownVolt(TList *files, int edit)
+{
+ unsigned int nrfiles = files->GetSize();
+ char ctemp[1024];
+ char exportname[1024];
+ char paramname[1024];
+ int j, k = 0;
+
+ TCanvas *gCanvas;
+ TTree *header_data, *meas_data;
+
+ // Fitting variables
+ TSpectrum *spec;
+ TH1F *histtemp;
+ TH1 *histback;
+ TH1F *h2;
+ float *xpeaks;
+ TF1 *fit;
+ TF1 *fittingfunc;
+ TLatex *latex;
+ double *fparam, *fparamerr;
+ double meansel[20];
+ double meanselerr[20];
+ double sigmasel[20];
+ double meanparam, meanparamerr, paramsigma;
+ int sortindex[20];
+ bool exclude = false;
+
+ int p = 0;
+ double volt[nrfiles], volterr[nrfiles], sep[3][nrfiles], seperr[3][nrfiles];
+ int first = 1;
+
+ FILE *fp;
+ remove_from_last((char*)files->At(0)->GetTitle(), '_', ctemp);
+ sprintf(paramname, "%s_fitresult.txt", ctemp);
+ fp = fopen(paramname, "w");
+ fclose(fp);
+
+ int peaklimit = minPeak->widgetNE[0]->GetNumber()+1; // +1 to account for the pedestal peak
+
+ // Zero the parameter values
+ for(int i = 0; i < nrfiles; i++)
+ {
+ volt[i] = 0; volterr[i] = 0;
+ sep[0][i] = 0; sep[1][i] = 0; sep[2][i] = 0;
+ seperr[0][i] = 0; seperr[1][i] = 0; seperr[2][i] = 0;
+ if(i < 20) { meansel[i] = 0; meanselerr[i] = 0; sigmasel[i] = 0; }
+ }
+
+ float progVal = 0;
+ analysisProgress->widgetPB->SetPosition(progVal);
+ gVirtualX->Update(1);
+
+ // Start if we select at least one file
+ if(nrfiles > 0)
+ {
+ for(int i = 0; i < (int)nrfiles; i++)
+ {
+ if(files->At(i))
+ {
+ // Replot the spectrum on analysisCanvas and do not close the input file
+ DisplayHistogram( (char*)(files->At(i)->GetTitle()), 0, 1);
+ analysisCanvas->GetCanvas()->Modified();
+ analysisCanvas->GetCanvas()->Update();
+
+ // Get the spectrum
+ histtemp = (TH1F*)analysisCanvas->GetCanvas()->GetPrimitive(histname);
+ npeaks = 15;
+ double par[300];
+ spec = new TSpectrum(npeaks);
+ // Find spectrum background
+ histback = spec->Background(histtemp, (int)fitInter->widgetNE[0]->GetNumber(), "same");
+ // Clone histogram and subtract background from it if we select that option
+ h2 = (TH1F*)histtemp->Clone("h2");
+ if(fitChecks->widgetChBox[0]->IsDown())
+ h2->Add(histback, -1);
+ // Search for the peaks
+ int found = spec->Search(h2, fitSigma->widgetNE[0]->GetNumber(), "goff", fitTresh->widgetNE[0]->GetNumber() );
+ printf("BreakdownVolt(): Found %d candidates to fit.\n",found);
+ npeaks = found;
+
+ // Set initial peak parameters
+ xpeaks = spec->GetPositionX();
+ for(j = 0; j < found; j++)
+ {
+ float xp = xpeaks[j];
+ int bin = h2->GetXaxis()->FindBin(xp);
+ float yp = h2->GetBinContent(bin);
+ par[3*j] = yp;
+ par[3*j+1] = xp;
+ par[3*j+2] = (double)fitSigma->widgetNE[0]->GetNumber();
+ }
+
+ // Fit the histogram
+ fit = new TF1("fit", FindPeaks, adcRange->widgetNE[0]->GetNumber(), adcRange->widgetNE[1]->GetNumber(), 3*npeaks);
+ TVirtualFitter::Fitter(histtemp, 3*npeaks);
+ fit->SetParameters(par);
+ fit->SetNpx(300);
+ h2->Fit("fit","Q");
+ // Get the fitted parameters
+ fittingfunc = h2->GetFunction("fit");
+ if(nrfiles == 1) // TODO: Show the fit if only one file is selected
+ fittingfunc->Draw("SAME");
+ fparam = fittingfunc->GetParameters();
+ fparamerr = fittingfunc->GetParErrors();
+
+ // Gather the parameters (mean peak value for now)
+ int j = 1;
+ int nrfit = 0;
+ while(1)
+ {
+ if( (fparam[j] < 1.E-30) || (fparamerr[j] < 1.E-10) )// TODO: Maybe not correct for the error
+ break;
+ else
+ {
+ // Check if pedestal is above the lower limit and sigma is smaller than the mean
+ if( (fparam[j] > pedesLow->widgetNE[0]->GetNumber()) && ((double)fparamerr[j]/fparam[j] < accError->widgetNE[0]->GetNumber()) )
+ {
+ meansel[nrfit] = fparam[j];
+ meanselerr[nrfit] = fparamerr[j];
+ sigmasel[nrfit] = fparam[j+1];
+ nrfit++;
+ }
+ }
+
+ j+=3;
+ }
+ TMath::Sort(nrfit, meansel, sortindex, kFALSE);
+
+ meanparam = meansel[sortindex[0]];
+ meanparamerr = meanselerr[sortindex[0]];
+ paramsigma = sigmasel[sortindex[0]];
+
+ for(j = 0; j < nrfit; j++)
+ {
+ if(DBGSIG)
+ printf("BreakdownVolt(): %d: peak mean = %lf, peak err = %lf\n", j, meansel[sortindex[j]], meanselerr[sortindex[j]]);
+ }
+
+ // Delete the opened histogram and spectrum
+ delete spec;
+ delete inroot;
+
+ // Open the input file and read header, ADC and TDC values
+ sprintf(ctemp, "%s", files->At(i)->GetTitle());
+ inroot = new TFile(ctemp, "READ");
+
+ inroot->GetObject("header_data", header_data);
+ inroot->GetObject("meas_data", meas_data);
+
+ // Reading the header
+ if( header_data->FindBranch("biasvolt") )
+ {
+ header_data->SetBranchAddress("biasvolt", &evtheader.biasvolt);
+ header_data->GetEntry(0);
+ }
+ else
+ {
+ printf("BreakdownVolt(): Error! Selected file has no bias voltage header value. Please edit header to add the bias voltage header value.\n");
+ break;
+ }
+
+// h2->SetStats(0);
+
+ analysisCanvas->GetCanvas()->Modified();
+ analysisCanvas->GetCanvas()->Update();
+
+ // Save each fitting plot
+ if(fitChecks->widgetChBox[1]->IsDown()) // TODO: Check if this works
+ {
+ remove_ext((char*)files->At(i)->GetTitle(), ctemp);
+ sprintf(exportname, "%s_fit.pdf", ctemp);
+ analysisCanvas->GetCanvas()->SaveAs(exportname);
+ }
+
+ // Calculate the separation between peaks
+ volt[p] = evtheader.biasvolt;
+ volterr[p] = 1.e-5;
+
+ if(nrfit == 3)
+ {
+ sep[0][p] = meansel[sortindex[2]] - meansel[sortindex[1]];
+ seperr[0][p] = TMath::Abs(meanselerr[sortindex[2]]) + TMath::Abs(meanselerr[sortindex[1]]);
+
+ exclude = (seperr[0][p]/sep[0][p] < accError->widgetNE[0]->GetNumber());
+ }
+ else if(nrfit == 4)
+ {
+ sep[0][p] = meansel[sortindex[2]] - meansel[sortindex[1]];
+ sep[1][p] = meansel[sortindex[3]] - meansel[sortindex[2]];
+ seperr[0][p] = TMath::Abs(meanselerr[sortindex[2]]) + TMath::Abs(meanselerr[sortindex[1]]);
+ seperr[1][p] = TMath::Abs(meanselerr[sortindex[3]]) + TMath::Abs(meanselerr[sortindex[2]]);
+
+ exclude = ((seperr[0][p]/sep[0][p] < accError->widgetNE[0]->GetNumber()) && (seperr[1][p]/sep[1][p] < accError->widgetNE[0]->GetNumber()));
+ }
+ else if(nrfit > 4)
+ {
+ sep[0][p] = meansel[sortindex[2]] - meansel[sortindex[1]];
+ sep[1][p] = meansel[sortindex[3]] - meansel[sortindex[2]];
+ sep[2][p] = meansel[sortindex[4]] - meansel[sortindex[3]];
+ seperr[0][p] = TMath::Abs(meanselerr[sortindex[2]]) + TMath::Abs(meanselerr[sortindex[1]]);
+ seperr[1][p] = TMath::Abs(meanselerr[sortindex[3]]) + TMath::Abs(meanselerr[sortindex[2]]);
+ seperr[2][p] = TMath::Abs(meanselerr[sortindex[4]]) + TMath::Abs(meanselerr[sortindex[3]]);
+
+ exclude = ((seperr[0][p]/sep[0][p] < accError->widgetNE[0]->GetNumber()) && (seperr[1][p]/sep[1][p] < accError->widgetNE[0]->GetNumber()) && (seperr[2][p]/sep[2][p] < accError->widgetNE[0]->GetNumber()));
+ }
+ else
+ {
+ printf("BreakdownVolt(): The current separation measurements does not fall within acceptable errors.\n");
+ exclude = false;
+ }
+
+ // Write out parameters to a file
+ fp = fopen(paramname, "a");
+ if(exclude)
+ {
+ if(first == 1)
+ {
+ fprintf(fp, "%le\t%d\t", evtheader.biasvolt, nrfit);
+ for(j = 0; j < nrfit; j++)
+ fprintf(fp, "%le\t%le\t", meansel[sortindex[j]], meanselerr[sortindex[j]]);
+ fprintf(fp,"\n");
+ first = 0;
+ }
+ p++;
+ }
+ else
+ {
+ if(nrfit == 3)
+ printf("Point (at %.2lfV) rejected due to too large errors: %lf\n", volt[p], seperr[0][p]/sep[0][p]);
+ else if(nrfit == 4)
+ printf("Point (at %.2lfV) rejected due to too large errors: %lf, %lf\n", volt[p], seperr[0][p]/sep[0][p], seperr[1][p]/sep[1][p]);
+ else if(nrfit > 4)
+ printf("Point (at %.2lfV) rejected due to too large errors: %lf, %lf, %lf\n", volt[p], seperr[0][p]/sep[0][p], seperr[1][p]/sep[1][p], seperr[2][p]/sep[2][p]);
+ }
+ fclose(fp);
+ }
+
+ if(nrfiles == 1) break;
+ first = 1;
+
+ // Update the progress bar
+ progVal = (float)(90.00/nrfiles)*i;
+ analysisProgress->widgetPB->SetPosition(progVal);
+ gVirtualX->Update(1);
+ }
+
+ printf("BreakdownVolt(): %d files were selected.\n", nrfiles);
+ printf("BreakdownVolt(): Number of points to plot is %d\n", p);
+
+ // Plot and fit breakdown voltage plot
+ if(edit == 0)
+ gCanvas = new TCanvas("canv","canv",1200,900);
+ else if(edit == 1)
+ gCanvas = tempAnalysisCanvas->GetCanvas();
+ gCanvas->cd();
+ gCanvas->SetGrid();
+
+ TGraphErrors* bdplot;
+ k = peakSepCalc->widgetNE[0]->GetNumber();
+ if(k < 4)
+ bdplot = new TGraphErrors(p, volt, sep[k-1], volterr, seperr[k-1]);
+ else
+ {
+ printf("BreakdownVold(): Unsupported peak separation selected (%d).\n", k);
+ return;
+ }
+
+ bdplot->SetMarkerStyle(20);
+ bdplot->SetMarkerSize(0.4);
+ bdplot->SetMarkerColor(kBlue);
+ bdplot->SetLineWidth(1);
+ bdplot->SetLineColor(kBlue);
+ bdplot->GetXaxis()->SetLabelSize(0.030);
+ bdplot->GetXaxis()->CenterTitle();
+// bdplot->GetXaxis()->SetRange(-90,90);
+// bdplot->GetXaxis()->SetRangeUser(-90,90);
+// bdplot->GetXaxis()->SetLimits(-90,90);
+ bdplot->GetYaxis()->SetTitleOffset(1.2);
+ bdplot->GetYaxis()->SetLabelSize(0.030);
+ bdplot->GetYaxis()->CenterTitle();
+// bdplot->GetYaxis()->SetRangeUser(0., 1.2);
+ bdplot->SetName("bdplot");
+ bdplot->Draw("AP");
+ bdplot->SetTitle(";Bias voltage (V);Peak separation");
+
+ // Fit the breakdown voltage plot with a line
+ bdplot->Fit("pol1","Q");
+
+ TF1 *fit1 = bdplot->GetFunction("pol1");
+ meansel[0] = fit1->GetParameter(0);
+ meanselerr[0] = fit1->GetParError(0);
+ meansel[1] = fit1->GetParameter(1);
+ meanselerr[1] = fit1->GetParError(1);
+
+ meansel[2] = -meansel[0]/meansel[1];
+ if(!cleanPlots)
+ {
+ sprintf(ctemp, "#splitline{#Delta_{p}(U) = (%.2lf #pm %.2lf)#timesU + (%.2lf #pm %.3lf)}{U_{0} = %.2lf #pm %.3lf}", meansel[0], meanselerr[0], meansel[1], meanselerr[1], meansel[2], meansel[2]*(TMath::Abs(meanselerr[0]/meansel[0]) + TMath::Abs(meanselerr[1]/meansel[1])) );
+ latex = new TLatex();
+ latex->SetTextSize(0.039);
+ latex->DrawLatex(volt[0], 0.97*sep[0][sortindex[p-1]], ctemp);
+ }
+ else
+ printf("#Delta_{p}(U) = (%.2lf #pm %.2lf)#timesU + (%.2lf #pm %.3lf)}{U_{0} = %.2lf #pm %.3lf", meansel[0], meanselerr[0], meansel[1], meanselerr[1], meansel[2], meansel[2]*(TMath::Abs(meanselerr[0]/meansel[0]) + TMath::Abs(meanselerr[1]/meansel[1])) );
+
+ if(edit == 0)
+ {
+ remove_from_last((char*)files->At(0)->GetTitle(), '_', ctemp);
+ sprintf(exportname, "%s_breakdown.pdf", ctemp);
+ gCanvas->SaveAs(exportname);
+
+ delete bdplot;
+ delete gCanvas;
+ }
+ else if(edit == 1)
+ {
+ gCanvas->Modified();
+ gCanvas->Update();
+ }
+
+ // Update the progress bar
+ analysisProgress->widgetPB->SetPosition(100.);
+ gVirtualX->Update(1);
+ }
+}
+
+void TGAppMainFrame::SurfaceScan(TList *files, int edit)
+{
+ unsigned int nrfiles = files->GetSize();
+ char ctemp[1024];
+ char exportname[1024];
+ int j, k = 0, m = 0, n = 0;
+
+ TTree *header_data, *meas_data;
+ double *integralCount;
+ integralCount = new double[nrfiles];
+ double *surfx, *surfy;
+ surfx = new double[nrfiles];
+ surfy = new double[nrfiles];
+ double xsurfmin = 0, ysurfmin = 0;
+ int nrentries;
+// double minInteg, maxInteg;
+ bool norm = surfScanOpt->widgetChBox[0]->IsDown();
+// double curzval;
+// bool edge2d = false;
+
+ TCanvas *gCanvas;
+
+ float progVal = 0;
+ analysisProgress->widgetPB->SetPosition(progVal);
+ gVirtualX->Update(1);
+
+ // Zero the integral count and accumulated vaules
+ for(int i = 0; i < (int)nrfiles; i++) integralCount[i] = 0;
+
+ // Start if we select at more than one file
+ if( (nrfiles > 1) && (multiSelect->widgetChBox[0]->IsOn()) )
+ {
+ printf("SurfaceScan(): Creating a surface plot. Please wait...\n");
+ for(int i = 0; i < (int)nrfiles; i++)
+ {
+ if(files->At(i))
+ {
+ n++;
+ // Read the X and Y positions from header and ADC and TDC values from the measurements
+ sprintf(ctemp, "%s", files->At(i)->GetTitle());
+ inroot = new TFile(ctemp, "READ");
+
+ inroot->GetObject("header_data", header_data);
+ inroot->GetObject("meas_data", meas_data);
+
+ header_data->SetBranchAddress("xpos", &evtheader.xpos);
+ header_data->GetEntry(0);
+ header_data->SetBranchAddress("ypos", &evtheader.ypos);
+ header_data->GetEntry(0);
+
+ char rdc[256];
+ j = selectCh->widgetNE[0]->GetNumber();
+ double rangetdc[2];
+ rangetdc[0] = tdcRange->widgetNE[0]->GetNumber();
+ rangetdc[1] = tdcRange->widgetNE[1]->GetNumber();
+
+ k = 0;
+ m = 0;
+
+ // Reading the data
+ for(int e = 0; e < meas_data->GetEntries(); e++)
+ {
+ sprintf(rdc, "ADC%d", j);
+ meas_data->SetBranchAddress(rdc, &evtdata.adcdata[j]);
+ meas_data->GetEntry(e);
+
+ sprintf(rdc, "TDC%d", j);
+ meas_data->SetBranchAddress(rdc, &evtdata.tdcdata[j]);
+ meas_data->GetEntry(e);
+
+ // Use data point only if it is inside the TDC window
+ if( ((double)evtdata.tdcdata[j]/tdctimeconversion >= rangetdc[0]) && ((double)evtdata.tdcdata[j]/tdctimeconversion <= rangetdc[1]) )
+ {
+ k++;
+ m += evtdata.adcdata[j];
+ }
+ }
+
+ // X, Y and Z values from each file (table units or microns)
+ if(posUnits->widgetCB->GetSelected() == 0)
+ {
+ if(n == 1)
+ {
+ xsurfmin = (double)(evtheader.xpos);
+ ysurfmin = (double)(evtheader.ypos);
+ }
+
+ surfx[i] = (double)(evtheader.xpos);
+ surfy[i] = (double)(evtheader.ypos);
+ }
+ else if(posUnits->widgetCB->GetSelected() == 1)
+ {
+ if(n == 1)
+ {
+ xsurfmin = (double)(evtheader.xpos*lenconversion);
+ ysurfmin = (double)(evtheader.ypos*lenconversion);
+ }
+
+ surfx[i] = (double)(evtheader.xpos*lenconversion);
+ surfy[i] = (double)(evtheader.ypos*lenconversion);
+ }
+
+ // Save result for later plotting
+ if(norm)
+ integralCount[i] += ((double)m)/((double)k);
+ else
+ integralCount[i] += m;
+
+ inroot->Close();
+ delete inroot;
+ }
+
+ // Update the progress bar
+ progVal = (float)(75.00/nrfiles)*i;
+ analysisProgress->widgetPB->SetPosition(progVal);
+ gVirtualX->Update(1);
+ }
+
+ nrentries = n;
+ printf("SurfaceScan(): %d files were selected.\n", nrfiles);
+
+// // If only an integral is needed, do not plot and exit here
+// if( direction == 0 )
+// {
+// delete[] integralCount;
+// delete[] surfxy;
+// delete[] surfz;
+// return;
+// }
+//
+// // Current z value and the accumulated counter
+// curzval = surfz[0];
+// j = 0;
+// int acc = 0;
+// int zb;
+// for(int i = 0; i <= (int)nrfiles; i++)
+// {
+// // Collect the accumulated integral in order to produce a PDF from a CDF
+// // While we are at the same Z value, save under one set
+// if( (surfz[i] == curzval) && (acc != nrfiles) )
+// {
+// integralAcc[j] = integralCount[i];
+// if(DBGSIG) printf("IntegSpectrum(): Integral check 1 (i=%d,j=%d,z=%.2lf): %lf\t%lf\n", i, j, surfz[i], integralCount[i], integralAcc[j]);
+// j++;
+// acc++;
+// }
+// // When we switch to a new set of Z values and at the end, we must save the previous ones to make 1D edge plots
+// else
+// {
+// // Find minimal and maximal integral values to subtract the offset and normate PDF to 1
+// NormateSet(i, j, &minInteg, &maxInteg, integralCount, integralAcc);
+//
+// if(acc != nrfiles)
+// {
+// curzval = surfz[i];
+// // PDF and CDF plot
+// PlotEdgeDistribution(files, i, j, &minInteg, &maxInteg, surfxy, integralAcc, direction, edge2d, edit);
+// i--;
+// j = 0;
+// }
+// else
+// {
+// // PDF and CDF plot
+// PlotEdgeDistribution(files, i, j, &minInteg, &maxInteg, surfxy, integralAcc, direction, edge2d, edit);
+// i--;
+// break;
+// }
+// }
+//
+// // Update the progress bar
+// progVal = (float)(15.00/nrfiles)*i+75.00;
+// analysisProgress->widgetPB->SetPosition(progVal);
+// gVirtualX->Update(1);
+// }
+
+ // Make the 2D surface plot
+ if(edit == 0)
+ gCanvas = new TCanvas("canv","canv",1100,900);
+ else
+ gCanvas = tempAnalysisCanvas->GetCanvas();
+
+ double range[4];
+ TGraph2D *gScan2D;
+ gScan2D = new TGraph2D();
+ range[0] = TMath::MinElement(nrfiles, surfx);
+ range[1] = TMath::MaxElement(nrfiles, surfx);
+ range[2] = TMath::MinElement(nrfiles, surfy);
+ range[3] = TMath::MaxElement(nrfiles, surfy);
+
+ for(int i = 0; i < nrfiles; i++)
+ {
+ if(DBGSIG)
+ {
+ if(surfScanOpt->widgetChBox[1]->IsDown())
+ printf("SurfaceScan(): %.2lf\t%.2lf\t%lf\n", surfx[i]-range[0], surfy[i]-range[2], integralCount[i]);
+ else
+ printf("SurfaceScan(): %.2lf\t%.2lf\t%lf\n", surfx[i], surfy[i], integralCount[i]);
+ }
+
+ if(surfScanOpt->widgetChBox[1]->IsDown())
+ gScan2D->SetPoint(i, surfx[i]-range[0], surfy[i]-range[2], integralCount[i]);
+ else
+ gScan2D->SetPoint(i, surfx[i], surfy[i], integralCount[i]);
+
+ // Update the progress bar
+ progVal = (float)(9.00/nrfiles)*i+90.00;
+ analysisProgress->widgetPB->SetPosition(progVal);
+ gVirtualX->Update(1);
+ }
+
+ if(surfScanOpt->widgetChBox[1]->IsDown())
+ {
+ range[1] -= range[0];
+ range[3] -= range[2];
+ range[0] -= range[0];
+ range[2] -= range[2];
+ }
+
+ gCanvas->cd();
+ gStyle->SetPalette(1);
+ gCanvas->SetLeftMargin(0.15);
+ gCanvas->SetRightMargin(0.126);
+ gCanvas->SetTopMargin(0.077);
+ gScan2D->Draw("COLZ");
+
+ gCanvas->Modified();
+ gCanvas->Update();
+
+ if(!cleanPlots)
+ {
+ if(posUnits->widgetCB->GetSelected() == 0)
+ gScan2D->SetTitle("Surface scan;X [table units];Y [table units]");
+ else if(posUnits->widgetCB->GetSelected() == 1)
+ gScan2D->SetTitle("Surface scan;X [#mum];Y [#mum]");
+ }
+ else
+ {
+ if(posUnits->widgetCB->GetSelected() == 0)
+ gScan2D->SetTitle(";X [table units];Y [table units]");
+ else if(posUnits->widgetCB->GetSelected() == 1)
+ gScan2D->SetTitle(";X [#mum];Y [#mum]");
+ }
+/* TGaxis *xax = (TGaxis*)gScan2D->GetXaxis();
+ xax->SetMaxDigits(4);
+ TGaxis *yax = (TGaxis*)gScan2D->GetYaxis();
+ yax->SetMaxDigits(4);*/
+
+ gScan2D->SetNpx((int)resolSurf->widgetNE[0]->GetNumber());
+ gScan2D->SetNpy((int)resolSurf->widgetNE[1]->GetNumber());
+
+ gCanvas->Modified();
+ gCanvas->Update();
+
+ gScan2D->GetXaxis()->SetTitleOffset(1.3);
+ gScan2D->GetXaxis()->CenterTitle(kTRUE);
+ gScan2D->GetXaxis()->SetLabelSize(0.027);
+ gScan2D->GetXaxis()->SetLabelOffset(0.02);
+ gScan2D->GetXaxis()->SetRangeUser(range[0], range[1]);
+ gScan2D->GetXaxis()->SetNoExponent(kTRUE);
+ gScan2D->GetYaxis()->SetTitleOffset(1.9);
+ gScan2D->GetYaxis()->CenterTitle(kTRUE);
+ gScan2D->GetYaxis()->SetLabelSize(0.027);
+ gScan2D->GetXaxis()->SetLabelOffset(0.02);
+ gScan2D->GetYaxis()->SetRangeUser(range[2], range[3]);
+ gScan2D->GetYaxis()->SetNoExponent(kTRUE);
+
+ gCanvas->Modified();
+ gCanvas->Update();
+
+ remove_from_last((char*)files->At(0)->GetTitle(), '_', ctemp);
+ sprintf(exportname, "%s_surfscan.pdf", ctemp);
+ gCanvas->SaveAs(exportname);
+
+ // Update the progress bar
+ analysisProgress->widgetPB->SetPosition(100.0);
+ gVirtualX->Update(1);
+
+ if(edit == 0)
+ {
+ delete gScan2D;
+ delete gCanvas;
+ }
+ else if(edit == 1)
+ {
+ gCanvas->Modified();
+ gCanvas->Update();
+ }
+ }
+}
Index: sipmscan/trunk/src/connections.cpp
===================================================================
--- sipmscan/trunk/src/connections.cpp (nonexistent)
+++ sipmscan/trunk/src/connections.cpp (revision 146)
@@ -0,0 +1,2249 @@
+#include "../include/sipmscan.h"
+#include "../include/workstation.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+int retTemp;
+
+// Additional functions -------------------------------------
+
+// Display the currently selected histogram in the file list
+void TGAppMainFrame::DisplayHistogram(char *histfile, int histtype, int opt)
+{
+ char histtime[256];
+ char ctemp[512];
+
+ if(DBGSIG)
+ printf("DisplayHistogram(): Selected file: %s\n", histfile);
+
+ TCanvas *gCanvas = analysisCanvas->GetCanvas();
+
+ inroot = TFile::Open(histfile, "READ");
+
+ TTree *header_data, *meas_data;
+ inroot->GetObject("header_data", header_data);
+ inroot->GetObject("meas_data", meas_data);
+
+ // Reading the header
+ header_data->SetBranchAddress("nrch", &evtheader.nrch);
+ header_data->GetEntry(0);
+ header_data->SetBranchAddress("timestamp", &evtheader.timestamp);
+ header_data->GetEntry(0);
+ header_data->SetBranchAddress("biasvolt", &evtheader.biasvolt);
+ header_data->GetEntry(0);
+ header_data->SetBranchAddress("xpos", &evtheader.xpos);
+ header_data->GetEntry(0);
+ header_data->SetBranchAddress("ypos", &evtheader.ypos);
+ header_data->GetEntry(0);
+ header_data->SetBranchAddress("zpos", &evtheader.zpos);
+ header_data->GetEntry(0);
+ header_data->SetBranchAddress("temperature", &evtheader.temperature);
+ header_data->GetEntry(0);
+ if( header_data->FindBranch("angle") )
+ {
+ header_data->SetBranchAddress("angle", &evtheader.angle);
+ header_data->GetEntry(0);
+ }
+ header_data->SetBranchAddress("laserinfo", &evtheader.laserinfo);
+ header_data->GetEntry(0);
+
+ // Change timestamp to local time
+ GetTime(evtheader.timestamp, histtime);
+
+ // Displaying header information debug
+ if(DBGSIG)
+ {
+ printf("DisplayHistogram(): Opened file header information:\n");
+ printf("- Number of channels (ADC and TDC are considered as separate channels): %d\n", evtheader.nrch);
+ printf("- Timestamp: %d (%s)\n", evtheader.timestamp, histtime);
+ printf("- Bias voltage: %lf\n", evtheader.biasvolt);
+ printf("- Table position (X,Y,Z): %d, %d, %d\n", evtheader.xpos, evtheader.ypos, evtheader.zpos);
+ if(evtheader.temperature)
+ printf("- Temperature: %lf\n", evtheader.temperature);
+ if( header_data->FindBranch("angle") )
+ printf("- Incidence angle: %lf\n", evtheader.angle);
+ else
+ printf("- Incidence angle: No angle information!\n");
+ printf("- Laser and filter settings: %s\n", evtheader.laserinfo);
+ }
+
+ // Displaying header information on the GUI
+ dispTime->widgetTE->SetText(histtime);
+ dispBias->widgetNE[0]->SetNumber(evtheader.biasvolt);
+ sprintf(ctemp, "%d, %d, %d", evtheader.xpos, evtheader.ypos, evtheader.zpos);
+ dispPos->widgetTE->SetText(ctemp);
+ if(evtheader.temperature)
+ dispTemp->widgetNE[0]->SetNumber(evtheader.temperature);
+ else
+ dispTemp->widgetNE[0]->SetNumber(0.0);
+ if( header_data->FindBranch("angle") )
+ dispAngle->widgetNE[0]->SetNumber(evtheader.angle);
+ else
+ dispAngle->widgetNE[0]->SetNumber(0.0);
+ dispLaser->widgetTE->SetText(evtheader.laserinfo);
+
+ selectCh->widgetNE[0]->SetLimitValues(0, (evtheader.nrch/2)-1);
+
+ // Redraw the histograms
+ int j;
+ char rdc[256];
+ char rdcsel[256];
+
+ j = selectCh->widgetNE[0]->GetNumber();
+
+ printf("Found %d data points.\n", (int)meas_data->GetEntries());
+
+ gCanvas->cd();
+ double range[4];
+ range[0] = adcRange->widgetNE[0]->GetNumber();
+ range[1] = adcRange->widgetNE[1]->GetNumber();
+ range[2] = tdcRange->widgetNE[0]->GetNumber();
+ range[3] = tdcRange->widgetNE[1]->GetNumber();
+
+ // ADC histogram
+ if(histtype == 0)
+ {
+ if( range[0] == range[1] )
+ sprintf(rdc, "ADC%d>>%s", j, histname);
+ else
+ sprintf(rdc, "ADC%d>>%s(%d,%lf,%lf)", j, histname, (int)(range[1]-range[0]), range[0]-0.5, range[1]-0.5);
+
+ sprintf(rdcsel, "(TDC%d>%lf)&&(TDC%d<%lf)", j, range[2]*tdctimeconversion, j, range[3]*tdctimeconversion);
+ meas_data->Draw(rdc, rdcsel);
+
+ sprintf(rdc, "ADC%d, Vbias=%.3lf, TDC=(%.2lf,%.2lf);ADC;", j, evtheader.biasvolt, range[2], range[3]);
+ TH1F *histtemp = (TH1F*)gCanvas->GetPrimitive(histname);
+ if(!cleanPlots)
+ histtemp->SetTitle(rdc);
+ else
+ histtemp->SetTitle(";ADC;");
+ histtemp->GetXaxis()->SetLabelSize(0.025);
+ histtemp->GetXaxis()->CenterTitle(kTRUE);
+ histtemp->GetYaxis()->SetLabelSize(0.025);
+ if(cleanPlots)
+ {
+ TGaxis *yax = (TGaxis*)histtemp->GetYaxis();
+ yax->SetMaxDigits(4);
+ }
+
+ gCanvas->Modified();
+ gCanvas->Update();
+
+ if( yRange->widgetNE[0]->GetNumber() != yRange->widgetNE[1]->GetNumber() )
+ {
+ if( (histOpt->widgetChBox[0]->IsDown()) && (yRange->widgetNE[0]->GetNumber() <= 0) )
+ {
+ histtemp->GetYaxis()->SetRangeUser(0.5, yRange->widgetNE[1]->GetNumber());
+ yRange->widgetNE[0]->SetNumber(0.5);
+ logChange = 1;
+ }
+ else
+ {
+ gCanvas->SetLogy(kFALSE);
+ if(logChange == 1)
+ {
+ yRange->widgetNE[0]->SetNumber(0.0);
+ logChange = 0;
+ }
+ histtemp->GetYaxis()->SetRangeUser(yRange->widgetNE[0]->GetNumber(), yRange->widgetNE[1]->GetNumber());
+ }
+ }
+
+ TPaveStats *stats = (TPaveStats*)histtemp->FindObject("stats");
+ if(!cleanPlots)
+ {
+ stats->SetX1NDC(0.84); stats->SetX2NDC(0.97);
+ stats->SetY1NDC(0.87); stats->SetY2NDC(0.97);
+ }
+ else
+ {
+ stats->SetX1NDC(1.1); stats->SetX2NDC(1.3);
+ stats->SetY1NDC(1.1); stats->SetY2NDC(1.3);
+ }
+ }
+ // TDC histogram
+ else if(histtype == 1)
+ {
+ if( range[0] == range[1] )
+ sprintf(rdc, "(TDC%d/%lf)>>%s", j, tdctimeconversion, histname);
+ else
+ sprintf(rdc, "(TDC%d/%lf)>>%s(%d,%lf,%lf)", j, tdctimeconversion, histname, (int)((range[3]-range[2])*tdctimeconversion), range[2], range[3]);
+
+ sprintf(rdcsel, "(TDC%d>%lf)&&(TDC%d<%lf)", j, range[2]*tdctimeconversion, j, range[3]*tdctimeconversion);
+ meas_data->Draw(rdc, rdcsel);
+
+ sprintf(rdc, "TDC%d, Vbias=%.3lf, TDC=(%.2lf,%.2lf);Time (TDC channel) [ns];", j, evtheader.biasvolt, range[2], range[3]);
+ TH1F *histtemp = (TH1F*)gCanvas->GetPrimitive(histname);
+ if(!cleanPlots)
+ histtemp->SetTitle(rdc);
+ else
+ histtemp->SetTitle(";Time (TDC channel) [ns];");
+ histtemp->GetXaxis()->SetLabelSize(0.025);
+ histtemp->GetXaxis()->CenterTitle(kTRUE);
+ histtemp->GetYaxis()->SetLabelSize(0.025);
+ if(cleanPlots)
+ {
+ TGaxis *yax = (TGaxis*)histtemp->GetYaxis();
+ yax->SetMaxDigits(4);
+ }
+
+ gCanvas->Modified();
+ gCanvas->Update();
+
+ if( yRange->widgetNE[0]->GetNumber() != yRange->widgetNE[1]->GetNumber() )
+ {
+ if( (histOpt->widgetChBox[0]->IsDown()) && (yRange->widgetNE[0]->GetNumber() <= 0) )
+ {
+ histtemp->GetYaxis()->SetRangeUser(0.5, yRange->widgetNE[1]->GetNumber());
+ yRange->widgetNE[0]->SetNumber(0.5);
+ logChange = 1;
+ }
+ else
+ {
+ gCanvas->SetLogy(kFALSE);
+ if(logChange == 1)
+ {
+ yRange->widgetNE[0]->SetNumber(0.0);
+ logChange = 0;
+ }
+ histtemp->GetYaxis()->SetRangeUser(yRange->widgetNE[0]->GetNumber(), yRange->widgetNE[1]->GetNumber());
+ }
+ }
+
+ TPaveStats *stats = (TPaveStats*)histtemp->FindObject("stats");
+ if(!cleanPlots)
+ {
+ stats->SetX1NDC(0.84); stats->SetX2NDC(0.97);
+ stats->SetY1NDC(0.87); stats->SetY2NDC(0.97);
+ }
+ else
+ {
+ stats->SetX1NDC(1.1); stats->SetX2NDC(1.3);
+ stats->SetY1NDC(1.1); stats->SetY2NDC(1.3);
+ }
+ }
+ // ADC vs. TDC histogram
+ else if(histtype == 2)
+ {
+ if( ((range[0] == range[1]) && (range[2] == range[3])) || (range[2] == range[3]) || (range[0] == range[1]) )
+ sprintf(rdc, "(TDC%d/%lf):ADC%d>>%s", j, tdctimeconversion, j, histname);
+ else
+ sprintf(rdc, "(TDC%d/%lf):ADC%d>>%s(%d,%lf,%lf,%d,%lf,%lf)", j, tdctimeconversion, j, histname, (int)(range[1]-range[0])/2, range[0]-0.5, range[1]-0.5, (int)((range[3]-range[2])*tdctimeconversion)/2, range[2], range[3]);
+ meas_data->Draw(rdc,"","COLZ");
+
+ sprintf(rdc, "ADC/TDC%d, Vbias=%.3lf, TDC=(%.2lf,%.2lf);ADC;TDC", j, evtheader.biasvolt, range[2], range[3]);
+ TH2F *histtemp = (TH2F*)gCanvas->GetPrimitive(histname);
+ if(!cleanPlots)
+ histtemp->SetTitle(rdc);
+ else
+ histtemp->SetTitle(";ADC;Time (TDC channel) [ns]");
+ histtemp->GetXaxis()->SetLabelSize(0.025);
+ histtemp->GetXaxis()->CenterTitle(kTRUE);
+ histtemp->GetYaxis()->SetLabelSize(0.025);
+ histtemp->GetYaxis()->CenterTitle(kTRUE);
+ histtemp->GetYaxis()->SetTitleOffset(1.35);
+ if(cleanPlots)
+ {
+ TGaxis *yax = (TGaxis*)histtemp->GetYaxis();
+ yax->SetMaxDigits(4);
+ }
+
+ gCanvas->Modified();
+ gCanvas->Update();
+
+ TPaveStats *stats = (TPaveStats*)histtemp->FindObject("stats");
+ stats->SetX1NDC(1.1); stats->SetX2NDC(1.3);
+ stats->SetY1NDC(1.1); stats->SetY2NDC(1.3);
+
+ TPaletteAxis *gpalette = (TPaletteAxis*)histtemp->GetListOfFunctions()->FindObject("palette");
+ gpalette->SetLabelSize(0.022);
+ }
+
+ if(histtype < 2)
+ {
+ if( histOpt->widgetChBox[0]->IsDown() )
+ gCanvas->SetLogy(kTRUE);
+ else if( !histOpt->widgetChBox[0]->IsDown() )
+ gCanvas->SetLogy(kFALSE);
+ }
+ else
+ gCanvas->SetLogy(kFALSE);
+
+ gCanvas->Modified();
+ gCanvas->Update();
+
+ delete header_data;
+ delete meas_data;
+
+ // Delete the opened file when we just display it in the analysis canvas (otherwise wait for histogram save)
+ if(opt != 1)
+ delete inroot;
+
+ // If you close the opened file (delete inroot), the data can not be accessed by other functions (any time we wish to use the data directly from histogram, we need to call the DisplayHistogram function -> using different opt to determine what we need to do)
+}
+
+// Start a measurement (acquisition from CAMAC)
+void TGAppMainFrame::RunMeas(void *ptr, int runCase, int &scanon)
+{
+ int vscan = 0, pscan = 0, zscan = 0, ascan = 0;
+ if(scansOn->widgetChBox[0]->IsDown()) vscan = 1;
+ if(scansOn->widgetChBox[1]->IsDown()) pscan = 1;
+ if(scansOn->widgetChBox[2]->IsDown()) zscan = 1;
+ if(scansOn->widgetChBox[3]->IsDown()) ascan = 1;
+
+ printf("Start of Run, run case %d\n", runCase);
+
+ float progVal;
+
+ char ctemp[256];
+ char ctemp2[256];
+ char fname[256];
+ int itemp = 0;
+ TH1F *liveHist;
+
+ float minVoltage, maxVoltage, stepVoltage, diffVoltage;
+ float minXpos, maxXpos, stepXpos, diffXpos;
+ float minYpos, maxYpos, stepYpos, diffYpos;
+ float minZpos, maxZpos, stepZpos, diffZpos;
+ float minAlpha, maxAlpha, stepAlpha, diffAlpha;
+
+ minVoltage = vOutStart->widgetNE[0]->GetNumber();
+ maxVoltage = vOutStop->widgetNE[0]->GetNumber();
+ diffVoltage = abs(maxVoltage - minVoltage);
+ stepVoltage = abs(vOutStep->widgetNE[0]->GetNumber());
+ minXpos = xPosMin->widgetNE[0]->GetNumber();
+ maxXpos = xPosMax->widgetNE[0]->GetNumber();
+ diffXpos = abs(maxXpos - minXpos);
+ stepXpos = abs(xPosStep->widgetNE[0]->GetNumber());
+ minYpos = yPosMin->widgetNE[0]->GetNumber();
+ maxYpos = yPosMax->widgetNE[0]->GetNumber();
+ diffYpos = abs(maxYpos - minYpos);
+ stepYpos = abs(yPosStep->widgetNE[0]->GetNumber());
+ minZpos = zPosMin->widgetNE[0]->GetNumber();
+ maxZpos = zPosMax->widgetNE[0]->GetNumber();
+ diffZpos = abs(maxZpos - minZpos);
+ stepZpos = abs(zPosStep->widgetNE[0]->GetNumber());
+ minAlpha = rotPosMin->widgetNE[0]->GetNumber();
+ maxAlpha = rotPosMax->widgetNE[0]->GetNumber();
+ diffAlpha = abs(maxAlpha - minAlpha);
+ stepAlpha = abs(rotPosStep->widgetNE[0]->GetNumber());
+
+ remove_ext((char*)fileName->widgetTE->GetText(), ctemp);
+
+ // TODO - angle scan + voltage scan
+ // Voltage or surface scan
+ if( vscan || pscan || ascan )
+ {
+ // No Z scan, No angle scan
+ if(!zscan && !ascan)
+ {
+ // When we have a voltage scan
+ if( vscan && (stepVoltage > 0.) )
+ SeqNumber(runCase, (int)diffVoltage/stepVoltage, ctemp2);
+ // With only a surface scan
+ else if(pscan)
+ {
+ if( stepXpos == 0 )
+ itemp = 1;
+ else
+ itemp = (int)diffXpos/stepXpos;
+
+ if( stepYpos == 0 )
+ itemp *= 1;
+ else
+ itemp *= (int)diffYpos/stepYpos;
+ SeqNumber(runCase, itemp, ctemp2);
+ }
+ sprintf(fname, "%s_%s%s", ctemp, ctemp2, histext);
+ }
+ // With Z scan, No angle scan
+ else if(zscan && !ascan)
+ {
+ SeqNumber((int)zPos->widgetNE[0]->GetNumber(), maxZpos, ctemp2);
+
+ // Voltage scan is on
+ if( vscan && (stepVoltage > 0.) )
+ {
+ sprintf(fname, "%s_z%s_", ctemp, ctemp2);
+ SeqNumber(runCase, (int)diffVoltage/stepVoltage+1, ctemp2);
+ strcat(fname, ctemp2);
+ strcat(fname, histext);
+ }
+ // Surface scan is on
+ else if(pscan)
+ {
+ sprintf(fname, "%s_z%s_", ctemp, ctemp2);
+
+ if( stepXpos == 0 )
+ itemp = 1;
+ else
+ itemp = (int)diffXpos/stepXpos+1;
+
+ if( stepYpos == 0 )
+ itemp *= 1;
+ else
+ itemp *= (int)diffYpos/stepYpos+1;
+ SeqNumber(runCase, itemp, ctemp2);
+ strcat(fname, ctemp2);
+ strcat(fname, histext);
+ }
+ // Just Z scan
+ else
+ sprintf(fname, "%s_z%s%s", ctemp, ctemp2, histext);
+ }
+ // No Z scan, With angle scan
+ else if(!zscan && ascan)
+ {
+ SeqNumber(runCase, (int)diffAlpha/stepAlpha, ctemp2);
+
+ // Voltage scan is on
+ if( vscan && (stepVoltage > 0.) )
+ {
+ sprintf(fname, "%s_phi%s_", ctemp, ctemp2);
+ SeqNumber(runCase, (int)diffVoltage/stepVoltage+1, ctemp2);
+ strcat(fname, ctemp2);
+ strcat(fname, histext);
+ }
+ // Just angle scan
+ else
+ sprintf(fname, "%s_phi%s%s", ctemp, ctemp2, histext);
+ }
+ }
+ // All the rest
+ else if(!vscan && !pscan)
+ sprintf(fname, "%s%s", ctemp, histext);
+
+ // Check if set voltage is below the hard limit
+ if( vOut->widgetNE[0]->GetNumber() > vHardlimit->widgetNE[0]->GetNumber() )
+ {
+ printf("Voltage hard limit triggered (%lf > %lf)!\n", vOut->widgetNE[0]->GetNumber(), vHardlimit->widgetNE[0]->GetNumber() );
+ vOut->widgetNE[0]->SetNumber( vHardlimit->widgetNE[0]->GetNumber() );
+ }
+
+ printf("Output file is (runCase = %d): %s\n", runCase, fname);
+
+ // Writing to output file
+ outroot = TFile::Open(fname, "RECREATE");
+
+ TTree *header_data = new TTree("header_data", "Header information for the measurement.");
+ 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");
+ header_data->Branch("timestamp", &evtheader.timestamp, "timestamp/I");
+ header_data->Branch("biasvolt", &evtheader.biasvolt, "biasvolt/D");
+ header_data->Branch("xpos", &evtheader.xpos, "xpos/I");
+ header_data->Branch("ypos", &evtheader.ypos, "ypos/I");
+ header_data->Branch("zpos", &evtheader.zpos, "zpos/I");
+ header_data->Branch("temperature", &evtheader.temperature, "temperature/D");
+ header_data->Branch("angle", &evtheader.angle, "angle/D");
+ header_data->Branch("laserinfo", &evtheader.laserinfo, "laserinfo/C");
+
+ evtheader.nrch = (int)NCH->widgetNE[0]->GetNumber()*2;
+ evtheader.timestamp = (int)time(NULL);
+ evtheader.biasvolt = (double)vOut->widgetNE[0]->GetNumber();
+ if(posUnits->widgetCB->GetSelected() == 0)
+ {
+ evtheader.xpos = (int)xPos->widgetNE[0]->GetNumber();
+ evtheader.ypos = (int)yPos->widgetNE[0]->GetNumber();
+ evtheader.zpos = (int)zPos->widgetNE[0]->GetNumber();
+ }
+ else if(posUnits->widgetCB->GetSelected() == 1)
+ {
+ evtheader.xpos = (int)xPos->widgetNE[0]->GetNumber()/lenconversion;
+ evtheader.ypos = (int)yPos->widgetNE[0]->GetNumber()/lenconversion;
+ evtheader.zpos = (int)zPos->widgetNE[0]->GetNumber()/lenconversion;
+ }
+ evtheader.temperature = (double)chtemp->widgetNE[0]->GetNumber();
+ if(rotUnits->widgetCB->GetSelected() == 0)
+ evtheader.angle = (double)rotPos->widgetNE[0]->GetNumber()*rotconversion;
+ else if(rotUnits->widgetCB->GetSelected() == 1)
+ evtheader.angle = (double)rotPos->widgetNE[0]->GetNumber();
+ sprintf(evtheader.laserinfo, "%s", laserInfo->widgetTE->GetText());
+
+ char histtime[256];
+ GetTime(evtheader.timestamp, histtime);
+
+ printf("Save file header information:\n");
+ printf("- Number of channels: %d\n", evtheader.nrch);
+ printf("- Timestamp: %d (%s)\n", evtheader.timestamp, histtime);
+ printf("- Bias voltage: %lf\n", evtheader.biasvolt);
+ printf("- Table position (X,Y,Z): %d, %d, %d\n", evtheader.xpos, evtheader.ypos, evtheader.zpos);
+ printf("- Temperature: %lf\n", evtheader.temperature);
+ printf("- Incidence angle: %lf\n", evtheader.angle);
+ printf("- Laser and filter settings: %s\n", evtheader.laserinfo);
+
+ header_data->Fill();
+
+ // Branches for ADC and TDC data
+ for(int i = 0; i < evtheader.nrch/2; i++)
+ {
+ sprintf(ctemp, "ADC%d", i);
+ sprintf(fname, "ADC%d/I", i);
+ meas_data->Branch(ctemp, &evtdata.adcdata[i], fname);
+
+ sprintf(ctemp, "TDC%d", i);
+ sprintf(fname, "TDC%d/I", i);
+ meas_data->Branch(ctemp, &evtdata.tdcdata[i], fname);
+ }
+
+ //TODO
+ // 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->widgetNE[0]->GetNumber();
+ int allEvt, zProg;
+ zProg = 1;
+
+#if WORKSTAT == 'I'
+#else
+// ONLY FOR TESTING!
+ TRandom *randNum = new TRandom();
+ randNum->SetSeed(0);
+// ONLY FOR TESTING!
+#endif
+
+ // Initialize the CAMAC
+ if (gDaq)
+ {
+ if(scanon == 0)
+ {
+ gDaq->init(evtheader.nrch);
+ scanon = 1;
+ }
+ gDaq->fStop=0;
+
+ // Set the stopwatch
+ clock_t clkt1;
+
+ // Prepare histogram for live histogram update
+ int liven;
+ TCanvas *gCanvas;
+ if(liveUpdate && (!vscan && !pscan && !zscan && !ascan))
+ {
+ gCanvas = measCanvas->GetCanvas();
+ gCanvas->SetGrid();
+ gCanvas->cd();
+ liveHist = new TH1F(histname,"",(int)TMath::Sqrt(neve),0,0);
+ liven = 1;
+ }
+
+ // Start gathering
+ gDaq->start();
+
+ for (int n=0;n<neve && !gDaq->fStop ;/*n++*/)
+ {
+ int nb = gDaq->event(gBuf,BSIZE);
+
+#if WORKSTAT == 'I'
+#else
+// ONLY FOR TESTING!
+ for(int i=0; i < evtheader.nrch; i++)
+ {
+ if(i == 1)
+ gBuf[i] = randNum->Gaus(1500,300);
+ else if(i == 0)
+ gBuf[i] = randNum->Poisson(2500);
+ }
+// ONLY FOR TESTING!
+#endif
+ if (nb<=0) n--;
+
+ int nc=0;
+
+ while ( (nb>0) && (n<neve) )
+ {
+ for(int i = 0; i < evtheader.nrch; i++)
+ {
+ unsigned short adc = gBuf[i+nc]&0xFFFF;
+ if(i % 2 == 0) // TDC
+ 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();*/ // TODO
+ }
+ meas_data->Fill();
+ n++;
+sleep(1);
+
+ // Start making a scope measurement
+/* if( (gScopeDaq->scopeUseType == 2) && (sCamaclink->IsDown()) )
+ {
+ StartScopeAcq();
+ evtmeas.measdata = gScopeDaq->measubuf;
+ }
+ scope_data->Fill();*/ // TODO
+
+ // Start filling the histogram (only in normal single scan)
+ if(liveUpdate && (!vscan && !pscan && !zscan && !ascan))
+ {
+ liveHist->Fill(evtdata.adcdata[0]);
+ if( n == (neve*liven)/10 )
+ {
+ gCanvas->cd();
+ liveHist->Draw("");
+ gCanvas->Modified();
+ gCanvas->Update();
+ liven++;
+ }
+ }
+
+ nc += evtheader.nrch;
+ nb -= evtheader.nrch;
+ }
+
+ MyTimer();
+ allEvt = n;
+ if (gSystem->ProcessEvents()) printf("Run Interrupted\n");
+
+ if( acqStarted && (n == (neve*zProg)/10) && (!vscan && !pscan && !zscan && !ascan) )
+ {
+ // Progress the progress bar
+ progVal = (float)zProg*10;
+ measProgress->widgetPB->SetPosition(progVal);
+
+ // Calculate the remaining time
+ TimeEstimate(clkt0, timet0, progVal, ctemp, 0);
+ printf("End time: %s\n", ctemp);
+ measProgress->widgetTE->SetText(ctemp);
+
+ gVirtualX->Update(1);
+ zProg++;
+ }
+ }
+
+ printf("Number of gathered events: %d\n", allEvt);
+ measProgress->widgetTB[0]->SetText("Start acquisition");
+ acqStarted = false;
+
+ gDaq->stop();
+ }
+
+ printf("End of Run neve=%d\n",neve);
+
+ header_data->Write();
+ meas_data->Write();
+// scope_data->Write(); // TODO
+ delete header_data;
+ delete meas_data;
+ delete scope_data;
+
+ // Remove the histogram
+ if(liveUpdate && (!vscan && !pscan && !zscan && !ascan))
+ delete liveHist;
+
+
+ outroot->Close();
+}
+
+int TGAppMainFrame::MyTimer()
+{
+ char cmd[100];
+ GetTime(-1, cmd);
+ if (timeStamp) timeStamp->widgetTE->SetText(cmd);
+ return 0;
+}
+
+// Additional functions -------------------------------------
+
+// Settings pane connections --------------------------------
+
+// Enable or disable scans
+void TGAppMainFrame::EnableScan(int type)
+{
+ // Voltage scan
+ if(type == 0)
+ {
+ if(scansOn->widgetChBox[type]->IsOn())
+ {
+ vOutStart->widgetNE[0]->SetState(kTRUE);
+ vOutStop->widgetNE[0]->SetState(kTRUE);
+ vOutStep->widgetNE[0]->SetState(kTRUE);
+ }
+ else
+ {
+ vOutStart->widgetNE[0]->SetState(kFALSE);
+ vOutStop->widgetNE[0]->SetState(kFALSE);
+ vOutStep->widgetNE[0]->SetState(kFALSE);
+ }
+ }
+ // Surface (X, Y axis) scan
+ else if(type == 1)
+ {
+ if(scansOn->widgetChBox[type]->IsOn())
+ {
+ xPosMin->widgetNE[0]->SetState(kTRUE);
+ xPosMax->widgetNE[0]->SetState(kTRUE);
+ xPosStep->widgetNE[0]->SetState(kTRUE);
+ yPosMin->widgetNE[0]->SetState(kTRUE);
+ yPosMax->widgetNE[0]->SetState(kTRUE);
+ yPosStep->widgetNE[0]->SetState(kTRUE);
+ }
+ else
+ {
+ xPosMin->widgetNE[0]->SetState(kFALSE);
+ xPosMax->widgetNE[0]->SetState(kFALSE);
+ xPosStep->widgetNE[0]->SetState(kFALSE);
+ yPosMin->widgetNE[0]->SetState(kFALSE);
+ yPosMax->widgetNE[0]->SetState(kFALSE);
+ yPosStep->widgetNE[0]->SetState(kFALSE);
+ }
+ }
+ // Z axis scan
+ else if(type == 2)
+ {
+ if(scansOn->widgetChBox[type]->IsOn())
+ {
+ zPosMin->widgetNE[0]->SetState(kTRUE);
+ zPosMax->widgetNE[0]->SetState(kTRUE);
+ zPosStep->widgetNE[0]->SetState(kTRUE);
+ }
+ else
+ {
+ zPosMin->widgetNE[0]->SetState(kFALSE);
+ zPosMax->widgetNE[0]->SetState(kFALSE);
+ zPosStep->widgetNE[0]->SetState(kFALSE);
+ }
+ }
+ // Incidence angle scan
+ else if(type == 3)
+ {
+ if(scansOn->widgetChBox[type]->IsOn())
+ {
+ rotPosMin->widgetNE[0]->SetState(kTRUE);
+ rotPosMax->widgetNE[0]->SetState(kTRUE);
+ rotPosStep->widgetNE[0]->SetState(kTRUE);
+ }
+ else
+ {
+ rotPosMin->widgetNE[0]->SetState(kFALSE);
+ rotPosMax->widgetNE[0]->SetState(kFALSE);
+ rotPosStep->widgetNE[0]->SetState(kFALSE);
+ }
+ }
+}
+
+// Apply the upper voltage limit from settings pane to main window
+void TGAppMainFrame::VoltageLimit()
+{
+ vOut->widgetNE[0]->SetLimitValues(0, vHardlimit->widgetNE[0]->GetNumber() );
+}
+
+// Select the table position units to be used (1 = 0.3595 micron)
+void TGAppMainFrame::ChangeUnits(int type)
+{
+ int pos[12], poslim[3], chng = 0;
+ double micro[12], microlim[3];
+
+ TGNumberEntry *posEntries[12];
+ posEntries[0] = (TGNumberEntry*)xPos->widgetNE[0];
+ posEntries[1] = (TGNumberEntry*)yPos->widgetNE[0];
+ posEntries[2] = (TGNumberEntry*)zPos->widgetNE[0];
+ posEntries[3] = (TGNumberEntry*)xPosMin->widgetNE[0];
+ posEntries[4] = (TGNumberEntry*)xPosMax->widgetNE[0];
+ posEntries[5] = (TGNumberEntry*)xPosStep->widgetNE[0];
+ posEntries[6] = (TGNumberEntry*)yPosMin->widgetNE[0];
+ posEntries[7] = (TGNumberEntry*)yPosMax->widgetNE[0];
+ posEntries[8] = (TGNumberEntry*)yPosStep->widgetNE[0];
+ posEntries[9] = (TGNumberEntry*)zPosMin->widgetNE[0];
+ posEntries[10] = (TGNumberEntry*)zPosMax->widgetNE[0];
+ posEntries[11] = (TGNumberEntry*)zPosStep->widgetNE[0];
+
+ // Table position values
+ if(type == 0)
+ {
+ // Check if we had microns before
+ if(posEntries[0]->GetNumStyle() == TGNumberFormat::kNESRealTwo)
+ chng = 1;
+
+ // Change to table position values
+ if(chng == 1)
+ {
+ for(int i = 0; i < 12; i++)
+ {
+ if(posEntries[i]->GetNumber() == 0.0)
+ pos[i] = 0;
+ else
+ pos[i] = (int)posEntries[i]->GetNumber()/lenconversion;
+ }
+
+ poslim[0] = -100;
+ poslim[1] = 215000;
+ poslim[2] = 375000;
+
+ for(int i = 0; i < 12; i++)
+ {
+ posEntries[i]->SetNumStyle(TGNumberFormat::kNESInteger);
+ if( (i > 8) || (i == 2) ) // limits for Z axis (longer table)
+ posEntries[i]->SetLimits(TGNumberFormat::kNELLimitMinMax, poslim[0], poslim[2]);
+ else
+ posEntries[i]->SetLimits(TGNumberFormat::kNELLimitMinMax, poslim[0], poslim[1]);
+
+ posEntries[i]->SetNumber(pos[i]);
+ }
+ }
+ }
+ // Microns
+ else if(type == 1)
+ {
+ // Check if we had table position values before
+ if(posEntries[0]->GetNumStyle() == TGNumberFormat::kNESInteger)
+ chng = 1;
+
+ // Change to microns
+ if(chng == 1)
+ {
+ for(int i = 0; i < 12; i++)
+ {
+ if(posEntries[i]->GetNumber() == 0.0)
+ micro[i] = 0.;
+ else
+ micro[i] = (double)posEntries[i]->GetNumber()*lenconversion;
+ }
+
+ microlim[0] = (double)-100*lenconversion;
+ microlim[1] = (double)215000*lenconversion;
+ microlim[2] = (double)375000*lenconversion;
+
+ for(int i = 0; i < 12; i++)
+ {
+ posEntries[i]->SetNumStyle(TGNumberFormat::kNESRealTwo);
+ if( (i > 8) || (i == 2) ) // limits for Z axis (longer table)
+ posEntries[i]->SetLimits(TGNumberFormat::kNELLimitMinMax, microlim[0], microlim[2]);
+ else
+ posEntries[i]->SetLimits(TGNumberFormat::kNELLimitMinMax, microlim[0], microlim[1]);
+
+ posEntries[i]->SetNumber(micro[i]);
+ }
+ }
+ }
+}
+
+// Select the rotation units to be used (1 = 6.3281/3600 degrees)
+void TGAppMainFrame::ChangeUnitsRot(int type)
+{
+ int rot[4], rotlim[2], chng = 0;
+ double deg[4], deglim[2];
+
+ TGNumberEntry *rotEntries[4];
+ rotEntries[0] = (TGNumberEntry*)rotPos->widgetNE[0];
+ rotEntries[1] = (TGNumberEntry*)rotPosMin->widgetNE[0];
+ rotEntries[2] = (TGNumberEntry*)rotPosMax->widgetNE[0];
+ rotEntries[3] = (TGNumberEntry*)rotPosStep->widgetNE[0];
+
+ // Rotation values
+ if(type == 0)
+ {
+ // Check if we had degrees before
+ if(rotEntries[0]->GetNumStyle() == TGNumberFormat::kNESRealTwo)
+ chng = 1;
+
+ // Change to rotation values
+ if(chng == 1)
+ {
+ for(int i = 0; i < 4; i++)
+ {
+ if(rotEntries[i]->GetNumber() == 0.0)
+ rot[i] = 0;
+ else
+ rot[i] = (int)rotEntries[i]->GetNumber()/rotconversion;
+ }
+
+ rotlim[0] = (int)-180/rotconversion;
+ rotlim[1] = (int)180/rotconversion;
+
+ for(int i = 0; i < 4; i++)
+ {
+ rotEntries[i]->SetNumStyle(TGNumberFormat::kNESInteger);
+ rotEntries[i]->SetLimits(TGNumberFormat::kNELLimitMinMax, rotlim[0], rotlim[1]);
+
+ rotEntries[i]->SetNumber(rot[i]);
+ }
+ }
+ }
+ // Degree
+ else if(type == 1)
+ {
+ // Check if we had table position values before
+ if(rotEntries[0]->GetNumStyle() == TGNumberFormat::kNESInteger)
+ chng = 1;
+
+ // Change to degrees
+ if(chng == 1)
+ {
+ for(int i = 0; i < 4; i++)
+ {
+ if(rotEntries[i]->GetNumber() == 0)
+ deg[i] = 0.;
+ else
+ deg[i] = (double)rotEntries[i]->GetNumber()*rotconversion;
+ }
+
+ deglim[0] = -180.;
+ deglim[1] = 180.;
+
+ for(int i = 0; i < 4; i++)
+ {
+ rotEntries[i]->SetNumStyle(TGNumberFormat::kNESRealTwo);
+ rotEntries[i]->SetLimits(TGNumberFormat::kNELLimitMinMax, deglim[0], deglim[1]);
+
+ rotEntries[i]->SetNumber(deg[i]);
+ }
+ }
+ }
+}
+
+// Enable display canvas to have a live update of histogram
+void TGAppMainFrame::EnableLiveUpdate()
+{
+ liveUpdate = liveDisp->widgetChBox[0]->IsDown();
+}
+
+// Settings pane connections --------------------------------
+
+// Main measurement window connections ----------------------
+
+// Get the currently selected channel
+int TGAppMainFrame::GetChannel()
+{
+ int selectedOutput;
+ if(vOutCh->widgetCB->GetSelected() < 8) selectedOutput = (vOutCh->widgetCB->GetSelected())+1;
+ else if( (vOutCh->widgetCB->GetSelected() >= 8) && (vOutCh->widgetCB->GetSelected() < 16) ) selectedOutput = (vOutCh->widgetCB->GetSelected())+93;
+ else selectedOutput = 1;
+
+ return selectedOutput;
+}
+
+// Set, get or reset the output voltage
+void TGAppMainFrame::VoltOut(int opt)
+{
+ char cmd[256];
+
+ // Set the selected voltage
+ if(opt == 0)
+ {
+ int outOn;
+ float outputVoltage;
+
+ outputVoltage = vOut->widgetNE[0]->GetNumber();
+
+ if(vOutOpt->widgetChBox[1]->IsOn()) outOn = 1;
+ else outOn = 0;
+
+ fflush(stdout);
+ sprintf(cmd, "%s/src/mpod/mpod_voltage.sh -o %d -v %f -s %d", rootdir, GetChannel(), outputVoltage, outOn);
+#if WORKSTAT == 'I'
+ retTemp = system(cmd);
+#else
+ printf("Cmd: %s\n",cmd);
+#endif
+ fflush(stdout);
+ }
+ // Get current voltage
+ else if(opt == 1)
+ {
+ fflush(stdout);
+ sprintf(cmd, "%s/src/mpod/mpod_voltage.sh -o %d -g > %s/settings/curvolt.txt", rootdir, GetChannel(), rootdir);
+#if WORKSTAT == 'I'
+ retTemp = system(cmd);
+#else
+ printf("Cmd: %s\n",cmd);
+#endif
+ fflush(stdout);
+
+#if WORKSTAT == 'I'
+ FILE* fvolt;
+ double dtemp;
+ char ctemp[24];
+ sprintf(cmd, "%s/settings/curvolt.txt", rootdir);
+ fvolt = fopen(cmd, "r");
+
+ if(fvolt != NULL)
+ {
+ sprintf(cmd, "WIENER-CRATE-MIB::outputVoltage.u%d = Opaque: Float: %s V\n", GetChannel()-1, "%lf" );
+ retTemp = fscanf(fvolt, cmd, &dtemp);
+ vOut->widgetNE[0]->SetNumber(dtemp);
+ sprintf(cmd, "WIENER-CRATE-MIB::outputSwitch.u%d = INTEGER: %s\n", GetChannel()-1, "%s" );
+ retTemp = fscanf(fvolt, cmd, ctemp);
+ if( strcmp(ctemp, "On(1)") == 0 )
+ vOutOpt->widgetChBox[1]->SetState(kButtonDown);
+ else if( strcmp(ctemp, "Off(0)") == 0 )
+ vOutOpt->widgetChBox[1]->SetState(kButtonUp);
+ }
+
+ fclose(fvolt);
+#endif
+ }
+ // Reset output voltage (if stuck in interlock)
+ else if(opt == 2)
+ {
+ vOut->widgetNE[0]->SetNumber(0.000);
+ vOutOpt->widgetChBox[1]->SetState(kButtonUp);
+
+ fflush(stdout);
+ sprintf(cmd, "%s/src/mpod/mpod_voltage.sh -r %d", rootdir, GetChannel());
+#if WORKSTAT == 'I'
+ retTemp = system(cmd);
+#else
+ printf("Cmd: %s\n",cmd);
+#endif
+ fflush(stdout);
+ }
+}
+
+// Set output voltage polarity to negative
+void TGAppMainFrame::NegativePolarity()
+{
+ double newHardlimit;
+ int polar = 0; // 0 = positive, 1 = negative
+
+ if(vOutOpt->widgetChBox[0]->IsOn())
+ polar = 1;
+ else
+ polar = 0;
+
+ // Set hard limit to the negative version of what it was before
+ if( (vHardlimit->widgetNE[0]->GetNumber() > 0.) && (polar == 1) )
+ newHardlimit = -(vHardlimit->widgetNE[0]->GetNumber());
+ else if( (vHardlimit->widgetNE[0]->GetNumber() < 0.) && (polar == 0) )
+ newHardlimit = -(vHardlimit->widgetNE[0]->GetNumber());
+ else if(vHardlimit->widgetNE[0]->GetNumber() == 0.)
+ newHardlimit = 0.;
+ else
+ newHardlimit = vHardlimit->widgetNE[0]->GetNumber();
+
+ // Apropriately set the limit to the output voltage number entry
+ vHardlimit->widgetNE[0]->SetNumber(newHardlimit);
+
+ if(polar == 1)
+ vOut->widgetNE[0]->SetLimits(TGNumberFormat::kNELLimitMinMax, newHardlimit, 0.);
+ else if(polar == 0)
+ vOut->widgetNE[0]->SetLimits(TGNumberFormat::kNELLimitMinMax, 0., newHardlimit);
+}
+
+// Set, get, home or reset the table position
+void TGAppMainFrame::PositionSet(int opt)
+{
+ char cmd[1024];
+
+ // Set the selected table position
+ if(opt == 0)
+ {
+ int positX, positY, positZ;
+
+ if(posUnits->widgetCB->GetSelected() == 0)
+ {
+ positX = xPos->widgetNE[0]->GetNumber();
+ positY = yPos->widgetNE[0]->GetNumber();
+ positZ = zPos->widgetNE[0]->GetNumber();
+ }
+ else if(posUnits->widgetCB->GetSelected() == 1)
+ {
+ positX = (int)xPos->widgetNE[0]->GetNumber()/lenconversion;
+ positY = (int)yPos->widgetNE[0]->GetNumber()/lenconversion;
+ positZ = (int)zPos->widgetNE[0]->GetNumber()/lenconversion;
+ }
+
+ sprintf(cmd, "sudo %s/src/MIKRO/mikro_ctrl -n 1 -v %d -s la && %s/src/MIKRO/mikro_ctrl -n 1 -c m", rootdir, positX, rootdir);
+#if WORKSTAT == 'I'
+ retTemp = system(cmd);
+#else
+ printf("Cmd: %s\n",cmd);
+#endif
+
+ sprintf(cmd, "sudo %s/src/MIKRO/mikro_ctrl -n 2 -v %d -s la && %s/src/MIKRO/mikro_ctrl -n 2 -c m", rootdir, positY, rootdir);
+#if WORKSTAT == 'I'
+ retTemp = system(cmd);
+#else
+ printf("Cmd: %s\n",cmd);
+#endif
+
+ sprintf(cmd, "sudo %s/src/MIKRO/mikro_ctrl -n 3 -v %d -s la && %s/src/MIKRO/mikro_ctrl -n 3 -c m", rootdir, positZ, rootdir);
+#if WORKSTAT == 'I'
+ retTemp = system(cmd);
+#else
+ printf("Cmd: %s\n",cmd);
+#endif
+ }
+ // Get current table position
+ else if(opt == 1)
+ {
+ fflush(stdout);
+
+ sprintf(cmd, "sudo %s/src/MIKRO/mikro_ctrl -n 1 -p > %s/settings/curpos.txt", rootdir, rootdir); // X-axis
+ fflush(stdout);
+#if WORKSTAT == 'I'
+ retTemp = system(cmd);
+#else
+ printf("Cmd: %s\n",cmd);
+#endif
+
+ sprintf(cmd, "sudo %s/src/MIKRO/mikro_ctrl -n 2 -p >> %s/settings/curpos.txt", rootdir, rootdir); // Y-axis
+ fflush(stdout);
+#if WORKSTAT == 'I'
+ retTemp = system(cmd);
+#else
+ printf("Cmd: %s\n",cmd);
+#endif
+
+ sprintf(cmd, "sudo %s/src/MIKRO/mikro_ctrl -n 3 -p >> %s/settings/curpos.txt", rootdir, rootdir); // Z-axis
+ fflush(stdout);
+#if WORKSTAT == 'I'
+ retTemp = system(cmd);
+#else
+ printf("Cmd: %s\n",cmd);
+#endif
+
+#if WORKSTAT == 'I'
+ FILE* fpos;
+ int itemp;
+ sprintf(cmd, "%s/settings/curpos.txt", rootdir);
+ fpos = fopen(cmd, "r");
+
+ if(fpos != NULL)
+ {
+ if(posUnits->widgetCB->GetSelected() == 0)
+ {
+ retTemp = fscanf(fpos, "%d\n", &itemp);
+ xPos->widgetNE[0]->SetNumber(itemp);
+ retTemp = fscanf(fpos, "%d\n", &itemp);
+ yPos->widgetNE[0]->SetNumber(itemp);
+ retTemp = fscanf(fpos, "%d\n", &itemp);
+ zPos->widgetNE[0]->SetNumber(itemp);
+ }
+ else if(posUnits->widgetCB->GetSelected() == 1)
+ {
+ retTemp = fscanf(fpos, "%d\n", &itemp);
+ xPos->widgetNE[0]->SetNumber((double)itemp*lenconversion);
+ retTemp = fscanf(fpos, "%d\n", &itemp);
+ yPos->widgetNE[0]->SetNumber((double)itemp*lenconversion);
+ retTemp = fscanf(fpos, "%d\n", &itemp);
+ zPos->widgetNE[0]->SetNumber((double)itemp*lenconversion);
+ }
+ }
+
+ fclose(fpos);
+#endif
+ }
+ // Home the table position
+ else if(opt == 2)
+ {
+ sprintf(cmd, "sudo %s/src/MIKRO/mikro_ctrl -n 1 -h", rootdir); // X-axis
+#if WORKSTAT == 'I'
+ retTemp = system(cmd);
+#else
+ printf("Cmd: %s\n",cmd);
+#endif
+
+ sprintf(cmd, "sudo %s/src/MIKRO/mikro_ctrl -n 2 -h", rootdir); // Y-axis
+#if WORKSTAT == 'I'
+ retTemp = system(cmd);
+#else
+ printf("Cmd: %s\n",cmd);
+#endif
+
+ sprintf(cmd, "sudo %s/src/MIKRO/mikro_ctrl -n 3 -h", rootdir); // Z-axis
+#if WORKSTAT == 'I'
+ retTemp = system(cmd);
+#else
+ printf("Cmd: %s\n",cmd);
+#endif
+ PositionSet(1);
+ }
+ // Reset the table position
+ else if(opt == 3)
+ {
+ sprintf(cmd, "sudo %s/src/MIKRO/mikro_ctrl -n 1 -r && sudo %s/src/MIKRO/mikro_ctrl -n 1 -i 3 && sudo %s/src/MIKRO/mikro_ctrl -n 1 -h", rootdir, rootdir, rootdir); // X-axis
+#if WORKSTAT == 'I'
+ printf("Positioning table reset, initialization and homing in progress. Please wait...\n");
+ retTemp = system(cmd);
+#else
+ printf("Cmd: %s\n",cmd);
+#endif
+
+ sprintf(cmd, "sudo %s/src/MIKRO/mikro_ctrl -n 2 -r && sudo %s/src/MIKRO/mikro_ctrl -n 2 -i 3 && sudo %s/src/MIKRO/mikro_ctrl -n 2 -h", rootdir, rootdir, rootdir); // Y-axis
+#if WORKSTAT == 'I'
+ retTemp = system(cmd);
+#else
+ printf("Cmd: %s\n",cmd);
+#endif
+
+ sprintf(cmd, "sudo %s/src/MIKRO/mikro_ctrl -n 3 -r && sudo %s/src/MIKRO/mikro_ctrl -n 3 -i 3 && sudo %s/src/MIKRO/mikro_ctrl -n 3 -h", rootdir, rootdir, rootdir); // Z-axis
+#if WORKSTAT == 'I'
+ retTemp = system(cmd);
+ printf("Positioning table reset, initialization and homing complete.\n");
+#else
+ printf("Cmd: %s\n",cmd);
+#endif
+ PositionSet(1);
+ }
+}
+
+// Set, get, home or reset the rotation platform
+void TGAppMainFrame::RotationSet(int opt)
+{
+ char cmd[1024];
+
+ // Set the selected rotation
+ if(opt == 0)
+ {
+ int positAlpha;
+
+ if(rotUnits->widgetCB->GetSelected() == 0)
+ positAlpha = rotPos->widgetNE[0]->GetNumber();
+ else if(rotUnits->widgetCB->GetSelected() == 1)
+ positAlpha = rotPos->widgetNE[0]->GetNumber()/rotconversion;
+
+ sprintf(cmd, "sudo %s/src/MIKRO/mikro_ctrl -n 4 -v %d -s la && %s/src/MIKRO/mikro_ctrl -n 4 -c m", rootdir, positAlpha, rootdir);
+#if WORKSTAT == 'I'
+ retTemp = system(cmd);
+#else
+ printf("Cmd: %s\n",cmd);
+#endif
+ }
+ // Get current rotation
+ else if(opt == 1)
+ {
+ fflush(stdout);
+
+ sprintf(cmd, "sudo %s/src/MIKRO/mikro_ctrl -n 4 -p > %s/settings/currot.txt", rootdir, rootdir);
+ fflush(stdout);
+#if WORKSTAT == 'I'
+ retTemp = system(cmd);
+#else
+ printf("Cmd: %s\n",cmd);
+#endif
+
+#if WORKSTAT == 'I'
+ FILE* frot;
+ int itemp;
+ sprintf(cmd, "%s/settings/currot.txt", rootdir);
+ frot = fopen(cmd, "r");
+
+ if(frot != NULL)
+ {
+ retTemp = fscanf(frot, "%d\n", &itemp);
+ if(rotUnits->widgetCB->GetSelected() == 0)
+ rotPos->widgetNE[0]->SetNumber(itemp);
+ else if(rotUnits->widgetCB->GetSelected() == 1)
+ rotPos->widgetNE[0]->SetNumber((double)itemp*rotconversion);
+ }
+
+ fclose(frot);
+#endif
+ }
+ // Home the rotation
+ else if(opt == 2)
+ {
+ // TODO: For now only set back to 0, not home!
+// sprintf(cmd, "sudo %s/src/MIKRO/mikro_ctrl -n 4 -h", rootdir);
+ sprintf(cmd, "sudo %s/src/MIKRO/mikro_ctrl -n 4 -v 0 -s la && %s/src/MIKRO/mikro_ctrl -n 4 -c m", rootdir, rootdir);
+#if WORKSTAT == 'I'
+ retTemp = system(cmd);
+#else
+ printf("Cmd: %s\n",cmd);
+#endif
+ RotationSet(1);
+ }
+ // Reset the rotation
+ else if(opt == 3)
+ {
+ // TODO: For now only set back to 0, not home!
+ sprintf(cmd, "sudo %s/src/MIKRO/mikro_ctrl -n 4 -r && sudo %s/src/MIKRO/mikro_ctrl -n 4 -i 2 && sudo %s/src/MIKRO/mikro_ctrl -n 4 -h", rootdir, rootdir, rootdir);
+#if WORKSTAT == 'I'
+ printf("Rotation platform reset, initalization and homing in progress. Please wait...\n");
+ sprintf(cmd, "sudo %s/src/MIKRO/mikro_ctrl -n 4 -v 0 -s la && %s/src/MIKRO/mikro_ctrl -n 4 -c m", rootdir, rootdir);
+ retTemp = system(cmd);
+ sleep(15); // wait for the motor to change position from wherever to 0
+ sprintf(cmd, "sudo %s/src/MIKRO/mikro_ctrl -n 4 -r && sudo %s/src/MIKRO/mikro_ctrl -n 4 -i 2", rootdir, rootdir);
+ retTemp = system(cmd);
+ printf("Rotation platform reset, initalization and homing complete.\n");
+#else
+ printf("Cmd: %s\n",cmd);
+#endif
+ RotationSet(1);
+ }
+}
+
+// File browser for selecting the save file
+void TGAppMainFrame::SaveFile()
+{
+ TGFileInfo file_info;
+ const char *filetypes[] = {"Histograms",histextall,0,0};
+ char *cTemp;
+ file_info.fFileTypes = filetypes;
+ cTemp = new char[1024];
+ sprintf(cTemp, "%s/results", rootdir);
+ file_info.fIniDir = StrDup(cTemp);
+ new TGFileDialog(gClient->GetDefaultRoot(), fMain, kFDSave, &file_info);
+ delete[] cTemp;
+
+ if(file_info.fFilename != NULL)
+ fileName->widgetTE->SetText(file_info.fFilename);
+}
+
+// Start the acquisition
+void TGAppMainFrame::StartAcq()
+{
+ // Variable that will initialize camac only once (for scans)
+ int scanon = 0;
+
+ // Determine the type of measurement to perform
+ int vscan = 0, pscan = 0, zscan = 0, ascan = 0;
+ if(scansOn->widgetChBox[0]->IsDown()) vscan = 1;
+ if(scansOn->widgetChBox[1]->IsDown()) pscan = 1;
+ if(scansOn->widgetChBox[2]->IsDown()) zscan = 1;
+ if(scansOn->widgetChBox[3]->IsDown()) ascan = 1;
+
+ char cmd[256];
+ int i, j, k;
+ float progVal;
+ FILE *pfin;
+
+ // Variables for voltage scan
+ float currentVoltage, minVoltage, maxVoltage, stepVoltage;
+ int repetition;
+
+ // Variables for surface scan and Z axis scan
+ float minXpos, maxXpos, stepXpos;
+ float minYpos, maxYpos, stepYpos;
+ float minZpos, maxZpos, stepZpos;
+ int repetX, repetY, repetZ;
+
+ // Variables for angle scan
+ float currentAlpha, minAlpha, maxAlpha, stepAlpha;
+ int repetAlpha;
+
+ // Only voltage scan
+ if( (vscan == 1) && (pscan == 0) && (ascan == 0) )
+ { // TODO - include possibility to make voltage and angle scan at same time
+ // If already started, stop the acquisition
+ if(acqStarted)
+ {
+ printf("Stopping current voltage scan...\n");
+ gROOT->SetInterrupt();
+ measProgress->widgetTB[0]->SetText("Start acquisition");
+ acqStarted = false;
+
+ // Write information to the finish_sig.txt value
+ sprintf(cmd, "%s/dbg/finish_sig.txt", rootdir);
+ pfin = fopen(cmd,"w");
+ fprintf(pfin, "%s: Voltage scan stopped.", timeStamp->widgetTE->GetText());
+ fclose(pfin);
+ }
+ // If stopped, start the acquisition
+ else if(!acqStarted)
+ {
+ printf("Running a voltage scan...\n");
+
+ // Check the steps
+ minVoltage = vOutStart->widgetNE[0]->GetNumber();
+ maxVoltage = vOutStop->widgetNE[0]->GetNumber();
+ stepVoltage = vOutStep->widgetNE[0]->GetNumber();
+
+ if(stepVoltage == 0.)
+ repetition = 1;
+ else
+ {
+ // Example: min = 40, max = 70, step = 5 (in increasing steps)
+ if( (maxVoltage > minVoltage) && (stepVoltage > 0) )
+ repetition = ((maxVoltage - minVoltage)/stepVoltage)+1;
+ // Example: min = 70, max = 40, step = -5 (in decreasing steps)
+ else if( (maxVoltage < minVoltage) && (stepVoltage < 0) )
+ repetition = ((minVoltage - maxVoltage)/stepVoltage)-1;
+ // Example: min = 70, max = 70 (no scan)
+ else if( maxVoltage == minVoltage )
+ repetition = 1;
+ // If step is not correctly set, stop the acqusition
+ else
+ {
+ // TODO
+ printf("Stopping current voltage scan...\n");
+ gROOT->SetInterrupt();
+ measProgress->widgetTB[0]->SetText("Start acquisition");
+ acqStarted = false;
+ repetition = 0;
+ }
+ }
+
+ if(DBGSIG) printf("StartAcq(): Voltage repetition (%lf,%lf,%lf) = %d\n", minVoltage, maxVoltage, stepVoltage, repetition);
+
+ i = 0;
+
+ // TODO - Setting button text and acqStarted do not work!
+ measProgress->widgetTB[0]->SetText("Stop acquisition");
+ acqStarted = true;
+ progVal = 0.00;
+ measProgress->widgetPB->SetPosition(progVal);
+ gVirtualX->Update(1);
+
+ clkt0 = clock();
+ timet0 = time(NULL);
+
+ while(1)
+ {
+ if( (repetition > 0) && (i == repetition) ) break;
+ else if( (repetition < 0) && (i == -repetition) ) break;
+ else if( repetition == 0 ) break;
+
+ progVal = (float)(100.00/abs(repetition))*i;
+ measProgress->widgetPB->SetPosition(progVal);
+
+ TimeEstimate(clkt0, timet0, progVal, cmd, singlewait*abs(repetition));
+ measProgress->widgetTE->SetText(cmd);
+
+ gVirtualX->Update(1);
+
+ fflush(stdout);
+ currentVoltage = minVoltage + stepVoltage*i;
+ sprintf(cmd, "%s/src/mpod/mpod_voltage.sh -o %d -v %f -s 1", rootdir, GetChannel(), currentVoltage);
+#if WORKSTAT == 'I'
+ retTemp = system(cmd);
+#else
+ printf("Cmd: %s\n",cmd);
+#endif
+ fflush(stdout);
+
+ printf("Waiting for voltage change...\n");
+ sleep(singlewait);
+ vOut->widgetNE[0]->SetNumber(currentVoltage);
+ gVirtualX->Update(1);
+ printf("Continuing...\n");
+
+ // Here comes function to start histogramming <<<<<<<<<<<<<<<<<<<<<<<<
+ RunMeas((void*)0, i, scanon); // TODO
+ fflush(stdout);
+
+ i++;
+ }
+
+ // Set output back to off
+ fflush(stdout);
+ printf("Measurement finished, returning to starting voltage...\n");
+ sprintf(cmd, "%s/src/mpod/mpod_voltage.sh -o %d -v %f -s 1", rootdir, GetChannel(), minVoltage);
+ vOut->widgetNE[0]->SetNumber(minVoltage);
+#if WORKSTAT == 'I'
+ retTemp = system(cmd);
+#else
+ printf("Cmd: %s\n",cmd);
+#endif
+ fflush(stdout);
+
+ progVal = 100.00;
+ measProgress->widgetPB->SetPosition(progVal);
+ printf("\n");
+
+ sprintf(cmd, "%s/dbg/finish_sig.txt", rootdir);
+ pfin = fopen(cmd,"w");
+ fprintf(pfin, "%s: Voltage scan finished.", timeStamp->widgetTE->GetText());
+ fclose(pfin);
+
+ measProgress->widgetTB[0]->SetText("Start acquisition");
+ acqStarted = false;
+ }
+ }
+ // Surface scan
+ else if( (pscan == 1) && (vscan == 0) && (ascan == 0) )
+ {
+ // If already started, stop the acquisition
+ if(acqStarted)
+ {
+ printf("Stopping current surface scan...\n");
+ gROOT->SetInterrupt();
+ measProgress->widgetTB[0]->SetText("Start acquisition");
+ acqStarted = false;
+
+ // Write information to the finish_sig.txt value
+ sprintf(cmd, "%s/dbg/finish_sig.txt", rootdir);
+ pfin = fopen(cmd,"w");
+ fprintf(pfin, "%s: Surface scan stopped.", timeStamp->widgetTE->GetText());
+ fclose(pfin);
+ }
+ // If stopped, start the acquisition
+ else if(!acqStarted)
+ {
+ printf("Running a surface scan...\n");
+
+ minXpos = xPosMin->widgetNE[0]->GetNumber();
+ maxXpos = xPosMax->widgetNE[0]->GetNumber();
+ stepXpos = xPosStep->widgetNE[0]->GetNumber();
+ minYpos = yPosMin->widgetNE[0]->GetNumber();
+ maxYpos = yPosMax->widgetNE[0]->GetNumber();
+ stepYpos = yPosStep->widgetNE[0]->GetNumber();
+ minZpos = zPosMin->widgetNE[0]->GetNumber();
+ maxZpos = zPosMax->widgetNE[0]->GetNumber();
+ stepZpos = zPosStep->widgetNE[0]->GetNumber();
+
+ // Setting repetition for Z axis scan
+ if(zscan == 1)
+ {
+ if(stepZpos == 0.)
+ repetZ = 1;
+ else
+ {
+ // Example: min = 40, max = 70, step = 5 (in increasing steps)
+ if( (maxZpos > minZpos) && (stepZpos > 0) )
+ repetZ = ((maxZpos - minZpos)/stepZpos)+1;
+ // Example: min = 70, max = 40, step = -5 (in decreasing steps)
+ else if( (maxZpos < minZpos) && (stepZpos < 0) )
+ repetZ = ((minZpos - maxZpos)/stepZpos)-1;
+ // Example: min = 70, max = 70 (no scan)
+ else if( maxZpos == minZpos )
+ repetZ = 1;
+ // If step is not correctly set, stop the acqusition
+ else
+ {
+ // TODO
+ printf("Stopping current surface scan (Z step error)...\n");
+ gROOT->SetInterrupt();
+ measProgress->widgetTB[0]->SetText("Start acquisition");
+ acqStarted = false;
+ repetZ = 0;
+ }
+ }
+ }
+ else
+ {
+ minZpos = zPos->widgetNE[0]->GetNumber();
+ repetZ = 1;
+ }
+
+ // Setting repetition for X axis
+ if(stepXpos == 0.)
+ repetX = 1;
+ else
+ {
+ // Example: min = 40, max = 70, step = 5 (in increasing steps)
+ if( (maxXpos > minXpos) && (stepXpos > 0) )
+ repetX = ((maxXpos - minXpos)/stepXpos)+1;
+ // Example: min = 70, max = 40, step = -5 (in decreasing steps)
+ else if( (maxXpos < minXpos) && (stepXpos < 0) )
+ repetX = ((minXpos - maxXpos)/stepXpos)-1;
+ // Example: min = 70, max = 70 (no scan)
+ else if( maxXpos == minXpos )
+ repetX = 1;
+ // If step is not correctly set, stop the acqusition
+ else
+ {
+ // TODO
+ printf("Stopping current surface scan (X step error)...\n");
+ gROOT->SetInterrupt();
+ measProgress->widgetTB[0]->SetText("Start acquisition");
+ acqStarted = false;
+ repetX = 0;
+ }
+ }
+ // Setting repetition for Y axis
+ if(stepYpos == 0.)
+ repetY = 1;
+ else
+ {
+ // Example: min = 40, max = 70, step = 5 (in increasing steps)
+ if( (maxYpos > minYpos) && (stepYpos > 0) )
+ repetY = ((maxYpos - minYpos)/stepYpos)+1;
+ // Example: min = 70, max = 40, step = -5 (in decreasing steps)
+ else if( (maxYpos < minYpos) && (stepYpos < 0) )
+ repetY = ((minYpos - maxYpos)/stepYpos)-1;
+ // Example: min = 70, max = 70 (no scan)
+ else if( maxYpos == minYpos )
+ repetY = 1;
+ // If step is not correctly set, stop the acqusition
+ else
+ {
+ // TODO
+ printf("Stopping current surface scan (Y step error)...\n");
+ gROOT->SetInterrupt();
+ measProgress->widgetTB[0]->SetText("Start acquisition");
+ acqStarted = false;
+ repetY = 0;
+ }
+ }
+
+ if(DBGSIG) printf("StartAcq(): X axis repetition (%lf,%lf,%lf) = %d\n", minXpos, maxXpos, stepXpos, repetX);
+ if(DBGSIG) printf("StartAcq(): Y axis repetition (%lf,%lf,%lf) = %d\n", minYpos, maxYpos, stepYpos, repetY);
+ if(DBGSIG) printf("StartAcq(): Z axis repetition (%lf,%lf,%lf) = %d\n", minZpos, maxZpos, stepZpos, repetZ);
+
+ i = 0; j = 0; k = 0;
+
+ // TODO - Setting button text and acqStarted do not work!
+ measProgress->widgetTB[0]->SetText("Stop acquisition");
+ acqStarted = true;
+ progVal = 0.00;
+ measProgress->widgetPB->SetPosition(progVal);
+ gVirtualX->Update(1);
+
+ clkt0 = clock();
+ timet0 = time(NULL);
+
+ // Scan over Z axis
+ while(1)
+ {
+ if( (repetZ > 0) && (k == repetZ) ) break;
+ else if( (repetZ < 0) && (k == -repetZ) ) break;
+ else if( repetZ == 0 ) break;
+
+ fflush(stdout);
+ // Z-axis change
+ if( posUnits->widgetCB->GetSelected() == 0)
+ sprintf(cmd, "sudo %s/src/MIKRO/mikro_ctrl -n 3 -v %d -s la && %s/src/MIKRO/mikro_ctrl -n 3 -c m", rootdir, (int)(minZpos + stepZpos*k), rootdir);
+ else if( posUnits->widgetCB->GetSelected() == 1)
+ sprintf(cmd, "sudo %s/src/MIKRO/mikro_ctrl -n 3 -v %d -s la && %s/src/MIKRO/mikro_ctrl -n 3 -c m", rootdir, (int)((minZpos + stepZpos*k)/lenconversion), rootdir);
+#if WORKSTAT == 'I'
+ retTemp = system(cmd);
+#else
+ printf("Cmd: %s\n",cmd);
+#endif
+ fflush(stdout);
+
+ printf("Next Z position...\n");
+ sleep(2*doublewait);
+ zPos->widgetNE[0]->SetNumber(minZpos + stepZpos*k);
+ fflush(stdout);
+
+ // Scan over Y axis
+ while(1)
+ {
+ if( (repetY > 0) && (j == repetY) ) break;
+ else if( (repetY < 0) && (j == -repetY) ) break;
+ else if( repetY == 0 ) break;
+
+ fflush(stdout);
+ // Y-axis change
+ if( posUnits->widgetCB->GetSelected() == 0)
+ sprintf(cmd, "sudo %s/src/MIKRO/mikro_ctrl -n 2 -v %d -s la && %s/src/MIKRO/mikro_ctrl -n 2 -c m", rootdir, (int)(minYpos + stepYpos*j), rootdir);
+ else if( posUnits->widgetCB->GetSelected() == 1)
+ sprintf(cmd, "sudo %s/src/MIKRO/mikro_ctrl -n 2 -v %d -s la && %s/src/MIKRO/mikro_ctrl -n 2 -c m", rootdir, (int)((minYpos + stepYpos*j)/lenconversion), rootdir);
+#if WORKSTAT == 'I'
+ retTemp = system(cmd);
+#else
+ printf("Cmd: %s\n",cmd);
+#endif
+ fflush(stdout);
+
+ printf("Next Y position...\n");
+ sleep(2*doublewait);
+ yPos->widgetNE[0]->SetNumber(minYpos + stepYpos*j);
+ fflush(stdout);
+
+ // Scan over X axis
+ while(1)
+ {
+ if( (repetX > 0) && (i == repetX) ) break;
+ else if( (repetX < 0) && (i == -repetX) ) break;
+ else if( repetX == 0 ) break;
+
+ progVal = (float)(100.00/(abs(repetX)*abs(repetY)*abs(repetZ)))*(k*abs(repetX)*abs(repetY) + j*abs(repetX) + i);
+ measProgress->widgetPB->SetPosition(progVal);
+
+ TimeEstimate(clkt0, timet0, progVal, cmd, doublewait*((abs(repetX)+2)*abs(repetY)+2)*abs(repetZ));
+ measProgress->widgetTE->SetText(cmd);
+
+ gVirtualX->Update(1);
+
+ // X-axis change
+ if( posUnits->widgetCB->GetSelected() == 0)
+ sprintf(cmd, "sudo %s/src/MIKRO/mikro_ctrl -n 1 -v %d -s la && %s/src/MIKRO/mikro_ctrl -n 1 -c m", rootdir, (int)(minXpos + stepXpos*i), rootdir);
+ else if( posUnits->widgetCB->GetSelected() == 1)
+ sprintf(cmd, "sudo %s/src/MIKRO/mikro_ctrl -n 1 -v %d -s la && %s/src/MIKRO/mikro_ctrl -n 1 -c m", rootdir, (int)((minXpos + stepXpos*i)/lenconversion), rootdir);
+#if WORKSTAT == 'I'
+ retTemp = system(cmd);
+#else
+ printf("Cmd: %s\n",cmd);
+#endif
+ fflush(stdout);
+
+ printf("Next X position...\n");
+ fflush(stdout);
+
+ printf("Waiting for position change...\n");
+ sleep(doublewait);
+ xPos->widgetNE[0]->SetNumber(minXpos + stepXpos*i);
+ printf("Continuing...\n");
+
+ // Here comes function to start histogramming <<<<<<<<<<<<<<<<<<<<<<<<
+ RunMeas((void*)0, (j*repetX + i), scanon);
+
+ fflush(stdout);
+
+ i++;
+ }
+
+ i = 0;
+ printf("\n");
+
+ j++;
+ }
+
+ j = 0;
+
+ k++;
+ }
+printf("Time = %d\n", (int)time(NULL));
+
+ fflush(stdout);
+ printf("Measurement finished, returning to starting position...\n");
+ // X-axis return
+ if( posUnits->widgetCB->GetSelected() == 0)
+ sprintf(cmd, "sudo %s/src/MIKRO/mikro_ctrl -n 1 -v %d -s la && %s/src/MIKRO/mikro_ctrl -n 1 -c m", rootdir, (int)minXpos, rootdir);
+ else if( posUnits->widgetCB->GetSelected() == 1)
+ sprintf(cmd, "sudo %s/src/MIKRO/mikro_ctrl -n 1 -v %d -s la && %s/src/MIKRO/mikro_ctrl -n 1 -c m", rootdir, (int)(minXpos/lenconversion), rootdir);
+#if WORKSTAT == 'I'
+ retTemp = system(cmd);
+#else
+ printf("Cmd: %s\n",cmd);
+#endif
+ fflush(stdout);
+
+ // Y-axis return
+ if( posUnits->widgetCB->GetSelected() == 0)
+ sprintf(cmd, "sudo %s/src/MIKRO/mikro_ctrl -n 2 -v %d -s la && %s/src/MIKRO/mikro_ctrl -n 2 -c m", rootdir, (int)minYpos, rootdir);
+ else if( posUnits->widgetCB->GetSelected() == 1)
+ sprintf(cmd, "sudo %s/src/MIKRO/mikro_ctrl -n 2 -v %d -s la && %s/src/MIKRO/mikro_ctrl -n 2 -c m", rootdir, (int)(minYpos/lenconversion), rootdir);
+#if WORKSTAT == 'I'
+ retTemp = system(cmd);
+#else
+ printf("Cmd: %s\n",cmd);
+#endif
+
+ // Z-axis return
+ if( posUnits->widgetCB->GetSelected() == 0)
+ sprintf(cmd, "sudo %s/src/MIKRO/mikro_ctrl -n 3 -v %d -s la && %s/src/MIKRO/mikro_ctrl -n 3 -c m", rootdir, (int)minZpos, rootdir);
+ else if( posUnits->widgetCB->GetSelected() == 1)
+ sprintf(cmd, "sudo %s/src/MIKRO/mikro_ctrl -n 3 -v %d -s la && %s/src/MIKRO/mikro_ctrl -n 3 -c m", rootdir, (int)(minZpos/lenconversion), rootdir);
+#if WORKSTAT == 'I'
+ retTemp = system(cmd);
+#else
+ printf("Cmd: %s\n",cmd);
+#endif
+ xPos->widgetNE[0]->SetNumber(minXpos);
+ yPos->widgetNE[0]->SetNumber(minYpos);
+ zPos->widgetNE[0]->SetNumber(minZpos);
+
+ progVal = 100.00;
+ measProgress->widgetPB->SetPosition(progVal);
+ printf("\n");
+
+ // Write information to the finish_sig.txt value
+ sprintf(cmd, "%s/dbg/finish_sig.txt", rootdir);
+ pfin = fopen(cmd,"w");
+ fprintf(pfin, "%s: Surface scan finished.", timeStamp->widgetTE->GetText());
+ fclose(pfin);
+
+ measProgress->widgetTB[0]->SetText("Start acquisition");
+ acqStarted = false;
+ }
+ }
+ // Only angle scan
+ if( (ascan == 1) && (pscan == 0) && (vscan == 0) )
+ {
+ // If already started, stop the acquisition
+ if(acqStarted)
+ {
+ printf("Stopping current angle scan...\n");
+ gROOT->SetInterrupt();
+ measProgress->widgetTB[0]->SetText("Start acquisition");
+ acqStarted = false;
+
+ // Write information to the finish_sig.txt value
+ sprintf(cmd, "%s/dbg/finish_sig.txt", rootdir);
+ pfin = fopen(cmd,"w");
+ fprintf(pfin, "%s: Angle scan stopped.", timeStamp->widgetTE->GetText());
+ fclose(pfin);
+ }
+ // If stopped, start the acquisition
+ else if(!acqStarted)
+ {
+ printf("Running an incidence angle scan...\n");
+
+ // Check the steps
+ minAlpha = rotPosMin->widgetNE[0]->GetNumber();
+ maxAlpha = rotPosMax->widgetNE[0]->GetNumber();
+ stepAlpha = rotPosStep->widgetNE[0]->GetNumber();
+
+ if(stepAlpha == 0.)
+ repetAlpha = 1;
+ else
+ {
+ // Example: min = 40, max = 70, step = 5 (in increasing steps)
+ if( (maxAlpha > minAlpha) && (stepAlpha > 0) )
+ repetAlpha = ((maxAlpha - minAlpha)/stepAlpha)+1;
+ // Example: min = 70, max = 40, step = -5 (in decreasing steps)
+ else if( (maxAlpha < minAlpha) && (stepAlpha < 0) )
+ repetAlpha = ((minAlpha - maxAlpha)/stepAlpha)-1;
+ // Example: min = 70, max = 70 (no scan)
+ else if( maxAlpha == minAlpha )
+ repetAlpha = 1;
+ // If step is not correctly set, stop the acqusition
+ else
+ {
+ // TODO
+ printf("Stopping current incidence angle scan...\n");
+ gROOT->SetInterrupt();
+ measProgress->widgetTB[0]->SetText("Start acquisition");
+ acqStarted = false;
+ repetAlpha = 0;
+ }
+ }
+
+ if(DBGSIG) printf("StartAcq(): Angle repetition (%lf,%lf,%lf) = %d\n", minAlpha, maxAlpha, stepAlpha, repetAlpha);
+
+ int angleWait = TMath::Ceil(abs(rotPos->widgetNE[0]->GetNumber()-minAlpha)*15/(rotPos->widgetNE[0]->GetNumMax()));
+ if(rotUnits->widgetCB->GetSelected() == 1)
+ {
+ minAlpha = minAlpha/rotconversion;
+ maxAlpha = maxAlpha/rotconversion;
+ stepAlpha = stepAlpha/rotconversion;
+ }
+
+ i = 0;
+
+ // TODO - Setting button text and acqStarted do not work!
+ measProgress->widgetTB[0]->SetText("Stop acquisition");
+ acqStarted = true;
+ progVal = 0.00;
+ measProgress->widgetPB->SetPosition(progVal);
+ gVirtualX->Update(1);
+
+ clkt0 = clock();
+ timet0 = time(NULL);
+
+ // Setting angle to initial position
+ sprintf(cmd, "sudo %s/src/MIKRO/mikro_ctrl -n 4 -v %d -s la && %s/src/MIKRO/mikro_ctrl -n 4 -c m", rootdir, (int)minAlpha, rootdir);
+ if(rotUnits->widgetCB->GetSelected() == 0)
+ rotPos->widgetNE[0]->SetNumber(minAlpha);
+ else if(rotUnits->widgetCB->GetSelected() == 1)
+ rotPos->widgetNE[0]->SetNumber(minAlpha*rotconversion);
+#if WORKSTAT == 'I'
+ retTemp = system(cmd);
+#else
+ printf("Cmd: %s\n",cmd);
+#endif
+ fflush(stdout);
+
+ printf("Waiting for %ds for rotation platform to move into starting position...\n", angleWait);
+ sleep(angleWait);
+
+ while(1)
+ {
+ if( (repetAlpha > 0) && (i == repetAlpha) ) break;
+ else if( (repetAlpha < 0) && (i == -repetAlpha) ) break;
+ else if( repetAlpha == 0 ) break;
+
+ progVal = (float)(100.00/abs(repetAlpha))*i;
+ measProgress->widgetPB->SetPosition(progVal);
+
+ TimeEstimate(clkt0, timet0, progVal, cmd, singlewait*abs(repetAlpha));
+ measProgress->widgetTE->SetText(cmd);
+
+ gVirtualX->Update(1);
+
+ fflush(stdout);
+ currentAlpha = minAlpha + stepAlpha*i;
+ sprintf(cmd, "sudo %s/src/MIKRO/mikro_ctrl -n 4 -v %d -s la && %s/src/MIKRO/mikro_ctrl -n 4 -c m", rootdir, (int)currentAlpha, rootdir);
+#if WORKSTAT == 'I'
+ retTemp = system(cmd);
+#else
+ printf("Cmd: %s\n",cmd);
+#endif
+ fflush(stdout);
+
+ printf("Waiting for angle change...\n");
+ sleep(singlewait);
+ if(rotUnits->widgetCB->GetSelected() == 0)
+ rotPos->widgetNE[0]->SetNumber(currentAlpha);
+ else if(rotUnits->widgetCB->GetSelected() == 1)
+ rotPos->widgetNE[0]->SetNumber(currentAlpha*rotconversion);
+ gVirtualX->Update(1);
+ printf("Continuing...\n");
+
+ // Here comes function to start histogramming <<<<<<<<<<<<<<<<<<<<<<<<
+ RunMeas((void*)0, i, scanon); // TODO
+ fflush(stdout);
+
+ i++;
+ }
+
+ // Set angle back to original position
+ fflush(stdout);
+ printf("Measurement finished, returning to starting incidence angle...\n");
+ sprintf(cmd, "sudo %s/src/MIKRO/mikro_ctrl -n 4 -v %d -s la && %s/src/MIKRO/mikro_ctrl -n 4 -c m", rootdir, (int)minAlpha, rootdir);
+ if(rotUnits->widgetCB->GetSelected() == 0)
+ rotPos->widgetNE[0]->SetNumber(minAlpha);
+ else if(rotUnits->widgetCB->GetSelected() == 1)
+ rotPos->widgetNE[0]->SetNumber(minAlpha*rotconversion);
+#if WORKSTAT == 'I'
+ retTemp = system(cmd);
+#else
+ printf("Cmd: %s\n",cmd);
+#endif
+ fflush(stdout);
+
+ progVal = 100.00;
+ measProgress->widgetPB->SetPosition(progVal);
+ printf("\n");
+
+ sprintf(cmd, "%s/dbg/finish_sig.txt", rootdir);
+ pfin = fopen(cmd,"w");
+ fprintf(pfin, "%s: Incidence angle scan finished.", timeStamp->widgetTE->GetText());
+ fclose(pfin);
+
+ measProgress->widgetTB[0]->SetText("Start acquisition");
+ acqStarted = false;
+ }
+ }
+ // Normal single measurement
+ else if( (vscan == 0) && (pscan == 0) && (ascan == 0) )
+ {
+ // Set the start button to stop and enable stopping of measurement
+ if(acqStarted)
+ {
+ printf("Stopping current single scan...\n");
+ gROOT->SetInterrupt();
+ measProgress->widgetTB[0]->SetText("Start acquisition");
+ acqStarted = false;
+ }
+ else if(!acqStarted)
+ {
+ measProgress->widgetTB[0]->SetText("Stop acquisition");
+ acqStarted = true;
+
+ printf("Running a single scan...\n");
+ clkt0 = clock();
+ timet0 = time(NULL);
+ RunMeas((void*)0, 0, scanon);
+ printf("Measurement finished...\n");
+ printf("\n");
+
+ measProgress->widgetTB[0]->SetText("Start acquisition");
+ acqStarted = false;
+ }
+ }
+}
+
+// Main measurement window connections ----------------------
+
+// Histogram file selection pane connections ----------------
+
+// File browser for opening histograms
+void TGAppMainFrame::SelectDirectory()
+{
+ int i = fileList->GetNumberOfEntries();
+ char *cTemp;
+
+ TGFileInfo file_info;
+ const char *filetypes[] = {"Histograms",histextall,0,0};
+ file_info.fFileTypes = filetypes;
+ cTemp = new char[1024];
+ sprintf(cTemp, "%s/results", rootdir);
+ file_info.fIniDir = StrDup(cTemp);
+ file_info.fMultipleSelection = kTRUE;
+ new TGFileDialog(gClient->GetDefaultRoot(), fMain, kFDOpen, &file_info);
+ delete[] cTemp;
+
+ TList *files = file_info.fFileNamesList;
+ if(files)
+ {
+ TSystemFile *file;
+ TString fname;
+ TIter next(files);
+ while(file=(TSystemFile*)next())
+ {
+ fname = file->GetName();
+ fileList->AddEntry(fname.Data(), i);
+ i++;
+ }
+ }
+ fileList->Layout();
+}
+
+// Toggle multiple selection in filelist or delete all entries
+void TGAppMainFrame::ListMultiSelect(int opt)
+{
+ // Enable multiselect
+ if(opt == 0)
+ {
+ fileList->SetMultipleSelections((multiSelect->widgetChBox[0]->IsOn()));
+
+ if(multiSelect->widgetChBox[1]->IsDown())
+ multiSelect->widgetChBox[1]->SetState(kButtonUp);
+ }
+ else if(opt == 1)
+ {
+ if(multiSelect->widgetChBox[1]->IsDown())
+ {
+ multiSelect->widgetChBox[0]->SetState(kButtonDown);
+ fileList->SetMultipleSelections((multiSelect->widgetChBox[0]->IsOn()));
+ for(int i = 0; i < fileList->GetNumberOfEntries(); i++)
+ fileList->Select(i,kTRUE);
+ }
+ else if(!multiSelect->widgetChBox[1]->IsDown())
+ {
+ multiSelect->widgetChBox[0]->SetState(kButtonUp);
+ fileList->SetMultipleSelections((multiSelect->widgetChBox[0]->IsOn()));
+ for(int i = 0; i < fileList->GetNumberOfEntries(); i++)
+ fileList->Select(i,kFALSE);
+ }
+ }
+}
+
+// Navigation buttons for the filelist (<<, >>) and double click
+void TGAppMainFrame::FileListNavigation(int opt)
+{
+ unsigned int nrfiles = fileList->GetNumberOfEntries();
+ int curSel;
+ TList *files;
+ if( nrfiles > 0 )
+ {
+ if(opt < -1)
+ {
+ // turn off multiple selection and select first file on list
+ if(multiSelect->widgetChBox[0]->IsOn())
+ {
+ fileList->SetMultipleSelections(kFALSE);
+ multiSelect->widgetChBox[0]->SetState(kButtonUp);
+ multiSelect->widgetChBox[1]->SetState(kButtonUp);
+
+ fileList->Select(0,kTRUE);
+ }
+ else
+ {
+ // if nothing is selected, curSel will be -1
+ curSel = fileList->GetSelected();
+ // go to next file on list
+ if(opt == -3)
+ {
+ if( (curSel == (int)(nrfiles-1)) || (curSel == -1) )
+ fileList->Select(0);
+ else
+ fileList->Select(curSel+1);
+ }
+ // go to previous file on list
+ else if(opt == -2)
+ {
+ if( (curSel == 0) || (curSel == -1) )
+ fileList->Select(nrfiles-1);
+ else
+ fileList->Select(curSel-1);
+ }
+ }
+ }
+ }
+
+ UpdateHistogram(0);
+}
+
+// Open the header edit window when pressing on editHeader button
+void TGAppMainFrame::HeaderEdit()
+{
+ bool createTab = true;
+ int tabid = -1;
+
+ for(int i = 0; i < fTab->GetNumberOfTabs(); i++)
+ {
+ if(strcmp("File header editor", fTab->GetTabTab(i)->GetString() ) == 0)
+ {
+ createTab = false;
+ tabid = i;
+ }
+
+ if(DBGSIG > 1) printf("HeaderEdit(): Name of tab = %s\n", fTab->GetTabTab(i)->GetString() );
+ }
+
+ unsigned int nrfiles = fileList->GetNumberOfEntries();
+ if(nrfiles > 0)
+ HeaderEditTab(fTab, createTab, &tabid);
+}
+
+// Clear the histogram file selection list and dark run analysis selection
+void TGAppMainFrame::ClearHistogramList()
+{
+ fileList->RemoveAll();
+ darkRun->widgetTE->Clear();
+}
+
+// Histogram file selection pane connections ----------------
+
+// Histogram controls pane connections ----------------------
+
+// Readjust the histogram range after changing ADC, TDC, Y range or logarithmic scale (opt: 0 = normal redraw, 1 = export, 2 = redraw when changing which channel to display)
+void TGAppMainFrame::UpdateHistogram(int opt)
+{
+ if(DBGSIG > 1)
+ {
+ printf("UpdateHistogram(): Clearing the TList\n");
+ gDirectory->GetList()->Delete();
+ gObjectTable->Print();
+ }
+
+ // Do not do normal histogram update if we have multiple files selected
+ if( (opt == 0) && (multiSelect->widgetChBox[0]->IsDown()) )
+ {
+ printf("UpdateHistogram(): To preview changes done to a histogram, please deselect the \"Multiple files select\" option.");
+ return;
+ }
+
+ // Do not update histogram if we are on the same channel
+ if( ((opt == 2) && (selChannel != (int)selectCh->widgetNE[0]->GetNumber())) || (opt < 2) )
+ {
+ unsigned int nrfiles = fileList->GetNumberOfEntries();
+ TCanvas *gCanvas;
+ char exportname[512];
+ char cTemp[512];
+
+ if(opt == 1)
+ gCanvas = analysisCanvas->GetCanvas();
+
+ if(nrfiles > 0)
+ {
+ TList *files;
+ files = new TList();
+ fileList->GetSelectedEntries(files);
+
+ if(files)
+ {
+ for(int i = 0; i < (int)nrfiles; i++)
+ {
+ if(files->At(i))
+ {
+ if(DBGSIG)
+ printf("UpdateHistogram(): Filename: %s\n", files->At(i)->GetTitle());
+ if(opt == 1)
+ remove_ext((char*)files->At(i)->GetTitle(), cTemp);
+ if( fMenuHisttype->IsEntryChecked(M_ANALYSIS_HISTTYPE_1DADC) )
+ {
+ sprintf(exportname, "%s_adc%d.pdf", cTemp, (int)selectCh->widgetNE[0]->GetNumber());
+ DisplayHistogram( (char*)(files->At(i)->GetTitle()), 0, opt);
+ }
+ else if( fMenuHisttype->IsEntryChecked(M_ANALYSIS_HISTTYPE_1DTDC) )
+ {
+ sprintf(exportname, "%s_tdc%d.pdf", cTemp, (int)selectCh->widgetNE[0]->GetNumber());
+ DisplayHistogram( (char*)(files->At(i)->GetTitle()), 1, opt);
+ }
+ else if( fMenuHisttype->IsEntryChecked(M_ANALYSIS_HISTTYPE_2D) )
+ {
+ sprintf(exportname, "%s_adctdc%d.pdf", cTemp, (int)selectCh->widgetNE[0]->GetNumber());
+ DisplayHistogram( (char*)(files->At(i)->GetTitle()), 2, opt);
+ }
+
+ if(opt == 1)
+ {
+ gCanvas->SaveAs(exportname);
+ delete inroot;
+ }
+ }
+ }
+ }
+ }
+ selChannel = selectCh->widgetNE[0]->GetNumber();
+ }
+
+ if(DBGSIG > 1)
+ {
+ printf("UpdateHistogram(): After drawing histograms (connections)\n");
+ gObjectTable->Print();
+ }
+}
+
+// Options for histogram (logarithmic scale, clean plots)
+void TGAppMainFrame::HistogramOptions(int opt)
+{
+ // Logarithmic scale
+ if(opt == 0)
+ UpdateHistogram(0);
+ // Clean plots
+ else if(opt == 1)
+ {
+ cleanPlots = histOpt->widgetChBox[1]->IsDown();
+ UpdateHistogram(0);
+ }
+}
+
+// Changing the histogram type to display
+void TGAppMainFrame::ChangeHisttype(int type)
+{
+ TGTextButton *pressedB = new TGTextButton();
+ int menuID = 0;
+ unsigned int nrfiles = fileList->GetNumberOfEntries();
+
+ // ADC histogram
+ if(type == 0)
+ {
+ pressedB = plotType->widgetTB[0];
+ menuID = M_ANALYSIS_HISTTYPE_1DADC;
+
+ plotType->widgetTB[1]->SetDown(kFALSE);
+ plotType->widgetTB[2]->SetDown(kFALSE);
+ fMenuHisttype->UnCheckEntry(M_ANALYSIS_HISTTYPE_1DTDC);
+ fMenuHisttype->UnCheckEntry(M_ANALYSIS_HISTTYPE_2D);
+ }
+ // TDC histogram
+ else if(type == 1)
+ {
+ pressedB = plotType->widgetTB[1];
+ menuID = M_ANALYSIS_HISTTYPE_1DTDC;
+
+ plotType->widgetTB[0]->SetDown(kFALSE);
+ plotType->widgetTB[2]->SetDown(kFALSE);
+ fMenuHisttype->UnCheckEntry(M_ANALYSIS_HISTTYPE_1DADC);
+ fMenuHisttype->UnCheckEntry(M_ANALYSIS_HISTTYPE_2D);
+ }
+ // ADC vs. TDC histogram
+ else if(type == 2)
+ {
+ pressedB = plotType->widgetTB[2];
+ menuID = M_ANALYSIS_HISTTYPE_2D;
+
+ plotType->widgetTB[0]->SetDown(kFALSE);
+ plotType->widgetTB[1]->SetDown(kFALSE);
+ fMenuHisttype->UnCheckEntry(M_ANALYSIS_HISTTYPE_1DADC);
+ fMenuHisttype->UnCheckEntry(M_ANALYSIS_HISTTYPE_1DTDC);
+ }
+
+ if( fMenuHisttype->IsEntryChecked(menuID) )
+ {
+ pressedB->SetDown(kFALSE);
+ fMenuHisttype->UnCheckEntry(menuID);
+ }
+ else if( !fMenuHisttype->IsEntryChecked(menuID) )
+ {
+ pressedB->SetDown(kTRUE);
+ fMenuHisttype->CheckEntry(menuID);
+ }
+
+ UpdateHistogram(0);
+}
+
+// Histogram controls pane connections ----------------------
Index: sipmscan/trunk/src/daqscope.C
===================================================================
--- sipmscan/trunk/src/daqscope.C (nonexistent)
+++ sipmscan/trunk/src/daqscope.C (revision 146)
@@ -0,0 +1,390 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "../include/vxi11_x86_64/vxi11_user.h"
+#include "../include/daqscope.h"
+#include "../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)
+ {
+ vxi11_send(clink, "*IDN?");
+ vxi11_receive(clink, buf, WAVE_LEN);
+ printf("Connected to device (%s): %s\n", IPaddr, buf);
+ savedIP = IPaddr;
+ return iTemp;
+ }
+ 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;
+ }
+ 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
+ sprintf(posoff, "Just some temporary string info.");
+ 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;
+}
+
+daqscope::~daqscope() {
+ disconnect(savedIP);
+}
+// ---------------------------------------------------------------
Index: sipmscan/trunk/src/daqusb.C
===================================================================
--- sipmscan/trunk/src/daqusb.C (nonexistent)
+++ sipmscan/trunk/src/daqusb.C (revision 146)
@@ -0,0 +1,258 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <errno.h>
+#include <signal.h>
+#include <ctype.h>
+#include <time.h>
+//#include "../include/wusbxx_dll.h" /* the header of the shared library */
+#include "../include/daq.h"
+
+//#define DEBUG /* vkljuci dodatni izpis */
+#ifdef DEBUG
+ #define DBG(X) X
+ #define DBGFUNI(X) printf(">>> %s -> %d\n",#X,(X))
+#else
+ #define DBG(X)
+ #define DBGFUNI(X) X
+#endif
+
+/* definiram lokacije enot*/
+//#define NTDC 1 /* TDC */
+//#define NTDCCH 8
+//#define NADC 2 /* ADC */
+//#define NADCCH 8
+int ctrlc=0;
+char *ccserial=(char*)"CC0126";
+int devDetect; // variable to tell if we detect any devices
+
+int daq::connect(){
+// odpri daq
+/* xxusb_device_type devices[100];
+ //struct usb_device *dev;
+ devDetect = xxusb_devices_find(devices);
+// printf("Detected devices: %d\n", devDetect);
+ //dev = devices[0].usbdev;
+ //udev = xxusb_device_open(dev);
+
+ if(devDetect > 0)
+ {
+ WUSBXX_load(NULL);
+ WUSBXX_open(ccserial);
+ printf("daq::connect()\n");
+ }
+ else
+*/ printf("daq::connect() - No devices were detected!\n");
+ return 0;
+}
+
+int daq::init(int chan = 0){
+
+// 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);
+
+ CCCZ;
+ CCCC;
+ CREM_I;
+
+ NTDC = 1;
+ NADC = 2;
+ if(chan != 0)
+ {
+ NTDCCH = chan/2;
+ NADCCH = chan/2;
+ }
+ else
+ {
+ NTDCCH = 1;
+ NADCCH = 1;
+ }
+ printf("after: NTDCCH = %d, NADCCH = %d\n", NTDCCH, NADCCH);
+
+// create command stack for the TDC and ADC
+ k=1;
+ for(i=0;(i<NTDCCH)&&(i<NADCCH);i++) { stackwrite[k++]=NAF(NTDC,i,0); stackwrite[k++]=NAF(NADC,i,0); }
+// for(i=0;i<NADCCH;i++) stackwrite[k++]=NAF(NADC,i,0);
+ stackwrite[k++]=NAF(NTDC,0,9);
+ stackwrite[k++]=NAF(NADC,0,9);
+ stackwrite[k++]=NAFS(0,0,16); // insert next word to data
+ stackwrite[k++]=0xfafb; // event termination word
+ stackwrite[0]=k-1;
+// upload stack #2
+ xxusb_stack_write(udev,0x2,(long int *)stackwrite);
+ xxusb_stack_read(udev,0x2,(long int *) stackdata);
+ DBG(for(i=0;i<k;i++) printf("0x%04x\n",stackdata[i]);)
+
+ int ret[10];
+
+ CAMAC_LED_settings(udev, 1,1,0,0);
+ ret[0] = CAMAC_register_read(udev,0,&k);
+ printf("Firmware ID (return %d) -> 0x%08lX\n",ret[0],k); // GKM: Firmware ID (i.e. 0x72000001 = 0111 0010 0000 0000 0000 0000 0000 0001)
+ ret[1] = CAMAC_register_read(udev,1,&k);
+ printf("Global Mode (return %d) -> 0x%08lX\n",ret[1],k);
+ k=(k&0xF000)|0x0005; // set buffer length: n=0..6 -> 0x10000 >> n, n=7 -> single event
+ ret[0] = CAMAC_register_write(udev,1,k); // GKM: sets the buffer length (i.e. k=5 -> buf length=128 words)
+ ret[1] = CAMAC_register_write(udev,2,0x80); // wait 0x80 us after trigger // GKM: delay settings in microseconds
+ ret[2] = CAMAC_register_write(udev,3,0x0); // Scaler Readout Control Register // GKM: scaler readout settings - sets the frequency of readout (if 0, it is disabled)
+ ret[3] = CAMAC_register_write(udev,9,0x0); // Lam Mask Register // GKM: When 0, readout is triggered by the signal on NIM input
+ ret[4] = CAMAC_register_write(udev,14,0x0); // USB Bulk Transfer Setup Register
+
+ // CAMAC_DGG(udev,1,2,3,0,200,0,0);
+ // CAMAC_DGG(udev,0,0,0,0,100,0,0);
+ ret[5] = CAMAC_register_write(udev,5,(0x06<<16)+(0x04<<8)+0x00); // output // GKM: NIM outputs (i.e. 0x060400 = 00 0110 0000 0100 0000 0000 -> NIM O2=DGG_B, NIM O3=DGG_A)
+ ret[6] = CAMAC_register_write(udev,6,(0x01<<24)+(0x01<<16)+(0x0<<8)+0x0); // SCLR & DGG // GKM: device source selector (i.e. 0x01010000 = 00 0000 0001 0000 0001 0000 0000 0000 0000 -> DGG_A=NIM I1, DGG_B=NIM I1, SCLR=disabled)
+ ret[7] = CAMAC_register_write(udev,7,(100<<16)+0); // output // GKM: Delay and Gate Generator A registers (i.e. 0x00640000 = 0000 0000 0110 0100 0000 0000 0000 0000 -> DDG_A [gate=100, delay=0])
+ ret[8] = CAMAC_register_write(udev,8,(10000<<16)+0); // output // GKM: Delay and Gate Generator B registers (i.e. 0x27100000 = 0010 0111 0001 0000 0000 0000 0000 0000 -> DDG_B [gate=10000, delay=0])
+ ret[9] = CAMAC_register_write(udev,13,0); // output // GKM: Extended (course) delay (i.e. 0x00000000 = 0 -> DDG_A ext=0, DDG_B ext=0)
+
+// for(i = 0; i < 10; i++) printf("Setting %d? -> return = %d\n",i,ret[i]);
+
+// ret[0] = CAMAC_register_read(udev,1,&k);
+// printf("k (return %d) -> 0x%08lX\n",ret[0],k);
+
+*/ printf("daq::init()\n");
+ return 0;
+}
+
+int daq::start(){
+// xxusb_register_write(udev,1,0x1); // Start DAQ mode
+ printf("daq::start()\n");
+ return 0;
+}
+
+int daq::stop(){
+// xxusb_register_write(udev,1,0x0); // Stop DAQ mode
+// while (xxusb_usbfifo_read(udev,(int *)stackdump,BUFF_L,30)>0);
+ printf("daq::stop()\n");
+ return 0;
+}
+
+int daq::event(unsigned int *data, int maxn){
+// int ib,count;
+ int count;
+/* int events,evsize;
+ short ret;
+
+ ib=0;
+ ret=xxusb_usbfifo_read(udev,(int *) stackdata,BUFF_L,500);
+ events=stackdata[ib++];
+ DBG(printf("ret=%d,events=0x%08x\n",ret,events);)
+ if ((ret<0)||(ret!=(((NTDCCH+NADCCH)*4+4)*events+4))) return 0;
+
+ count=0;
+ while (ib<(ret/2-1)){
+ evsize = stackdata[ib++]&0xffff;
+ DBG(printf("Event:%d EvSize:%d\n", events, evsize);)
+ for (int i=0;i<(NTDCCH+NADCCH);i++,ib++) data[count++] =stackdata[ib++]&0xffff;
+ if (stackdata[ib++]!=0xfafb){
+ printf("Error!\n");,
+ return 0;
+ }
+ events--;
+ if (fStop) return 0;
+ }
+ if (stackdata[ib++]!=0xffff){
+ printf("Error!\n");
+ return 0;
+ }
+*/
+ count = 1;
+ return count;
+}
+
+int daq::disconnect(){
+// zapri daq
+// WUSBXX_close();
+ printf("daq::disconnect()\n");
+ return 0;
+}
+
+daq::daq(){
+ fStop=0;
+ connect();
+// if(devDetect > 0)
+// init();
+}
+
+daq::~daq(){
+disconnect();
+}
+
+#ifdef MAIN
+void CatchSig (int signumber)
+{
+ ctrlc = 1;
+}
+
+
+int main (int argc, char **argv){
+
+ int neve=1000000;
+ char *fname="test.dat";
+ if (argc==1) {
+ printf("Uporaba: %s stevilo_dogodkov ime_datoteke\n",argv[0]);
+ printf("Meritev prekini s Ctrl-C, ce je nabranih dogodkov ze dovolj\n");
+ exit(0);
+ }
+ if (argc>1) neve = atoi(argv[1]);
+ if (argc>2) fname = argv[2];
+
+
+// intercept routine
+ if (signal (SIGINT, CatchSig) == SIG_E,RR) perror ("sigignore");
+
+#define BSIZE 10000
+ int i,ieve,nc,nb;
+// int hdr[4]={1,(NTDCCH+4)*sizeof(int)}; // hdr[0]=1, hdr[1]=(NTDCCH+4)*4
+ int hdr[4]={1,(NTDCCH+NADCCH+4)*sizeof(int)};
+ unsigned short adc;
+ unsigned int data[BSIZE];
+ daq *d= new daq();,
+ time_t time_check;,
+
+// odpremo datoteko za pisanje
+ FILE *fp=fopen(fname,"w");
+
+ d->start();
+ ieve=0;
+
+ while((ieve<neve)&&(!ctrlc)){
+ nc=d->event(data,BSIZE);
+ nb=0;
+ while((nc>0)&&(ieve++<neve)&&(!ctrlc)){
+ // zapis v datoteko
+ hdr[2]=time(NULL);
+ hdr[3]=ieve;
+ fwrite(hdr,sizeof(int),4 ,fp);
+ fwrite(&data[nb],sizeof(int),(NTDCCH+NADCCH),fp);
+// DBG(
+ for(i=0;i<(NTDCCH+NADCCH);i++){
+ adc=data[nb+i]&0xFFFF;
+ if(i % 2 == 0)
+printf(/*"nev=%4d %d. TDC data=%d\n"*/"%d\t"/*,ieve,i*//*/2*/,adc);
+// printf("nev=%4d %d. TDC data=%d\n",ieve,i/2,adc);
+ else if(i % 2 == 1)
+printf(/*"nev=%4d %d. TDC data=%d\n"*/"%d\t"/*,ieve,i*//*/2*/,adc);
+// printf("nev=%4d %d. ADC data=%d\n",ieve,i/2,adc);
+ }
+printf("\n");
+// )
+ nb+=(NTDCCH+NADCCH);
+ nc-=(NTDCCH+NADCCH);
+ if (!(ieve%1000)) printf("event no. -> %d\n",ieve);
+ };
+ };
+
+ d->stop();
+ fclose(fp);
+ printf("Podatki so v datoteki %s\n", fname);
+ delete d;
+
+ return 0;
+}
+#endif
Index: sipmscan/trunk/src/libxxusb.cpp
===================================================================
--- sipmscan/trunk/src/libxxusb.cpp (nonexistent)
+++ sipmscan/trunk/src/libxxusb.cpp (revision 146)
@@ -0,0 +1,1651 @@
+
+// libxxusb.cpp : Defines the entry point for the DLL application.
+//
+
+
+
+#include <string.h>
+#include <malloc.h>
+//#include "usb.h"
+#include "../include/libxxusb.h"
+#include <time.h>
+
+
+
+
+// 03/09/06 Release 3.00 changes
+// 07/28/06 correction CAMAC write for F to be in range 16...23
+// 10/09/06 correction CAMAC read for F to be in range <16 OR >23
+// 10/16/06 CAMAC DGG corrected
+// 12/28/07 Open corrected for bug when calling register after opening
+/*
+******** xxusb_longstack_execute ************************
+
+ Executes stack array passed to the function and returns the data read from the VME bus
+
+ Paramters:
+ hdev: USB device handle returned from an open function
+ DataBuffer: pointer to the dual use buffer
+ when calling , DataBuffer contains (unsigned short) stack data, with first word serving
+ as a placeholder
+ upon successful return, DataBuffer contains (unsigned short) VME data
+ lDataLen: The number of bytes to be fetched from VME bus - not less than the actual number
+ expected, or the function will return -5 code. For stack consisting only of write operations,
+ lDataLen may be set to 1.
+ timeout: The time in ms that should be spent tryimg to write data.
+
+ Returns:
+ When Successful, the number of bytes read from xxusb.
+ Upon failure, a negative number
+
+ Note:
+ The function must pass a pointer to an array of unsigned integer stack data, in which the first word
+ is left empty to serve as a placeholder.
+ The function is intended for executing long stacks, up to 4 MBytes long, both "write" and "read"
+ oriented, such as using multi-block transfer operations.
+ Structure upon call:
+ DataBuffer(0) = 0(don't care place holder)
+ DataBuffer(1) = (unsigned short)StackLength bits 0-15
+ DataBuffer(2) = (unsigned short)StackLength bits 16-20
+ DataBuffer(3 - StackLength +2) (unsigned short) stack data
+ StackLength represents the number of words following DataBuffer(1) word, thus the total number
+ of words is StackLength+2
+ Structure upon return:
+ DataBuffer(0 - (ReturnValue/2-1)) - (unsigned short)array of returned data when ReturnValue>0
+*/
+
+int xxusb_longstack_execute(usb_dev_handle *hDev, void *DataBuffer, int lDataLen, int timeout)
+{
+ int ret;
+ char *cbuf;
+ unsigned short *usbuf;
+ int bufsize;
+
+ cbuf = (char *)DataBuffer;
+ usbuf = (unsigned short *)DataBuffer;
+ cbuf[0]=12;
+ cbuf[1]=0;
+ bufsize = 2*(usbuf[1]+0x10000*usbuf[2])+4;
+ ret=usb_bulk_write(hDev, XXUSB_ENDPOINT_OUT, cbuf, bufsize, timeout);
+ if (ret>0)
+ ret=usb_bulk_read(hDev, XXUSB_ENDPOINT_IN, cbuf, lDataLen, timeout);
+
+ return ret;
+}
+
+/*
+******** xxusb_bulk_read ************************
+
+ Reads the content of the usbfifo whenever "FIFO full" flag is set,
+ otherwise times out.
+
+ Paramters:
+ hdev: USB device handle returned from an open function
+ DataBuffer: pointer to an array to store data that is read from the VME bus;
+ the array may be declared as byte, unsigned short, or unsigned long
+ lDatalen: The number of bytes to read from xxusb
+ timeout: The time in ms that should be spent waiting for data.
+
+ Returns:
+ When Successful, the number of bytes read from xxusb.
+ Upon failure, a negative number
+
+ Note:
+ Depending upon the actual need, the function may be used to return the data in a form
+ of an array of bytes, unsigned short integers (16 bits), or unsigned long integers (32 bits).
+ The latter option of passing a pointer to an array of unsigned long integers is meaningful when
+ xxusb data buffering option is used (bit 7=128 of the global register) that requires data
+ 32-bit data alignment.
+
+*/
+int xxusb_bulk_read(usb_dev_handle *hDev, void *DataBuffer, int lDataLen, int timeout)
+{
+int ret;
+char *cbuf;
+cbuf = (char *)DataBuffer;
+ ret = usb_bulk_read(hDev, XXUSB_ENDPOINT_IN, cbuf, lDataLen, timeout);
+ return ret;
+}
+
+/*
+******** xxusb_bulk_write ************************
+
+ Writes the content of an array of bytes, unsigned short integers, or unsigned long integers
+ to the USB port fifo; times out when the USB fifo is full (e.g., when xxusb is busy).
+
+ Paramters:
+ hdev: USB device handle returned from an open function
+ DataBuffer: pointer to an array storing the data to be sent;
+ the array may be declared as byte, unsigned short, or unsigned long
+ lDatalen: The number of bytes to to send to xxusb
+ timeout: The time in ms that should be spent waiting for data.
+
+ Returns:
+ When Successful, the number of bytes passed to xxusb.
+ Upon failure, a negative number
+
+ Note:
+ Depending upon the actual need, the function may be used to pass to xxusb the data in a form
+ of an array of bytes, unsigned short integers (16 bits), or unsigned long integers (32 bits).
+*/
+int xxusb_bulk_write(usb_dev_handle *hDev, void *DataBuffer, int lDataLen, int timeout)
+{
+int ret;
+char *cbuf;
+cbuf = (char *)DataBuffer;
+ ret = usb_bulk_write(hDev, XXUSB_ENDPOINT_OUT, cbuf, lDataLen, timeout);
+ return ret;
+}
+
+/*
+******** xxusb_usbfifo_read ************************
+
+ Reads data stored in the xxusb fifo and packs them in an array of long integers.
+
+ Paramters:
+ hdev: USB device handle returned from an open function
+ DataBuffer: pointer to an array of long to store data that is read
+ the data occupy only the least significant 16 bits of the 32-bit data words
+ lDatalen: The number of bytes to read from the xxusb
+ timeout: The time in ms that should be spent waiting for data.
+
+ Returns:
+ When Successful, the number of bytes read from xxusb.
+ Upon failure, a negative number
+
+ Note:
+ The function is not economical as it wastes half of the space required for storing
+ the data received. Also, it is relatively slow, as it performs extensive data repacking.
+ It is recommended to use xxusb_bulk_read with a pointer to an array of unsigned short
+ integers.
+*/
+int xxusb_usbfifo_read(usb_dev_handle *hDev, int *DataBuffer, int lDataLen, int timeout)
+{
+int ret;
+char *cbuf;
+unsigned short *usbuf;
+int i;
+
+cbuf = (char *)DataBuffer;
+usbuf = (unsigned short *)DataBuffer;
+
+ ret = usb_bulk_read(hDev, XXUSB_ENDPOINT_IN, cbuf, lDataLen, timeout);
+ if (ret > 0)
+ for (i=ret/2-1; i >= 0; i=i-1)
+ {
+ usbuf[i*2]=usbuf[i];
+ usbuf[i*2+1]=0;
+ }
+ return ret;
+}
+
+
+//******************************************************//
+//******************* GENERAL XX_USB *******************//
+//******************************************************//
+// The following are functions used for both VM_USB & CC_USB
+
+
+/*
+******** xxusb_register_write ************************
+
+ Writes Data to the xxusb register selected by RedAddr. For
+ acceptable values for RegData and RegAddr see the manual
+ the module you are using.
+
+ Parameters:
+ hdev: usb device handle returned from open device
+ RegAddr: The internal address if the xxusb
+ RegData: The Data to be written to the register
+
+ Returns:
+ Number of bytes sent to xxusb if successful
+ 0 if the register is write only
+ Negative numbers if the call fails
+*/
+short xxusb_register_write(usb_dev_handle *hDev, short RegAddr, long RegData)
+{
+ long RegD;
+ char buf[8]={5,0,0,0,0,0,0,0};
+ int ret;
+ int lDataLen;
+ int timeout;
+ if ((RegAddr==0) || (RegAddr==12) || (RegAddr==15))
+ return 0;
+ buf[2]=(char)(RegAddr & 15);
+ buf[4]=(char)(RegData & 255);
+
+ RegD = RegData >> 8;
+ buf[5]=(char)(RegD & 255);
+ RegD = RegD >>8;
+ if (RegAddr==8)
+ {
+ buf[6]=(char)(RegD & 255);
+ lDataLen=8;
+ }
+ else
+ lDataLen=6;
+ timeout=10;
+ ret=xxusb_bulk_write(hDev, buf, lDataLen, timeout);
+ return ret;
+}
+
+/*
+******** xxusb_stack_write ************************
+
+ Writes a stack of VME/CAMAC calls to the VM_USB/CC_USB
+ to be executed upon trigger.
+
+ Parameters:
+ hdev: usb device handle returned from an open function
+ StackAddr: internal register to which the stack should be written
+ lpStackData: Pointer to an array holding the stack
+
+ Returns:
+ The number of Bytes written to the xxusb when successful
+ A negative number upon failure
+*/
+short xxusb_stack_write(usb_dev_handle *hDev, short StackAddr, long *intbuf)
+{
+ int timeout;
+ short ret;
+ short lDataLen;
+ char buf[2000];
+ short i;
+ int bufsize;
+
+ buf[0]=(char)((StackAddr & 51) + 4);
+ buf[1]=0;
+ lDataLen=(short)(intbuf[0] & 0xFFF);
+ buf[2]=(char)(lDataLen & 255);
+ lDataLen = lDataLen >> 8;
+ buf[3] = (char)(lDataLen & 255);
+ bufsize=intbuf[0]*2+4;
+ if (intbuf[0]==0)
+ return 0;
+ for (i=1; i <= intbuf[0]; i++)
+ {
+ buf[2+2*i] = (char)(intbuf[i] & 255);
+ buf[3+2*i] = (char)((intbuf[i] >>8) & 255);
+ }
+ timeout=50;
+ ret=usb_bulk_write(hDev, XXUSB_ENDPOINT_OUT, buf, bufsize, timeout);
+ return ret;
+}
+
+/*
+******** xxusb_stack_execute **********************
+
+ Writes, executes and returns the value of a DAQ stack.
+
+ Parameters:
+ hdev: USB device handle returned from an open function
+ intbuf: Pointer to an array holding the values stack. Upon return
+ Pointer value is the Data returned from the stack.
+
+ Returns:
+ When successful, the number of Bytes read from xxusb
+ Upon Failure, a negative number.
+*/
+short xxusb_stack_execute(usb_dev_handle *hDev, long *intbuf)
+{
+ int timeout;
+ short ret;
+ short lDataLen;
+ char buf[26700];
+ short i;
+ int bufsize;
+ int ii = 0;
+
+ buf[0]=12;
+ buf[1]=0;
+ lDataLen=(short)(intbuf[0] & 0xFFF);
+ buf[2]=(char)(lDataLen & 255);
+ lDataLen = lDataLen >> 8;
+ buf[3] = (char)(lDataLen & 15);
+ bufsize=intbuf[0]*2+4;
+ if (intbuf[0]==0)
+ return 0;
+ for (i=1; i <= intbuf[0]; i++)
+ {
+ buf[2+2*i] = (char)(intbuf[i] & 255);
+ buf[3+2*i] = (char)((intbuf[i] >>8) & 255);
+ }
+ timeout=2000;
+ ret=usb_bulk_write(hDev, XXUSB_ENDPOINT_OUT, buf, bufsize, timeout);
+ if (ret>0)
+ {
+ lDataLen=26700;
+ timeout=6000;
+ ret=usb_bulk_read(hDev, XXUSB_ENDPOINT_IN, buf, lDataLen, timeout);
+ if (ret>0)
+ for (i=0; i < ret; i=i+2)
+ intbuf[ii++]=(UCHAR)(buf[i]) +(UCHAR)( buf[i+1])*256;
+ }
+ return ret;
+}
+
+/*
+******** xxusb_stack_read ************************
+
+ Reads the current DAQ stack stored by xxusb
+
+ Parameters:
+ hdev: USB device handle returned by an open function
+ StackAddr: Indicates which stack to read, primary or secondary
+ intbuf: Pointer to a array where the stack can be stored
+
+ Returns:
+ Number of bytes read from xxusb when successful
+ Upon failure, a negative number
+*/
+short xxusb_stack_read(usb_dev_handle *hDev, short StackAddr, long *intbuf)
+{
+ int timeout;
+ short ret;
+ short lDataLen;
+ short bufsize;
+ char buf[1600];
+ int i;
+
+ buf[0]=(char)(StackAddr & 51);
+ buf[1]=0;
+ lDataLen = 2;
+ timeout=100;
+ ret=usb_bulk_write(hDev, XXUSB_ENDPOINT_OUT, buf, lDataLen, timeout);
+ if (ret < 0)
+ return ret;
+ else
+ bufsize=1600;
+ int ii=0;
+ {
+ ret=usb_bulk_read(hDev, XXUSB_ENDPOINT_IN, buf, bufsize, timeout);
+ if (ret>0)
+ for (i=0; i < ret; i=i+2)
+ intbuf[ii++]=(UCHAR)(buf[i]) + (UCHAR)(buf[i+1])*256;
+ return ret;
+
+ }
+}
+
+/*
+******** xxusb_register_read ************************
+
+ Reads the current contents of an internal xxusb register
+
+ Parameters:
+ hdev: USB device handle returned from an open function
+ RegAddr: The internal address of the register from which to read
+ RegData: Pointer to a long to hold the data.
+
+ Returns:
+ When Successful, the number of bytes read from xxusb.
+ Upon failure, a negative number
+*/
+short xxusb_register_read(usb_dev_handle *hDev, short RegAddr, long *RegData)
+{
+//long RegD;
+int timeout;
+ char buf[4]={1,0,0,0};
+ int ret;
+ int lDataLen;
+
+ buf[2]=(char)(RegAddr & 15);
+ timeout=10;
+ lDataLen=4;
+ ret=xxusb_bulk_write(hDev, buf, lDataLen, timeout);
+ if (ret < 0)
+ return (short)ret;
+ else
+ {
+ lDataLen=8;
+ timeout=100;
+ ret=xxusb_bulk_read(hDev, buf, lDataLen, timeout);
+ if (ret<0)
+ return (short)ret;
+ else
+ {
+ *RegData=(UCHAR)(buf[0])+256*(UCHAR)(buf[1]);
+ if (ret==4)
+ *RegData=*RegData+0x10000*(UCHAR)(buf[2]);
+ return (short)ret;
+ }
+ }
+}
+
+/*
+******** xxusb_reset_toggle ************************
+
+ Toggles the reset state of the FPGA while the xxusb in programming mode
+
+ Parameters
+ hdev: US B device handle returned from an open function
+
+ Returns:
+ Upon failure, a negative number
+*/
+short xxusb_reset_toggle(usb_dev_handle *hDev)
+{
+ short ret;
+ char buf[2] = {(char)255,(char)255};
+ int lDataLen=2;
+ int timeout=1000;
+ ret = usb_bulk_write(hDev, XXUSB_ENDPOINT_OUT, buf,lDataLen, timeout);
+ return (short)ret;
+}
+
+/*
+******** xxusb_devices_find ************************
+
+ Determines the number and parameters of all xxusb devices attched to
+ the computer.
+
+ Parameters:
+ xxdev: pointer to an array on which the device parameters are stored
+
+ Returns:
+ Upon success, returns the number of devices found
+ Upon Failure returns a negative number
+*/
+short xxusb_devices_find(xxusb_device_type *xxdev)
+{
+ short DevFound = 0;
+ usb_dev_handle *udev;
+ struct usb_bus *bus;
+ struct usb_device *dev;
+struct usb_bus *usb_busses;
+ char string[256];
+ short ret;
+ usb_init();
+ usb_find_busses();
+ usb_busses=usb_get_busses();
+ usb_find_devices();
+ for (bus=usb_busses; bus; bus = bus->next)
+ {
+ for (dev = bus->devices; dev; dev= dev->next)
+ {
+ if (dev->descriptor.idVendor==XXUSB_WIENER_VENDOR_ID)
+ {
+ udev = usb_open(dev);
+ if (udev)
+ {
+ ret = usb_get_string_simple(udev, dev->descriptor.iSerialNumber, string, sizeof(string));
+ if (ret >0 )
+ {
+ xxdev[DevFound].usbdev=dev;
+ strcpy(xxdev[DevFound].SerialString, string);
+ DevFound++;
+ }
+ usb_close(udev);
+ }
+ else return -1;
+ }
+ }
+ }
+ return DevFound;
+}
+
+/*
+******** xxusb_device_close ************************
+
+ Closes an xxusb device
+
+ Parameters:
+ hdev: USB device handle returned from an open function
+
+ Returns: 1
+*/
+short xxusb_device_close(usb_dev_handle *hDev)
+{
+ short ret;
+ ret=usb_release_interface(hDev,0);
+ usb_close(hDev);
+ return 1;
+}
+
+/*
+******** xxusb_device_open ************************
+
+ Opens an xxusb device found by xxusb_device_find
+
+ Parameters:
+ dev: a usb device
+
+ Returns:
+ A USB device handle
+*/
+usb_dev_handle* xxusb_device_open(struct usb_device *dev)
+{
+ short ret;
+ long val;
+ int count =0;
+ usb_dev_handle *udev;
+ udev = usb_open(dev);
+ ret = usb_set_configuration(udev,1);
+ ret = usb_claim_interface(udev,0);
+// RESET USB (added 10/16/06 Andreas Ruben)
+ ret=xxusb_register_write(udev, 10, 0x04);
+// Loop to find known state (added 12/28/07 TH / AR)
+ ret =-1;
+ while ((ret <0) && (count <10))
+ {
+ xxusb_register_read(udev, 0, &val);
+ count++;
+ }
+
+ return udev;
+}
+
+/*
+******** xxusb_flash_program ************************
+
+ --Untested and therefore uncommented--
+*/
+short xxusb_flash_program(usb_dev_handle *hDev, char *config, short nsect)
+{
+ int i=0;
+ int k=0;
+ short ret=0;
+ time_t t1,t2;
+
+ char *pconfig;
+ char *pbuf;
+ pconfig=config;
+ char buf[518] ={(char)0xAA,(char)0xAA,(char)0x55,(char)0x55,(char)0xA0,(char)0xA0};
+ while (*pconfig++ != -1);
+ for (i=0; i<nsect; i++)
+ {
+ pbuf=buf+6;
+ for (k=0; k<256; k++)
+ {
+ *(pbuf++)=*(pconfig);
+ *(pbuf++)=*(pconfig++);
+ }
+ ret = usb_bulk_write(hDev, XXUSB_ENDPOINT_OUT, buf, 518, 2000);
+ if (ret<0)
+ return ret;
+ t1=clock()+(time_t)(0.03*CLOCKS_PER_SEC);
+ while (t1>clock());
+ t2=clock();
+ }
+ return ret;
+}
+
+/*
+******** xxusb_flashblock_program ************************
+
+ --Untested and therefore uncommented--
+*/
+short xxusb_flashblock_program(usb_dev_handle *hDev, UCHAR *config)
+{
+ int k=0;
+ short ret=0;
+
+ UCHAR *pconfig;
+ char *pbuf;
+ pconfig=config;
+ char buf[518] ={(char)0xAA,(char)0xAA,(char)0x55,(char)0x55,(char)0xA0,(char)0xA0};
+ pbuf=buf+6;
+ for (k=0; k<256; k++)
+ {
+ *(pbuf++)=(UCHAR)(*(pconfig));
+ *(pbuf++)=(UCHAR)(*(pconfig++));
+ }
+ ret = usb_bulk_write(hDev, XXUSB_ENDPOINT_OUT, buf, 518, 2000);
+ return ret;
+}
+
+/*
+******** xxusb_serial_open ************************
+
+ Opens a xxusb device whose serial number is given
+
+ Parameters:
+ SerialString: a char string that gives the serial number of
+ the device you wish to open. It takes the form:
+ VM0009 - for a vm_usb with serial number 9 or
+ CC0009 - for a cc_usb with serial number 9
+
+ Returns:
+ A USB device handle
+*/
+usb_dev_handle* xxusb_serial_open(char *SerialString)
+{
+ short DevFound = 0;
+ usb_dev_handle *udev = NULL;
+ struct usb_bus *bus;
+ struct usb_device *dev;
+struct usb_bus *usb_busses;
+char string[7];
+ short ret;
+// usb_set_debug(4);
+ usb_init();
+ usb_find_busses();
+ usb_busses=usb_get_busses();
+ usb_find_devices();
+ for (bus=usb_busses; bus; bus = bus->next)
+ {
+ for (dev = bus->devices; dev; dev= dev->next)
+ {
+ if (dev->descriptor.idVendor==XXUSB_WIENER_VENDOR_ID)
+ {
+ udev = xxusb_device_open(dev);
+ if (udev)
+ {
+ ret = usb_get_string_simple(udev, dev->descriptor.iSerialNumber, string, sizeof(string));
+ if (ret >0 )
+ {
+ if (strcmp(string,SerialString)==0)
+ return udev;
+ }
+ usb_close(udev);
+ }
+ }
+ }
+ }
+ udev = NULL;
+ return udev;
+}
+
+
+//******************************************************//
+//****************** EZ_VME Functions ******************//
+//******************************************************//
+// The following are functions used to perform simple
+// VME Functions with the VM_USB
+
+/*
+******** VME_write_32 ************************
+
+ Writes a 32 bit data word to the VME bus
+
+ Parameters:
+ hdev: USB devcie handle returned from an open function
+ Address_Modifier: VME address modifier for the VME call
+ VME_Address: Address to write the data to
+ Data: 32 bit data word to be written to VME_Address
+
+ Returns:
+ Number of bytes read from xxusb when successful
+ Upon failure, a negative number
+*/
+short VME_write_32(usb_dev_handle *hdev, short Address_Modifier, long VME_Address, long Data)
+{
+ long intbuf[1000];
+ short ret;
+ intbuf[0]=7;
+ intbuf[1]=0;
+ intbuf[2]=Address_Modifier;
+ intbuf[3]=0;
+ intbuf[4]=(VME_Address & 0xffff);
+ intbuf[5]=((VME_Address >>16) & 0xffff);
+ intbuf[6]=(Data & 0xffff);
+ intbuf[7]=((Data >> 16) & 0xffff);
+ ret = xxusb_stack_execute(hdev, intbuf);
+ return ret;
+}
+
+/*
+******** VME_read_32 ************************
+
+
+ Reads a 32 bit data word from a VME address
+
+ Parameters:
+ hdev: USB devcie handle returned from an open function
+ Address_Modifier: VME address modifier for the VME call
+ VME_Address: Address to read the data from
+ Data: 32 bit data word read from VME_Address
+
+ Returns:
+ Number of bytes read from xxusb when successful
+ Upon failure, a negative number
+*/
+short VME_read_32(usb_dev_handle *hdev, short Address_Modifier, long VME_Address, long *Data)
+{
+ long intbuf[1000];
+ short ret;
+ intbuf[0]=5;
+ intbuf[1]=0;
+ intbuf[2]=Address_Modifier +0x100;
+ intbuf[3]=0;
+ intbuf[4]=(VME_Address & 0xffff);
+ intbuf[5]=((VME_Address >>16) & 0xffff);
+ ret = xxusb_stack_execute(hdev, intbuf);
+ *Data=intbuf[0] + (intbuf[1] * 0x10000);
+ return ret;
+}
+
+/*
+******** VME_write_16 ************************
+
+ Writes a 16 bit data word to the VME bus
+
+ Parameters:
+ hdev: USB devcie handle returned from an open function
+ Address_Modifier: VME address modifier for the VME call
+ VME_Address: Address to write the data to
+ Data: word to be written to VME_Address
+
+ Returns:
+ Number of bytes read from xxusb when successful
+ Upon failure, a negative number
+*/
+short VME_write_16(usb_dev_handle *hdev, short Address_Modifier, long VME_Address, long Data)
+{
+ long intbuf[1000];
+ short ret;
+ intbuf[0]=7;
+ intbuf[1]=0;
+ intbuf[2]=Address_Modifier;
+ intbuf[3]=0;
+ intbuf[4]=(VME_Address & 0xffff)+ 0x01;
+ intbuf[5]=((VME_Address >>16) & 0xffff);
+ intbuf[6]=(Data & 0xffff);
+ intbuf[7]=0;
+ ret = xxusb_stack_execute(hdev, intbuf);
+ return ret;
+}
+
+/*
+******** VME_read_16 ************************
+
+ Reads a 16 bit data word from a VME address
+
+ Parameters:
+ hdev: USB devcie handle returned from an open function
+ Address_Modifier: VME address modifier for the VME call
+ VME_Address: Address to read the data from
+ Data: word read from VME_Address
+
+ Returns:
+ Number of bytes read from xxusb when successful
+ Upon failure, a negative number
+*/
+short VME_read_16(usb_dev_handle *hdev,short Address_Modifier, long VME_Address, long *Data)
+{
+ long intbuf[1000];
+ short ret;
+ intbuf[0]=5;
+ intbuf[1]=0;
+ intbuf[2]=Address_Modifier +0x100;
+ intbuf[3]=0;
+ intbuf[4]=(VME_Address & 0xffff)+ 0x01;
+ intbuf[5]=((VME_Address >>16) & 0xffff);
+ ret = xxusb_stack_execute(hdev, intbuf);
+ *Data=intbuf[0];
+ return ret;
+}
+
+/*
+******** VME_BLT_read_32 ************************
+
+ Performs block transfer of 32 bit words from a VME address
+
+ Parameters:
+ hdev: USB devcie handle returned from an open function
+ Address_Modifier: VME address modifier for the VME call
+ count: number of data words to read
+ VME_Address: Address to read the data from
+ Data: pointer to an array to hold the data words
+
+ Returns:
+ Number of bytes read from xxusb when successful
+ Upon failure, a negative number
+*/
+short VME_BLT_read_32(usb_dev_handle *hdev, short Adress_Modifier, int count, long VME_Address, long Data[])
+{
+ long intbuf[1000];
+ short ret;
+ int i=0;
+ if (count > 255) return -1;
+ intbuf[0]=5;
+ intbuf[1]=0;
+ intbuf[2]=Adress_Modifier +0x100;
+ intbuf[3]=(count << 8);
+ intbuf[4]=(VME_Address & 0xffff);
+ intbuf[5]=((VME_Address >>16) & 0xffff);
+ ret = xxusb_stack_execute(hdev, intbuf);
+ int j=0;
+ for (i=0;i<(2*count);i=i+2)
+ {
+ Data[j]=intbuf[i] + (intbuf[i+1] * 0x10000);
+ j++;
+ }
+ return ret;
+}
+
+//******************************************************//
+//****************** VM_USB Registers ******************//
+//******************************************************//
+// The following are functions used to set the registers
+// in the VM_USB
+
+/*
+******** VME_register_write ************************
+
+ Writes to the vmusb registers that are accessible through
+ VME style calls
+
+ Parameters:
+ hdev: USB devcie handle returned from an open function
+ VME_Address: The VME Address of the internal register
+ Data: Data to be written to VME_Address
+
+ Returns:
+ Number of bytes read from xxusb when successful
+ Upon failure, a negative number
+*/
+short VME_register_write(usb_dev_handle *hdev, long VME_Address, long Data)
+{
+ long intbuf[1000];
+ short ret;
+
+ intbuf[0]=7;
+ intbuf[1]=0;
+ intbuf[2]=0x1000;
+ intbuf[3]=0;
+ intbuf[4]=(VME_Address & 0xffff);
+ intbuf[5]=((VME_Address >>16) & 0xffff);
+ intbuf[6]=(Data & 0xffff);
+ intbuf[7]=((Data >> 16) & 0xffff);
+ ret = xxusb_stack_execute(hdev, intbuf);
+ return ret;
+}
+
+/*
+******** VME_register_read ************************
+
+ Reads from the vmusb registers that are accessible trough VME style calls
+
+ Parameters:
+ hdev: USB devcie handle returned from an open function
+ VME_Address: The VME Address of the internal register
+ Data: Data read from VME_Address
+
+ Returns:
+ Number of bytes read from xxusb when successful
+ Upon failure, a negative number
+*/
+short VME_register_read(usb_dev_handle *hdev, long VME_Address, long *Data)
+{
+ long intbuf[1000];
+ short ret;
+
+ intbuf[0]=5;
+ intbuf[1]=0;
+ intbuf[2]=0x1100;
+ intbuf[3]=0;
+ intbuf[4]=(VME_Address & 0xffff);
+ intbuf[5]=((VME_Address >>16) & 0xffff);
+ ret = xxusb_stack_execute(hdev, intbuf);
+ *Data=intbuf[0] + (intbuf[1] * 0x10000);
+ return ret;
+}
+
+/*
+******** VME_LED_settings ************************
+
+ Sets the vmusb LED's
+
+ Parameters:
+ hdev: USB devcie handle returned from an open function
+ LED: The number which corresponds to an LED values are:
+ 0 - for Top YELLOW LED
+ 1 - for RED LED
+ 2 - for GREEN LED
+ 3 - for Bottom YELLOW LED
+ code: The LED aource selector code, valid values for each LED
+ are listed in the manual
+ invert: to invert the LED lighting
+ latch: sets LED latch bit
+
+ Returns:
+ Number of bytes read from xxusb when successful
+ Upon failure, a negative number
+*/
+short VME_LED_settings(usb_dev_handle *hdev, int LED, int code, int invert, int latch)
+{
+ short ret;
+// long internal;
+ long Data;
+
+ if( (LED <0) ||(LED > 3) || (code < 0) || (code > 7)) return -1;
+
+ VME_register_read(hdev,0xc,&Data);
+ if(LED == 0)
+ {
+ Data = Data & 0xFFFFFF00;
+ Data = Data | code;
+ if (invert == 1 && latch == 1) Data = Data | 0x18;
+ if (invert == 1 && latch == 0) Data = Data | 0x08;
+ if (invert == 0 && latch == 1) Data = Data | 0x10;
+ }
+ if(LED == 1)
+ {
+ Data = Data & 0xFFFF00FF;
+ Data = Data | (code * 0x0100);
+ if (invert == 1 && latch == 1) Data = Data | 0x1800;
+ if (invert == 1 && latch == 0) Data = Data | 0x0800;
+ if (invert == 0 && latch == 1) Data = Data | 0x1000;
+ }
+ if(LED == 2)
+ {
+ Data = Data & 0xFF00FFFF;
+ Data = Data | (code * 0x10000);
+ if (invert == 1 && latch == 1) Data = Data | 0x180000;
+ if (invert == 1 && latch == 0) Data = Data | 0x080000;
+ if (invert == 0 && latch == 1) Data = Data | 0x100000;
+ }
+ if(LED == 3)
+ {
+ Data = Data & 0x00FFFFFF;
+ Data = Data | (code * 0x10000);
+ if (invert == 1 && latch == 1) Data = Data | 0x18000000;
+ if (invert == 1 && latch == 0) Data = Data | 0x08000000;
+ if (invert == 0 && latch == 1) Data = Data | 0x10000000;
+ }
+ ret = VME_register_write(hdev, 0xc, Data);
+ return ret;
+}
+
+/*
+******** VME_DGG ************************
+
+ Sets the parameters for Gate & Delay channel A of vmusb
+
+ Parameters:
+ hdev: USB devcie handle returned from an open function
+ channel: Which DGG channel to use Valid Values are:
+ 0 - For DGG A
+ 1 - For DGG B
+ trigger: Determines what triggers the start of the DGG Valid values are:
+ 0 - Channel disabled
+ 1 - NIM input 1
+ 2 - NIM input 2
+ 3 - Event Trigger
+ 4 - End of Event
+ 5 - USB Trigger
+ 6 - Pulser
+ output: Determines which NIM output to use for the channel, Vaild values are:
+ 0 - for NIM O1
+ 1 - for NIM O2
+ delay: 32 bit word consisting of
+ lower 16 bits: Delay_fine in steps of 12.5ns between trigger and start of gate
+ upper 16 bits: Delay_coarse in steps of 81.7us between trigger and start of gate
+ gate: the time the gate should stay open in steps of 12.5ns
+ invert: is 1 if you wish to invert the DGG channel output
+ latch: is 1 if you wish to run the DGG channel latched
+
+ Returns:
+ Returns 1 when successful
+ Upon failure, a negative number
+*/
+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)
+{
+ long Data, DGData, Delay_ext;
+ long internal;
+ short ret;
+
+
+ ret = VME_register_read(hdev, 0x10, &Data);
+ // check and correct values
+ if(ret<=0) return -1;
+
+ if(channel >1) channel =1;
+ if(invert >1) invert =1;
+ if(latch >1) latch =1;
+ if(output >1) output =1;
+ if(trigger >6) trigger =0;
+
+ // define Delay and Gate data
+ DGData = gate * 0x10000;
+ DGData += (unsigned short) delay;
+
+ // Set channel, output, invert, latch
+ if (output == 0)
+ {
+ Data = Data & 0xFFFFFF00;
+ Data += 0x04 + channel +0x08*invert + 0x10*latch;
+ }
+ if (output == 1)
+ {
+ Data = Data & 0xFFFF00FF;
+ Data += (0x04 + channel +0x08*invert + 0x10*latch)*0x100;
+ }
+
+ // Set trigger, delay, gate
+
+ if(channel ==0) // CHANNEL DGG_A
+ {
+ internal = (trigger * 0x1000000) ;
+ Data= Data & 0xF0FFFFFF;
+ Data += internal;
+ ret = VME_register_write(hdev,0x10,Data);
+ if(ret<=0) return -1;
+ ret=VME_register_write(hdev,0x14,DGData);
+ if(ret<=0) return -1;
+ // Set coarse delay in DGG_Extended register
+ ret = VME_register_read(hdev,0x38,&Data);
+ Delay_ext= (Data & 0xffff0000);
+ Delay_ext+= ((delay/0x10000) & 0xffff);
+ ret = VME_register_write(hdev,0x38,Delay_ext);
+ }
+ if( channel ==1) // CHANNEL DGG_B
+ {
+ internal = (trigger * 0x10000000) ;
+ Data= Data & 0x0FFFFFFF;
+ Data += internal;
+ ret = VME_register_write(hdev,0x10,Data);
+ if(ret<=0) return -1;
+ ret=VME_register_write(hdev,0x18,DGData);
+ if(ret<=0) return -1;
+ // Set coarse delay in DGG_Extended register
+ ret = VME_register_read(hdev,0x38,&Data);
+ Delay_ext= (Data & 0x0000ffff);
+ Delay_ext+= (delay & 0xffff0000);
+ ret = VME_register_write(hdev,0x38,Delay_ext);
+ }
+ return 1;
+
+}
+
+/*
+******** VME_Output_settings ************************
+
+ Sets the vmusb NIM output register
+
+ Parameters:
+ hdev: USB devcie handle returned from an open function
+ Channel: The number which corresponds to an output:
+ 1 - for Output 1
+ 2 - for Output 2
+ code: The Output selector code, valid values
+ are listed in the manual
+ invert: to invert the output
+ latch: sets latch bit
+
+ Returns:
+ Number of bytes read from xxusb when successful
+ Upon failure, a negative number
+*/
+short VME_Output_settings(usb_dev_handle *hdev, int Channel, int code, int invert, int latch)
+{
+
+ short ret;
+// long internal;
+ long Data;
+
+ if( (Channel <1) ||(Channel > 2) || (code < 0) || (code > 7)) return -1;
+ VME_register_read(hdev,0x10,&Data);
+ if(Channel == 1)
+ {
+ Data = Data & 0xFFFF00;
+ Data = Data | code;
+ if (invert == 1 && latch == 1) Data = Data | 0x18;
+ if (invert == 1 && latch == 0) Data = Data | 0x08;
+ if (invert == 0 && latch == 1) Data = Data | 0x10;
+ }
+ if(Channel == 2)
+ {
+ Data = Data & 0xFF00FF;
+ Data = Data | (code * 0x0100);
+ if (invert == 1 && latch == 1) Data = Data | 0x1800;
+ if (invert == 1 && latch == 0) Data = Data | 0x0800;
+ if (invert == 0 && latch == 1) Data = Data | 0x1000;
+ }
+ ret = VME_register_write(hdev, 0x10, Data);
+ return ret;
+}
+
+
+//******************************************************//
+//****************** CC_USB Registers ******************//
+//******************************************************//
+// The following are functions used to set the registers
+// in the CAMAC_USB
+
+/*
+******** CAMAC_register_write *****************
+
+ Performs a CAMAC write to CC_USB register
+
+ Parameters:
+ hdev: USB device handle returned from an open function
+ A: CAMAC Subaddress
+ F: CAMAC Function
+ Data: data to be written
+
+ Returns:
+ Number of bytes written to xxusb when successful
+ Upon failure, a negative number
+*/
+short CAMAC_register_write(usb_dev_handle *hdev, int A, long Data)
+{
+ int F = 16;
+ int N = 25;
+ long intbuf[4];
+ int ret;
+
+ intbuf[0]=1;
+ intbuf[1]=(long)(F+A*32+N*512 + 0x4000);
+ intbuf[0]=3;
+ intbuf[2]=(Data & 0xffff);
+ intbuf[3]=((Data >>16) & 0xffff);
+ ret = xxusb_stack_execute(hdev, intbuf);
+
+ return ret;
+}
+
+/*
+******** CAMAC_register_read ************************
+
+ Performs a CAMAC read from CC_USB register
+
+ Parameters:
+ hdev: USB device handle returned from an open function
+ N: CAMAC Station Number
+ A: CAMAC Subaddress
+ F: CAMAC Function
+ Q: The Q response from the CAMAC dataway
+ X: The comment accepted response from CAMAC dataway
+
+ Returns:
+ Number of bytes read from xxusb when successful
+ Upon failure, a negative number
+*/
+short CAMAC_register_read(usb_dev_handle *hdev, int A, long *Data)
+{
+ int F = 0;
+ int N = 25;
+ long intbuf[4];
+ int ret;
+
+ intbuf[0]=1;
+ intbuf[1]=(long)(F+A*32+N*512 + 0x4000);
+ ret = xxusb_stack_execute(hdev, intbuf);
+ *Data=intbuf[0] + (intbuf[1] * 0x10000);
+
+ return ret;
+}
+
+/*
+******** CAMAC_DGG ************************
+
+ Sets the parameters for Gate & Delay channel A of CC_USB
+
+ Parameters:
+ hdev: USB devcie handle returned from an open function
+ channel: Which DGG channel to use Valid Values are:
+ 0 - For DGG A
+ 1 - For DGG B
+ trigger: Determines what triggers the start of the DGG Valid values are:
+ 0 - Channel disabled
+ 1 - NIM input 1
+ 2 - NIM input 2
+ 3 - NIM input 2
+ 4 - Event Trigger
+ 5 - End of Event
+ 6 - USB Trigger
+ 7 - Pulser
+ output: Determines which NIM output to use for the channel, Vaild values are:
+ 1 - for NIM O1
+ 2 - for NIM O2
+ 3 - for NIM O3
+ delay: Delay in steps of 12.5ns between trigger and start of gate
+ gate: the time the gate should stay open in steps of 12.5ns
+ invert: is 1 if you wish to invert the DGG channel output
+ latch: is 1 if you wish to run the DGG channel latched
+
+ Returns:
+ Returns 1 when successful
+ Upon failure, a negative number
+*/
+short CAMAC_DGG(usb_dev_handle *hdev, short channel, short trigger, short output,
+ int delay, int gate, short invert, short latch)
+
+
+
+{
+// short channel_ID;
+ long Data;
+ long internal;
+ short ret;
+ long Delay_ext;
+
+ ret = CAMAC_register_read(hdev,5,&Data);
+ //Set trigger
+ if((output < 1 ) || (output >3) || (channel < 0 ) || (channel > 1))
+ return -1;
+ if(output ==1)
+ {
+ if(channel ==0)
+ {
+ internal = 0x03;
+ } else {
+ internal = 0x04;
+ }
+ }
+ if(output ==2)
+ {
+ if(channel ==0)
+ {
+ internal = 0x04;
+ } else {
+ internal = 0x05;
+ }
+ }
+ if(output ==3)
+ {
+ if(channel ==0)
+ {
+ internal = 0x05;
+ } else {
+ internal = 0x06;
+ }
+ }
+
+
+// Set invert bit
+ if(invert ==1)
+ internal = internal | 0x10;
+ else
+ internal = internal & 0x0F;
+ // Set Latch Bit
+ if(latch==1)
+ internal = internal | 0x20;
+ else
+ internal = internal & 0x1F;
+// Add new data to old
+ if(output == 1)
+ {
+ Data = Data & 0xFFFF00;
+ Data = Data | internal;
+ }
+ if(output == 2)
+ {
+ Data = Data & 0xFF00FF;
+ Data = Data |(internal * 0x100);
+ }
+ if(output == 3)
+ {
+ Data = Data & 0x00FFFF;
+ Data = Data | (internal * 0x10000) ;
+ }
+ CAMAC_register_write(hdev, 5, Data);
+ ret = CAMAC_register_read(hdev,6,&Data);
+//Set Trigger
+ if(trigger <0 || trigger > 7)
+ return -1;
+ if(channel ==0)
+ {
+ Data = Data & 0xFF00FFFF;
+ internal = trigger * 0x10000;
+ Data = Data | internal;
+ } else {
+ Data = Data & 0x00FFFFFF;
+ internal = trigger * 0x1000000;
+ Data = Data | internal;
+ }
+ ret = CAMAC_register_write(hdev, 6, Data);
+ if(channel == 0)
+ {
+// Write Delay and Gate info
+ ret = CAMAC_register_read(hdev,13,&Data);
+ Delay_ext= (Data & 0xffff0000);
+ Delay_ext+= ((delay/0x10000) & 0xffff);
+ internal = gate * 0x10000;
+ Data = internal + (delay & 0xffff);
+ ret=CAMAC_register_write(hdev,7,Data);
+// Set coarse delay in DGG_Extended register
+ ret=CAMAC_register_write(hdev,13,Delay_ext);
+ }
+ else
+ {
+ ret=CAMAC_register_write(hdev,8,Data);
+ ret = CAMAC_register_read(hdev,13,&Data);
+ Delay_ext= (Data & 0x0000ffff);
+ Delay_ext+= (delay & 0xffff0000);
+ internal = gate * 0x10000;
+ Data = internal + (delay & 0xffff);
+// Set coarse delay in DGG_Extended register
+ ret=CAMAC_register_write(hdev,13,Delay_ext);
+ }
+ return 1;
+}
+
+/*
+******** CAMAC_LED_settings ************************
+
+ Writes a data word to the vmusb LED register
+
+ Parameters:
+ hdev: USB devcie handle returned from an open function
+ LED: The number which corresponds to an LED values are:
+ 1 - for RED LED
+ 2 - for GREEN LED
+ 3 - for Yellow LED
+ code: The LED aource selector code, valid values for each LED
+ are listed in the manual
+ invert: to invert the LED lighting
+ latch: sets LED latch bit
+
+ Returns:
+ Number of bytes read from xxusb when successful
+ Upon failure, a negative number
+*/
+short CAMAC_LED_settings(usb_dev_handle *hdev, int LED, int code, int invert, int latch)
+{
+
+ short ret;
+// long internal;
+ long Data;
+
+ if( (LED <1) ||(LED > 3) || (code < 0) || (code > 7))
+ return -1;
+
+ CAMAC_register_read(hdev,4,&Data);
+
+ if(LED == 1)
+ {
+ Data = Data & 0xFFFF00;
+ Data = Data | code;
+ if (invert == 1 && latch == 1)
+ Data = Data | 0x30;
+ if (invert == 1 && latch == 0)
+ Data = Data | 0x10;
+ if (invert == 0 && latch == 1)
+ Data = Data | 0x20;
+ }
+ if(LED == 2)
+ {
+ Data = Data & 0xFF00FF;
+ Data = Data | (code * 0x0100);
+ if (invert == 1 && latch == 1)
+ Data = Data | 0x3000;
+ if (invert == 1 && latch == 0)
+ Data = Data | 0x1000;
+ if (invert == 0 && latch == 1)
+ Data = Data | 0x2000;
+ }
+ if(LED == 3)
+ {
+ Data = Data & 0x00FFFF;
+ Data = Data | (code * 0x10000);
+ if (invert == 1 && latch == 1)
+ Data = Data | 0x300000;
+ if (invert == 1 && latch == 0)
+ Data = Data | 0x100000;
+ if (invert == 0 && latch == 1)
+ Data = Data | 0x200000;
+ }
+ ret = CAMAC_register_write(hdev, 4, Data);
+ return ret;
+}
+
+/*
+******** CAMAC_Output_settings ************************
+
+ Writes a data word to the vmusb LED register
+
+ Parameters:
+ hdev: USB devcie handle returned from an open function
+ Channel: The number which corresponds to an output:
+ 1 - for Output 1
+ 2 - for Output 2
+ 3 - for Output 3
+ code: The Output selector code, valid values
+ are listed in the manual
+ invert: to invert the output
+ latch: sets latch bit
+
+ Returns:
+ Number of bytes read from xxusb when successful
+ Upon failure, a negative number
+*/
+short CAMAC_Output_settings(usb_dev_handle *hdev, int Channel, int code, int invert, int latch)
+{
+ short ret;
+// long internal;
+ long Data;
+
+ if( (Channel <1) ||(Channel > 3) || (code < 0) || (code > 7))
+ return -1;
+
+ CAMAC_register_read(hdev,5,&Data);
+
+ if(Channel == 1)
+ {
+ Data = Data & 0xFFFF00;
+ Data = Data | code;
+ if (invert == 1 && latch == 1)
+ Data = Data | 0x30;
+ if (invert == 1 && latch == 0)
+ Data = Data | 0x10;
+ if (invert == 0 && latch == 1)
+ Data = Data | 0x20;
+ }
+ if(Channel == 2)
+ {
+ Data = Data & 0xFF00FF;
+ Data = Data | (code * 0x0100);
+ if (invert == 1 && latch == 1)
+ Data = Data | 0x3000;
+ if (invert == 1 && latch == 0)
+ Data = Data | 0x1000;
+ if (invert == 0 && latch == 1)
+ Data = Data | 0x2000;
+ }
+ if(Channel == 3)
+ {
+ Data = Data & 0x00FFFF;
+ Data = Data | (code * 0x10000);
+ if (invert == 1 && latch == 1)
+ Data = Data | 0x300000;
+ if (invert == 1 && latch == 0)
+ Data = Data | 0x100000;
+ if (invert == 0 && latch == 1)
+ Data = Data | 0x200000;
+ }
+ ret = CAMAC_register_write(hdev, 5, Data);
+ return ret;
+}
+
+/*
+******** CAMAC_write_LAM_mask ************************
+
+ Writes the data word to the LAM mask register
+
+ Parameters:
+ hdev: USB devcie handle returned from an open function
+ Data: LAM mask to write
+
+ Returns:
+ Number of bytes read from xxusb when successful
+ Upon failure, a negative number
+*/
+short CAMAC_write_LAM_mask(usb_dev_handle *hdev, long Data)
+{
+ short ret;
+ ret = CAMAC_register_write(hdev, 9, Data);
+
+ return ret;
+}
+
+/*
+******** CAMAC_read_LAM_mask ************************
+
+ Writes the data word to the LAM mask register
+
+ Parameters:
+ hdev: USB devcie handle returned from an open function
+ Data: LAM mask to write
+
+ Returns:
+ Number of bytes read from xxusb when successful
+ Upon failure, a negative number
+*/
+short CAMAC_read_LAM_mask(usb_dev_handle *hdev, long *Data)
+{
+ long intbuf[4];
+ int ret;
+ int N = 25;
+ int F = 0;
+ int A = 9;
+
+ // CAMAC direct read function
+ intbuf[0]=1;
+ intbuf[1]=(long)(F+A*32+N*512 + 0x4000);
+ ret = xxusb_stack_execute(hdev, intbuf);
+ *Data=intbuf[0] + (intbuf[1] & 255) * 0x10000;
+ return ret;
+}
+
+
+//******************************************************//
+//**************** EZ_CAMAC Functions ******************//
+//******************************************************//
+// The following are functions used to perform simple
+// CAMAC Functions with the CC_USB
+
+
+/*
+******** CAMAC_write ************************
+
+ Performs a CAMAC write using NAF comments
+
+ Parameters:
+ hdev: USB device handle returned from an open function
+ N: CAMAC Station Number
+ A: CAMAC Subaddress
+ F: CAMAC Function (16...23)
+ Q: The Q response from the CAMAC dataway
+ X: The comment accepted response from CAMAC dataway
+
+ Returns:
+ Number of bytes written to xxusb when successful
+ Upon failure, a negative number
+*/
+short CAMAC_write(usb_dev_handle *hdev, int N, int A, int F, long Data, int *Q, int *X)
+{
+ long intbuf[4];
+ int ret;
+// CAMAC direct write function
+ intbuf[0]=1;
+ intbuf[1]=(long)(F+A*32+N*512 + 0x4000);
+ if ((F > 15) && (F < 24))
+ {
+ intbuf[0]=3;
+ intbuf[2]=(Data & 0xffff);
+ intbuf[3]=((Data >>16) & 255);
+ ret = xxusb_stack_execute(hdev, intbuf);
+ *Q = (intbuf[0] & 1);
+ *X = ((intbuf[0] >> 1) & 1);
+ }
+ return ret;
+}
+
+/*
+******** CAMAC_read ************************
+
+ Performs a CAMAC read using NAF comments
+
+ Parameters:
+ hdev: USB device handle returned from an open function
+ N: CAMAC Station Number
+ A: CAMAC Subaddress
+ F: CAMAC Function (F<16 or F>23)
+ Q: The Q response from the CAMAC dataway
+ X: The comment accepted response from CAMAC dataway
+
+ Returns:
+ Number of bytes read from xxusb when successful
+ Upon failure, a negative number
+*/
+short CAMAC_read(usb_dev_handle *hdev, int N, int A, int F, long *Data, int *Q, int *X)
+{
+ long intbuf[4];
+ int ret;
+ // CAMAC direct read function
+ intbuf[0]=1;
+ intbuf[1]=(long)(F+A*32+N*512 + 0x4000);
+ ret = xxusb_stack_execute(hdev, intbuf);
+ if ((F < 16) || (F >23))
+ {
+ *Data=intbuf[0] + (intbuf[1] & 255) * 0x10000; //24-bit word
+ *Q = ((intbuf[1] >> 8) & 1);
+ *X = ((intbuf[1] >> 9) & 1);
+ }
+ return ret;
+}
+
+/*
+******** CAMAC_Z ************************
+
+ Performs a CAMAC init
+
+ Parameters:
+ hdev: USB device handle returned from an open function
+
+ Returns:
+ Number of bytes written to xxusb when successful
+ Upon failure, a negative number
+*/
+short CAMAC_Z(usb_dev_handle *hdev)
+{
+ long intbuf[4];
+ int ret;
+// CAMAC Z = N(28) A(8) F(29)
+ intbuf[0]=1;
+ intbuf[1]=(long)(29+8*32+28*512 + 0x4000);
+ ret = xxusb_stack_execute(hdev, intbuf);
+ return ret;
+}
+
+/*
+******** CAMAC_C ************************
+
+ Performs a CAMAC clear
+
+ Parameters:
+ hdev: USB device handle returned from an open function
+
+ Returns:
+ Number of bytes written to xxusb when successful
+ Upon failure, a negative number
+*/
+short CAMAC_C(usb_dev_handle *hdev)
+{
+ long intbuf[4];
+ int ret;
+ intbuf[0]=1;
+ intbuf[1]=(long)(29+9*32+28*512 + 0x4000);
+ ret = xxusb_stack_execute(hdev, intbuf);
+ return ret;
+}
+
+/*
+******** CAMAC_I ************************
+
+ Set CAMAC inhibit
+
+ Parameters:
+ hdev: USB device handle returned from an open function
+
+ Returns:
+ Number of bytes written to xxusb when successful
+ Upon failure, a negative number
+*/
+short CAMAC_I(usb_dev_handle *hdev, int inhibit)
+{
+ long intbuf[4];
+ int ret;
+ intbuf[0]=1;
+ if (inhibit) intbuf[1]=(long)(24+9*32+29*512 + 0x4000);
+ else intbuf[1]=(long)(26+9*32+29*512 + 0x4000);
+ ret = xxusb_stack_execute(hdev, intbuf);
+ return ret;
+}
+
+
Index: sipmscan/trunk/src/mpod/WIENER-CRATE-MIB.txt
===================================================================
--- sipmscan/trunk/src/mpod/WIENER-CRATE-MIB.txt (nonexistent)
+++ sipmscan/trunk/src/mpod/WIENER-CRATE-MIB.txt (revision 146)
@@ -0,0 +1,1578 @@
+----------------------------------------------------------------------------------------------------
+-- $HeadURL: http://svn.wiener-d.com/src/enet/trunk/mibs/WIENER-CRATE-MIB.txt $
+-- $LastChangedDate: 2008-11-27 12:00:00 +0100 (Fr, 21. Nov 2008) $
+-- $LastChangedRevision: 617 / 510 $
+-- $LastChangedBy: koester (roemer)$
+-- Copyright © 2005-2007 W-IE-NE-R Plein & Baus GmbH, Burscheid, Germany
+----------------------------------------------------------------------------------------------------
+WIENER-CRATE-MIB DEFINITIONS ::= BEGIN
+
+IMPORTS
+ OBJECT-TYPE, MODULE-IDENTITY, OBJECT-IDENTITY,
+ Integer32, Opaque, enterprises
+ FROM SNMPv2-SMI
+
+ TEXTUAL-CONVENTION, DisplayString
+ FROM SNMPv2-TC
+
+-- Float
+-- FROM NET-SNMP-TC
+-- Float
+-- FROM UCD-SNMP-MIB
+ ;
+
+
+
+
+wiener MODULE-IDENTITY
+ LAST-UPDATED "200810090000Z" -- October 9, 2008
+ ORGANIZATION "WIENER Plein & Baus GmbH"
+ CONTACT-INFO "
+ postal: WIENER Plein & Baus GmbH
+ Mullersbaum 20
+ D-51399 Burscheid
+ Germany
+
+ email: info@wiener-d.com
+
+ "
+
+ DESCRIPTION
+ "Introduction of the communication.can branch.
+ "
+
+
+ REVISION "200805060000Z" -- May 6, 2008
+ DESCRIPTION
+ "Introduction of the signal branch.
+ "
+
+ REVISION "200804150000Z" -- April 15, 2008
+ DESCRIPTION
+ "Enlargement of u0..u11 -> u0..u1999
+ "
+
+ REVISION "200804100000Z" -- April 10, 2008
+ DESCRIPTION
+ "This revision uses again Integer32 instead of Counter32.
+ "
+
+ REVISION "200804020000Z" -- April 02, 2008
+ DESCRIPTION
+ "This revision modifies the syntax of this file to be complient with smilint.
+ "
+
+ REVISION "200709100000Z"
+ DESCRIPTION
+ "This revision introduces new OIDs for debug functionality:
+ sysDebugMemory8, sysDebugMemory16 and sysDebugMemory32.
+ "
+
+ REVISION "200703160000Z"
+ DESCRIPTION
+ "This revision introduces new OIDs for slew control:
+ outputVoltageRiseRate and outputVoltageFallRate.
+ "
+
+ REVISION "200502010000Z"
+ DESCRIPTION
+ "This revision introduces new OIDs for group managment:
+ groupTable
+ "
+
+ REVISION "200406280000Z"
+ DESCRIPTION
+ "WIENER Crate MIB, actual Firmware: UEL6E 4.02.
+ Initial Version.
+ "
+
+ ::= { enterprises 19947 }
+
+
+-------------------------------------------------------------------------------
+-- Define the Float Textual Convention
+-- This definition was written by David Perkins.
+--
+Float ::= TEXTUAL-CONVENTION
+ STATUS current
+ DESCRIPTION
+ "A single precision floating-point number. The semantics
+ and encoding are identical for type 'single' defined in
+ IEEE Standard for Binary Floating-Point,
+ ANSI/IEEE Std 754-1985.
+ The value is restricted to the BER serialization of
+ the following ASN.1 type:
+ FLOATTYPE ::= [120] IMPLICIT FloatType
+ (note: the value 120 is the sum of '30'h and '48'h)
+ The BER serialization of the length for values of
+ this type must use the definite length, short
+ encoding form.
+
+ For example, the BER serialization of value 123
+ of type FLOATTYPE is '9f780442f60000'h. (The tag
+ is '9f78'h; the length is '04'h; and the value is
+ '42f60000'h.) The BER serialization of value
+ '9f780442f60000'h of data type Opaque is
+ '44079f780442f60000'h. (The tag is '44'h; the length
+ is '07'h; and the value is '9f780442f60000'h."
+ SYNTAX Opaque (SIZE (7))
+
+-------------------------------------------------------------------------------
+-- crate
+-------------------------------------------------------------------------------
+
+crate OBJECT-IDENTITY
+ STATUS current
+ DESCRIPTION
+ "SNMP control for electronic crates. A crate is a complete electronic system and
+ consists of the mechanical rack, a power supply, a fan tray and a backplane.
+ All this things are necessary to provide an adequate housing for electronic
+ modules (e.g. VME CPU's)"
+ ::= { wiener 1 }
+
+--Crate ::= SEQUENCE {
+-- system System,
+-- input Input,
+-- output Output,
+-- sensor Sensor,
+-- communication Communication,
+-- powersupply Powersupply,
+-- fantray Fantray,
+-- rack Rack
+--}
+
+system OBJECT-IDENTITY
+ STATUS current
+ DESCRIPTION
+ "A collection of objects which affect the complete crate"
+ ::= { crate 1 }
+
+
+input OBJECT-IDENTITY
+ STATUS current
+ DESCRIPTION
+ "All objects which are associated with the power input of the crate"
+ ::= { crate 2 }
+
+output OBJECT-IDENTITY
+ STATUS current
+ DESCRIPTION
+ "All objects which are associated with the power output of the crate"
+ ::= { crate 3 }
+
+sensor OBJECT-IDENTITY
+ STATUS current
+ DESCRIPTION
+ "All objects which are associated with temperature sensors in the crate"
+ ::= { crate 4 }
+
+communication OBJECT-IDENTITY
+ STATUS current
+ DESCRIPTION
+ "All objects which affect the remote control of the crate"
+ ::= { crate 5 }
+
+powersupply OBJECT-IDENTITY
+ STATUS current
+ DESCRIPTION
+ "All objects which are specific for the power supply of the crate"
+ ::= { crate 6 }
+
+fantray OBJECT-IDENTITY
+ STATUS current
+ DESCRIPTION
+ "All objects which are specific for the fan tray of the crate"
+ ::= { crate 7 }
+
+rack OBJECT-IDENTITY
+ STATUS current
+ DESCRIPTION
+ "All objects which are specific for the crate (BIN) of the crate"
+ ::= { crate 8 }
+
+signal OBJECT-IDENTITY
+ STATUS current
+ DESCRIPTION
+ "All objects which are associated with analog/digtal input/output in the crate"
+ ::= { crate 9 }
+
+
+-------------------------------------------------------------------------------
+-- system
+-------------------------------------------------------------------------------
+System ::= SEQUENCE {
+ sysMainSwitch INTEGER,
+ sysStatus BITS,
+ sysVmeSysReset INTEGER,
+ sysDebugMemory8 Integer32,
+ sysDebugMemory16 Integer32,
+ sysDebugMemory32 Integer32
+}
+
+sysMainSwitch OBJECT-TYPE
+ SYNTAX INTEGER { off (0), on (1) }
+ MAX-ACCESS read-write
+ STATUS current
+ DESCRIPTION
+ "Read: An enumerated value which shows the current state of
+ the crates main switch.
+ Write: Try to switch the complete crate ON or OFF.
+ Only the values ON or OFF are allowed."
+ ::= { system 1 }
+
+sysStatus OBJECT-TYPE
+ SYNTAX BITS {
+ mainOn (0) ,
+ mainInhibit (1) ,
+ localControlOnly (2) ,
+ inputFailure (3) ,
+ outputFailure (4) ,
+ fantrayFailure (5) ,
+ sensorFailure (6),
+ vmeSysfail (7),
+ plugAndPlayIncompatible (8)
+ }
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "A bit string which shows the status (health) of the complete crate.
+ If a bit is set (1), the explanation is satisfied
+ mainOn (0), system is switched on, individual outputs may be controlled by their specific ON/INHIBIT
+ mainInhibit(1), external (hardware-)inhibit of the complete system
+ localControlOnly (2), local control only (CANBUS write access denied)
+ inputFailure (3), any input failure (e.g. power fail)
+ outputFailure (4), any output failure, details in outputTable
+ fantrayFailure (5), fantray failure
+ sensorFailure (6), temperature of the external sensors too high
+ VmeSysfail(7), VME SYSFAIL signal is active
+ plugAndPlayIncompatible (8) wrong power supply and rack connected
+ "
+ ::= { system 2 }
+
+
+-- ERROR_BIN_CHECKSUM(?),
+
+
+
+
+
+sysVmeSysReset OBJECT-TYPE
+ SYNTAX INTEGER { trigger (1) }
+ MAX-ACCESS read-write
+ STATUS current
+ DESCRIPTION
+ "Read: Always 0.
+ Write: Trigger the generation of the VME SYSRESET signal.
+ This signal will be active for a time of 200 ms"
+ ::= { system 3 }
+
+sysDebugMemory8 OBJECT-TYPE
+ SYNTAX Integer32 (0..255)
+ MAX-ACCESS read-write
+ STATUS current
+ DESCRIPTION
+ "Debug 16-bit memory access."
+ ::= { system 1024 }
+
+sysDebugMemory16 OBJECT-TYPE
+ SYNTAX Integer32 (0..65535)
+ MAX-ACCESS read-write
+ STATUS current
+ DESCRIPTION
+ "Debug 16-bit memory access."
+ ::= { system 1025 }
+
+sysDebugMemory32 OBJECT-TYPE
+ SYNTAX Integer32 (-2147483648..2147483647)
+ MAX-ACCESS read-write
+ STATUS current
+ DESCRIPTION
+ "Debug 32-bit memory access."
+ ::= { system 1026 }
+
+-------------------------------------------------------------------------------
+-- input
+-------------------------------------------------------------------------------
+-- reserved, possible entries:
+-- inputSetPfcVoltage
+-- inputMesPowerFail
+-- inputMesVoltage
+-- inputMesCurrent
+-- inputMesPower
+-- inputMesTemperature
+-------------------------------------------------------------------------------
+-- output
+-------------------------------------------------------------------------------
+--Output ::= SEQUENCE {
+-- outputNumber Integer32,
+-- outputTable OutputTable,
+-- groupsNumber Integer32,
+-- groupsTable GroupsTable
+-- ??TotalPower
+--}
+
+outputNumber OBJECT-TYPE
+ SYNTAX Integer32 (0..1999)
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The number of output channels of the crate."
+ ::= { output 1 }
+
+outputTable OBJECT-TYPE
+ SYNTAX SEQUENCE OF OutputEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "A list of output entries."
+ ::= { output 2 }
+
+groupsNumber OBJECT-TYPE
+ SYNTAX Integer32 (1..1999)
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The number of output groups of the crate."
+ ::= { output 3 }
+
+groupsTable OBJECT-TYPE
+ SYNTAX SEQUENCE OF GroupsEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "A list of output groups entries."
+ ::= { output 4 }
+
+outputEntry OBJECT-TYPE
+ SYNTAX OutputEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "A table row"
+ INDEX { outputIndex }
+ ::= { outputTable 1 }
+
+OutputEntry ::= SEQUENCE {
+ outputIndex INTEGER,
+ outputName DisplayString,
+ outputGroup INTEGER,
+ outputStatus BITS,
+ outputMeasurementSenseVoltage Float,
+ outputMeasurementTerminalVoltage Float,
+ outputMeasurementCurrent Float,
+ outputMeasurementTemperature INTEGER,
+
+ outputSwitch INTEGER,
+ outputVoltage Float,
+ outputAdjustVoltage Integer32,
+ outputCurrent Float,
+
+ outputVoltageRiseRate Float,
+ outputVoltageFallRate Float,
+
+ outputSupervisionBehavior Integer32,
+ outputSupervisionMinSenseVoltage Float,
+ outputSupervisionMaxSenseVoltage Float,
+ outputSupervisionMaxTerminalVoltage Float,
+ outputSupervisionMaxCurrent Float,
+-- outputSupervisionMaxTemperature Integer32,
+
+ outputConfigMaxSenseVoltage Float,
+ outputConfigMaxTerminalVoltage Float,
+ outputConfigMaxCurrent Float,
+ outputSupervisionMaxPower Float,
+
+ outputCurrentRiseRate Float,
+ outputCurrentFallRate Float,
+ outputTripTimeMaxCurrent INTEGER
+ }
+
+
+outputIndex OBJECT-TYPE
+ SYNTAX INTEGER {
+ u0(1),u1(2),u2(3),u3(4),u4(5),u5(6),u6(7),u7(8),u8(9),u9(10),
+ u10(11),u11(12),u12(13),u13(14),u14(15),u15(16),u16(17),u17(18),u18(19),u19(20),
+ u20(21),u21(22),u22(23),u23(24),u24(25),u25(26),u26(27),u27(28),u28(29),u29(30),
+ u30(31),u31(32),u32(33),u33(34),u34(35),u35(36),u36(37),u37(38),u38(39),u39(40),
+ u40(41),u41(42),u42(43),u43(44),u44(45),u45(46),u46(47),u47(48),u48(49),u49(50),
+ u50(51),u51(52),u52(53),u53(54),u54(55),u55(56),u56(57),u57(58),u58(59),u59(60),
+ u60(61),u61(62),u62(63),u63(64),u64(65),u65(66),u66(67),u67(68),u68(69),u69(70),
+ u70(71),u71(72),u72(73),u73(74),u74(75),u75(76),u76(77),u77(78),u78(79),u79(80),
+ u80(81),u81(82),u82(83),u83(84),u84(85),u85(86),u86(87),u87(88),u88(89),u89(90),
+ u90(91),u91(92),u92(93),u93(94),u94(95),u95(96),u96(97),u97(98),u98(99),u99(100),
+ u100(101),u101(102),u102(103),u103(104),u104(105),u105(106),u106(107),u107(108),u108(109),u109(110),
+ u110(111),u111(112),u112(113),u113(114),u114(115),u115(116),u116(117),u117(118),u118(119),u119(120),
+ u120(121),u121(122),u122(123),u123(124),u124(125),u125(126),u126(127),u127(128),u128(129),u129(130),
+ u130(131),u131(132),u132(133),u133(134),u134(135),u135(136),u136(137),u137(138),u138(139),u139(140),
+ u140(141),u141(142),u142(143),u143(144),u144(145),u145(146),u146(147),u147(148),u148(149),u149(150),
+ u150(151),u151(152),u152(153),u153(154),u154(155),u155(156),u156(157),u157(158),u158(159),u159(160),
+ u160(161),u161(162),u162(163),u163(164),u164(165),u165(166),u166(167),u167(168),u168(169),u169(170),
+ u170(171),u171(172),u172(173),u173(174),u174(175),u175(176),u176(177),u177(178),u178(179),u179(180),
+ u180(181),u181(182),u182(183),u183(184),u184(185),u185(186),u186(187),u187(188),u188(189),u189(190),
+ u190(191),u191(192),u192(193),u193(194),u194(195),u195(196),u196(197),u197(198),u198(199),u199(200),
+ u200(201),u201(202),u202(203),u203(204),u204(205),u205(206),u206(207),u207(208),u208(209),u209(210),
+ u210(211),u211(212),u212(213),u213(214),u214(215),u215(216),u216(217),u217(218),u218(219),u219(220),
+ u220(221),u221(222),u222(223),u223(224),u224(225),u225(226),u226(227),u227(228),u228(229),u229(230),
+ u230(231),u231(232),u232(233),u233(234),u234(235),u235(236),u236(237),u237(238),u238(239),u239(240),
+ u240(241),u241(242),u242(243),u243(244),u244(245),u245(246),u246(247),u247(248),u248(249),u249(250),
+ u250(251),u251(252),u252(253),u253(254),u254(255),u255(256),u256(257),u257(258),u258(259),u259(260),
+ u260(261),u261(262),u262(263),u263(264),u264(265),u265(266),u266(267),u267(268),u268(269),u269(270),
+ u270(271),u271(272),u272(273),u273(274),u274(275),u275(276),u276(277),u277(278),u278(279),u279(280),
+ u280(281),u281(282),u282(283),u283(284),u284(285),u285(286),u286(287),u287(288),u288(289),u289(290),
+ u290(291),u291(292),u292(293),u293(294),u294(295),u295(296),u296(297),u297(298),u298(299),u299(300),
+ u300(301),u301(302),u302(303),u303(304),u304(305),u305(306),u306(307),u307(308),u308(309),u309(310),
+ u310(311),u311(312),u312(313),u313(314),u314(315),u315(316),u316(317),u317(318),u318(319),u319(320),
+ u320(321),u321(322),u322(323),u323(324),u324(325),u325(326),u326(327),u327(328),u328(329),u329(330),
+ u330(331),u331(332),u332(333),u333(334),u334(335),u335(336),u336(337),u337(338),u338(339),u339(340),
+ u340(341),u341(342),u342(343),u343(344),u344(345),u345(346),u346(347),u347(348),u348(349),u349(350),
+ u350(351),u351(352),u352(353),u353(354),u354(355),u355(356),u356(357),u357(358),u358(359),u359(360),
+ u360(361),u361(362),u362(363),u363(364),u364(365),u365(366),u366(367),u367(368),u368(369),u369(370),
+ u370(371),u371(372),u372(373),u373(374),u374(375),u375(376),u376(377),u377(378),u378(379),u379(380),
+ u380(381),u381(382),u382(383),u383(384),u384(385),u385(386),u386(387),u387(388),u388(389),u389(390),
+ u390(391),u391(392),u392(393),u393(394),u394(395),u395(396),u396(397),u397(398),u398(399),u399(400),
+ u400(401),u401(402),u402(403),u403(404),u404(405),u405(406),u406(407),u407(408),u408(409),u409(410),
+ u410(411),u411(412),u412(413),u413(414),u414(415),u415(416),u416(417),u417(418),u418(419),u419(420),
+ u420(421),u421(422),u422(423),u423(424),u424(425),u425(426),u426(427),u427(428),u428(429),u429(430),
+ u430(431),u431(432),u432(433),u433(434),u434(435),u435(436),u436(437),u437(438),u438(439),u439(440),
+ u440(441),u441(442),u442(443),u443(444),u444(445),u445(446),u446(447),u447(448),u448(449),u449(450),
+ u450(451),u451(452),u452(453),u453(454),u454(455),u455(456),u456(457),u457(458),u458(459),u459(460),
+ u460(461),u461(462),u462(463),u463(464),u464(465),u465(466),u466(467),u467(468),u468(469),u469(470),
+ u470(471),u471(472),u472(473),u473(474),u474(475),u475(476),u476(477),u477(478),u478(479),u479(480),
+ u480(481),u481(482),u482(483),u483(484),u484(485),u485(486),u486(487),u487(488),u488(489),u489(490),
+ u490(491),u491(492),u492(493),u493(494),u494(495),u495(496),u496(497),u497(498),u498(499),u499(500),
+ u500(501),u501(502),u502(503),u503(504),u504(505),u505(506),u506(507),u507(508),u508(509),u509(510),
+ u510(511),u511(512),u512(513),u513(514),u514(515),u515(516),u516(517),u517(518),u518(519),u519(520),
+ u520(521),u521(522),u522(523),u523(524),u524(525),u525(526),u526(527),u527(528),u528(529),u529(530),
+ u530(531),u531(532),u532(533),u533(534),u534(535),u535(536),u536(537),u537(538),u538(539),u539(540),
+ u540(541),u541(542),u542(543),u543(544),u544(545),u545(546),u546(547),u547(548),u548(549),u549(550),
+ u550(551),u551(552),u552(553),u553(554),u554(555),u555(556),u556(557),u557(558),u558(559),u559(560),
+ u560(561),u561(562),u562(563),u563(564),u564(565),u565(566),u566(567),u567(568),u568(569),u569(570),
+ u570(571),u571(572),u572(573),u573(574),u574(575),u575(576),u576(577),u577(578),u578(579),u579(580),
+ u580(581),u581(582),u582(583),u583(584),u584(585),u585(586),u586(587),u587(588),u588(589),u589(590),
+ u590(591),u591(592),u592(593),u593(594),u594(595),u595(596),u596(597),u597(598),u598(599),u599(600),
+ u600(601),u601(602),u602(603),u603(604),u604(605),u605(606),u606(607),u607(608),u608(609),u609(610),
+ u610(611),u611(612),u612(613),u613(614),u614(615),u615(616),u616(617),u617(618),u618(619),u619(620),
+ u620(621),u621(622),u622(623),u623(624),u624(625),u625(626),u626(627),u627(628),u628(629),u629(630),
+ u630(631),u631(632),u632(633),u633(634),u634(635),u635(636),u636(637),u637(638),u638(639),u639(640),
+ u640(641),u641(642),u642(643),u643(644),u644(645),u645(646),u646(647),u647(648),u648(649),u649(650),
+ u650(651),u651(652),u652(653),u653(654),u654(655),u655(656),u656(657),u657(658),u658(659),u659(660),
+ u660(661),u661(662),u662(663),u663(664),u664(665),u665(666),u666(667),u667(668),u668(669),u669(670),
+ u670(671),u671(672),u672(673),u673(674),u674(675),u675(676),u676(677),u677(678),u678(679),u679(680),
+ u680(681),u681(682),u682(683),u683(684),u684(685),u685(686),u686(687),u687(688),u688(689),u689(690),
+ u690(691),u691(692),u692(693),u693(694),u694(695),u695(696),u696(697),u697(698),u698(699),u699(700),
+ u700(701),u701(702),u702(703),u703(704),u704(705),u705(706),u706(707),u707(708),u708(709),u709(710),
+ u710(711),u711(712),u712(713),u713(714),u714(715),u715(716),u716(717),u717(718),u718(719),u719(720),
+ u720(721),u721(722),u722(723),u723(724),u724(725),u725(726),u726(727),u727(728),u728(729),u729(730),
+ u730(731),u731(732),u732(733),u733(734),u734(735),u735(736),u736(737),u737(738),u738(739),u739(740),
+ u740(741),u741(742),u742(743),u743(744),u744(745),u745(746),u746(747),u747(748),u748(749),u749(750),
+ u750(751),u751(752),u752(753),u753(754),u754(755),u755(756),u756(757),u757(758),u758(759),u759(760),
+ u760(761),u761(762),u762(763),u763(764),u764(765),u765(766),u766(767),u767(768),u768(769),u769(770),
+ u770(771),u771(772),u772(773),u773(774),u774(775),u775(776),u776(777),u777(778),u778(779),u779(780),
+ u780(781),u781(782),u782(783),u783(784),u784(785),u785(786),u786(787),u787(788),u788(789),u789(790),
+ u790(791),u791(792),u792(793),u793(794),u794(795),u795(796),u796(797),u797(798),u798(799),u799(800),
+ u800(801),u801(802),u802(803),u803(804),u804(805),u805(806),u806(807),u807(808),u808(809),u809(810),
+ u810(811),u811(812),u812(813),u813(814),u814(815),u815(816),u816(817),u817(818),u818(819),u819(820),
+ u820(821),u821(822),u822(823),u823(824),u824(825),u825(826),u826(827),u827(828),u828(829),u829(830),
+ u830(831),u831(832),u832(833),u833(834),u834(835),u835(836),u836(837),u837(838),u838(839),u839(840),
+ u840(841),u841(842),u842(843),u843(844),u844(845),u845(846),u846(847),u847(848),u848(849),u849(850),
+ u850(851),u851(852),u852(853),u853(854),u854(855),u855(856),u856(857),u857(858),u858(859),u859(860),
+ u860(861),u861(862),u862(863),u863(864),u864(865),u865(866),u866(867),u867(868),u868(869),u869(870),
+ u870(871),u871(872),u872(873),u873(874),u874(875),u875(876),u876(877),u877(878),u878(879),u879(880),
+ u880(881),u881(882),u882(883),u883(884),u884(885),u885(886),u886(887),u887(888),u888(889),u889(890),
+ u890(891),u891(892),u892(893),u893(894),u894(895),u895(896),u896(897),u897(898),u898(899),u899(900),
+ u900(901),u901(902),u902(903),u903(904),u904(905),u905(906),u906(907),u907(908),u908(909),u909(910),
+ u910(911),u911(912),u912(913),u913(914),u914(915),u915(916),u916(917),u917(918),u918(919),u919(920),
+ u920(921),u921(922),u922(923),u923(924),u924(925),u925(926),u926(927),u927(928),u928(929),u929(930),
+ u930(931),u931(932),u932(933),u933(934),u934(935),u935(936),u936(937),u937(938),u938(939),u939(940),
+ u940(941),u941(942),u942(943),u943(944),u944(945),u945(946),u946(947),u947(948),u948(949),u949(950),
+ u950(951),u951(952),u952(953),u953(954),u954(955),u955(956),u956(957),u957(958),u958(959),u959(960),
+ u960(961),u961(962),u962(963),u963(964),u964(965),u965(966),u966(967),u967(968),u968(969),u969(970),
+ u970(971),u971(972),u972(973),u973(974),u974(975),u975(976),u976(977),u977(978),u978(979),u979(980),
+ u980(981),u981(982),u982(983),u983(984),u984(985),u985(986),u986(987),u987(988),u988(989),u989(990),
+ u990(991),u991(992),u992(993),u993(994),u994(995),u995(996),u996(997),u997(998),u998(999),u999(1000),
+ u1000(1001),u1001(1002),u1002(1003),u1003(1004),u1004(1005),u1005(1006),u1006(1007),u1007(1008),u1008(1009),u1009(1010),
+ u1010(1011),u1011(1012),u1012(1013),u1013(1014),u1014(1015),u1015(1016),u1016(1017),u1017(1018),u1018(1019),u1019(1020),
+ u1020(1021),u1021(1022),u1022(1023),u1023(1024),u1024(1025),u1025(1026),u1026(1027),u1027(1028),u1028(1029),u1029(1030),
+ u1030(1031),u1031(1032),u1032(1033),u1033(1034),u1034(1035),u1035(1036),u1036(1037),u1037(1038),u1038(1039),u1039(1040),
+ u1040(1041),u1041(1042),u1042(1043),u1043(1044),u1044(1045),u1045(1046),u1046(1047),u1047(1048),u1048(1049),u1049(1050),
+ u1050(1051),u1051(1052),u1052(1053),u1053(1054),u1054(1055),u1055(1056),u1056(1057),u1057(1058),u1058(1059),u1059(1060),
+ u1060(1061),u1061(1062),u1062(1063),u1063(1064),u1064(1065),u1065(1066),u1066(1067),u1067(1068),u1068(1069),u1069(1070),
+ u1070(1071),u1071(1072),u1072(1073),u1073(1074),u1074(1075),u1075(1076),u1076(1077),u1077(1078),u1078(1079),u1079(1080),
+ u1080(1081),u1081(1082),u1082(1083),u1083(1084),u1084(1085),u1085(1086),u1086(1087),u1087(1088),u1088(1089),u1089(1090),
+ u1090(1091),u1091(1092),u1092(1093),u1093(1094),u1094(1095),u1095(1096),u1096(1097),u1097(1098),u1098(1099),u1099(1100),
+ u1100(1101),u1101(1102),u1102(1103),u1103(1104),u1104(1105),u1105(1106),u1106(1107),u1107(1108),u1108(1109),u1109(1110),
+ u1110(1111),u1111(1112),u1112(1113),u1113(1114),u1114(1115),u1115(1116),u1116(1117),u1117(1118),u1118(1119),u1119(1120),
+ u1120(1121),u1121(1122),u1122(1123),u1123(1124),u1124(1125),u1125(1126),u1126(1127),u1127(1128),u1128(1129),u1129(1130),
+ u1130(1131),u1131(1132),u1132(1133),u1133(1134),u1134(1135),u1135(1136),u1136(1137),u1137(1138),u1138(1139),u1139(1140),
+ u1140(1141),u1141(1142),u1142(1143),u1143(1144),u1144(1145),u1145(1146),u1146(1147),u1147(1148),u1148(1149),u1149(1150),
+ u1150(1151),u1151(1152),u1152(1153),u1153(1154),u1154(1155),u1155(1156),u1156(1157),u1157(1158),u1158(1159),u1159(1160),
+ u1160(1161),u1161(1162),u1162(1163),u1163(1164),u1164(1165),u1165(1166),u1166(1167),u1167(1168),u1168(1169),u1169(1170),
+ u1170(1171),u1171(1172),u1172(1173),u1173(1174),u1174(1175),u1175(1176),u1176(1177),u1177(1178),u1178(1179),u1179(1180),
+ u1180(1181),u1181(1182),u1182(1183),u1183(1184),u1184(1185),u1185(1186),u1186(1187),u1187(1188),u1188(1189),u1189(1190),
+ u1190(1191),u1191(1192),u1192(1193),u1193(1194),u1194(1195),u1195(1196),u1196(1197),u1197(1198),u1198(1199),u1199(1200),
+ u1200(1201),u1201(1202),u1202(1203),u1203(1204),u1204(1205),u1205(1206),u1206(1207),u1207(1208),u1208(1209),u1209(1210),
+ u1210(1211),u1211(1212),u1212(1213),u1213(1214),u1214(1215),u1215(1216),u1216(1217),u1217(1218),u1218(1219),u1219(1220),
+ u1220(1221),u1221(1222),u1222(1223),u1223(1224),u1224(1225),u1225(1226),u1226(1227),u1227(1228),u1228(1229),u1229(1230),
+ u1230(1231),u1231(1232),u1232(1233),u1233(1234),u1234(1235),u1235(1236),u1236(1237),u1237(1238),u1238(1239),u1239(1240),
+ u1240(1241),u1241(1242),u1242(1243),u1243(1244),u1244(1245),u1245(1246),u1246(1247),u1247(1248),u1248(1249),u1249(1250),
+ u1250(1251),u1251(1252),u1252(1253),u1253(1254),u1254(1255),u1255(1256),u1256(1257),u1257(1258),u1258(1259),u1259(1260),
+ u1260(1261),u1261(1262),u1262(1263),u1263(1264),u1264(1265),u1265(1266),u1266(1267),u1267(1268),u1268(1269),u1269(1270),
+ u1270(1271),u1271(1272),u1272(1273),u1273(1274),u1274(1275),u1275(1276),u1276(1277),u1277(1278),u1278(1279),u1279(1280),
+ u1280(1281),u1281(1282),u1282(1283),u1283(1284),u1284(1285),u1285(1286),u1286(1287),u1287(1288),u1288(1289),u1289(1290),
+ u1290(1291),u1291(1292),u1292(1293),u1293(1294),u1294(1295),u1295(1296),u1296(1297),u1297(1298),u1298(1299),u1299(1300),
+ u1300(1301),u1301(1302),u1302(1303),u1303(1304),u1304(1305),u1305(1306),u1306(1307),u1307(1308),u1308(1309),u1309(1310),
+ u1310(1311),u1311(1312),u1312(1313),u1313(1314),u1314(1315),u1315(1316),u1316(1317),u1317(1318),u1318(1319),u1319(1320),
+ u1320(1321),u1321(1322),u1322(1323),u1323(1324),u1324(1325),u1325(1326),u1326(1327),u1327(1328),u1328(1329),u1329(1330),
+ u1330(1331),u1331(1332),u1332(1333),u1333(1334),u1334(1335),u1335(1336),u1336(1337),u1337(1338),u1338(1339),u1339(1340),
+ u1340(1341),u1341(1342),u1342(1343),u1343(1344),u1344(1345),u1345(1346),u1346(1347),u1347(1348),u1348(1349),u1349(1350),
+ u1350(1351),u1351(1352),u1352(1353),u1353(1354),u1354(1355),u1355(1356),u1356(1357),u1357(1358),u1358(1359),u1359(1360),
+ u1360(1361),u1361(1362),u1362(1363),u1363(1364),u1364(1365),u1365(1366),u1366(1367),u1367(1368),u1368(1369),u1369(1370),
+ u1370(1371),u1371(1372),u1372(1373),u1373(1374),u1374(1375),u1375(1376),u1376(1377),u1377(1378),u1378(1379),u1379(1380),
+ u1380(1381),u1381(1382),u1382(1383),u1383(1384),u1384(1385),u1385(1386),u1386(1387),u1387(1388),u1388(1389),u1389(1390),
+ u1390(1391),u1391(1392),u1392(1393),u1393(1394),u1394(1395),u1395(1396),u1396(1397),u1397(1398),u1398(1399),u1399(1400),
+ u1400(1401),u1401(1402),u1402(1403),u1403(1404),u1404(1405),u1405(1406),u1406(1407),u1407(1408),u1408(1409),u1409(1410),
+ u1410(1411),u1411(1412),u1412(1413),u1413(1414),u1414(1415),u1415(1416),u1416(1417),u1417(1418),u1418(1419),u1419(1420),
+ u1420(1421),u1421(1422),u1422(1423),u1423(1424),u1424(1425),u1425(1426),u1426(1427),u1427(1428),u1428(1429),u1429(1430),
+ u1430(1431),u1431(1432),u1432(1433),u1433(1434),u1434(1435),u1435(1436),u1436(1437),u1437(1438),u1438(1439),u1439(1440),
+ u1440(1441),u1441(1442),u1442(1443),u1443(1444),u1444(1445),u1445(1446),u1446(1447),u1447(1448),u1448(1449),u1449(1450),
+ u1450(1451),u1451(1452),u1452(1453),u1453(1454),u1454(1455),u1455(1456),u1456(1457),u1457(1458),u1458(1459),u1459(1460),
+ u1460(1461),u1461(1462),u1462(1463),u1463(1464),u1464(1465),u1465(1466),u1466(1467),u1467(1468),u1468(1469),u1469(1470),
+ u1470(1471),u1471(1472),u1472(1473),u1473(1474),u1474(1475),u1475(1476),u1476(1477),u1477(1478),u1478(1479),u1479(1480),
+ u1480(1481),u1481(1482),u1482(1483),u1483(1484),u1484(1485),u1485(1486),u1486(1487),u1487(1488),u1488(1489),u1489(1490),
+ u1490(1491),u1491(1492),u1492(1493),u1493(1494),u1494(1495),u1495(1496),u1496(1497),u1497(1498),u1498(1499),u1499(1500),
+ u1500(1501),u1501(1502),u1502(1503),u1503(1504),u1504(1505),u1505(1506),u1506(1507),u1507(1508),u1508(1509),u1509(1510),
+ u1510(1511),u1511(1512),u1512(1513),u1513(1514),u1514(1515),u1515(1516),u1516(1517),u1517(1518),u1518(1519),u1519(1520),
+ u1520(1521),u1521(1522),u1522(1523),u1523(1524),u1524(1525),u1525(1526),u1526(1527),u1527(1528),u1528(1529),u1529(1530),
+ u1530(1531),u1531(1532),u1532(1533),u1533(1534),u1534(1535),u1535(1536),u1536(1537),u1537(1538),u1538(1539),u1539(1540),
+ u1540(1541),u1541(1542),u1542(1543),u1543(1544),u1544(1545),u1545(1546),u1546(1547),u1547(1548),u1548(1549),u1549(1550),
+ u1550(1551),u1551(1552),u1552(1553),u1553(1554),u1554(1555),u1555(1556),u1556(1557),u1557(1558),u1558(1559),u1559(1560),
+ u1560(1561),u1561(1562),u1562(1563),u1563(1564),u1564(1565),u1565(1566),u1566(1567),u1567(1568),u1568(1569),u1569(1570),
+ u1570(1571),u1571(1572),u1572(1573),u1573(1574),u1574(1575),u1575(1576),u1576(1577),u1577(1578),u1578(1579),u1579(1580),
+ u1580(1581),u1581(1582),u1582(1583),u1583(1584),u1584(1585),u1585(1586),u1586(1587),u1587(1588),u1588(1589),u1589(1590),
+ u1590(1591),u1591(1592),u1592(1593),u1593(1594),u1594(1595),u1595(1596),u1596(1597),u1597(1598),u1598(1599),u1599(1600),
+ u1600(1601),u1601(1602),u1602(1603),u1603(1604),u1604(1605),u1605(1606),u1606(1607),u1607(1608),u1608(1609),u1609(1610),
+ u1610(1611),u1611(1612),u1612(1613),u1613(1614),u1614(1615),u1615(1616),u1616(1617),u1617(1618),u1618(1619),u1619(1620),
+ u1620(1621),u1621(1622),u1622(1623),u1623(1624),u1624(1625),u1625(1626),u1626(1627),u1627(1628),u1628(1629),u1629(1630),
+ u1630(1631),u1631(1632),u1632(1633),u1633(1634),u1634(1635),u1635(1636),u1636(1637),u1637(1638),u1638(1639),u1639(1640),
+ u1640(1641),u1641(1642),u1642(1643),u1643(1644),u1644(1645),u1645(1646),u1646(1647),u1647(1648),u1648(1649),u1649(1650),
+ u1650(1651),u1651(1652),u1652(1653),u1653(1654),u1654(1655),u1655(1656),u1656(1657),u1657(1658),u1658(1659),u1659(1660),
+ u1660(1661),u1661(1662),u1662(1663),u1663(1664),u1664(1665),u1665(1666),u1666(1667),u1667(1668),u1668(1669),u1669(1670),
+ u1670(1671),u1671(1672),u1672(1673),u1673(1674),u1674(1675),u1675(1676),u1676(1677),u1677(1678),u1678(1679),u1679(1680),
+ u1680(1681),u1681(1682),u1682(1683),u1683(1684),u1684(1685),u1685(1686),u1686(1687),u1687(1688),u1688(1689),u1689(1690),
+ u1690(1691),u1691(1692),u1692(1693),u1693(1694),u1694(1695),u1695(1696),u1696(1697),u1697(1698),u1698(1699),u1699(1700),
+ u1700(1701),u1701(1702),u1702(1703),u1703(1704),u1704(1705),u1705(1706),u1706(1707),u1707(1708),u1708(1709),u1709(1710),
+ u1710(1711),u1711(1712),u1712(1713),u1713(1714),u1714(1715),u1715(1716),u1716(1717),u1717(1718),u1718(1719),u1719(1720),
+ u1720(1721),u1721(1722),u1722(1723),u1723(1724),u1724(1725),u1725(1726),u1726(1727),u1727(1728),u1728(1729),u1729(1730),
+ u1730(1731),u1731(1732),u1732(1733),u1733(1734),u1734(1735),u1735(1736),u1736(1737),u1737(1738),u1738(1739),u1739(1740),
+ u1740(1741),u1741(1742),u1742(1743),u1743(1744),u1744(1745),u1745(1746),u1746(1747),u1747(1748),u1748(1749),u1749(1750),
+ u1750(1751),u1751(1752),u1752(1753),u1753(1754),u1754(1755),u1755(1756),u1756(1757),u1757(1758),u1758(1759),u1759(1760),
+ u1760(1761),u1761(1762),u1762(1763),u1763(1764),u1764(1765),u1765(1766),u1766(1767),u1767(1768),u1768(1769),u1769(1770),
+ u1770(1771),u1771(1772),u1772(1773),u1773(1774),u1774(1775),u1775(1776),u1776(1777),u1777(1778),u1778(1779),u1779(1780),
+ u1780(1781),u1781(1782),u1782(1783),u1783(1784),u1784(1785),u1785(1786),u1786(1787),u1787(1788),u1788(1789),u1789(1790),
+ u1790(1791),u1791(1792),u1792(1793),u1793(1794),u1794(1795),u1795(1796),u1796(1797),u1797(1798),u1798(1799),u1799(1800),
+ u1800(1801),u1801(1802),u1802(1803),u1803(1804),u1804(1805),u1805(1806),u1806(1807),u1807(1808),u1808(1809),u1809(1810),
+ u1810(1811),u1811(1812),u1812(1813),u1813(1814),u1814(1815),u1815(1816),u1816(1817),u1817(1818),u1818(1819),u1819(1820),
+ u1820(1821),u1821(1822),u1822(1823),u1823(1824),u1824(1825),u1825(1826),u1826(1827),u1827(1828),u1828(1829),u1829(1830),
+ u1830(1831),u1831(1832),u1832(1833),u1833(1834),u1834(1835),u1835(1836),u1836(1837),u1837(1838),u1838(1839),u1839(1840),
+ u1840(1841),u1841(1842),u1842(1843),u1843(1844),u1844(1845),u1845(1846),u1846(1847),u1847(1848),u1848(1849),u1849(1850),
+ u1850(1851),u1851(1852),u1852(1853),u1853(1854),u1854(1855),u1855(1856),u1856(1857),u1857(1858),u1858(1859),u1859(1860),
+ u1860(1861),u1861(1862),u1862(1863),u1863(1864),u1864(1865),u1865(1866),u1866(1867),u1867(1868),u1868(1869),u1869(1870),
+ u1870(1871),u1871(1872),u1872(1873),u1873(1874),u1874(1875),u1875(1876),u1876(1877),u1877(1878),u1878(1879),u1879(1880),
+ u1880(1881),u1881(1882),u1882(1883),u1883(1884),u1884(1885),u1885(1886),u1886(1887),u1887(1888),u1888(1889),u1889(1890),
+ u1890(1891),u1891(1892),u1892(1893),u1893(1894),u1894(1895),u1895(1896),u1896(1897),u1897(1898),u1898(1899),u1899(1900),
+ u1900(1901),u1901(1902),u1902(1903),u1903(1904),u1904(1905),u1905(1906),u1906(1907),u1907(1908),u1908(1909),u1909(1910),
+ u1910(1911),u1911(1912),u1912(1913),u1913(1914),u1914(1915),u1915(1916),u1916(1917),u1917(1918),u1918(1919),u1919(1920),
+ u1920(1921),u1921(1922),u1922(1923),u1923(1924),u1924(1925),u1925(1926),u1926(1927),u1927(1928),u1928(1929),u1929(1930),
+ u1930(1931),u1931(1932),u1932(1933),u1933(1934),u1934(1935),u1935(1936),u1936(1937),u1937(1938),u1938(1939),u1939(1940),
+ u1940(1941),u1941(1942),u1942(1943),u1943(1944),u1944(1945),u1945(1946),u1946(1947),u1947(1948),u1948(1949),u1949(1950),
+ u1950(1951),u1951(1952),u1952(1953),u1953(1954),u1954(1955),u1955(1956),u1956(1957),u1957(1958),u1958(1959),u1959(1960),
+ u1960(1961),u1961(1962),u1962(1963),u1963(1964),u1964(1965),u1965(1966),u1966(1967),u1967(1968),u1968(1969),u1969(1970),
+ u1970(1971),u1971(1972),u1972(1973),u1973(1974),u1974(1975),u1975(1976),u1976(1977),u1977(1978),u1978(1979),u1979(1980),
+ u1980(1981),u1981(1982),u1982(1983),u1983(1984),u1984(1985),u1985(1986),u1986(1987),u1987(1988),u1988(1989),u1989(1990),
+ u1990(1991),u1991(1992),u1992(1993),u1993(1994),u1994(1995),u1995(1996),u1996(1997),u1997(1998),u1998(1999),u1999(2000)}
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "A unique number for each power output channel. Its value
+ ranges between 1 and total number of output channels.
+ This value is equivalent to the output channel number at
+ the type label of the crate or power supply, but because the SMI
+ index starts at 1, index 1 corresponds to U0."
+ ::= { outputEntry 1 }
+
+outputName OBJECT-TYPE
+ SYNTAX DisplayString (SIZE (1..4))
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "A textual string containing a short name of the
+ output. If the crate is equipped with an alphanumeric
+ display, this string is shown to identify a output channel."
+ ::= { outputEntry 2 }
+
+outputGroup OBJECT-TYPE
+ SYNTAX Integer32 (0..1999)
+ MAX-ACCESS read-write
+ STATUS current
+ DESCRIPTION
+ "The group number associated with this channel"
+ ::= { outputEntry 3 }
+
+
+outputStatus OBJECT-TYPE
+ SYNTAX BITS {
+ outputOn (0) ,
+ outputInhibit (1) ,
+ outputFailureMinSenseVoltage (2),
+ outputFailureMaxSenseVoltage (3),
+ outputFailureMaxTerminalVoltage (4),
+ outputFailureMaxCurrent (5),
+ outputFailureMaxTemperature (6),
+ outputFailureMaxPower (7),
+ -- reserved
+ outputFailureTimeout (9),
+ outputCurrentLimited (10),
+ outputRampUp (11),
+ outputRampDown (12),
+ outputEnableKill(13),
+ outputEmergencyOff (14)
+ }
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "A bit string which shows the status (health and operating conditions) of one output channel.
+ If a bit is set (1), the explanation is satisfied:
+ outputOn (0), output channel is on
+ outputInhibit(1), external (hardware-)inhibit of the output channel
+ outputFailureMinSenseVoltage (2) Supervision limit hurt: Sense voltage is too low
+ outputFailureMaxSenseVoltage (3), Supervision limit hurt: Sense voltage is too high
+ outputFailureMaxTerminalVoltage (4), Supervision limit hurt: Terminal voltage is too high
+ outputFailureMaxCurrent (5), Supervision limit hurt: Current is too high
+ outputFailureMaxTemperature (6), Supervision limit hurt: Heat sink temperature is too high
+ outputFailureMaxPower (7), Supervision limit hurt: Output power is too high
+ outputFailureTimeout (9), Communication timeout between output channel and main control
+ outputCurrentLimited (10), Current limiting is active (constant current mode)
+ outputRampUp (11), Output voltage is increasing (e.g. after switch on)
+ outputRampDown (12), Output voltage is decreasing (e.g. after switch off)
+ outputEnableKill (13), EnableKill is aktive
+ outputEmergencyOff (14), EmergencyOff event is aktive
+
+ "
+
+ ::= { outputEntry 4 }
+
+
+
+
+outputMeasurementSenseVoltage OBJECT-TYPE
+ SYNTAX Float
+ UNITS "V"
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The measured voltage at the sense input lines."
+ ::= { outputEntry 5 }
+
+outputMeasurementTerminalVoltage OBJECT-TYPE
+ SYNTAX Float
+ UNITS "V"
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The measured voltage at the output terminals."
+ ::= { outputEntry 6 }
+
+outputMeasurementCurrent OBJECT-TYPE
+ SYNTAX Float
+ UNITS "A"
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The measured output current."
+ ::= { outputEntry 7 }
+
+outputMeasurementTemperature OBJECT-TYPE
+ SYNTAX INTEGER { ok (-128), failure(127) }
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The measured temperature of the power module."
+ ::= { outputEntry 8 }
+
+
+outputSwitch OBJECT-TYPE
+ SYNTAX INTEGER { Off (0), On (1), resetEmergencyOff (2), setEmergencyOff (3), clearEvents (10) }
+ MAX-ACCESS read-write
+ STATUS current
+ DESCRIPTION
+ "Read: An enumerated value which shows the current state of
+ the output channel.
+
+ Write: Change the state of the channel.
+ If the channel is On, and the write value is Off, then the channel
+ will switch Off.
+ If the channel is Off, and the write value is On, and if no other
+ signals (mainInhibit, outputInhibit, outputEmergencyOff or outputFailureMaxCurrent)
+ are active, then the channel will switch on.
+
+ If the write value is resetEmergencyOff, then the channel will
+ leave the state EmergencyOff. A write of clearEvents is necessary
+ before the voltage can ramp up again.
+ If the write value is setEmergencyOff, then the channel will have
+ the state EmergencyOff, which means that the High Voltage will
+ switch off without a ramp and reset of the outputVoltage to null volt.
+
+ If the write value is clearEvents, then all failure messages
+ of the outputStatus will be reset (all channel events, all module events
+ and the state emergencyOff)."
+ ::= { outputEntry 9 }
+
+outputVoltage OBJECT-TYPE
+ SYNTAX Float
+ UNITS "V"
+ MAX-ACCESS read-write
+ STATUS current
+ DESCRIPTION
+ "The nominal output voltage of the channel."
+ ::= { outputEntry 10 }
+
+outputAdjustVoltage OBJECT-TYPE
+ SYNTAX Integer32 (-128..127)
+ MAX-ACCESS read-write
+ STATUS obsolete
+ DESCRIPTION
+ "A posibillity to make small changes of the output voltage."
+ ::= { outputEntry 11 }
+
+outputCurrent OBJECT-TYPE
+ SYNTAX Float
+ UNITS "A"
+ MAX-ACCESS read-write
+ STATUS current
+ DESCRIPTION
+ "The current limit of the channel."
+ ::= { outputEntry 12 }
+
+outputVoltageRiseRate OBJECT-TYPE
+ SYNTAX Float
+ UNITS "V/s"
+ MAX-ACCESS read-write
+ STATUS current
+ DESCRIPTION
+ "Voltage Fall Slew Rate [V/s].
+ The slew rate of the output voltage if it increases (after switch on or if the Voltage has been
+ changed).
+ "
+ ::= { outputEntry 13 }
+
+outputVoltageFallRate OBJECT-TYPE
+ SYNTAX Float
+ UNITS "V/s"
+ MAX-ACCESS read-write
+ STATUS current
+ DESCRIPTION
+ "Voltage Rise Slew Rate [V/s].
+ The slew rate of the output voltage if it decreases (after switch off or if the Voltage has been
+ changed).
+ "
+ ::= { outputEntry 14 }
+
+outputSupervisionBehavior OBJECT-TYPE
+ SYNTAX Integer32 (0..65535)
+ MAX-ACCESS read-write
+ STATUS current
+ DESCRIPTION
+ "A bit field packed into an integer which define the behavior of the output channel / power supply
+ after failures.
+ For each supervision value, a two-bit field exists.
+ The enumeration of this value (..L+..H*2) is:
+ WIENER LV devices
+ 0 ignore the failure
+ 1 switch off this channel
+ 2 switch off all channels with the same group number
+ 3 switch off the complete crate.
+ iseg HV devices
+ 0 ignore the failure
+ 1 switch off this channel by ramp down the voltage
+ 2 switch off this channel by a emergencyOff
+ 3 switch off the whole board of the HV module by emergencyOff.
+ The position of the bit fields in the integer value are:
+ Bit 0, 1: outputFailureMinSenseVoltage
+ Bit 2, 3: outputFailureMaxSenseVoltage
+ Bit 4, 5: outputFailureMaxTerminalVoltage
+ Bit 6, 7: outputFailureMaxCurrent
+ Bit 8, 9: outputFailureMaxTemperature
+ Bit 10, 11: outputFailureMaxPower
+ Bit 12, 13: outputFailureInhibit
+ Bit 14, 15: outputFailureTimeout
+ "
+
+ ::= { outputEntry 15 }
+
+outputSupervisionMinSenseVoltage OBJECT-TYPE
+ SYNTAX Float
+ UNITS "V"
+ MAX-ACCESS read-write
+ STATUS current
+ DESCRIPTION
+ "If the measured sense voltage is below this value, the power supply
+ performs the function defined by SupervisionAction."
+ ::= { outputEntry 16 }
+
+outputSupervisionMaxSenseVoltage OBJECT-TYPE
+ SYNTAX Float
+ UNITS "V"
+ MAX-ACCESS read-write
+ STATUS current
+ DESCRIPTION
+ "If the measured sense voltage is above this value, the power supply
+ performs the function defined by SupervisionAction."
+ ::= { outputEntry 17 }
+
+outputSupervisionMaxTerminalVoltage OBJECT-TYPE
+ SYNTAX Float
+ UNITS "V"
+ MAX-ACCESS read-write
+ STATUS current
+ DESCRIPTION
+ "If the measured voltage at the power supply output
+ terminals is above this value, the power supply
+ performs the function defined by SupervisionAction."
+ ::= { outputEntry 18 }
+
+outputSupervisionMaxCurrent OBJECT-TYPE
+ SYNTAX Float
+ UNITS "A"
+ MAX-ACCESS read-write
+ STATUS current
+ DESCRIPTION
+ "If the measured current is above this value, the power supply
+ performs the function defined by SupervisionAction."
+ ::= { outputEntry 19 }
+
+--outputSupervisionMaxTemperature OBJECT-TYPE wohl besser config !!
+-- SYNTAX INTEGER
+-- MAX-ACCESS read-write
+-- STATUS current
+-- DESCRIPTION
+-- "If the measured module temperature is above this value, the power supply
+-- performs the function defined by SupervisionAction."
+-- ::= { outputEntry 20 }
+
+
+
+outputConfigMaxSenseVoltage OBJECT-TYPE
+ SYNTAX Float
+ UNITS "V"
+ MAX-ACCESS read-write
+ STATUS current
+ DESCRIPTION
+ "The maximum possible value of the sense voltage"
+ ::= { outputEntry 21 }
+
+outputConfigMaxTerminalVoltage OBJECT-TYPE
+ SYNTAX Float
+ UNITS "V"
+ MAX-ACCESS read-write
+ STATUS current
+ DESCRIPTION
+ "The maximum possible value of the terminal voltage"
+ ::= { outputEntry 22 }
+
+outputConfigMaxCurrent OBJECT-TYPE
+ SYNTAX Float
+ UNITS "A"
+ MAX-ACCESS read-write
+ STATUS current
+ DESCRIPTION
+ "The maximum possible value of the output current"
+ ::= { outputEntry 23 }
+
+outputSupervisionMaxPower OBJECT-TYPE
+ SYNTAX Float
+ UNITS "W"
+ MAX-ACCESS read-write
+ STATUS current
+ DESCRIPTION
+ "If the measured power (measured current * measured terminal voltage)
+ is above this value, the power supply performs the function defined
+ by SupervisionAction."
+ ::= { outputEntry 24 }
+
+outputCurrentRiseRate OBJECT-TYPE
+ SYNTAX Float
+ UNITS "A/s"
+ MAX-ACCESS read-write
+ STATUS current
+ DESCRIPTION
+ "Current Fall Slew Rate [A/s].
+ The slew rate of the output current if it increases (after
+ switch on or if the Current has been changed).
+ "
+ ::= { outputEntry 25 }
+
+outputCurrentFallRate OBJECT-TYPE
+ SYNTAX Float
+ UNITS "A/s"
+ MAX-ACCESS read-write
+ STATUS current
+ DESCRIPTION
+ "Current Rise Slew Rate [A/s].
+ The slew rate of the output current if it decreases (after
+ switch off or if the Current has been changed).
+ "
+ ::= { outputEntry 26 }
+
+outputTripTimeMaxCurrent OBJECT-TYPE
+ SYNTAX INTEGER (0..4000)
+ UNITS "ms"
+ MAX-ACCESS read-write
+ STATUS current
+ DESCRIPTION
+ "Current trip time out [ms].
+ The outputTripTimeMaxCurrent defines a span for the time out function.
+ The activity is depending from the bit field outputFailureMaxCurrent
+ of the outputSupervisionBehavior."
+ ::= { outputEntry 27 }
+
+-------------------------------------------------------------------------------
+-- output->groups
+-------------------------------------------------------------------------------
+
+groupsEntry OBJECT-TYPE
+ SYNTAX GroupsEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "A table row"
+ INDEX { groupsIndex }
+ ::= { groupsTable 1 }
+
+GroupsEntry ::=
+ SEQUENCE {
+ groupsIndex
+ INTEGER,
+-- outputGroupsName
+-- DisplayString,
+-- outputGroupsGroup
+-- INTEGER,
+
+-- outputGroupsStatus
+-- BITS,
+-- outputGroupsMeasurementSenseVoltage
+-- Float,
+-- outputMeasurementTerminalVoltage
+-- Float,
+-- outputMeasurementCurrent
+-- Float,
+-- outputMeasurementTemperature
+-- INTEGER,
+
+
+ groupsSwitch
+ INTEGER
+-- outputVoltage
+-- Float,
+-- outputAdjustVoltage
+-- INTEGER,
+-- outputCurrent
+-- Float,
+
+-- outputRampUp
+-- Float,
+-- outputRampDown
+-- Float,
+
+-- outputSupervisionBehavior
+-- INTEGER,
+-- outputSupervisionMinSenseVoltage
+-- Float,
+-- outputSupervisionMaxSenseVoltage
+-- Float,
+-- outputSupervisionMaxTerminalVoltage
+-- Float,
+-- outputSupervisionMaxCurrent
+-- Float,
+-- outputSupervisionMaxTemperature
+-- INTEGER,
+
+-- outputConfigMaxSenseVoltage
+-- Float,
+-- outputConfigMaxTerminalVoltage
+-- Float,
+-- outputConfigMaxCurrent
+-- Float,
+-- outputSupervisionMaxPower
+-- Float,
+ }
+
+groupsIndex OBJECT-TYPE
+ SYNTAX Integer32 (0..1999)
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "A unique number for each power output group. Its value
+ ranges between 1 and 1999.
+ The special group 0 is predefined and gives access to all channels.
+ "
+ ::= { groupsEntry 1 }
+
+groupsSwitch OBJECT-TYPE
+ SYNTAX INTEGER { undefined (-1), Off (0), On (1), resetEmergencyOff (2), setEmergencyOff(3), disableKill (4), enableKill (5), clearEvents(10) }
+ MAX-ACCESS read-write
+ STATUS current
+ DESCRIPTION
+ "Read: This function is not defined with groups of output channels.
+
+ Write: Switch the state of all channels of a group.
+ If any channel is On, and the write value is Off, then all channels
+ will switch off.
+ If any channel is Off, and the write value is On, and if no other
+ signals (mainInhibit, outputInhibit, outputEmergencyOff or outputFailureMaxCurrent)
+ are active, then all channels will switch on.
+
+ If the write value is resetEmergencyOff, then all channels will
+ leave the state EmergencyOff. A write of clearEvents is necessary
+ before the voltage can ramp up again.
+ If the write value is setEmergencyOff, then all channels will have
+ the state EmergencyOff, which means that the High Voltage will
+ switch off without a ramp and reset of the outputVoltage to null volt.
+
+ If the write value is disableKILL, then all channels will switch
+ to disableKill (outputStatus outputDisableKill).
+ If the write value is enableKILL, then all channels will switch
+ to enableKill (outputStatus outputEnableKill).
+
+ If the write value is clearEvents, then all failure messages
+ of the outputStatus will be cleared (all channel events,
+ all module events and the state outputEmergencyOff will be reset)."
+ ::= { groupsEntry 9 }
+
+--groupsName OBJECT-TYPE
+-- SYNTAX DisplayString (SIZE (1..4))
+-- MAX-ACCESS read-only
+-- STATUS current
+-- DESCRIPTION
+-- "A textual string containing a short name of the
+-- output. If the crate is equipped with an alphanumeric
+-- display, this string is shown to identify a output channel."
+-- ::= { groupsEntry 2 }
+
+
+
+
+-------------------------------------------------------------------------------
+-- sensor
+-------------------------------------------------------------------------------
+--Sensor ::= SEQUENCE {
+-- sensorNumber Integer32,
+-- sensorTable SensorTable
+--}
+
+sensorNumber OBJECT-TYPE
+ SYNTAX Integer32 (0..8)
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The number of temperature sensors of the crate."
+ ::= { sensor 1 }
+
+sensorTable OBJECT-TYPE
+ SYNTAX SEQUENCE OF SensorEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "A (conceptual table) of temperature sensor data."
+ ::= { sensor 2 }
+
+sensorEntry OBJECT-TYPE
+ SYNTAX SensorEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "An entry (conceptual row) of the sensorTable."
+ INDEX { sensorIndex }
+ ::= { sensorTable 1 }
+
+SensorEntry ::= SEQUENCE {
+ sensorIndex INTEGER,
+ sensorTemperature INTEGER,
+ sensorWarningThreshold INTEGER,
+ sensorFailureThreshold INTEGER
+ }
+
+sensorIndex OBJECT-TYPE
+ SYNTAX INTEGER { temp1 (1), temp2(2), temp3(3), temp4(4), temp5(5),
+ temp6(6), temp7(7), temp8(8) }
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "A unique number for each temperature sensor in the crate"
+ ::= { sensorEntry 1 }
+
+sensorTemperature OBJECT-TYPE
+-- CHECK SYNTAX INTEGER { UNUSED(-128), (-127..127) }
+ SYNTAX Integer32 (-128..127)
+ UNITS "deg C"
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The measured temperature of the sensor.
+ Unused temperature probes have the special value -128"
+ ::= { sensorEntry 2 }
+
+sensorWarningThreshold OBJECT-TYPE
+-- CHECK SYNTAX INTEGER { (0..126), DISABLED(127) }
+ SYNTAX Integer32 (0..127)
+ UNITS "deg C"
+ MAX-ACCESS read-write
+ STATUS current
+ DESCRIPTION
+ "If the measured temperature of the sensor is higher than this
+ value, the fan speed of the connected fan tray is increased.
+ The value 127 has the special meaning: channel disabled."
+ ::= { sensorEntry 3}
+
+sensorFailureThreshold OBJECT-TYPE
+-- CHECK SYNTAX INTEGER { (0..126), DISABLED(127) }
+ SYNTAX Integer32 (0..127)
+ UNITS "deg C"
+ MAX-ACCESS read-write
+ STATUS current
+ DESCRIPTION
+ "If the measured temperature of the sensor is higher than this
+ value, the power supply switches off.
+ The value 127 has the special meaning: channel disabled."
+ ::= { sensorEntry 4}
+
+--################
+
+-------------------------------------------------------------------------------
+-- signal
+-------------------------------------------------------------------------------
+--Signal ::= SEQUENCE {
+-- numberOfAnalogInputs Integer32,
+-- analogInputTable AnalogInputTable
+-- numberOfAnalogOutputs Integer32,
+-- analogOutputTable AnalogOutputTable
+-- digitalInput BITS,
+-- digitalOutput BITS
+--}
+
+numberOfAnalogInputs OBJECT-TYPE
+ SYNTAX Integer32 (0..8)
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The number of additional analog inputs of the crate."
+ ::= { signal 1 }
+
+analogInputTable OBJECT-TYPE
+ SYNTAX SEQUENCE OF AnalogInputEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "A (conceptual table) of analog input data."
+ ::= { signal 2 }
+
+analogInputEntry OBJECT-TYPE
+ SYNTAX AnalogInputEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "An entry (conceptual row) of the analogInputTable."
+ INDEX { analogInputIndex }
+ ::= { analogInputTable 1 }
+
+AnalogInputEntry ::= SEQUENCE {
+ analogInputIndex INTEGER,
+ analogMeasurementVoltage Float
+ }
+
+analogInputIndex OBJECT-TYPE
+ SYNTAX Integer32 (1..8)
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "A unique number for each analog input of the crate"
+ ::= { analogInputEntry 1 }
+
+analogMeasurementVoltage OBJECT-TYPE
+ SYNTAX Float
+ UNITS "V"
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The measured voltage of the analog input."
+ ::= { analogInputEntry 2 }
+
+
+digitalInput OBJECT-TYPE
+ SYNTAX BITS {
+ d0 (0) ,
+ d1 (1) ,
+ d2 (2) ,
+ d3 (3)
+ }
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The value of the digital inputs."
+ ::= { signal 5 }
+
+
+
+
+-- ###################
+-------------------------------------------------------------------------------
+-- communication
+-------------------------------------------------------------------------------
+--Communication ::= SEQUENCE {
+-- snmp Snmp,
+-- tcpip Tcpip,
+-- http Http,
+-- telnet Telnet,
+-- canbus Canbus,
+-- rs232 RS232
+--}
+
+-------------------------------------------------------------------------------
+-- communication.snmp
+-------------------------------------------------------------------------------
+snmp OBJECT-IDENTITY
+ STATUS current
+ DESCRIPTION
+ "SNMP configuration."
+ ::= { communication 1 }
+
+--Snmp ::= SEQUENCE {
+-- snmpCommunityTable SnmpCommunityTable,
+-- snmpPort INTEGER
+--}
+
+snmpCommunityTable OBJECT-TYPE
+ SYNTAX SEQUENCE OF SnmpCommunityEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "The SNMP community string table for different views."
+ ::= { snmp 1 }
+
+snmpCommunityEntry OBJECT-TYPE
+ SYNTAX SnmpCommunityEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "One table row."
+ INDEX { snmpAccessRight }
+ ::= { snmpCommunityTable 1 }
+
+
+SnmpCommunityEntry ::= SEQUENCE {
+ snmpAccessRight INTEGER,
+ snmpCommunityName OCTET STRING
+}
+
+snmpAccessRight OBJECT-TYPE
+ SYNTAX INTEGER { public (1), private (2), admin (3), guru (4) }
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "A unique number for each access right"
+ ::= { snmpCommunityEntry 1 }
+
+snmpCommunityName OBJECT-TYPE
+ SYNTAX OCTET STRING (SIZE (0..14))
+ MAX-ACCESS read-write
+ STATUS current
+ DESCRIPTION
+ "The SNMP community names for different views. The rights of the different communities are:
+ public no write access
+ private can switch power on/off, generate system reset
+ admin can change supervision levels
+ guru can change output voltage & current (this may destroy hardware if done wrong!)
+ Setting a community name to a zero-length string completly
+ disables the access to this view. If there is no higher-
+ privileged community, the community name can only changed
+ by direct access to the crate (not via network)!
+ "
+ ::= { snmpCommunityEntry 2}
+
+snmpPort OBJECT-TYPE
+ SYNTAX Integer32
+ MAX-ACCESS read-write
+ STATUS current
+ DESCRIPTION
+ "The UDP port number of the SNMP protocol"
+ ::= { snmp 2}
+
+-------------------------------------------------------------------------------
+-- communication.canTunnel
+-------------------------------------------------------------------------------
+can OBJECT-IDENTITY
+ STATUS current
+ DESCRIPTION
+ "CAN-Bus tunnel via SNMP."
+ ::= { communication 2 }
+
+canBitRate OBJECT-TYPE
+ SYNTAX Integer32
+ MAX-ACCESS read-write
+ STATUS current
+ DESCRIPTION
+ "Control of the CAN-Bus.
+ The value defines the bit rate of the CAN-bus interface.
+ A write disconnects the CAN interface from the ISEG modules and connects
+ it to the SNMP communication. Both the receive and transmit fifos are
+ cleared and the CAN interface is initialized with the selected bit rate.
+ The special bit rate 0 disables the tunnel and switches back to normal operation.
+ "
+ ::= { can 1 }
+
+canReceive OBJECT-TYPE
+ SYNTAX OCTET STRING (SIZE (14))
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Control of the CAN-Bus Receive FIFO.
+ A read access returns the total number of CAN messages stored in the receive
+ fifo and the oldest message.
+ This message is removed from the fifo.
+ The OCTET STRING data is formatted according to the CANviaSNMP structure.
+ "
+ ::= { can 2 }
+
+canTransmit OBJECT-TYPE
+ SYNTAX OCTET STRING (SIZE (14))
+ MAX-ACCESS read-write
+ STATUS current
+ DESCRIPTION
+ "Control of the CAN-Bus Transmit FIFO.
+ A read access returns the total number of CAN messages stored in the transmit
+ fifo and a NULL message.
+ A write inserts the CAN message into the transmit fifo. This message will be
+ transmitted via the CAN interface later. The total number of CAN messages
+ stored in the transmit fifo and the recent message are returned.
+ The OCTET STRING data is formatted according to the CANviaSNMP structure.
+ "
+ ::= { can 3 }
+
+-------------------------------------------------------------------------------
+-- communication....
+-------------------------------------------------------------------------------
+
+-- other future entries:
+-- +-tcpip
+-- | |
+-- | +- tcpipIpAddress
+-- | +- tcpipGateway
+-- | +- tcpipSubnetMask
+-- | +- tcpipNegotiation
+-- | +- tcpipMAC
+-- |
+-- +-http
+-- | |
+-- | +- httpPort
+-- | +- httpWriteEnable
+-- |
+-- +-telnet
+-- | |
+-- | +- telnetPort
+-- |
+-- +-canbus
+-- | |
+-- | +- address
+-- | +- address2
+-- | +- speed
+-- |
+-- +-rs232
+-- | |
+-- | +- ?
+
+
+
+-------------------------------------------------------------------------------
+-- powersupply
+-------------------------------------------------------------------------------
+Powersupply ::= SEQUENCE {
+ --psFirmwareVersion DisplayString,
+ psSerialNumber DisplayString,
+ psOperatingTime Integer32,
+ psDirectAccess OCTET STRING
+}
+
+--integrated in system.sysDesc
+--psFirmwareVersion OBJECT-TYPE
+-- SYNTAX DisplayString
+-- MAX-ACCESS read-only
+-- STATUS current
+-- DESCRIPTION
+-- "The firmware version of the power supply main CPU."
+-- ::= { powersupply 1 }
+
+psSerialNumber OBJECT-TYPE
+ SYNTAX DisplayString
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The serial number of the power supply."
+ ::= { powersupply 2 }
+
+psOperatingTime OBJECT-TYPE
+ SYNTAX Integer32
+ UNITS "s"
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The time in seconds for how long the power supply was switched on."
+ ::= { powersupply 3 }
+
+psDirectAccess OBJECT-TYPE
+ SYNTAX OCTET STRING (SIZE (1..14))
+ MAX-ACCESS read-write
+ STATUS current
+ DESCRIPTION
+ "Direct data transfer to the UEP6000 power supply.
+ A read access returns nothing, a write access returns the
+ response of the power supply.
+ "
+ ::= { powersupply 1024 }
+
+-------------------------------------------------------------------------------
+-- fantray
+-------------------------------------------------------------------------------
+--Fantray ::= SEQUENCE {
+-- fanFirmwareVersion DisplayString,
+-- fanSerialNumber OCTET STRING,
+-- fanOperatingTime Integer32,
+-- fanAirTemperature INTEGER,
+-- fanSwitchOffDelay INTEGER,
+-- fanNominalSpeed INTEGER,
+-- fanNumberOfFans INTEGER,
+-- fanSpeedTable FanSpeedTable
+--}
+
+--integrated in system.sysDesc
+--fanFirmwareVersion OBJECT-TYPE
+-- SYNTAX DisplayString
+-- MAX-ACCESS read-only
+-- STATUS current
+-- DESCRIPTION
+-- "The firmware version of the fan tray CPU."
+-- ::= { fantray 1 }
+
+fanSerialNumber OBJECT-TYPE
+ SYNTAX DisplayString (SIZE (0..14))
+ MAX-ACCESS read-write
+ STATUS current
+ DESCRIPTION
+ "The serial number of the fan tray."
+ ::= { fantray 2 }
+
+fanOperatingTime OBJECT-TYPE
+ SYNTAX Integer32
+ UNITS "s"
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The time in seconds for how long the fan tray was switched on."
+ ::= { fantray 3 }
+
+fanAirTemperature OBJECT-TYPE
+ SYNTAX Integer32
+ UNITS "deg C"
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The temperature of the fan tray inlet air."
+ ::= { fantray 4 }
+
+fanSwitchOffDelay OBJECT-TYPE
+ SYNTAX Integer32 (0 .. 900)
+ UNITS "s"
+ MAX-ACCESS read-write
+ STATUS current
+ DESCRIPTION
+ "The maximum time in seconds for which the fans will continue running
+ after the power supply has been switched off. This feature is used
+ to cool down the electronics after switching off.
+ "
+ ::= { fantray 5 }
+
+fanNominalSpeed OBJECT-TYPE
+-- CHECK SYNTAX INTEGER { (0) , (1200..3600) }
+ SYNTAX Integer32 (0..3600)
+ UNITS "RPM"
+ MAX-ACCESS read-write
+ STATUS current
+ DESCRIPTION
+ "The nominal fan rotation speed (RPM, Revolutions Per Minute)
+ Value 0 does switch off the fans (only allowed if at least
+ one rack temperature sensor is present).
+ Values 1..1199 are not allowed"
+ ::= { fantray 6 }
+
+fanNumberOfFans OBJECT-TYPE
+ SYNTAX Integer32 ( 0..12 )
+ UNITS "Fans"
+ MAX-ACCESS read-write
+ STATUS current
+ DESCRIPTION
+ "The number of installed fans"
+ ::= { fantray 7 }
+
+
+fanSpeedTable OBJECT-TYPE
+ SYNTAX SEQUENCE OF FanSpeedEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "A list of fanSpeedEntries."
+ ::= { fantray 8 }
+
+fanSpeedEntry OBJECT-TYPE
+ SYNTAX FanSpeedEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "A table row"
+ INDEX { fanNumber }
+ ::= { fanSpeedTable 1 }
+
+FanSpeedEntry ::= SEQUENCE {
+ fanNumber
+ INTEGER,
+ fanSpeed
+ INTEGER
+}
+
+fanNumber OBJECT-TYPE
+ SYNTAX Integer32 ( 1..12 )
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "A unique number for each fan."
+ ::= { fanSpeedEntry 1 }
+
+fanSpeed OBJECT-TYPE
+ SYNTAX Integer32
+ UNITS "RPM"
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The measured fan rotation speed (RPM, Revolutions Per Minute)"
+ ::= { fanSpeedEntry 2 }
+
+
+
+
+
+-------------------------------------------------------------------------------
+-- rack
+-------------------------------------------------------------------------------
+-- this is reserved for futer items (BIN serial number, plug&play, ...)
+
+
+
+-------------------------------------------------------------------------------
+END
Index: sipmscan/trunk/src/mpod/instructions_mpod.txt
===================================================================
--- sipmscan/trunk/src/mpod/instructions_mpod.txt (nonexistent)
+++ sipmscan/trunk/src/mpod/instructions_mpod.txt (revision 146)
@@ -0,0 +1,6 @@
+mpod_voltage.sh has the following options:
+ --resetall Resets all outputs
+ -r [integer] Resets output selected with [integer]
+ -o [integer] Selects output [integer]
+ -v [float] Sets the voltage to [float]. Must be used in combination with -o
+ -s [0/1] Turns output on (1) or off (0). Must be used in combination with -o
Index: sipmscan/trunk/src/mpod/mpod_voltage.sh
===================================================================
--- sipmscan/trunk/src/mpod/mpod_voltage.sh (nonexistent)
+++ sipmscan/trunk/src/mpod/mpod_voltage.sh (revision 146)
@@ -0,0 +1,114 @@
+#!/bin/bash
+
+# Commands:
+# snmpset - sets the selected attribute of a single channel
+# snmpget - prints the selected atribute of a single channel
+# snmpwalk - prints the selected attribute of all channels
+#
+# Attributes:
+# outputVoltage - float(F), R/W
+# outputCurrent - float(F), R/W
+# outputMeasurementSenseVoltage - float(F), R
+# outputMeasurementCurrent - float(F), R
+# outputSwitch - integer(i), R/W
+# outputVoltageRiseRate - float(F), R/W
+# outputStatus - bits, R
+
+#ip=194.249.156.124
+#ip=f9mpod.ijs.si
+
+#if [$1 -lt 99]; then
+# if [$2 -lt 74]; then
+# echo "Setting bias to " $2
+# snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputVoltage.$1 F $2
+# else
+# echo "Bias voltage needs to be smaller than 74V."
+# fi
+#else if [$1 -gt 99]; then
+# if [$2 -lt 35]; then
+# echo "Setting bias to " $2
+# snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputVoltage.$1 F $2
+# else
+# echo "Bias voltage needs to be smaller than 35V."
+# fi
+#fi
+
+function reset_all
+{
+ snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.1 i 10
+ snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.2 i 10
+ snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.3 i 10
+ snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.4 i 10
+ snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.5 i 10
+ snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.6 i 10
+ snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.7 i 10
+ snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.8 i 10
+ snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.101 i 10
+ snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.102 i 10
+ snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.103 i 10
+ snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.104 i 10
+ snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.105 i 10
+ snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.106 i 10
+ snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.107 i 10
+ snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.108 i 10
+
+ exit 0
+}
+
+ip=f9mpod.ijs.si
+
+# save all arguments to array args
+args=("$@")
+
+argcnt=0
+outSel=-1
+outVolt=-1
+outSw=-1
+resetOut=-1
+getOut=-1
+
+# search the arguments for valid options
+for ARG in "${args[@]}"; do
+ if [ "$ARG" == "--resetall" ]; then
+ reset_all
+ elif [ "$ARG" == "-g" ]; then
+ getOut=1
+ elif [ "$ARG" == "-r" ]; then
+ resetOut=${args[$argcnt+1]}
+ elif [ "$ARG" == "-o" ]; then
+ outSel=${args[$argcnt+1]}
+ elif [ "$ARG" == "-v" ]; then
+ outVolt=${args[$argcnt+1]}
+ elif [ "$ARG" == "-s" ]; then
+ outSw=${args[$argcnt+1]}
+ fi
+ (( argcnt++ ))
+done
+
+if [ $resetOut != -1 ]; then
+ if [ $resetOut -ge 1 -a $resetOut -le 8 ] || [ $resetOut -ge 101 -a $resetOut -le 108 ]; then
+ snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.$resetOut i 10
+ else
+ echo "Please select output between 1 and 8 (channel 1) or 101 and 108 (output 2)."
+ fi
+else
+ if [ $outSel != -1 ]; then
+ # limit the channels to the correct value
+ if [ $outSel -ge 1 -a $outSel -le 8 ] || [ $outSel -ge 101 -a $outSel -le 108 ]; then
+ if [ $outVolt != -1 ]; then
+ snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputVoltage.$outSel F $outVolt
+ fi
+ if [ $outSw != -1 ]; then
+ snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.$outSel i $outSw
+ fi
+ if [ $getOut != -1 ]; then
+ snmpget -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputVoltage.$outSel
+ snmpget -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.$outSel
+ fi
+ else
+ echo "Please select output between 1 and 8 (channel 1) or 101 and 108 (output 2)."
+ fi
+ fi
+fi
+
+exit 0
/sipmscan/trunk/src/mpod/mpod_voltage.sh
Property changes:
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: sipmscan/trunk/src/mpod/test.sh
===================================================================
--- sipmscan/trunk/src/mpod/test.sh (nonexistent)
+++ sipmscan/trunk/src/mpod/test.sh (revision 146)
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+snmpsearch="--snmp-install="
+
+for var in $@
+do
+ case $var in
+ "$snmpsearch"*)
+ echo "Mached argument: $var"
+ snmpdir=${var#$snmpsearch}
+ echo "SNMP directory = $snmpdir";;
+ *) ;;
+# echo "Unmached argument: $var";;
+ esac
+done
+
+printenv PATH | grep "snmp"
+if [ $? == 0 ]; then
+ echo "Something found."
+else
+ echo "Nothing found."
+fi
+
+printenv ROOTSYS > /dev/null
+if [ $? == 0 ]; then
+ echo "Something found."
+else
+ echo "Nothing found."
+fi
+
+exit 0
/sipmscan/trunk/src/mpod/test.sh
Property changes:
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: sipmscan/trunk/src/new_tabs.cpp
===================================================================
--- sipmscan/trunk/src/new_tabs.cpp (nonexistent)
+++ sipmscan/trunk/src/new_tabs.cpp (revision 146)
@@ -0,0 +1,777 @@
+#include "../include/sipmscan.h"
+#include "../include/workstation.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+// Layout hints
+TGLayoutHints *f0centerX = new TGLayoutHints(kLHintsCenterX,2,2,2,2);
+TGLayoutHints *f0leftX = new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2);
+TGLayoutHints *f0leftXnoleft = new TGLayoutHints(kLHintsLeft | kLHintsTop,0,2,2,2);
+TGLayoutHints *f0leftXnopad = new TGLayoutHints(kLHintsLeft | kLHintsTop,0,0,0,0);
+TGLayoutHints *f0leftXpad = new TGLayoutHints(kLHintsLeft | kLHintsTop,12,12,2,2);
+TGLayoutHints *f0rightX = new TGLayoutHints(kLHintsRight | kLHintsTop,2,2,2,2);
+TGLayoutHints *f0rightXpad = new TGLayoutHints(kLHintsRight | kLHintsTop,12,12,2,2);
+TGLayoutHints *f0centerY = new TGLayoutHints(kLHintsCenterY,2,2,2,2);
+TGLayoutHints *f0center2d = new TGLayoutHints(kLHintsCenterX | kLHintsCenterY,2,2,2,2);
+TGLayoutHints *f1expandX = new TGLayoutHints(kLHintsExpandX,2,2,2,2);
+TGLayoutHints *f1expand2d = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,2,2,2,2);
+TGLayoutHints *f1expandXpad = new TGLayoutHints(kLHintsExpandX,12,12,2,2);
+
+// Edit file window ---------------------------------------------------
+
+// Open a new tab for editing datafile headers
+void TGAppMainFrame::HeaderEditTab(TGTab *mainTab, bool create, int *tabid)
+{
+ unsigned int nrfiles;
+ ULong_t rcolor, bcolor;
+ gClient->GetColorByName("red", rcolor);
+ gClient->GetColorByName("black", bcolor);
+
+ if(create)
+ {
+ TGCompositeFrame *fH1, *fV1;
+ TGHorizontalFrame *fTitle;
+ TGGroupFrame *fG1;
+ TGLabel *lab;
+
+ int startTab = mainTab->GetCurrent();
+ int newTab = mainTab->GetNumberOfTabs();
+ if(DBGSIG > 1) printf("HeaderEditTab(): Current tab = %d, Nr. of tabs = %d\n", startTab, newTab );
+
+ double numform[6];
+
+ int subgroup[2];
+ subgroup[0] = mainTab->GetWidth()-10;
+ subgroup[1] = mainTab->GetHeight()-10;
+
+ TGCompositeFrame *fT1;
+ fT1 = fTab->AddTab("File header editor");
+
+ // Title label
+ fTitle = new TGHorizontalFrame(fT1, 100, 25, kFixedHeight | kSunkenFrame);
+ TGTitleLabel(fT1, fTitle, "File header editor", (Pixel_t)FORECOLOR, (Pixel_t)BACKCOLOR, FONT);
+ fT1->AddFrame(fTitle, new TGLayoutHints(kLHintsExpandX | kLHintsTop));
+
+ // List view of files that we will edit
+ if(DBGSIG > 1) printf("HeaderEditTab(): Creating TGListBox *editList -> List box for editing files\n");
+ editList = new TGListBox(fT1,1);
+ editList->GetVScrollbar();
+ editList->Resize(300, (3*subgroup[1]/7)-10 );
+ fT1->AddFrame(editList, f1expandXpad);
+
+ editList->SetMultipleSelections((multiSelect->widgetChBox[0]->IsOn()));
+
+ // Copy the file list from the analysis tab for clearer view
+ nrfiles = fileList->GetNumberOfEntries();
+ printf("Nr. files = %d\n", nrfiles);
+ for(int i = 0; i < nrfiles; i++)
+ editList->AddEntry(fileList->GetEntry(i)->GetTitle(), i);
+
+ fH1 = new TGCompositeFrame(fT1, subgroup[0], subgroup[1], kHorizontalFrame);
+ fV1 = new TGCompositeFrame(fH1, subgroup[0]/2, subgroup[1], kVerticalFrame);
+ // Time stamp display
+ if(DBGSIG > 1) printf("HeaderEditTab(): Creating TSubStructure *timeEditDisplay -> Display text Entry (time stamp)\n");
+ timeEditDisplay = new TSubStructure();
+ if(timeEditDisplay->TGLabelTEntry(fV1, subgroup[0]/2-4, 30, "Time of measurement:", "", "oneline"))
+ fV1->AddFrame(timeEditDisplay->outsidebox, f0leftXpad);
+ timeEditDisplay->widgetTE->SetState(kFALSE);
+
+ // Bias voltage edit
+ if(DBGSIG > 1) printf("HeaderEditTab(): Creating TSubStructure *biasEdit -> Number entry for bias voltage edit\n");
+ biasEdit = new TSubStructure();
+ for(int i = 0; i < 6; i++) numform[i] = 0;
+ numform[0] = 7; numform[1] = 2;
+ if(biasEdit->TGCheckNEntry(fV1, subgroup[0]/2, 30, "Bias voltage edit:", 0, 0.00, numform, "left"))
+ fV1->AddFrame(biasEdit->outsidebox, f0leftXpad);
+
+ // Position edits
+ if(DBGSIG > 1) printf("HeaderEditTab(): Creating TSubStructure *xPosEdit, *yPosEdit, *zPosEdit -> Number entries for position edit\n");
+ xPosEdit = new TSubStructure();
+ for(int i = 0; i < 6; i++) numform[i] = 0;
+ numform[0] = 9; numform[3] = 2; numform[4] = -100; numform[5] = 215000;
+ if(xPosEdit->TGCheckNEntry(fV1, subgroup[0]/2, 30, "X position edit:", 0, 0, numform, "left"))
+ fV1->AddFrame(xPosEdit->outsidebox, f0leftXpad);
+
+ yPosEdit = new TSubStructure();
+ if(yPosEdit->TGCheckNEntry(fV1, subgroup[0]/2, 30, "Y position edit:", 0, 0, numform, "left"))
+ fV1->AddFrame(yPosEdit->outsidebox, f0leftXpad);
+
+ zPosEdit = new TSubStructure();
+ numform[5] = 375000;
+ if(zPosEdit->TGCheckNEntry(fV1, subgroup[0]/2, 30, "Z position edit:", 0, 0, numform, "left"))
+ fV1->AddFrame(zPosEdit->outsidebox, f0leftXpad);
+
+ // Temperature edit
+ if(DBGSIG > 1) printf("HeaderEditTab(): Creating TSubStructure *tempEdit -> Number entry for temperature edit\n");
+ tempEdit = new TSubStructure();
+ for(int i = 0; i < 6; i++) numform[i] = 0;
+ numform[0] = 6; numform[1] = 1;
+ if(tempEdit->TGCheckNEntry(fV1, subgroup[0]/2, 30, "Temperature edit:", 0, 0.0, numform, "left"))
+ fV1->AddFrame(tempEdit->outsidebox, f0leftXpad);
+
+ // Angle edit
+ if(DBGSIG > 1) printf("HeaderEditTab(): Creating TSubStructure *angleEdit -> Number entry for angle edit\n");
+ angleEdit = new TSubStructure();
+ for(int i = 0; i < 6; i++) numform[i] = 0;
+ numform[0] = 7; numform[1] = 2;
+ if(angleEdit->TGCheckNEntry(fV1, subgroup[0]/2, 30, "Incidence angle edit:", 0, 0.00, numform, "left"))
+ fV1->AddFrame(angleEdit->outsidebox, f0leftXpad);
+
+ // Laser settings edit
+ if(DBGSIG > 1) printf("HeaderEditTab(): Creating TSubStructure *laserEdit -> Display text Entry for laser edit\n");
+ laserEdit = new TSubStructure();
+ if(laserEdit->TGCheckTEntry(fV1, subgroup[0]/2, 30, "Laser settings edit:", 0, "", "oneline"))
+ fV1->AddFrame(laserEdit->outsidebox, f0leftXpad);
+
+ // Edit and close buttons
+ if(DBGSIG > 1) printf("HeaderEditTab(): Creating TSubStructure *editHead -> 2 buttons for either editing the head or closing the tab\n");
+ editHead = new TSubStructure();
+ const char *selnames[512] = {"Edit header","Close"};
+ if(editHead->TGMultiButton(fV1, subgroup[0]/2, 30, 2, selnames, "center"))
+ fV1->AddFrame(editHead->outsidebox, f0leftXpad);
+ fH1->AddFrame(fV1, f0leftXnopad);
+
+ fV1 = new TGCompositeFrame(fH1, subgroup[0]/2, subgroup[1], kVerticalFrame);
+ // Multiple file select
+ if(DBGSIG > 1) printf("HeaderEditTab(): Creating TSubStructure *editMulti -> 1 Check button to set multi select or not\n");
+ editMulti = new TSubStructure();
+ int *checksel;
+ checksel = new int;
+ *checksel = multiSelect->widgetChBox[0]->IsDown();
+ selnames[0] = "Select multiple files";
+ if(editMulti->TGCheckList(fV1, subgroup[0]/2, 30, 1, selnames, checksel, "vertical", "center"))
+ fV1->AddFrame(editMulti->outsidebox, f0centerX);
+
+ // Warning information
+ fG1 = new TGGroupFrame(fV1, "Warnings");
+ lab = new TGLabel(fG1, "Note: Tick checkbox in front of each header information you wish to change\n(to avoid any unwanted changes, they are unticked by default).");
+ fG1->AddFrame(lab, f0leftXpad);
+ lab = new TGLabel(fG1, "Note: When selecting files in the list, the entry fields will update accordingly\nwith information from the selected file (only for those where check\nboxes are not turned on).");
+ fG1->AddFrame(lab, f0leftXpad);
+ lab = new TGLabel(fG1, "Warning: Using button \"Edit header\" will edit headers in all files currently\nselected in the above selection list.");
+ lab->SetTextColor(rcolor);
+ fG1->AddFrame(lab, f0leftXpad);
+ if((editMulti->widgetChBox[0]->IsOn()))
+ {
+ selectWarn = new TGLabel(fG1, "Warning: Multiple files selected!");
+ selectWarn->SetTextColor(rcolor);
+ fG1->AddFrame(selectWarn, f0leftXpad);
+ }
+ else
+ {
+ selectWarn = new TGLabel(fG1, "Note: Single file selected. ");
+ selectWarn->SetTextColor(bcolor);
+ fG1->AddFrame(selectWarn, f0leftXpad);
+ }
+ fV1->AddFrame(fG1, f0centerX);
+ fH1->AddFrame(fV1, f0centerX);
+
+ // Actions for header editor
+ editList->Connect("Selected(Int_t)", "TGAppMainFrame", this, "ShowHeaderEdit(Int_t)");
+ biasEdit->widgetChBox[0]->Connect("Clicked()", "TGAppMainFrame", this, "EditTickToggle(=1)");
+ xPosEdit->widgetChBox[0]->Connect("Clicked()", "TGAppMainFrame", this, "EditTickToggle(=2)");
+ yPosEdit->widgetChBox[0]->Connect("Clicked()", "TGAppMainFrame", this, "EditTickToggle(=3)");
+ zPosEdit->widgetChBox[0]->Connect("Clicked()", "TGAppMainFrame", this, "EditTickToggle(=4)");
+ tempEdit->widgetChBox[0]->Connect("Clicked()", "TGAppMainFrame", this, "EditTickToggle(=5)");
+ angleEdit->widgetChBox[0]->Connect("Clicked()", "TGAppMainFrame", this, "EditTickToggle(=6)");
+ laserEdit->widgetChBox[0]->Connect("Clicked()", "TGAppMainFrame", this, "EditTickToggle(=7)");
+ editMulti->widgetChBox[0]->Connect("Clicked()", "TGAppMainFrame", this, "SetWarnings()");
+ editHead->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "StartHeaderEdit()");
+ char cTemp[512];
+ sprintf(cTemp, "CloseEditTab(=%d)", newTab*100+startTab);
+ editHead->widgetTB[1]->Connect("Clicked()", "TGAppMainFrame", this, cTemp);
+
+ fT1->AddFrame(fH1, f1expand2d);
+ fMain->MapSubwindows();
+ fMain->MapWindow();
+ fMain->Layout();
+
+ // Initialize the values
+ for(int i = 0; i < 8; i++)
+ EditTickToggle(i);
+
+ // Switch to new tab
+ fTab->SetTab(newTab);
+
+ if(DBGSIG > 1)
+ {
+ printf("HeaderEditTab(): New tab objects (Edit Header)\n");
+ gObjectTable->Print();
+ }
+ }
+ else
+ {
+ if(multiSelect->widgetChBox[0]->IsDown())
+ editMulti->widgetChBox[0]->SetState(kButtonDown);
+ else
+ editMulti->widgetChBox[0]->SetState(kButtonUp);
+
+ editList->SetMultipleSelections((editMulti->widgetChBox[0]->IsDown()));
+
+ // Recopy the file list from the analysis tab
+ nrfiles = fileList->GetNumberOfEntries();
+ printf("Nr. files = %d\n", nrfiles);
+ for(int i = 0; i < nrfiles; i++)
+ editList->AddEntry(fileList->GetEntry(i)->GetTitle(), i);
+
+ SetWarnings();
+
+ // Switch to new tab
+ fTab->SetTab(*tabid);
+ }
+}
+
+// Change the warning when selecting multiple files
+void TGAppMainFrame::SetWarnings()
+{
+ ULong_t rcolor, bcolor;
+ gClient->GetColorByName("red", rcolor);
+ gClient->GetColorByName("black", bcolor);
+
+ editList->SetMultipleSelections((editMulti->widgetChBox[0]->IsDown()));
+
+ // Set the warnings
+ if(editMulti->widgetChBox[0]->IsDown())
+ {
+ selectWarn->SetText("Warning: Multiple files selected!");
+ selectWarn->SetTextColor(rcolor);
+ selectWarn->SetWrapLength(-1);
+ }
+ else
+ {
+ selectWarn->SetText("Note: Single file selected. ");
+ selectWarn->SetTextColor(bcolor);
+ selectWarn->SetWrapLength(-1);
+ }
+}
+
+// Actions for editing the header
+void TGAppMainFrame::EditTickToggle(int type)
+{
+ // Toggle the edit possibility for header entries
+
+ // Bias voltage
+ if(type == 1)
+ {
+ if(biasEdit->widgetChBox[0]->IsDown()) biasEdit->widgetNE[0]->SetState(kTRUE);
+ else biasEdit->widgetNE[0]->SetState(kFALSE);
+ }
+ // X position
+ else if(type == 2)
+ {
+ if(xPosEdit->widgetChBox[0]->IsDown()) xPosEdit->widgetNE[0]->SetState(kTRUE);
+ else xPosEdit->widgetNE[0]->SetState(kFALSE);
+ }
+ // Y position
+ else if(type == 3)
+ {
+ if(yPosEdit->widgetChBox[0]->IsDown()) yPosEdit->widgetNE[0]->SetState(kTRUE);
+ else yPosEdit->widgetNE[0]->SetState(kFALSE);
+ }
+ // Z position
+ else if(type == 4)
+ {
+ if(zPosEdit->widgetChBox[0]->IsDown()) zPosEdit->widgetNE[0]->SetState(kTRUE);
+ else zPosEdit->widgetNE[0]->SetState(kFALSE);
+ }
+ // Temperature
+ else if(type == 5)
+ {
+ if(tempEdit->widgetChBox[0]->IsDown()) tempEdit->widgetNE[0]->SetState(kTRUE);
+ else tempEdit->widgetNE[0]->SetState(kFALSE);
+ }
+ // Angle
+ else if(type == 6)
+ {
+ if(angleEdit->widgetChBox[0]->IsDown()) angleEdit->widgetNE[0]->SetState(kTRUE);
+ else angleEdit->widgetNE[0]->SetState(kFALSE);
+ }
+ // Laser info
+ else if(type == 7)
+ {
+ if(laserEdit->widgetChBox[0]->IsDown()) laserEdit->widgetTE->SetState(kTRUE);
+ else laserEdit->widgetTE->SetState(kFALSE);
+ }
+}
+
+void TGAppMainFrame::StartHeaderEdit()
+{
+ unsigned int nrfiles = editList->GetNumberOfEntries();
+ TList *files;
+ // Changelist: Bias, X, Y, Z Positions, Temperature, Angle, Laser info
+ bool changelist[] = { biasEdit->widgetChBox[0]->IsDown(), xPosEdit->widgetChBox[0]->IsDown(), yPosEdit->widgetChBox[0]->IsDown(), zPosEdit->widgetChBox[0]->IsDown(), tempEdit->widgetChBox[0]->IsDown(), angleEdit->widgetChBox[0]->IsDown(), laserEdit->widgetChBox[0]->IsDown() };
+
+ if( nrfiles > 0 )
+ {
+ // check the selected file/files and return its name/their names
+ files = new TList();
+ editList->GetSelectedEntries(files);
+ if(files)
+ {
+ for(int i = 0; i < (int)nrfiles; i++)
+ {
+ if(files->At(i))
+ {
+ if(DBGSIG)
+ printf("StartHeaderEdit(): Filename: %s\n", files->At(i)->GetTitle());
+
+ HeaderChange( (char*)(files->At(i)->GetTitle()), changelist );
+ }
+ }
+ }
+ }
+}
+
+void TGAppMainFrame::ShowHeaderEdit(int id)
+{
+ char cTemp[512];
+
+ // Preparing input file
+ inroot = TFile::Open(editList->GetEntry(id)->GetTitle(), "READ");
+
+ // Header tree
+ TTree *header_data;
+ inroot->GetObject("header_data", header_data);
+
+ // Display branches from header in the entry fields
+ header_data->SetBranchAddress("timestamp", &evtheader.timestamp);
+ header_data->GetEntry(0);
+ header_data->SetBranchAddress("biasvolt", &evtheader.biasvolt);
+ header_data->GetEntry(0);
+ header_data->SetBranchAddress("xpos", &evtheader.xpos);
+ header_data->GetEntry(0);
+ header_data->SetBranchAddress("ypos", &evtheader.ypos);
+ header_data->GetEntry(0);
+ header_data->SetBranchAddress("zpos", &evtheader.zpos);
+ header_data->GetEntry(0);
+ header_data->SetBranchAddress("temperature", &evtheader.temperature);
+ header_data->GetEntry(0);
+ if( header_data->FindBranch("angle") )
+ {
+ header_data->SetBranchAddress("angle", &evtheader.angle);
+ header_data->GetEntry(0);
+ }
+ header_data->SetBranchAddress("laserinfo", &evtheader.laserinfo);
+ header_data->GetEntry(0);
+
+ GetTime(evtheader.timestamp, cTemp);
+
+ timeEditDisplay->widgetTE->SetText(cTemp);
+ if(!biasEdit->widgetChBox[0]->IsDown())
+ biasEdit->widgetNE[0]->SetNumber(evtheader.biasvolt);
+ if(!xPosEdit->widgetChBox[0]->IsDown())
+ xPosEdit->widgetNE[0]->SetNumber(evtheader.xpos);
+ if(!yPosEdit->widgetChBox[0]->IsDown())
+ yPosEdit->widgetNE[0]->SetNumber(evtheader.ypos);
+ if(!zPosEdit->widgetChBox[0]->IsDown())
+ zPosEdit->widgetNE[0]->SetNumber(evtheader.zpos);
+ if(!tempEdit->widgetChBox[0]->IsDown())
+ tempEdit->widgetNE[0]->SetNumber(evtheader.temperature);
+ if(!angleEdit->widgetChBox[0]->IsDown())
+ {
+ if( header_data->FindBranch("angle") )
+ tempEdit->widgetNE[0]->SetNumber(evtheader.angle);
+ else
+ tempEdit->widgetNE[0]->SetNumber(0.);
+ }
+ if(!laserEdit->widgetChBox[0]->IsDown())
+ laserEdit->widgetTE->SetText(evtheader.laserinfo);
+
+ delete header_data;
+ delete inroot;
+}
+
+void TGAppMainFrame::HeaderChange(char *histfile, bool *changetype)
+{
+ int scopeTemp;
+
+ if(DBGSIG)
+ printf("HeaderChange(): Selected file: %s\n", histfile);
+
+ // Preparing input file and the temporary output file
+ inroot = TFile::Open(histfile, "READ");
+
+ scopeTemp = inroot->GetListOfKeys()->Contains("scope_data");
+
+ char outname[256];
+ sprintf(outname, "%s/results/temp.root", rootdir);
+ outroot = TFile::Open(outname, "RECREATE");
+
+ // Tree structure of input file and output file
+ TTree *header_data, *meas_data, *scope_data;
+
+ printf("%d\n", inroot->GetListOfKeys()->Contains("header_data"));
+ printf("%d\n", inroot->GetListOfKeys()->Contains("meas_data"));
+ printf("%d\n", scopeTemp);
+
+ TTree *new_meas_data, *new_scope_data;
+ inroot->GetObject("header_data", header_data);
+ inroot->GetObject("meas_data", meas_data);
+ new_meas_data = meas_data->CloneTree();
+ //TTree *new_scope_data;
+ if(scopeTemp)
+ {
+ inroot->GetObject("scope_data", scope_data);
+ new_scope_data = scope_data->CloneTree();
+ }
+ else
+ printf("No scope_data header found.\n");
+
+ // Save branches from the old header to temporary variables
+ header_data->SetBranchAddress("nrch", &evtheader.nrch);
+ header_data->GetEntry(0);
+ header_data->SetBranchAddress("timestamp", &evtheader.timestamp);
+ header_data->GetEntry(0);
+ header_data->SetBranchAddress("biasvolt", &evtheader.biasvolt);
+ header_data->GetEntry(0);
+ header_data->SetBranchAddress("xpos", &evtheader.xpos);
+ header_data->GetEntry(0);
+ header_data->SetBranchAddress("ypos", &evtheader.ypos);
+ header_data->GetEntry(0);
+ header_data->SetBranchAddress("zpos", &evtheader.zpos);
+ header_data->GetEntry(0);
+ header_data->SetBranchAddress("temperature", &evtheader.temperature);
+ header_data->GetEntry(0);
+ if( header_data->FindBranch("angle") )
+ {
+ header_data->SetBranchAddress("angle", &evtheader.angle);
+ header_data->GetEntry(0);
+ }
+ header_data->SetBranchAddress("laserinfo", &evtheader.laserinfo);
+ header_data->GetEntry(0);
+
+ int itemp[5] = {0,0,0,0,0};
+ double dtemp[3] = {0.,0.,0.};
+ char ctemp[256];
+
+ itemp[0] = evtheader.nrch;
+ itemp[1] = evtheader.timestamp;
+ itemp[2] = evtheader.xpos;
+ itemp[3] = evtheader.ypos;
+ itemp[4] = evtheader.zpos;
+ dtemp[0] = evtheader.biasvolt;
+ dtemp[1] = evtheader.temperature;
+ if( header_data->FindBranch("angle") )
+ dtemp[2] = evtheader.angle;
+ else
+ dtemp[2] = 0.;
+ sprintf(ctemp, "%s", evtheader.laserinfo);
+
+ delete header_data;
+ delete meas_data;
+ if(scopeTemp)
+ delete scope_data;
+ delete inroot;
+
+printf("HeaderChange(): 6\n");
+ // Prepare branches for the new header
+ TTree *new_header_data = new TTree("header_data", "Header information for the measurement.");
+ new_header_data->Branch("nrch", &evtheader.nrch, "nrch/I");
+ new_header_data->Branch("timestamp", &evtheader.timestamp, "timestamp/I");
+ new_header_data->Branch("biasvolt", &evtheader.biasvolt, "biasvolt/D");
+ new_header_data->Branch("xpos", &evtheader.xpos, "xpos/I");
+ new_header_data->Branch("ypos", &evtheader.ypos, "ypos/I");
+ new_header_data->Branch("zpos", &evtheader.zpos, "zpos/I");
+ new_header_data->Branch("temperature", &evtheader.temperature, "temperature/D");
+ new_header_data->Branch("angle", &evtheader.angle, "temperature/D");
+ new_header_data->Branch("laserinfo", &evtheader.laserinfo, "laserinfo/C");
+
+printf("HeaderChange(): 7\n");
+ // Save new values (and old ones where we don't want to edit anything)
+ evtheader.nrch = itemp[0];
+ evtheader.timestamp = itemp[1];
+ // Bias voltage
+ if(changetype[0])
+ evtheader.biasvolt = (double)biasEdit->widgetNE[0]->GetNumber();
+ else
+ evtheader.biasvolt = dtemp[0];
+ // X pos
+ if(changetype[1])
+ evtheader.xpos = (int)xPosEdit->widgetNE[0]->GetNumber();
+ else
+ evtheader.xpos = itemp[2];
+ // Y pos
+ if(changetype[2])
+ evtheader.ypos = (int)yPosEdit->widgetNE[0]->GetNumber();
+ else
+ evtheader.ypos = itemp[3];
+ // Z pos
+ if(changetype[3])
+ evtheader.zpos = (int)zPosEdit->widgetNE[0]->GetNumber();
+ else
+ evtheader.zpos = itemp[4];
+ // Temperature
+ if(changetype[4])
+ evtheader.temperature = (double)tempEdit->widgetNE[0]->GetNumber();
+ else
+ evtheader.temperature = dtemp[1];
+ // Angle
+ if(changetype[5])
+ evtheader.angle = (double)angleEdit->widgetNE[0]->GetNumber();
+ else
+ evtheader.angle = dtemp[2];
+ // Laser info
+ if(changetype[6])
+ sprintf(evtheader.laserinfo, "%s", laserEdit->widgetTE->GetText());
+ else
+ sprintf(evtheader.laserinfo, "%s", ctemp);
+
+printf("HeaderChange(): 8\n");
+ new_header_data->Fill();
+
+ // Write down the temporary output file
+ new_header_data->Write();
+ new_meas_data->Write();
+ if(scopeTemp)
+ new_scope_data->Write();
+
+printf("HeaderChange(): 9\n");
+ delete new_header_data;
+ delete new_meas_data;
+ if(scopeTemp)
+ delete new_scope_data;
+ delete outroot;
+
+ // Replace the original file with temporary output file (and delete temporary file)
+ sprintf(outname, "cp -f %s/results/temp.root %s", rootdir, histfile);
+ system(outname);
+ sprintf(outname, "rm -f %s/results/temp.root", rootdir);
+ system(outname);
+
+ printf("Edited header in file: %s\n", histfile);
+}
+
+void TGAppMainFrame::CloseEditTab(int tabval)
+{
+ int curtab = (int)TMath::Floor(tabval/100.);
+ int oldtab = tabval - curtab*100;
+
+ if(DBGSIG > 1) printf("CloseEditTab(): New tab = %d, old tab = %d\n", curtab, oldtab);
+
+ fTab->RemoveTab(curtab);
+
+ delete editList;
+ delete timeEditDisplay;
+ delete biasEdit;
+ delete xPosEdit;
+ delete yPosEdit;
+ delete zPosEdit;
+ delete tempEdit;
+ delete angleEdit;
+ delete laserEdit;
+ delete editHead;
+ delete selectWarn;
+
+ for(int i = 0; i < fTab->GetNumberOfTabs(); i++)
+ if(DBGSIG > 1) printf("CloseEditTab(): Name of tab (%d) = %s\n", i, fTab->GetTabTab(i)->GetString() );
+
+ fTab->SetTab(oldtab);
+}
+
+// Edit file window ---------------------------------------------------
+
+// Temporary analysis window ------------------------------------------
+
+// Open a new tab for editing datafile headers
+void TGAppMainFrame::TempAnalysisTab(TGTab *mainTab, bool create, int *tabid, int analtype)
+{
+ if(create)
+ {
+ TGCompositeFrame *fH1, *fV1;
+ TGHorizontalFrame *fTitle;
+ TGGroupFrame *fG1;
+ TGLabel *lab;
+
+ int startTab = mainTab->GetCurrent();
+ int newTab = mainTab->GetNumberOfTabs();
+ if(DBGSIG > 1) printf("TempAnalysisTab(): Current tab = %d, Nr. of tabs = %d\n", startTab, newTab );
+
+ double numform[6];
+
+ int subgroup[2];
+ subgroup[0] = mainTab->GetWidth()-10;
+ subgroup[1] = mainTab->GetHeight()-10;
+
+ TGCompositeFrame *fT1;
+ fT1 = fTab->AddTab("Analysis edit");
+
+ // Title label
+ fTitle = new TGHorizontalFrame(fT1, 100, 25, kFixedHeight | kSunkenFrame);
+ TGTitleLabel(fT1, fTitle, "Analysis edit", (Pixel_t)FORECOLOR, (Pixel_t)BACKCOLOR, FONT);
+ fT1->AddFrame(fTitle, new TGLayoutHints(kLHintsExpandX | kLHintsTop));
+
+ fV1 = new TGCompositeFrame(fT1, subgroup[0], subgroup[1], kVerticalFrame);
+ // Temporary analysis canvas
+ if( (analTab->GetCurrent() == 3) || ((analTab->GetCurrent() == 0) && (intSpect->widgetChBox[0]->IsDown() || intSpect->widgetChBox[1]->IsDown())) )
+ {
+ tempAnalysisCanvas = new TRootEmbeddedCanvas("tempAnalysisCanvas",fV1,subgroup[1],5*subgroup[1]/6);
+ fV1->AddFrame(tempAnalysisCanvas, f0centerX);
+ }
+ else
+ {
+ tempAnalysisCanvas = new TRootEmbeddedCanvas("tempAnalysisCanvas",fV1,3*subgroup[0]/4,3*subgroup[1]/4);
+ fV1->AddFrame(tempAnalysisCanvas, f1expandXpad);
+ }
+ tempAnalysisCanvas->GetCanvas()->SetGrid();
+
+ // Specific options for plotting (analtype: 0 = Normal integration, 1 = Edge scans, 2 = Relative PDE,...)
+ // Normal integration
+ if(analtype == 0)
+ {
+ }
+ // Edge scans
+ else if(analtype == 1)
+ {
+ }
+ // Relative PDE
+ else if(analtype == 2)
+ {
+ // Running average offset
+ if(DBGSIG > 1) printf("TempAnalysisTab(): Creating TSubStructure *runningOff -> Set running average offset.\n");
+ runningOff = new TSubStructure();
+ for(int i = 0; i < 6; i++) numform[i] = 0;
+ numform[0] = 5; numform[2] = 2;
+ if(runningOff->TGLabelNEntry(fV1, subgroup[0]/2-24, 30, "Running average offset:", 0, numform, "center"))
+ fV1->AddFrame(runningOff->outsidebox, f1expandXpad);
+
+ // Running average setting for plot
+ if(DBGSIG > 1) printf("TempAnalysisTab(): Creating TSubStructure *runningAver -> Produce running average of a graph.\n");
+ runningAver = new TSubStructure();
+ for(int i = 0; i < 6; i++) numform[i] = 0;
+ numform[0] = 5; numform[2] = 2;
+ if(runningAver->TGLabelNEntry(fV1, subgroup[0]/2-24, 30, "Running average type (0 to disable):", 0, numform, "center"))
+ fV1->AddFrame(runningAver->outsidebox, f1expandXpad);
+
+ // Putting a second y-axis to the plot for mean number of photons histogram
+ if(DBGSIG > 1) printf("TempAnalysisTab(): Creating TSubStructure *secondAxis -> Create second y-axis for mean number of photons.\n");
+ secondAxis = new TSubStructure();
+ for(int i = 0; i < 6; i++) numform[i] = 0;
+ numform[0] = 5; numform[1] = 1; numform[2] = 2;
+ if(secondAxis->TGLabelNEntry(fV1, subgroup[0]/2-24, 30, "Scale second axis:", 0, numform, "center"))
+ fV1->AddFrame(secondAxis->outsidebox, f1expandXpad);
+
+ runningAver->widgetNE[0]->Connect("ValueSet(Long_t)", "TGAppMainFrame", this, "ApplyRunningAver()");
+ runningOff->widgetNE[0]->Connect("ValueSet(Long_t)", "TGAppMainFrame", this, "ApplyRunningAver()");
+ }
+
+ // Export and close buttons
+ if(DBGSIG > 1) printf("TempAnalysisTab(): Creating TSubStructure *exportExitAnalysis -> 2 buttons for either exporting the plot or closing the tab\n");
+ exportExitAnalysis = new TSubStructure();
+ const char *selnames[512] = {"Export","Close"};
+ if(exportExitAnalysis->TGMultiButton(fV1, subgroup[0]/2, 30, 2, selnames, "center"))
+ fV1->AddFrame(exportExitAnalysis->outsidebox, f1expandXpad);
+
+ // Actions for header editor
+ char cTemp[512];
+ sprintf(cTemp, "CloseTempAnalysisTab(=%d)", newTab*100+startTab);
+ exportExitAnalysis->widgetTB[1]->Connect("Clicked()", "TGAppMainFrame", this, cTemp);
+
+ fT1->AddFrame(fV1, f1expand2d);
+
+ fMain->MapSubwindows();
+ fMain->MapWindow();
+ fMain->Layout();
+
+ // Set tab ID
+ *tabid = newTab;
+
+ if(DBGSIG > 1)
+ {
+ printf("TempAnalysisTab(): New tab objects (Temporary Analysis Header)\n");
+ gObjectTable->Print();
+ }
+ }
+ else
+ {
+ // Switch to new tab
+ fTab->SetTab(*tabid);
+ }
+}
+
+void TGAppMainFrame::CloseTempAnalysisTab(int tabval)
+{
+ int curtab = (int)TMath::Floor(tabval/100.);
+ int oldtab = tabval - curtab*100;
+
+ if(DBGSIG > 1) printf("CloseTempAnalysisTab(): New tab = %d, old tab = %d\n", curtab, oldtab);
+
+ fTab->RemoveTab(curtab);
+
+ delete tempAnalysisCanvas;
+ delete exportExitAnalysis;
+
+ for(int i = 0; i < fTab->GetNumberOfTabs(); i++)
+ if(DBGSIG > 1) printf("CloseTempAnalysisTab(): Name of tab (%d) = %s\n", i, fTab->GetTabTab(i)->GetString() );
+
+ fTab->SetTab(oldtab);
+}
+
+void TGAppMainFrame::ApplyRunningAver()
+{
+ TCanvas *gCanvas = tempAnalysisCanvas->GetCanvas();
+ TList *funcList = (TList*)gCanvas->GetListOfPrimitives();
+ unsigned int nrfunc = funcList->GetSize();
+ TGraph *baseGr;
+ char funcname[512];
+ int runav = runningAver->widgetNE[0]->GetNumber();
+ int offx = runningOff->widgetNE[0]->GetNumber();
+
+ if(runav == 0) // If running average is disabled, don't update the plot
+ return;
+
+ for(int i = 0; i < nrfunc; i++)
+ {
+ sprintf(funcname, "%s", funcList->At(i)->GetName());
+ if(DBGSIG) printf("ApplyRunningAver(): Function is: %s\n", funcname);
+
+ if(strcmp(funcname,"runaver") == 0)
+ {
+ gCanvas->GetPrimitive(funcname)->Delete();
+ gCanvas->Modified();
+ gCanvas->Update();
+ }
+ else if(strcmp(funcname,"pde") == 0)
+ {
+ baseGr = (TGraph*)gCanvas->GetPrimitive(funcname);
+ int nrpoints = baseGr->GetN();
+ TGraph *runaver = new TGraph((int)(nrpoints-2*offx)/runav);
+ runaver->SetName("runaver");
+ runaver->SetFillColor(1);
+ runaver->SetLineColor(kBlack);
+ runaver->SetLineWidth(2);
+ runaver->SetMarkerColor(kBlack);
+ int nr = 0, j = 0;
+ double averx = 0, avery = 0;
+ double *xval, *yval;
+ xval = new double[runav];
+ yval = new double[runav];
+ while(1)
+ {
+ if((nr == (int)nrpoints/runav) || (runav*nr+j+offx > nrpoints-offx)) break;
+ baseGr->GetPoint(runav*nr+j+offx,xval[j],yval[j]);
+ if(DBGSIG) printf("ApplyRunningAver(): j = %d: X = %lf, Y = %lf\n", j, xval[j], yval[j]);
+ averx += xval[j];
+ avery += yval[j];
+ j++;
+ if((j == runav) && (runav*nr+j+offx <= nrpoints-offx))
+ {
+ runaver->SetPoint(nr,averx/runav,avery/runav);
+ if(DBGSIG) printf("ApplyRunningAver(): \t%d: averX = %lf, averY = %lf\n", nr, averx/runav, avery/runav);
+ nr++;
+ averx = 0;
+ avery = 0;
+ j = 0;
+ }
+ }
+ gCanvas->cd();
+ runaver->Draw("l same");
+ gCanvas->Modified();
+ gCanvas->Update();
+ delete[] xval;
+ delete[] yval;
+ }
+ }
+}
+
+// Temporary analysis window ------------------------------------------
Index: sipmscan/trunk/src/separate_functions.cpp
===================================================================
--- sipmscan/trunk/src/separate_functions.cpp (nonexistent)
+++ sipmscan/trunk/src/separate_functions.cpp (revision 146)
@@ -0,0 +1,212 @@
+#include "../include/sipmscan.h"
+#include "../include/workstation.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+// Separate functions -----------------------------------------
+void GetTime(int intime, char *outtime)
+{
+ time_t rawtime;
+ struct tm * timeinfo;
+ if(intime < 0)
+ time(&rawtime);
+ else
+ rawtime = (time_t)intime;
+ timeinfo = localtime(&rawtime);
+ sprintf(outtime, "%s", asctime(timeinfo));
+ int len = strlen(outtime);
+ if(len) outtime[len-1] = 0;
+}
+
+void remove_ext(char *inname, char *outname)
+{
+ char ctemp[256];
+ for(int i = 0; i < (int)strlen(inname); i++)
+ {
+ if( (inname[i] == '.') && (i > (int)(strlen(inname)-6)) )
+ {
+ ctemp[i] = '\0';
+ sprintf(outname, "%s", ctemp);
+ break;
+ }
+ else
+ ctemp[i] = inname[i];
+ }
+
+ if(DBGSIG)
+ printf("remove_ext(): Outfile = %s\n", outname);
+}
+
+void remove_from_last(char *inname, char search, char *outname)
+{
+ char ctemp[256];
+ int searchpos = -1;
+ for(int i = (int)strlen(inname); i >= 0; i--)
+ {
+ if(inname[i] == search)
+ {
+ searchpos = i;
+ break;
+ }
+ }
+
+ for(int i = 0; i < searchpos; i++)
+ ctemp[i] = inname[i];
+
+ ctemp[searchpos] = '\0';
+ sprintf(outname, "%s", ctemp);
+
+ if(DBGSIG)
+ printf("remove_from_last(): Outfile = %s\n", outname);
+}
+
+void remove_before_last(char *inname, char search, char *outname)
+{
+ char ctemp[256];
+ int searchpos = -1;
+ for(int i = (int)strlen(inname); i >= 0; i--)
+ {
+ if(inname[i] == search)
+ {
+ searchpos = i;
+ break;
+ }
+ }
+
+ int k = 0;
+ for(int i = searchpos+1; i < (int)strlen(inname); i++)
+ {
+ ctemp[k] = inname[i];
+ k++;
+ }
+
+ ctemp[k] = '\0';
+ sprintf(outname, "%s", ctemp);
+
+ if(DBGSIG)
+ printf("remove_before_last(): Outfile = %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);
+ }
+}
+
+void TimeEstimate(clock_t stopw0, time_t time0, float progress, char *retEstim, int offset)
+{
+ // Calculate the remaining time
+ clock_t clkt1;
+ char ctemp[512];
+
+ clkt1 = clock() - stopw0;
+ if(DBGSIG) printf("TimeEstimate(): Startclock = %d, Midclock (%f) = %f (%d), starttime = %d, curtime = %d\n", (int)stopw0, progress, (float)clkt1/CLOCKS_PER_SEC, (int)clkt1, (int)time0, (int)time(NULL));
+ GetTime((int)(100.*((float)clkt1/CLOCKS_PER_SEC)/progress+(int)time0+offset), ctemp);
+ sprintf(retEstim, "Estimated end time: %s", ctemp);
+}
+
+void NormateSet(int file, int nrpoint, double *min, double *max, double *setCount, double *setAcc)
+{
+ int count = 0;
+
+ // Find minimal value in set and subtract the offset
+ *min = TMath::MinElement(nrpoint, setAcc);
+ for(int i = 0; i < nrpoint; i++)
+ setAcc[i] -= *min;
+
+ // Find maximal value in set and normate to 1
+ *max = TMath::MaxElement(nrpoint, setAcc);
+ for(int i = 0; i < nrpoint; i++)
+ {
+ count = file - nrpoint + i;
+ setCount[count] = setAcc[i]/(*max);
+ if(DBGSIG) printf("NormateSet(): Integral check 2 (i=%d,za=%d,j=%d): %lf\t\%lf\n", count, i, nrpoint, setCount[count], setAcc[i]/(*max));
+ }
+}
+
+// Estimate the next point, depending on the set of points beforehand (least squares fit) and return the error
+double PointEstimate(int nrp, double *points)
+{
+ double accx = 0, accy = 0, accxy = 0, accx2 = 0;
+ double A, B;
+ double esty;
+
+ for(int i = 0; i < nrp; i++)
+ {
+ accx += points[2*i];
+ accy += points[2*i+1];
+ accxy += points[2*i]*points[2*i+1];
+ accx2 += points[2*i]*points[2*i];
+ }
+
+ A = (accx2*accy - accx*accxy)/(nrp*accx2 - accx*accx);
+ B = (nrp*accxy - accx*accy)/(nrp*accx2 - accx*accx);
+
+ esty = A + B*points[2*nrp];
+
+ if(DBGSIG) printf("PointEstimate(): A = %lf, B = %lf, estimate = %lf, real = %lf, error = %lf\n", A, B, esty, points[2*nrp+1], abs(esty - points[2*nrp+1])/points[2*nrp+1]);
+
+ return abs(esty - points[2*nrp+1])/points[2*nrp+1];
+}
+
+// Separate functions -----------------------------------------
Index: sipmscan/trunk/src/sipmscan.cpp
===================================================================
--- sipmscan/trunk/src/sipmscan.cpp (nonexistent)
+++ sipmscan/trunk/src/sipmscan.cpp (revision 146)
@@ -0,0 +1,1262 @@
+#include "../include/sipmscan.h"
+#include "../include/workstation.h"
+#include "../include/substructure.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+// Main window constructor (+layout) ---------------------------------
+
+TGAppMainFrame::TGAppMainFrame(const TGWindow *p, int w, int h)
+{
+ TGCompositeFrame *fT1;
+ idtotal = 0;
+
+ char *cTemp;
+
+ // CAMAC and Scope objects
+ gDaq = new daq();
+ gScopeDaq = new daqscope();
+
+ // Define main window and menubar
+ fMain = new TGMainFrame(p, w, h, kVerticalFrame);
+
+ // Initialize the menu
+ fMenuBar = new TGMenuBar(fMain, 200, 30);
+ InitMenu();
+ fMain->AddFrame(fMenuBar, new TGLayoutHints(kLHintsExpandX | kLHintsTop));
+
+ // Prepare the tabbed structure
+ fTab = new TGTab(fMain, 500, 500);
+
+ // Read the layout we wish to use
+ int frmWidth[measwin+analysiswin], frmHeight[measwin+analysiswin];
+ LayoutRead(measwin+analysiswin, frmWidth, frmHeight);
+
+ // Structure the measurement layout window
+ int *vert, *hor, *wPane, *hPane;
+
+ vert = new int[2]; hor = new int;
+ *hor = 1;
+ vert[0] = 1; vert[1] = 0;
+
+ const char *measFrmTit[] = {"Settings pane", "Display", "Main measurement window"};
+ wPane = new int[measwin]; hPane = new int[measwin];
+ for(int i = 0; i < measwin; i++)
+ {
+ wPane[i] = frmWidth[i];
+ hPane[i] = frmHeight[i];
+ }
+
+ fT1 = fTab->AddTab("Measurement");
+ TGSplitter(fT1, "horizontal", hor, vert, measFrmTit, measLayout, wPane, hPane);
+ fT1->AddFrame(fLayout[idtotal], new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
+ idtotal++;
+ delete[] vert; delete hor; delete[] wPane; delete[] hPane;
+
+ // Structure the analysis layout window
+ vert = new int[2]; hor = new int;
+ *hor = 1;
+ vert[0] = 1; vert[1] = 1;
+
+ const char *analysisFrmTit[] = {"Histogram file selection", "Analysis", "Histogram", "Histogram controls"};
+ wPane = new int[analysiswin]; hPane = new int[analysiswin];
+ for(int i = 0; i < analysiswin; i++)
+ {
+ wPane[i] = frmWidth[i+measwin];
+ hPane[i] = frmHeight[i+measwin];
+ }
+
+ fT1 = fTab->AddTab("Analysis");
+ TGSplitter(fT1, "horizontal", hor, vert, analysisFrmTit, analysisLayout, wPane, hPane);
+ fT1->AddFrame(fLayout[idtotal], new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
+ idtotal++;
+ delete[] vert; delete hor; delete[] wPane; delete[] hPane;
+
+ // Structure the monitoring layout window (Fieldpoint) //TODO
+ fT1 = fTab->AddTab("Monitoring");
+ fTab->SetEnabled(2,kFALSE); //TODO
+
+ // Structure the help layout window
+ fT1 = fTab->AddTab("Help");
+ TGTextView *helpdesc;
+ const TGFont *tfont = gClient->GetFont(HELPFONT);
+ FontStruct_t helpFont = tfont->GetFontStruct();
+ helpdesc = new TGTextView(fT1,100,100);
+ helpdesc->SetFont(helpFont);
+ helpdesc->SetForegroundColor(0x000000);
+ fT1->AddFrame(helpdesc, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
+
+ cTemp = new char[1024];
+ sprintf(cTemp, "%s/doc/README", rootdir);
+ if(helpdesc->LoadFile(cTemp))
+ {
+ if(DBGSIG) printf("TGAppMainFrame(): Help file correctly loaded.\n");
+ }
+ else
+ printf("Error! Help file not loaded.\n");
+ delete[] cTemp;
+ helpdesc->AddLine("");
+
+ fMain->AddFrame(fTab, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
+
+ // Set the inner layout of each frame
+ AppLayout();
+
+ fMain->SetWindowName(WINDOW_NAME);
+ fMain->MapSubwindows();
+ fMain->MapWindow();
+ fMain->Layout();
+
+ // Prepare initial settings
+ EnableScan(0); //.
+ EnableScan(1); // Grey out scan
+ EnableScan(2); // options by default
+ EnableScan(3); //.
+ EnableLiveUpdate(); //. Disable the live histogram update at beginning
+ VoltOut(1); //. Get the output voltage save in file
+ HistogramOptions(1); //. Enable clean plots by default
+ plotType->widgetTB[0]->SetDown(kTRUE); //.
+ fMenuHisttype->CheckEntry(M_ANALYSIS_HISTTYPE_1DADC); // Set the ADC histogram
+ fMenuHisttype->UnCheckEntry(M_ANALYSIS_HISTTYPE_1DTDC); // to show by default
+ fMenuHisttype->UnCheckEntry(M_ANALYSIS_HISTTYPE_2D); //.
+ acqStarted = false; //. At program start, the acquisition is stopped
+ ToolTipSet(); //. Turn on tooltips
+ PositionSet(1); //. Get starting table position
+ RotationSet(1); //. Get starting rotation
+
+ if(DBGSIG > 1)
+ {
+ printf("TGAppMainFrame(): At end of constructor\n");
+ gObjectTable->Print();
+ }
+}
+
+TGAppMainFrame::~TGAppMainFrame()
+{
+ fMain->Cleanup();
+ delete fMain;
+}
+
+// -------------------------------------------------------------------
+
+// Event handler for menubar actions ---------------------------------
+
+void TGAppMainFrame::HandleMenu(Int_t id)
+{
+// int ret = 0;
+ char cmd[256];
+
+ switch(id)
+ {
+ case M_FILE_SET_LAYOUT:
+ LayoutSet();
+ break;
+
+ case M_FILE_SAVE_LAYOUT:
+ LayoutSave();
+ break;
+
+ case M_FILE_SAVE_MSETTINGS:
+ // Here, we save the set values in the measurement layout (automatically done when we safely exit the application and after each start of measurement).
+ break;
+
+ case M_FILE_SAVE_ASETTINGS:
+ // Here, we save the set values in the analysis layout (automatically done when we safely exit the application and after each start of analysis).
+ break;
+
+ case M_FILE_CHECK_WIDTH:
+ printf("\nSettings window: %dx%d\n", measLayout[0]->GetWidth(), measLayout[0]->GetHeight());
+ printf("Histogram window: %dx%d\n", measLayout[1]->GetWidth(), measLayout[1]->GetHeight());
+ printf("Main measurement window: %dx%d\n", measLayout[2]->GetWidth(), measLayout[2]->GetHeight());
+ printf("Histogram file window: %dx%d\n", analysisLayout[0]->GetWidth(), analysisLayout[0]->GetHeight());
+ printf("Analysis window: %dx%d\n", analysisLayout[1]->GetWidth(), analysisLayout[1]->GetHeight());
+ printf("Histogram window: %dx%d\n", analysisLayout[2]->GetWidth(), analysisLayout[2]->GetHeight());
+ printf("Histogram controls window: %dx%d\n", analysisLayout[3]->GetWidth(), analysisLayout[3]->GetHeight());
+
+ printf("Main window: %dx%d\n", fMain->GetWidth(), fMain->GetHeight());
+ printf("Menu bar: %dx%d\n", fMenuBar->GetWidth(), fMenuBar->GetHeight());
+ printf("Tab window: %dx%d\n", fTab->GetWidth(), fTab->GetHeight());
+ break;
+
+ case M_FILE_EXIT:
+ CloseWindow();
+ break;
+
+ case M_ANALYSIS_HISTTYPE_1DADC:
+ ChangeHisttype(0);
+ break;
+
+ case M_ANALYSIS_HISTTYPE_1DTDC:
+ ChangeHisttype(1);
+ break;
+
+ case M_ANALYSIS_HISTTYPE_2D:
+ ChangeHisttype(2);
+ break;
+
+ case M_ANALYSIS_INTEG:
+ fTab->SetTab(1);
+ analTab->SetTab(0);
+ for(int i = 0; i < 3; i++)
+ {
+ if(intSpect->widgetChBox[i]->IsDown())
+ intSpect->widgetChBox[i]->SetState(kButtonUp);
+ }
+ break;
+
+ case M_ANALYSIS_INTEGX:
+ fTab->SetTab(1);
+ analTab->SetTab(0);
+ for(int i = 0; i < 3; i++)
+ {
+ if(i == 0)
+ intSpect->widgetChBox[i]->SetState(kButtonDown);
+ else
+ {
+ if(intSpect->widgetChBox[i]->IsDown())
+ intSpect->widgetChBox[i]->SetState(kButtonUp);
+ }
+ }
+ break;
+
+ case M_ANALYSIS_INTEGY:
+ fTab->SetTab(1);
+ analTab->SetTab(0);
+ for(int i = 0; i < 3; i++)
+ {
+ if(i == 1)
+ intSpect->widgetChBox[i]->SetState(kButtonDown);
+ else
+ {
+ if(intSpect->widgetChBox[i]->IsDown())
+ intSpect->widgetChBox[i]->SetState(kButtonUp);
+ }
+ }
+ break;
+
+ case M_ANALYSIS_PHOTMU:
+ fTab->SetTab(1);
+ analTab->SetTab(1);
+ for(int i = 0; i < 3; i++)
+ {
+ if(i == 2)
+ intSpect->widgetChBox[i]->SetState(kButtonDown);
+ else
+ {
+ if(intSpect->widgetChBox[i]->IsDown())
+ intSpect->widgetChBox[i]->SetState(kButtonUp);
+ }
+ }
+ break;
+
+ case M_ANALYSIS_BREAKDOWN:
+ fTab->SetTab(1);
+ analTab->SetTab(2);
+ break;
+
+ case M_ANALYSIS_SURFSCAN:
+ fTab->SetTab(1);
+ analTab->SetTab(3);
+ break;
+
+ case M_ANALYSIS_TIMING:
+ fTab->SetTab(1);
+ analTab->SetTab(4);
+ break;
+
+ case M_HELP_WEBHELP:
+ printf("TGAppMainFrame::HandleMenu(): Opening %s/doc/documentation.html in a web browser.\n", rootdir);
+ sprintf(cmd, "xdg-open %s/doc/documentation.html &", rootdir);
+ system(cmd);
+ break;
+
+ case M_HELP_ABOUT:
+ About();
+ break;
+
+ default:
+// fMainFrame->SetCurrent(id);
+ break;
+ }
+}
+
+// -------------------------------------------------------------------
+
+// Initialize the main window menu -----------------------------------
+
+void TGAppMainFrame::InitMenu()
+{
+ fMenuBarItemLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0);
+
+ // Popup menu in menubar for File controls
+ fMenuFile = new TGPopupMenu(gClient->GetRoot());
+ fMenuFile->AddEntry(new TGHotString("Set &user layout"), M_FILE_SET_LAYOUT);
+ fMenuFile->AddEntry(new TGHotString("Save &current layout"), M_FILE_SAVE_LAYOUT);
+ fMenuFile->AddSeparator();
+ fMenuFile->AddEntry(new TGHotString("Save current &measurement settings"), M_FILE_SAVE_MSETTINGS);
+ fMenuFile->AddEntry(new TGHotString("Save current &analysis settings"), M_FILE_SAVE_ASETTINGS);
+ fMenuFile->AddEntry(new TGHotString("&Check frame width (Testing)"), M_FILE_CHECK_WIDTH);
+ fMenuFile->AddSeparator();
+ fMenuFile->AddEntry(new TGHotString("E&xit"), M_FILE_EXIT);
+
+ // Popup menu in menubar for Analysis controls
+ fMenuHisttype = new TGPopupMenu(gClient->GetRoot()); // adds a cascade menu that will be incorporated into analysis controls
+ fMenuHisttype->AddEntry(new TGHotString("1D &ADC histogram"), M_ANALYSIS_HISTTYPE_1DADC);
+ fMenuHisttype->AddEntry(new TGHotString("1D &TDC histogram"), M_ANALYSIS_HISTTYPE_1DTDC);
+ fMenuHisttype->AddEntry(new TGHotString("&2D ADC vs. TDC histogram"), M_ANALYSIS_HISTTYPE_2D);
+
+ fMenuAnalysis = new TGPopupMenu(gClient->GetRoot()); // adds a new popup menu to the menubar
+ fMenuAnalysis->AddPopup(new TGHotString("&Histogram type"), fMenuHisttype);
+ fMenuAnalysis->AddEntry(new TGHotString("&Integrate spectrum"), M_ANALYSIS_INTEG);
+ fMenuAnalysis->AddEntry(new TGHotString("Integrate spectrum (&X direction)"), M_ANALYSIS_INTEGX);
+ fMenuAnalysis->AddEntry(new TGHotString("Integrate spectrum (&Y direction)"), M_ANALYSIS_INTEGY);
+ fMenuAnalysis->AddEntry(new TGHotString("&Relative PDE"), M_ANALYSIS_PHOTMU);
+ fMenuAnalysis->AddEntry(new TGHotString("&Breakdown voltage"), M_ANALYSIS_BREAKDOWN);
+ fMenuAnalysis->AddEntry(new TGHotString("Surface 2&D scan"), M_ANALYSIS_SURFSCAN);
+ fMenuAnalysis->AddEntry(new TGHotString("&Timing analysis"), M_ANALYSIS_TIMING);
+
+ // Popup menu in menubar for File controls
+ fMenuHelp = new TGPopupMenu(gClient->GetRoot());
+ fMenuHelp->AddEntry(new TGHotString("Open &help in web browser"), M_HELP_WEBHELP);
+ fMenuHelp->AddEntry(new TGHotString("&About"), M_HELP_ABOUT);
+
+ // Connect all menu items with actions
+ fMenuFile->Connect("Activated(Int_t)", "TGAppMainFrame", this, "HandleMenu(Int_t)");
+ fMenuAnalysis->Connect("Activated(Int_t)", "TGAppMainFrame", this, "HandleMenu(Int_t)");
+ fMenuHelp->Connect("Activated(Int_t)", "TGAppMainFrame", this, "HandleMenu(Int_t)");
+
+ // Draw the created popup menus on the menubar
+ fMenuBar->AddPopup(new TGHotString("&File"), fMenuFile, fMenuBarItemLayout);
+ fMenuBar->AddPopup(new TGHotString("&Analysis"),fMenuAnalysis,fMenuBarItemLayout);
+ fMenuBar->AddPopup(new TGHotString("&Help"), fMenuHelp, fMenuBarItemLayout);
+}
+
+// -------------------------------------------------------------------
+
+// Setting the application subwindow layout --------------------------
+
+void TGAppMainFrame::AppLayout()
+{
+ double numform[6], numform2[6];
+ int *checksel;
+ char selected[256];
+ int subgroup[2];
+ TGCompositeFrame *fH1, *fV1, *fH2, *fT1;
+ TGGroupFrame *fG1;
+
+ TGLayoutHints *f0centerX = new TGLayoutHints(kLHintsCenterX,2,2,2,2);
+ TGLayoutHints *f0leftX = new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2);
+ TGLayoutHints *f0leftXnoleft = new TGLayoutHints(kLHintsLeft | kLHintsTop,0,2,2,2);
+ TGLayoutHints *f0leftXpad = new TGLayoutHints(kLHintsLeft | kLHintsTop,12,12,2,2);
+ TGLayoutHints *f0rightX = new TGLayoutHints(kLHintsRight | kLHintsTop,2,2,2,2);
+ TGLayoutHints *f0rightXpad = new TGLayoutHints(kLHintsRight | kLHintsTop,12,12,2,2);
+ TGLayoutHints *f0centerY = new TGLayoutHints(kLHintsCenterY,2,2,2,2);
+ TGLayoutHints *f0center2d = new TGLayoutHints(kLHintsCenterX | kLHintsCenterY,2,2,2,2);
+ TGLayoutHints *f1expandX = new TGLayoutHints(kLHintsExpandX,2,2,2,2);
+ TGLayoutHints *f1expand2d = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,2,2,2,2);
+ TGLayoutHints *f1expandXpad = new TGLayoutHints(kLHintsExpandX,12,12,2,2);
+
+// Settings pane ---------------------------------------------------------------------------
+ subgroup[0] = (measLayout[0]->GetWidth())-4;
+
+ // Check buttons to toggle voltage, surface and Z axis scans
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *scansOn -> 4 check buttons (voltage, surface, Z axis, incidence angle scans)\n");
+ scansOn = new TSubStructure();
+ checksel = new int[4];
+ checksel[0] = 0; checksel[1] = 0; checksel[2] = 0; checksel[3] = 0;
+ const char *selnames[] = {"Voltage scan ON/OFF", "Surface scan ON/OFF", "Z-axis scan ON/OFF","Rotation scan ON/OFF","0","0","0","0","0","0","0","0","0","0","0","0"};
+ if(scansOn->TGCheckList(measLayout[0], subgroup[0], 30, 4, selnames, checksel, "vertical", "center"))
+ measLayout[0]->AddFrame(scansOn->outsidebox, f1expandXpad);
+ delete[] checksel;
+
+ // Hard limit for maximum voltage we can set
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *vHardlimit -> Number entry for voltage limit\n");
+ vHardlimit = new TSubStructure();
+ for(int i = 0; i < 6; i++) numform[i] = 0;
+ numform[0] = 6; numform[1] = 2;
+ if(vHardlimit->TGLabelNEntry(measLayout[0], subgroup[0], 30, "Voltage limit:", 70.00, numform, "center"))
+ measLayout[0]->AddFrame(vHardlimit->outsidebox, f1expandXpad);
+
+ // Number of used channels
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *NCH -> Number entry for number of channels to capture\n");
+ NCH = new TSubStructure();
+ for(int i = 0; i < 6; i++) numform[i] = 0;
+ numform[0] = 3; numform[2] = 2; numform[3] = 2; numform[4] = 1; numform[5] = 8;
+ if(NCH->TGLabelNEntry(measLayout[0], subgroup[0], 30, "Nr. of channels:", 1, numform, "center"))
+ measLayout[0]->AddFrame(NCH->outsidebox, f1expandXpad);
+
+ // Select the units to use for table positioning (micrometer, table position units)
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *posUnits -> Dropdown menu for selecting the units for table positioning\n");
+ posUnits = new TSubStructure();
+ selnames[0] = "table units"; selnames[1] = "micrometers";
+ sprintf(selected, "table units");
+ if(posUnits->TGLabelDrop(measLayout[0], 2*subgroup[0]/3, 30, "Position units:", 2, selnames, selected))
+ measLayout[0]->AddFrame(posUnits->outsidebox, f1expandXpad);
+
+ // Select the units to use for rotation platform (degrees, table rotation units)
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *rotUnits -> Dropdown menu for selecting the units for rotation\n");
+ rotUnits = new TSubStructure();
+ selnames[0] = "table units"; selnames[1] = "degrees";
+ sprintf(selected, "degrees");
+ if(rotUnits->TGLabelDrop(measLayout[0], 2*subgroup[0]/3, 30, "Rotation units:", 2, selnames, selected))
+ measLayout[0]->AddFrame(rotUnits->outsidebox, f1expandXpad);
+
+ // Button and textbox to enter the oscilloscope IP address
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *oscConnect -> Text Entry (oscilloscope IP address)\n");
+ oscConnect = new TSubStructure();
+ if(oscConnect->TGLabelTEntryButton(measLayout[0], subgroup[0], 30, "Scope IP:", "178.172.43.157", "Connect", "twoline"))
+ measLayout[0]->AddFrame(oscConnect->outsidebox, f1expandXpad);
+
+ // Laser settings (freq., tune, ND filter)
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *laserInfo -> Text Entry (Laser setting information)\n");
+ laserInfo = new TSubStructure();
+ if(laserInfo->TGLabelTEntry(measLayout[0], subgroup[0], 30, "Laser settings:", "kHz, tune, ND", "twoline"))
+ measLayout[0]->AddFrame(laserInfo->outsidebox, f1expandXpad);
+
+ // Chamber temperature (will only be manually set until we can get it directly from the chamber)
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *chtemp -> Number entry for chamber temperature\n");
+ chtemp = new TSubStructure();
+ for(int i = 0; i < 6; i++) numform[i] = 0;
+ numform[0] = 5; numform[1] = 1; numform[3] = 2; numform[4] = -70.; numform[5] = 140.;
+ if(chtemp->TGLabelNEntry(measLayout[0], subgroup[0], 30, "Chamber temp.:", 25.0, numform, "center"))
+ measLayout[0]->AddFrame(chtemp->outsidebox, f1expandXpad);
+
+ // Check button to toggle live update of histogram (in display canvas)
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *liveDisp -> 1 check button (live histogram update)\n");
+ liveDisp = new TSubStructure();
+ checksel = new int;
+ *checksel = 0;
+ selnames[0] = "Live histogram ON/OFF";
+ if(liveDisp->TGCheckList(measLayout[0], subgroup[0], 30, 1, selnames, checksel, "vertical", "center"))
+ measLayout[0]->AddFrame(liveDisp->outsidebox, f1expandXpad);
+ delete checksel;
+
+ // Actions for Settings pane //TODO
+ scansOn->widgetChBox[0]->Connect("Clicked()", "TGAppMainFrame", this, "EnableScan(=0)");
+ scansOn->widgetChBox[1]->Connect("Clicked()", "TGAppMainFrame", this, "EnableScan(=1)");
+ scansOn->widgetChBox[2]->Connect("Clicked()", "TGAppMainFrame", this, "EnableScan(=2)");
+ scansOn->widgetChBox[3]->Connect("Clicked()", "TGAppMainFrame", this, "EnableScan(=3)");
+ vHardlimit->widgetNE[0]->Connect("ValueSet(Long_t)", "TGAppMainFrame", this, "VoltageLimit()");
+ (vHardlimit->widgetNE[0]->GetNumberEntry())->Connect("ReturnPressed()", "TGAppMainFrame", this, "VoltageLimit()");
+ posUnits->widgetCB->Connect("Selected(Int_t)", "TGAppMainFrame", this, "ChangeUnits(Int_t)");
+ rotUnits->widgetCB->Connect("Selected(Int_t)", "TGAppMainFrame", this, "ChangeUnitsRot(Int_t)");
+ liveDisp->widgetChBox[0]->Connect("Clicked()", "TGAppMainFrame", this, "EnableLiveUpdate()");
+// Settings pane ---------------------------------------------------------------------------
+
+// Main window -----------------------------------------------------------------------------
+ TGTab *setTab;
+
+ // Voltage, position and incidence angle tab
+ subgroup[0] = 2*(measLayout[2]->GetWidth())/7-14;
+ subgroup[1] = (measLayout[2]->GetHeight())/2-4;
+ setTab = new TGTab(measLayout[2], subgroup[0], subgroup[1]);
+
+ fT1 = setTab->AddTab("Voltage, position and incidence angle");
+ fH1 = new TGCompositeFrame(fT1, measLayout[2]->GetWidth(), subgroup[1], kFixedHeight | kHorizontalFrame);
+
+ // Left pane (Bias voltage controls)
+ fV1 = new TGCompositeFrame(fH1, subgroup[0], subgroup[1], kFixedWidth | kFixedHeight | kVerticalFrame);
+ fG1 = new TGGroupFrame(fV1, "Bias voltage controls");
+
+ // Output voltage supply channel
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *vOutCh -> Dropdown menu for bias voltage channel\n");
+ vOutCh = new TSubStructure();
+ selnames[0] = "U0"; selnames[1] = "U1"; selnames[2] = "U2"; selnames[3] = "U3"; selnames[4] = "U4"; selnames[5] = "U5"; selnames[6] = "U6"; selnames[7] = "U7"; selnames[8] = "U100"; selnames[9] = "U101"; selnames[10] = "U102"; selnames[11] = "U103"; selnames[12] = "U104"; selnames[13] = "U105"; selnames[14] = "U106"; selnames[15] = "U107";
+ sprintf(selected, "U0");
+ if(vOutCh->TGLabelDrop(fG1, 2*subgroup[0]/3, 30, "Output channel:", 16, selnames, selected))
+ fG1->AddFrame(vOutCh->outsidebox, f1expandXpad);
+
+ // Output voltage setting
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *vOutOpt -> 2 check buttons (negative polarity, ON/OFF toggle switch)\n");
+ vOutOpt = new TSubStructure();
+ checksel = new int[2];
+ checksel[0] = 0; checksel[1] = 0;
+ selnames[1] = "Output ON/OFF"; selnames[0] = "Negative polarity";
+ if(vOutOpt->TGCheckList(fG1, 3*subgroup[0]/4, 30, 2, selnames, checksel, "vertical", "center"))
+ fG1->AddFrame(vOutOpt->outsidebox, f1expandXpad);
+ delete[] checksel;
+
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *vOut -> Number entry for bias voltage\n");
+ vOut = new TSubStructure();
+ for(int i = 0; i < 6; i++) numform[i] = 0;
+ numform[0] = 7; numform[1] = 2; numform[3] = 2; numform[4] = 0.; numform[5] = vHardlimit->widgetNE[0]->GetNumber();
+ if(vOut->TGLabelNEntry(fG1, 3*subgroup[0]/4, 30, "Output voltage:", 0.00, numform, "center"))
+ fG1->AddFrame(vOut->outsidebox, f1expandXpad);
+
+ // Set, get and reset voltage buttons
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *vOutButtons -> 3 buttons (set bias voltage, read current bias voltage, reset voltage output when it gets interlocked)\n");
+ vOutButtons = new TSubStructure();
+ selnames[0] = "Set"; selnames[1] = "Get"; selnames[2] = "Reset";
+ if(vOutButtons->TGMultiButton(fG1, 3*subgroup[0]/4, 30, 3, selnames, "center"))
+ fG1->AddFrame(vOutButtons->outsidebox, f1expandXpad);
+
+ // Voltage scan controls
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *vOutStart -> Number entry for starting bias voltage\n");
+ vOutStart = new TSubStructure();
+ for(int i = 0; i < 6; i++) numform[i] = 0;
+ numform[0] = 7; numform[1] = 2;
+ if(vOutStart->TGLabelNEntry(fG1, 3*subgroup[0]/4, 30, "V (min):", 0.00, numform, "center"))
+ fG1->AddFrame(vOutStart->outsidebox, f1expandXpad);
+
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *vOutStop -> Number entry for starting bias voltage\n");
+ vOutStop = new TSubStructure();
+ for(int i = 0; i < 6; i++) numform[i] = 0;
+ numform[0] = 7; numform[1] = 2;
+ if(vOutStop->TGLabelNEntry(fG1, 3*subgroup[0]/4, 30, "V (max):", 0.00, numform, "center"))
+ fG1->AddFrame(vOutStop->outsidebox, f1expandXpad);
+
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *vOutStep -> Number entry for starting bias voltage\n");
+ vOutStep = new TSubStructure();
+ for(int i = 0; i < 6; i++) numform[i] = 0;
+ numform[0] = 7; numform[1] = 2;
+ if(vOutStep->TGLabelNEntry(fG1, 3*subgroup[0]/4, 30, "V (step):", 0.00, numform, "center"))
+ fG1->AddFrame(vOutStep->outsidebox, f1expandXpad);
+
+ fV1->AddFrame(fG1, f1expand2d);
+ // Left pane (Bias voltage controls)
+ fH1->AddFrame(fV1, f0leftX);
+
+ // Center pane (Table position controls)
+ subgroup[0] = 3*(measLayout[2]->GetWidth())/7-13;
+ fV1 = new TGCompositeFrame(fH1, subgroup[0], subgroup[1], kFixedWidth | kFixedHeight | kVerticalFrame);
+ fG1 = new TGGroupFrame(fV1, "Table position controls");
+
+ // X, Y and Z positions
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *xPos, *yPos, *zPos, *zPosMin, *zPosMax, *zPosStep -> Settings for position and Z axis scan\n");
+ fH2 = new TGCompositeFrame(fG1, 3*subgroup[0]/4, 30, kFixedWidth | kHorizontalFrame);
+ xPos = new TSubStructure();
+ for(int i = 0; i < 6; i++) numform[i] = 0;
+ numform[0] = 9; numform[3] = 2; numform[4] = -100; numform[5] = 215000;
+ if(xPos->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "X:", 0, numform, "center"))
+ fH2->AddFrame(xPos->outsidebox, f0centerX);
+
+ zPosMin = new TSubStructure();
+ numform[5] = 375000;
+ if(zPosMin->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "Z (min):", 0, numform, "center"))
+ fH2->AddFrame(zPosMin->outsidebox, f0centerX);
+ fG1->AddFrame(fH2, f1expandXpad);
+
+ fH2 = new TGCompositeFrame(fG1, 3*subgroup[0]/4, 30, kFixedWidth | kHorizontalFrame);
+ yPos = new TSubStructure();
+ numform[5] = 215000;
+ if(yPos->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "Y:", 0, numform, "center"))
+ fH2->AddFrame(yPos->outsidebox, f0centerX);
+
+ zPosMax = new TSubStructure();
+ numform[5] = 375000;
+ if(zPosMax->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "Z (max):", 0, numform, "center"))
+ fH2->AddFrame(zPosMax->outsidebox, f0centerX);
+ fG1->AddFrame(fH2, f1expandXpad);
+
+ fH2 = new TGCompositeFrame(fG1, 3*subgroup[0]/4, 30, kFixedWidth | kHorizontalFrame);
+ zPos = new TSubStructure();
+ numform[5] = 375000;
+ if(zPos->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "Z:", 0, numform, "center"))
+ fH2->AddFrame(zPos->outsidebox, f0centerX);
+
+ zPosStep = new TSubStructure();
+ for(int i = 0; i < 6; i++) numform[i] = 0;
+ numform[0] = 9;
+ if(zPosStep->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "Z (step):", 0, numform, "center"))
+ fH2->AddFrame(zPosStep->outsidebox, f0centerX);
+ fG1->AddFrame(fH2, f1expandXpad);
+
+ // Set, get, home and reset position buttons
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *posButtons -> 4 buttons (set position, read current position, home the motor and reset all three controllers)\n");
+ posButtons = new TSubStructure();
+ selnames[0] = "Set"; selnames[1] = "Get"; selnames[2] = "Home"; selnames[3] = "Reset";
+ if(posButtons->TGMultiButton(fG1, 3*subgroup[0]/4, 30, 4, selnames, "center"))
+ fG1->AddFrame(posButtons->outsidebox, f1expandXpad);
+
+ // Position scan controls
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *xPosMin, *xPosMax, *xPosStep, *yPosMin, *yPosMax, *yPosStep -> Settings for X and Y axis scans\n");
+ fH2 = new TGCompositeFrame(fG1, 3*subgroup[0]/4, 30, kFixedWidth | kHorizontalFrame);
+ xPosMin = new TSubStructure();
+ for(int i = 0; i < 6; i++) numform[i] = 0;
+ numform[0] = 9; numform[3] = 2; numform[4] = -100; numform[5] = 215000;
+ if(xPosMin->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "X (min):", 0, numform, "center"))
+ fH2->AddFrame(xPosMin->outsidebox, f0centerX);
+
+ yPosMin = new TSubStructure();
+ if(yPosMin->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "Y (min):", 0, numform, "center"))
+ fH2->AddFrame(yPosMin->outsidebox, f0centerX);
+ fG1->AddFrame(fH2, f1expandXpad);
+
+ fH2 = new TGCompositeFrame(fG1, 3*subgroup[0]/4, 30, kFixedWidth | kHorizontalFrame);
+ xPosMax = new TSubStructure();
+ if(xPosMax->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "X (max):", 0, numform, "center"))
+ fH2->AddFrame(xPosMax->outsidebox, f0centerX);
+
+ yPosMax = new TSubStructure();
+ if(yPosMax->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "Y (max):", 0, numform, "center"))
+ fH2->AddFrame(yPosMax->outsidebox, f0centerX);
+ fG1->AddFrame(fH2, f1expandXpad);
+
+ fH2 = new TGCompositeFrame(fG1, 3*subgroup[0]/4, 30, kFixedWidth | kHorizontalFrame);
+ xPosStep = new TSubStructure();
+ for(int i = 0; i < 6; i++) numform[i] = 0;
+ numform[0] = 9;
+ if(xPosStep->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "X (step):", 0, numform, "center"))
+ fH2->AddFrame(xPosStep->outsidebox, f0centerX);
+
+ yPosStep = new TSubStructure();
+ if(yPosStep->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "Y (step):", 0, numform, "center"))
+ fH2->AddFrame(yPosStep->outsidebox, f0centerX);
+ fG1->AddFrame(fH2, f1expandXpad);
+
+ fV1->AddFrame(fG1, f1expand2d);
+ // Center pane (Table position controls)
+ fH1->AddFrame(fV1, f0leftX);
+
+ // Right pane (Incidence angle controls)
+ subgroup[0] = 2*(measLayout[2]->GetWidth())/7-14;
+ fV1 = new TGCompositeFrame(fH1, subgroup[0], subgroup[1], kFixedWidth | kFixedHeight | kVerticalFrame);
+ fG1 = new TGGroupFrame(fV1, "Incidence angle controls");
+
+ // Rotation positions
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *rotPos -> Setting for rotation position\n");
+ rotPos = new TSubStructure();
+ for(int i = 0; i < 6; i++) numform[i] = 0;
+ numform[0] = 7; numform[1] = 2; numform[3] = 2; numform[4] = -180.; numform[5] = 180.;
+ if(rotPos->TGLabelNEntry(fG1, 3*subgroup[0]/4, 30, "Incidence angle:", 0., numform, "center"))
+ fG1->AddFrame(rotPos->outsidebox, f1expandXpad);
+
+ // Set, get, home and reset rotation buttons
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *rotButtons -> 4 buttons (set rotation, read current rotation, home the motor and reset controller)\n");
+ rotButtons = new TSubStructure();
+ selnames[0] = "Set"; selnames[1] = "Get"; selnames[2] = "Home"; selnames[3] = "Reset";
+ if(rotButtons->TGMultiButton(fG1, 3*subgroup[0]/4, 30, 4, selnames, "center"))
+ fG1->AddFrame(rotButtons->outsidebox, f1expandXpad);
+
+ // Rotation scan controls
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *rotPosMin -> Number entry for starting angle\n");
+ rotPosMin = new TSubStructure();
+ if(rotPosMin->TGLabelNEntry(fG1, 3*subgroup[0]/4, 30, "Angle (min):", 0.0, numform, "center"))
+ fG1->AddFrame(rotPosMin->outsidebox, f1expandXpad);
+
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *rotPosMax -> Number entry for finishing angle\n");
+ rotPosMax = new TSubStructure();
+ if(rotPosMax->TGLabelNEntry(fG1, 3*subgroup[0]/4, 30, "Angle (max):", 0.0, numform, "center"))
+ fG1->AddFrame(rotPosMax->outsidebox, f1expandXpad);
+
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *rotPosStep -> Number entry for angle step\n");
+ rotPosStep = new TSubStructure();
+ for(int i = 0; i < 6; i++) numform[i] = 0;
+ numform[0] = 7; numform[1] = 1;
+ if(rotPosStep->TGLabelNEntry(fG1, 3*subgroup[0]/4, 30, "Angle (step):", 0.0, numform, "center"))
+ fG1->AddFrame(rotPosStep->outsidebox, f1expandXpad);
+
+ fV1->AddFrame(fG1, f1expand2d);
+ // Right pane (Incidence angle controls)
+ fH1->AddFrame(fV1, f0leftX);
+
+ fT1->AddFrame(fH1, f1expand2d);
+
+ // Waveform tab
+ //TODO
+ measLayout[2]->AddFrame(setTab, f0leftX);
+
+ // Bottom pane (File controls)
+ subgroup[0] = measLayout[2]->GetWidth()-19;
+ subgroup[1] = (measLayout[2]->GetHeight())/4-4;
+ fH1 = new TGCompositeFrame(measLayout[2], subgroup[0], subgroup[1], kFixedWidth | kFixedHeight | kHorizontalFrame);
+ fG1 = new TGGroupFrame(fH1, "Event/Data file controls");
+
+ // Number of events
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *evtNum -> Number entry for set number of events to acquire\n");
+ evtNum = new TSubStructure();
+ for(int i = 0; i < 6; i++) numform[i] = 0;
+ numform[0] = 8; numform[2] = 1;
+ if(evtNum->TGLabelNEntry(fG1, 3*subgroup[0]/4, 30, "Number of events:", 10000, numform, "left"))
+ fG1->AddFrame(evtNum->outsidebox, f0leftXpad);
+
+ // Time stamp display
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *timeStamp -> Text entry for timestamp\n");
+ timeStamp = new TSubStructure();
+ if(timeStamp->TGLabelTEntry(fG1, 3*subgroup[0]/4, 30, "Time stamp:", "", "oneline"))
+ {
+ timeStamp->widgetTE->SetState(kFALSE);
+ fG1->AddFrame(timeStamp->outsidebox, f1expandXpad);
+ }
+
+ // Save to file
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *fileName -> Text entry for timestamp\n");
+ fileName = new TSubStructure();
+ char *cTemp;
+ cTemp = new char[256];
+ sprintf(cTemp, "%s/results/test%s", rootdir, histext);
+ if(fileName->TGLabelTEntryButton(fG1, 3*subgroup[0]/4, 30, "Save to file:", cTemp, "...", "oneline"))
+ {
+ fileName->widgetTE->SetState(kFALSE);
+ fG1->AddFrame(fileName->outsidebox, f1expandXpad);
+ }
+
+ fH1->AddFrame(fG1, new TGLayoutHints(kLHintsExpandX,8,2,2,2));
+ // Bottom pane (File controls)
+ measLayout[2]->AddFrame(fH1, f0leftX);
+
+ // Start acquisition and progress bar
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *measProgress -> Button to start acquiring data and horizontal progress bar\n");
+ measProgress = new TSubStructure();
+ if(measProgress->TGButtonProgressTEntry(measLayout[2], 3*subgroup[0]/4, 30, "Start acquisition", "Estimated end time: "))
+ {
+ measProgress->widgetTE->SetState(kFALSE);
+ measLayout[2]->AddFrame(measProgress->outsidebox, f1expandXpad);
+ }
+
+ // Actions for Main window //TODO
+ vOutOpt->widgetChBox[0]->Connect("Clicked()", "TGAppMainFrame", this, "NegativePolarity()");
+ vOutButtons->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "VoltOut(=0)");
+ vOutButtons->widgetTB[1]->Connect("Clicked()", "TGAppMainFrame", this, "VoltOut(=1)");
+ vOutButtons->widgetTB[2]->Connect("Clicked()", "TGAppMainFrame", this, "VoltOut(=2)");
+ posButtons->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "PositionSet(=0)");
+ posButtons->widgetTB[1]->Connect("Clicked()", "TGAppMainFrame", this, "PositionSet(=1)");
+ posButtons->widgetTB[2]->Connect("Clicked()", "TGAppMainFrame", this, "PositionSet(=2)");
+ posButtons->widgetTB[3]->Connect("Clicked()", "TGAppMainFrame", this, "PositionSet(=3)");
+ rotButtons->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "RotationSet(=0)");
+ rotButtons->widgetTB[1]->Connect("Clicked()", "TGAppMainFrame", this, "RotationSet(=1)");
+ rotButtons->widgetTB[2]->Connect("Clicked()", "TGAppMainFrame", this, "RotationSet(=2)");
+ rotButtons->widgetTB[3]->Connect("Clicked()", "TGAppMainFrame", this, "RotationSet(=3)");
+ fileName->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "SaveFile()");
+ measProgress->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "StartAcq()");
+ // TODO - Save file
+
+// Main window -----------------------------------------------------------------------------
+
+// Display pane ----------------------------------------------------------------------------
+ measCanvas = new TRootEmbeddedCanvas("measCanvas",measLayout[1],300,300);
+ measLayout[1]->AddFrame(measCanvas, f1expand2d);
+// Display pane ----------------------------------------------------------------------------
+
+// Histogram file selection pane -----------------------------------------------------------
+ subgroup[0] = (analysisLayout[0]->GetWidth())-4;
+
+ // Open browser for file selection
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *selectDir -> Button to open histogram files\n");
+ selectDir = new TSubStructure();
+ if(selectDir->TGLabelButton(analysisLayout[0], 3*subgroup[0]/4, 30, "File selection:", "...", "left"))
+ analysisLayout[0]->AddFrame(selectDir->outsidebox, f0leftXpad);
+
+ // List view of the opened files
+ if(DBGSIG > 1) printf("AppLayout(): Creating TGListBox *fileList -> List box for opened histograms\n");
+ fileList = new TGListBox(analysisLayout[0],1);
+ fileList->GetVScrollbar();
+ fileList->Resize(300, (3*analysisLayout[0]->GetHeight()/7)-10 );
+ analysisLayout[0]->AddFrame(fileList, f1expandXpad);
+
+ fH1 = new TGCompositeFrame(analysisLayout[0], subgroup[0], 30, kHorizontalFrame);
+ // Multiple file selection toggle
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *multiSelect -> 2 check buttons (enable multiple select, select everything)\n");
+ multiSelect = new TSubStructure();
+ checksel = new int[2];
+ checksel[0] = 0; checksel[1] = 0;
+ selnames[0] = "Multiple file select"; selnames[1] = "Select all listed files";
+ if(multiSelect->TGCheckList(fH1, subgroup[0]/2, 30, 2, selnames, checksel, "horizontal", "left"))
+ fH1->AddFrame(multiSelect->outsidebox, f0leftX);
+ delete[] checksel;
+
+ // Previous/next controls, clear list and edit header
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *fileListCtrl -> Multiple buttons for controlling and displaying the histograms in list box\n");
+ fileListCtrl = new TSubStructure();
+ selnames[0] = "<<"; selnames[1] = ">>"; selnames[2] = "Edit header"; selnames[3] = "Clear list";
+ if(fileListCtrl->TGMultiButton(fH1, subgroup[0]/3, 30, 4, selnames, "right"))
+ fH1->AddFrame(fileListCtrl->outsidebox, f0rightX);
+
+ analysisLayout[0]->AddFrame(fH1, f1expandXpad);
+
+ // Header information of opened file
+ fG1 = new TGGroupFrame(analysisLayout[0], "Opened file header information");
+
+ fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30);
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *dispTime -> Display text Entry for opened histogram (time stamp)\n");
+ dispTime = new TSubStructure();
+ if(dispTime->TGLabelTEntry(fH1, 3*subgroup[0]/4-24, 30, "Time:", "", "oneline"))
+ fH1->AddFrame(dispTime->outsidebox, f0leftXnoleft);
+ dispTime->widgetTE->SetState(kFALSE);
+
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *dispBias -> Number entry for opened histogram (bias voltage)\n");
+ dispBias = new TSubStructure();
+ for(int i = 0; i < 6; i++) numform[i] = 0;
+ numform[0] = 7; numform[1] = 2;
+ if(dispBias->TGLabelNEntry(fH1, subgroup[0]/4-24, 30, "Bias voltage:", 0.00, numform, "center"))
+ fH1->AddFrame(dispBias->outsidebox, f0leftX);
+ dispBias->widgetNE[0]->SetState(kFALSE);
+ fG1->AddFrame(fH1, f0leftXpad);
+
+ fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30);
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *dispPos -> Display text Entry for opened histogram (table position)\n");
+ dispPos = new TSubStructure();
+ if(dispPos->TGLabelTEntry(fH1, subgroup[0]/2-12, 30, "Position:", "", "oneline"))
+ fH1->AddFrame(dispPos->outsidebox, f0leftXnoleft);
+ dispPos->widgetTE->SetState(kFALSE);
+
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *dispTemp -> Number entry for opened histogram (temperature)\n");
+ dispTemp = new TSubStructure();
+ for(int i = 0; i < 6; i++) numform[i] = 0;
+ numform[0] = 6; numform[1] = 1;
+ if(dispTemp->TGLabelNEntry(fH1, subgroup[0]/4-18, 30, "Temperature:", 0.0, numform, "center"))
+ fH1->AddFrame(dispTemp->outsidebox, f0leftX);
+ dispTemp->widgetNE[0]->SetState(kFALSE);
+
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *dispAngle -> Number entry for opened histogram (incidence angle)\n");
+ dispAngle = new TSubStructure();
+ for(int i = 0; i < 6; i++) numform[i] = 0;
+ numform[0] = 7; numform[1] = 2;
+ if(dispAngle->TGLabelNEntry(fH1, subgroup[0]/4-18, 30, "Angle:", 0.00, numform, "center"))
+ fH1->AddFrame(dispAngle->outsidebox, f0leftX);
+ dispAngle->widgetNE[0]->SetState(kFALSE);
+ fG1->AddFrame(fH1, f0leftXpad);
+
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *dispLaser -> Display text Entry for opened histogram (laser and additional info)\n");
+ dispLaser = new TSubStructure();
+ if(dispLaser->TGLabelTEntry(fG1, 3*subgroup[0]/4, 30, "Laser settings:", "", "oneline"))
+ fG1->AddFrame(dispLaser->outsidebox, f1expandXpad);
+ dispLaser->widgetTE->SetState(kFALSE);
+
+ analysisLayout[0]->AddFrame(fG1, f1expandX);
+
+ // Actions for histogram file selection pane
+ selectDir->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "SelectDirectory()");
+ multiSelect->widgetChBox[0]->Connect("Clicked()", "TGAppMainFrame", this, "ListMultiSelect(=0)");
+ multiSelect->widgetChBox[1]->Connect("Clicked()", "TGAppMainFrame", this, "ListMultiSelect(=1)");
+ fileList->Connect("DoubleClicked(Int_t)", "TGAppMainFrame", this, "FileListNavigation(Int_t)");
+ fileListCtrl->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "FileListNavigation(=-2)");
+ fileListCtrl->widgetTB[1]->Connect("Clicked()", "TGAppMainFrame", this, "FileListNavigation(=-3)");
+ fileListCtrl->widgetTB[2]->Connect("Clicked()", "TGAppMainFrame", this, "HeaderEdit()");
+ fileListCtrl->widgetTB[3]->Connect("Clicked()", "TGAppMainFrame", this, "ClearHistogramList()");
+
+// Histogram file selection pane -----------------------------------------------------------
+
+// Analysis pane ---------------------------------------------------------------------------
+ fH1 = new TGCompositeFrame(analysisLayout[1], analysisLayout[1]->GetWidth(), 30, kHorizontalFrame);
+
+ subgroup[0] = (analysisLayout[1]->GetWidth())/2-4;
+ subgroup[1] = (analysisLayout[1]->GetHeight())-4;
+
+ analTab = new TGTab(fH1, subgroup[0], subgroup[1]);
+
+ // Analysis tabs
+ // Integrate spectrum tab
+ fT1 = analTab->AddTab("Integ. spectrum");
+ fV1 = new TGCompositeFrame(fT1, subgroup[0], subgroup[1], kVerticalFrame | kFixedWidth | kFixedHeight);
+
+ // Check buttons to toggle direction of integration and normalization
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *intSpect -> 3 check buttons (direction of integration, normalization)\n");
+ intSpect = new TSubStructure();
+ checksel = new int[3];
+ checksel[0] = 0; checksel[1] = 0; checksel[2] = 1;
+ selnames[0] = "X direction (for edge scans)";
+ selnames[1] = "Y direction (for edge scans)";
+ selnames[2] = "Normalize to number of events";
+ if(intSpect->TGCheckList(fV1, subgroup[0], 30, 3, selnames, checksel, "vertical", "center"))
+ fV1->AddFrame(intSpect->outsidebox, f1expandXpad);
+ delete[] checksel;
+
+ // Values for 2D plot pixel resolution
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *resol2d -> Pixel resolution for 2D plots\n");
+ resol2d = new TSubStructure();
+ for(int i = 0; i < 6; i++) { numform[i] = 0; numform2[i] = 0; }
+ numform[0] = 5; numform2[0] = 5; numform[2] = 2; numform2[2] = 2;
+ if(resol2d->TGLabelDoubleNEntry(fV1, subgroup[0], 30, "2D plot pixel resolution (X, Y):", 40, numform, 40, numform2, "center"))
+ fV1->AddFrame(resol2d->outsidebox, f1expandX);
+
+ // Start integrating or set its defaults
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *intSpectButtons -> 2 buttons for integrating spectra\n");
+ intSpectButtons = new TSubStructure();
+ selnames[0] = "Start"; selnames[1] = "Start and edit"; selnames[2] = "Default values";
+ if(intSpectButtons->TGMultiButton(fV1, subgroup[0], 30, 3, selnames, "center"))
+ fV1->AddFrame(intSpectButtons->outsidebox, f1expandX);
+
+ fT1->AddFrame(fV1, f1expandX);
+
+ // Relative photon detection efficiency tab (PDE)
+ fT1 = analTab->AddTab("Relative PDE");
+ fV1 = new TGCompositeFrame(fT1, subgroup[0], subgroup[1], kVerticalFrame | kFixedWidth | kFixedHeight);
+
+ // Check button to toggle normalization
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *relPde -> 2 check buttons (relative pde, normalization)\n");
+ relPde = new TSubStructure();
+ checksel = new int;
+ *checksel = 1;
+ selnames[0] = "Normalize to number of events";
+ if(relPde->TGCheckList(fV1, subgroup[0], 30, 1, selnames, checksel, "vertical", "center"))
+ fV1->AddFrame(relPde->outsidebox, f1expandXpad);
+ delete[] checksel;
+
+ // Calculate relative PDE using the middle of the pedestal peak
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *midPeak -> Calculate the relative PDE, by setting the middle of the pedestal peak.\n");
+ midPeak = new TSubStructure();
+ checksel = new int;
+ *checksel = 0;
+ selnames[0] = "Pedestal entries end at middle of ped. peak";
+ if(midPeak->TGCheckList(fV1, subgroup[0], 30, 1, selnames, checksel, "vertical", "center"))
+ fV1->AddFrame(midPeak->outsidebox, f1expandX);
+ delete checksel;
+
+ // Select the dark run
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *darkRun -> Button to open histogram files of a dark run\n");
+ darkRun = new TSubStructure();
+ if(darkRun->TGLabelTEntryButton(fV1, 3*subgroup[0]/4, 30, "Select dark run histogram:", "", "...", "oneline"))
+ {
+ darkRun->widgetTE->SetState(kFALSE);
+ fV1->AddFrame(darkRun->outsidebox, f1expandXpad);
+ }
+
+ // Select the offset of 0 angle
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *zeroAngle -> Set the offset for 0 angle\n");
+ zeroAngle = new TSubStructure();
+ for(int i = 0; i < 6; i++) numform[i] = 0;
+ numform[0] = 6; numform[1] = 2;
+ if(zeroAngle->TGLabelNEntry(fV1, 3*subgroup[0]/4, 30, "Offset to zero angle:", 0., numform, "center"))
+ fV1->AddFrame(zeroAngle->outsidebox, f0centerX);
+
+ // Start calculating the PDE or set its defaults
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *relPdeButtons -> 2 buttons for calculating the relative PDE\n");
+ relPdeButtons = new TSubStructure();
+ selnames[0] = "Start"; selnames[1] = "Start and edit"; selnames[2] = "Default values";
+ if(relPdeButtons->TGMultiButton(fV1, subgroup[0], 30, 3, selnames, "center"))
+ fV1->AddFrame(relPdeButtons->outsidebox, f1expandX);
+
+ fT1->AddFrame(fV1, f1expandX);
+
+ // Breaktown voltage tab
+ fT1 = analTab->AddTab("Breakdown voltage");
+ fV1 = new TGCompositeFrame(fT1, subgroup[0], subgroup[1], kVerticalFrame | kFixedWidth | kFixedHeight);
+
+ // Select the minumum number of peaks for fitting to be initiated
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *minPeak -> Minimum number of peaks to fit for peak fitting\n");
+ minPeak = new TSubStructure();
+ for(int i = 0; i < 6; i++) numform[i] = 0;
+ numform[0] = 4; numform[2] = 1; numform[3] = 2; numform[4] = 1; numform[5] = 20;
+ if(minPeak->TGLabelNEntry(fV1, subgroup[0], 30, "Min. nr. of peaks:", 2, numform, "center"))
+ fV1->AddFrame(minPeak->outsidebox, f0centerX);
+
+ // Select which separation to use
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *peakSepCalc -> Make the separation between the selected peaks\n");
+ peakSepCalc = new TSubStructure();
+ for(int i = 0; i < 6; i++) numform[i] = 0;
+ numform[0] = 4; numform[2] = 1; numform[3] = 2; numform[4] = 1; numform[5] = 3;
+ if(peakSepCalc->TGLabelNEntry(fV1, subgroup[0], 30, "Calculate peak separation between N pe and N+1 pe peaks:", 1, numform, "center"))
+ fV1->AddFrame(peakSepCalc->outsidebox, f0centerX);
+
+ // Start calculating the breakdown voltage or set its defaults
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *brDownButtons -> 2 buttons for calculating the breakdown voltage\n");
+ brDownButtons = new TSubStructure();
+ selnames[0] = "Start"; selnames[1] = "Start and edit"; selnames[2] = "Default values";
+ if(brDownButtons->TGMultiButton(fV1, subgroup[0], 30, 3, selnames, "center"))
+ fV1->AddFrame(brDownButtons->outsidebox, f1expandX);
+
+ fT1->AddFrame(fV1, f1expandX);
+
+ // Surface scan tab
+ fT1 = analTab->AddTab("Surface scan");
+ fV1 = new TGCompositeFrame(fT1, subgroup[0], subgroup[1], kVerticalFrame | kFixedWidth | kFixedHeight);
+
+ // Check button to toggle normalization
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *surfScanOpt -> 2 check buttons (normalization, zero bottom-left corner)\n");
+ surfScanOpt = new TSubStructure();
+ checksel = new int[2];
+ checksel[0] = 1; checksel[1] = 0;
+ selnames[0] = "Normalize to number of events"; selnames[1] = "Zero the bottom left corner";
+ if(surfScanOpt->TGCheckList(fV1, subgroup[0], 30, 2, selnames, checksel, "vertical", "center"))
+ fV1->AddFrame(surfScanOpt->outsidebox, f1expandXpad);
+ delete[] checksel;
+
+ // Values for 2D plot pixel resolution
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *resolSurf -> Pixel resolution for surface plots\n");
+ resolSurf = new TSubStructure();
+ for(int i = 0; i < 6; i++) { numform[i] = 0; numform2[i] = 0; }
+ numform[0] = 5; numform2[0] = 5; numform[2] = 2; numform2[2] = 2;
+ if(resolSurf->TGLabelDoubleNEntry(fV1, subgroup[0], 30, "Surface plot pixel resolution (X, Y):", 40, numform, 40, numform2, "center"))
+ fV1->AddFrame(resolSurf->outsidebox, f1expandX);
+
+ // Start calculating the breakdown voltage or set its defaults
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *surfButtons -> 2 buttons for calculating the surface scan\n");
+ surfButtons = new TSubStructure();
+ selnames[0] = "Start"; selnames[1] = "Start and edit"; selnames[2] = "Default values";
+ if(surfButtons->TGMultiButton(fV1, subgroup[0], 30, 3, selnames, "center"))
+ fV1->AddFrame(surfButtons->outsidebox, f1expandX);
+
+ fT1->AddFrame(fV1, f1expandX);
+
+ // Timing tab
+ fT1 = analTab->AddTab("Timing");
+ fV1 = new TGCompositeFrame(fT1, subgroup[0], subgroup[1], kVerticalFrame | kFixedWidth | kFixedHeight);
+
+ fT1->AddFrame(fV1, f1expandX);
+
+ // Analysis tabs
+ fH1->AddFrame(analTab, /*f1expandX*/f0leftX);
+
+ // Peak fitting settings
+ fV1 = new TGCompositeFrame(fH1, subgroup[0], 30, kVerticalFrame);
+
+ fH2 = new TGCompositeFrame(fV1, subgroup[0], 30, kHorizontalFrame);
+ // Select the sigma for peak fitting
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *fitSigma -> Sigma for peak fitting\n");
+ fitSigma = new TSubStructure();
+ for(int i = 0; i < 6; i++) numform[i] = 0;
+ numform[0] = 6; numform[1] = 3; numform[2] = 2;
+ if(fitSigma->TGLabelNEntry(fH2, subgroup[0]/2, 30, "Peak sigma:", 1.2, numform, "center"))
+ fH2->AddFrame(fitSigma->outsidebox, f0centerX);
+ // Select the signal to noise treshold for peak fitting
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *fitTresh -> S/N ratio for peak fitting\n");
+ fitTresh = new TSubStructure();
+ for(int i = 0; i < 6; i++) numform[i] = 0;
+ numform[0] = 6; numform[1] = 3; numform[2] = 2;
+ if(fitTresh->TGLabelNEntry(fH2, subgroup[0]/2, 30, "S/N ratio:", 0.005, numform, "center"))
+ fH2->AddFrame(fitTresh->outsidebox, f0centerX);
+ fV1->AddFrame(fH2, f1expandXpad);
+
+ // Select the background interpolation for peak fitting
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *fitInter -> Background interpolation for peak fitting\n");
+ fitInter = new TSubStructure();
+ for(int i = 0; i < 6; i++) numform[i] = 0;
+ numform[0] = 5; numform[2] = 1;
+ if(fitInter->TGLabelNEntry(fV1, subgroup[0], 30, "Back. interpolation:", 7, numform, "center"))
+ fV1->AddFrame(fitInter->outsidebox, f0centerX);
+
+ // Select the ADC offset
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *adcOffset -> Select the offset for all ADC spectra\n");
+ adcOffset = new TSubStructure();
+ for(int i = 0; i < 6; i++) numform[i] = 0;
+ numform[0] = 6; numform[1] = 2;
+ if(adcOffset->TGLabelNEntry(fV1, subgroup[0], 30, "ADC spectrum offset:", 0.00, numform, "center"))
+ fV1->AddFrame(adcOffset->outsidebox, f0centerX);
+
+ // Select the acceptable error for peak fitting
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *accError -> Acceptable peak fitting error for peak fitting\n");
+ accError = new TSubStructure();
+ for(int i = 0; i < 6; i++) numform[i] = 0;
+ numform[0] = 6; numform[1] = 2; numform[2] = 1;
+ if(accError->TGLabelNEntry(fV1, subgroup[0], 30, "Max. peak fit error:", 0.15, numform, "center"))
+ fV1->AddFrame(accError->outsidebox, f0centerX);
+
+ // Select the pedestal lower limit for peak fitting
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *pedesLow -> Lower ADC limit of pedestal peak for peak fitting\n");
+ pedesLow = new TSubStructure();
+ for(int i = 0; i < 6; i++) numform[i] = 0;
+ numform[0] = 6; numform[1] = 1; numform[2] = 2;
+ if(pedesLow->TGLabelNEntry(fV1, subgroup[0], 30, "Pedestal low limit:", 0.0, numform, "center"))
+ fV1->AddFrame(pedesLow->outsidebox, f0centerX);
+
+ // Check buttons to toggle subtracting the background and exporting the fitted spectra
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *fitChecks -> 2 check buttons (substracting background, exporting fitted spectra)\n");
+ fitChecks = new TSubStructure();
+ checksel = new int[2];
+ checksel[0] = 1; checksel[1] = 0;
+ selnames[0] = "Backround subtraction ON/OFF";
+ selnames[1] = "Export fitted spectra ON/OFF";
+ if(fitChecks->TGCheckList(fV1, subgroup[0], 30, 2, selnames, checksel, "vertical", "center"))
+ fV1->AddFrame(fitChecks->outsidebox, f1expandXpad);
+ delete[] checksel;
+
+ // Analysis progress bar
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *analysisProgress -> Horizontal progress bar for analysis\n");
+ analysisProgress = new TSubStructure();
+ if(analysisProgress->TGLabelProgress(fV1, subgroup[0], 30, "Current analysis:"))
+ fV1->AddFrame(analysisProgress->outsidebox, f1expandXpad);
+
+ fH1->AddFrame(fV1, f1expandX);
+
+ analysisLayout[1]->AddFrame(fH1, f1expandXpad);
+
+ // Actions for analysis pane
+ intSpectButtons->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "AnalysisHandle(=0)");
+ intSpectButtons->widgetTB[1]->Connect("Clicked()", "TGAppMainFrame", this, "AnalysisHandle(=1)");
+ intSpectButtons->widgetTB[2]->Connect("Clicked()", "TGAppMainFrame", this, "AnalysisDefaults()");
+
+ relPdeButtons->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "AnalysisHandle(=0)");
+ relPdeButtons->widgetTB[1]->Connect("Clicked()", "TGAppMainFrame", this, "AnalysisHandle(=1)");
+ relPdeButtons->widgetTB[2]->Connect("Clicked()", "TGAppMainFrame", this, "AnalysisDefaults()");
+ darkRun->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "SelectDarkHist()");
+
+ brDownButtons->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "AnalysisHandle(=0)");
+ brDownButtons->widgetTB[1]->Connect("Clicked()", "TGAppMainFrame", this, "AnalysisHandle(=1)");
+ brDownButtons->widgetTB[2]->Connect("Clicked()", "TGAppMainFrame", this, "AnalysisDefaults()");
+
+ surfButtons->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "AnalysisHandle(=0)");
+ surfButtons->widgetTB[1]->Connect("Clicked()", "TGAppMainFrame", this, "AnalysisHandle(=1)");
+ surfButtons->widgetTB[2]->Connect("Clicked()", "TGAppMainFrame", this, "AnalysisDefaults()");
+// Analysis pane ---------------------------------------------------------------------------
+
+// Histogram pane --------------------------------------------------------------------------
+ analysisCanvas = new TRootEmbeddedCanvas("analysisCanvas",analysisLayout[2],300,300);
+ analysisLayout[2]->AddFrame(analysisCanvas, f1expand2d);
+ analysisCanvas->GetCanvas()->SetGrid();
+// Histogram pane --------------------------------------------------------------------------
+
+// Histogram controls pane -----------------------------------------------------------------
+ subgroup[0] = (analysisLayout[3]->GetWidth())-4;
+
+ // Control for histogram X range
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *adcRange -> Range for ADC histogram\n");
+ adcRange = new TSubStructure();
+ for(int i = 0; i < 6; i++) { numform[i] = 0; numform2[i] = 0; }
+ numform[0] = 6; numform2[0] = 6;
+ if(adcRange->TGLabelDoubleNEntry(analysisLayout[3], subgroup[0], 30, "ADC range (min, max):", 0, numform, 0, numform2, "center"))
+ analysisLayout[3]->AddFrame(adcRange->outsidebox, f1expandXpad);
+
+ // TDC window for getting data
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *tdcRange -> Range for TDC histogram\n");
+ tdcRange = new TSubStructure();
+ for(int i = 0; i < 6; i++) { numform[i] = 0; numform2[i] = 0; }
+ numform[0] = 8; numform[1] = 2; numform2[0] = 8; numform2[1] = 2;
+ if(tdcRange->TGLabelDoubleNEntry(analysisLayout[3], subgroup[0], 30, "TDC range (min, max):", -0.5, numform, 221.8, numform2, "center"))
+ analysisLayout[3]->AddFrame(tdcRange->outsidebox, f1expandXpad);
+
+ // Y axis range settings
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *yRange -> Y axis range\n");
+ yRange = new TSubStructure();
+ for(int i = 0; i < 6; i++) { numform[i] = 0; numform2[i] = 0; }
+ numform[0] = 8; numform[1] = 1; numform2[0] = 8; numform2[1] = 1;
+ if(yRange->TGLabelDoubleNEntry(analysisLayout[3], subgroup[0], 30, "Y range (min, max):", 0, numform, 0, numform2, "center"))
+ analysisLayout[3]->AddFrame(yRange->outsidebox, f1expandXpad);
+
+ fH1 = new TGHorizontalFrame(analysisLayout[3], subgroup[0], 30);
+ // Select the channel to display
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *selectCh -> Channel to display\n");
+ selectCh = new TSubStructure();
+ for(int i = 0; i < 6; i++) numform[i] = 0;
+ numform[0] = 3; numform[2] = 2; numform[3] = 2; numform[4] = 0; numform[5] = 7; // TODO - ko odprem file, nastavi zgornjo limito
+ if(selectCh->TGLabelNEntry(fH1, subgroup[0]/2-24, 30, "Display channel:", 0, numform, "center"))
+ fH1->AddFrame(selectCh->outsidebox, f0leftX);
+ selChannel = -1;
+
+ // Change plot type
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *plotType -> 3 buttons for selecting the plot type (ADC, TDC, ADC/TDC)\n");
+ plotType = new TSubStructure();
+ selnames[0] = "ADC"; selnames[1] = "TDC"; selnames[2] = "ADC/TDC";
+ if(plotType->TGMultiButton(fH1, subgroup[0]/2-24, 30, 3, selnames, "center"))
+ fH1->AddFrame(plotType->outsidebox, f1expandX);
+ analysisLayout[3]->AddFrame(fH1, f1expandXpad);
+
+ // Check button to toggle logarithmic scale
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *histOpt -> 2 check buttons (histogram logarithmic scale, clean plots)\n");
+ histOpt = new TSubStructure();
+ checksel = new int[2];
+ checksel[0] = 0; checksel[1] = 1;
+ selnames[0] = "Logarithmic scale ON/OFF";
+ selnames[1] = "Clean plots ON/OFF";
+ if(histOpt->TGCheckList(analysisLayout[3], subgroup[0], 30, 2, selnames, checksel, "vertical", "center"))
+ analysisLayout[3]->AddFrame(histOpt->outsidebox, f1expandXpad);
+ delete[] checksel;
+
+ // Export the selected files
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *exportHist -> Button to export current histogram\n");
+ exportHist = new TSubStructure();
+ if(exportHist->TGLabelButton(analysisLayout[3], subgroup[0], 30, "Export selected histograms:", "Export", "center"))
+ analysisLayout[3]->AddFrame(exportHist->outsidebox, f1expandXpad);
+
+ // Edit the selected histograms
+ if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *editSelHist -> Button to additionally edit the selected histograms (make a canvas clone in a new tab)\n");
+ editSelHist = new TSubStructure();
+ if(editSelHist->TGLabelButton(analysisLayout[3], subgroup[0], 30, "Edit selected histograms:", "Edit", "center"))
+ analysisLayout[3]->AddFrame(editSelHist->outsidebox, f1expandXpad);
+
+ // Actions for histogram controls pane //TODO
+ for(int i = 0; i < 2; i++)
+ {
+ adcRange->widgetNE[i]->Connect("ValueSet(Long_t)", "TGAppMainFrame", this, "UpdateHistogram(=0)");
+// (adcRange->widgetNE[i]->GetNumberEntry())->Connect("ReturnPressed()", "TGAppMainFrame", this, "UpdateHistogram(=0)");
+ tdcRange->widgetNE[i]->Connect("ValueSet(Long_t)", "TGAppMainFrame", this, "UpdateHistogram(=0)");
+// (tdcRange->widgetNE[i]->GetNumberEntry())->Connect("ReturnPressed()", "TGAppMainFrame", this, "UpdateHistogram(=0)");
+ yRange->widgetNE[i]->Connect("ValueSet(Long_t)", "TGAppMainFrame", this, "UpdateHistogram(=0)");
+// (yRange->widgetNE[i]->GetNumberEntry())->Connect("ReturnPressed()", "TGAppMainFrame", this, "UpdateHistogram(=0)");
+ }
+ plotType->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "ChangeHisttype(=0)");
+ plotType->widgetTB[1]->Connect("Clicked()", "TGAppMainFrame", this, "ChangeHisttype(=1)");
+ plotType->widgetTB[2]->Connect("Clicked()", "TGAppMainFrame", this, "ChangeHisttype(=2)");
+ selectCh->widgetNE[0]->Connect("ValueSet(Long_t)", "TGAppMainFrame", this, "UpdateHistogram(=2)");
+ selectCh->widgetNE[0]->Connect("ValueChanged(Long_t)", "TGAppMainFrame", this, "UpdateHistogram(=2)");
+ (selectCh->widgetNE[0]->GetNumberEntry())->Connect("ReturnPressed()", "TGAppMainFrame", this, "UpdateHistogram(=2)");
+ histOpt->widgetChBox[0]->Connect("Clicked()", "TGAppMainFrame", this, "HistogramOptions(=0)");
+ histOpt->widgetChBox[1]->Connect("Clicked()", "TGAppMainFrame", this, "HistogramOptions(=1)");
+ exportHist->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "UpdateHistogram(=1)");
+
+// Histogram controls pane -----------------------------------------------------------------
+}
+
+// -------------------------------------------------------------------
+
+// Closing main window and checking about information ----------------
+
+void TGAppMainFrame::CloseWindow()
+{
+ gApplication->Terminate(0);
+}
+
+Bool_t TGAppMainFrame::About()
+{
+ int ret = 0;
+
+ new TGMsgBox(gClient->GetRoot(), fMain, fMain->GetWindowName(), "Software for SiPM characterization with\nCAMAC, scope, bias voltage and table position support\n\nCreated by Gasper Kukec Mezek (gasper.kukec@ung.si),\nUpdated on July 17th 2015", kMBIconQuestion, kMBClose, &ret);
+
+ return kFALSE;
+}
+
+// -------------------------------------------------------------------
+
+// Subwindow constructor (+layout) and close subwindow ---------------
+/*
+TGMdiSubwindow::TGMdiSubwindow(TGMdiMainFrame *main, int w, int h)
+{
+ // Create a new subwindow
+ fMdiFrame = new TGMdiFrame(main, w, h);
+ fMdiFrame->Connect("CloseWindow()", "TGMdiSubwindow", this, "CloseWindow(=0)");
+ fMdiFrame->DontCallClose();
+}
+
+Bool_t TGMdiSubwindow::CloseWindow(int layoutchange)
+{
+ int ret = 0;
+
+ if(layoutchange == 0)
+ new TGMsgBox(gClient->GetRoot(), fMdiFrame, fMdiFrame->GetWindowName(), "Really want to close the window?", kMBIconExclamation, kMBYes | kMBNo, &ret);
+ else if(layoutchange == 1)
+ ret = kMBYes;
+ if(ret == kMBYes)
+ {
+ if(strcmp("Information window", fMdiFrame->GetWindowName()) == 0)
+ id = -1;
+ return fMdiFrame->CloseWindow();
+ }
+
+ return kFALSE;
+}*/
+
+// -------------------------------------------------------------------
+
+// Main function -----------------------------------------------------
+void root_app()
+{
+ if(DBGSIG > 1)
+ {
+ printf("root_app(): Starting objects\n");
+ gObjectTable->Print();
+ }
+
+ int winWidth = 1240;
+ int winHeight = 800;
+ layoutMainWindow(&winWidth, &winHeight);
+
+ new TGAppMainFrame(gClient->GetRoot(), winWidth, winHeight);
+}
+
+int main(int argc, char **argv)
+{
+ if(DBGSIG > 1)
+ {
+ printf("main(): Starting objects\n");
+ gObjectTable->Print();
+ }
+
+ TApplication theApp("MdiTest", &argc, argv);
+ root_app();
+ theApp.Run();
+
+ return 0;
+}
+
+// -------------------------------------------------------------------
Index: sipmscan/trunk/src/substructure.cpp
===================================================================
--- sipmscan/trunk/src/substructure.cpp (nonexistent)
+++ sipmscan/trunk/src/substructure.cpp (revision 146)
@@ -0,0 +1,797 @@
+#include "../include/substructure.h"
+#include "../include/workstation.h"
+#include <stdio.h>
+
+TSubStructure::TSubStructure()
+{
+ // ID of certain objects
+ /*
+ * id = 0 -> Label + Text Entry
+ * id = 1 -> Label + Text Entry + Button
+ * id = 2 -> Label + Button
+ * id = 3 -> Label + Number Entry
+ * id = 4 -> Text Entry + Button
+ * id = 5 -> Label + Dropdown menu
+ * id = 6 -> 2 or more buttons
+ * id = 7 -> Label + 2 Number Entries
+ * id = 8 -> Checkbutton list
+ * id = 9 -> Button + horizontal progress bar
+ * id = 10 -> Label + horizontal progress bar
+ * id = 11 -> Button + horizontal progress bar + Text Entry
+ * id = 12 -> Checkbutton + Number Entry
+ * id = 13 -> Checkbutton + Text Entry
+ */
+}
+
+TSubStructure::~TSubStructure()
+{
+ // TODO (delete and new not working as they should)
+}
+
+// Widget with Label and Text Entry
+bool TSubStructure::TGLabelTEntry(TGWindow *parent, int w, int h, const char *label, const char *deftext = "", const char *layout = "oneline")
+{
+ id = 0;
+
+ f0 = new TGLayoutHints(kLHintsLeft | kLHintsCenterY,2,2,2,2);
+
+ if(strcmp("oneline", layout) == 0)
+ {
+ outsidebox = new TGCompositeFrame(parent, w-6, h, kHorizontalFrame | kFixedWidth);
+ if(DBGSIG > 1) outsidebox->SetBackgroundColor(0);
+ f0expandX = new TGLayoutHints(kLHintsExpandX | kLHintsCenterY,6,2,2,2);
+ }
+ else if(strcmp("twoline", layout) == 0)
+ {
+ outsidebox = new TGCompositeFrame(parent, w-6, h, kVerticalFrame | kFixedWidth);
+ if(DBGSIG > 1) outsidebox->SetBackgroundColor(0);
+ f0expandX = new TGLayoutHints(kLHintsExpandX | kLHintsCenterY,0,2,2,2);
+ }
+ lab = new TGLabel(outsidebox, label);
+ outsidebox->AddFrame(lab, f0);
+ widgetTE = new TGTextEntry(outsidebox, deftext);
+ outsidebox->AddFrame(widgetTE, f0expandX);
+
+ if(DBGSIG > 1) printf("id = %d\n",id);
+
+ return true;
+}
+
+// Widget with Label, Text Entry and Button
+bool TSubStructure::TGLabelTEntryButton(TGWindow *parent, int w, int h, const char *label, const char *deftext = "", const char *buttext = "Set", const char *layout = "oneline")
+{
+ id = 1;
+
+ f0 = new TGLayoutHints(kLHintsLeft | kLHintsCenterY,2,2,2,2);
+
+ if(strcmp("oneline", layout) == 0)
+ {
+ outsidebox = new TGCompositeFrame(parent, w-6, h, kHorizontalFrame | kFixedWidth);
+ if(DBGSIG > 1) outsidebox->SetBackgroundColor(0);
+ f0expandX = new TGLayoutHints(kLHintsExpandX | kLHintsCenterY,6,6,2,2);
+ lab = new TGLabel(outsidebox, label);
+ outsidebox->AddFrame(lab, f0);
+ widgetTE = new TGTextEntry(outsidebox, deftext);
+ widgetTE->Resize(w-12,22);
+ outsidebox->AddFrame(widgetTE, f0expandX);
+ widgetTB[0] = new TGTextButton(outsidebox, buttext);
+ widgetTB[0]->SetTextJustify(36);
+ widgetTB[0]->SetWrapLength(-1);
+ widgetTB[0]->Resize(60,22);
+ outsidebox->AddFrame(widgetTB[0], f0);
+ }
+ else if(strcmp("twoline", layout) == 0)
+ {
+ outsidebox = new TGCompositeFrame(parent, w-6, h, kVerticalFrame | kFixedWidth);
+ if(DBGSIG > 1) outsidebox->SetBackgroundColor(0);
+ f0expandX = new TGLayoutHints(kLHintsExpandX | kLHintsCenterY,0,6,2,2);
+ lab = new TGLabel(outsidebox, label);
+ outsidebox->AddFrame(lab, f0);
+
+ fH1 = new TGHorizontalFrame(outsidebox, 100, h);
+ if(DBGSIG > 1) fH1->SetBackgroundColor(200);
+ widgetTE = new TGTextEntry(fH1, deftext);
+ widgetTE->Resize(w-12,22);
+ fH1->AddFrame(widgetTE, f0expandX);
+ widgetTB[0] = new TGTextButton(fH1, buttext);
+ widgetTB[0]->SetTextJustify(36);
+ widgetTB[0]->SetWrapLength(-1);
+ widgetTB[0]->Resize(60,22);
+ fH1->AddFrame(widgetTB[0], f0);
+ outsidebox->AddFrame(fH1, f0expandX);
+ }
+
+ if(DBGSIG > 1) printf("id = %d\n",id);
+
+ return true;
+}
+
+// Widget with Label and Button
+bool TSubStructure::TGLabelButton(TGWindow *parent, int w, int h, const char *label, const char *buttext = "Set", const char *pos = "left")
+{
+ id = 2;
+
+ f0 = new TGLayoutHints(kLHintsLeft | kLHintsCenterY,2,2,2,2);
+ f1 = new TGLayoutHints(kLHintsLeft | kLHintsCenterY,6,2,2,2);
+ if(strcmp("left",pos) == 0)
+ f2 = new TGLayoutHints(kLHintsLeft,0,0,0,0);
+ else if(strcmp("center",pos) == 0)
+ f2 = new TGLayoutHints(kLHintsCenterX,0,0,0,0);
+ else if(strcmp("right",pos) == 0)
+ f2 = new TGLayoutHints(kLHintsRight,0,0,0,0);
+
+ outsidebox = new TGCompositeFrame(parent, w-6, h, kHorizontalFrame | kFixedWidth);
+ if(DBGSIG > 1) outsidebox->SetBackgroundColor(0);
+ fH1 = new TGHorizontalFrame(outsidebox, 100, h);
+ if(DBGSIG > 1) fH1->SetBackgroundColor(200);
+ lab = new TGLabel(fH1, label);
+ fH1->AddFrame(lab, f0);
+ widgetTB[0] = new TGTextButton(fH1, buttext);
+ widgetTB[0]->SetTextJustify(36);
+ widgetTB[0]->SetWrapLength(-1);
+ widgetTB[0]->Resize(60,22);
+ fH1->AddFrame(widgetTB[0], f1);
+ outsidebox->AddFrame(fH1, f2);
+
+ if(DBGSIG > 1) printf("id = %d\n",id);
+
+ return true;
+}
+
+// Widget with Label and Number Entry
+bool TSubStructure::TGLabelNEntry(TGWindow *parent, int w, int h, const char *label, double defval, double *format, const char *pos)
+{
+ id = 3;
+
+ TGNumberFormat::EStyle numtype;
+ TGNumberFormat::EAttribute negpos;
+ TGNumberFormat::ELimit numlim;
+ bool arelimits[] = {false,false};
+
+ // Number type (integer, real)
+ if( (int)format[1] == 0 ) numtype = TGNumberFormat::kNESInteger;
+ else if( (int)format[1] == 1 ) numtype = TGNumberFormat::kNESRealOne;
+ else if( (int)format[1] == 2 ) numtype = TGNumberFormat::kNESRealTwo;
+ else if( (int)format[1] == 3 ) numtype = TGNumberFormat::kNESRealThree;
+ else if( (int)format[1] == 4 ) numtype = TGNumberFormat::kNESRealFour;
+ else if( (int)format[1] == -1 ) numtype = TGNumberFormat::kNESReal;
+
+ // Negative or positive
+ if( (int)format[2] == 0 ) negpos = TGNumberFormat::kNEAAnyNumber;
+ else if( (int)format[2] == 1 ) negpos = TGNumberFormat::kNEAPositive;
+ else if( (int)format[2] == 2 ) negpos = TGNumberFormat::kNEANonNegative;
+
+ // Limits
+ if( (int)format[3] == 0 ) numlim = TGNumberFormat::kNELNoLimits;
+ else if( (int)format[3] == 1 ) { numlim = TGNumberFormat::kNELLimitMax; arelimits[1] = true; }
+ else if( (int)format[3] == 2 ) { numlim = TGNumberFormat::kNELLimitMinMax; arelimits[0] = true; arelimits[1] = true; }
+ else if( (int)format[3] == -1 ) { numlim = TGNumberFormat::kNELLimitMin; arelimits[0] = true; }
+
+ f0 = new TGLayoutHints(kLHintsLeft | kLHintsCenterY,2,2,2,2);
+ f1 = new TGLayoutHints(kLHintsLeft | kLHintsCenterY,6,2,2,2);
+ if(strcmp("left",pos) == 0)
+ f2 = new TGLayoutHints(kLHintsLeft,0,0,0,0);
+ else if(strcmp("center",pos) == 0)
+ f2 = new TGLayoutHints(kLHintsCenterX,0,0,0,0);
+ else if(strcmp("right",pos) == 0)
+ f2 = new TGLayoutHints(kLHintsRight,0,0,0,0);
+
+ outsidebox = new TGCompositeFrame(parent, w-6, h, kHorizontalFrame | kFixedWidth);
+ if(DBGSIG > 1) outsidebox->SetBackgroundColor(0);
+ fH1 = new TGHorizontalFrame(outsidebox, 100, h);
+ if(DBGSIG > 1) fH1->SetBackgroundColor(200);
+ lab = new TGLabel(fH1, label);
+ fH1->AddFrame(lab, f0);
+ if( (int)format[1] == 0 )
+ {
+ if( arelimits[0] && arelimits[1] )
+ widgetNE[0] = new TGNumberEntry(fH1, (int)defval, (int)format[0], 999, numtype, negpos, numlim, (int)format[4], (int)format[5]);
+ else if( arelimits[0] )
+ widgetNE[0] = new TGNumberEntry(fH1, (int)defval, (int)format[0], 999, numtype, negpos, numlim, (int)format[4], 0);
+ else if( arelimits[1] )
+ widgetNE[0] = new TGNumberEntry(fH1, (int)defval, (int)format[0], 999, numtype, negpos, numlim, 0, (int)format[4]);
+ else
+ widgetNE[0] = new TGNumberEntry(fH1, (int)defval, (int)format[0], 999, numtype, negpos, numlim);
+ }
+ else if( (((int)format[1] > 0) && ((int)format[1] < 5)) || ((int)format[1] == -1) )
+ {
+ if( arelimits[0] && arelimits[1] )
+ widgetNE[0] = new TGNumberEntry(fH1, defval, (int)format[0], 999, numtype, negpos, numlim, format[4], format[5]);
+ else if( arelimits[0] )
+ widgetNE[0] = new TGNumberEntry(fH1, defval, (int)format[0], 999, numtype, negpos, numlim, format[4], 0);
+ else if( arelimits[1] )
+ widgetNE[0] = new TGNumberEntry(fH1, defval, (int)format[0], 999, numtype, negpos, numlim, 0, format[4]);
+ else
+ widgetNE[0] = new TGNumberEntry(fH1, defval, (int)format[0], 999, numtype, negpos, numlim);
+ }
+ else
+ {
+ delete outsidebox;
+ delete lab;
+ return false;
+ }
+ fH1->AddFrame(widgetNE[0], f1);
+ outsidebox->AddFrame(fH1, f2);
+
+ if(DBGSIG > 1) printf("id = %d\n",id);
+
+ return true;
+}
+
+// Widget with Text Entry and Button
+bool TSubStructure::TGTEntryButton(TGWindow *parent, int w, int h, const char *deftext = "", const char *buttext = "Set")
+{
+ id = 4;
+
+ f0 = new TGLayoutHints(kLHintsLeft | kLHintsCenterY,2,2,2,2);
+ f0expandX = new TGLayoutHints(kLHintsExpandX | kLHintsCenterY,2,6,2,2);
+
+ outsidebox = new TGCompositeFrame(parent, w-6, h, kHorizontalFrame | kFixedWidth);
+ if(DBGSIG > 1) outsidebox->SetBackgroundColor(0);
+ widgetTE = new TGTextEntry(outsidebox, deftext);
+ widgetTE->Resize(w-12,22);
+ outsidebox->AddFrame(widgetTE, f0expandX);
+ widgetTB[0] = new TGTextButton(outsidebox, buttext);
+ widgetTB[0]->SetTextJustify(36);
+ widgetTB[0]->SetWrapLength(-1);
+ widgetTB[0]->Resize(60,22);
+ outsidebox->AddFrame(widgetTB[0], f0);
+
+ if(DBGSIG > 1) printf("id = %d\n",id);
+
+ return true;
+}
+
+// Widget with Label and Dropdown menu
+bool TSubStructure::TGLabelDrop(TGWindow *parent, int w, int h, const char *label, int nrentries, const char *entrytext[512], const char *selecttext)
+{
+ id = 5;
+
+ f0 = new TGLayoutHints(kLHintsLeft | kLHintsCenterY,2,2,2,2);
+ f0expandX = new TGLayoutHints(kLHintsExpandX | kLHintsCenterY,6,2,2,2);
+
+ int sel = 0;
+
+ outsidebox = new TGCompositeFrame(parent, w-6, h, kHorizontalFrame | kFixedWidth);
+ if(DBGSIG > 1) outsidebox->SetBackgroundColor(0);
+ lab = new TGLabel(outsidebox, label);
+ outsidebox->AddFrame(lab, f0);
+ widgetCB = new TGComboBox(outsidebox, 200);
+ for(int i = 0; i < nrentries; i++)
+ {
+ widgetCB->AddEntry(entrytext[i], i);
+ if( strcmp(entrytext[i], selecttext) == 0 )
+ sel = i;
+ }
+ widgetCB->Resize(50,22);
+ widgetCB->Select(sel);
+ outsidebox->AddFrame(widgetCB, f0expandX);
+
+ if(DBGSIG > 1) printf("id = %d\n",id);
+
+ return true;
+}
+
+// Widget with 2 or more buttons (up to 6)
+bool TSubStructure::TGMultiButton(TGWindow *parent, int w, int h, int nrbuttons, const char *buttext[512], const char *pos)
+{
+ id = 6;
+
+ if(nrbuttons > 6) return false;
+
+ f0 = new TGLayoutHints(kLHintsLeft | kLHintsCenterY,2,2,2,2);
+ f1 = new TGLayoutHints(kLHintsLeft | kLHintsCenterY,6,2,2,2);
+ if(strcmp("left",pos) == 0)
+ f2 = new TGLayoutHints(kLHintsLeft,0,0,0,0);
+ else if(strcmp("center",pos) == 0)
+ f2 = new TGLayoutHints(kLHintsCenterX,0,0,0,0);
+ else if(strcmp("right",pos) == 0)
+ f2 = new TGLayoutHints(kLHintsRight,0,0,0,0);
+
+ outsidebox = new TGCompositeFrame(parent, w-6, h, kHorizontalFrame | kFixedWidth);
+ if(DBGSIG > 1) outsidebox->SetBackgroundColor(0);
+ fH1 = new TGHorizontalFrame(outsidebox, 100, h);
+ if(DBGSIG > 1) fH1->SetBackgroundColor(200);
+ for(int i = 0; i < nrbuttons; i++)
+ {
+ widgetTB[i] = new TGTextButton(fH1, buttext[i]);
+ widgetTB[i]->SetTextJustify(36);
+ widgetTB[i]->SetWrapLength(-1);
+ widgetTB[i]->Resize((w-6-8)/nrbuttons,22);
+ if(i == 0) fH1->AddFrame(widgetTB[i], f0);
+ else fH1->AddFrame(widgetTB[i], f1);
+ }
+ outsidebox->AddFrame(fH1, f2);
+
+ if(DBGSIG > 1) printf("id = %d\n",id);
+
+ return true;
+}
+
+// Widget with Label and two Number Entries
+bool TSubStructure::TGLabelDoubleNEntry(TGWindow *parent, int w, int h, const char *label, double defval1, double *format1, double defval2, double *format2, const char *pos)
+{
+ id = 7;
+
+ TGNumberFormat::EStyle numtype1, numtype2;
+ TGNumberFormat::EAttribute negpos1, negpos2;
+ TGNumberFormat::ELimit numlim1, numlim2;
+ bool arelimits[] = {false,false,false,false};
+
+ // Number type (integer, real)
+ if( (int)format1[1] == 0 ) numtype1 = TGNumberFormat::kNESInteger;
+ else if( (int)format1[1] == 1 ) numtype1 = TGNumberFormat::kNESRealOne;
+ else if( (int)format1[1] == 2 ) numtype1 = TGNumberFormat::kNESRealTwo;
+ else if( (int)format1[1] == 3 ) numtype1 = TGNumberFormat::kNESRealThree;
+ else if( (int)format1[1] == 4 ) numtype1 = TGNumberFormat::kNESRealFour;
+ else if( (int)format1[1] == -1 ) numtype1 = TGNumberFormat::kNESReal;
+
+ if( (int)format2[1] == 0 ) numtype2 = TGNumberFormat::kNESInteger;
+ else if( (int)format2[1] == 1 ) numtype2 = TGNumberFormat::kNESRealOne;
+ else if( (int)format2[1] == 2 ) numtype2 = TGNumberFormat::kNESRealTwo;
+ else if( (int)format2[1] == 3 ) numtype2 = TGNumberFormat::kNESRealThree;
+ else if( (int)format2[1] == 4 ) numtype2 = TGNumberFormat::kNESRealFour;
+ else if( (int)format2[1] == -1 ) numtype2 = TGNumberFormat::kNESReal;
+
+ // Negative or positive
+ if( (int)format1[2] == 0 ) negpos1 = TGNumberFormat::kNEAAnyNumber;
+ else if( (int)format1[2] == 1 ) negpos1 = TGNumberFormat::kNEAPositive;
+ else if( (int)format1[2] == 2 ) negpos1 = TGNumberFormat::kNEANonNegative;
+
+ if( (int)format2[2] == 0 ) negpos2 = TGNumberFormat::kNEAAnyNumber;
+ else if( (int)format2[2] == 1 ) negpos2 = TGNumberFormat::kNEAPositive;
+ else if( (int)format2[2] == 2 ) negpos2 = TGNumberFormat::kNEANonNegative;
+
+ // Limits
+ if( (int)format1[3] == 0 ) numlim1 = TGNumberFormat::kNELNoLimits;
+ else if( (int)format1[3] == 1 ) { numlim1 = TGNumberFormat::kNELLimitMax; arelimits[1] = true; }
+ else if( (int)format1[3] == 2 ) { numlim1 = TGNumberFormat::kNELLimitMinMax; arelimits[0] = true; arelimits[1] = true; }
+ else if( (int)format1[3] == -1 ) { numlim1 = TGNumberFormat::kNELLimitMin; arelimits[0] = true; }
+
+ if( (int)format2[3] == 0 ) numlim2 = TGNumberFormat::kNELNoLimits;
+ else if( (int)format2[3] == 1 ) { numlim2 = TGNumberFormat::kNELLimitMax; arelimits[3] = true; }
+ else if( (int)format2[3] == 2 ) { numlim2 = TGNumberFormat::kNELLimitMinMax; arelimits[2] = true; arelimits[3] = true; }
+ else if( (int)format2[3] == -1 ) { numlim2 = TGNumberFormat::kNELLimitMin; arelimits[2] = true; }
+
+ f0 = new TGLayoutHints(kLHintsLeft | kLHintsCenterY,2,2,2,2);
+ f1 = new TGLayoutHints(kLHintsLeft | kLHintsCenterY,6,2,2,2);
+ if(strcmp("left",pos) == 0)
+ f2 = new TGLayoutHints(kLHintsLeft,0,0,0,0);
+ else if(strcmp("center",pos) == 0)
+ f2 = new TGLayoutHints(kLHintsCenterX,0,0,0,0);
+ else if(strcmp("right",pos) == 0)
+ f2 = new TGLayoutHints(kLHintsRight,0,0,0,0);
+
+ outsidebox = new TGCompositeFrame(parent, w-6, h, kHorizontalFrame | kFixedWidth);
+ if(DBGSIG > 1) outsidebox->SetBackgroundColor(0);
+ fH1 = new TGHorizontalFrame(outsidebox, 100, h);
+ if(DBGSIG > 1) fH1->SetBackgroundColor(200);
+ lab = new TGLabel(fH1, label);
+ fH1->AddFrame(lab, f0);
+ if( (int)format1[1] == 0 )
+ {
+ if( arelimits[0] && arelimits[1] )
+ widgetNE[0] = new TGNumberEntry(fH1, (int)defval1, (int)format1[0], 999, numtype1, negpos1, numlim1, (int)format1[4], (int)format1[5]);
+ else if( arelimits[0] )
+ widgetNE[0] = new TGNumberEntry(fH1, (int)defval1, (int)format1[0], 999, numtype1, negpos1, numlim1, (int)format1[4], 0);
+ else if( arelimits[1] )
+ widgetNE[0] = new TGNumberEntry(fH1, (int)defval1, (int)format1[0], 999, numtype1, negpos1, numlim1, 0, (int)format1[4]);
+ else
+ widgetNE[0] = new TGNumberEntry(fH1, (int)defval1, (int)format1[0], 999, numtype1, negpos1, numlim1);
+ }
+ else if( (((int)format1[1] > 0) && ((int)format1[1] < 5)) || ((int)format1[1] == -1) )
+ {
+ if( arelimits[0] && arelimits[1] )
+ widgetNE[0] = new TGNumberEntry(fH1, defval1, (int)format1[0], 999, numtype1, negpos1, numlim1, format1[4], format1[5]);
+ else if( arelimits[0] )
+ widgetNE[0] = new TGNumberEntry(fH1, defval1, (int)format1[0], 999, numtype1, negpos1, numlim1, format1[4], 0);
+ else if( arelimits[1] )
+ widgetNE[0] = new TGNumberEntry(fH1, defval1, (int)format1[0], 999, numtype1, negpos1, numlim1, 0, format1[4]);
+ else
+ widgetNE[0] = new TGNumberEntry(fH1, defval1, (int)format1[0], 999, numtype1, negpos1, numlim1);
+ }
+ fH1->AddFrame(widgetNE[0], f1);
+
+ if( (int)format2[1] == 0 )
+ {
+ if( arelimits[2] && arelimits[3] )
+ widgetNE[1] = new TGNumberEntry(fH1, (int)defval2, (int)format2[0], 999, numtype2, negpos2, numlim2, (int)format2[4], (int)format2[5]);
+ else if( arelimits[2] )
+ widgetNE[1] = new TGNumberEntry(fH1, (int)defval2, (int)format2[0], 999, numtype2, negpos2, numlim2, (int)format2[4], 0);
+ else if( arelimits[3] )
+ widgetNE[1] = new TGNumberEntry(fH1, (int)defval2, (int)format2[0], 999, numtype2, negpos2, numlim2, 0, (int)format2[4]);
+ else
+ widgetNE[1] = new TGNumberEntry(fH1, (int)defval2, (int)format2[0], 999, numtype2, negpos2, numlim2);
+ }
+ else if( (((int)format2[1] > 0) && ((int)format2[1] < 5)) || ((int)format2[1] == -1) )
+ {
+ if( arelimits[2] && arelimits[3] )
+ widgetNE[1] = new TGNumberEntry(fH1, defval2, (int)format2[0], 999, numtype2, negpos2, numlim2, format2[4], format2[5]);
+ else if( arelimits[2] )
+ widgetNE[1] = new TGNumberEntry(fH1, defval2, (int)format2[0], 999, numtype2, negpos2, numlim2, format2[4], 0);
+ else if( arelimits[3] )
+ widgetNE[1] = new TGNumberEntry(fH1, defval2, (int)format2[0], 999, numtype2, negpos2, numlim2, 0, format2[4]);
+ else
+ widgetNE[1] = new TGNumberEntry(fH1, defval2, (int)format2[0], 999, numtype2, negpos2, numlim2);
+ }
+ else
+ {
+ delete outsidebox;
+ delete lab;
+ return false;
+ }
+ fH1->AddFrame(widgetNE[1], f1);
+ outsidebox->AddFrame(fH1, f2);
+
+ if(DBGSIG > 1) printf("id = %d\n",id);
+
+ return true;
+}
+
+// Widget with 1 or more check boxes (up to 9)
+bool TSubStructure::TGCheckList(TGWindow *parent, int w, int h, int nrchecks, const char *labels[512], int *onoff, const char *layout, const char *pos)
+{
+ id = 8;
+
+ if(nrchecks > 8) return false;
+
+ f0 = new TGLayoutHints(kLHintsLeft | kLHintsCenterY,2,2,2,2);
+ f1 = new TGLayoutHints(kLHintsLeft | kLHintsCenterY,6,2,2,2);
+ if(strcmp("left",pos) == 0)
+ f2 = new TGLayoutHints(kLHintsLeft,0,0,0,0);
+ else if(strcmp("center",pos) == 0)
+ f2 = new TGLayoutHints(kLHintsCenterX,0,0,0,0);
+ else if(strcmp("right",pos) == 0)
+ f2 = new TGLayoutHints(kLHintsRight,0,0,0,0);
+
+ if(strcmp("left",pos) == 0)
+ f3 = new TGLayoutHints(kLHintsLeft,2,2,2,2);
+ else if(strcmp("center",pos) == 0)
+ f3 = new TGLayoutHints(kLHintsCenterX,2,2,2,2);
+ else if(strcmp("right",pos) == 0)
+ f3 = new TGLayoutHints(kLHintsRight,2,2,2,2);
+
+ if(strcmp("horizontal", layout) == 0)
+ {
+ outsidebox = new TGCompositeFrame(parent, w-6, h, kHorizontalFrame | kFixedWidth);
+ if(DBGSIG > 1) outsidebox->SetBackgroundColor(0);
+ fH1 = new TGHorizontalFrame(outsidebox, 100, h);
+ if(DBGSIG > 1) fH1->SetBackgroundColor(200);
+
+ for(int i = 0; i < nrchecks; i++)
+ {
+ widgetChBox[i] = new TGCheckButton(fH1, labels[i]);
+ if(onoff[i] == 0)
+ widgetChBox[i]->SetState(kButtonUp);
+ else if(onoff[i] == 1)
+ widgetChBox[i]->SetState(kButtonDown);
+ widgetChBox[i]->Resize((w-6-8)/nrchecks,22);
+ if(i == 0) fH1->AddFrame(widgetChBox[i], f0);
+ else fH1->AddFrame(widgetChBox[i], f1);
+ }
+
+ outsidebox->AddFrame(fH1, f2);
+ }
+ else if(strcmp("vertical", layout) == 0)
+ {
+ outsidebox = new TGCompositeFrame(parent, w-6, h, kVerticalFrame | kFixedWidth);
+ if(DBGSIG > 1) outsidebox->SetBackgroundColor(0);
+
+ for(int i = 0; i < nrchecks; i++)
+ {
+ widgetChBox[i] = new TGCheckButton(outsidebox, labels[i]);
+ if(onoff[i] == 0)
+ widgetChBox[i]->SetState(kButtonUp);
+ else if(onoff[i] == 1)
+ widgetChBox[i]->SetState(kButtonDown);
+ widgetChBox[i]->Resize((w-6-8)/nrchecks,22);
+ outsidebox->AddFrame(widgetChBox[i], f3);
+ }
+ }
+ else if(strcmp("twoline", layout) == 0)
+ {
+ outsidebox = new TGCompositeFrame(parent, w-6, h, kVerticalFrame | kFixedWidth);
+ if(DBGSIG > 1) outsidebox->SetBackgroundColor(0);
+ fH1 = new TGHorizontalFrame(outsidebox, 100, h);
+ if(DBGSIG > 1) fH1->SetBackgroundColor(200);
+
+ for(int i = 0; i < TMath::Ceil(nrchecks/2.); i++)
+ {
+ widgetChBox[i] = new TGCheckButton(fH1, labels[i]);
+ if(onoff[i] == 0)
+ widgetChBox[i]->SetState(kButtonUp);
+ else if(onoff[i] == 1)
+ widgetChBox[i]->SetState(kButtonDown);
+ widgetChBox[i]->Resize((w-6-8)/nrchecks,22);
+ if(i == 0) fH1->AddFrame(widgetChBox[i], f0);
+ else fH1->AddFrame(widgetChBox[i], f1);
+ }
+ outsidebox->AddFrame(fH1, f2);
+
+ fH1 = new TGHorizontalFrame(outsidebox, 100, h);
+ if(DBGSIG > 1) fH1->SetBackgroundColor(200);
+
+ for(int i = TMath::Ceil(nrchecks/2.); i < nrchecks; i++)
+ {
+ widgetChBox[i] = new TGCheckButton(fH1, labels[i]);
+ if(onoff[i] == 0)
+ widgetChBox[i]->SetState(kButtonUp);
+ else if(onoff[i] == 1)
+ widgetChBox[i]->SetState(kButtonDown);
+ widgetChBox[i]->Resize((w-6-8)/nrchecks,22);
+ if(i == TMath::Ceil(nrchecks/2.)) fH1->AddFrame(widgetChBox[i], f0);
+ else fH1->AddFrame(widgetChBox[i], f1);
+ }
+ outsidebox->AddFrame(fH1, f2);
+ }
+ else if(strcmp("threeline", layout) == 0)
+ {
+ outsidebox = new TGCompositeFrame(parent, w-6, h, kVerticalFrame | kFixedWidth);
+ if(DBGSIG > 1) outsidebox->SetBackgroundColor(0);
+ fH1 = new TGHorizontalFrame(outsidebox, 100, h);
+ if(DBGSIG > 1) fH1->SetBackgroundColor(200);
+
+ for(int i = 0; i < TMath::Ceil(nrchecks/3.); i++)
+ {
+ widgetChBox[i] = new TGCheckButton(fH1, labels[i]);
+ if(onoff[i] == 0)
+ widgetChBox[i]->SetState(kButtonUp);
+ else if(onoff[i] == 1)
+ widgetChBox[i]->SetState(kButtonDown);
+ widgetChBox[i]->Resize((w-6-8)/nrchecks,22);
+ if(i == 0) fH1->AddFrame(widgetChBox[i], f0);
+ else fH1->AddFrame(widgetChBox[i], f1);
+ }
+ outsidebox->AddFrame(fH1, f2);
+
+ fH1 = new TGHorizontalFrame(outsidebox, 100, h);
+ if(DBGSIG > 1) fH1->SetBackgroundColor(200);
+
+ for(int i = TMath::Ceil(nrchecks/3.); i < TMath::Ceil(2.*nrchecks/3.); i++)
+ {
+ widgetChBox[i] = new TGCheckButton(fH1, labels[i]);
+ if(onoff[i] == 0)
+ widgetChBox[i]->SetState(kButtonUp);
+ else if(onoff[i] == 1)
+ widgetChBox[i]->SetState(kButtonDown);
+ widgetChBox[i]->Resize((w-6-8)/nrchecks,22);
+ if(i == TMath::Ceil(nrchecks/3.)) fH1->AddFrame(widgetChBox[i], f0);
+ else fH1->AddFrame(widgetChBox[i], f1);
+ }
+ outsidebox->AddFrame(fH1, f2);
+
+ fH1 = new TGHorizontalFrame(outsidebox, 100, h);
+ if(DBGSIG > 1) fH1->SetBackgroundColor(200);
+
+ for(int i = TMath::Ceil(2.*nrchecks/3.); i < nrchecks; i++)
+ {
+ widgetChBox[i] = new TGCheckButton(fH1, labels[i]);
+ if(onoff[i] == 0)
+ widgetChBox[i]->SetState(kButtonUp);
+ else if(onoff[i] == 1)
+ widgetChBox[i]->SetState(kButtonDown);
+ widgetChBox[i]->Resize((w-6-8)/nrchecks,22);
+ if(i == TMath::Ceil(2.*nrchecks/3.)) fH1->AddFrame(widgetChBox[i], f0);
+ else fH1->AddFrame(widgetChBox[i], f1);
+ }
+ outsidebox->AddFrame(fH1, f2);
+ }
+ else
+ return false;
+
+ if(DBGSIG > 1) printf("id = %d\n",id);
+
+ return true;
+}
+
+// Widget with Button and horizontal progress bar
+bool TSubStructure::TGButtonProgress(TGWindow *parent, int w, int h, const char *buttext = "Set")
+{
+ id = 9;
+
+ f0 = new TGLayoutHints(kLHintsLeft | kLHintsCenterY,2,2,2,2);
+ f1 = new TGLayoutHints(kLHintsLeft | kLHintsCenterY,20,2,2,2);
+ f2 = new TGLayoutHints(kLHintsCenterX,0,0,0,0);
+
+ outsidebox = new TGCompositeFrame(parent, w-6, h, kHorizontalFrame | kFixedWidth);
+ if(DBGSIG > 1) outsidebox->SetBackgroundColor(0);
+ fH1 = new TGHorizontalFrame(outsidebox, 100, h);
+ if(DBGSIG > 1) fH1->SetBackgroundColor(200);
+ widgetTB[0] = new TGTextButton(fH1, buttext);
+ widgetTB[0]->SetTextJustify(36);
+ widgetTB[0]->SetWrapLength(-1);
+ widgetTB[0]->Resize(60,22);
+ fH1->AddFrame(widgetTB[0], f0);
+ widgetPB = new TGHProgressBar(fH1, TGProgressBar::kStandard, w/2);
+ widgetPB->ShowPosition();
+ widgetPB->SetRange(0,100);
+ widgetPB->SetBarColor("green");
+ fH1->AddFrame(widgetPB, f1);
+
+ outsidebox->AddFrame(fH1, f2);
+
+ if(DBGSIG > 1) printf("id = %d\n",id);
+
+ return true;
+}
+
+// Widget with Button and horizontal progress bar
+bool TSubStructure::TGButtonProgressTEntry(TGWindow *parent, int w, int h, const char *buttext = "Set", const char *deftext = "Remaining time: ")
+{
+ id = 11;
+
+ f0 = new TGLayoutHints(kLHintsLeft | kLHintsCenterY,2,2,2,2);
+ f0expandX = new TGLayoutHints(kLHintsExpandX | kLHintsCenterY,20,2,2,2);
+ f1 = new TGLayoutHints(kLHintsLeft | kLHintsCenterY,20,2,2,2);
+ f2 = new TGLayoutHints(kLHintsCenterX,0,0,0,0);
+
+ outsidebox = new TGCompositeFrame(parent, w-6, h, kHorizontalFrame | kFixedWidth);
+ if(DBGSIG > 1) outsidebox->SetBackgroundColor(0);
+ fH1 = new TGHorizontalFrame(outsidebox, 5*w/6, h, kFixedWidth);
+ if(DBGSIG > 1) fH1->SetBackgroundColor(200);
+ widgetTB[0] = new TGTextButton(fH1, buttext);
+ widgetTB[0]->SetTextJustify(36);
+ widgetTB[0]->SetWrapLength(-1);
+ widgetTB[0]->Resize(60,22);
+ fH1->AddFrame(widgetTB[0], f0);
+ widgetPB = new TGHProgressBar(fH1, TGProgressBar::kStandard, w/4);
+ widgetPB->ShowPosition();
+ widgetPB->SetRange(0,100);
+ widgetPB->SetBarColor("green");
+ fH1->AddFrame(widgetPB, f1);
+ widgetTE = new TGTextEntry(fH1, deftext);
+ fH1->AddFrame(widgetTE, f0expandX);
+
+ outsidebox->AddFrame(fH1, f2);
+
+ if(DBGSIG > 1) printf("id = %d\n",id);
+
+ return true;
+}
+
+// Widget with Label and horizontal progress bar
+bool TSubStructure::TGLabelProgress(TGWindow *parent, int w, int h, const char *label)
+{
+ id = 10;
+
+ f0 = new TGLayoutHints(kLHintsLeft | kLHintsCenterY,2,2,2,2);
+ f1 = new TGLayoutHints(kLHintsLeft | kLHintsCenterY,20,2,2,2);
+ f2 = new TGLayoutHints(kLHintsCenterX,0,0,0,0);
+
+ outsidebox = new TGCompositeFrame(parent, w-6, h, kHorizontalFrame | kFixedWidth);
+ if(DBGSIG > 1) outsidebox->SetBackgroundColor(0);
+ fH1 = new TGHorizontalFrame(outsidebox, 100, h);
+ if(DBGSIG > 1) fH1->SetBackgroundColor(200);
+ lab = new TGLabel(fH1, label);
+ fH1->AddFrame(lab, f0);
+ widgetPB = new TGHProgressBar(fH1, TGProgressBar::kStandard, w/2);
+ widgetPB->ShowPosition();
+ widgetPB->SetRange(0,100);
+ widgetPB->SetBarColor("green");
+ fH1->AddFrame(widgetPB, f1);
+
+ outsidebox->AddFrame(fH1, f2);
+
+ if(DBGSIG > 1) printf("id = %d\n",id);
+
+ return true;
+}
+
+// Widget with checkbutton and number entry
+bool TSubStructure::TGCheckNEntry(TGWindow *parent, int w, int h, const char *label, int onoff, double defval, double *format, const char *pos)
+{
+ id = 12;
+
+ TGNumberFormat::EStyle numtype;
+ TGNumberFormat::EAttribute negpos;
+ TGNumberFormat::ELimit numlim;
+ bool arelimits[] = {false,false};
+
+ // Number type (integer, real)
+ if( (int)format[1] == 0 ) numtype = TGNumberFormat::kNESInteger;
+ else if( (int)format[1] == 1 ) numtype = TGNumberFormat::kNESRealOne;
+ else if( (int)format[1] == 2 ) numtype = TGNumberFormat::kNESRealTwo;
+ else if( (int)format[1] == 3 ) numtype = TGNumberFormat::kNESRealThree;
+ else if( (int)format[1] == 4 ) numtype = TGNumberFormat::kNESRealFour;
+ else if( (int)format[1] == -1 ) numtype = TGNumberFormat::kNESReal;
+
+ // Negative or positive
+ if( (int)format[2] == 0 ) negpos = TGNumberFormat::kNEAAnyNumber;
+ else if( (int)format[2] == 1 ) negpos = TGNumberFormat::kNEAPositive;
+ else if( (int)format[2] == 2 ) negpos = TGNumberFormat::kNEANonNegative;
+
+ // Limits
+ if( (int)format[3] == 0 ) numlim = TGNumberFormat::kNELNoLimits;
+ else if( (int)format[3] == 1 ) { numlim = TGNumberFormat::kNELLimitMax; arelimits[1] = true; }
+ else if( (int)format[3] == 2 ) { numlim = TGNumberFormat::kNELLimitMinMax; arelimits[0] = true; arelimits[1] = true; }
+ else if( (int)format[3] == -1 ) { numlim = TGNumberFormat::kNELLimitMin; arelimits[0] = true; }
+
+ f0 = new TGLayoutHints(kLHintsLeft | kLHintsCenterY,2,2,2,2);
+ f1 = new TGLayoutHints(kLHintsLeft | kLHintsCenterY,6,2,2,2);
+ if(strcmp("left",pos) == 0)
+ f2 = new TGLayoutHints(kLHintsLeft,0,0,0,0);
+ else if(strcmp("center",pos) == 0)
+ f2 = new TGLayoutHints(kLHintsCenterX,0,0,0,0);
+ else if(strcmp("right",pos) == 0)
+ f2 = new TGLayoutHints(kLHintsRight,0,0,0,0);
+
+ outsidebox = new TGCompositeFrame(parent, w-6, h, kHorizontalFrame | kFixedWidth);
+ if(DBGSIG > 1) outsidebox->SetBackgroundColor(0);
+ fH1 = new TGHorizontalFrame(outsidebox, 100, h);
+ if(DBGSIG > 1) fH1->SetBackgroundColor(200);
+ widgetChBox[0] = new TGCheckButton(fH1, label);
+ if(onoff == 0)
+ widgetChBox[0]->SetState(kButtonUp);
+ else if(onoff == 1)
+ widgetChBox[0]->SetState(kButtonDown);
+// widgetChBox[0]->Resize(w-14,22);
+ fH1->AddFrame(widgetChBox[0], f0);
+ if( (int)format[1] == 0 )
+ {
+ if( arelimits[0] && arelimits[1] )
+ widgetNE[0] = new TGNumberEntry(fH1, (int)defval, (int)format[0], 999, numtype, negpos, numlim, (int)format[4], (int)format[5]);
+ else if( arelimits[0] )
+ widgetNE[0] = new TGNumberEntry(fH1, (int)defval, (int)format[0], 999, numtype, negpos, numlim, (int)format[4], 0);
+ else if( arelimits[1] )
+ widgetNE[0] = new TGNumberEntry(fH1, (int)defval, (int)format[0], 999, numtype, negpos, numlim, 0, (int)format[4]);
+ else
+ widgetNE[0] = new TGNumberEntry(fH1, (int)defval, (int)format[0], 999, numtype, negpos, numlim);
+ }
+ else if( (((int)format[1] > 0) && ((int)format[1] < 5)) || ((int)format[1] == -1) )
+ {
+ if( arelimits[0] && arelimits[1] )
+ widgetNE[0] = new TGNumberEntry(fH1, defval, (int)format[0], 999, numtype, negpos, numlim, format[4], format[5]);
+ else if( arelimits[0] )
+ widgetNE[0] = new TGNumberEntry(fH1, defval, (int)format[0], 999, numtype, negpos, numlim, format[4], 0);
+ else if( arelimits[1] )
+ widgetNE[0] = new TGNumberEntry(fH1, defval, (int)format[0], 999, numtype, negpos, numlim, 0, format[4]);
+ else
+ widgetNE[0] = new TGNumberEntry(fH1, defval, (int)format[0], 999, numtype, negpos, numlim);
+ }
+ else
+ {
+ delete outsidebox;
+ delete lab;
+ return false;
+ }
+ fH1->AddFrame(widgetNE[0], f1);
+ outsidebox->AddFrame(fH1, f2);
+
+ if(DBGSIG > 1) printf("id = %d\n",id);
+
+ return true;
+}
+
+// Widget with checkbutton and text entry
+bool TSubStructure::TGCheckTEntry(TGWindow *parent, int w, int h, const char *label, int onoff, const char *deftext, const char *layout)
+{
+ id = 13;
+
+ f0 = new TGLayoutHints(kLHintsLeft | kLHintsCenterY,2,2,2,2);
+
+ if(strcmp("oneline", layout) == 0)
+ {
+ outsidebox = new TGCompositeFrame(parent, w-6, h, kHorizontalFrame | kFixedWidth);
+ if(DBGSIG > 1) outsidebox->SetBackgroundColor(0);
+ f0expandX = new TGLayoutHints(kLHintsExpandX | kLHintsCenterY,6,2,2,2);
+ }
+ else if(strcmp("twoline", layout) == 0)
+ {
+ outsidebox = new TGCompositeFrame(parent, w-6, h, kVerticalFrame | kFixedWidth);
+ if(DBGSIG > 1) outsidebox->SetBackgroundColor(0);
+ f0expandX = new TGLayoutHints(kLHintsExpandX | kLHintsCenterY,0,2,2,2);
+ }
+
+ widgetChBox[0] = new TGCheckButton(outsidebox, label);
+ if(onoff == 0)
+ widgetChBox[0]->SetState(kButtonUp);
+ else if(onoff == 1)
+ widgetChBox[0]->SetState(kButtonDown);
+ outsidebox->AddFrame(widgetChBox[0], f0);
+ widgetTE = new TGTextEntry(outsidebox, deftext);
+ outsidebox->AddFrame(widgetTE, f0expandX);
+
+ if(DBGSIG > 1) printf("id = %d\n",id);
+
+ return true;
+}
Index: sipmscan/trunk/src/tooltips.cpp
===================================================================
--- sipmscan/trunk/src/tooltips.cpp (nonexistent)
+++ sipmscan/trunk/src/tooltips.cpp (revision 146)
@@ -0,0 +1,253 @@
+#include "../include/sipmscan.h"
+#include "../include/workstation.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+void TGAppMainFrame::ToolTipSet()
+{
+ // Measurement ----------------------------------------------------------------------
+ // Settings pane tooltips
+ scansOn->widgetChBox[0]->
+ SetToolTipText("If checked, perform scan over a range of voltages, set by V(min),\nV(max) and V(step) in the \"Main measurement window\".\nIf no scans are selected, a single measurement is performed.");
+ scansOn->widgetChBox[1]->
+ SetToolTipText("If checked, perform surface scan over the samples\nby moving the laser in X and Y directions.\nIf no scans are selected, a single measurement is performed.");
+ scansOn->widgetChBox[2]->
+ SetToolTipText("If checked, perform scan over a range of Z axis values, set by\nZ(min), Z(max) and Z(step) in the \"Main measurement window\".\nIf no scans are selected, a single measurement is performed.");
+ scansOn->widgetChBox[3]->
+ SetToolTipText("If checked, perform scan over a range of incidence angle values, set by\nAngle(min), Angle(max) and Angle(step) in the \"Main measurement window\".\nIf no scans are selected, a single measurement is performed.");
+ vHardlimit->widgetNE[0]->GetNumberEntry()->
+ SetToolTipText("Maximal limit for \"Output Voltage\" to\navoid any unwanted bias voltages.");
+ NCH->widgetNE[0]->GetNumberEntry()->
+ SetToolTipText("Number of channels to be acquired (limited to 8).");
+// posUnits->widgetCB->SetToolTipText("Table controllers use their own units (1 = 0.3595 microns).\nSelect units you wish to use.");
+ oscConnect->widgetTE->
+ SetToolTipText("Enable use of an oscilloscope that is\nconnected to the network with VXI11.");
+ oscConnect->widgetTB[0]->
+ SetToolTipText("Enable use of an oscilloscope that is\nconnected to the network with VXI11.");
+ laserInfo->widgetTE->
+ SetToolTipText("Additional information (laser, in particular)\nthat will be written to header of output files.");
+ chtemp->widgetNE[0]->GetNumberEntry()->
+ SetToolTipText("Temperature inside the chamber (this value\nis written to header of output files).");
+ liveDisp->widgetChBox[0]->
+ SetToolTipText("If checked, update the measured ADC histogram during\na measurement in the below \"Display window\".");
+
+ // Main measurement pane tooltips
+ vOutOpt->widgetChBox[0]->
+ SetToolTipText("If checked, the polarity of bias voltage\nwill be reversed (only negative values).");
+ vOutOpt->widgetChBox[1]->
+ SetToolTipText("If checked, the supplied bias voltage\nwill be enabled after pressing \"Set\".");
+ vOut->widgetNE[0]->GetNumberEntry()->
+ SetToolTipText("Bias voltage supplied to the sample (will be changed after pressing \"Set\").\nFor safety, the maximal value is set by \"Voltage limit\" in the \"Settings pane\").");
+ vOutButtons->widgetTB[0]->
+ SetToolTipText("Set the value of \"Output voltage\" to the currently selected\n\"Output channel\" for the supplied bias voltage.");
+ vOutButtons->widgetTB[1]->
+ SetToolTipText("Get the current value of bias voltage for\nthe currently selected \"Output channel\".");
+ vOutButtons->widgetTB[2]->
+ SetToolTipText("Reset the currently selected \"Output channel\". Only use, if there is a problem\nwith the bias voltage supply (interlock state on http://f9mpod.ijs.si).");
+ vOutStart->widgetNE[0]->GetNumberEntry()->
+ SetToolTipText("Starting bias voltage for a voltage scan.");
+ vOutStop->widgetNE[0]->GetNumberEntry()->
+ SetToolTipText("Finishing bias voltage for a voltage scan.");
+ vOutStep->widgetNE[0]->GetNumberEntry()->
+ SetToolTipText("Bias voltage step for a voltage scan. If \"V(max)-V(min)\" is not a multiple of V(step),\nthe finishing bias voltage will always be lower. If V(step) is 0, only a single\nmeasurement will be performed.\nFor more information, check under \"Voltage supply\" in the \"Help\" file.");
+
+ xPos->widgetNE[0]->GetNumberEntry()->
+ SetToolTipText("X axis position of the movement table (in units\nset by \"Position units\" in the \"Settings pane\").");
+ yPos->widgetNE[0]->GetNumberEntry()->
+ SetToolTipText("Y axis position of the movement table (in units\nset by \"Position units\" in the \"Settings pane\").");
+ zPos->widgetNE[0]->GetNumberEntry()->
+ SetToolTipText("Z axis position of the movement table (in units\nset by \"Position units\" in the \"Settings pane\").");
+ xPosMin->widgetNE[0]->GetNumberEntry()->
+ SetToolTipText("Starting X axis movement table position for a surface scan.");
+ xPosMax->widgetNE[0]->GetNumberEntry()->
+ SetToolTipText("Finishing X axis movement table position for a surface scan.");
+ xPosStep->widgetNE[0]->GetNumberEntry()->
+ SetToolTipText("X axis step for a surface scan. If \"X(max)-X(min)\" is not a multiple of X(step), the\nfinishing X axis position will always be lower. If X(step) is 0, only a single\nmeasurement will be performed.");
+ yPosMin->widgetNE[0]->GetNumberEntry()->
+ SetToolTipText("Starting Y axis movement table position for a surface scan.");
+ yPosMax->widgetNE[0]->GetNumberEntry()->
+ SetToolTipText("Finishing Y axis movement table position for a surface scan.");
+ yPosStep->widgetNE[0]->GetNumberEntry()->
+ SetToolTipText("Y axis step for a surface scan. If \"Y(max)-Y(min)\" is not a multiple of Y(step), the\nfinishing Y axis position will always be lower. If Y(step) is 0, only a single\nmeasurement will be performed.");
+ zPosMin->widgetNE[0]->GetNumberEntry()->
+ SetToolTipText("Starting Z axis movement table position for a Z-axis scan.");
+ zPosMax->widgetNE[0]->GetNumberEntry()->
+ SetToolTipText("Finishing Z axis movement table position for a Z-axis scan.");
+ zPosStep->widgetNE[0]->GetNumberEntry()->
+ SetToolTipText("Z axis step for a Z-axis scan. If \"Z(max)-Z(min)\" is not a multiple of Z(step), the\nfinishing Z axis position will always be lower. If Z(step) is 0, only a single\nmeasurement will be performed.");
+ posButtons->widgetTB[0]->
+ SetToolTipText("Set the position (X, Y and Z) of the movement table.");
+ posButtons->widgetTB[1]->
+ SetToolTipText("Get the current position (X, Y and Z) of the movement table.");
+ posButtons->widgetTB[2]->
+ SetToolTipText("Move the movement table to its predetermined initial position (home).");
+ posButtons->widgetTB[3]->
+ SetToolTipText("Reset, initialize and home all controllers for the movement table. Only use,\nif there is a problem with moving the table. If further problems\noccur, check under \"Movement table\" in the \"Help\" file.");
+
+ rotPos->widgetNE[0]->GetNumberEntry()->
+ SetToolTipText("Incidence angle of the laser onto the sample (in units set by \"Rotation units\" in the\n\"Settings pane\"). 0 degrees corresponds to perpendicular laser light onto the surface.");
+ rotPosMin->widgetNE[0]->GetNumberEntry()->
+ SetToolTipText("Starting incidence angle for a rotation scan.");
+ rotPosMax->widgetNE[0]->GetNumberEntry()->
+ SetToolTipText("Finishing incidence angle for a rotation scan.");
+ rotPosStep->widgetNE[0]->GetNumberEntry()->
+ SetToolTipText("Incidence angle step for a rotation scan. If \"Angle(max)-Angle(min)\" is not a multiple of\nAngle(step), the finishing incidence angle will always be lower. If Angle(step) is 0,\nonly a single measurement will be performed.");
+ rotButtons->widgetTB[0]->
+ SetToolTipText("Set the incidence angle of the rotation sample holder.");
+ rotButtons->widgetTB[1]->
+ SetToolTipText("Get the current incidence angle of the rotation sample holder.");
+ rotButtons->widgetTB[2]->
+ SetToolTipText("Move the rotation sample holder to angle 0 deg.");
+ rotButtons->widgetTB[3]->
+ SetToolTipText("Reposition to 0 deg, reset and initialize controller for the rotation sample holder.\nOnly use, if there is a problem with moving the table. If further problems\noccur, check under \"Movement table\" in the \"Help\" file.");
+
+ evtNum->widgetNE[0]->GetNumberEntry()->
+ SetToolTipText("Number of events to obtain before stopping data acquisition.");
+ timeStamp->widgetTE->
+ SetToolTipText("Timestamp (date and time of measurement) at start of measurement\n(this value is written to header of output files).");
+ fileName->widgetTE->
+ SetToolTipText("Filename where the current measurement will be saved to (output file).\nScans will have a sequential number appended to the filename.");
+ fileName->widgetTB[0]->
+ SetToolTipText("Change the filename of output file.");
+
+ measProgress->widgetTB[0]->
+ SetToolTipText("Start a new measurement. Stopping a measurement before finishing is\nonly possible for single measurements (not for scans).");
+
+ // Analysis -------------------------------------------------------------------------
+ // Histogram file selection pane
+ selectDir->widgetTB[0]->
+ SetToolTipText("Select a single or multiple files to use them for analysis.");
+ multiSelect->widgetChBox[0]->
+ SetToolTipText("If checked, multiple files can be selected in the above list.");
+ multiSelect->widgetChBox[1]->
+ SetToolTipText("If checked, all files on the above list are selected.");
+ fileListCtrl->widgetTB[0]->
+ SetToolTipText("Move to the previous file on the above list.");
+ fileListCtrl->widgetTB[1]->
+ SetToolTipText("Move to the next file on the above list.");
+ fileListCtrl->widgetTB[2]->
+ SetToolTipText("Open a new tab that enables header editing for any file on the above list.");
+ fileListCtrl->widgetTB[3]->
+ SetToolTipText("Empties the above list of files.");
+ dispTime->widgetTE->
+ SetToolTipText("Measurement time for the selected file from above list.\nOnly works, when \"Multiple file select\" is not checked.");
+ dispBias->widgetNE[0]->GetNumberEntry()->
+ SetToolTipText("Bias voltage for the selected file from above list.\nOnly works, when \"Multiple file select\" is not checked.");
+ dispPos->widgetTE->
+ SetToolTipText("Movement table position (x, Y, Z) of the selected file from above list.\nOnly works, when \"Multiple file select\" is not checked.");
+ dispTemp->widgetNE[0]->GetNumberEntry()->
+ SetToolTipText("Chamber temperature for the selected file from above list.\nOnly works, when \"Multiple file select\" is not checked.");
+ dispAngle->widgetNE[0]->GetNumberEntry()->
+ SetToolTipText("Incidence angle for the selected file from above list.\nOnly works, when \"Multiple file select\" is not checked.");
+ dispLaser->widgetTE->
+ SetToolTipText("Additional information (laser, in particular) of the selected file from above list.\nOnly works, when \"Multiple file select\" is not checked.");
+
+ // Analysis pane
+ intSpect->widgetChBox[0]->
+ SetToolTipText("Perform an integration of the ADC spectrum inside the \"ADC range\"\nfor various X-axis values. Used for edge scans in X-axis direction.");
+ intSpect->widgetChBox[1]->
+ SetToolTipText("Perform an integration of the ADC spectrum inside the \"ADC range\"\nfor various Y-axis values. Used for edge scans in Y-axis direction.");
+ intSpect->widgetChBox[2]->
+ SetToolTipText("Normalize the ADC integral to the number of events ([ADC integral]/[Nr. of events]).");
+ resol2d->widgetNE[0]->GetNumberEntry()->
+ SetToolTipText("Number of pixels in a 2D contour plot parallel to the X axis\n(determines the resolution of the actual image, not the measurement).");
+ resol2d->widgetNE[1]->GetNumberEntry()->
+ SetToolTipText("Number of pixels in a 2D contour plot parallel to the Y axis\n(determines the resolution of the actual image, not the measurement).");
+ intSpectButtons->widgetTB[0]->
+ SetToolTipText("Start the \"Integrate spectrum\" analysis and save\nresults to same folder as selected input files.");
+ intSpectButtons->widgetTB[1]->
+ SetToolTipText("Start the \"Integrate spectrum\" analysis and open results for further edit.");
+ intSpectButtons->widgetTB[2]->
+ SetToolTipText("Replace the current \"Integrate spectrum\" settings with default settings.");
+
+ relPde->widgetChBox[0]->
+ SetToolTipText("Normalize the ADC integral to the number of events ([ADC integral]/[Nr. of events]).");
+ midPeak->widgetChBox[0]->
+ SetToolTipText("Instead of taking the complete pedestal peak as noise, take only half of the peak.");
+ darkRun->widgetTE->
+ SetToolTipText("Filename of the dark run histogram (run with no incident light on the sample).\nMake sure this was measured right before or after the angle scan.");
+ darkRun->widgetTB[0]->
+ SetToolTipText("Select the file that holds the dark run histogram.");
+ zeroAngle->widgetNE[0]->GetNumberEntry()->
+ SetToolTipText("The angle offset of the dark run histogram from perpendicular position (0 degrees).");
+ intSpectButtons->widgetTB[0]->
+ SetToolTipText("Start the \"Relative PDE\" analysis and save\nresults to same folder as selected input files.");
+ intSpectButtons->widgetTB[1]->
+ SetToolTipText("Start the \"Relative PDE\" analysis and open results for further edit.");
+ intSpectButtons->widgetTB[2]->
+ SetToolTipText("Replace the current \"Relative PDE\" settings with default settings.");
+
+ minPeak->widgetNE[0]->GetNumberEntry()->
+ SetToolTipText("Minimal number of peaks visible to perform analysis\non a measurement (not counting the pedestal peak).");
+ peakSepCalc->widgetNE[0]->GetNumberEntry()->
+ SetToolTipText("Determines which peak separation to take for breakdown voltage analysis (most common is separation between 1 pe and 2 pe).");
+ brDownButtons->widgetTB[0]->
+ SetToolTipText("Start the \"Breakdown voltage\" analysis and save\nresults to same folder as selected input files.");
+ brDownButtons->widgetTB[1]->
+ SetToolTipText("Start the \"Breakdown voltage\" analysis and open results for further edit.");
+ brDownButtons->widgetTB[2]->
+ SetToolTipText("Replace the current \"Breakdown voltage\" settings with default settings.");
+
+ surfScanOpt->widgetChBox[0]->
+ SetToolTipText("Normalize the ADC integral to the number of events ([ADC integral]/[Nr. of events]).");
+ surfScanOpt->widgetChBox[1]->
+ SetToolTipText("Start the X and Y axis values from zero in the bottom left corner of the 2D plot,\ninstead of taking the actual position of the table.");
+ resolSurf->widgetNE[0]->GetNumberEntry()->
+ SetToolTipText("Number of pixels in a 2D contour plot parallel to the X axis\n(determines the resolution of the actual image, not the measurement).");
+ resolSurf->widgetNE[1]->GetNumberEntry()->
+ SetToolTipText("Number of pixels in a 2D contour plot parallel to the Y axis\n(determines the resolution of the actual image, not the measurement).");
+ surfButtons->widgetTB[0]->
+ SetToolTipText("Start the \"Surface scan\" analysis and save\nresults to same folder as selected input files.");
+ surfButtons->widgetTB[1]->
+ SetToolTipText("Start the \"Surface scan\" analysis and open results for further edit.");
+ surfButtons->widgetTB[2]->
+ SetToolTipText("Replace the current \"Surface scan\" settings with default settings.");
+
+ fitSigma->widgetNE[0]->GetNumberEntry()->
+ SetToolTipText("Sigma value of the peak (peaks are approximated\nto be Gaussians on top of background).");
+ fitTresh->widgetNE[0]->GetNumberEntry()->
+ SetToolTipText("The relative treshold between a peak and noise, below\nwhich jumps on spectrum are no longer considered as peaks.");
+ fitInter->widgetNE[0]->GetNumberEntry()->
+ SetToolTipText("The interpolation order for background estimation. Lower orders\nunderestimate the background, higher orders overestimate the background.");
+ adcOffset->widgetNE[0]->GetNumberEntry()->
+ SetToolTipText("If needed, the spectrum can be shifted by a small amount so that\nthe mean values are closer to X.0 values. Useful whenever we\nare estimating the peak with an integer number.");
+ accError->widgetNE[0]->GetNumberEntry()->
+ SetToolTipText("The maximal accepted error to still fit a peak. Whenever, the\nfraction of [peak mean error]/[peak mean] is above this value, the\nestimation of that peak is discarded.");
+ pedesLow->widgetNE[0]->GetNumberEntry()->
+ SetToolTipText("The lowest ADC channel value of, where we still search for\nthe pedestal peak. Used to discard and sudden jumps in the spectrum\nbefore the actual pedestal peak starts.");
+ fitChecks->widgetChBox[0]->
+ SetToolTipText("If checked, subtract the estimated background before\nfitting peaks. Otherwise, no subtraction is performed.");
+ fitChecks->widgetChBox[1]->
+ SetToolTipText("If checked, export fitted spectra for each selected file.");
+
+ // Histogram controls pane
+ adcRange->widgetNE[0]->GetNumberEntry()->
+ SetToolTipText("The lower limit of the ADC range. When both lower and upper\nare set to 0, the range is automatic. This range is regarded\nin the \"Histogram\" window and when performing analysis.");
+ adcRange->widgetNE[1]->GetNumberEntry()->
+ SetToolTipText("The upper limit of the ADC range. When both lower and upper\nare set to 0, the range is automatic. This range is regarded\nin the \"Histogram\" window and when performing analysis.");
+ tdcRange->widgetNE[0]->GetNumberEntry()->
+ SetToolTipText("The lower limit of the TDC range. When both lower and upper are set\nto 0, the range is automatic. This range determines the events used\nfor plotting the ADC spectrum (events with a certain time delay to laser).");
+ tdcRange->widgetNE[1]->GetNumberEntry()->
+ SetToolTipText("The upper limit of the TDC range. When both lower and upper are set\nto 0, the range is automatic. This range determines the events used\nfor plotting the ADC spectrum (events with a certain time delay to laser).");
+ yRange->widgetNE[0]->GetNumberEntry()->
+ SetToolTipText("The lower limit of the Y axis range. When both lower\nand upper are set to 0, the range is automatic.");
+ yRange->widgetNE[1]->GetNumberEntry()->
+ SetToolTipText("The upper limit of the Y axis range. When both lower\nand upper are set to 0, the range is automatic.");
+ selectCh->widgetNE[0]->GetNumberEntry()->
+ SetToolTipText("Channel number to plot, when opening a multichannel measurement file.");
+ plotType->widgetTB[0]->
+ SetToolTipText("Change plot type in the \"Histogram\" window to ADC\n(Analog-to-Digital-Converter channels versus number\nof events).");
+ plotType->widgetTB[1]->
+ SetToolTipText("Change plot type in the \"Histogram\" window to TDC\n(Time-to-Digital-Converter in nanoseconds versus number\nof events).");
+ plotType->widgetTB[2]->
+ SetToolTipText("Change plot type in the \"Histogram\" window to ADC versus TDC.");
+ histOpt->widgetChBox[0]->
+ SetToolTipText("If checked, change the Y axis to logarithmic scale.\nOtherwise, plot in a linear scale.");
+ histOpt->widgetChBox[1]->
+ SetToolTipText("If checked, the plot information is hidden (such as\nplot title, fitting information, statistical information).");
+ exportHist->widgetTB[0]->
+ SetToolTipText("Export the currently selected histogram (ADC, TDC or\nADC/TDC from selected files) into the .pdf format.");
+ editSelHist->widgetTB[0]->
+ SetToolTipText("Open the currently visible plot in the \"Histogram\"\nwindow in a new tab to enable further editing.");
+}
Index: sipmscan/trunk/src/window_layout.cpp
===================================================================
--- sipmscan/trunk/src/window_layout.cpp (nonexistent)
+++ sipmscan/trunk/src/window_layout.cpp (revision 146)
@@ -0,0 +1,327 @@
+#include "../include/sipmscan.h"
+#include "../include/workstation.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+// Title labels for each of the frame
+void TGAppMainFrame::TGTitleLabel(TGWindow *parent, TGHorizontalFrame *fTitle, const char *title, Pixel_t foreColor, Pixel_t backColor, const char *font)
+{
+ TGLabel *lab = new TGLabel(fTitle, title);
+ lab->ChangeBackground(backColor);
+ lab->SetTextColor(foreColor);
+ lab->SetTextFont(font);
+ fTitle->AddFrame(lab, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY) );
+ fTitle->ChangeBackground(backColor);
+}
+
+// Splitter to a set number of frames
+bool TGAppMainFrame::TGSplitter(TGWindow *parent, const char *majorSplit, int *horSplits, int *vertSplits, const char *frameTitles[512], TGCompositeFrame **frames, int *frameWidth, int *frameHeight)
+{
+ // Number of Frames that are not the ones we supply
+ int nrofmed = 0;
+ // Number of all splits in the minor direction
+ int minorSplits = 0;
+ int k = 0;
+
+ // Title frame height
+ int titHeight = 25;
+
+ if(strcmp("horizontal",majorSplit) == 0)
+ {
+ fLayout[idtotal] = new TGCompositeFrame(parent, 300, 300, kHorizontalFrame);
+ for(int i = 0; i <= horSplits[0]; i++)
+ {
+ minorSplits += vertSplits[i];
+ if(vertSplits[i] > 0)
+ nrofmed++;
+ }
+
+ if(DBGSIG > 1) printf("TGSplitter(): Number of intermediate frames = %d, all minor splits = %d\n", nrofmed, minorSplits);
+
+
+ TGCompositeFrame *fInter[nrofmed];
+ TGVSplitter *vsplit[horSplits[0]];
+ TGHSplitter *hsplit[minorSplits];
+
+ nrofmed = 0;
+
+ for(int i = 0; i <= horSplits[0]; i++)
+ {
+ if(DBGSIG > 1) printf("TGSplitter(): i = %d\n",i);
+ for(int j = 0; j <= vertSplits[i]; j++)
+ {
+ if(DBGSIG > 1) printf("TGSplitter(): j = %d, vertSplits = %d\n",j, vertSplits[i]);
+ if( vertSplits[i] > 0 )
+ {
+ if(j == 0)
+ {
+ if(DBGSIG > 1) printf("TGSplitter(): vertSplits - j = %d (nrofmed = %d)\n", (vertSplits[i]-j), nrofmed);
+ if(i > 0)
+ {
+ fInter[nrofmed] = new TGCompositeFrame(fLayout[idtotal], frameWidth[k], 200, kVerticalFrame);
+ fLayout[idtotal]->AddFrame(fInter[nrofmed], new TGLayoutHints(kLHintsExpandY | kLHintsExpandX));
+ }
+ else
+ {
+ fInter[nrofmed] = new TGCompositeFrame(fLayout[idtotal], frameWidth[k], 200, kVerticalFrame | kFixedWidth);
+ fLayout[idtotal]->AddFrame(fInter[nrofmed], new TGLayoutHints(kLHintsExpandY));
+ }
+ }
+
+ if( (vertSplits[i]-j) > 0)
+ {
+ if(DBGSIG > 1) printf("TGSplitter(): Step 0a (k = %d)\n", k);
+
+ frames[k] = new TGCompositeFrame(fInter[nrofmed], frameWidth[k], frameHeight[k], kVerticalFrame | kFixedHeight | kSunkenFrame);
+ fTitle = new TGHorizontalFrame(frames[k], 100, titHeight, kFixedHeight | kSunkenFrame);
+ TGTitleLabel(frames[k], fTitle, frameTitles[k], (Pixel_t)FORECOLOR, (Pixel_t)BACKCOLOR, FONT);
+ frames[k]->AddFrame(fTitle, new TGLayoutHints(kLHintsExpandX | kLHintsTop) );
+ fInter[nrofmed]->AddFrame(frames[k], new TGLayoutHints(kLHintsExpandX));
+
+ if(DBGSIG > 1) printf("TGSplitter(): Step 1a\n");
+
+ hsplit[nrofmed] = new TGHSplitter(fInter[nrofmed]);
+ hsplit[nrofmed]->SetFrame(frames[k], kTRUE);
+ fInter[nrofmed]->AddFrame(hsplit[nrofmed], new TGLayoutHints(kLHintsExpandX));
+
+ if(DBGSIG > 1) printf("TGSplitter(): Step 2a\n");
+
+ k++;
+ }
+ else
+ {
+ if(DBGSIG > 1) printf("TGSplitter(): Step 0b (k = %d)\n", k);
+
+ frames[k] = new TGCompositeFrame(fInter[nrofmed], frameWidth[k], frameHeight[k], kVerticalFrame | kSunkenFrame);
+ fTitle = new TGHorizontalFrame(frames[k], 100, titHeight, kFixedHeight | kSunkenFrame);
+ TGTitleLabel(frames[k], fTitle, frameTitles[k], (Pixel_t)FORECOLOR, (Pixel_t)BACKCOLOR, FONT);
+ frames[k]->AddFrame(fTitle, new TGLayoutHints(kLHintsExpandX | kLHintsTop) );
+ fInter[nrofmed]->AddFrame(frames[k], new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
+
+ if(DBGSIG > 1) printf("TGSplitter(): Step 1b\n");
+ k++;
+ }
+ }
+ else
+ {
+ if(DBGSIG > 1) printf("TGSplitter(): Step 0c (k = %d)\n", k);
+
+ frames[k] = new TGCompositeFrame(fLayout[idtotal], frameWidth[k], frameHeight[k], kVerticalFrame | kSunkenFrame);
+ fTitle = new TGHorizontalFrame(frames[k], 100, titHeight, kFixedHeight | kSunkenFrame);
+ TGTitleLabel(frames[k], fTitle, frameTitles[k], (Pixel_t)FORECOLOR, (Pixel_t)BACKCOLOR, FONT);
+ frames[k]->AddFrame(fTitle, new TGLayoutHints(kLHintsExpandX | kLHintsTop) );
+ fLayout[idtotal]->AddFrame(frames[k], new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
+
+ if(DBGSIG > 1) printf("TGSplitter(): Step 1c\n");
+ k++;
+ }
+ }
+
+ if(DBGSIG > 1) printf("TGSplitter(): i = %d, horSplits = %d\n", i, horSplits[0]);
+
+ if(i != horSplits[0])
+ {
+ vsplit[i] = new TGVSplitter(fLayout[idtotal]);
+ if( vertSplits[i] > 0 )
+ vsplit[i]->SetFrame(fInter[nrofmed], kTRUE);
+ else
+ vsplit[i]->SetFrame(frames[k], kTRUE);
+ fLayout[idtotal]->AddFrame(vsplit[nrofmed], new TGLayoutHints(kLHintsExpandY));
+ }
+
+ nrofmed++;
+ }
+
+ if(DBGSIG > 1) printf("TGSplitter(): Finished horizontal layout\n");
+ }
+ else if(strcmp("vertical",majorSplit) == 0)
+ {
+/* for(int i = 0; i <= vertSplits[0]; i++)
+ {
+ minorSplits += horSplits[i];
+ if(horSplits[i] > 0)
+ nrofmed++;
+ }
+
+ printf("Number of intermediate frames = %d\n", nrofmed);
+
+ TGCompositeFrame *fInter[nrofmed];*/
+ }
+ else
+ return false;
+
+ return true;
+}
+
+// Function for setting up the layout
+void TGAppMainFrame::LayoutRead(int nrframes, int *w, int *h)
+{
+ int WM, HM, k = 0, start = 0;
+
+ std::ifstream ilayout;
+
+ char *cTemp, *cTemp2, readTemp[1024];
+ cTemp = new char[512];
+ cTemp2 = new char[512];
+ sprintf(cTemp, "%s/layout/selected_layout.txt", rootdir);
+ ilayout.open(cTemp, std::ifstream::in);
+ if(ilayout.is_open())
+ {
+ ilayout >> cTemp2;
+ }
+ ilayout.close();
+ printf("Loaded layout file is: %s\n", cTemp2);
+
+ sprintf(cTemp, "%s/layout/%s", rootdir, cTemp2);
+ ilayout.open(cTemp, std::ifstream::in);
+ if(ilayout.is_open())
+ {
+ while(1)
+ {
+ if(ilayout.peek() == '#')
+ {
+ ilayout.getline(readTemp, 1024, '\n');
+ if(DBGSIG > 1) printf("LayoutRead(): readTemp = %s\n", readTemp);
+ }
+ else if(ilayout.peek() == '\n')
+ ilayout.ignore(1, '\n');
+ else
+ {
+ if(start == 0)
+ {
+ ilayout >> WM >> HM >> readTemp;
+ ilayout.ignore(1, '\n');
+ start++;
+ if(DBGSIG > 1) printf("LayoutRead(): W = %d, H = %d, Name = %s\n", WM, HM, readTemp);
+ }
+ else
+ {
+ ilayout >> w[k] >> h[k] >> readTemp;
+ ilayout.ignore(1, '\n');
+ if(DBGSIG > 1) printf("LayoutRead(): w[%d] = %d, h[%d] = %d, Name = %s\n", k, w[k], k, h[k], readTemp);
+ k++;
+
+ if(k == nrframes) break;
+ }
+ }
+ }
+ }
+
+ ilayout.close();
+ delete[] cTemp;
+ delete[] cTemp2;
+}
+
+// Function for saving the current layout
+void TGAppMainFrame::LayoutSave()
+{
+ TGFileInfo file_info;
+ const char *filetypes[] = {"Layout","*.layout",0,0};
+ char *cTemp;
+ file_info.fFileTypes = filetypes;
+ cTemp = new char[1024];
+ sprintf(cTemp, "%s/layout", rootdir);
+ file_info.fIniDir = StrDup(cTemp);
+ new TGFileDialog(gClient->GetDefaultRoot(), fMain, kFDSave, &file_info);
+ delete[] cTemp;
+
+ if(file_info.fFilename != NULL)
+ {
+ if(DBGSIG) printf("LayoutSave(): The layout save name: %s\n", file_info.fFilename);
+
+ std::ofstream olayout;
+
+ olayout.open(file_info.fFilename, std::ofstream::out);
+ if(olayout.is_open())
+ {
+ olayout << "# Whole window width and height" << std::endl;
+ olayout << fMain->GetWidth() << "\t" << fMain->GetHeight() << "\tmain" << std::endl << std::endl;
+ olayout << "# Measurement subwindows width and height" << std::endl;
+ for(int i = 0; i < measwin; i++)
+ olayout << measLayout[i]->GetWidth() << "\t" << measLayout[i]->GetHeight() << "\tmeasurementwindow" << i << std::endl;
+ olayout << std::endl;
+ olayout << "# Analysis subwindows width and height" << std::endl;
+ for(int i = 0; i < analysiswin; i++)
+ olayout << analysisLayout[i]->GetWidth() << "\t" << analysisLayout[i]->GetHeight() << "\tanalysiswindow" << i << std::endl;
+ }
+ else
+ printf("Error! Save file can not be opened (please do not use default.layout since it is write protected).\n");
+ olayout.close();
+ }
+}
+
+// Function for setting a user created layout
+void TGAppMainFrame::LayoutSet()
+{
+ TGFileInfo file_info;
+ int ret = 0;
+ const char *filetypes[] = {"Layout","*.layout",0,0};
+ char *cTemp, *layoutdir;
+ file_info.fFileTypes = filetypes;
+ layoutdir = new char[1024];
+ sprintf(layoutdir, "%s/layout", rootdir);
+ file_info.fIniDir = StrDup(layoutdir);
+ new TGFileDialog(gClient->GetDefaultRoot(), fMain, kFDOpen, &file_info);
+
+ if(file_info.fFilename != NULL)
+ {
+ if(DBGSIG) printf("LayoutSet(): The layout save name: %s\n", file_info.fFilename);
+ cTemp = new char[512];
+ remove_before_last(file_info.fFilename, '/', cTemp);
+ if(DBGSIG) printf("LayoutSet(): New selected layout: %s\n", cTemp);
+
+ FILE *fp;
+ sprintf(layoutdir, "%s/layout/selected_layout.txt", rootdir);
+ fp = fopen(layoutdir, "w");
+ fprintf(fp, "%s", cTemp);
+ fclose(fp);
+
+ sprintf(layoutdir, "Please restart the program to enable the selected layout (%s) for future use.", cTemp);
+ new TGMsgBox(gClient->GetRoot(), fMain, "Setting new layout", layoutdir, kMBIconAsterisk, kMBOk, &ret);
+ delete[] cTemp;
+ }
+ delete[] layoutdir;
+}
+
+// Layout function for the main window (width and height)
+void layoutMainWindow(int *w, int *h)
+{
+ std::ifstream ilayout;
+
+ char *cTemp, *cTemp2, readTemp[1024];
+ cTemp = new char[512];
+ cTemp2 = new char[512];
+ sprintf(cTemp, "%s/layout/selected_layout.txt", rootdir);
+ ilayout.open(cTemp, std::ifstream::in);
+ if(ilayout.is_open())
+ {
+ ilayout >> cTemp2;
+ }
+ ilayout.close();
+ if(DBGSIG) printf("layoutMainWindow(): Loaded layout file is: %s\n", cTemp2);
+
+ sprintf(cTemp, "%s/layout/%s", rootdir, cTemp2);
+ ilayout.open(cTemp, std::ifstream::in);
+ if(ilayout.is_open())
+ {
+ while(1)
+ {
+ if(ilayout.peek() == '#')
+ ilayout.getline(readTemp, 1024, '\n');
+ else if(ilayout.peek() == '\n')
+ ilayout.ignore(1, '\n');
+ else
+ {
+ ilayout >> *w >> *h;
+ if(DBGSIG > 1) printf("layoutMainWindow(): W = %d, H = %d\n", *w, *h);
+ break;
+ }
+ }
+ }
+
+ ilayout.close();
+ delete[] cTemp;
+ delete[] cTemp2;
+}
+
Index: sipmscan/trunk/src/wusbxx_dll.c
===================================================================
--- sipmscan/trunk/src/wusbxx_dll.c (nonexistent)
+++ sipmscan/trunk/src/wusbxx_dll.c (revision 146)
@@ -0,0 +1,104 @@
+#include "../include/wusbxx_dll.h"
+
+usb_dev_handle *udev;
+
+
+
+void _VI_FUNC WUSBXX_load (char* module_path)
+{
+
+ /*
+ if (module_path == NULL)
+ DLLHandle = LoadLibrary("libxxusb.dll");
+ else
+ DLLHandle = LoadLibrary(module_path);
+
+ if (!(xxusb_register_read_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_register_read"))) exit(1);
+ if (!(xxusb_stack_read_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_stack_read"))) exit(1);
+ if (!(xxusb_stack_write_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_stack_write"))) exit(1);
+ if (!(xxusb_stack_execute_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_stack_execute"))) exit(1);
+ if (!(xxusb_register_write_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_register_write"))) exit(1);
+ if (!(xxusb_usbfifo_read_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_usbfifo_read"))) exit(1);
+ if (!(xxusb_bulk_read_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_bulk_read"))) exit(1);
+ if (!(xxusb_bulk_write_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_bulk_write"))) exit(1);
+ if (!(xxusb_reset_toggle_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_reset_toggle"))) exit(1);
+
+ if (!(xxusb_devices_find_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_devices_find"))) exit(1);
+ if (!(xxusb_device_close_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_device_close"))) exit(1);
+ if (!(xxusb_device_open_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_device_open"))) exit(1);
+ if (!(xxusb_flash_program_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_flash_program"))) exit(1);
+ if (!(xxusb_flashblock_program_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_flashblock_program"))) exit(1);
+ if (!(xxusb_serial_open_Ptr = (void*) GetProcAddress(DLLHandle,"xxusb_serial_open"))) exit(1);
+
+ if (!(VME_register_write_Ptr = (void*) GetProcAddress(DLLHandle,"VME_register_write"))) exit(1);
+ if (!(VME_register_read_Ptr = (void*) GetProcAddress(DLLHandle,"VME_register_read"))) exit(1);
+ if (!(VME_LED_settings_Ptr = (void*) GetProcAddress(DLLHandle,"VME_LED_settings"))) exit(1);
+ if (!(VME_DGG_Ptr = (void*) GetProcAddress(DLLHandle,"VME_DGG"))) exit(1);
+ if (!(VME_Output_settings_Ptr = (void*) GetProcAddress(DLLHandle,"VME_Output_settings"))) exit(1);
+ if (!(VME_read_16_Ptr = (void*) GetProcAddress(DLLHandle,"VME_read_16"))) exit(1);
+ if (!(VME_read_32_Ptr = (void*) GetProcAddress(DLLHandle,"VME_read_32"))) exit(1);
+ if (!(VME_BLT_read_32_Ptr = (void*) GetProcAddress(DLLHandle,"VME_BLT_read_32"))) exit(1);
+ if (!(VME_write_16_Ptr = (void*) GetProcAddress(DLLHandle,"VME_write_16"))) exit(1);
+ if (!(VME_write_32_Ptr = (void*) GetProcAddress(DLLHandle,"VME_write_32"))) exit(1);
+
+ if (!(CAMAC_DGG_Ptr = (void*) GetProcAddress(DLLHandle,"CAMAC_DGG"))) exit(1);
+ if (!(CAMAC_register_read_Ptr = (void*) GetProcAddress(DLLHandle,"CAMAC_register_read"))) exit(1);
+ if (!(CAMAC_register_write_Ptr = (void*) GetProcAddress(DLLHandle,"CAMAC_register_write"))) exit(1);
+ if (!(CAMAC_LED_settings_Ptr = (void*) GetProcAddress(DLLHandle,"CAMAC_LED_settings"))) exit(1);
+ if (!(CAMAC_Output_settings_Ptr = (void*) GetProcAddress(DLLHandle,"CAMAC_Output_settings"))) exit(1);
+ if (!(CAMAC_read_LAM_mask_Ptr = (void*) GetProcAddress(DLLHandle,"CAMAC_read_LAM_mask"))) exit(1);
+ if (!(CAMAC_write_LAM_mask_Ptr = (void*) GetProcAddress(DLLHandle,"CAMAC_write_LAM_mask"))) exit(1);
+ if (!(CAMAC_write_Ptr = (void*) GetProcAddress(DLLHandle,"CAMAC_write"))) exit(1);
+ if (!(CAMAC_read_Ptr = (void*) GetProcAddress(DLLHandle,"CAMAC_read"))) exit(1);
+ if (!(CAMAC_Z_Ptr = (void*) GetProcAddress(DLLHandle,"CAMAC_Z"))) exit(1);
+ if (!(CAMAC_C_Ptr = (void*) GetProcAddress(DLLHandle,"CAMAC_C"))) exit(1);
+ if (!(CAMAC_I_Ptr = (void*) GetProcAddress(DLLHandle,"CAMAC_I"))) exit(1);
+*/
+}
+
+void _VI_FUNC WUSBXX_open (char *serial)
+{
+ if (serial != NULL)
+ udev = xxusb_serial_open(serial);
+}
+
+void _VI_FUNC WUSBXX_close (void)
+{
+ if (udev) xxusb_device_close(udev);
+}
+
+int _VI_FUNC WUSBXX_CCread (int n, int a, int f, unsigned long *data)
+{
+ long intbuf[4];
+ int ret;
+ // CAMAC direct read function
+ intbuf[0]=1;
+ intbuf[1]=(long)(f+a*32+n*512 + 0x4000);
+ ret = xxusb_stack_execute(udev, intbuf);
+ if (f < 16)
+ {
+ *data=intbuf[0] + intbuf[1] * 0x10000; //24-bit word
+// *Q = ((intbuf[1] >> 8) & 1);
+// *X = ((intbuf[1] >> 9) & 1);
+ }
+ return ret;
+}
+
+int _VI_FUNC WUSBXX_CCwrite (int n, int a, int f, unsigned long data)
+{
+ long intbuf[4];
+ int ret;
+// CAMAC direct write function
+ intbuf[0]=1;
+ intbuf[1]=(long)(f+a*32+n*512 + 0x4000);
+ if ((f > 15) && (f < 24))
+ {
+ intbuf[0]=3;
+ intbuf[2]=(data & 0xffff);
+ intbuf[3]=((data >>16) & 255);
+ ret = xxusb_stack_execute(udev, intbuf);
+// *Q = (intbuf[0] & 1);
+// *X = ((intbuf[0] >> 1) & 1);
+ }
+ return ret;
+}