/******************************************************************************
 *                                                                         
 *               Copyright 2004-2006 Agilent Technologies
 *               All rights reserved.
 *
 *****************************************************************************/
 
#include "stdafx.h"
#include "CoAgilent34980A.h"


/// <summary>
/// This method causes an automatic calibration of the specified 34951 DAC modules.
/// </summary>
/// <remarks>
/// All channels on the specified DAC modules will be calibrated. The optional internal
/// DMM must be present or the calibration will fail.  If there is no internal DMM
/// then the 34951 DACs must be manually calibrated (see the BeginDacVoltCal method).
///  If the instrument has been unsecured for calibration with the SetSecureState
/// method, the calibration constants will be saved in non-volatile memory after
/// the calibration finishes, otherwise, a local copy will be kept and used until
/// either the next calibration or a power cycle occurs.  Setting the All parameter
/// to TRUE will calibrate all 34951 modules in the mainframe otherwise, the specified
/// module will be calibrated.
/// </remarks>
/// <returns>
///	
/// </returns>
/// <param name="SlotNumber">
///	The number of slot where the DAC module is located.
/// </param>
/// <param name="All">
///	If TRUE, all installed 34951A modules will be calibrated.
/// </param>
HRESULT Agilent34980A::IAgilent34980ADAC_AutoCalibrate(short SlotNumber, VARIANT_BOOL All)
{
	HRESULT hr = S_OK;

	if( VARIANT_TRUE==All )
		hr = InstrPrintf( ":CALibration:MODule? ALL" );
	else // slot number already inserted
		hr = InstrPrintCommand();

	return hr;
}

/// <summary>
/// Aborts a calibration sequence on the specified DAC channel.
/// </summary>
/// <remarks>
/// 
/// </remarks>
/// <returns>
///	
/// </returns>
HRESULT Agilent34980A::IAgilent34980ADAC_Abort()
{
	HRESULT hr = S_OK;

	hr = InstrPrintCommand();

	return hr;
}

/// <summary>
/// Initiates a voltage calibration (adjustment) sequence for the specified DAC
/// channel on a 34952A or 34951A DAC channel.
/// </summary>
/// <remarks>
/// You must perform all of the adjustments on one DAC channel before adjusting
/// the other DAC channel.  \r\n
/// For a more detailed discussion of the calibration procedures, see the Agilent
/// 34980A Service Guide.
/// </remarks>
/// <returns>
///	
/// </returns>
/// <param name="ChannelList">
///	One channel in the form sccc. Select from s006 or s007 (valid only on DAC channels).
/// </param>
/// <param name="SetupNumber">
///	Calibration setup number. Since the 34952A requires only one calibration setup,
/// always specify 1 for this parameter.
/// </param>
HRESULT Agilent34980A::IAgilent34980ADAC_BeginVoltageCal(BSTR ChannelList, short SetupNumber)
{
	HRESULT hr = S_OK;

	hr = InstrPrintCommand();

	return hr;
}

/// <summary>
///	Gets the calibration count on the specified location.
/// </summary>
/// <remarks>
///	
/// </remarks>
/// <param name="SlotNumber">
///	Identifies the slot where the DAC module is located.
/// </param>
HRESULT Agilent34980A::IAgilent34980ADAC_get_Count(short SlotNumber, long* Val)
{
	HRESULT hr = S_OK;

	hr = InstrQueryCommand(Val);

	return hr;
}


/// <summary>
/// This command follows the BeginDacVoltCal method in the voltage calibration sequence
/// for the specified DAC channel on the 34952A Multifunction Module.
/// </summary>
/// <remarks>
/// This command sends the measured DAC output value back to the module, which then
/// computes the corresponding calibration constant. \r\n
/// For a more detailed discussion of the calibration procedures, see the Agilent
/// 34980A Service Guide.
/// </remarks>
/// <returns>
///	
/// </returns>
/// <param name="PointData">
///	The DAC output value that was measured on the calibrating channel.
/// </param>
HRESULT Agilent34980A::IAgilent34980ADAC_Point(double PointData)
{
	HRESULT hr = S_OK;

	hr = InstrPrintCommand();

	return hr;
}

/// <summary>
///	Sets or gets the specified calibration string.
/// </summary>
/// <remarks>
///	
/// </remarks>
/// <param name="SlotNumber">
///	Identifies the slot where the DAC module is located.
/// </param>
HRESULT Agilent34980A::IAgilent34980ADAC_get_String(short SlotNumber, BSTR* Val)
{
	HRESULT hr = S_OK;

	hr = InstrQueryCommand(Val);

	return hr;
}

/// <summary>
///	Sets or gets the specified calibration string.
/// </summary>
/// <remarks>
///	
/// </remarks>
/// <param name="SlotNumber">
///	Identifies the slot where the DAC module is located.
/// </param>
HRESULT Agilent34980A::IAgilent34980ADAC_put_String(short SlotNumber, BSTR Val)
{
	HRESULT hr = S_OK;

	hr = InstrPrintCommand();

	return hr;
}
