spec

Software for Diffraction

changes

Highlights for spec release 6.10

May 20, 2022 - RELEASE 6.10.07

IMPROVEMENTS

New Normalized Counter Option

It is now possible for spec to automatically normalize counter readings to the elapsed time from the timebase scaler channel. Such a counter can be configured on the Scaler screen of the configuration editor by selecting "normalize_to_time" in the "Use As" column. Additionally, a new "normalize_to_time" counter_par() option allows the configuration to be changed (and read back) from the spec command line. As with most such parameters, a reconfig or restart will restore the normalize behavior to the value in the config file. See the counting help file.

Protection From Disabling HKL Macros

Since the earliest days, the spec executable reads a standard command file based on the first four letters of its name from the spec auxiliary file directory, SPECD. A no-geometry instance named spec reads the file SPECD/spec.mac, which contains a single line of code to call the no_hkl macro to undefine irrelevant reciprocal space macros. Also since the beginning, spec reads a command file named spec.mac in the current directory on startup. That means if a user ran a version of spec that did include geometry support (twoc, fourc, etc.) and if the user started in the auxiliary file directory, the no_hkl macro in that spec.mac file would be read and all the reciprocal space macros (wh, br, hklscan, etc) would be undefined. This release of spec prevents that from happening by not reading a spec.mac file if started from the auxiliary file directory and the calc(2) "user-added" function has been assigned. (The standard geometry macros all use calc(2) to calculate HKL from motor positions.)

Clean Install Of pyspec Files

The pyspec subdirectory of the spec auxiliary file directory (normally /usr/local/lib/spec.d) contains files used by spec-related Python utilities, such as splot, eigerserver and specfile. The standard spec installation script now completely replaces the pyspec contents rather than leave obsolete files in place.

FIXES

Fix For Server Command Line Display During Client Commands

Recent updates to fix ^C issues with a spec server running client commands broke the behavior where the server prompt and typing would be restored after the client generated output was displayed. That problem is now fixed.

Fix For Client Display Of Server Errors With remote_eval()

The feature for a spec client to display an error message associated with the failure of a remote_eval() call to a spec server included in release 6.10.05 didn't always work as intended. That functionality is working better in this release.

HARDWARE

Thorlabs Motor Controller Support Updated For Serial and MLJ150

The Thorlabs APT motor controller support now works with a serial (RS-232) interface along with USB. In addition, model MLJ150 is now supported. See the thorlabs help file for details.

Additional Trinamic TMCL Motor Controllers Supported

Trinamic motor controller models TMCM-1110, TMCM-1141, TMCM-1211 and TMCM-1240 are now tested and working with spec TMCL support. See the tmcl help file for details.

MACROS

Fix For scan_data_init() Macro To Accommodate Fly Scans

A problem where the SCAN_COLS[] assignment didn't agree with how SCAN_D[][] was filled when using fly scans has been fixed in the scan_data_init() macro. The issue occurred when the MON or DET channel were disabled for the scan. SCAN_COLS[] is an associative array where each element contains the mnemonic associated with the corresponding column of the SCAN_D[][] data array.

Additional Option For Fly Scan Display

An additional option for how to display sweep data at the end of each fly scan is now available, namely a mode where all lines are displayed if the number of lines is less than a cutoff value, otherwise the first, middle and last blocks are displayed. The cutoff value can be entered in the fly_setup macro.

Fix For Unidirectional Mesh Fly Scans

An issue where recent updates to the fly scan macros broke unidirectional mesh fly scans has been fixed.

March 20, 2022 - RELEASE 6.10.06

IMPROVEMENTS

Internal Type For Motor Speeds Now 64 Bits

In spec release 6.08.01, storage for motor positions was switched from 32-bit integers to 64-bit integers to accommodate new motor controllers that required the additional resolution. It turns out that the motor speeds (units of steps/sec) for the same motor controllers also need to be able to be specified to higher resolution. Motor speeds are now maintained as 64-bit integers in spec and the edconf hardware configuration editor.

array_plot() Now Returns an Error For Out-Of-Bounds Array

The array_plot() function now appropriately returns an nonzero value to indicate an error if the array arguments access out-of-bounds array elements. The plotting macros now check for that error and will only print one error message rather than seven.

FIXES

Fix For ^C During sock_get()

