# LWDAQ Command Reference

For LWDAQ Version LWDAQ_Version_Here
© 2004−2020 Kevan Hashemi, Brandeis University
© 2006−2025 Kevan Hashemi, Open Source Instruments Inc.
section-chunk

## Contents

## Introduction

[18-JUN-25] When it starts up, LWDAQ installs hundreds of commands for instruments and tools to use. The LWDAQ (upper-case LWDAQ) commands are those installed by TclTk scripts that LWDAQ runs at start-up. The lwdaq (lower-case lwdaq) commands are those installed by the lwdaq library that LWDAQ loads at start-up. We compile this library from Pascal source code. The LWDAQ commands all begin with LWDAQ_. The lwdaq commands all begin with lwdaq_. This Command Reference describes all LWDAQ and lwdaq commands.

The LWDAQ distribution's Packages directory contains a number of TclTk libraries, which in Tcl nomenclature are called "packages". Some of these packages are loaded by LWDAQ at startup. The TTY package, for example, manages the console interface when we launch LWDAQ from a terminal, and the EDF package manages the writing of European Data Format files. This manual does not describe the packages in the Packages directory, but you can load them into LWDAQ with the Tcl "package require" command. There is no LWDAQ package. The LWDAQ libraries are distributed among two dozen LWDAQ scripts in the LWDAQ directory structure. We do not load the LWDAQ commands with "package require LWDAQ", we load them during the LWDAQ initialization. If you include a "package require LWDAQ" command in your script, you will generate an error.

The Tcl scripts that define the LWDAQ commands are in the LWDAQ/LWDAQ.app/Contents/LWDAQ directory. Each LWDAQ command has its own entry in this manual, with its Tcl declaration and its in the Tcl comments above the declaration. The Pascal units that define the lwdaq commands are in the LWDAQ/Sources directory. Each operating system has its own version of the shared library we compile from the Pascal units, but all versions define the same commands. Each lwdaq command takes some mandatory parameters, and a list of optional parameters. You specify the mandatory parameters by passing their values directly to the command, in the correct order. You specify optional parameters with a list of option names in the form "?option value?". You can specify any number of these options, and in any order. Here is an example library command call from the Rasnik instrument script.

    set result [lwdaq_rasnik $image_name \
    	-show_fitting $config(analysis_show_fitting) \
    	-show_timing $config(analysis_show_timing) \
    	-reference_code $config(analysis_reference_code) \
    	-orientation_code $config(analysis_orientation_code) \
    	-pixel_size_um $info(analysis_pixel_size_um) \
    	-reference_x_um $info(analysis_reference_x_um) \
    	-reference_y_um $info(analysis_reference_y_um) \
    	-square_size_um $config(analysis_square_size_um) ]

The lwdaq.pas file acts as an interface between our Pascal library and the Tcl interpreter that manages the entire LWDAQ process. The lwdaq.pas initialization routine, init_Lwdaq, loads the lwdaq shared library and declares all the lwdaq commands for the interpreter's use. We compile the shared libraries for Windows, Linux, MacOS, and Raspbian with the Free Pascal Compiler (FPC).

The lwdaq command grants access to a selection of mathematical routines declared in our Pascal library. We call these the lwdaq routines to distinguish them from the lwdaq commands, of which lwdaq is an exmaple. The following command calls our linear interpolator on a set of x-y data pairs to estimate the value of a curve at x=2.

    lwdaq linear_interpolate 2 "0 0 3 3 6 6"

You will find a list of the routines available through the lwdaq command in a table below, as well as descriptions of each of them.

The image parameters taken by many of the library commands are the names of images in the LWDAQ image list. This list of images is maintained in memory by the library commands. Each image contains its pixel intensities and an overlay in which the library routines can draw lines. You draw an image in a Tk photo widget with lwdaq_draw. First lwdaq_draw renders the pixel intensity in the photo, and then it renders the overlay. The same image can be rendered in multiple Tk photos. When an instrument captures consecutive images from a data acquisition system, it is deleting previous images (now redundant) from the LWDAQ image list, creating a new image, filling it with the acquired pixel intensities, and rendering the image in the same Tk photo in the instrument window.

LWDAQ_Commands lwdaq_Commands lwdaq_Routines