pi40iv_InitWithOptions

ViStatus pi40iv_InitWithOptions (ViRsrc resourceName, ViBoolean IDQuery, ViBoolean resetDevice, ViString optionString, ViPSession instrumentHandle);

Purpose

This function performs the following initialization actions:
- Creates a new IVI instrument driver and optionally sets the initial state of the following session attributes:
PI40IV_ATTR_RANGE_CHECK         
PI40IV_ATTR_QUERY_INSTR_STATUS  
PI40IV_ATTR_CACHE               
PI40IV_ATTR_SIMULATE            
PI40IV_ATTR_RECORD_COERCIONS    
- Opens a session to the specified device using the interface and address you specify for the Resource Name parameter.
- If the ID Query parameter is set to VI_TRUE, this function queries the instrument ID and checks that it is valid for this instrument driver.
- If the Reset parameter is set to VI_TRUE, this function resets the instrument to a known state.
- Sends initialization commands to set the instrument to the state necessary for the operation of the instrument driver.
- Returns a ViSession handle that you use to identify the instrument in all subsequent instrument driver function calls.
Note:  This function creates a new session each time you invoke it. Although you can open more than one IVI session for the same resource, it is best not to do so.  You can use the same session in multiple program threads.  You can use the pi40iv_LockSession and pi40iv_UnlockSession functions to protect sections of code that require exclusive access to the resource.

Parameters

Input
Name Type Description
resourceName ViRsrc

Pass the resource name of the device to initialize.
You can also pass the name of a virtual instrument or logical name that you configure with the IVI Configuration utility.  The virtual instrument identifies a specific device and specifies the initial settings for the session.  A logical Name identifies a particular virtual instrument.
Refer to the following table below for the exact grammar to use for this parameter.  Optional fields are shown in square brackets ([]).
Syntax
------------------------------------------------------
GPIB[board]::<primary address>[::secondary address]::INSTR
VXI[board]::<logical address>::INSTR
GPIB-VXI[board]::<logical address>::INSTR
ASRL<port>::INSTR
<LogicalName>
[VInstr->]<VirtualInstrument>
If you do not specify a value for an optional field, the following values are used:
Optional Field - Value
------------------------------------------------------
board - 0
secondary address - none (31)
The following table contains example valid values for this parameter.
"Valid Value" - Description
------------------------------------------------------
"GPIB::22::INSTR" - GPIB board 0, primary address 22 no
secondary address
"GPIB::22::5::INSTR" - GPIB board 0, primary address 22
secondary address 5
"GPIB1::22::5::INSTR" - GPIB board 1, primary address 22
secondary address 5
"VXI::64::INSTR" - VXI board 0, logical address 64
"VXI1::64::INSTR" - VXI board 1, logical address 64
"GPIB-VXI::64::INSTR" - GPIB-VXI board 0, logical address 64
"GPIB-VXI1::64::INSTR" - GPIB-VXI board 1, logical address 64
"ASRL2::INSTR" - COM port 2
"SampleInstr" - Logical name "SampleInstr"
"VInstr->xyz432" - Virtual Instrument "xyz432"
"xyz432" - Logical Name or Virtual Instrument "xyz432"
/*=CHANGE:===================================================*
Modify the following default value so that it reflects the default address for your instrument.  You must make the corresponding change to the Default Value entry for the control.
*================================================END=CHANGE=*/
Default Value:  "VXI::14::INSTR"
Note: You specify the resource name with the "VInstr->" if you have the logical name that is the same as the virtual instrument name and you want to explicitly use the virtual instrument name. Otherwise, the driver uses the logical name.

IDQuery ViBoolean

Specify whether you want the instrument driver to perform an ID Query.
Valid Range:
VI_TRUE  (1) - Perform ID Query (Default Value)
VI_FALSE (0) - Skip ID Query
When you set this parameter to VI_TRUE, the driver verifies that the instrument you initialize is a type that this driver supports.  
Circumstances can arise where it is undesirable to send an ID Query command string to the instrument.  When you set this parameter to VI_FALSE, the function initializes the instrument without performing an ID Query.

resetDevice ViBoolean

