SetAttributeFlags

IVI Library

Ivi_SetAttributeFlags

Usage

ViStatus Ivi_SetAttributeFlags(ViSession vi, ViAttr attributeID, IviAttrFlags flags);

Purpose

This function sets the flags of an attribute to new values. It always sets all of the flags. If you want to change one flag, use Ivi_GetAttributeFlags to obtain the current values of all the flags, modify the bit for the flag you want to change, and then call Ivi_SetAttributeFlags.

You cannot modify the value of the IVI_VAL_MULTI_CHANNEL flag.

Parameters

Name Type Description
vi ViSession

Returns a ViSession handle that you use to identify the session in subsequent function calls.

This function creates a new session each time you invoke it. This is useful if you have multiple physical instances of the same type of instrument.

Avoid creating multiple concurrent sessions to the same physical instrument. Although you can create more than one IVI session for the same resource, it is best not to do so. A better approach is to use same session in multiple execution threads. You can use functions Ivi_LockSession and Ivi_UnlockSession to protect sections of code that require exclusive access to the resource.

attributeID ViAttr

Pass the ID of an attribute for this parameter.

The include file for a specific instrument driver defines constant names for all of the user-accessible attributes that apply to the driver. This includes attributes that the IVI engine defines, attributes that the instrument class defines, and attributes that are specific to the particular instrument. Each defined constant name begins with PREFIX_ATTR_, where PREFIX is the specific instrument prefix.

For each IVI engine attribute, the specific driver include file uses the same constant name that appears in ivi.h, except that the specific instrument prefix replaces the IVI prefix. For example, ivi.h defines IVI_ATTR_CACHE, and the Fluke 45 include file, fl45.h, defines the following constant name:

#define FL45_ATTR_CACHEĀ  IVI_ATTR_CACHE

For each instrument class attribute, the specific driver include file uses the same constant name that appears in the instrument class include file, except that the specific instrument prefix replaces the class prefix. For example, the DMM class include file, ividmm.h, defines IVIDMM_ATTR_RANGE, and fl45.h defines the following constant name:

#define FL45_ATTR_RANGEĀ  IVIDMM_ATTR_RANGE

For each specific instrument attribute, the specific driver include file defines a constant name and assigns a value that is an offset from IVI_SPECIFIC_PUBLIC_ATTR_BASE. For example, fl45.h defines the following constant name:

#define FL45_ATTR_HOLD_THRESHOLD \ (IVI_SPECIFIC_PUBLIC_ATTR_BASE + 3L)

For each attribute that is private to an instrument driver, the instrument driver source file defines a constant name and assigns a value that is an offset from IVI_SPECIFIC_PRIVATE_ATTR_BASE. For example, hp34401a.c defines the following constant name:

#define HP34401A_ATTR_TRIGGER_TYPE \ (IVI_SPECIFIC_PRIVATE_ATTR_BASE + 1L)

flags IviAttrFlags

Specify the new values of the flags for the attribute. You express the flags as bits. You cannot modify the value of the IVI_VAL_MULTI_CHANNEL flag.

This function always sets all of the flags. If you want to change one flag, use Ivi_GetAttributeFlags to obtain the current values of all of the flags, modify the bit of the flag you want to change, and then call Ivi_SetAttributeFlags.

The code in the following example changes the IVI_VAL_NEVER_CACHE flag from 1 to 0.

IviAttrFlags oldFlags, newFlags;

Ivi_GetAttributeFlags (vi, attributeID, &oldFlags);newFlags = oldFlags & ~IVI_VAL_NEVER_CACHE;
Ivi_SetAttributeFlags (vi, attributeID, newFlags);

Valid Values:

BitValueFlag
0
0x0001IVI_VAL_NOT_SUPPORTED
10x0002IVI_VAL_NOT_READABLE
20x0004IVI_VAL_NOT_WRITABLE
30x0008IVI_VAL_NOT_USER_READABLE
40x0010IVI_VAL_NOT_USER_WRITABLE
50x0020IVI_VAL_NEVER_CACHE
60x0040IVI_VAL_ALWAYS_CACHE
100x0400IVI_VAL_MULTI_CHANNEL
110x0800IVI_VAL_COERCEABLE_ONLY_BY_INSTR
120x1000IVI_VAL_WAIT_FOR_OPC_BEFORE_READS
130x2000IVI_VAL_WAIT_FOR_OPC_AFTER_WRITES
140x4000IVI_VAL_USE_CALLBACKS_FOR_SIMULATION
150x8000IVI_VAL_DONT_CHECK_STATUS

IVI_VAL_HIDDEN is 0x0018, the combination of IVI_VAL_NOT_USER_READABLE and IVI_VAL_NOT_USER_WRITABLE.

See the control help for the Flags parameter to the Ivi_AddAttribute functions for detailed information on each flag.

Return Value

Contains the status code that the function call returns. IVI engine functions can return error and warning values from several sets of status codes. Some status codes are unique to the IVI engine. Other status codes are the same codes that VISA Library functions return. Still others are error or warning values that functions in specific instrument drivers return. Each set of status codes has its own numeric range.

Regardless of the source of the status code, 0 always indicates success, a positive value indicates a warning, and a negative value indicates an error.

Related Topic

IVI Status Codes