LWDAQ Command Reference

For LWDAQ Version 7.2.19
© 2004−2009 Kevan Hashemi, Brandeis Univiersity HEP Electronics Shop

Contents

Introduction
Library Commands
lwdaq_bcamlwdaq_calibrationlwdaq_config
lwdaq_data_manipulatelwdaq_diagnosticlwdaq_draw
lwdaq_flowmeterlwdaq_gaugelwdaq_graph
lwdaq_image_characteristicslwdaq_image_contentslwdaq_image_create
lwdaq_image_destroylwdaq_image_existslwdaq_image_histogram
lwdaq_image_manipulatelwdaq_image_resultslwdaq_inclinometer
lwdaq_photo_contentslwdaq_rasniklwdaq_rasnik_shift
lwdaq_recorderlwdaq_rfpmlwdaq_sampler
lwdaq_voltmeterlwdaq_wps
Library Routines
bcam_from_global_pointbcam_from_global_vectorbcam_source_bearing
bcam_source_positionfourier_termfourier_transform
global_from_bcam_pointglobal_from_bcam_vectorlinear_interpolate
matrix_inversestraight_line_fitsum_sinusoids
wps_wire_planexyz_line_plane_intersectionxyz_plane_plane_intersection
Driver.tcl
LWDAQ_byte_pollLWDAQ_byte_readLWDAQ_byte_write
LWDAQ_clear_data_addrLWDAQ_config_readLWDAQ_config_write
LWDAQ_controller_resetLWDAQ_delay_secondsLWDAQ_driver_init
LWDAQ_echoLWDAQ_execute_jobLWDAQ_firmware_version
LWDAQ_hardware_idLWDAQ_hardware_versionLWDAQ_integer_write
LWDAQ_job_doneLWDAQ_loginLWDAQ_loop_time
LWDAQ_mac_readLWDAQ_most_recent_byteLWDAQ_off
LWDAQ_onLWDAQ_ram_deleteLWDAQ_ram_read
LWDAQ_ram_writeLWDAQ_receive_byteLWDAQ_receive_data
LWDAQ_receive_integerLWDAQ_relay_rebootLWDAQ_set_base_addr_hex
LWDAQ_set_command_regLWDAQ_set_command_reg_binaryLWDAQ_set_command_reg_hex
LWDAQ_set_ct_configLWDAQ_set_data_addrLWDAQ_set_delay_seconds
LWDAQ_set_delay_ticksLWDAQ_set_device_addrLWDAQ_set_device_element
LWDAQ_set_device_typeLWDAQ_set_driver_muxLWDAQ_set_repeat_counter
LWDAQ_shortint_writeLWDAQ_sleepLWDAQ_software_version
LWDAQ_start_jobLWDAQ_stream_deleteLWDAQ_stream_read
LWDAQ_stream_writeLWDAQ_transmit_commandLWDAQ_transmit_command_binary
LWDAQ_transmit_command_hexLWDAQ_transmit_messageLWDAQ_wait_for_driver
LWDAQ_wake
Init.tcl
LWDAQ_initLWDAQ_stdin_console_executeLWDAQ_stdin_console_prompt
LWDAQ_stdin_console_start
Instruments.tcl
LWDAQ_acquireLWDAQ_acquire_buttonLWDAQ_close
LWDAQ_info_buttonLWDAQ_instrument_analyzeLWDAQ_instrument_print
LWDAQ_instruments_initLWDAQ_loop_buttonLWDAQ_open
LWDAQ_read_buttonLWDAQ_reset_instrument_countersLWDAQ_stop_button
LWDAQ_stop_instrumentsLWDAQ_write_button
Interface.tcl
LWDAQ_aboutLWDAQ_bind_command_keyLWDAQ_button_confirm
LWDAQ_button_waitLWDAQ_button_warningLWDAQ_clock_widget
LWDAQ_close_windowLWDAQ_enable_text_undoLWDAQ_init_main_window
LWDAQ_interface_initLWDAQ_MacOS_Open_FileLWDAQ_make_instrument_menu
LWDAQ_make_tool_menuLWDAQ_monitor_openLWDAQ_monitor_refresh
LWDAQ_new_toplevel_text_windowLWDAQ_new_toplevel_windowLWDAQ_open_document
LWDAQ_printLWDAQ_resetLWDAQ_save_text_window
LWDAQ_server_acceptLWDAQ_server_infoLWDAQ_server_interpreter
LWDAQ_server_openLWDAQ_server_startLWDAQ_server_stop
LWDAQ_text_widgetLWDAQ_view_arrayLWDAQ_view_text_file
LWDAQ_widget_list
Tools.tcl
LWDAQ_obsolete_namesLWDAQ_read_scriptLWDAQ_run_tool
LWDAQ_tool_configureLWDAQ_tool_dataLWDAQ_tool_help
LWDAQ_tool_initLWDAQ_tool_openLWDAQ_tool_save
LWDAQ_tool_startupLWDAQ_ToolmakerLWDAQ_Toolmaker_back
LWDAQ_Toolmaker_deleteLWDAQ_Toolmaker_executeLWDAQ_Toolmaker_forward
LWDAQ_Toolmaker_loadLWDAQ_Toolmaker_saveLWDAQ_tools_init
Utils.tcl
LWDAQ_close_all_socketsLWDAQ_command_referenceLWDAQ_debug_dump
LWDAQ_decimal_to_binaryLWDAQ_get_dir_nameLWDAQ_get_file_name
LWDAQ_global_var_nameLWDAQ_html_contentsLWDAQ_html_split
LWDAQ_html_tablesLWDAQ_image_boundsLWDAQ_image_pixels
LWDAQ_ip_addr_matchLWDAQ_is_error_resultLWDAQ_list_commands
LWDAQ_load_settingsLWDAQ_ndf_checkLWDAQ_ndf_create
LWDAQ_ndf_data_appendLWDAQ_ndf_data_readLWDAQ_ndf_string_append
LWDAQ_ndf_string_readLWDAQ_ndf_string_writeLWDAQ_post
LWDAQ_proc_declarationLWDAQ_proc_definitionLWDAQ_proc_description
LWDAQ_proc_listLWDAQ_put_file_nameLWDAQ_queue_clear
LWDAQ_queue_errorLWDAQ_queue_startLWDAQ_queue_step
LWDAQ_queue_stopLWDAQ_randomLWDAQ_random_wait_ms
LWDAQ_read_image_fileLWDAQ_save_settingsLWDAQ_script_description
LWDAQ_set_bitLWDAQ_soar_readLWDAQ_socket_accept
LWDAQ_socket_closeLWDAQ_socket_flushLWDAQ_socket_interpreter
LWDAQ_socket_listenLWDAQ_socket_openLWDAQ_socket_protocol
LWDAQ_socket_readLWDAQ_socket_uploadLWDAQ_socket_write
LWDAQ_splitLWDAQ_stop_vwaitsLWDAQ_support
LWDAQ_time_stampLWDAQ_updateLWDAQ_utils_init
LWDAQ_vwaitLWDAQ_vwait_var_nameLWDAQ_wait_ms
LWDAQ_wait_secondsLWDAQ_write_image_file
BCAM.tcl
LWDAQ_analysis_BCAMLWDAQ_daq_BCAMLWDAQ_extended_BCAM
LWDAQ_init_BCAM
Camera.tcl
LWDAQ_analysis_CameraLWDAQ_daq_CameraLWDAQ_init_Camera
Diagnostic.tcl
LWDAQ_analysis_DiagnosticLWDAQ_create_controls_DiagnosticLWDAQ_daq_Diagnostic
LWDAQ_exec_DiagnosticLWDAQ_init_DiagnosticLWDAQ_loop_Diagnostic
LWDAQ_off_DiagnosticLWDAQ_on_DiagnosticLWDAQ_reboot_Diagnostic
LWDAQ_refresh_DiagnosticLWDAQ_reset_DiagnosticLWDAQ_sleep_Diagnostic
LWDAQ_sleepall_DiagnosticLWDAQ_transmit_DiagnosticLWDAQ_wake_Diagnostic
Flowmeter.tcl
LWDAQ_analysis_FlowmeterLWDAQ_create_controls_FlowmeterLWDAQ_daq_Flowmeter
LWDAQ_init_FlowmeterLWDAQ_refresh_Flowmeter
Gauge.tcl
LWDAQ_analysis_GaugeLWDAQ_create_controls_GaugeLWDAQ_daq_Gauge
LWDAQ_init_GaugeLWDAQ_refresh_Gauge
Inclinometer.tcl
LWDAQ_analysis_InclinometerLWDAQ_create_controls_InclinometerLWDAQ_daq_Inclinometer
LWDAQ_init_Inclinometer
Rasnik.tcl
LWDAQ_analysis_RasnikLWDAQ_daq_RasnikLWDAQ_extended_Rasnik
LWDAQ_init_Rasnik
Recorder.tcl
LWDAQ_analysis_RecorderLWDAQ_create_controls_RecorderLWDAQ_daq_Recorder
LWDAQ_init_RecorderLWDAQ_refresh_RecorderLWDAQ_reset_Recorder
RFPM.tcl
LWDAQ_analysis_RFPMLWDAQ_create_controls_RFPMLWDAQ_daq_RFPM
LWDAQ_init_RFPMLWDAQ_refresh_RFPM
Terminal.tcl
LWDAQ_analysis_TerminalLWDAQ_daq_TerminalLWDAQ_init_Terminal
Thermometer.tcl
LWDAQ_analysis_ThermometerLWDAQ_create_controls_ThermometerLWDAQ_daq_Thermometer
LWDAQ_init_ThermometerLWDAQ_refresh_Thermometer
Viewer.tcl
LWDAQ_analysis_ViewerLWDAQ_create_controls_ViewerLWDAQ_DAQ_to_GIF_Viewer
LWDAQ_daq_ViewerLWDAQ_GIF_to_DAQ_ViewerLWDAQ_init_Viewer
LWDAQ_Set_Bounds_ViewerLWDAQ_Set_Dimensions_ViewerLWDAQ_Set_Results_Viewer
LWDAQ_special_analysis_Viewer
Voltmeter.tcl
LWDAQ_analysis_VoltmeterLWDAQ_create_controls_VoltmeterLWDAQ_daq_Voltmeter
LWDAQ_init_VoltmeterLWDAQ_refresh_Voltmeter
WPS.tcl
LWDAQ_analysis_WPSLWDAQ_daq_WPSLWDAQ_extended_WPS
LWDAQ_init_WPS

Introduction

When it starts up, LWDAQ installs hundreds of TCL/TK commands for use in instruments and tools. The script commands are those installed by the TCL/TK scripts that LWDAQ runs at start-up. The library commands are those installed by the lwdaq.so shared library that LWDAQ loads at start-up. This library has been compiled from our Pascal source code. Script commands all begin with LWDAQ in upper case letters, while library commands all begin with lwdaq in lower case letters.

The TCL/TK scripts define the script commands are in the ./LWDAQ.app/Contents/LWDAQ directory of the LWDAQ software installation, and its sub-directories. You will also find them on our Sources Page. Here is a list of the LWDAQ Scripts.

Driver.tclInit.tclInstruments.tclInterface.tcl
Tools.tclUtils.tclBCAM.tclCamera.tcl
Diagnostic.tclFlowmeter.tclGauge.tclInclinometer.tcl
Rasnik.tclRecorder.tclRFPM.tclTerminal.tcl
Thermometer.tclViewer.tclVoltmeter.tclWPS.tcl

Click on any one of the script names, and your browser will take you down the page to a section dedicated to this script and the LWDAQ script commands it defines. We give the TCL declaration of each command, and the description in TCL comments above the declaration in the script. If you do not understand the TCL declaration, search for an "Introduction to TCL/TK Programming" on the web, and look up the syntax for procedure declarations.

The Pascal files that define the library commands are in the ./Sources directory. Each operating system has its own version of lwdaq.so, but all versions define the same commands. Each library 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 libraries and TCL/TK. It provides init_Lwdaq, which TCL/TK calls when it loads the lwdaq dynamic library, and it defines all the library commands. The init_Lwdaq routine installs these commands in the TCL interpreter. The lwdaq.pas file is a Pascal main program rather than a Pascal unit, even though we compile it into a dynamic library. The GPC compiler expects a main program if it is to include the "_p_initialize" routine in the compiled object. We will need this routine to be present in the lwdaq.o object when we link the final lwdaq.dylib dynamic library with GCC.

The lwdaq command (lower case) 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.

Library Commands

lwdaq_bcam

lwdaq_bcam image ?option value?

lwdaq_bcam analyzes bcam images. The routine clears the image overlay for its own use. This routine is the one called by the BCAM Instrument to analyze images.

OptionFunction
-num_spotsThe number of spots the analysis should find.
-thresholdCriteria for finding spots, including threshold specification.
-colorColor for spot outlining in overlay, default red.
-pixel_size_umTells the analysis the pixel size (assumed square)
-show_timinigIf 1, print timing report to gui text window.
-show_pixelsIf 1, mark pixels above threshold.
-analysis_typeSelects the analysisi type
-sort_codeSelects the analysis type.

The lwdaq_bcam routine makes a list of spots in the image. The -threshold string tells lwdaq_bcam how to distinguish background pixels from spot pixels. At the very least, the -threshold string must specify a threshold intensity, or a means of calculating a threshold intensity. All the spot-locating routines called by lwdaq_bcam use the net intensity of pixels, which is the image intensity minus the threshold intensity, with negative values are clipped to zero.

The -threshold string starts with a number and a symbol. The symbol tells lwdaq_bcam how the number and the intensity characteristics of the image are to be used to determine a threshold intensity. The "*" symbol means that the number specifies the threshold directly. No reference to the image intensity is necessary. In this case, the threshold must be between 0 and 255 for eight-bit images. The "%" symbol means that the number is a percentage. The threshold is the minimum image intensity plus a precentage of the difference between the maximum and minimum intensities. The "#" symbol means that the threshold will be the average intensity plus a percentage of the difference between the maximum and average intensities. If there is no symbol, lwdaq_bcam assumes the symbol is "*" and treats the next number, if it's present, as the first of the optional numerical parameters.

The first optional numerical parameters is the mininum number of pixels a spot must contain to be valid. Any spots with fewer than this number will be ignored. Their pixels will be marked white in the overlay.

The lwdaq_bcam routine identifies all distinct sets of contiguous pixels above threshold, eliminates those that do not meet the test criteria, determines the position and intensity of each of remaining set, sorts them in order of decreasing intensity, and eliminates all but the first -num_spots sets. The routine returns the position of each spot in microns with respect to the top-left corner of the image. To convert from pixels to microns, the routine uses -pixel_size_um, and assumes the pixels are square. There are several ways that lwdaq_bcam can calculate the spot position from the net intensity of its pixels.

spot_use_centroid=1;
spot_use_ellipse=2;
spot_use_vertical_line=3;

With analysis_type=1, which is the default, the position of the spot is the weighted centroid of its net intensity. With analysis_type=2, the routine fits an ellipse to the edge of the spot. The position is the center of the ellipse. With analysis_type=3 the routine fits a straight line to the net intensity of the spot and returns the intersection of this straight line with the top of the CCD instead of x, and the anti-clockwise rotation of this line in milliradians instead of y.

The sort_code has the following meanings, and dictates the order in which the spots are returned in the result string.

spot_decreasing_intensity=1;
spot_increasing_x=2;
spot_increasing_y=3;
spot_decreasing_x=4;
spot_decreasing_y=5;

Thus with spot_decreasing_x as the value for sort_code, the routine sorts the num_spots brightest spots in order of decreasing x position, which means spots on the right of the image will appear first in the result string.

With show_pixels trye

See the BCAM Instrument Manual for more information about the option values.

lwdaq_calibration

lwdaq_image_calibration device_calibration apparatus_measurement ?option value?

lwdaq_calibration takes as input an apparatus measurement and a device calibration, and returns a parameter calculation.

lwdaq_config

lwdaq_config ?option value?

lwdaq_config sets global variables that control the operation of the lwdaq analysis libraries. If you specify no options, lwdaq_config returns a string giving you the current values of all the options, except the -eol option. Each option requires a value, which will be assigned to the global variable names in the option. Here are the options and their expected value types. Boolean variables you specify with 0 for false and 1 for true.

-stdout_availableBooleanstandard output channel is available
-stdin_availableBooleanstandard input channel is available
-track_ptrsBooleantrack memory allocation
-text_nameStringtext window in which to print messages
-photo_nameStringphoto in which to draw images and graphs
-zoomIntegerdisplay zoom for images
-intensifyStringintensification type for images,
none, mild, strong, or exact.
-wait_msIntegermilliseconds to pause during lwdaq_gui_wait
-gamma_correctionRealimage drawing gamma correction
-fsrIntegerfield size for real numbers returned in strings.
-fsdIntegerdecimal places for real numbers returned in strings.
-eolStringend of line characters for text windows and files.
-append_errorsBooleanAppend errors to the global error string
instead of over-writing with latest error.

The analysis routines can write to TK text windows, and draw in TK photos through -text_name and -photo_name. During execution, they can pause to allow you to view the intermediate results for -wait_ms millisconds. If you set -wait_ms to -1, TK will open a window with a Continue button in it, which you must click before the analysis proceeds. The gamma correction sets the gray scale image display gamma correction used by lwdaq_draw.

Many routines return real numbers in strings. These real numbers will have a fixed number of decimal places equal to the global Pascal variable fsd and a total field size equal to the global Pascal variable fsr.

The global error_string variable is used by all the command routines in lwdaq.pas. Each command routine resets error_string and checks it when it's finished. If error_string is not empty, the routine will return an error condition and error_string will be its result. The append_errors option tells the analysis library to append new errors to error_string instead of over-writing previous errors with the new error. By default, append_errors is false.

lwdaq_data_manipulate

lwdaq_data_manipulate image_name manipulation ?parameters?

lwdaq_data_manipulate operates upon the data in an image, and we intend it for use with instruments that store one-dimensional arrays of data in an image's intensity array. Our convention, when using the intensity array in this way, is to start storing data in the first column of the second row. This leaves the first row free for header information when we store the image to disk. We refer to the block of memory starting with the first byte of the second row, and ending with the last byte of the last row, as the data space. We specify bytes in the data space with their byte address, which is zero at the first byte in the data space. The routine does not return a text string. It either returns an error or an empty string. The data manipulations alter the existing image.

ManipulationFunction
writeWrites a block of data into the data space.
readReads a block of data from the data space.
shiftShifts data towards start of data space.
clearClears the data.
noneNo action.

The write function requires two parameters: the data you wish to write to the data space, and the byte address at which you want the first byte of your data to be written. The following command writes the contents of data to the data space of the image named image_name starting at the first byte in the data space (which is the first pixel in the second row).

lwdaq_data_manipulate image_name write 0 $data

The read function requires two parameters: the number of bytes you wish to read from the data space, and the byte address at which you want to start reading. The following command reads 10000 bytes starting at byte address 100. If the image has 100 pixels per row, the first byte the routine reads will be the first pixel in the third row of the image.

lwdaq_data_manipulate image_name read 100 10000

The shift function requires one parameter: the number of bytes to the left by which you want the data to be shifted. Shifting to the left is in the direction of the start of the data space. If you specify a negative shift, the routine shifts the data to the right, in the direction of the end of the data space.

The clear function takes no parameters. It clears all the byte in the data space to zero.

lwdaq_diagnostic

lwdaq_diagnostic image ?option value?

lwdaq_diagnostic analyzes sixteen-bit adc samples from the driver supplies. It assumes that five numbers specifying the relay software version, the driver assembly number, the driver hardware version, the controller firmware version, and the data transfer speed are all saved in the input image's results string. The routine leaves these numbers in the results string after it is done.

lwdaq_draw

lwdaq_draw image photo ?option value?

lwdaq_draw transfers the named image into the named TK photo. You pass the lwdaq image name followed by the tk photo name, and then your options in the form ?option value?. When the routine draws the image, it over-writes the first few pixels in the first image row with a header block containing the image dimensions, its analysis bounds, and its results string.

The -intensify option can take four values: mild, strong, exact, and none. Mild intensification displays anything darker than four standard deviations below the mean intensity as black, and anything brighter than four standard deviations above the mean intensity as white. In between black and white the display is linear with pixel brightness. Strong intensification does the same thing, but for a range of two standard deviations from the mean. Exact displays the darkest spot in the image as black and the brightest as white. In all three cases, we calculate the mean, standard deviation, minimum, and maximum intensity of the image within the analysis bounds, not across the entire image.

The -zoom option scales the image as we draw it in the TK photo. If the TK photo is initially smaller than the size required by the zoomed image, the TK photo will expand to accommodate the zoomed image. But if the TK photo is initially larger than required, the TK photo will not contract to the smaller size of the zoomed image. The -zoom option can take any value between 0.1 and 10. But the effective value of -zoom is dicated by the requirements of sub-sampling. If -zoom is greater than 1, we round it to the nearest integer, e, and draw each image pixel on the screen as a block of e×e pixels. If -zoom is less than 1, we round its inverse to the nearest integer, c. We draw only one pixel out of every c pixels in the TK photo. If -zoom = 0.3, we draw every third pixel. If -zoom = 0.4, we draw every third pixel if your computer rounds 1/0.4 to 3, or every second pixel if your computer rounds 1/0.4 to 2.

With -clear set to 1, lwdaq_draw clears the overlay in the lwdaq image before drawing in the TK photo. The overlay may contain a graph or oscilloscope display, or analysis indicator lines. If you don't want these to be displayed, set -clear to 1. But note that whatever was in the overlay will be lost.

By default, -show_bounds is 1, and the routine draws a blue rectangle to show the the image analysis boundaries, which are used by image analysis routines like lwdaq_rasnik and lwdaq_bcam. But with -show_bounds set to 0, this blue rectangle is not drawn. If you want to be sure that you don't have a blue rectangle drawn over your gray-scale image, you should also specify -clear 1, so that lwdaq_draw will clear the image overlay of any pre-existing blue rectangles.

lwdaq_flowmeter

lwdaq_flowmeter image ?option value?

lwdaq_flowmeter analyzes sixteen-bit adc values by calling lwdaq_A2053_flowmeter. It assumes that two numbers specifying the sample period and the number of channels sampled are saved in the input image's results string. The routine leaves these numbers in the results string after it is done.

lwdaq_gauge

lwdaq_gauge image ?option value?

lwdaq_gauge analyzes sixteen-bit adc values by calling lwdaq_A2053_gauge. The routine assumes that two numbers specifying the sample period and the number of channels sampled are saved in the input image's results string. The routine leaves these numbers in the results string after it is done. For each gauge channel in the image, the routine returns a result, according to the result specifiers. With -ave 1, the result for each channel includes the average gauge value. With -stdev 1, the result includes the standard deviation of the gauge value. With both set to zero, the result is an empty string. The default values for ave and stdev are 1 and 0 respectively.

lwdaq_graph

lwdaq_graph data image ?option value?

lwdaq_graph takes a string from TCL that contains consecutive x-y value pairs, and plots a graph of the values in the overlay of an image. The routine fills the analysis bounds of the image with a graph, or it fills the entire image with the graph. You can specify the values of x and y that correspond to the edges of the plotting area. If you do not specify the edgs, the routine will stretch or compress the plot to fit exactly in the available space.

OptionValue and Effect
-x_minx at left edge, if 0 with x_max, pick minimum value of x.
-x_maxx at right edge, if 0 with x_min, pick maximum value of x.
-y_miny at bottom edge, if 0 with y_max, pick minimum value of y.
-y_maxy at top edge, if 0 with y_min, pick maximum value of y.
-ac_coupleadd average y-value to y_min and y_max.
-colorinteger code for the color.
-clearif 1, clear image overlay before plotting.
-fillif 1, fill image overlay before plotting.
-x_divif > 0, plot vertical divisions spaced by this amount.
-y_divif > 0, plot horizontal divisions spaced by this amount.
-entireif 1, use entire image for plot, if 0, use analysis bounds.

The color codes for the graph give 255 unique colors. You can try them out to see which ones you like.

lwdaq_image_characteristics

lwdaq_image_characteristics image

lwdaq_image_characteristics returns features of the image: the left, top, right, and bottom edges of the analysis boundries, the average, standard deviation, maximum, and minimum values of intensity, and the height and width of the image.

lwdaq_image_contents

lwdaq_image_contents image

lwdaq_image_contents returns a byte array containing the intensity array from the named image. In the first line of the image the routine records the image dimensions, analysis boundry, and results string. The integers are two-bytes long, and we use big-endian byte ordering, so the high-order byte is first.

If you specify -truncate 1, the routine removes all trailing zero-bytes from the data. When we create a new image to accomodate the same data later, we clear the image intensity array before we copy in the new data, so the image is re-constructed faithfully. This truncation is effective at reducing the size of data files from instruments that don't fill the intensity array with real data, but instead use the intensity array as a place to store one-dimensional data, and use the overlay as a white-board upon which to render the data (like the Voltmeter). If you specify -data_only 1, the routine chops off the leading row of data, leaving only the data from the first pixel of the first row onwards, which is the block of data operated upon by our lwdaq_data_manipulate routines. If you specify -record_size larger than 1, the routine makes sure that the size of the block it returns is divisible by the record size.

lwdaq_image_create

lwdaq_image_create option value ?option value?

lwdaq_image_create creates a new image and returns a unique name for the image, by which the interpreter can identify the image to other lwdaq routines.

OptionFunction
-nameSpecify the name for the image.
-resultsSet the image results string.
-widthThe width of the image in pixels.
-heightThe height of the image in pixels
-dataPixel intensity values as a binary array of bytes.
-leftLeft column of analysis bounds.
-rightRight column of analysis bounds.
-topTopm row of analysis bounds.
-bottomBottom row of analysis bounds.
-try_headerTry the image data for a legitimate lwdaq-format header.

The above table lists the options accepted by lwdaq_image_create, and their functions. If you use the -name option and provide the name of a pre-existing image in the lwdaq image list, lwdaq_image_create deletes the pre-existing image. If you specify "-data $value", the routine copies $value into the image's intensity array, starting at the first pixel of the first row. When you combine "-data $value" with "-try_header 1", the routine looks at the first bytes in $value to see if it contains a valid image header, specifying image width and height, as well as analysis bounds and a results string. When the routine looks for the header, it assumes that the bytes in the header specify two-byte integers in big-endian order.

If you have -try_header 0, or if the routine's effort to find a header fails, lwdaq_image_create will look at the values you specify for the analysis bounds with the -left, -top, -right, and -bottom options. A value of −1 directs the routine to place the boundary at the edge of the image. The default values for these options are all −1.

lwdaq_image_destroy

lwdaq_image_destroy image

lwdaq_image_destroy disposes of an image. You can specify multiple images, or image name patterns with * and ? wild cards. You can enter multiple image names on the command line, too.

lwdaq_image_exists

lwdaq_image_exists image ?option value?

lwdaq_image_exists returns a list of images in the lwdaq image list that match the image_name pattern you pass to the routine. If you pass "*", it will return a list of all existing images. If there are no matching images, lwdaq_image_exists returns an empty string.

lwdaq_image_histogram

lwdaq_image_histogram image

lwdaq_image_histogram returns a histogram of image intensity within the analysis bounds of an image. The histogram takes the form of an x-y graph in a space-delimited string, with the x-coordinate representing intensity, and the y-coordinate representing frequency.

lwdaq_image_manipulate

lwdaq_image_manipulate image_name manipulation ?option value?

lwdaq_image_manipulate returns the name of a new image derived from one or more images passed to lwdaq_image_manipulate. If we set the -replace option to 1 then lwdaq_image_manipulate replaces the original image with the result image. The command takes the name of an image in the LWDAQ image list, and the name of a manipulation to be performed upon this image. The currently-supported manipulations are as follows.

Manipulation
Code
Function
noneNo manipulation of pixels, the new image is the old image.
invertTurn image upside-down by reversing order of pixels. Top-left becomes bottom-right.
reverse_rowsReverse the order of the rows. The top row becomes the bottom row.
soecSwap odd and even columns. This routine corrects errors in images recorded from certain obsolete data acquisition systems.
grad_iMagnitude of the horizontal intensity derivative.
grad_i_sHorizontal intensity derivative, signed.
grad_jMagnitude of the vertical intensity derivative.
grad_j_sVertical intensity derivative, signed.
gradMagnitude of the intensity gradient.
negateNegate the image.
smoothSmooth with 3 × 3 box filter and add contrast.
copyCopy the image into a new image.
combineReplaces a portion of the image.
subtractSubtract a second image from the first image.
rasnikDraw a rasnik pattern in the image.
Table: Manipulation Codes and their Functions.

The subtract manipulation requires you to name a second image, which will be subtracted from the first to create a third image. The none manipulation does nothing. In each case, we have a new image pointer, but with the none manipulation, this image pointer is a pointer to the first image. The combine manipulation allows you to write over the data in an image, starting with the offset'th pixel. You specify offset after the data. The manipulation copies the entire contents of an m-byte binary block into the image, starting at pixel offset, and ending at pixel offset+m-1. If the copy goes past the end of the image array, the manipulation aborts without doing anything, and returns an error.

The gradient manipulations either return an absolute intensity gradient or a signed intensity gradient. We calculate the horizontal gradient at pixel (i,j) by subtracting the intensity of pixel (i-1,j) from that of pixel (i+1,j). The vertical gradient is (i,j+1) minus (i,j-1). When we return the magnitude of the gradient, the intensity of the gradient image is simply the absolute value of the gradient. When we return the signed gradient, we offset the gradient image intensity by mid_intensity, which is 128 for eight-bit gray scale images. Thus an intensity of 128 means zero gradient, and an intensity of 138 means +10. When the gradient exceeds 127 or -128, we clip its value to 255 and 0 respectively. For more details, see the image_filter and subsequent routine in image_manip.pas.

The rasnik manipulation draws a rasnik pattern in the image. We specify the rasnik pattern with a string of six numbers: origin.x, origin.y, pattern_x_width, pattern_y_width, rotation, and sharpness. The origin is the image coordinates of the top-left corner of one of the squares in the chessboard. Units are pixels, not mircons. The x and y width of the squares are in the near-horizontal and near-vertical direction respectively. Units are pixels again. The rotation is counter-clockwise in milliradians of the pattern with respect to the sensor. With sharpness 1, the pattern has sinusoidal intensity variation from black to white. With sharpness less than 1, the amplitude of the sinusoidal variation decreases in proportion. With sharpness greater than one, the sinusoidal amplitude increases in proportion, but is clipped to black and white intensity, so that we obtain a sharply-defined chessboard.

OptionFunction
-nameThe name of the new image will be $value.
-resultsSet the new image results string to $value.
-replaceIf $value is 1, delete the original image and replace it with the new one. 0 by default.
-clearif $value is 1, clear overlay of final image, 0 by default.
-fillif $value is 1, fill overlay of final image with white, 0 by default.
-paintpaint the analysis bounds with color number $value.
-bottomSet the bottom of the analysis bounds to $value.
-topSet the top of the analysis bounds to $value.
-leftSet the left of the analysis bounds to $value.
-rightSet the rigth of the analysis bounds to $value.

With -name you specify the name of the new image created by the manipulation, or the existing image if there is no new image created by the manipulation. Any pre-existing images with this name will be destroyed before the name change occurs.

With -replace 0, the manipulation creates a new image and returns its name. With -replace 1, the manipulation over-writes data in the old image and returns the old image name.

The -paint option instructs lwdaq_image_manipulate to paint the entire area within the analysis bounds with the color given by $value. This value should be a number between 0 and 255. The value 0 is for transparant. Other than the 0-value, the number will be treated like an eight-bit RGB code, with the top three bits for red, the middle three for green, and the bottom three for blue. Thus $E0 (hex E0) is red, $1C is green, and $03 is blue.

In addition to the pixel manipulations, we also have options to change other secondary properties of the image. The table above shows the available manipulation options, each of which is followed by a value in the command line, in the format ?option value?.

When you specify the analysis bounds, a value of −1 is the code for "do nothing". The boundary will remain as it was. This use of the −1 code contasts with that of lwdaq_image_create, where −1 directs lwdaq_image_create to move the boundary to the edge of the image.

lwdaq_image_results

lwdaq_image_results image

lwdaq_image_results returns an image's results string, which may be up to short_string_length characters long.

lwdaq_inclinometer

lwdaq_inclinometer image ?option value?

lwdaq_inclinometer analyzes an image returned by the Inclinometer instrument. It returns the amplitude of harmonics in signals recorde in an image.

lwdaq_photo_contents

lwdaq_photo_contents photo

lwdaq_photo_contents returns a byte array containing gray-scale intensity array corresponding to a tk photo. The routine uses the red intensity as the gray-scale intensity, which will work in a purely gray-scale image, and assumes that the red intensity is an 8-bit number.

The routine embeds the image dimensions in the first four pixels of the image by over-writing them with j_size-1 and i_size-1 each as two-byte integers in big-endian format. If the image is one that has been previously stored or drawn by lwdaq routines, the first twelve pixels of the first line will already contain the image dimensions, plus the analysis boundaries, all encoded as two-byte big-endian integers. Because the routine already knows for sure what the image dimensions are, it over-writes dimensions in the first row. But it does not over-write the analysis boundaries. These may be correct or incorrect. You can pass this routine's result to lwdaq_image_create, and have the image-creating routine check the first twelve bytes for valid analysis bounds, or ignore these bounds and use newly-specified bounds.

To assemble the 8-bit gray-scale image, the routine uses the lwdaq scratch image. If the routine were to allocate and dispose of an image, the printing activity of the disposal when -track_ptrs is set to 1 would alter the TCL return string.

lwdaq_rasnik

lwdaq_rasnik image ?option value?

lwdaq_rasnik analyzes rasnik images. Specify the image with -image_name as usual. The routine clears the image overlay for its own use. The routine takes the following options, each of which you specify by giving the option name followed by its value, ?option value?. See the Rasnik Instrument for a description of the options.

OptionFunction
-reference_codeSelects the analysis reference point.
-reference_x_umx-coordinate of reference point when -reference_code=3.
-reference_y_umy-coordinate of reference point when -reference_code=3.
-orientation_codeSelects the analysis orientation code.
-square_size_umTells the analysis the mask square size (assumed square).
-pixel_size_umTells the analysis the pixel size (assumed square)
-show_timinigIf 1, print timing report to gui text window.
-show_fittingIf <> 0, show fitting stages with delay $value ms.
-pattern_onlyIf 1, return pattern description not rasnik measurement.

See the Rasnik Instrument Manual for more information about the option values, in particular the reference and orientation code meanings.

With the -pattern_only option set, the routine returns a description of the chessboard pattern it finds in the image. The result string contains seven numbers: origin.x, origin.y, pattern_x_width, pattern_y_width, rotation, error, and extent. The origin values are the image coordinates of the top-left corner of one of the squares in the chessboard. Units are pixels, not mircons. The next two numbers are the width of the squares in the near-horizontal direction and their width in the near-vertical direction. Units are again pixels. The rotation is counter-clockwise in milliradians. The error is an estimate of the fitting accuracy in pixel widths. The extent is the number of squares from the image center over which the pattern extends.

lwdaq_rasnik_shift

lwdaq_rasnik_shift old_result ?option value?

lwdaq_rasnik_shift takes in a rasnik result string and shifts it to a new reference point. The routine gets the old reference point from the results string, and re-calculates the rasnik measurement using the x and y coordinates you specify with -reference_x_um and -reference_y_um.

lwdaq_recorder

lwdaq_recorder image command

lwdaq_recorder steps through the pixels of an image looking for valid messages from an asynchronous transmitter such as the Subcutaneous Transmitter (A3013) as received by a Data Receiver (A3018). It draws the signals it discovers in the image overlay. See the Recorder Instrument Manual for details.

lwdaq_rfpm

lwdaq_rfpm image ?option value?

lwdaq_rfpm analyzes images from an RFPM instrument.

lwdaq_sampler

lwdaq_sampler image command

lwdaq_sampler steps through the pixels of an image looking for valid samples from a sampling circuit like the ADC Tester (A2100).

lwdaq_voltmeter

lwdaq_voltmeter image ?option value?

lwdaq_voltmeter analyzes image data for the Voltmeter instrument.

lwdaq_wps

lwdaq_wps image ?option value?

lwdaq_wps analyzes wps images. It clears the overlay for its own use. We describe the analysis in our WPS1 Manual.

pixels.
OptionFunction
-pixel_size_umWidth and height of image pixels in microns.
-reference_umLocation of reference line in microns below top edge of top row.
-show_timinigIf 1, print timing report to gui text window, default zero.
-show_edgesIf 1, show edge pixesls in image, defalut zero
-num_wiresThe number of wires you want the routine to find.
-pre_smoothSmooth the image before you take the derivative.
-thresholdCriteria for finding spots, including threshold specification.

The -threshold string is used in the same way as in lwdaq_bcam. It can contain an intensity threshold or it can define a means to calculate the threshold. The string can also specify the minimum number of pixels a spot must contain, and its maximum eccentricity. Spots that do not meet these criteria will be marked as invalid. In this case, note that the threshold intensity will be applied to the horizontal gradient of the wire image, not the image itself. With -pre_smooth set to 1, the threshold will be applied to the gradient of the smoothed image.

The wire positions are given with respect to a horizontal reference line drawing reference_um microns down from the top edge of the top image row. With show_edges equal to zero (the default value), the routine plots the image's horizontal intensity profile in green and the derivative profile in yellow. But when you set show_edges to 1, the routine no longer plots these two graphs, but instead displays the spots it finds in the derivative image, overlayed upon the original image. The edges of a wire will be covered with colored pixels. White pixels are ones that were part of spots that did not satisfy the -threshold critera.

Library Routines

The lwdaq command acts as an entry point into our analysis libraries, making various math functions available at the TCL command line. You specify the routine you wish to call, and pass arguments to the routine in strings or byte arrays or both. Most routines return results as text strings in which real numbers are encoded in characters with a fixed number of decimal places, as defined by the global constants fsr and fsd. You can set both of these with lwdaq_config. Beware that these routines can round small values to zero. In the comments below, we assume that fsr is 8, and fsd is 6.

bcam_from_global_point

lwdaq bcam_from_global_point point mount

Transforms a point in global coordinates to a point in BCAM coordinates. The point in BCAM coordinates is returned as a string of three numbers, the BCAM x, y, and z coordinates of the point. You specify the point in global coordinates with the point parameter, which also takes the form of a string of three numbers, these numbers being the global x, y, and z coordinates of the point whose BCAM coordinates you want to determine. You specify how the BCAM and global coordinate systems relate to one another with the mount string. The mount string contains the global coordinates of the BCAM's kinematic mounting balls. You specify the coordinates of the cone, slot, and flat balls, and for each ball you give its x, y, and z coordinates. In the following example, we transform the global point (0,1,0) into BCAM coordinates when our cone, slot and flat balls have coordinates (0,1,0), (-1,1,-1), and (1,1,-1).

lwdaq bcam_from_global_point "0 1 0" "0 1 0 -1 1 -1 1 1 -1"
0.000000 0.000000 0.000000

For a description of the BCAM coordinate system, and how it is defined with respect to a BCAM's kinematic mounting balls, consult the BCAM User Manual. We usually use millimeters to specify coordinates, because we use millimeters in our BCAM camera and source calibration constants. But the routine will work with any units of length, so long as you use the same units for both the point and the mount strings.

bcam_from_global_vector

lwdaq bcam_from_global_vector vector mount

Transforms a vector in global coordinates to a vector in BCAM coordinates. See bcam_from_global_point for more details.

lwdaq bcam_from_global_vector "0 1 0" "0 1 0 -1 1 -1 1 1 -1"
0.000000 1.000000 0.000000

For a description of the BCAM coordinate system, and how it is defined with respect to a BCAM's kinematic mounting balls, consult the BCAM User Manual.

bcam_source_bearing

lwdaq bcam_source_bearing spot_center camera

Calculates the line upon which a light source must lie for its image to be centered at spot_center. The line is returned as a string containing six numbers. The first three numbers are the coordinates of the BCAM pivot point in BCAM coordinates in millimeters. The last three numbers are a unit vector in the direction of the line. The BCAM itself you describe with its calibration constants in the camera string. The camera string contains nine elements, as described in the BCAM User Manual. The camera string specifies length in millimeters and rotation in milliradians.

lwdaq bcam_source_bearing "1.72 1.22" "P0001 1 0 0 0 0 1 75 0"
1.000000 0.000000 0.000000 0.000000 0.000000 1.000000

The first element in the camera string is the name of the camera, even though this calculation does not use the camera name. In the example above, P0001 is the camera name, the pivot point is at (1,0,0) in BCAM coordinates, the camera axis is parallel to the BCAM z-axis, the pivot point is 75 mm from the lens, and the CCD rotation is zero. We transform point (1.72, 1.22) on the CCD (dimensions are millimeters) into a bearing that passes through the pivot point (1,0,0) in the direction (0,0,1). The point (1.72,1.22) is our aribitrarily-chosen center of the CCD in all currently-available BCAMs (it is close to the center of the TC255P image sensor, but not exactly at the center). The BCAM camera axis is the line passing through the CCD center and the pivot point.

bcam_source_position

lwdaq bcam_source_position spot_center bcam_z camera

Calculates the BCAM coordinates of a light source whose image is centered at spot_center, and which we know to lie in the plane z = bcam_z in BCAM coordinates. The routine is similar to bcam_source_bearing, but you specify the BCAM z-coordinate of the source as well, in millimeters. The routine determines the position of the source by calling bcam_source_bearing and intersecting the source bearing with the z=range plane.

lwdaq bcam_source_position "1.72 1.22" 1000 "P0001 1 0 0 0 0 1 75 0"
1.000000 0.000000 1000.000000

Here we see the source is at (1,0,1000) in BCAM coordinates, where all three coordinates are in millimeters. You specify the BCAM itself with its calibration constants using the camera string, just as for bcam_source_bearing.

fourier_term

lwdaq fourier_term period waveform

Calculates a term in the discrete Fourier transform of waveform by calling calculate_ft_term from utls.pas. You specify the waveform as a string of real numbers. Each represents the value of the waveform at discrete, consecutive moments in time (or space, or some other one-dimensional metric) separated by the sample interval. You specify which term you want to calculate by giving its period in units of sample intervals with the period parameter. The routine returns a string containg the amplitude and phase of the term in the fourier transform corresponding to period. If you pass "2" for the period and "0 1 0 1 0 1" for the data, the routine returns, "1.000000 0.500000". The phase, as you can see, is given in units of sample interval, and its sine is such that you subtract it from the phase of a sinusoid to create the Fourier term. To obtain the zero-frequency (DC) term, which corresponds to period infinity, pass period "0" to the routine. We use "0" as a code for "infinity", since we cannot calculate the discrete fourier transform at period zero. If you want to calculate a fourier transform made up of many fourier terms, try using the fourier_transform routine instead. It is much faster when you have a large waveform and many frequencies in your desired spectrum, because it translates the TCL data string into a Pascal binary string only once.

fourier_transform

lwdaq fourier_transform periods waveform

Calculates a series of terms in the discrete Fourier transform of waveform. In effect, this option acts like repeated calls to fourier_term, but is more efficient for large waveform strings, because TCL does not have to copy the string for each term. Instead of passing the routine a single period for a single fourier term, you pass a list of periods. The routine returns a list of terms, each term consisting of the period, amplitude and offset, separated by spaces. To improve its accuracy when calculating terms with non-zero frequency, the routine subtracts the average value of the waveform from each term in the waveform before it calculates terms. In response to period "0", the routine returns the average value of the waveform, so "0" is how you indicate period infinity.

global_from_bcam_point

lwdaq global_from_bcam_point point mount

Transforms a point in global coordinates to a point in BCAM coordinates. It is the inverse of bcam_from_global_point. You pass it the global coordinates of a point in the point string, and the coordinates of the BCAM's kinematic mounting balls with the mount string. The routine returns the global coordinates of the point.

lwdaq global_from_bcam_point "0 1 0" "0 1 0 -1 1 -1 1 1 -1"
0.000000 2.000000 0.000000

For a description of the BCAM coordinate system, and how it is defined with respect to a BCAM's kinematic mounting balls, consult the BCAM User Manual.

global_from_bcam_vector

lwdaq global_from_bcam_vector vector mount

Transforms a vector in global coordinates to a vector in BCAM coordinates. It is the inverse of bcam_from_global_vector.

lwdaq global_from_bcam_vector "0 1 0" "0 1 0 -1 1 -1 1 1 -1"
0.000000 1.000000 0.000000

For a description of the BCAM coordinate system, and how it is defined with respect to a BCAM's kinematic mounting balls, consult the BCAM User Manual.

linear_interpolate

lwdaq linear_interpolate x_position x_y_data

Interpolates between the two-dimensional points of x_y_data to obtain an estimate of y at x=x_position. If you pass "2.5" for the x position, and "0 0 10 10" for the x-y data, the routine will return "2.500000".

matrix_inverse

lwdaq matrix_inverse matrix