Specify whether you want the to reset the instrument during the initialization procedure.
Valid Range:
VI_TRUE  (1) - Reset Device (Default Value)
VI_FALSE (0) - Don't Reset

optionString ViString

You can use this control to set the initial value of certain attributes for the session.  The following table lists the attributes and the name you use in this parameter to identify the attribute.
Name              Attribute Defined Constant   --------------------------------------------
RangeCheck        PI40IV_ATTR_RANGE_CHECK
QueryInstrStatus  PI40IV_ATTR_QUERY_INSTR_STATUS
Cache             PI40IV_ATTR_CACHE
Simulate          PI40IV_ATTR_SIMULATE
RecordCoercions   PI40IV_ATTR_RECORD_COERCIONS
The format of this string is, "AttributeName=Value" where AttributeName is the name of the attribute and Value is the value to which the attribute will be set.  To set multiple attributes, separate their assignments with a comma.
If you pass NULL or an empty string for this parameter and a VISA resource descriptor for the Resource Name parameter, the session uses the default values for the attributes. The default values for the attributes are shown below:
Attribute Name     Default Value
----------------   -------------
RangeCheck         VI_TRUE
QueryInstrStatus   VI_TRUE
Cache              VI_TRUE
Simulate           VI_FALSE
RecordCoercions    VI_FALSE
If you pass NULL or an empty string for this parameter and a virtual instrument or logical name for the Resource Name parameter, the session uses the values that you configure for virtual instrument or logical name with the IVI Configuration utility.
You can override the values of the attributes by assigning a value explicitly in a string you pass for this parameter.  You do not have to specify all of the attributes and may leave any of them out.  If you do not specify one of the attributes, its default value or the value that you configure with the IVI Configuration utility will be used.
The following are the valid values for ViBoolean attributes:
True:     1, TRUE, or VI_TRUE
False:    0, False, or VI_FALSE
Default Value:
"Simulate=0,RangeCheck=1,QueryInstrStatus=1,Cache=1"

Output
Name Type Description
instrumentHandle ViSession (passed by reference)

Returns a ViSession handle that you use to identify the instrument in all subsequent instrument driver function calls.
Notes:
(1) 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.  
(2) 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 the same IVI session in multiple execution threads.  You can use functions pi40iv_LockSession and pi40iv_UnlockSession to protect sections of code that require exclusive access to the resource.

Return Value

Name Type Description
status ViStatus

Returns the status code of this operation.  The status code  either indicates success or describes an error or warning condition.  You examine the status code from each call to an instrument driver function to determine if an error occurred.
To obtain a text description of the status code, call the pi40iv_error_message function.  To obtain additional information about the error condition, call the pi40iv_GetErrorInfo function.  To clear the error information from the driver, call the pi40iv_ClearErrorInfo function.
The general meaning of the status code is as follows:
Value                  Meaning
-------------------------------
0                      Success
Positive Values        Warnings
Negative Values        Errors
This driver defines the following status codes:
Status    Description
-------------------------------------------------
WARNINGS:
/*=CHANGE:===================================================*
Insert Instrument-defined warning codes here.
*================================================END=CHANGE=*/
ERRORS:
/*=CHANGE:===================================================*
Insert Instrument-defined error codes here.
*================================================END=CHANGE=*/
This instrument driver also returns errors and warnings defined by other sources.  The following table defines the ranges of additional status codes that this driver can return.  The table lists the different include files that contain the defined constants for the particular status codes:
Numeric Range (in Hex)   Status Code Types
-------------------------------------------------
3FFA2000 to 3FFA3FFF     IviSwtch Warnings
3FFA0000 to 3FFA1FFF     IVI      Warnings
3FFF0000 to 3FFFFFFF     VISA     Warnings
3FFC0000 to 3FFCFFFF     VXIPnP   Driver Warnings
BFFA2000 to BFFA3FFF     IviSwtch Errors
BFFA0000 to BFFA1FFF     IVI      Errors
BFFF0000 to BFFFFFFF     VISA     Errors
BFFC0000 to BFFCFFFF     VXIPnP   Driver Errors

References

Pickering Interfaces PXI/LXI IVI Switch
Alphabetical Function Index
Hierarchical Function Index