esrf

Beamline Instrument Software Support
SPEC Macro documentation: [ Macro Index | BCU Home ]

xia2x.mac
See other macros in category: All
Description:
    Macros to work with XIA-2X $Revision: 2.61 $
Documentation:
    DESCRIPTION
    Macros to handle XIA DXP electronics to control multi-element detectors
    This macro set can be used with two differents XIA models:
    * DXP2X boards: CAMAC boards controlled by a Jorway on SCSI
    * XMAP boards: PXI boards controlled by a NI MXI bus coupler
    A windows device server exists for these 2 boards: xiads (dxp2x boards) and xmapds (xmap boards)

    SETUP
    In SPEC, minimal setup needed is:
    xiasetup <taco_device_name>
    This setup macro need to be executed at each reconfig since it sets the taco TCP mode and timeout.

Macros:
    getval_one_char
    Usage: getval_one_char (<message>, <default>)
    Prompts for a single letter until a unique one is entered.

    xiasetup
    Usage: xiasetup <device_name>
    Global setup macro.
    -<device_name> : Taco device server name.

    xia
    Usage: xia
    Main menu which gives access to almost all needed functions

    xiainit
    Usage: xiainit
    Initialize XIA hardware and read device parameters
    Used to reinitialize haardware with default firmwares/parameters

    xiaconfigure
    Usage: xiaconfigure
    Load a DSP configuration file
    For DXP2X boards: file created with MESA (*.sav)
    For XMAP boards: file created with xManager

    xiaacq
    Usage: xiaacq [<time>] [<refresh_rate>]
    Acquisition for <time> sec. or until Ctrl-C is pressed
    default refresh_rate is set to 0.5 (real time mode), 0.1 (live time mode)

    xiaon
    Usage: xiaon
    Activate xia on ct/scans

    xiaoff
    Usage: xiaoff
    Deactivate xia on ct/scans

    xiaacqsetup
    Usage: xiaacqsetup [<acqmode> [<par1> <par2> <par3>]]
    Set acquisition parameters:
    * standard modes:
    - acqmode= XIA_MODEMCA (acquire spectrum, dxp2x and xmap)
    - acqmode= XIA_MODESCA (acquire only scas, dxp2x only)
    - par1= extgate, par2= autoclear, par3= presetmode
    * mapping mode:
    - XMAP boards:
    ... acqmode= XIA_MODEMAP|XIA_MODEMCA (acquire spectrum, xmap only)
    ... par1= gate/sync pixel advance, par2= nb of pixels, par3= pixels/buffer
    - DXP2X boards:
    ... acqmode= XIA_MODEMAP|XIA_MODESCA (acquire only scas, dxp2x only)
    ... par1= multimode, par2= signlepass, par3= numpoints

    xiarange
    Usage: xiarange [<chmin> <chmax> | <length>]
    Set spectrum range for all detectors
    * DXP2X boards: spectrum between channels <chmin> and <chmax>
    * XMAP boards : define only spectrum length. Channel range is [0:length-1]

    xiaclear
    Usage: xiaclear
    When auto-clear mode is OFF, allow user to clear spectrum memory when needed

    xiamapreport
    Usage: xiamapreport <detector_number>
    dxp2x boards only:
    In SCA mapping mode, report all values acquired for one detector. This includes livetime, realtime, input/output counts, and all scas configured.

    xiamapstatus
    Usage: xiamapstatus
    xmap boards only:
    In MCA mapping mode, gets information on current acquisition

    xiatimes
    Usage: xiatimes
    Report Livetime, DeadTime, ICR and OCR of last acquisition

    xiastatus
    Usage: xiastatus
    Print out status and some parameters

    xiainfo
    Usage: xiainfo
    Print out device parameters

    xiaguidisplay
    Usage: xiaguidisplay <display>
    Set display used for external GUI (PyMca, XiaStat)

    xiaguiopen
    Usage: xiaguiopen [<display>]
    Open PyMca plotting GUI

    xiaguion
    Usage: xiaguion [<display>]
    Open PyMca plotting GUI

    xiaguiclose
    Usage: xiaguiclose
    Close PyMca plotting GUI

    xiastatopen
    Usage: xiastatopen [<display>]
    Open statistics GUI

    xiastatclose
    Usage: xiastatclose
    Close statistics GUI

    xiaplot
    Usage: xiaplot <det> [<from>] [<to>]
    Plot data for detector <det>, from channel <from> to <to>

    xiaplotloop
    Usage: xiaplotloop [<min_channel> <max_channel>] [<sleep_time>]
    Loop on all detectors and plot its spectrum

    xiaplotselect
    Usage: xiaplotselect [<online> [<detno> <plotmin> <plotmax> <plotlog>]]
    Selects online spec plotting for one detector

    xianewfile
    Usage: xianewfile <directory> <file_radix>
    Changes/Defines file path to save data. Checks if local file in ok and displays next saving file. -MODEMCA or MODEMAP: => saves on windows pc in XIA_SAVE["mapdir"]/XIA_SAVE["mapfile"] -SCAMODE: => saves via SPEC on local PC in XIA_SAVE["dir"]/XIA_SAVE["radix"]

    user_xia_map_header
    Usage: user_xia_map_header
    User hook macros to set edf header in mapping mode (when files are saved by device server).
    User has to fill associative array XIA_HEADER
    Example:
    XIA_HEADER["theta"]= 23.5
    XIA_HEADER["expname"]= "name of the experiment"

    user_xia_header
    Usage: user_xia_header
    User hook macros to set edf header in normal mode (when files are saved by spec) (not in zapscan)
    User has to fill associative array XIA_HEADER
    Example:
    XIA_HEADER["theta"]= 23.5
    XIA_HEADER["expname"]= "name of the experiment"

    xiasave
    Usage: xiasave
    Save last acquisition (xiaacq or ct)

    xiasavesetup
    Usage: xiasavesetup
    Setup save during scans / save after ct/xiaacq (not in zapscan). -XIA_SAVE["mapauto"] : in MCA or MAPPING mode. -XIA_SAVE["scan"] : after a scan. -XIA_SAVE["ct"] : after a count.

    xiacntshow
    Usage: xiacntshow
    Display XIA counters configured in current spec session

    xiacntassign
    Usage: xiacntassign [<-1(average)|detector_number>]
    Change common counters assignation (xocr, xicr, xlt, xdt)
    Common counters can be assigned to either -1=Average on all detectors or <detector_number>

    xiacntdisable
    Usage: xiacntdisable
    Disable all xia counters (statistics and rois counters)

    xiacntenable
    Usage: xiacntenable
    Enable all xia counters (statistics and rois counters)
    for all currently configured detectors

    xiaroimenu
    Usage: xiaroimenu
    Menu to Add/Modify/Delete/Save/Load rois

    xiaroisave
    Usage: xiaroisave [<filename>]
    Saves rois definition in a file. If <filename> is not specified, saves to a default file.

    xiaroiload
    Usage: xiaroiload [<filename>]
    Load rois from a file. If <filename> is not specified, load from the standard location
    Loading rois from file will erase current roi settings.

    xiaroi
    Usage: xiaroi <roimne> <detector|"all"|"sum"|"avg"> <first> <last> [<lvt_corr>] [<dt_corr>] [<mne_norm>]
    Define a new roi. If no arguments are given, run xiaroimenu.
    Arguments are:
    * roimne : counter mnemonic for the roi (should be defined in spec config)
    * detector:
    ... if ==\"all\" : add same roi on all detector. roi are named <roimne>N
    ... if ==\"avg\" : the roi named <roimne>Avg is an average on all <roimne>N
    ... if ==\"sum\" : the roi named <roimne>Avg is an average on all <roimne>N
    ... if ==<detetector_number> : add a single roi on the given detector
    * first : first channel
    * last : last channel
    * lvt_corr: if ==1, normalize roi by livetime, 0 otherwise
    * dt_corr : if ==1, deadtime correction, 0 otherwise
    * mne_norm: Normalize the roi using the given counter

    xiadetdisable
    Usage: xiadetdisable <detector_number>
    Disable detector in ROI which computes SUM/AVG on all det.
    if <detector_number>==\"all\": disable all detectors

    xiadetenable
    Usage: xiadetenable <dectector_number>
    Enable detector in ROI which computes SUM/AVG on all det.
    if <detector_number>==\"all\": enable all detectors.

    xiacorrsetup
    Usage: xiacorrsetup [parma]


    xiasummenu
    Usage: xiasummenu
    Menu to define spectrum detectors sum or average
    Options are given to perform livetime and/or deadtime corrections

    xiasum
    Usage: xiasum [<sumno> <lvt_corr> <dt_corr> <do_avg> <det1> ... <detn>]

    If no arguments, display a menu to configure detector sum
    If arguments are given, add the defiened detector sum

    xiasumsave
    Usage: xiasumsave [<filename>]
    Save spectrum sum definitions in a file. If <filename> is not specified, save to the standard location

    xiasumload
    Usage: xiasumload [<filename>]
    Load spectrum sum definition from a file. If <filename> is not specified, load from the standard location
    Loading sum from file will erase current sum settings.

    xialineupon
    Usage: xialineupon
    Set lineup facility ON
    Lineup will store all data in MCA_DATA

    xialineupoff
    Usage: xialineupoff
    Set lineup facility OFF

    xiareaddsp
    Usage: xiareaddsp <detector_number>
    Read ALL DSP parameters for one detector

    xiagetdsp
    Usage: xiagetdsp <parameters_names>
    Read one or several DSP parameters on all detectors

    xiasetdsp
    Usage: xiasetdsp <parameter_name>
    Set one DSP parameter on all detectors

    xiareadbase
    Usage: xiareadbase
    Read baseline history

    xiaplotbase
    Usage: xiaplotbase [<det> [<min> <max>]]
    Plot baseline history for detector <det>. Optionnal plotting interval
    Caution: xiareadbase needs to be executed first. No automatic read

    xiasavebase
    Usage: xiasavebase <filename>
    Save all baseline history in EDF file

    xiabaseres
    Usage: xiabaseres
    Computes FWHM, COM, MAX on baseline history

Internal Macros:
    xiaunsetup
    Usage: xiaunsetup
    Unsetup XIA detector

    _xia_init
    Usage: _xia_init ()
    Initialize XIA hardware
    Return 1 on success, 0 otherwise

    _xia_isinit
    Usage: _xia_isinit ()
    Return 1 if XIA hardware already initialized, 0 otherwise

    xiaupdate
    Usage: xiaupdate
    Read xia parameters from device server
    Usefull when xiaconfigure ends with a timeout

    _xia_readpar
    Usage: _xia_readpar ()
    Read XIA channels and acquisition parameters
    Store parameters in ass. array XIA_PAR
    Store detector numbers in array XIA_DET

    _xia_readacqpar
    Usage: _xia_readacqpar ()
    Read acquisition parameters

    _xia_readconfig
    Usage: _xia_readconfig ()
    Read last DSP configuration file

    _xia_readchanpar
    Usage: _xia_readchanpar ()
    Read channel definition

    _xia_createarrays
    Usage: _xia_createarrays ()
    Creates shared arrays
    XIA_DATA = spectrum for all detectors
    XIA_STAT = run statistics for all detectors (nevt, icr, ocr, lvt)
    XIA_SUMDATA = sum of spectrums if defined

    _xia_check_ROIs
    Usage: _xia_check_ROIs ()
    Checks that defined XIA ROIs are valid (defined on an existing detector)

    _xia_roitosca
    Usage: _xia_roitosca ()
    Configures all defined ROIs as hard SCAs
    Returns 1 on success, 0 otherwise

    _xia_scaarray
    Usage: _xia_scaarray [parma]
    Allocates arrays for SCAS. Here is the source of the message : "Must have have at least one row for array "XIA_SCAS". This function is called: -after a roi definition. -at zap initialization.

    _xia_test
    Usage: _xia_test [<ocr_min>] [<timeout>]
    Test acquisition done after configure

    _xia_setconfig
    Usage: _xia_setconfig(cfg)
    Download DSP configuration file
    Return 1 on success, 0 otherwise Called by xiaconfigure.

    xiaread
    Usage: xiaread [<pixel_number>]
    Read spectrum, run statistics, computes or read ROIs, computes SUMs
    Update shared arrays and counters
    In MCAMAP mode:
    if <pixel_number> is specified, read spectrum, sums, stats for that pixel
    otherwise, read the last pixel available in device server buffer

    _xia_readout
    Usage: _xia_readout
    Start readout thread on server

    _xia_readoutwait
    Usage: _xia_readoutwait ()
    Wait until readout is finished
    Return 1 if readout finished successfully
    Return 0 if readout finished with errors

    _xia_readdata
    Usage: _xia_readdata (<frombuffer>)
    Read spectrum
    if <frombuffer> is set to 1, get spectrums from server buffer: no readout performed.

    _xia_readscas
    Usage: _xia_readscas (<frombuffer>)
    Read SCAs
    if <frombuffer> is set to 1, get SCAs from server buffer: no readout performed.

    _xia_readstat
    Usage: _xia_readstat(frombuffer)
    Reads run statistics
    if <frombuffer> is set to 1, get statistics from server buffer: no readout performed.

    _xia_readcnts
    Usage: _xia_readcnts
    Read xia specific counters

    _xia_mapstatarray
    Usage: _xia_mapstatarray()


    _xia_readmapstat
    Usage: _xia_readmapstat(frompt)


    xiastart
    Usage: xiastart
    Start acquisition

    xiastart_wait
    Usage: xiastart_wait
    Waits forr the device server to be ready after saving and starts acquisition

    xiastop
    Usage: xiastop
    Stop acquisition

    _xia_cleanup
    Usage: _xia_cleanup
    Cleanup macro

    xia_activate
    Usage: xia_activate


    xia_desactivate
    Usage: xia_desactivate


    _xia_prepcount
    Usage: _xia_prepcount


    _xia_getcounts
    Usage: _xia_getcounts


    _xia_handlecounts
    Usage: _xia_handlecounts


    _xia_scan_head
    Usage: _xia_scan_head


    _xia_scan_loop
    Usage: _xia_scan_loop


    _xia_scan_tail
    Usage: _xia_scan_tail


    _xia_scan_abort
    Usage: _xia_scan_abort


    _xia_Fheader
    Usage: _xia_Fheader


    _xia_dxp2x_acqsetup
    Usage: _xia_dxp2x_acqsetup
    DXP2X specific acquisition setup

    _xia_xmap_acqsetup
    Usage: _xia_xmap_acqsetup
    XMAP specific acquisition setup

    _xia_mercury_acqsetup
    Usage: _xia_mercury_acqsetup


    _xia_setacqpar
    Usage: _xia_setacqpar (acqmode, par1, par2, par3)
    Set device acquisition parameters
    See xiaacqsetup for description of parameters <acqmode> : IN MODE <par1> : <par2> : <par3> : IN MAP MODE <par1> : <par2> : <par3> :

    _xia_setrange
    Usage: _xia_setrange (chmin, chmax)
    Set acquisition range in channels

    xiapreset
    Usage: xiapreset [<preset_value>]
    Set preset value
    if preset mode is Live or Real time, preset is <preset_value> sec.
    if preset mode is Input or Output, preset is <preset_value> counts.

    _xia_setpreset
    Usage: _xia_setpreset (preset)
    Set preset value (in ms if real/live time preset mode set)

    _xia_mapsave
    Usage: _xia_mapsave(file, scanno, heading, nbpts, addscand)


    _xia_mapcheck
    Usage: _xia_mapcheck ()
    In mapping mode, checks that the number of points acquired is the same as the number of points asked. Return 1 on success, 0 otherwise.

    _xia_mapsetpoints
    Usage: _xia_mapsetpoints (numpoints)
    Shortcut to set SCAMAP mode with NO multimode, singlepass set and given number of points

    _xia_print
    Usage: _xia_print (fnct, msg, type)
    Print formatted message (type=1 means error message) (type=1 means warning message)

    _xia_guistart
    Usage: _xia_guistart [parma]


    _xia_guiclose
    Usage: _xia_guiclose [parma]


    _xia_getdetidx
    Usage: _xia_getdetidx (detnum)
    Return array index for detector <detnum>
    If not found, return -1

    _xia_plotinit
    Usage: _xia_plotinit (det)
    Initialize spec plot for given detector

    _xia_plotdata
    Usage: _xia_plotdata (det, from, to)
    Plot data on spec plot

    _xia_plotonlineinit
    Usage: _xia_plotonlineinit
    Online spec plotting init

    _xia_plotonlinedata
    Usage: _xia_plotonlinedata
    Online spec plotting refresh

    _xia_getfilename
    Usage: _xia_getfilename (det)
    Get filename depending on mode and usage. In mapping mode, file names are forged by DS. <det>: -"ct" : SCAMODE file name -"SN" : Sum Name. -"XX" : generic name for spectra. -"st" : stat -default : <det> is a detector number. <sidx> : second index for mesh-like scans.

    _xia_savescaninit
    Usage: _xia_savescaninit


    _xia_savescandata
    Usage: _xia_savescandata


    _xia_savescanfile
    Usage: _xia_savescanfile


    _xia_saveheader
    Usage: _xia_saveheader


    _xia_saveroiheader
    Usage: _xia_saveroiheader


    _xia_setfilepar
    Usage: _xia_setfilepar (<directory>, <radix>, <num0>, <num1>, <num2>, <auto>)
    Sets file parameters to device server for MCAMAP mode
    directory: windows directory
    radix: file radix
    num0,1,2: file numbers as in zap macros
    auto: autosave files at the end of run
    bidirect: bidirectionnal scans (zap option)

    _xia_getfilepar
    Usage: _xia_getfilepar ()
    Read back file parameters from device server (store in XIA_SAVE)

    _xia_checkcnt
    Usage: _xia_checkcnt
    Checks cnt assigned if it is still in detectors configured. Used after config changed.

    _xia_roiremove
    Usage: _xia_roiremove(cmne)
    Remove roi definition

    user_xia_roi_remove
    Usage: user_xia_roi_remove
    user hook macro called each time a roi has been removed
    First parameter sent ($1) is the roi mnemonic

    _xia_roiremovesingle
    Usage: _xia_roiremovesingle(cmne)
    Remove one roi and call user hook

    _xia_roiremoveall
    Usage: _xia_roiremoveall()
    Remove all roi and call user hook

    _xia_roimenu
    Usage: _xia_roimenu


    _xia_roiadd
    Usage: _xia_roiadd (cmne, cdet, min, max, lvt, dt, norm)
    Add a roi with following rules:
    if cdet==\"all\": add the same roi on all detectors named <cmne>N
    if cdet==\"avg\": add a roi named <cmne>Avg, which will be computed as a average of <cmne>N
    if cdet==\"sum\": add a roi named <cmne>Sum, which will be computed as a sum of <cmne>N
    if cdet==detector_number: add a single roi on given detector

    user_xia_roi_add
    Usage: user_xia_roi_add
    user hook macro called each time a roi has been added
    First parameter sent ($1) is the roi mnemonic

    _xia_roiinsert
    Usage: _xia_roiinsert(mne, det, min, max, lvt, dt, norm, name)
    add a roi in list XIA_ROI and call user hook

    _xia_hwscamenu
    Usage: _xia_hwscamenu


    _xia_hwscashow
    Usage: _xia_hwscashow()


    _xia_roishow
    Usage: _xia_roishow ()
    Shows ROI definition

    _xia_readrois
    Usage: _xia_readrois
    Computes all defined rois
    Roi values are stored in XIA_ROIVAL
    and saved in standard S[] array if counter exists

    _xia_roioperation
    Usage: _xia_roioperation (mne)
    Computes average/sum Rois assuming that single Roi has already been stored in XIA_ROIVAL

    _xia_roicalc
    Usage: _xia_roicalc (mne)
    Return roi value. If requested, the roi value if altered for live-time and dead-time correction.

    _xia_hascorr
    Usage: _xia_hascorr [parma]


    _xia_iscorrsaved
    Usage: _xia_iscorrsaved [parma]


    _xia_corrcreatearray
    Usage: _xia_corrcreatearray [parma]


    _xia_corrdata
    Usage: _xia_corrdata [parma]


    _xia_sumshow
    Usage: _xia_sumshow ()
    Display current detector sum configured

    _xia_addsum
    Usage: _xia_addsum [parma]


    _xia_delsum
    Usage: _xia_delsum [parma]


    _xia_sumcreatearray
    Usage: _xia_sumcreatearray [parma]


    _xia_readsum
    Usage: _xia_readsum [parma]


    _xia_lineupcreatearray
    Usage: _xia_lineupcreatearray
    Create MCA_DATA for lineup

    _xia_lineupdata
    Usage: _xia_lineupdata
    Store data of all detectors (read in XIA_DATA) in array MCA_DATA

    _xia_lineupsize
    Usage: _xia_lineupsize ()
    Return total size of lineup array

    _xia_lineupclear
    Usage: _xia_lineupclear
    Clear MCA_DATA array

    _xia_plotbase
    Usage: _xia_plotbase (<num>, <beg>, <end>)


Filename: xia2x.mac
Author: E.Papillon
Last mod.: 13/11/2020 16:24 by guilloud