spec

Software for Diffraction

changes

Highlights for spec release 6.05

April 5, 2017 - RELEASE 6.05.04

IMPROVEMENTS

New setsector for ESRF SUV Geometry

A new option for the ESRF horizontal z-axis diffractometer to flip the sign of the delta circle is implemented. A new setsector macro in the SUV geometry code toggles the mode.

MACROS

The newfile Macro Will Add Header If Missing In File

In addition to the warning message that appears when opening a spec data file that doesn't begin with the usual #F, the newfile macro will now append the standard file header to the data file if no line in the file begins with #F.

New _g3 Global To Track Mesh Scan Rows

A new global variable associated with the standard scan macros is set to the first point number for each row of a mesh scan. For non-mesh scans, _g3 remains at zero. This parameter joins _g1, the point counter in the inner loop of scans and _g2, the point counter in the outer loop of mesh scans. The _g3 variable will be used by the Python splot utility when displaying the results of mesh scans as 2D plots.

Added Missing calcHKL In Continuous Scan Macros

A missing call to calcHKL in the _cscan() macro function (used by all the continuous scan macros) has been put into place. Without that call, the SCAN_D array did not contain HKL values when it should have.

FIXES

Fix For cnt_num() and motor_num()

A bug in the new argument evaluation feature introduced in spec release 6.05.01 for cnt_num() and motor_num() has been fixed. Before the fix, cnt_num() would accept a string containing a valid motor mnemonic and motor_num() would accept a string containing a valid counter mnemonic. Now, those uses return a -1 error.

Fix For GETLINE_EOF

A bug, where the recently introduced global variable GETLINE_EOF was set to -1 when getline() was successfully called with the "open" or "close" arguments, has been fixed.

HARDWARE SUPPORT

Fix For TANGO_ERR

An issue where requesting an attribute or property that doesn't exist on a TANGO device didn't follow the documented behavior has been fixed. The behavior is supposed to be that if TANGO_ERR is set to -1 before the tango_get(), tango_put() or tango_io() call, no error message is printed, the calling function returns -1 and TANGO_ERR is set to the text of the message. That wasn't happening for the particular error above, but is fixed in this release. See the tango help file for details on use of TANGO_ERR.

Refinement Of EPICS "slop" Parameter

The special behavior in spec for EPICS motors with the optional read-back "slop" parameter set to a nonzero value has been updated. In spec release 6.03.07, a feature was introduced so that the "slop" parameter for EPICS motors creates a position dead band. Position events within "slop" counts of the current position don't update the current position in spec. However, at the end of a move or during a sync command, the current position will always be read. This update further restricts the position updates to motors started by spec.

February 22, 2017 - RELEASE 6.05.03

IMPROVEMENTS

Greater Flexibility In Associative Array Initialization

It is now possible to initialize associative arrays without specifying the array index. If the array index is missing, spec will use the position number of the data value in the list as the index number. For example:

testarray = [ 123, 456, "testing" ]

is the same as:

testarray = [ 0:123, 1:456, 2:"testing" ]

Explicit index values can be intermixed with missing values. For example:

testarray = [ 123, "second":456, "testing" ]

will result in:

testarray["0"] = 123
testarray["2"] = "testing"
testarray["second"] = 456

Also, initialization can now be carried out over multiple lines without having to use a backslash escape to continue lines, although the final closing bracket must appear on the same line as the last initialization value.

Array Assignment Implemented For Associative Arrays

It is now possible to assign the same value to every element of an existing associative array. For example:

S = 0

will set all elements of the scaler array S[] to zero.

Improved Sort For Symbols and Associative Array Elements

An improved "natural sort" algorithm is now used for sorting associative array elements displayed with print and for determining the order that array elements are accessed using the for i in arr syntax. The same sort algorithm is applied to the list of symbols displayed with syms, the macros displayed with lsdef and the symbols and values displayed with the utility show_state. "Natural sort" means that consecutive digits are treated as a single character and sorted according to their value as a group. That way, a10 will come after a9, contrary to the order with strict lexicographical sorting.

Consistency For Bit-Shift Operators

The support for (not quite) 64-bit integer operations introduced in spec release 6.00 treated the bit-shift operators somewhat differently than the other bit-wise operations, which masked the operands to 52-bits (the maximum precision available for the significand in double-precision floating-point values, which is how spec stores numbers). Previously, the bit-shift operators didn't mask the operand, which allowed the highest order bits to be used, but if those high-order bits were set, the values of the low-order bits would be lost. For consistency, the bit-shift operators now simply mask the operands to 52-bits and then do the shift operation.

Can Now Use wait() For Externally Started Motors

When spec is sharing motors, either as a client to a spec server or using EPICS channel access, if those motors are started by a different client, setting bit 4 (16) in the argument to the wait() function will cause spec to wait until those motors have completed their move. Waiting can be interrupted with ^C, but that will not stop the motors. See the wait help file for details.

FIXES

Fix For Escan fixQ Mode

When the Escan macro was rewritten to use the new array-based scan engine in spec release 6.03.08, the fixQ mode was not handled correctly. This spec release includes an updated Escan macro that includes the geometry motors in the motor position array passed to the _array_scan macro scan engine.

Fix For Delta xscan Macros

A bug in the placement of curly brackets that broke the delta scan versions of the xscan macros (xdscan, xd2scan, ...) is fixed. The xscan macros break up a scan into three regions doing denser point spacing in the middle region.

MACROS

Scans With Count Time of Zero Now Set Count Values to Zero

The standard count and _upd_count macros used to start the counters during scans now set the values of the S[] scaler array to zero if the count time argument is zero.

January 27, 2017 - RELEASE 6.05.02

FIXES

Fix For Crash On reconfig

Release 6.04.05 contained a fix for a memory leak that occurred during reconfig when using macro hardware pseudomotors. Unfortunately, the fix was buggy, and with some macro hardware pseudomotor configurations, spec crashed on reconfig. This release solves the crashing problem and still fixes the memory leak.

January 20, 2017 - RELEASE 6.05.01

IMPROVEMENTS

New Argument Parsing For motor_num() and cnt_num()

The motor_num() and cnt_num() functions now evaluate their arguments. If the argument is a number, it is checked if it is in range of allowed motor or counter numbers. If the argument is a simple string, it is checked whether it is a valid mnemonic. If the argument is an uninitialized variable, the functions return -1. If the argument is an initialized variable or an expression, the argument is evaluated. If the result is a number, its value is checked against the valid range. If the result is a string, its value is checked against valid mnemonics. Only commands and functions that make sense in the context are allowed in the expression. Commands that control hardware or generate screen output are not allowed. For example, sprintf() is allowed, but not print or printf(). The functions return -1 if disallowed commands are included.

Built-in Expression Evaluation in spec_menu() Now Safer

Text input to "value" items in the spec_menu() arrays is evaluated using the built-in spec parser. Previously, any allowed spec keywords were accepted. With this spec release, only commands and functions that make sense in the context are allowed. For example, commands that control hardware or generate screen output are not allowed. In addition, most of the error messages that might occur during evaluation of the expression will now appear in the spec_menu() error space rather than at the cursor position.

Revamped History Facility

The command-line history is now saved in a separate file from the state file. It is now possible to start "fresh" while retaining the command line history. (A "fresh" start resets all symbols to their default values, and reinitializes the set of defined macros and global variables from the standard command files in SPECD, /usr/local/lib/spec.d, by default).

When starting "fresh" with the -f or -F flags, an additional -h flag on the command line means retain history.

The new history file is saved alongside the state file in the SPECD directory. If the state file is named, for example, /usr/local/lib/spec.d/fourc/userfiles/user_ttyp#S, the history file will be named /usr/local/lib/spec.d/fourc/userfiles/user_ttyp#H.

Additionally, the maximum size of history can be set using the spec_par() function. The command spec_par("history_size") returns the current maximum number of lines saved to history, which defaults to 1000, the fixed value in previous spec versions. A command such as:

spec_par("history_size", 2000)

sets the history size to the indicated value. For sanity, there is a maximum allowed value (32768).

Although this release of spec and the accompanying show_state utility can read state files from previous spec releases, previous versions will not be able to use state files created from this release. Starting an older spec release with state files from this spec release (or later) will display a message about incompatible state files and force a "fresh" start.