The reworked signal handling introduced in spec release 6.09.01 prevented a ^C from immediately interrupting a sock_get() call. That issue is fixed.

Fix For Obscure spec_menu() Issue

A issue when using the "bit" key with a child item of a spec_menu() specification, where selected values weren't correctly assigned to an associative array passed as the @ value, has been fixed. (The fly_setup macro uses such a construct.)

Fix For motor_par() "read" For Tsuji PM16C-02/04 Controllers

Code that would likely produce a segmentation fault when using the motor_par() "read" command-pass-through option without an accompanying send string with the spec Tsuji PM16C-02/04 motor controller support has been fixed.

MACROS

whats Can Take Multiple Arguments

The standard macro whats, which displays what the given argument is in terms of spec objects, now accepts multiple arguments and will display the type of each one.

New Macros For Writing To the DATAFILE

The standard macros now send all string output destined for DATAFILE through a new macro function df_print(). The arrays sent to DATAFILE by the fly and mca scans now call a new macro function df_array() instead of the function array_dump(). A new df_flush() macro is called at the end of a scan in the standard _tail macro. These macros enable use of an alternative scheme for outputting data.

In the default case, the above macros write output to DATAFILE, just as before. However, if the new global variable DFILE_HOW is set to some string word, the above macros will instead call local macros named df_print_word(), df_array_word() and df_flush_word() which would output the strings and arrays passed as arguments as local needs require.

Changes to the standard macros are rather minimal. Usage such as fprintf(DATAFILE, ...) becomes df_print(...). In a few cases where fprintf() printed out partial lines, the entire output line is now collected into a string and that string is passed to df_print().

Existing local macros that write directly to DATAFILE will continue to work just fine. If local users want to take advantage of the new DFILE_HOW feature, local macros should use the new df_*() macro functions for data file output.

See the macros/file.mac file included with the spec distribution for more details on using DFILE_HOW.

SCAN_D Now Matches Data File Columns

The SCAN_D array, which holds motor positions and counter values for spec scans, now has the same column arrangement as is saved in the data file. The first column is the main independent variable of the scan. That is followed by other motors and/or HKL values involved in the scan. Next is the epoch time associated with the data point. The remaining columns are the the counter values. The counter associated with DET is always the last column. The counter associated with the preset (either time or monitor counts) is the second to last column. Other counters are ordered by counter number. What has changed is that SCAN_D now includes the epoch time, and the preset and DET counter values are now placed in the last columns.

Fix For Using Parameters In splot Macro To Specify Range

Previously, a command such as:

splot tth det 3:NPTS-3

would fail as the macros wouldn't properly evaluate the expression for the range of points. The above usage now works.

Fly Scan Updates

The fly scan macros include a number of updates. When using a prescaler, the number of intervals and range is now adjusted to insure a full complement of motor pulses will arrive to generate sufficient channel advance pulses to the multi-channel scaler. The macros attempt to maintain the range as best as possible, with most of the adjustment being on the number of intervals.

A new fly_setup option is available to configure how much of the sweep data is displayed on the screen. Since the data can't be displayed until it is read at the end of the sweep, it may not be desirable to have perhaps hundreds of data rows output to the screen at once. Configuration choices include:

o Display just the last line (traditional behavior)

o Display all the data

o Display the first and last block of data

o Display the first, middle and last block of data

The block size is currently six data points (or rows).

Also, an issue setting the motor pulses per unit in the fly_setup macro has been fixed.

HARDWARE

Configurable Gate For USB-CTR In MCS Mode

A new "gate_mode" mca_par() option for the Measurement Computing USB-CTR counter/timer is now available. spec supports that module in multi-channel scaling mode, which is used by the fly scan macros. See the usbctr and flyscan help files.

Select Motor Controller Support Now Uses 64-Bits For Speed

Support for macro hardware motors, spec server motors and the EPICS motor record has been updated to use the 64-bit resolution for motor speeds available in this spec release.

SmarAct MCS2 Controller Support Speed Update

The units for motor speed for the SmarAct MCS2 controller are now steps per second and can be specified with up to 64-bit integer precision. Note, previous support for the controller set the speed to a value which was the product of the config file setting and the steps per mm parameter. Current users of that motor controller need to adjust the values configured for slew rate, base rate, home slew rate and home base rate to reflect the updated support, which is now the usual steps per second.

Support for libusb-1.0

spec can now be linked with version 1.0 of libusb. Previously spec only supported version 0.1, which is on longer maintained. On Linux, spec USB support is available using built-in code that makes direct calls to the Linux generic USB driver. For MacOS, support is only through libusb. Version 1.0 appears to be required on MacOS Monterey. Both versions of libusb work with Linux, but the built-in code should be preferred. To use the USB libraries, the site_libs parameter in the spec install_data file needs to be assigned with the name of the library during spec installation, along the lines of:

site_lib="-L/usr/local/lib -lusb-1.0"

On MacOS, one may need to download the library source, build and install. Find the source at github.com/libusb. Most Linux distributions will have a downloadable package available with a name along the lines of libusb-1.0.0-dev.

January 15, 2022 - RELEASE 6.10.05

IMPROVEMENTS

encode()/decode() Updates and Fixes

The encode() and decode() functions now support Base64 in addition to JSON. The JSON decode() function now takes an optional associative array argument into which any JSON string can be decoded. JSON values that are objects or arrays will be returned as string array elements, which can then be passed into decode() again. See the encode help file for details.

New "match_one" Option For getline()

The getline() function accepts a new option, "match_one", which unlike "match", only returns the one line that matches the regular expression. See getline in the funcs help file.

HDF5 Support Updated To Current HDF5 Release

The built-in HDF5 support in spec is now using HDF5 stable release 1.12.1. Previously, spec was built against HDF5 release 1.10.1. See the hdf5 help file for details on spec's HDF5 support.

Certain Errors On spec Server Now Display With remote_eval()

When a "fatal" error occurs on a spec server while running a command sent by a spec client using remote_eval() or from any client sending a CMD_WITH_RETURN message, the server response will now include the error message in the return packet. A spec client will display the error. A fatal error is an error that resets spec to the command prompt, such as a syntax error or certain hardware errors. (See the HDW_ERR help file for a list of fatal hardware errors.)

The exit command also resets to command level. Messages associated with nonfatal errors or displayed with eprint or eprintf() will also be sent and displayed if an exit command follows the error within the statement block. However, if any additional commands between the error generating command and the exit generates an ordinary (non-error) message, the error message will not be returned.

Distribution and Installation Updates

The scripts and Makefiles used to prepare and install spec distributions have been cleaned and reorganized a bit. Entries for obsolete computer architecture targets are gone for the most part. (Supported platforms/architectures are currently 32-bit and 64-bit linux on both Intel and arm and 64-bit macOS on Intel and arm.) Commands and logic for setting file ownership during installation is improved. The spec_zcat gzip compression utility is gone, as there is no longer any risk that the "z" flag to tar will not be available.

The Python splot Utility Now Includes HKL on Plots

The Python splot utility will now show the reciprocal space HKL coordinates at the start of a scan in the plot header of the screen display.

FIXES

Fix For Both Server and Client Response To ^C

The reworked signal handling introduced in spec release 6.09.01 broke some ^C behavior when a spec server was running a command from a client. A ^C entered on the server keyboard was not recognized while executing an SV_CMD or SV_CMD_WITH_RETURN packet (generated by remote_cmd() or remote_eval() in a spec client). In addition, a spec client's remote_eval() could not be interrupted by a ^C on the client keyboard. Both issues have been fixed.

MACROS

Energy Macros Updated For Asymmetric Cut Monochromator Crystal

For type 5 two-crystal monochromators (configured with two motors with mnemonics mono and monp), the motor position calculations now take into account an asymmetric crystal characterized by the cut angle beta, stored as a constant global variable g_mo_beta. The setmono macro will prompt for the value of the cut angle. A zero indicates no correction.

New Rounding For Number Of Intervals In Scan Macros

The number-of-intervals argument in spec scans is now rounded to the nearest integer. That solves a problem when the argument is an expression involving floating point values and the integer value of that expression may be one less than the expected value. For example, the integer part of 10.2/0.01 is 1019, not 1020, due to the inexact representation of floating point numbers on a computer. If expr is the expression used as the number-of-intervals argument, the scan macros now use int(expr + 0.5).

November 9, 2021 - RELEASE 6.10.04

IMPROVEMENTS

New scantypes Help File

A new help file, scantypes, summarizes the many standard scans available with spec.

New -U fake_user Start-Up Option

The new -U fake_user start-up option creates a state file associated with the name fake_user rather than the actual account user name. Such a feature may be useful at a facility that requires all visitors to use the same computer account, but would like to maintain separate spec state files for each visitor. The site could require visitors to begin their sessions by entering their visitor ID, which could be placed in an environment variable used by a shell script that invokes spec with the -U flag and that variable.

FIXES

Better Test On RPC Library With Install

On some Linux systems the standard C library (glibc) no longer includes support for the SUN RPC function calls, used by spec's VXI11 and SPring-8 MADOCA hardware support. The library functions are needed to link spec during installation. An additional library (libtirpc.a) can be installed on those systems. The spec Install script does a check on whether that alternative library is needed and available. If needed, but not available, the script requests it be installed. The previous version of the check was not entirely robust across platforms. The test is this release should work better.

Fix For array_dump() Not Closing File

An old bug, where under some conditions an output file specified as the first argument to the array_dump() or data_dump() functions was not closed at the end of the function call, has been fixed.

Fix For spec_menu() "text" Item

A bug in the recently introduced "text" spec_menu() item which could result in corrupted menu displays has been fixed.

HARDWARE

Additional Parameters Available For Galil Controllers

The built-in support for Galil motor controllers now recognizes additional non-standard optional motor parameters and recognizes additional motor types. The recognized Galil commands and associated spec parameters are as follows:

KP      proportional_gain
KI      integral_gain
KD      derivative_gain
IL      integration_limit
FV      veloc_feedforward
FA      accel_feedforward
DB      on_band
DS      off_band
OE      off_on_error
ER      error_limit
SK      max_pulse_freq
MT      motor_type
CE      configure_encoder

The first six can also be specified using the similarly named standard optional parameters (names having an initial "dc_"). Commands for all but the last two parameters are normally only sent with the first move after start up or a reconfig, or if the values have been changed with motor_par(). The command motor_par(mne, "update") will update the controller immediately. The last two commands are sent immediately after reading the config file or when changed with motor_par().

Setting "motor_type" to values 12, -12, 12.5 or -12.5 turns on encoder mode and position maintenance mode (if available). Values of 1 or -1 turn on servo mode (if available). Setting "motor_type" will override the encoder and servo mode selections made by setting the controller to GALIL_E or GALIL_S in the config file. The MT command is only sent to the controller if "motor_type" is set.

For encoder and servo modes, positions are read with the TP controller command, otherwise RP is used. When encoder mode is enabled, the chg_dial() function will send a DE controller command in addition to a DP command. In encoder mode, if the standard optional parameter "encoder_step_size" is set and nonzero, the value read from TP or sent with DE is scaled by the ratio of motor steps to encoder steps.

Updates To Mclennan Motor Controller Support

The communication with the Mclennan motor controllers has been made a bit more robust. Also, spec can now read and return long replies, such as those generated by the "QA" (query all) and "HE" (help) commands. spec now recognizes the motor types PM600_P and PM600_S that signify using an encoder with position maintenance and using a servo motor. New motor_par() commands "update" to program the controller with the current parameters in spec and "dump" to display all the controller parameters are available. Additional optional parameters are recognized. See the new mclennan help file for details.

New motor_par() "update" Option For Newport SMC100

A new motor_par() "update" option for the Newport SMC100 motor controller will send commands to update any changed parameters. Updating some parameters requires a reset/homing cycle that can take several seconds. As before, reprogramming is done automatically, if needed, on the first move after any parameter has changed. This new option allows the parameter programming to be done before executing a move command. See the newport help file.

Better Thread Mutex Locks For Measurement Computing USB-CTR

spec creates a dedicated thread to read data from the Measurement Computing USB-CTR when running in multi-channel scaling (MCS) mode. The code includes mutex locks around the USB access to allow access to other functions of the USB-CTR while MCS acquisition is in progress. The first implementation of the mutex locks would sometimes freeze out attempts to access the controller through the main spec thread (to access the I/O pins, for example). This spec release takes a slightly different approach to the mutex locks that appears to solve the problem.

Fix For DSP CC-488 GPIB-To-CAMAC Controller

A problem with the DSP CC-488 GPIB-to-CAMAC controller, where the code did not properly poll the LAM (look-at-me) register, has been fixed. Yes, at least one spec user still uses CAMAC.

July 30, 2021 - RELEASE 6.10.03

IMPROVEMENTS

Accommodation For Dangling ifs In Command Files

The lexical analyzer will now complete a dangling if (that is, an if statement without a corresponding else) at the end of in input file and no longer generate syntax errors. The standard macro source files have included a last line of the sort, "# Do not remove this line -- it keeps the parser from waiting for an "else"." for a long time. Such measures are no longer needed.

New Installation Option For Reading TIFF Image Files

The fmt_tiff.c file included in the spec distribution has always include the option for reading TIFF images files with spec's fmt_read() function. However, because inclusion required that the TIFF libraries be available, the option was off by default. Turning on the option required changing a #define option in the fmt_tiff.c file and including the TIFF library in the site_libs install parameter. With this release, the spec Install script now prompts for the TIFF library. If a library is selected, the fmt_tiff.c file will automatically be built with the TIFF file read option enabled. Updating or reinstalling spec with the same install_data file will automatically maintain the TIFF file read option selected.

deg() and rad() Now Work With Data Array Arguments

The functions deg() and rad() can now take a data array as input argument. The functions perform the operation on each element of the array and return the results in an array of the same dimension as the argument array.

HARDWARE

Updates For Newport SMC100CC/PP

The spec support for the Newport SMC100 motor controller now distinguishes between the CC and PP flavors, allowing the base rate to be set for the PP type. In addition, nonstandard optional motor parameters, "micro-step_factor" and "full_step_value" are recognized for the PP flavor, while "closed_loop" and "encoder_increment" are recognized for the CC type. Refer to the Newport manual for a description of the parameters. See the newport help file for a list of all parameters supported by spec. Also, an issue where spec would unnecessarily put the controller in the "configuration" state to reprogram parameters that hadn't actually changed in value has been fixed.

Updated Support For Trinamic TMCM Controllers

The Trinamic TMCL support now includes support for the model TMCM-6214. In addition, spec now sets all parameters associated with the "SixPoint" motion profile used by this and other models. See the tmcl help file.

Tsuji Counter CT08-01F Recognized

spec now recognizes Tsuji CT08 with firmware 01F.

FIXES

Fix For Screen Width Changes In spec_menu()

The spec_menu() function compressed long strings as intended when redisplaying the menu with a narrower screen, but didn't uncompress the strings if redisplayed after the screen was made wider. That issue has been fixed in this release.

Fix For Logarithmic Axes With Python splot

Issues when using logarithmic axes with the Python splot utility have been addressed. Data points with values less than or equal to zero are now not plotted and not used in setting the axis range.

Fix For USB-CTR MCS Dwell Time

A bug introduced in spec release 6.10.01 with the Measurement Computing USB-CTR, where the parameter set using the mca_par() "dwell" option was converted to an integer, has been fixed. With the bug, dwell times less than one second were set to zero, which is invalid. The code sets the dwell time to the default of 0.01 seconds when the parameter is not valid.

Fix For Distribution File Ownership

The Install script now does a better job of setting the owner of the distribution and installation files to the owner specified in the install_data file. Previously, a number of files ended up belonging to the root user, even if another owner was configured.

MACROS

Fix For flyscan Macro

An issue where the flyscan macro generated motor positions incorrectly if scanning from a larger to smaller position has been fixed.

Fix For Saving EPOCH With cscan Macros

The cscan macros now save the EPOCH value to the data file to millisecond resolution, which now matches the behavior of the standard scans.

May 11, 2021 - RELEASE 6.10.02

IMPROVEMENTS

Assignment Now Allowed With array Declaration

The array declaration now supports initialization. For example,

array a[10] = [ 1, 2, 3 ]
string array a[20] = [ "this is a test" ]
ushort array a[2][3] = [ 1, 2, 3, 4, 5, 6 ]

Unassigned array elements are set to zero. Surplus initializers are ignored. For 2D arrays, elements are assigned row by row. In the last example, the assignment produces:

SPEC> print a
{{1, 2, 3}, {4, 5, 6}}

See the arrays help file.

FIXES

Fix For spec Client Connecting To Remote Servers

An issue introduced in spec release 6.09.13, where a spec client might fail to connect to spec servers on a different host, has been addressed.

MACROS

Fix For Typo In Updated sixc.src

Missing def keywords in the recently updated sixc.src file have been added. The update was to implement the new macro definitions for aziscan and azidscan that use the new _pa_scan_prep geometry pseudo angle scan.

April 29, 2021 - RELEASE 6.10.01

IMPROVEMENTS

New Runtime Counter Creation

Runtime counters can now be created without editing the spec hardware config file or reinitializing the hardware. The command:

counter_par(mne, "add" [, macro_name ])

creates a new counter with the specified mnemonic. The optionally specified macro function will be called with the counter mnemonic as argument when the getcounts command is executed. When spec executes the getcounts command, hardware counters are read first, then macro-hardware counter macros are called, then runtime counter macros are called. This order determines what counter values are available to the macros. The command:

counter_par(mne, "delete")

removes the specified counter. The command:

counter_par(mne, "name", "New Name")

can be used to assign the counter name. Otherwise the name will be the same as the mnemonic. Mnemonics can be at most 7 characters, while names can be 15 characters long.

The runtime counters disappear on exit or hardware reconfiguration (reconfig). The built-in config_mac macro can be used to have the counters automatically recreated after reading the hardware configuration. (See an example of that in the roi.mac file.)

The "controller" and "device_id" options to counter_par() both return the string "RUNTIME" for these counters.

Bad Mnemonics for counter_par() and motor_par() Now Return an Error

When the counter_par() and motor_par() functions are called with an invalid mnemonic or channel number, the functions now set HDW_ERR to value 6 (unconfigured hardware) and return -1. Previously, such errors were "fatal" in that spec would jump back to the main prompt.

New "config" Option To image_par(), mca_spar() and mca_par()

The new usage image_par("config") displays the current configuration for all images devices in the same format that mca_sel("?") displays MCA device configuration. That is, information including unit numbers, device description and enabled status is shown. The usage image_par(sel, "config") returns a string containing the configuration for the selected unit only, or returns zero if there is no corresponding entry in the hardware configuration file. For symmetry, the usage mca_spar("config") and mca_spar(sel, "config") does the same for MCA devices. mca_sel("?") still works as before.

New spec_menu() Feature For Including Multiple Parameters On Single Line

New spec_menu() "family" and "parent" keys allow setting values for multiple parameters on a single line. The "family" key configures IDs for each sibling. The "parent" key associates an item with a "family". In addition, a new "prefix" key is associated with "parent" descriptions. A new "check_macro" key allows configuring a validation macro to be called on number and string items. See the spec_menu help file for details.

Better Validation Of config File Motor/Counter Numbers

The code to read motor and counter configuration from the spec hardware config file now has improved validation of the motor and counter numbers. spec now insists on consecutive numbers with no duplicates. The edconf configuration editor always saves files using those rules, but the update catches errors that might be introduced by a manual edit of the file.

Metacharacters Allowed With Some Chained Macro Operations

When the strdef() function is used to return the definition of a cdef chained macro, the second argument specifying the cdef key can now include the standard metacharacters *, ? and [] for matching. When using delete, enable or disable flags with cdef(), the third argument specifying the cdef keys can now include the same metacharacters. As usual, * matches anything, ? matches any single character, and [] enclose a range of characters to be matched.

eval() Quiet Mode Puts eprint/eprintf() Messages In EVAL_ERR

The eval() optional "quiet" argument suppresses spec errors but puts the error message in the global variable EVAL_ERR. In this release, messages from eprint and eprintf() are now treated in the same manner, in that they won't appear on the screen and the last such message will be assigned to EVAL_ERR. See eval in the funcs help file.

Improved Syntax With 2D Associative Array for and if Commands

Previously, spec would allow a loop or a test for just one element of a 2D associative array, but would not accept an empty set of brackets for the second index. That is:

local arr[] = [ "one":1, "one":2, "two":3 ]

for (i in arr["one"])
   print arr["one"][i]

would work, but:

for (i in arr["one"][])
   print arr["one"][i]

would not work with the empty brackets resulting in a syntax error. That usage is now permitted, as is also:

if (2 in arr["one"][])
    print "yes!"

A set of empty brackets for the first element has always worked.

New HISTCMD Built-in Variable Holds Current History Number