Calculates the inverse of a square matrix. You pass the original matrix as a string of real numbers in matrix. The first number should be the top-left element in the matrix, the second number should be the element immediately to the right of the top-left element, and so on, proceeding from left to right, and then downwards to the bottom-right element. The command deduces the dimensions of the matrix from the number of elements, which must be an integer square. For more information about the matrix inverter, see matrix_inverse in utils.pas. The "lwdaq matrix_inverse" routine is inefficient in its use of the matrix_inverse function. The routine spends most of its time translating between TCL strings and Pascal floating point numbers. A 10x10 matrix inversion with random elements takes 1800 μs on our 1 GHz iBook, of which only 100 μs is spent calculating the inverse. The routine returns the inverse as a string of real numbers, in the same format as the original matrix.

straight_line_fit

lwdaq straight_line_fit data

Fits a straight line to data, where data contains a string of numbers, alternating between x and y coordinates. The routine returns a string of three numbers: slope, intercept, and rms residual. The rms residual is the standard deviation of the difference between the straight line and the data, in the y-direction. The data "0 3 1 5 2 7 5 13" would represent a straight line with slope 2, intercept 3, and rms residual 0. The result would be "2.000000 3.000000 0.000000".

sum_sinusoids

lwdaq sum_sinusoids a.amplitude a.phase b.amplitude b.phase

Adds two sinusoidal waves of the same frequency together. You specify the two waves with their amlitude and phase. The phase must be in radians. The amplitude is dimensionless. The result contains the amplitude and phase of the sum of the two waves. If you pass the numbers "1 0 1 0.1" to the routine, it will return "1.997500 0.050000".

wps_wire_plane

lwdaq wps_source_plane wire_center wire_rotation camera

Calculates the plane that must contain the center-line of a wire given the position and rotation of a wire image in a WPS camera. The units for wire position are millimeters, and for rotation are milliradians. We use the camera's calibration constants to determine the plane. We specify the plane in WPS coordinates, which are defined in the same way as BCAM coordinates, using the positions of the WPS (or BCAM) mounting balls. For a description of the BCAM coordinate system, consult the BCAM User Manual.

lwdaq wps_wire_plane "1.720 1.220" "0.000" "Q0131_1 0 0 0 -10 0 0 0 0 0"
0.000000 0.000000 0.000000 0.000000 0.000000 1.000000

The image position in our example is 1.720 mm from the right and 1.220 mm from the top. This is at the nominal center point of a TC255 image sensor. The wire is rotated by 0 mrad anti-clockwise in the image. The first element in the camera string is the name of the camera, even though this calculation does not use the camera name. In the example above, Q0131_1 is the camera name. It is camera number one on the WPS with serial number Q0131. In this example, the camera pivot point is at (0,0,0) in WPS coordinates, which puts it at the center of the cone ball supporting the WPS. That's clearly impossible, but we're just using simple numbers to illustrate the routine. The center of the image sensor (the CCD) is at (-10,0,0). The x-axis runs directly through the pivot point and the center of the sensor. The rotation of the sensor is (0,0,0), which means the x-axis is perpendicular to the sensor surface. Here is another example.

lwdaq wps_wire_plane "1 1.220" "10.000" "Q0131_1 0 0 0 -10 0 0 0 0 0"
0.000000 0.000000 0.000000 0.071811 0.009974 0.997368

The routine calculates the plane that contains the center of the image and the pivot point. It specifies the plane as the pivot point, which is a point in the plane, and a normal to the plane. The first three numbers in the result are the coordinates of the pivot point. The last three numbers are the normal to the plane. The normal is a unit vector.

xyz_line_plane_intersection

lwdaq xyz_line_plane_intersection line plane

Determines the point at which a line and a plane intersect. We specify the line with a point and a direction. We specify the plane with a point and a normal vector.

xyz_plane_plane_intersection

lwdaq xyz_plane_plane_intersection plane_1 plane_2

Determines the line along which two planes intersect. We specify each plane with a point in the plane and a normal to the plane, making six numbers for each plane.

Driver.tcl

Driver.tcl defines procedures that communicate with data acquisition drivers and system controllers through TCPIP sockets. The Driver.tcl routines call the sockeet-handling routines defined in Utils.tcl.

LWDAQ_byte_poll

proc LWDAQ_byte_poll {sock addr value} 

LWDAQ_byte_poll tells the relay at the other end of TCPIP socket $sock to wait until the byte it reads from address $addr has value $value.

LWDAQ_byte_read

proc LWDAQ_byte_read {sock addr} 

LWDAQ_byte_read reads a byte from the controller address space on a driver. The read takes place through a socket open with the driver called $sock, and reads a byte from controller address $addr. The routine returns the byte as a decimal number.

LWDAQ_byte_write

proc LWDAQ_byte_write {sock addr value} 

LWDAQ_byte_write writes byte $value through TCPIP socket $sock to controller address $addr. Note that value is a string of digits that represent a decimal number.

LWDAQ_clear_data_addr

proc LWDAQ_clear_data_addr {sock} 

LWDAQ_clear_data_addr clears the data address of a driver's data address to zero. The driver is at the other end of an open TCPIP socket $sock.

LWDAQ_config_read

proc LWDAQ_config_read {sock} 

LWDAQ_config_read reads the configuration parameters from the LWDAQ relay at the other end of an open TCPIP socket $sock, and returns them if they are valid. If the contents are not valid, the routine reports an error. The parameters the routine reads are those in the relay's RAM. These are the the ones in effect on the relay. They are not the ones written in the relay's EEPROM configuration file. There is no way to read the EEPROM configuration directly. The EEPROM parameters are loaded into ram after a hardware reset, which can be performed by pressing a button on the driver, or with LWDAQ_relay_reboot.

LWDAQ_config_write

proc LWDAQ_config_write {sock config} 

LWDAQ_config_write writes $config to the configuration EEPROM on the relay. The new configuration parameters will not take effect until you reboot the driver. Until then, the existing parameters in the driver's RAM will remain in effect.

LWDAQ_controller_reset

proc LWDAQ_controller_reset {sock} 

LWDAQ_controller_reset writes the value 1 to the software reset byte on a controller at the other end of socket $sock, thus resetting all its state machines and registers. The relay remains unaffected.

LWDAQ_delay_seconds

proc LWDAQ_delay_seconds {sock value} 

LWDAQ_delay_seconds tells a driver at the other end of $sock to pause for $value seconds. The routine does not itself take $value seconds, but the driver will be busy for $value seconds after it receives the delay instructions. If the delay is larger than $LWDAQ_Driver(max_delay_seconds) then the routine submits multiple delay jobs to create a total delay of $value seconds.

LWDAQ_driver_init

proc LWDAQ_driver_init {} 

LWDAQ_driver_init initializes the global variable LWDAQ_Driver that describes the LWDAQ Relay and LWDAQ Controller sections of the LWDAQ Driver.

LWDAQ_echo

proc LWDAQ_echo {sock s} 

LWDAQ_echo takes a string and sends it to a driver in an echo message. It waits for a data return message containing a string, which should match the string it sent.

LWDAQ_execute_job

proc LWDAQ_execute_job {sock job} 

LWDAQ_execute_job tells a driver to execute job with job identifier $job through socket $sock. The driver will be busy thereafter for however long it takes to execute the job, but the routine will return as soon as the TCPIP messages required to instruct the driver have been transmitted. Note that if you have lazy_flush set to 1, the job won't execute until you flush the socket, close it, or read from it.

LWDAQ_firmware_version

proc LWDAQ_firmware_version {sock} 

LWDAQ_firmware_version reads the controller's firmware version number through open socket $sock, and returns the version.

LWDAQ_hardware_id

proc LWDAQ_hardware_id {sock} 

LWDAQ_hardware_id reads the controller identifier number from the LWDAQ driver at the other end of TCPIP socket $sock, and returns the identifier.

LWDAQ_hardware_version

proc LWDAQ_hardware_version {sock} 

LWDAQ_hardware_version reads the controller's hardware version number through open socket $sock, and returns it.

LWDAQ_integer_write

proc LWDAQ_integer_write {sock addr value} 

LWDAQ_integer_write writes a four-byte integer $value through open TCPIP socket $sock to controller address $addr.

LWDAQ_job_done

proc LWDAQ_job_done {sock} 

LWDAQ_job_done returns 1 if the driver's job register reads back zero, and 1 otherwise.

LWDAQ_login

proc LWDAQ_login {sock password {error_on_fail 1}} 

LWDAQ_login attempts to log into a LWDAQ relay with a login message and password $password. The routine recognises "no_password" as a key phrase to skip the login attempt and return the value 0. Otherwise, the routine sends the password and waits for an answer from the relay. An answer of 1 is success and 0 is failure. On success, the routine returns 1. On failure, the routine will generate an error by default, or return -1 if you pass the value 0 for error_on_fail.

LWDAQ_loop_time

proc LWDAQ_loop_time {sock} 

LWDAQ_loop_time reads the contents of a LWDAQ Driver's loop timer register and returns it. The driver is at the other end of an open TCPIP socket named $sock.

LWDAQ_mac_read

proc LWDAQ_mac_read {sock} 

LWDAQ_mac_read reads the mac address of the Ethernet chip on the LWDAQ relay at the other end of open TCPIP socket $sock, and returns the address.

LWDAQ_most_recent_byte

proc LWDAQ_most_recent_byte {sock} 

LWDAQ_most_recent_byte reads the contents of a LWDAQ Driver's mrb register and returns it. The driver is at the other end of an open TCPIP socket named $sock. The mrb register contains the most recent byte to be written to the Driver's ram, either by the relay or by the controller.

LWDAQ_off

proc LWDAQ_off {sock} 

LWDAQ_off turns off power to all devices connected to the driver listening at the other end of $sock.

LWDAQ_on

proc LWDAQ_on {sock} 

LWDAQ_on turns on power to all devices connected to the driver listening at the other end of $sock.

LWDAQ_ram_delete

proc LWDAQ_ram_delete {sock addr length {value 0}} 

LWDAQ_ram_delete sets the LWDAQ Controller's data address equal to $addr and then clears a block of $length bytes starting from address $addr in the LWDAQ Controller memory. The bytes are set to zero unless another value is passed to the routine.

LWDAQ_ram_read

proc LWDAQ_ram_read {sock addr length} 

LWDAQ_ram_read sets the LWDAQ Controller's data address equal to $addr and reads a block of $length bytes from the controller's RAM Portal. The routine returns the bytes as a TCL byte array object.

LWDAQ_ram_write

proc LWDAQ_ram_write {sock addr data} 

LWDAQ_ram_write sets the LWDAQ Controller's data address equal to $addr and writes a block of data byte by byte into the RAM Portal.

LWDAQ_receive_byte

proc LWDAQ_receive_byte {sock} 

LWDAQ_receive_byte receives a data return message and scans its contents for single-byte integer.

LWDAQ_receive_data

proc LWDAQ_receive_data {sock} 

LWDAQ_receive_data receives a LWDAQ Message Protocol data return message from a socket and returns the message contents. The routine supports the lwdaq and siap message formats.

LWDAQ_receive_integer

proc LWDAQ_receive_integer {sock} 

LWDAQ_receive_integer receives a data return message and scans its contents for a four-byte integer in big-endian byte order (most significant byte received first).

LWDAQ_relay_reboot

proc LWDAQ_relay_reboot {sock} 

LWDAQ_relay_reboot resets the relay without affecting the controller. This routine is supported only by relay software versions thirteen and up.

LWDAQ_set_base_addr_hex

proc LWDAQ_set_base_addr_hex {sock value} 

LWDAQ_set_base_addr_hex sets the four bytes of the driver's base address to $value, where $value is a hexadecimal 32-bit number. The driver is at the other end of open TCPIP socket $sock. The base address register exists in LWDAQ components like the VME-TCPIP Interface (A2064), where it sets the base position in VME address space of the LWDAQ Driver with VME Interface to which subsequent instructions to the A2064 should be directed. We call this routine whenever we open a TCPIP socket to a LWDAQ component. The routine accepts a hex number followed by a colon and an integer "00E00000:7". It uses the hex number before the colon as the base address.

LWDAQ_set_command_reg

proc LWDAQ_set_command_reg {sock value} 

LWDAQ_set_command_reg sets a driver's command register to $value through TCPIP socket $sock.

LWDAQ_set_command_reg_binary

proc LWDAQ_set_command_reg_binary {sock value} 

LWDAQ_set_command_reg_binary sets a driver's command register to $value, where $value is a binary string representation of the register's sixteen bits.

LWDAQ_set_command_reg_hex

proc LWDAQ_set_command_reg_hex {sock value} 

LWDAQ_set_command_reg_hex sets a driver's command register to $value, where $value is a hexadecimal string representation of the register's sixteen bits.

LWDAQ_set_ct_config

proc LWDAQ_set_ct_config {sock value} 

LWDAQ_set_ct_config sets a driver's counter-timer configuration register to $value through $sock.

LWDAQ_set_data_addr

proc LWDAQ_set_data_addr {sock value} 

LWDAQ_set_data_addr sets the four bytes of the driver's data address to $value. The driver is at the other end of open TCPIP socket $sock.

LWDAQ_set_delay_seconds

proc LWDAQ_set_delay_seconds {sock value} 

LWDAQ_set_delay_seconds sets a driver's delay timer to a number of ticks that will count down to zero in $value seconds. The driver is at the other end of TCPIP socket $sock.

LWDAQ_set_delay_ticks

proc LWDAQ_set_delay_ticks {sock value} 

LWDAQ_set_delay_ticks sets a driver's delay timer to $value through socket $sock.

LWDAQ_set_device_addr

proc LWDAQ_set_device_addr {sock value} 

LWDAQ_set_device_addr sets the device address register on a driver to $value through TCPIP socket $sock. The driver will be busy with this instruction for a few tens of microseconds thereafter, as it switches its driver sockets and transmits a new address down the newly active socket.

LWDAQ_set_device_element

proc LWDAQ_set_device_element {sock value} 

LWDAQ_set_device_element sets a driver's device type register to $value through socket $sock.

LWDAQ_set_device_type

proc LWDAQ_set_device_type {sock value} 

LWDAQ_set_device_type sets a driver's device type register to $value through socket $sock.

LWDAQ_set_driver_mux

proc LWDAQ_set_driver_mux {sock driver {mux 1}} 

LWDAQ_set_driver_mux sets the device address register on a driver so as to select driver socket $driver and multiplexer socket (also known as the branch socket) $mux. The driver will be busy for a few tens of microseconds thereafter, as it switches target sockets. The driver socket can be a simple integer specifying the socket on a LWDAQ driver, or it can be of the form b:a, where "b" is a 32-bit "base address" expressed as an eight-digit hex string, and "a" is a decimal number. The base address selects one of several drivers associated with $sock. We might have a VME crate holding twenty LWDAQ Drivers (A2037A) and a single VME-TCPIP interface (A2064). The $sock connection is with the A2064, and we instruct the A2064 to select one of the twenty drivers using "b" in $driver. For example, 00E0000:3 would select the driver at VME base address hexadecimal 00E00000, and socket 3 within that driver. If we do not specify a base address, the routine does not bother setting the base address on the TCPIP interface at $sock. It uses $driver as the decimal socket number.

LWDAQ_set_repeat_counter

proc LWDAQ_set_repeat_counter {sock value} 

LWDAQ_set_repeat_counter sets a driver's repeat counter to $value through socket $sock.

LWDAQ_shortint_write

proc LWDAQ_shortint_write {sock addr value} 

LWDAQ_shortint_write writes a two-byte integer $value through open TCPIP socket $sock to controller address $addr.

LWDAQ_sleep

proc LWDAQ_sleep {sock} 

LWDAQ_sleep sends a driver's target device to sleep through $sock.

LWDAQ_software_version

proc LWDAQ_software_version {sock} 

LWDAQ_software_version fetches the relay software version from a driver through an open socket $sock.

LWDAQ_start_job

proc LWDAQ_start_job {sock job} 

LWDAQ_start_job tells a driver to begin a job execution by writing job identifier $job to the job register at socket $sock.

LWDAQ_stream_delete

proc LWDAQ_stream_delete {sock addr stream_length value} 

LWDAQ_stream_delete writes a constant byte value repeatedly to the same controller address, so as to clear consecutive memory locations. It is like the stream read in reverse, except the data value is always $value, where $value is a string of digits that represent a decimal value.

LWDAQ_stream_read

proc LWDAQ_stream_read {sock addr stream_length} 

LWDAQ_stream_read reads $stream_length bytes out of controller address $addr on the driver at the other end of TCPIP socket $sock, and returns the entire stream. The routine is intended for use with the controller's stream read location, which presents consecutive bytes in the controller RAM on consecutive reads by the relay.

LWDAQ_stream_write

proc LWDAQ_stream_write {sock addr data} 

LWDAQ_stream_write writes a block of bytes to the same controller address so as to transfer them into a memory block through a memory portal. It is like the stream read in reverse

LWDAQ_transmit_command

proc LWDAQ_transmit_command {sock value} 

LWDAQ_transmit_command instructs a driver to transmit LWDAQ command $value to its current target device. The routine instructs the driver through open TCPIP socket $sock. The driver will be busy for a few microseconds thereafter as it transmits the command, but the routine will return almost immediately. Note that if you have lazy_flush set to 1, the messages produced by the routine will remain in $sock's output buffer until you flush the socket, close it, or read from it.

LWDAQ_transmit_command_binary

proc LWDAQ_transmit_command_binary {sock value} 

LWDAQ_transmit_command_binary is the same as LWDAQ_transmit_command except it takes a binary string representation of the command value.

LWDAQ_transmit_command_hex

proc LWDAQ_transmit_command_hex {sock value} 

LWDAQ_transmit_command_hex is the same as LWDAQ_transmit_command except it takes a hexadecimal string representation of the command value.

LWDAQ_transmit_message

proc LWDAQ_transmit_message {sock id contents} 

LWDAQ_transmit_message sends a message through a socket. The routine detects which protocol the socket uses and formats the message accordingly. The message identifier is passed to the procedure in $id and the contents are in $contents. The routine supports the lwdaq, siap, and basic message formats.

LWDAQ_wait_for_driver

proc LWDAQ_wait_for_driver {sock {approx 0}} 

LWDAQ_wait_for_driver waits until the driver has finished executing all pending commands. If you expect the commands to take more than a few seconds, specify how long you expect them to take with the optional $approx parameter. By specifying the approximate delay, you allow this routine to avoid a TCPIP read timeout.

LWDAQ_wake

proc LWDAQ_wake {sock} 

LWDAQ_wake wakes up a driver's target device through socket $sock.

Init.tcl

Init.tcl is the initialization script that calls all other LWDAQ program scripts. Here we set the LWDAQ environment variables in the LWDAQ_Info array, and install any TCL commands necessary to make the local TCL compatible with TCL/TK 8.4.

LWDAQ_init

proc LWDAQ_init {} 

LWDAQ_init initializes the LWDAQ application. As we modify the scripts, we can call this routine from the console instead of quitting and re-starting the LWDAQ program. We include error-catching in the LWDAQ_init to protect against the interpreter aborting when we start up. The only things that LWDAQ_init will run again is itself and the lwdaq.so, which it will not re-load. If you modify either the dynamic library or this initialization procedure, you must close and re-start the application to implement your changes.

LWDAQ_stdin_console_execute

proc LWDAQ_stdin_console_execute {} 

LWDAQ_stdin_console_execute executes a command supplied from the stdin console, if it exists, and writes the result to the stdout console.

LWDAQ_stdin_console_prompt

proc LWDAQ_stdin_console_prompt {} 

LWDAQ_stdin_console_prompt writes the LWDAQ prompt to the stdin console.

LWDAQ_stdin_console_start

proc LWDAQ_stdin_console_start {} 

LWDAQ_stdin_console_start turns the standard input, which will exist when we start LWDAQ from a terminal on UNIX, LINUX, and even Windows and MacOS. The console is primitive in its current incarnation: no up or down-arrow implementation to give you previous commands, no left or right arrows to navigate through the command. But it's better than nothing.

Instruments.tcl

Instruments.tcl contains the routines that set up the common foundations upon which all LWDAQ instruments are built.

LWDAQ_acquire

proc LWDAQ_acquire {instrument {loop Acquire}} 

LWDAQ_acquire acquires data for the instrument called $instrument from either a file, or an existing image in memory, or directly from the daq. It returns a result string. The optional $loop allows this call of LWDAQ_acquire to post itself again to the event queue if the instrument's info(control) is "Loop". We call the routine with $loop equal to Loop only from the instrument's Loop button.

LWDAQ_acquire_button

proc LWDAQ_acquire_button {name} 

LWDAQ_acquire_button is for use with instrument acquire buttons.

LWDAQ_close

proc LWDAQ_close {name} 

LWDAQ_close closes the window of the named instrument.

LWDAQ_info_button

proc LWDAQ_info_button {name} 

LWDAQ_info_button makes a new toplevel window with a button that lets you see the instrument script. Below the button are the elements of the instrument's info array. You can change the elements by typing in the entry boxes.

LWDAQ_instrument_analyze

proc LWDAQ_instrument_analyze {instrument {id ""}} 

LWDAQ_instrument_analyze calls an instrument's analysis routine after checking its analysis_enable flag, and catches errors from the analysis routine. It assumes that the image it is to analyze is the image named in the instrument's memory_name parameter. The routine places an identifier in the result, as provided by the id parameter. By default, id becomes the memory name. The routine also prints the result to the panel text window.

LWDAQ_instrument_print

proc LWDAQ_instrument_print {instrument s {color black}} 

LWDAQ_instrument_print prints the result of analysis to an instrument text window using LWDAQ_print. If the verbose_result is set in the instrument's config array, then the routine uses the verbose_description list in the info array to describe each element of the result on on separate lines. We intend for this routine to be used only for printing instrument results in the instrument window. If you want to print anything else in the instrument window, use LWDAQ_print with the text window name $info(text). The info(text) element is set even if the instrument window is not open, and LWDAQ_print checks to see if the text window exists before it prints.

LWDAQ_instruments_init

proc LWDAQ_instruments_init {} 

LWDAQ_instruments_init initializes the instruments routines.

LWDAQ_loop_button

proc LWDAQ_loop_button {name} 

LWDAQ_loop_button is for use with instrument loop buttons.

LWDAQ_open

proc LWDAQ_open {name} 

LWDAQ_open opens the named instrument's window. We recommend that you post this routine to the event queue, or else it will conflict with acquisitions from the same instrument that are taking place with the window closed.

LWDAQ_read_button

proc LWDAQ_read_button {name} 

LWDAQ_read_button reads an image from disk. It allows the user to specify multiple files, and opens them one after another.

LWDAQ_reset_instrument_counters

proc LWDAQ_reset_instrument_counters {{value 0}} 

LWDAQ_reset_instrument_counters sets all the counters to the specifiec value, or to 1 if no value is specified.

LWDAQ_stop_button

proc LWDAQ_stop_button {name} 

LWDAQ_stop_button is for use with instrument stop buttons.

LWDAQ_stop_instruments

proc LWDAQ_stop_instruments {} 

LWDAQ_stop_instruments stops all looping instruments.

LWDAQ_write_button

proc LWDAQ_write_button {name} 

LWDAQ_write_button writes the current image to disk

Interface.tcl

Interface.tcl creates the LWDAQ graphical user interface.

LWDAQ_about

proc LWDAQ_about {} 

LWDAQ_about creates a message box that pops up and tells us about the program.

LWDAQ_bind_command_key

proc LWDAQ_bind_command_key {window letter command} 

LWDAQ_bind_command_key binds the specified command letter to the specified command on all platforms.

LWDAQ_button_confirm

proc LWDAQ_button_confirm {s} 

LWDAQ_button_confirm opens a toplevel window called "Confirm" and prints message $s in the window. The procedure returns after the user presses a button.

LWDAQ_button_wait

proc LWDAQ_button_wait {{s ""}} 

LWDAQ_button_wait opens a toplevel window with a continue button and waits until the user presses the button before closing the window and continuing.

LWDAQ_button_warning

proc LWDAQ_button_warning {s} 

LWDAQ_button_warning opens a toplevel window called "Warning" and prints message $s in the window. The procedure returns after the user presses a button.

LWDAQ_clock_widget

proc LWDAQ_clock_widget {{wf ""}} 

LWDAQ_clock_widget creates a text widget that displays second-by-second current time. If you specify a window name, the clock widget will appear in the window, packed towards the top. Otherwise the routine creates a new toplevel window for the clock.

LWDAQ_close_window

proc LWDAQ_close_window {widget} 

LWDAQ_close_window takes a widget name and closes the toplevel window that contains the widget.

LWDAQ_enable_text_undo

proc LWDAQ_enable_text_undo {t} 

LWDAQ_enable_text_undo turns on a text widget's undo stack. This stack will consume memory as it gets larger, so you should leave the stack off when you are repeatedly and automatically updating the text window contents, as we do in the System Monitor or the Acquisifier windows.

LWDAQ_init_main_window

proc LWDAQ_init_main_window {} 

LWDAQ_init_main_window initialize the main window and defines the menubar.

LWDAQ_interface_init

proc LWDAQ_interface_init {} 

LWDAQ_interface_init initializes the interface routines, installs operating-system dependent event handlers, and configures the default fonts for the graphical user interface.

LWDAQ_MacOS_Open_File

proc LWDAQ_MacOS_Open_File {theAppleEvent theReplyAE} 

No description available.

LWDAQ_make_instrument_menu

proc LWDAQ_make_instrument_menu {} 

LWDAQ_make_instrument_menu destroys the current instrument menu and makes a new one that matches the current list of instruments.

LWDAQ_make_tool_menu

proc LWDAQ_make_tool_menu {} 

LWDAQ_make_tool_menu destroys the current tool menu and makes a new one that matches the current selection of tools in the Tools folder.

LWDAQ_monitor_open

proc LWDAQ_monitor_open {} 

LWDAQ_monitor_open opens the system monitor window.

LWDAQ_monitor_refresh

proc LWDAQ_monitor_refresh {} 

LWDAQ_monitor_refresh updates the system monitor window, if it exists, and posts itself for re-execution in the TCL event loop.

LWDAQ_new_toplevel_text_window

proc LWDAQ_new_toplevel_text_window {{width 84} {height 30}} 

LWDAQ_new_toplevel_text_window creates a new text window. It returns the name of the toplevel window containing the text widget. You can construct the name of the text widget itself by adding .text to the window name.

LWDAQ_new_toplevel_window

proc LWDAQ_new_toplevel_window { {title ""} } 

LWDAQ_new_toplevel_window will make a new top-level window with a unique name, and returns its name.

LWDAQ_open_document

proc LWDAQ_open_document {fn} 

LWDAQ_open_document takes a file name and opens the file according to its file extensions. On MacOS, we call this procedure from tk::mac::OpenDocument.

LWDAQ_print

proc LWDAQ_print {args} 

LWDAQ_print prints a string to the end of a text device. The text device can be a text window or a file. When the routine writes to a text window, it does so in a specified color, unless the string begins with "ERROR: " or "WARNING: ", in which case the routine picks the color itself. If you pass "-nonewline" as an option after LWDAQ_print, the routine does not add a carriage return to the end of the print string. The routine also recognises "-newline", which is the default. The routine assumes the text device is a text window if its name starts with a period and this period is not followed by a forward slash or a backslash. If the text window exists, the routine writes the print string to the end of the window. If the text device is either "stdout" or "stderr", the routine writes directly to these channels. if the text device is a file name and the directory of the file exists, the routine appends the string to the file, or creates the file if the file does not exist. If the routine cannot find any valid device that matches the device name, it will write the print string to stdout when the global default_to_stdout flag is set.

LWDAQ_reset

proc LWDAQ_reset {} 

LWDAQ_reset stops all instruments, closes all sockets, stops all vwaits, and the event queue, sets the global reset variable to 1 for a period of time, and then sets all the instrument control variables to Idle.

LWDAQ_save_text_window

proc LWDAQ_save_text_window {window_name file_name} 

LWDAQ_save_text_window saves the contents of text window $window_name to a file named $file_name.

LWDAQ_server_accept

proc LWDAQ_server_accept {sock addr port} 

LWDAQ_server_accept is called when a remote control socket opens. The first thing the routine does is check that the IP address of the TCPIP client matches the server's address_filter. The routine installs the LWDAQ_server_interpreter routine as the incoming data handler for the remote control socket, and it lists the new socket in the LWDAQ open socket list.

LWDAQ_server_info

proc LWDAQ_server_info {{sock "nosocket"}} 

LWDAQ_server_info returns a string giving the name of the specified socket. The routine is intended for use within the System Server, where we pass the name of a socket to the routine, and it returns the name and various other pieces of system information. If, however, you call the routine from the console or within a script, it will return the same information, but with the socket name set to its default value. When you send the command "LWDAQ_server_info" to the System Server over a System Server socket, the System Server calls LWDAQ_server_info with the name of this same socket, and so returns the socket name along with the system information. The elements returned by the routine are a socket number, the time in seconds, the local platform, the program patchlevel, and the TCL version.n

LWDAQ_server_interpreter

proc LWDAQ_server_interpreter {sock} 

LWDAQ_server_interpreter receives commands from a TCPIP socket

LWDAQ_server_open

proc LWDAQ_server_open {} 

LWDAQ_server_open opens the remote control window. In the window, you specify an IP address match string to filter incoming connection requests. You specify the IP port to at whith LWDAQ should listen. You provide match strings for the commands that the remote control command interpreter should process. When you press Run, the remote controller is running and listening. When you press Stop, it stops. You cannot adjust the listening port while the remote controller is running.

LWDAQ_server_start

proc LWDAQ_server_start {} 

LWDAQ_server_start starts up the remote control server socket.

LWDAQ_server_stop

proc LWDAQ_server_stop {} 

LWDAQ_server_stop stops the remote control server socket, and closes all open sockets.

LWDAQ_text_widget

proc LWDAQ_text_widget {wf width height {scrolly 1}} 

LWDAQ_text_widget opens a text window within the specified window frame. The text window has its "undo" stack turned off. If you want to turn on the "undo" stack, LWDAQ_enable_text_undo will check that you are using TK 8.4+, and turn on the stack if you are.

LWDAQ_view_array

proc LWDAQ_view_array {array_name} 

LWDAQ_view_array opens a new window that displays the contents of a global TCL array, and allows you to change the values of all elements in the array.

LWDAQ_view_text_file

proc LWDAQ_view_text_file {file_name} 

LWDAQ_view_text_file reads a text file into a new top-level text window. The routine returns the name of the top-level window. The name of the text widget used to display the file is $w.text, where $w is the top-level window name.

LWDAQ_widget_list

proc LWDAQ_widget_list {w} 

LWDAQ_widget_list returns a list of all existing children of the window or widget you pass to the routine. If you pass just ".", then the routine will list all existing widgets and windows. The routine calls itself recursively.

Tools.tcl

Tools.tcl contains routines that configure and manage polite and standard LWDAQ tools. It provides the Tool Maker and Run Tool commands for the Tool menu.

LWDAQ_obsolete_names

proc LWDAQ_obsolete_names {} 

LWDAQ_obsolete_names returns a list of obsolete names and their new values.

LWDAQ_read_script

proc LWDAQ_read_script {{file_name ""}} 

LWDAQ_read_script reads a text file, which we assume to be a LWDAQ tool, or some script that serves a LWDAQ tool. The routine substitutes new names for obsolete names. To see the substitutions the current version of the routine performs, enter LWDAQ_obsolete_names at the console prompt, and it will print a list of obsolete names and their new values. If LWDAQ_read_script finds obsolete names, and it also sees that LWDAQ_Info(quiet_update) is not set, it opens a window, warns the user which obsolete names the script file contains, and asks if the user wants to update the script file with a new file that contains the new names.

LWDAQ_run_tool

proc LWDAQ_run_tool {{file_name ""}} 

LWDAQ_run_tool executes a tool script at the global scope. To read the tool file, the routine uses LWDAQ_read_script, which replaces obsolete parameter and procedure names with their new names. If the routine cannot find the script file, it looks in the Tools folder and the Tools/More folder.

LWDAQ_tool_configure

proc LWDAQ_tool_configure {name} 

LWDAQ_tool_configure opens a configuration window so we can set a tool's configuration array elements. It also provides for extra configuration buttons by returning the name of a frame below the Save button.

LWDAQ_tool_data

proc LWDAQ_tool_data {name} 

LWDAQ_tool_data extracts data lines from a tool's script and returns them as a string.

LWDAQ_tool_help

proc LWDAQ_tool_help {name} 

LWDAQ_tool_help extracts help lines from the tool script and prints them in the tool's text window.

LWDAQ_tool_init

proc LWDAQ_tool_init {name version} 

LWDAQ_tool_init replaces LWDAQ_tool_startup in newer tools. It provides more functionality, and requires that the calling routine, which we assume is a tool initializer, checks to see if the tool window exists. If so, the calling routine should abort. This routine drops support for the embedding of tools in the main window when they are alone in the startup directory. For full support for tool Help and Data, which we extract from the script files, make sure the tool script is in the Tools or Tools/More directory.

LWDAQ_tool_open

proc LWDAQ_tool_open {name} 

LWDAQ_tool_open opens a tool window if none exists. It checks to see if the window is already open, and if so it raises the window to the front and returns an empty string. The calling routine should check to see if this routine returns an empty string, and if so it should not attempt to perform any graphics operations in the existing window without checking for itself the mode in which LWDAQ is running: in no graphics mode, all graphics routines will fail.

LWDAQ_tool_save

proc LWDAQ_tool_save {name} 

LWDAQ_tool_save writes a tool's configuration array to disk.

LWDAQ_tool_startup

proc LWDAQ_tool_startup {name} 

LWDAQ_tool_startup initializes the tool directory and file variables. We are retiring this routine, but keep in for backward-compatibility with older versions of LWDAQ. Before LWDAQ 7.1.10, a solitary too script in the Startup directory would use the main TK window, which is the one called ".". But we dropped this feature in 7.1.10.

LWDAQ_Toolmaker

proc LWDAQ_Toolmaker {} 

LWDAQ_Toolmaker makes a new toplevel window for the Toolmaker. You enter a sequence of commands in the text window, and you can execute this sequence, which we call a script, with the Execute button. When you press Execute, your script will disappear from the text window, but you can make it re-appear with the Back button. The Toolmaker keeps a list of the scripts you have executed, and allows you to navigate and edit the list with the Forward, Back, and Clear buttons. You can save the list to a file with Save, and read a previously-saved list with Load. The file will contain all your scripts delimited by XML-style marks at the beginning and end of each script respectively. For each Execute, Toolmaker creates a new toplevel text window. You can print to the lower one (which is intended for results) by referring to it as $t, and using it with a text widget routine like LWDAQ_print, or calling it directly with its TK widget command, $t.

LWDAQ_Toolmaker_back

proc LWDAQ_Toolmaker_back {} 

LWDAQ_Toolmaker_back clears the script text window, decrements the script index, and displays the previous script in the Toolmaker comamnd list.

LWDAQ_Toolmaker_delete

proc LWDAQ_Toolmaker_delete {} 

LWDAQ_Toolmaker_delete deletes the current entry from the script list.

LWDAQ_Toolmaker_execute

proc LWDAQ_Toolmaker_execute {} 

LWDAQ_Toolmaker_execute extracts the script in the Toolmaker's text window, appends it to the Toolmaker script list, writes the script to a new toplevel text window, and executes the script at the global level. It prints out results as the script requires, and print errors in red when they occur. The script can refer to the text widget with the global variable "t". Above the text window is a frame, "f", also declared at the global level, which is packed in the top of the window, but empty unless the script creates buttons and such like to fill it.

LWDAQ_Toolmaker_forward

proc LWDAQ_Toolmaker_forward {} 

LWDAQ_Toolmaker_forward clears the script window, increments the script index, and displays the next script in the Toolmaker script list. If you have reached the end of the list, it displays a blank screen, ready for a fresh script.

LWDAQ_Toolmaker_load

proc LWDAQ_Toolmaker_load {{file_name ""}} 

LWDAQ_Toolmaker_load reads a previously-saved sequence of scripts from a file, and appends them to the current script list.

LWDAQ_Toolmaker_save

proc LWDAQ_Toolmaker_save {{file_name ""}} 

LWDAQ_Toolmaker_save saves the current Toolmaker script list to a file.

LWDAQ_tools_init

proc LWDAQ_tools_init {} 

LWDAQ_tools_init initializes the Tools routines.

Utils.tcl

Utils.tcl contains file input-output routines, the LWDAQ event queue, time and date routines, debug and diagnostic routines, and LWDAQ help routines. The LWDAQ Event Queue is an event scheduler that allows us to perform simultaneous live data acquisition from multiple instruments by scheduling the acquision actions so they do not overlap with one another.

LWDAQ_close_all_sockets

proc LWDAQ_close_all_sockets {} 

LWDAQ_close_all_sockets closes all open sockets.

LWDAQ_command_reference

proc LWDAQ_command_reference { {file_name ""} } 

LWDAQ_command_reference generates the LWDAQ software command reference manual automatically, using ./Sources/lwdaq.pas and ./LWDAQ.app/Contents/LWDAQ/CRT.html.

LWDAQ_debug_dump

proc LWDAQ_debug_dump {s} 

LWDAQ_debug_dump opens a file called debug_dump.txt in the program directory and appends a string to the end of it, then closes the file.

LWDAQ_decimal_to_binary

proc LWDAQ_decimal_to_binary {decimal {length 32}} 

LWDAQ_decimal_to_binary takes a decimal integer, $decimal, and returns the least significant $length digits of its binary representation as a string of ones and zeros. By default, $length is 32, which is also the maximum value of $length supported by the routine. We include comment in the code to explain our use of binary format and binary scan. It turns out that we have to use both these routines to achieve our end. First we format the integer as a binary object, then we scan this binary object for its bits.

LWDAQ_get_dir_name

proc LWDAQ_get_dir_name {} 

LWDAQ_get_dir_name opens a file browser and allows you to select a directory.

LWDAQ_get_file_name

proc LWDAQ_get_file_name {{multiple 0}} 

LWDAQ_get_file_name opens a file browser window and allows the user to select one or more files in the file system. The user can select multiple files when multiple is one (1). By default, multiple is zero (0).

LWDAQ_global_var_name

proc LWDAQ_global_var_name {} 

LWDAQ_global_var_name will return a unique name for a global variable.

LWDAQ_html_contents

proc LWDAQ_html_contents { {cell_spacing 4} {num_columns 4} {file_name ""} } 

LWDAQ_html_contents creates a table of contents for an HTML document. Each h2 and h3 level heading must have a unique name in the document, because this routine uses the heading text as the identifier for each heading line. The table of contents will be placed underneath an h2 heading with text "Contents". Any pre-existing table of contents between this h2 heading and the next h2 heading will be removed from the document. The routine takes three optional parameters. The first two are cell_spacing and num_columns for the h3 heading tables beneath each h2 heading. The third parameter is the name of the HTML file to be processed.

LWDAQ_html_split

proc LWDAQ_html_split {{file_name ""}} 

LWDAQ_html_split takes a long file with h2-level chapters and splits it into chapter files. It puts the chapter files in a new directory. If the original file is called A.html, the directory is A, and the chapters are named A_1.html to A_n.html, where n is the number of chapters. There will be another file called index.html, which is the table of contents. Each chapter provides a link to the table of contents, to the previous chapter, and to the next chapter. Each preserves the header and stylsheets used in the original file. All local html links get displaced downwards by one level in order to account for the chapters being buried in a new directory. Internal links in the document are broken, so you will have to go in and fix them by hand. Any h2-level heading called "Contents" will be removed from the list of chapter, because we assume it's a table of contents generated by the routine LWDAQ_html_contents.

LWDAQ_html_tables

proc LWDAQ_html_tables { {file_name ""} } 

LWDAQ_html_tables extracts all the tables from an HTML document and writes them to a new HTML document with Tables_ added to the beginning of the original document's file root. The routine takes one optional parameter: the name of the HTML document.

LWDAQ_image_bounds

proc LWDAQ_image_bounds {image {left ""} {top ""} {right ""} {bottom ""}} 

LWDAQ_image_bounds returns a string containing the analysis bounds of an image. You can specify new bounds with four numbers in the order left, top, right, bottom. If you specify zero (0) for the right or bottom bounds, the routine sets them to their maximum values. You can save the result of this routine in a string, change the bounds by calling the routine again, and then restore the earlier values by passing the saved string as its argument. But you have to do this with "eval" so that the TCL interpreter will break the string into four elements before passing it to LWDAQ_image_bounds.

LWDAQ_image_pixels

proc LWDAQ_image_pixels {image_name} 

LWDAQ_image_pixels returns a string containing the intensities of all pixels in the analysis boundaries of an image. The pixels form an array by use of spaces and line breaks. There is a line break at the end of each row of pixels and a space between each column. You can paste the output from this routine directly into Excel and obtain a two-dimensional intensity array.

LWDAQ_ip_addr_match

proc LWDAQ_ip_addr_match {addr_1 addr_2} 

LWDAQ_ip_addr_match takes two IP address strings and compares them to see if they point to the same driver socket. If the addresses match, the routine returns a 1. If they don't match, it returns a 0. A * in either parameter is a wild card, and will match.

LWDAQ_is_error_result

proc LWDAQ_is_error_result {s} 

LWDAQ_is_error_result returns 1 if and only if the first string begins with "ERROR: " (case sensitive).

LWDAQ_list_commands

proc LWDAQ_list_commands { {pattern *} } 

LWDAQ_list_commands lists LWDAQ commands.

LWDAQ_load_settings

proc LWDAQ_load_settings {{file_name ""}} 

LWDAQ_load_settings reads settings out of the specified settings file. If you do not specify a setting file name, the routine opens a file browser window so the user can choose a settings file.

LWDAQ_ndf_check

proc LWDAQ_ndf_check {file_name} 

LWDAQ_ndf_check returns the byte locations of an NDF file's meta-data string within an NDF file, the location of its data block, and the length of the data block. If the file you specify is not an NDF file, the routine returns an error.

LWDAQ_ndf_create

proc LWDAQ_ndf_create {file_name meta_data_size} 

LWDAQ_ndf_create creates a new Neuroscience Data Format file, which is the format used by LWDAQ to store archives of continuous time-series data. The NDF format begins with a four-byte format identifier, which is the string " ndf". Next comes a four-byte offset to the meta-data space and a four-byte offset to the data space. The header may contain additional binary information. The four-byte numbers are stored in big-endian byte order (most significant byte first). The meta-data space follows the header and contains only a null-terminated character string. The data space comes next, and occupies the remainder of the file. This routine creates a new file with an empty string and no data.

LWDAQ_ndf_data_append

proc LWDAQ_ndf_data_append {file_name data} 

LWDAQ_ndf_data_append appends new data to an NDF file.

LWDAQ_ndf_data_read

proc LWDAQ_ndf_data_read {file_name start_addr num_bytes} 

LWDAQ_ndf_data_read reads num_bytes of data out of an NDF file data block, starting at byte start_addr. The first byte in the data block is byte zero. If you specify * for num_bytes, the routine reads all available data bytes from the file.

LWDAQ_ndf_string_append

proc LWDAQ_ndf_string_append {file_name meta_data} 

LWDAQ_ndf_string_append appends a meta-data string to the one that already exists in an NDF file.

LWDAQ_ndf_string_read

proc LWDAQ_ndf_string_read {file_name} 

LWDAQ_ndf_string_read returns the null-terminated meta-data string in an NDF-file on disk.

LWDAQ_ndf_string_write

proc LWDAQ_ndf_string_write {file_name meta_data} 

LWDAQ_ndf_string_write re-writes the meta-data string in an NDF-file on disk but leaves the data intact.

LWDAQ_post

proc LWDAQ_post {event {place "end"}} 

LWDAQ_post adds the $event script to the LWDAQ Manager event list. If you set the optional parameter $place to "front" the the event gets added to the front of the queue. Otherwise, the event gets added to the end of the queue.

LWDAQ_proc_declaration

proc LWDAQ_proc_declaration {{proc_name "LWDAQ_*"} {file_name ""} } 

LWDAQ_proc_declaration returns a list of procedure declarations that match proc_name from the script file specified by file_name. The script must indicate a procedure declaration by quoting the procedure name after "proc " on a new line.

LWDAQ_proc_definition

proc LWDAQ_proc_definition {{proc_name "LWDAQ_*"} {file_name ""} } 

LWDAQ_proc_definition returns a list of procedure definitions that match proc_name from the script file specified by file_name. The script must indicate the start of a procedure definition by quoting the procedure name after "proc " on a new line. It must indicate the end of the procedure definition with a line consisting only of a single right-brace "}".

LWDAQ_proc_description

proc LWDAQ_proc_description {{proc_name "LWDAQ_*"} {file_name ""} {keep_breaks 0} } 

LWDAQ_proc_description returns a list of procedure descriptions, such as this one, as exctracted from the TCL/TK script that defines the procedure. If there are procedures in the script that match the proc_name parameter, but do not have their own descriptions, the routine returns an empty element in its list. The script must indicate the description by quoting the procedure name after "" on a new line. If you pass keep_breaks=1, the procedure will retain the original line breaks, which can be useful for printing directly to the TCL console.

LWDAQ_proc_list

proc LWDAQ_proc_list {{proc_name "LWDAQ_*"} {file_name ""} } 

LWDAQ_proc_list returns a list of all procedures declared in the specified file that match the proc_name string. The proc_name can contain wild cards * and ?. Each procedure must be declared on a new line that begins with "proc " followed by the procedure name.

LWDAQ_put_file_name

proc LWDAQ_put_file_name { {name ""} } 

LWDAQ_put_file_name opens a file browser window and allows the user to specify an output file. The browser allows the user to select an existing directory in the file system, and to type in a name for the file within that directory. If the "name" parameter is set when this procedure is called, the value of "name" will be the default file name in the browser window.

LWDAQ_queue_clear

proc LWDAQ_queue_clear {} 

LWDAQ_queue_clear clears the event queue.

LWDAQ_queue_error

proc LWDAQ_queue_error {event error_result} 

LWDAQ_queue_error displays an error for the event queue.

LWDAQ_queue_start

proc LWDAQ_queue_start {} 

LWDAQ_queue_start starts the event queue if it's not running already.

LWDAQ_queue_step

proc LWDAQ_queue_step {} 

LWDAQ_queue_step takes the first event out of the event queue deletes it, executes it, and posts itself to execute again after a delay of queue_ms.

LWDAQ_queue_stop

proc LWDAQ_queue_stop {} 

LWDAQ_queue_stop stops the LWDAQ event manager.

LWDAQ_random

proc LWDAQ_random {{min 0.0} {max 1.0}} 

LWDAQ_random returns a number between min and max. If both min and max are integers, then the number returned is also and integer. If either min or max is real, then the number returned is real. The random calculation we take from Practical Programming in TCL and TK by Brent Welch et al.

LWDAQ_random_wait_ms

proc LWDAQ_random_wait_ms {{min 0} {max 1000}} 

LWDAQ_random_wait_ms waits for a random number of milliseconds between min and max. During the wait, it passes control to the TCL/TK event loop so that idle tasks can be executed.

LWDAQ_read_image_file

proc LWDAQ_read_image_file {infile_name {image_name ""}} 

LWDAQ_read_image_file reads an image file from disk into the lwdaq image list and returns its list name. If the file name ends with ".gif" (case insensitive), the routine reads the file as a GIF image. The gray-scale values in the first line of the image should, for best results, contain a DAQ image header. The DAQ header contains the image dimensions, the analysis bounds, and a result string. Two- dimensional image data begins only on the second line of the image. If the file name ends with ".ndf", the routine reads the file as an NDF (Neuroscience Data Format) file. It creates a new image that is approximately square, and large enough to contain the NDF data. It sets the image result string equal to the NDF meta-data string. It copies the NDF data into the image data area, which begins with the first pixel of the second row in the new image. If the file name ends with any other extension, the routine reads the image in as a DAQ file. You can specify a name for the image if you like, otherwise the routine will assign its own name.

LWDAQ_save_settings

proc LWDAQ_save_settings {{file_name ""}} 

LWDAQ_save_settings saves instrument settings to a settings file, as well as a few elements from the Info array. If you do not specify a settings file name, the routine opens a file browser so the user can choose a file name.

LWDAQ_script_description

proc LWDAQ_script_description {{file_name ""} {keep_breaks 0} } 

LWDAQ_script_description returns the introductory paragraph of a TCL/TK script. It extracts the script name from the file_name parameter. The script name is the tail of the file_name. The script must indicate the introductory paragraph by quoting the script name after "" on a new line. If you pass keep_breaks=1, the procedure will retain the original line breaks, which can be useful for printing directly to the TCL console.

LWDAQ_set_bit

proc LWDAQ_set_bit {binary_string bit_num {value 1}} 

LWDAQ_set_bit takes a string of ones and zeros, called binary_string, and sets bit number $bit_num to $value. By default, $value is 1, in keeping with the electrical engineer's meaning of the word "set".

LWDAQ_soar_read

proc LWDAQ_soar_read {sock} 

LWDAQ_soar_read is called by LWDAQ_socket_open when the socket message protocol is SIAP. The SIAP protocol runs on top of the SOAR Communication Protocol, which specifies that a server must answer a client immediately with a string that either confirms acceptance of the connection request or refusal of the request. The first four bytes of a SOAR message are the big-endian content length. We read these from the socket and then read the specified number of characters, and return those.

LWDAQ_socket_accept

proc LWDAQ_socket_accept {sock addr port} 

LWDAQ_socket_accept is an example socket acceptance routine. It sets up the socket to call LWDAQ_socket_interpreter whenever a new line of data arrives from the socket.

LWDAQ_socket_close

proc LWDAQ_socket_close {sock} 

LWDAQ_socket_close closes a socket if it exists, and returns a 1. Otherwise it returns a zero. If the socket is listed in the LWDAQ open sockets list, this routine will remove the socket from the list. If the socket is a LWDAQ client, the routine sends an end of transmission character before closing the socket.

LWDAQ_socket_flush

proc LWDAQ_socket_flush {sock} 

LWDAQ_socket_flush flushes output from a socket. It returns an error message starting with a capitalized nown.

LWDAQ_socket_interpreter

proc LWDAQ_socket_interpreter {sock} 

LWDAQ_socket_interpreter is an example socket interpreter. It calls the LWDAQ socket closing routine to make sure that the open_sockets list is kept up to date.

LWDAQ_socket_listen

proc LWDAQ_socket_listen {{accept ""} {port ""}} 

LWDAQ_socket_listen opens a server socket for listening on the specified port on the local machine. You specify an acceptance procedure that TCL will call when the server accepts a new connection.

LWDAQ_socket_open

proc LWDAQ_socket_open {target {protocol "none"}} 

LWDAQ_socket_open opens a connection to a TCPIP server and returns the socket name. The target parameter is of the form a:b where a is an IP address in standard x.x.x.x format or a host name, b is an IP port number in decimal format. The port number can be omitted, in which case the routine assumes a default port number. The optional parameter is the message protocol name. Supported protocols are "lwdaq", "siap", and "basic". The default is to pick the protocol based upon the port number. If no port number is specified, or if the port number is outside the siap port number range, the protocol is lwdaq. Otherwise the protocol is siap. To get the basic protocol, which is not protocol at all beyond TCPIP, you must specify basic as the protocol when you call the routine. The lwdaq protocol differs from basic in that it transmits an end of transmission code when we close the socket. The siap protocol differs in that it the server responds with the string "DONE" when it accepts a socket. There are further differences between siap and lwdaq, but they are not apparant in our socket opening, closing, reading, and writing routines. The routines that exchange messages with siap and lwdaq servers are in the Driver.tcl file, and there you will see the transmit and receive routines checking the socket info determine the socket protocol.

LWDAQ_socket_protocol

proc LWDAQ_socket_protocol {sock} 

LWDAQ_socket_protocol determines the message protocol in use on a socket.

LWDAQ_socket_read

proc LWDAQ_socket_read {sock size} 

LWDAQ_socket_read reads $size bytes from the input buffer of $sock. If the global LWDAQA_Info(blocking_sockets) variable is 1, the read takes place in one entire data block. While the data arrives, the LWDAQ program freezes. If the same variable is 0, the this procedure reads the data in fragments, allowing the program to respond to menu and window events between fragments. The routine collects all the necessary fragments together and returns them.

LWDAQ_socket_upload

proc LWDAQ_socket_upload {target data} 

LWDAQ_socket_upload opens a socket to a server, writes a data string to the socket, and then closes the socket. The target parameter is of the form a:b where a is an IP address in standard x.x.x.x format or a host name, b is an IP port number in decimal format. The routine treats the string as a binary object, with no carriate return at the end.

LWDAQ_socket_write

proc LWDAQ_socket_write {sock data} 

LWDAQ_socket_write sends data to a socket's output buffer. Normally, we don't send out our data until the buffer is full or we are about to read from the socket. We call this 'lazy flushing'. Sending many instructions in one data packet is more efficient, and we get to use the TCP/IP buffer as a place to construct the string of commands. But if we want to see what is happening on the driver, we might want to send instructions to the LWDAQ Relay immediately. In that case, we set the lazy_flush flag to zero. We must make sure puts does not add a newline character to the end of every binary array it sends.

LWDAQ_split

proc LWDAQ_split {s} 

LWDAQ_split takes a list of parameters delimited by white space, colons, commas, equal-signs, semi-colons, and null characters. It returns a list containing no empty elements.

LWDAQ_stop_vwaits

proc LWDAQ_stop_vwaits {} 

LWDAQ_stop_vwaits sets all vwait variables generated by the above routine to zero, which will indicate to all routines in vwait that a global reset has occured. Because TCL vwaits are nested, LWDAQ_stop_vwaits will cause any depth of nesting to terminate, even it the nesting is in deadlock.

LWDAQ_support

proc LWDAQ_support {} 

LWDAQ_support allows you to move windows while running a computation. You simply include a call to this routine in your repeating loop. Every support_ms, the routine will call LWDAQ_update to handle system activity.

LWDAQ_time_stamp

proc LWDAQ_time_stamp { {s ""} } 

LWDAQ_time_stamp returns a year, month, date, hour, seconds time-stamp string for record keeping, or converts a [clock seconds] result into a time-stamp.

LWDAQ_update

proc LWDAQ_update {} 

LWDAQ_update passes control to the TclTk event handler for analysis_update_ms. During this time, the event handler can perform window updates, respond to mouse clicks, and service TCPIP sockets.

LWDAQ_utils_init

proc LWDAQ_utils_init {} 

LWDAQ_utils_init initializes the untils routines.

LWDAQ_vwait

proc LWDAQ_vwait {var_name} 

LWDAQ_vwait calls vwait, but also keeps a list of the current vwait variable stack, which we can use to keep track of our vwaits.

LWDAQ_vwait_var_name

proc LWDAQ_vwait_var_name {} 

LWDAQ_vwait_var_name will return a unique name for a global vwait variable. All LWDAQ routines that call TCL's vwait routine use a global timeout variable assigned by this routine, so that its partner routine LWDAQ_stop_vwaits can go through all existing timeout variables and set them to 0, which indicates to the vwait-calling procedure that the vwait has been aborted by a global LWDAQ reset.

LWDAQ_wait_ms

proc LWDAQ_wait_ms {time_ms} 

LWDAQ_wait_ms waits for the specified time.

LWDAQ_wait_seconds

proc LWDAQ_wait_seconds {t} 

LWDAQ_wait_seconds waits for the specified time.

LWDAQ_write_image_file

proc LWDAQ_write_image_file {image_name outfile_name} 

LWDAQ_write_image_file writes an image to disk in the LWDAQ image format. If the file name has tail ".gif" (case insensitive), the routine saves the file in GIF format. If the file name ends with ".ndf", the routine writes the image file as an NDF file. Otherwise, the routine saves the image in the DAQ format. In a GIF or DAQ file, the LWDAQ image header, with dimensions, analysis bounds, and results string, will be embedded in the first line of the image. In an NDF file, this header information is lost. The results string is saved in the meta-data string and the image contents, starting with the first pixel of the first row, are stored in the NDF data block.

BCAM.tcl

LWDAQ_analysis_BCAM

proc LWDAQ_analysis_BCAM {{image_name ""}} 

LWDAQ_analysis_BCAM applies BCAM analysis to an image in the lwdaq image list. By default, the routine uses the image $config(memory_name).

LWDAQ_daq_BCAM

proc LWDAQ_daq_BCAM {} 

LWDAQ_daq_BCAM captures an image from the LWDAQ electronics and places the image in the lwdaq image list. It provides background subtraction by taking a second image while flashing non-existent lasers. It provides automatic exposure adjustment by calling itself until the maximum image intensity lies within peak_min and peak_max.

LWDAQ_extended_BCAM

proc LWDAQ_extended_BCAM {} 

LWDAQ_extended_BCAM tries to assign optimal values to peak_max and peak_min, and adjust the analysis boundaries to enclose the spots within a number of pixels of their centers. You direct the configuration calculations with the extended_parameters string, which contains parameters as a list. The string "0.6 0.9 20 1" sets peak_min to 60% of saturation, peak_max to 90% of saturation, shrinks the image bounds to 20 pixels around the spot center, and adjusts individual source exposure times. If you don't want a border, specify bounds to be 0 (instead of 20). If you don't want to adjust multiple sources individually, specify 0 for individual_sources.

LWDAQ_init_BCAM

proc LWDAQ_init_BCAM {} 

LWDAQ_init_BCAM creates all elements of the BCAM instrument's config and info arrays.

Camera.tcl

Camera.tcl defines the Camera instrument.

LWDAQ_analysis_Camera

proc LWDAQ_analysis_Camera {{image_name ""}} 

LWDAQ_analysis_Camera applies Camera analysis to an image in the lwdaq image list. By default, the routine uses the image $config(memory_name).

LWDAQ_daq_Camera

proc LWDAQ_daq_Camera {} 

LWDAQ_daq_Camera captures an image from the LWDAQ electronics and places the image in the lwdaq image list.

LWDAQ_init_Camera

proc LWDAQ_init_Camera {} 

LWDAQ_init_Camera creates all elements of the Camera instrument's config and info arrays.

Diagnostic.tcl

Diagnostic.tcl defines the Diagnostic instrument.

LWDAQ_analysis_Diagnostic

proc LWDAQ_analysis_Diagnostic {{image_name ""}} 

LWDAQ_analysis_Diagnostic displays the power supply measurements carried by the $image_name and displays them in the diagnostic instrument window. It calculates average values for the power supply voltages and current consumption and returns these parameters, as well as other information about the driver. By default, the routine uses the image $config(memory_name).

LWDAQ_create_controls_Diagnostic

proc LWDAQ_create_controls_Diagnostic {} 

LWDAQ_create_controls_Diagnostic creates secial controls for the Diagnostic instrument.

LWDAQ_daq_Diagnostic

proc LWDAQ_daq_Diagnostic {} 

LWDAQ_daq_Diagnostic reads configuration paramters from the LWDAQ hardware, and records them in a result string, which it returns.

LWDAQ_exec_Diagnostic

proc LWDAQ_exec_Diagnostic {operation} 

LWDAQ_exec_Diagnostic opens a socket to a driver and calls the specified operation routine.

LWDAQ_init_Diagnostic

proc LWDAQ_init_Diagnostic {} 

LWDAQ_init_Diagnostic creates all elements of the Diagnostic instrument's config and info arrays.

LWDAQ_loop_Diagnostic

proc LWDAQ_loop_Diagnostic {sock} 

LWDAQ_loop_Diagnostic executes a loop job on the Diagnostic instrument's target device, reads out the LWDAQ Driver's loop timer, and prints the loop time in the Diagnostic text window.

LWDAQ_off_Diagnostic

proc LWDAQ_off_Diagnostic {sock} 

LWDAQ_off_Diagnostic turns off the device power.

LWDAQ_on_Diagnostic

proc LWDAQ_on_Diagnostic {sock} 

LWDAQ_on_Diagnostic turns on the LWDAQ device power.

LWDAQ_reboot_Diagnostic

proc LWDAQ_reboot_Diagnostic {sock} 

LWDAQ_reboot_Diagnostic re-boots the server.

LWDAQ_refresh_Diagnostic

proc LWDAQ_refresh_Diagnostic {{image_name ""}} 

LWDAQ_refresh_Diagnostic refreshes the display of the data, given new display settings. It calls the Diagnostic instrument's analysis procedure.

