/*****************************************************************************
* � 1998-2003, National Instruments, Corporation. All Rights Reserved. *
*****************************************************************************/
/*****************************************************************************
* TKDS30XX 2(4)-CH Digital Phosphor Oscilloscope Instrument Driver
* LabWindows/CVI 5.0 Instrument Driver
* Original Release: 2/11/99
* By: Martin Koutny, National Instruments
* Email: martin.koutny@vsb.cz
* PH. Fax
*
* Modification History:
*
* 2/11/98 - [mk] Instrument Driver Created.
* 5/10/1999 - [sz] Added Glitch trigger capability
* 6/17/1999 - [sz] Improved Help in the .fp file
* 9/01/1999 - [aae] Updated to meet new specifications for IVI scope
* 9/10/1999 - [sz] Added "VERBOSE ON" to override the instr default
* behavior;
* Fixed the range tables for MAX_INPUT_FREQUENCY
* attribute for the 301x and 303x models
* 9/17/1999 - [sz] Added conditional execution of Runt trigger setting
* in the DefaultInstrSetup to prevent errors when
* the option is not installed
* 2/14/2000 - [pp] Set USE_CALLBACKS_FOR_SIMULATION Flags on the
* following attributes: INSTRUMENT_FIRMWARE_REVISION,
* INSTRUMENT_MANUFACTURER, INSTRUMENT_MODEL
* 3/13/2000 - [pp] Added code to INSTRUMENT_MODEL ReadCallback to Get ATTR_MODEL
* and then convert the model to a string if simulating.
* 11/2/2000 - [vm] Fixed a bug when reading FFT waveform: Commented out lines 3101-3107
* since units are Hz and not seconds
* Changed MINOR version to 100
* 11/30/2000- [vm] Changed the attributes in ConfigureMathChannelFFT
* Changed MINOR version to 200
* 03/20/2001- [ZR] Driver changed to accord with IVI-3.2 specification
* It's include following changes:
* Added functions:
* tkds30xx_InvalidateAllAttributes
* tkds30xx_ResetWithDefaults
* tkds30xx_Disable
* tkds30xx_GetNextInterchangeWarning
* tkds30xx_ResetInterchangeCheck
* tkds30xx_ClearInterchangeWarning
* tkds30xx_GetError
* tkds30xx_ClearError
* Added attributes:
* TKDS30XX_ATTR_DRIVER_SETUP
* TKDS30XX_ATTR_INTERCHANGE_CHECK
* Renamed
* TKDS30XX_ATTR_QUERY_INSTR_STATUS to TKDS30XX_ATTR_QUERY_INSTRUMENT_STATUS
* TKDS30XX_ATTR_RESOURCE_DESCRIPTOR to TKDS30XX_ATTR_IO_RESOURCE_DESCRIPTOR
* TKDS30XX_ATTR_NUM_CHANNELS to TKDS30XX_ATTR_CHANNEL_COUNT
* Fixed
* Restriction to the channel.
* (Old version does not restrict channel based attributes)
* Changed:
* tktds30xx_InitWithOptions changed type of optionsString
* parameter to ViConstString
* 07/16/2001- [DS] Added support for RS-232 (Serial) interface.
* 04/30/2002- [BB] Added support for tds30xxB and ethernet.
* 05/15/2002- [BB] Added support for FV:v3.15 and greater
* 07/24/2002- [BB] Fixed CAR 2MK8810M repaired simOffset error
* 08/04/2002- [BB] Removed Immediate Trigger
* 05/28/2003 - [AL] Set attribute IVI_ATTR_IO_RESOURCE_DESCRIPTOR
* in initialize time.
* 05/29/2003 - [VJ] Made a slight modification in the code for initialX;
* fixed tkds30xxAttrChannelImpedance_ReadCallback;
* 11/18/2003 - [VJ] Made modifications in the ConfigureRefLevels function. Added back the
* ConfigureMidRef function.
*
*****************************************************************************/
#include <string.h>
#include <stdio.h>
#include <formatio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <utility.h>
#include "tkds30xx.h"
/*****************************************************************************
*--------------------- Hidden Attribute Declarations -----------------------*
*****************************************************************************/
#define TKDS30XX_ATTR_OPC_TIMEOUT (IVI_SPECIFIC_PRIVATE_ATTR_BASE + 1L) /* ViInt32 */
#define TKDS30XX_ATTR_INPUT_DATA_SOURCE (IVI_SPECIFIC_PRIVATE_ATTR_BASE + 2L) /* ViString */
#define TKDS30XX_ATTR_MAIN_TRIGGER_TYPE (IVI_SPECIFIC_PRIVATE_ATTR_BASE + 4L) /* ViInt32 */
#define TKDS30XX_ATTR_PULSE_TRIGGER_CLASS (IVI_SPECIFIC_PRIVATE_ATTR_BASE + 5L) /* ViInt32 */
#define TKDS30XX_ATTR_LOGIC_TRIGGER_CLASS (IVI_SPECIFIC_PRIVATE_ATTR_BASE + 6L) /* ViInt32 */
#define TKDS30XX_ATTR_MEAS_VALUE (IVI_SPECIFIC_PRIVATE_ATTR_BASE + 7L) /* ViReal64 */
#define TKDS30XX_ATTR_PROBE_SENSE (IVI_SPECIFIC_PRIVATE_ATTR_BASE + 8L) /* ViBoolean */
#define TKDS30XX_ATTR_TOTAL_POINTS (IVI_SPECIFIC_PRIVATE_ATTR_BASE + 11L) /* ViInt32 */
/*****************************************************************************
*---------------------------- Useful Macros --------------------------------*
*****************************************************************************/
/*- I/O buffer size -----------------------------------------------------*/
#define BUFFER_SIZE 512L
#define FETCH_BUFFER_SIZE 1000L
#define TKDS30XX_IO_SESSION_TYPE IVI_VAL_VISA_SESSION_TYPE
/*- 488.2 Event Status Register (ESR) Bits ------------------------------*/
/*- 488.2 Event Status Register (ESR) Bits ------------------------------*/
#define IEEE_488_2_QUERY_ERROR_BIT 0x04
#define IEEE_488_2_DEVICE_DEPENDENT_ERROR_BIT 0x08
#define IEEE_488_2_EXECUTION_ERROR_BIT 0x10
#define IEEE_488_2_COMMAND_ERROR_BIT 0x20
#define IEEE_488_2_ERROR_BITS (IEEE_488_2_QUERY_ERROR_BIT | \
IEEE_488_2_DEVICE_DEPENDENT_ERROR_BIT | \
IEEE_488_2_EXECUTION_ERROR_BIT | \
IEEE_488_2_COMMAND_ERROR_BIT)
/*- List of channels passed to the Ivi_BuildChannelTable function -------*/
#define CHANNEL_LIST_2 "CH1,CH2,MATH,REF1,REF2,REF3,REF4"
#define CHANNEL_LIST_4 "CH1,CH2,CH3,CH4,MATH,REF1,REF2,REF3,REF4"
#define INPUT_CHANNEL_LIST_2 "CH1,CH2"
#define INPUT_CHANNEL_LIST_4 "CH1,CH2,CH3,CH4"
/*- Channel Types -------------------------------------------------------*/
#define TKDS30XX_VAL_INPUT_CHANNEL 0
#define TKDS30XX_VAL_REF_CHANNEL 1
#define TKDS30XX_VAL_MATH_CHANNEL 2
/*- Hidden trigger source - only for the internal usage -----------------*/
#define TKDS30XX_VAL_AC_LINE "VAL_AC_LINE"
static IviRangeTablePtr attrMeasFunctionRangeTable = VI_NULL;
static IviRangeTableEntry attrAcLineTriggerSlopeRangeTableEntries[] =
{
{TKDS30XX_VAL_AC_LINE_POSITIVE, 0, 0, "", 0},
{TKDS30XX_VAL_AC_LINE_NEGATIVE, 0, 0, "", 0},
{IVI_RANGE_TABLE_LAST_ENTRY}
};
static IviRangeTable attrAcLineTriggerSlopeRangeTable =
{
IVI_VAL_DIS