The command line history number is now accessible as the parameter HISTCMD. That is the name used for the same item in the standard bash and zsh shells. HISTCMD is used in the new standard highlight macro described below.

Additional Geometry/Orientation Matrix Errors Made Non-Fatal

A number of errors associated with calculation of the orientation matrix for various diffractometer geometries are no longer fatal. That is, the errors no longer cause spec to stop execution and jump back to the command line prompt. Instead, the associated calc() call now returns an error. Possible errors are a zero lattice constant or lattice angle, a zero LAMBDA (incident wave-length), a zero length reflection or parallel reflections when calculating the orientation matrix from two reflections or failure to fit an orientation matrix from multiple reflections (for example, if the reflections are all in the same plane).

Most of the standard scan macros already check the return value of calcA (defined as calc(1) for all standard geometries and used to calculate motor positions from reciprocal space coordinates) and exit the scan or move if there is an error.

HARDWARE

Update to USB-CTR Digital I/O Pins Access

When the Measurement Computing USB-CTR is used in "external-gate-select" mode, one to three of the eight digital I/O pins are reserved and used for gating the counter channels based on which channel is designated as the master counter. Previously, spec prevented changing the state of those pins at all times. Now it is possible to set and clear those pins except when actively counting. See the usbctr help file.

Fix For USB-CTR Time Presets Over 36 Minutes and Counters Over 32 Bits

It seems the Measurement Computer USB-CTR firmware does not allow time presets greater than 31 bits. With the timebase frequency set by spec to 1 megahertz, the maximum count time was a bit less than 36 minutes. The code now decreases the timebase frequency by a factor of ten for each factor of ten in the preset count time above 36 minutes, but only when the hardware config file sets the scale factor for the timebase to the recommended 1e6. If set to another value, spec assumes an external timebase. See the usbctr help file.

In addition, a bug where counter values greater than 32-bits were not converted correctly to count values in the S[] scaler array has been fixed.

New Tracking Option For EPICS PV Monitors

The "monitor_set" option to epics_par() now takes an optional argument that is a spec global variable or data array. When set, the value of the spec parameter will track the value of the EPICS process variable. See the epics help file for details.

Encoder Mode Update For Galil Motor Controllers

By default, the spec support for Galil motor controllers uses relative move commands for encoder motors (GALIL_E) and absolute move commands otherwise (GALIL). A new custom optional motor parameter "encoder_move_mode" can be assigned values "absolute" or "relative" to set what kind of moves to use for encoders. Use the p command from the standard Motor screen to access the custom parameter screen.

Errors Now Checked When Setting Newport XPS Speeds

spec will now return an error on starting a move or home search on an XPS controller if the PositionerSGammaParametersSet command returns an error when setting the velocity and acceleration. Previously, spec would consider the speeds had been set and proceed with the moves.

Updates For SPring-8 MADOCA Support

An issue where spec would query a MADOCA motor controller during hardware configuration if there were any motors configured to use the controller, even if the associated controller was set to "OFF" in the config file has been fixed. If the controller is unavailable, no MADOCA commands will be sent.

In addition, spec now rounds count times to the maximum two significant figures the standard MADOCA timer hardware supports. spec also will truncate count times to the maximum 990 seconds allowed. Warning messages are printed in each case. To disable count time adjustments for the less used MADOCA timers that don't have such constraints, set the nonstandard optional controller parameter "no_time_check" to a nonzero value from the Devices screen of the configuration editor.

MACROS

New Region Of Interest Counter Macros

A new facility to create run-time region of interest (ROI) counters is now included with the standard macros. The macros work with any MCA- or image-type controller. Counters are created using the new counter_par() "add" function. The ROIs can be configured to return the sum, average, minimum or maximum values associated with the specified detector region. Multiple ROIs can be assigned to the same controller. A new roisetup macro uses the spec_menu() built-in function to provide a configuration screen. See the roi help file for details.

New highlight Macro Displays Matching Items From Command History

The standard macros now include a macro called highlight, which takes a single argument. The argument is a string or regular expression. The macro displays all items from the command line history which match the argument. The matches are displayed as highlighted text. The macro uses the new HISTCMD variable, the relatively new get_history() function, and the slightly less new match() and gsub() functions.

New Option For newfile Macro

When re-opening an existing data file, if the current scan number (SCAN_N) doesn't match the last scan number of the file, the newfile macro will now prompt whether to assign SCAN_N to continue the existing file scan numbering. In addition, if a -c argument (for "continue") is included on the newfile command line, the assignment will be made with no prompting, even if a different scan number was included on the macro command line.

New ub_default Macro To Reset Geometry Parameters

A new ub_default macro is available to reset geometry parameters to the default values they have after starting fresh. The parameters include the lattice constants and the HKL values, angles and associated energy of the primary and secondary orientation reflections.

New Implementation For Geometry Pseudo Angle Scans

The standard macros now include a utility macro called _pa_scan_prep that is used with a number of geometry macros to scan pseudo angles. Both regular and delta versions of the scans are included. The fourc, fivec and sixc geometries have aziscan and azidscan to scan the AZIMUTH pseudo angle. The zaxis geometry has alphascan and betascan, along with delta versions, to scan the ALPHA and BETA pseudo angles. The psic geometry includes alphascan for ALPHA, betascan for BETA, omscan (or thscan) for OMEGA, psiscan (or aziscan) for PSI, qazscan for QAZ and nazscan for NAZ along with delta versions for each. See the comments in the newscans.mac source file for details on how _pa_scan_prep works.

resume Macro Now Restores cleanup_once Macro

The resume macro that restarts scans that were interrupted (usually by a ^C) now restores the cleanup_once macro that was in effect at the time of interruption. For example, with delta scans, the cleanup_once macro returns motors to their positions at the start of the scan. Previously, if a delta scan was resumed, the cleanup action was lost and the motors would not be returned to starting positions.

splot Macros Simplified When Using the Python splot Utility

The draw_plot() macro function used by the splot macro no longer includes unnecessary calls of splot_cntl() to set PLOT_MODE parameters, as the splot utility gets those parameters from the meta region of the SCAN_D[] shared data array.

_dscan_cleanup Updated To Use move_info()

The _dscan_cleanup macro used by most of the delta scans to return scanned motors to positions held at the start of the scan now includes a call to move_info() to determine which motors need to be moved. This change eliminates messages about returning motors to a position they are already at, particularly in the case of the scans associated with the geometry pseudo angles introduced in this release.

Fly Scan Macros Updated

The fly scan macros have a number of updates and fixes, including a new configuration choice in fly_setup to select permitted fly scan motors and parameters for each. In addition, it is now possible to select channel advance behavior for the motorless fly scans, choosing either the internal clock (the default) or an external signal.

Fix For disable_undo Of the disable Macro Set

A small issue, where the saved state of disabled hardware could not be restored with a disable_undo after successful completion of a disable/enable command, has been fixed. See the disable help file for details on the macros.

New Option To Disallow Using Motor Numbers For Move Commands

The standard move macros (mv, umv, mvr, umvr, mvd, umvd, mvr2 and umvr2) traditionally allow motors to be specified by motor numbers in addition to mnemonics. In order to avoid one kind of typing error that results in moving a motor unintentionally, the mstartup (or startup) macros now offer the option to disallow using motor numbers to specify motors for those move commands. If the new global variable NO_MV_MOTNUM has a nonzero value, the macros will print an error message and exit if numbers are used instead of mnemonics. Note, though, variables are still allowed as long as they have been set to a value. Using an uninitialized variable to specify a motor has resulted in an error since spec release 6.05.01. The feature is off by default. Assign a nonzero value to NO_MV_MOTNUM in a local macro file such as site.mac in SPECD to enable the check for all users.

FIXES

Fix For Crash On motor_par(mne, "?") In Some Configurations

For a small number of motor and scaler types, spec could crash if there was a motor or scaler configured but no corresponding controller configured, and the motor_par(mne, "?") or counter_par(mne, "?") functions were called. This was notably a problem with macro hardware motors and scalers, but also affected a handful of other controller types. The issue is now fixed.

Fix For Using Three Arguments With strdef()

A bug that prevented the three-argument invocation of the strdef() function has been fixed. The strdef() function returns the macro definition of its first argument. For cdef() chained macros, the second argument can specify a key to match cdef() segments. The last argument for both regular and cdef() macros can be an associative array that will be filled with the defined argument names if the macro is a macro function, along with an element called "file" that will be filled with the macro source location.