setcap Now Used By Default On Linux

As anticipated in the release notes for spec release 6.04.04, the Linux capabilities facility has now become the default method for giving spec access to PC hardware. The operation on the spec executable takes place during installation when the spec Install script is run by the root user. If the Linux platform lacks the setcap command, spec will use set-user-id root mode, as before. The enhanced capabilities are needed in configurations that use spec's built-in support for certain instrument control and data acquisition devices. For some hardware, spec needs access to /dev/mem to map PCI/PCIe memory space to the spec process. On some recent Linux platforms, PCI/PCIe cards used by spec without kernel drivers are disabled on boot by the Linux kernel, and spec needs escalated privileges to enable the cards. If udev rules are not in place to set permissions for USB devices supported by spec, spec will use escalated permissions to open the device nodes. For some older PC cards, spec needs direct access to I/O ports. To protect the system, spec turns off all capability modes immediately on program start up (just as it does with set-user-id root privilege) and only enables the capabilities around the few lines of code used to gain access to the otherwise unavailable resources.

splot Updates

The Python splot utility is now at version 3.02.

MACROS

Motor Argument Can Now Be a Symbol or Expression

The motor scan macros, the move macros, the home, set, set_dial, zero and set_lm macros all can now have motors specified as expressions or symbols, as they all use the updated motor_num() function. A number of macros that previously partially accommodated use of symbols or expressions have been simplified, since the capability is now included in the built-in code for motor_num(). In addition, the _check0 macro, which protected against moving motor zero due to mistyping a motor mnemonic (creating an uninitialized symbol with a value of zero), is now obsolete, as the built-in code implements that protection. However, _check0 will still be included in the standard macros to accommodate local macros that still use it.

Motor Macro Value Arguments Can Be a Symbol or Expression

The value arguments for the standard motor macros set, set_dial, set_lm and home (the optional home position) can now be expressions or symbols, as the arguments will be evaluated using eval2().

File Scan Macro Will Now Plot Mesh Scans

A new #L control line in the header of input files for the fscan (file scan) macro can be used to specify the number of outer Loops contained in the following data. The total number of points in the file will be divided by the number of outer loops and spec will reset the real-time plot for each such loop.

Minor Updates to Standard Macros

Several minor updates are included with the standard macros:

  • The internal _mot macro has been renamed _show_mot.
  • The "+0" strings in all the eval2() occurrences have been eliminated, since eval2() now treats single numbers or symbols as expressions.
  • The internal local variables in macros that use eval2() to evaluate macro arguments have been renamed with an initial underscore to avoid conflicts with user symbols (users should avoid using initial underscores for their variables to prevent conflict with spec internal symbols).
  • The set_lm macro now includes the values in user units when printing the new limits.
  • The macros that use spec_menu() (mstartup, setplot, counters, and setshow) now set the maximum width to 90 characters to improve readability on wide windows.
  • The fscan (file scan) macro does a bit better job handling improperly formatted scan files.

FIXES

Fix For Updated Counting Macro

A missing expression in the updated _upd_count in spec release 6.04.05 resulted in each counting update during the scan to generate a newline on the screen. That issue is fixed.

Fix For Continuous Delta Mesh Macro

A typo that produced the wrong outer loop values for the cdmesh (continuous delta mesh) macro has been corrected.

Fix For lup Macro

An issue where the lup (line-up) macro was not properly supported by the new array-scan engine has been fixed.

Fix For Using Multiple Windows With the splot Utility

An accidental edit to the definition of the macro symbol PL_MULTI_SPLOT in spec release 6.03.09, which broke using multiple windows with the Python splot utility, has been corrected.

Fix For set_sim() No-Sleep Toggle

The command set_sim(0x10) turns on a mode where the user-level sleep() command returns immediately, while set_sim(0) turns that mode off. Previously, if spec was started in simulate mode with the -s flag or was forced into simulate mode due to a hardware lock, set_sim(0x10) could still be used to set no-sleep mode, but set_sim(0) would not turn the mode off. With this release, set_sim(0) will turn off no-sleep mode.