spec

Software for Diffraction

disable and enable

Disable and Enable Hardware

DESCRIPTION

The enable and disable macros provide a simple way to disable hardware not currently involved with measurements, which may speed up scans by eliminating unnecessary hardware access. The macros also re-establish the disabled state across reconfig and even spec sessions (if not starting fresh).

The enable and disable macros take a list of motor or counter mnemonics or MCA or image-type image devices (specified as mca0, mca1, ... or image0, image1, ...) and enable or disable the specified devices. The different types of devices can be mixed on the command line in any order.

Additionally, words such as all, all counters, all motors, all mcas or all images can be used. These can be modified with except or but not (which mean the same) followed by additional mnemonics. Also, the modifier only will enable or disable only the individual devices that follow. The word and can be used in the list but has no effect.

The sec counter will never be disabled.

Use a ? argument to get a list of the current status of all devices. The ? can be included with other arguments, and the list will be shown after the state of the devices has been set according to the other arguments.

EXAMPLES

Just disable/enable mca1. The state of other hardware is unchanged:

disable mca1
enable mca1

Disable/enable all devices:

disable all
enable all

Disable MCAs. Enable everything else:

disable only mcas
enable all except mcas
enable all but not mcas

Disable MCAs and image-type devices. Enable everything else:

disable only mcas and images

Disable all hardware except the counter det and the four specified motors. disable all except ... and enable only ... have the same effect:

disable all except det tth th chi phi
enable only det tth th chi phi

Disable all motors except the four listed:

disable all motors except tth th chi and phi
disable all motors but not tth th chi and phi

Enable all hardware except for image0:

disable only image0

DETAILS

The state of disabled devices is saved in the associative array DISABLE_OLD before changing anything in the enable/disable macros. The disable_undo macro restores the state from DISABLE_OLD.

Also, if there is an error in parsing the arguments, the macro calls disable_undo to restore the state before exiting.

The macros maintain the state of disabled devices in the global associative array DISABLE. The global variable retains its value across a reconfig or spec sessions, except when starting fresh.

At ESRF, the esrf_db() function is used to store the state of disabled counters and motors. This state is maintained even when starting fresh.

When the macro source file is read, the disable_get_db() and disable_set_db() macros are dynamically defined (using rdef) to use esrf_db() if it is available, otherwise the DISABLE array is used.

In order to enable the functionality of having the disabled state of the hardware maintained across reconfig, the following command is needed:

cdef("config_mac", "disable_setup;", "disable_mac")

The config_mac macro name is built into spec and is run automatically (if defined) after hardware configuration. The spec administrator can add the above line to the local site.mac file if the feature is to be used.

INTERNAL MACROS

The _dis_fit() macro is used for formatting of the disabled status. The macro takes two arguments, a short label string and an arbitrarily long string of space-separated words. The macro returns a string containing the label followed by the words broken into multiple lines so that the length of a line doesn't exceed the number of columns available, up to a maximum of 70 columns. Subsequent lines are indented by the length of the label.

The disable_save() macro saves the previous state in DISABLE_OLD for disable_undo, and saves the current state in DISABLE. In addition, disable_save() returns the current state as an associative array which can be used as an argument to the macro function disable_restore(), which will restore hardware to the saved state.

If dont is nonzero, DISABLE_OLD is not touched.

The disable_counter(), disable_motor(), disable_MCA() and disable_image() macro functions each take two arguments, the device mnemonic or identifier and a 0 or 1 to indicate whether to disable or enable, respectively. The functions call the appropriate spec built-in function to enable or disable the controller, and save the state in the data base.

ACKNOWLEDGMENTS

The enable and disable macros borrow heavily from macros developed at the ESRF in 2000 by Friedrich Schotte.

GLOBALS

DISABLE[]

DISABLE_OLD[]

MACROS

disable

enable

_disable(clist, how)

disable_undo

disable_setup

disable_get_db(s, mne)

disable_set_db(s, mne, state)

_dis_fit(a, b)

disable_save(dont)

disable_restore(dis)

disable_counter(mne, state)

disable_motor(mne, state)

disable_MCA(mne, state)

disable_image(mne, state)