LWDAQ_reset_Diagnostic

proc LWDAQ_reset_Diagnostic {sock} 

LWDAQ_reset_Diagnostic reboots the controller logic.

LWDAQ_sleep_Diagnostic

proc LWDAQ_sleep_Diagnostic {sock} 

LWDAQ_sleep_Diagnostic sends the target device to sleep.

LWDAQ_sleepall_Diagnostic

proc LWDAQ_sleepall_Diagnostic {sock} 

LWDAQ_sleepall_Diagnostic sends a range of devices to sleep. The routine starts with driver socket 1 and multiplexer socket 1, and proceeds to driver socket 1, multiplexer socket b, where b is the second number in sleepall_params. The routine moves on to driver socket 2 and repeats the same procedure, and so on, up to driver socket a, where a is the first number in sleepall_params.

LWDAQ_transmit_Diagnostic

proc LWDAQ_transmit_Diagnostic {sock} 

LWDAQ_transmit_Diagnostic transmits each hex word in info(command) to the target device (info(repeat) + 1) times.

LWDAQ_wake_Diagnostic

proc LWDAQ_wake_Diagnostic {sock} 

LWDAQ_wake_Diagnostic wakes up the target device.

Flowmeter.tcl

Flowmeter.tcl defines the Flowmeter instrument.

LWDAQ_analysis_Flowmeter

proc LWDAQ_analysis_Flowmeter {{image_name ""}} 

LWDAQ_analysis_Flowmeter takes the flowmeter RTD sensor resistance measurements in $image_name and plots a graph of sensor temperature versus time in the Flowmeter window. It returns a string containing the inverse time-constant of the cool-down phase. By default, the routine uses image $config(memory_name).

LWDAQ_create_controls_Flowmeter

proc LWDAQ_create_controls_Flowmeter {} 

LWDAQ_create_controls_Flowmeter creates secial controls for the Flowmeter instrument.

LWDAQ_daq_Flowmeter

proc LWDAQ_daq_Flowmeter {} 

LWDAQ_daq_Flowmeter reads configuration parameters from the LWDAQ hardware, and records them in a result string, which it returns.

LWDAQ_init_Flowmeter

proc LWDAQ_init_Flowmeter {} 

LWDAQ_init_Flowmeter creates all elements of the Flowmeter instrument's config and info arrays.

LWDAQ_refresh_Flowmeter

proc LWDAQ_refresh_Flowmeter {} 

LWDAQ_refresh_Flowmeter refreshes the display of the data, given new display settings. It calls the Flowmeter analysis procedure.

Gauge.tcl

Gauge.tcl defines the Gauge instrument.

LWDAQ_analysis_Gauge

proc LWDAQ_analysis_Gauge {{image_name ""}} 

LWDAQ_analysis_Gauge takes the RTD resistance measurements contained in $image_name and plots a graph of temperature versus time for each sensor whose resistance is recorded in the image. It calculates the average value of each temperature and returns the averages as a string. By default, the routine uses image $config(memory_name).

LWDAQ_create_controls_Gauge

proc LWDAQ_create_controls_Gauge {} 

LWDAQ_create_controls_Gauge creates secial controls for the Gauge instrument.

LWDAQ_daq_Gauge

proc LWDAQ_daq_Gauge {} 

LWDAQ_daq_Gauge reads configuration paramters from the LWDAQ hardware, and records them in a result string, which it returns.

LWDAQ_init_Gauge

proc LWDAQ_init_Gauge {} 

LWDAQ_init_Gauge creates all elements of the Gauge instrument's config and info arrays.

LWDAQ_refresh_Gauge

proc LWDAQ_refresh_Gauge {} 

LWDAQ_refresh_Gauge refreshes the display of the data, given new display settings. It calls the Gauge analysis routine, which assumes that certain parameters are stored in the image's results string.

Inclinometer.tcl

Inclinometer.tcl defines the Inclinometer instrument.

LWDAQ_analysis_Inclinometer

proc LWDAQ_analysis_Inclinometer {{image_name ""}} 

LWDAQ_analysis_Inclinometer converts the ADC measurements contained in $image_name into voltages, and plots them in the Inclinometer window. It calculates the average value of the voltage, the slope, and the standard deviation, and returns these in a string. By default, the routine uses image $config(memory_name).

LWDAQ_create_controls_Inclinometer

proc LWDAQ_create_controls_Inclinometer {} 

LWDAQ_create_controls_Inclinometer creates secial controls for the Inclinometer instrument.

LWDAQ_daq_Inclinometer

proc LWDAQ_daq_Inclinometer {} 

LWDAQ_daq_Inclinometer reads samples out of an input channel.

LWDAQ_init_Inclinometer

proc LWDAQ_init_Inclinometer {} 

LWDAQ_init_Inclinometer creates all elements of the Inclinometer instrument's config and info arrays.

Rasnik.tcl

Rasnik.tcl defines the Rasnik instrument.

LWDAQ_analysis_Rasnik

proc LWDAQ_analysis_Rasnik {{image_name ""}} 

LWDAQ_analysis_Rasnik applies rasnik analysis to an image in the lwdaq image list. By default, the routine uses image $config(memory_name).

LWDAQ_daq_Rasnik

proc LWDAQ_daq_Rasnik {} 

LWDAQ_daq_Rasnik ccaptures an image from the LWDAQ electronics and places the image in the lwdaq image list. It provides background subtraction by taking a second image while flashing non-existent LEDs. It provides automatic exposure adjustment by calling itself until the maximum image intensity lies withint peak_min and peak_max.

LWDAQ_extended_Rasnik

proc LWDAQ_extended_Rasnik {} 

LWDAQ_extended_Rasnik tries to assign optimal values to peak_max and peak_min. You direct the configuration with info(extended_parameters), which contains min_frac and max_frac. With the string "0.6 0.9", the configuration sets peak_min to 60% of saturation, peak_max to 90% of saturation.

LWDAQ_init_Rasnik

proc LWDAQ_init_Rasnik {} 

LWDAQ_init_Rasnik creates all elements of the Rasnik instrument's config and info arrays.

Recorder.tcl

Recorder.tcl defines the Recorder instrument.

LWDAQ_analysis_Recorder

proc LWDAQ_analysis_Recorder {{image_name ""}} 

LWDAQ_analysis_Recorder applies Recorder analysis to an image in the lwdaq image list. By default, the routine uses the image $config(memory_name).

LWDAQ_create_controls_Recorder

proc LWDAQ_create_controls_Recorder {} 

LWDAQ_create_controls_Recorder creates secial controls for the Recorder instrument.

LWDAQ_daq_Recorder

proc LWDAQ_daq_Recorder {} 

LWDAQ_daq_Recorder reads data from a data device.

LWDAQ_init_Recorder

proc LWDAQ_init_Recorder {} 

LWDAQ_init_Recorder creates all elements of the Recorder instrument's config and info arrays.

LWDAQ_refresh_Recorder

proc LWDAQ_refresh_Recorder {} 

LWDAQ_refresh_Recorder refreshes the display of the data, given new display settings.

LWDAQ_reset_Recorder

proc LWDAQ_reset_Recorder {} 

LWDAQ_reset_Recorder resets the data recorder hardware and the recorder instrument.

RFPM.tcl

RFPM.tcl defines the Radio-Frequency Power Meter (RFPM) instrument.

LWDAQ_analysis_RFPM

proc LWDAQ_analysis_RFPM {{image_name ""}} 

LWDAQ_analysis_RFPM converts the ADC measurements contained in $image_name into voltages, and plots them in the RFPM window. By default, the routine uses image $config(memory_name). If analysis_enable is set to 1, the analysis returns the peak-to-peak value of the signal on all four RFPM signal paths in units of ADC counts. If analysis_enanalysis is 2, the analysis returns the rms values of the signals.

LWDAQ_create_controls_RFPM

proc LWDAQ_create_controls_RFPM {} 

LWDAQ_create_controls_RFPM creates secial controls for the RFPM instrument.

LWDAQ_daq_RFPM

proc LWDAQ_daq_RFPM {} 

LWDAQ_daq_RFPM reads samples out of an input channel.

LWDAQ_init_RFPM

proc LWDAQ_init_RFPM {} 

LWDAQ_init_RFPM creates all elements of the RFPM instrument's config and info arrays.

LWDAQ_refresh_RFPM

proc LWDAQ_refresh_RFPM {} 

LWDAQ_refresh_RFPM refreshes the display of the data, given new display settings. RFPM analysis assumes that certain parameters are stored in the image's results string.

Terminal.tcl

Terminal.tcl defines the Terminal instrument.

LWDAQ_analysis_Terminal

proc LWDAQ_analysis_Terminal {{image_name ""}} 

LWDAQ_analysis_Terminal scans an image received from a Terminal data acquisition, and turns it into a string of numbers. By default, the routine uses image $config(memory_name).

LWDAQ_daq_Terminal

proc LWDAQ_daq_Terminal {} 

LWDAQ_daq_Terminal reads a string of characters or a block of data froma data device.

LWDAQ_init_Terminal

proc LWDAQ_init_Terminal {} 

LWDAQ_init_Terminal creates all elements of the Terminal instrument's config and info arrays.

Thermometer.tcl

Thermometer.tcl defines the Thermometer instrument.

LWDAQ_analysis_Thermometer

proc LWDAQ_analysis_Thermometer {{image_name ""}} 

LWDAQ_analysis_Thermometer takes the RTD resistance measurements contained in $image_name and plots a graph of temperature versus time for each sensor whose resistance is recorded in the image. It calculates the average value of each temperature and returns the averages as a string. By default, the routine uses image $config(memory_name).

LWDAQ_create_controls_Thermometer

proc LWDAQ_create_controls_Thermometer {} 

LWDAQ_create_controls_Thermometer creates secial controls for the Thermometer instrument.

LWDAQ_daq_Thermometer

proc LWDAQ_daq_Thermometer {} 

LWDAQ_daq_Thermometer reads configuration paramters from the LWDAQ hardware, and records them in a result string, which it returns.

LWDAQ_init_Thermometer

proc LWDAQ_init_Thermometer {} 

LWDAQ_init_Thermometer creates all elements of the Thermometer instrument's config and info arrays.

LWDAQ_refresh_Thermometer

proc LWDAQ_refresh_Thermometer {} 

LWDAQ_refresh_Thermometer refreshes the display of the data, given new display settings. It calls the Thermometer analysis routine, which assumes that certain parameters are stored in the image's results string.

Viewer.tcl

Viewer.tcl defines the Viewer instrument.

LWDAQ_analysis_Viewer

proc LWDAQ_analysis_Viewer {{image_name ""}} 

LWDAQ_analysis_Viewer returns the results string of an image in the lwdaq image list. By default, the routine uses the image $config(memory_name).

LWDAQ_create_controls_Viewer

proc LWDAQ_create_controls_Viewer {} 

LWDAQ_create_controls_Viewer creates secial controls for the Viewer instrument.

LWDAQ_DAQ_to_GIF_Viewer

proc LWDAQ_DAQ_to_GIF_Viewer {} 

LWDAQ_DAQ_to_GIF_Viewer opens a browser in which you select multiple DAQ image files, and converts them to GIF files, writing them into the same directory with suffix ".gif".

LWDAQ_daq_Viewer

proc LWDAQ_daq_Viewer {} 

LWDAQ_daq_Viewer is a dummy procedure for the standard aquire button.

LWDAQ_GIF_to_DAQ_Viewer

proc LWDAQ_GIF_to_DAQ_Viewer {} 

LWDAQ_GIF_to_DAQ_Viewer opens a browser in which you select multiple GIF image files, and converts them to DAQ files, writing them into the same directory with suffix ".daq".

LWDAQ_init_Viewer

proc LWDAQ_init_Viewer {} 

LWDAQ_init_Viewer creates all elements of the Viewer instrument's config and info arrays.

LWDAQ_Set_Bounds_Viewer

proc LWDAQ_Set_Bounds_Viewer {} 

LWDAQ_Set_Bounds_Viewer applies the analyisis boundaries specified in the viewer's info array to the image named by config memory_name.

LWDAQ_Set_Dimensions_Viewer

proc LWDAQ_Set_Dimensions_Viewer {} 

LWDAQ_Set_Dimensions_Viewer takes the contents of the image named by config(memory_name) and creates a new image with the dimensions specified in the dimension control boxes. The routine keeps the analysis boundaries the same.

LWDAQ_Set_Results_Viewer

proc LWDAQ_Set_Results_Viewer {} 

LWDAQ_Set_Results_Viewer sets the results string of an image.

LWDAQ_special_analysis_Viewer

proc LWDAQ_special_analysis_Viewer {instrument} 

LWDAQ_special_analysis_Viewer calls the analysis of other instruments, displays the results on the screen, and prints them to the text window.

Voltmeter.tcl

Voltmeter.tcl defines the Voltmeter instrument.

LWDAQ_analysis_Voltmeter

proc LWDAQ_analysis_Voltmeter {{image_name ""}} 

LWDAQ_analysis_Voltmeter converts the ADC measurements contained in $image_name into voltages, and plots them in the Voltmeter window. It calculates the average value of the voltage, the slope, and the standard deviation, and returns these in a string. By default, the routine uses image $config(memory_name).

LWDAQ_create_controls_Voltmeter

proc LWDAQ_create_controls_Voltmeter {} 

LWDAQ_create_controls_Voltmeter creates secial controls for the Voltmeter instrument.

LWDAQ_daq_Voltmeter

proc LWDAQ_daq_Voltmeter {} 

LWDAQ_daq_Voltmeter reads samples out of an input channel.

LWDAQ_init_Voltmeter

proc LWDAQ_init_Voltmeter {} 

LWDAQ_init_Voltmeter creates all elements of the Voltmeter instrument's config and info arrays.

LWDAQ_refresh_Voltmeter

proc LWDAQ_refresh_Voltmeter {} 

LWDAQ_refresh_Voltmeter refreshes the display of the data, given new display settings. Voltmeter analysis assumes that certain parameters are stored in the image's results string.

WPS.tcl

WPS.tcl defines the WPS instrument.

LWDAQ_analysis_WPS

proc LWDAQ_analysis_WPS {{image_name ""}} 

LWDAQ_analysis_WPS applies WPS analysis to an image in the lwdaq image list. By default, the routine uses the image $config(memory_name).

LWDAQ_daq_WPS

proc LWDAQ_daq_WPS {} 

LWDAQ_daq_WPS captures an image from the LWDAQ electronics and places the image in the lwdaq image list. It provides background subtraction by taking a second image while flashing non-existent lasers. It provides automatic exposure adjustment by calling itself until the maximum image intensity lies within peak_min and peak_max.

LWDAQ_extended_WPS

proc LWDAQ_extended_WPS {} 

LWDAQ_extended_WPS tries to assign optimal values to peak_max and peak_min. You direct the configuration calculations with the info(extended_parameters) string, which contains parameters as a list. The string "0.6 0.9 1" sets peak_min to 60% of saturation, peak_max to 90% of saturation and adjusts individual source exposure times. If you don't want to adjust multiple sources individually, specify 0 for individual_sources.

LWDAQ_init_WPS

proc LWDAQ_init_WPS {} 

LWDAQ_init_WPS creates all elements of the WPS instrument's config and info arrays.