📄 gf.c
字号:
/*****************************************************************************
* Copyright 1998 National Instruments Corporation. All Rights Reserved. *
*****************************************************************************/
/*=Sung:===============================================================*
INSTRUCTIONS TO THE INSTRUMENT DRIVER DEVELOPER
READ THESE INSTRUCTIONS FIRST!
*=======================================================================*
Congratulations! You have successfully created all the files needed
for your instrument driver - *.c, *.h, *.fp, and *.sub. These
files give you a framework to build your complete instrument driver
with the following features:
- IVI compliance
- VXIplug&play compliance
- Attribute model
- State caching
- Simulation
- Multithread safety
Before you can begin using this driver, you must perform the following
manual changes.
- If you are developing a driver for a register-based device,
remove the function panels for the GF_WriteInstrData
and GF_ReadInstrData functions. These functions
are for use with message-based instruments.
- Device-specific changes are marked with the comment "Sung".
Search for all occurrences of the word "Sung" and make the changes
for your specific instrument. Delete the comments after you complete
the changes.
- The IVI wizard might not properly align the code it generates.
Review the resulting *.h and *.c files and reformat them as necessary.
- Read the help text for the functions and attributes to understand
the functionality you must implement in this driver. The easiest
way to view the help text is by using the GF.fp
function panels in "operate" mode. You can view the help text for
the attributes in any of the GF_GetAttribute
function panels.
- Many of the functions contain extensive code examples within
comment blocks. These code examples contain embedded comments.
The only way to embed comments is by using double slashes (//).
Some C compilers do not accept double slashes. If you are developing
this driver for general use, convert the double slashes to
traditional C comment markers.
- Edit the Function Panel help. Pay close attention to the default
values and valid ranges for each parameter. If you change the
default value for a control, you also need to change the default
value in the help for the control. Also, search for the comment
"Sung" in the help text, and make the appropriate changes.
- Edit the help for all attributes with the attribute editor. Pay close
attention to the valid range information. The Set/Get/Check attribute
function panels automatically display valid range information for
attributes that have range tables of type IVI_VAL_DISCRETE or
IVI_VAL_COERCED. You must edit/create the valid range information
in the description of an attribute if any of the following conditions
is true:
* The attribute does not have a range table.
* The attribute has a range table of type IVI_VAL_RANGED.
* The attribute uses multiple static range tables or a dynamic
range table.
Also, look for "Sung" comments in the help text, and make the
appropriate changes.
- Verify that all values that the header file defines are valid for
your instrument. Delete the values that your instrument does not
use.
- Delete these instructions and save the modified program.
*=======================================================================*
This driver has functions and attributes that are common to most
function generators. The functions and attributes have example code
with instructions on how you can modify the code for your specific
function generator. This section provides additional modification
instructions regarding special situations you might encounter or the
relationships between elements of this driver. The instructions in
the example code sections reference these comments when applicable.
- NOTE REGARDING CONFIGURATION STATE
The example code in this driver makes the following assumptions:
- The function generator can be configured only when in a Configuration
state.
- The driver must check to be sure it is in the Configuration state
before attempting to make changes to the instrument's settings.
- The instrument is not configurable while it is generating a signal.
The GF_InitiateGeneration function moves the instrument
into a non-configurable state, and the GF_AbortGeneration
function moves it to the Configuration state.
- The GF_VerifyConfigurable utility function
encapsulates the code that checks if the instrument is currently
configurable.
If you cannot query your instrument directly to determine configurability,
do the following:
- Remove the GFAttrConfigurable_ReadCallback and
GFAttrConfigurable_WriteCallback functions.
- At every point in the driver that changes the configurability of the
instrument, call the Ivi_SetAttributeViBoolean function to change the
value of the hidden attribute GF_ATTR_CONFIGURABLE
to reflect the current state of the instrument.
If some attributes can be set regardless of your instrument's Configuration
state, do the following:
- Remove the call to the GF_VerifyConfigurable utility function
from the attribute's callback functions.
If you can configure your instrument while it is not in the Configuration
state, do the following:
- Delete the GF_ATTR_CONFIGURABLE attribute and the
GFAttrConfigurable_ReadCallback and GFAttrConfigurable_WriteCallback
functions. Remove the Ivi_AddAttribute function that adds the attribute to the
driver. Delete the GF_VerifyConfigurable utility function's
prototype and definition, and remove any reference to it in the source code.
- NOTE REGARDING GF_ATTR_OUTPUT_MODE
The example code in this driver makes the following assumptions:
- Some of the function generator's attributes can be configured only
when the instrument is set to produce a certain kind of output.
- The output modes available are Standard Function and Arbitrary Waveform.
- The driver must check that it is in the correct output mode before it
attempts to read or write some attributes.
- The GF_VerifyOutputMode utility function verifies that
the instrument is set to the correct output mode.
You should make the following changes throughout your driver:
- Remove any calls to GF_VerifyOutputMode that you
do not need
- Add any calls to GF_VerifyOutputMode that your driver
requires and that are not already present in the example code.
- Change any calls to GF_VerifyOutputMode that check for an output
mode other than the one your instrument requires.
If your instrument supports only one output mode, do the following:
- Delete the GFAttrOutputMode_WriteCallback and
GFAttrOutputMode_ReadCallback functions, and modify the
attrOutputModeRangeTable range table so that the only valid value is
the output mode your instrument supports.
- Pass the value of the output mode your instrument supports as
the default value parameter of the Ivi_AddAttribute function that
adds the GF_ATTR_OUTPUT_MODE attribute to the
driver.
- Remove all calls to the GF_VerifyOutputMode utility
function and remove any other references in the driver that check the
GF_ATTR_OUTPUT_MODE attribute.
If an attribute can be read or written regardless of the output mode,
do the following:
- Remove calls to the GF_VerifyOutputMode utility function
from the attribute's Callback functions.
If an attribute can be set under more than one output mode, but not all
of them, do the following:
- Remove calls to the GF_VerifyOutputMode utility function
from the attribute's Callback functions.
- Use the Ivi_GetAttributeViInt32 function to read the current output mode
from the GF_ATTR_OUTPUT_MODE attribute, and an if-else
structure to determine if the instrument is in one of the correct output
modes. If the output mode is not correct, return the
GF_ERROR_INVALID_MODE error.
If your instrument supports different output modes than those used
in the examples, do the following:
- Modify the attrOutputModeRangeTable range table so that it contains
valid values for all output modes your instrument supports.
*=======================================================================*
The following sections list groups of attributes and functions that are
optional. This driver has these functions and attributes, but you do not
have to implement them in the driver for your specific instrument.
If you choose to implement one of the attributes or functions listed below,
you must implement all of the attributes and functions that belong to
the same group, unless otherwise noted.
NOTE: You must implement either the Standard Waveform Group or the
Arbitrary Waveform Generation Group. You may implement both
of them.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -