AddRepeatedAttributeViReal64

IVI Library

Ivi_AddRepeatedAttributeViReal64

Usage

ViStatus Ivi_AddRepeatedAttributeViReal64(ViSession vi, ViChar repeatedCapabilityName[ ], ViAttr newAttributeID, ViChar attributeName[ ], ViReal64 defaultValue, IviAttrFlags flags, ReadAttrViReal64_CallbackPtr readCallback, WriteAttrViReal64_CallbackPtr writeCallback, IviRangeTablePtr rangeTable, ViInt32 comparePrecision);

Purpose

This function creates and configures a new ViReal64 attribute for the instrument session you specify. The value of the Repeated Capability parameter determines the repeated capability to which the attribute applies.

Parameters

Name Type Description
vi ViSession

The ViSession handle that you obtain from Ivi_SpecificDriverNew. The handle identifies a particular IVI session.

repeatedCapabilityName ViChar[ ]

Pass a string containing the name of the repeated capability on which to operate. For instance, if you are working with the table of channel names, pass in the string "Channel".

newAttributeID ViAttr

Pass the ID you want the new attribute to have. Every attribute must have a distinct ID. You must define a constant name for the attribute in the include file for the instrument driver or in your source code. The constant name must begin with PREFIX_ATTR_, where PREFIX is the specific instrument prefix.

The include file for your specific instrument driver must define 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, use the same constant name that appears in ivi.h, except replace the IVI prefix with the specific instrument 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, use the same constant name that appears in the instrument class include file, except replace the class prefix with the specific instrument 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 that the end-user can access, define a constant name in the instrument driver include file, and assign 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, define a constant name in the driver source file, and assign 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)

attributeName ViChar[ ]

The name of the attribute. Specify the name to be the same as the defined constant name for the attribute ID.

For example, if the defined constant for this attribute is PREFIX_ATTR_RANGE, then pass "PREFIX_ATTR_RANGE".

defaultValue ViReal64

Specify the default initial value for the attribute.

The IVI engine uses the default value in the following cases:

  • IVI_ATTR_SIMULATION is enabled, you query the attribute value before you set it, and the IVI_VAL_USE_CALLBACKS_FOR_SIMULATION attribute is not set.
  • The attribute does not have a read callback, and you query the attribute before you set it.
flags IviAttrFlags

Specify the flags you want to set for this attribute. To set multiple flags, bitwise OR them together. For example, if you want the attribute to be hidden and never cached, then pass IVI_VAL_NOT_USER_WRITABLE | IVI_VAL_NEVER_CACHE.

You can query and modify the flags for an attribute using Ivi_GetAttributeFlags and Ivi_SetAttributeFlags.

Valid Values:

Bit Value Flag
0 0x0001 IVI_VAL_NOT_SUPPORTED
1 0x0002 IVI_VAL_NOT_READABLE
2 0x0004 IVI_VAL_NOT_WRITABLE
3 0x0008 IVI_VAL_NOT_USER_READABLE
4 0x0010 IVI_VAL_NOT_USER_WRITABLE
5 0x0020 IVI_VAL_NEVER_CACHE
6 0x0040 IVI_VAL_ALWAYS_CACHE
10 0x0400 IVI_VAL_MULTI_CHANNEL
11 0x0800 IVI_VAL_COERCEABLE_ONLY_BY_INSTR
12 0x1000 IVI_VAL_WAIT_FOR_OPC_BEFORE_READS
13 0x2000 IVI_VAL_WAIT_FOR_OPC_AFTER_WRITES
14 0x4000 IVI_VAL_USE_CALLBACKS_FOR_SIMULATION
15 0x8000 IVI_VAL_DONT_CHECK_STATUS

IVI_VAL_HIDDEN is 0x0018, the combination of IVI_VAL_NOT_USER_READABLE and IVI_VAL_NOT_USER_WRITABLE. Use the IVI_VAL_HIDDEN macro for attributes you do not want the end-user to access.

IVI_VAL_NOT_SUPPORTED–Indicates that the class driver creates the attribute but the specific driver does not implement it.

IVI_VAL_NOT_READABLE—Indicates that neither end-users nor instrument drivers can query the value of the attribute. Only the IVI engine can query the value of the attribute.

IVI_VAL_NOT_WRITABLE—Indicates that neither end-users nor instrument drivers can modify the value of the attribute. Only the IVI engine can modify the value of the attribute.

IVI_VAL_NOT_USER_READABLE—Indicates that end-users cannot query the value of the attribute. Only the IVI engine and instrument drivers can query the value of the attribute.

IVI_VAL_NOT_USER_WRITABLE—Indicates that end-users cannot modify the value of the attribute. Only the IVI engine and instrument drivers can modify the value of the attribute.

IVI_VAL_NEVER_CACHE—Directs the IVI engine never to use the cache value of the attribute, regardless of the state of the IVI_ATTR_CACHE attribute. The IVI engine always calls the read and write callbacks for the attribute, if present.

IVI_VAL_ALWAYS_CACHE—Directs the IVI engine to use the cache value of the attribute, if it is valid, regardless of the state of the IVI_ATTR_CACHE attribute.

IVI_VAL_MULTI_CHANNEL—Indicates that the attribute has a separate value for each channel. You cannot modify this flag using Ivi_SetAttributeFlags.

IVI_VAL_COERCEABLE_ONLY_BY_INSTR—Indicates that the instrument coerces values in a way that the instrument driver cannot anticipate in software. Do not use this flag unless the instrument's coercion algorithm is undocumented or too complicated to encapsulate in a range table or a coerce callback. When you query the value of an attribute for which this flag is set, the IVI engine ignores the cache value unless it obtained the cache value from the instrument. Thus, after you call an Ivi_SetAttribute function, the IVI engine invokes the read callback the next time you call an Ivi_GetAttribute function. When you set this flag, the IVI engine makes two assumptions that allow it to retain most of the benefits of state-caching:

  1. The instrument always coerces the same value in the same way.
  2. If you send the instrument a value that you obtained from the instrument, the instrument does not coerce the value. Based on these two assumptions, the IVI engine does not invoke the write callback for the attribute when you call an Ivi_SetAttribute function with the same value that you previously sent to, or received from, the instrument. If one or both of these assumption are not valid, use the IVI_VAL_NEVER_CACHE flag instead.

IVI_VAL_WAIT_FOR_OPC_BEFORE_READS—Directs the IVI engine to call the operation complete callback for the session before calling the read callback for the attribute.

IVI_VAL_WAIT_FOR_OPC_AFTER_WRITES—Directs the IVI engine to call the operation complete callback for the session after calling the write callback for the attribute.

IVI_VAL_USE_CALLBACKS_FOR_SIMULATION—Directs the IVI engine to invoke the read and write callbacks for the attribute even when in simulation mode.

IVI_VAL_DONT_CHECK_STATUS—By default, when an end-user calls one of the PREFIX_GetAttribute or PREFIX_SetAttribute functions in an instrument driver and the IVI_ATTR_QUERY_INSTRUMENT_STATUS attribute is enabled, the IVI engine calls the check status callback for the session after calling the read or write callback for the attribute. This flag directs the IVI engine never to call the check status callback for the attribute.

readCallback ReadAttrViReal64_CallbackPtr

Specify the read callback function you want the IVI engine to invoke when you request the current value of the attribute.

You must define the read callback function in the source code for the specific instrument driver. The function must have the following prototype:

ViStatus _VI_FUNC Callback (ViSession vi, ViSession io, ViConstString repCapName, ViAttr attributeId, ViReal64 *value);

Upon entry to the callback, *value contains the cache value. Upon exit from the callback, *value must contain the actual current value.

Note  If you want to use the Edit IVI Specific Driver Attributes dialog box to develop your instrument driver source code, retain the parameter names as shown in the prototype for the callback.

If you do not want to use a read callback function, pass VI_NULL.

You can change the callback at a later time by calling Ivi_SetAttrReadCallbackViReal64.

writeCallback WriteAttrViReal64_CallbackPtr

Specify the write callback function you want the IVI engine to invoke when you set the attribute to a new value.

You must define the write callback function in the source code for the specific instrument driver. The function must have the following prototype:

ViStatus _VI_FUNC Callback(ViSession vi, ViSession io, ViConstString repCapName, ViAttr attributeId, ViReal64 value);

Note  If you want to use the Edit IVI Specific Driver Attributes dialog box to develop your instrument driver source code, retain the parameter names as shown in the prototype for the callback.

If you do not want to use a write callback function, pass VI_NULL.

You can change the callback at a later time by calling Ivi_SetAttrWriteCallbackViReal64.

rangeTable IviRangeTablePtr

Specify the range table that the IVI engine can use to validate and coerce values for this attribute. Refer to the typedefs for IviRangeTable and IviRangeTableEntry in ivi.h. When you specify a non-NULL range table, the IVI engine automatically installs its default check callback. If the type of the range table is IVI_VAL_COERCED, the IVI engine automatically installs its default coerce callback.

If you do not want to use a range table, pass VI_NULL.

If the valid range for this attribute varies depending on the settings of other attributes, you might want to use several range tables. If so, pass VI_NULL for this parameter, and specify a range table callback function using the Ivi_SetAttrRangeTableCallback function.

comparePrecision ViInt32

Specify the degree of decimal precision the default IVI compare callback function uses for this ViReal64 attribute. Unless you call Ivi_SetAttrCompareCallbackViReal64 to install your own compare callback function, the IVI engine invokes the default compare callback when comparing cache values it obtains from the instrument against new values you set the attribute to. If the values are equal within the degree of precision you specify, the IVI engine does not call the write callback for the attribute.

The IVI engine uses this method instead of strict equality because of differences between computer and instrument floating point representations.

The value for this parameter is in terms of decimal digits of precision. The higher the value, the closer the two values must be for the default compare callback to consider them equal.

Valid Range: 0, or 1 to 14

If you pass 0, the function sets the precision to the IVI default for this value, which is 14.

You can modify this value at a later type by calling the Ivi_SetAttrComparePrecision function.

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