/******************************************************************************
 *                                                                         
 *               Copyright 2004-2006 Agilent Technologies
 *               All rights reserved.
 *
 *****************************************************************************/
 
#include "stdafx.h"
#include "CoAgilent34980A.h"
/// <summary>
///	The actual range that the DMM is currently using, even if it is auto-ranging.
/// </summary>
/// <remarks>
///	
/// </remarks>
HRESULT Agilent34980A::IIviDmmAdvanced_get_ActualRange(double* Val)
{
	HRESULT hr = S_OK;

	//[:SENSe]:<function_type>:RANGe?
	CString sFunc;
	hr = _GetInstrFunction( sFunc );
	if( FAILED(hr) ) return hr;
	sFunc += ":RANG?";
	hr = InstrQuery( sFunc, Val );
	return hr;
}

/// <summary>
///	The measurement aperture time (also known as integration time) based on the
/// present configuration.  Units are specified by the property ApertureTimeUnits.
/// </summary>
/// <remarks>
///	
/// </remarks>
HRESULT Agilent34980A::IIviDmmAdvanced_get_ApertureTime(double* Val)
{
	HRESULT hr = S_OK;

	//[:SENSe]:<function_type>:APERture?
	CString sFunc;
	hr = _GetInstrFunction( sFunc );
	if( FAILED(hr) ) return hr;
	sFunc += ":APER?";
	hr = InstrQuery( sFunc, Val );

	return hr;
}

/// <summary>
///	The units for the ApertureTime property.
/// </summary>
/// <remarks>
///	
/// </remarks>
HRESULT Agilent34980A::IIviDmmAdvanced_get_ApertureTimeUnits(IviDmmApertureTimeUnitsEnum* Val)
{
	HRESULT hr = S_OK;
	//No SCPI -- units are always seconds.
	*Val = IviDmmApertureSeconds;
	return hr;
}

/// <summary>
///	The auto-zero mode.  When the auto-zero mode is enabled, the DMM internally
/// disconnects the input signal and takes a Zero Reading. The DMM then subtracts
/// the Zero Reading from the measurement.
/// </summary>
/// <remarks>
///	
/// </remarks>
HRESULT Agilent34980A::IIviDmmAdvanced_get_AutoZero(IviDmmAutoZeroEnum* Val)
{
	HRESULT hr = S_OK;

	//[SENS:]<function_type>:ZERO:AUTO
	CString sFunc;
	hr = _GetInstrFunction( sFunc );
	if( FAILED(hr) ) return hr;
	sFunc += ":ZERO:AUTO?";
	hr = InstrQuery( sFunc, (long*)Val ); // instr returns 0 or 1

	return hr;
}

/// <summary>
///	The auto-zero mode.  When the auto-zero mode is enabled, the DMM internally
/// disconnects the input signal and takes a Zero Reading. The DMM then subtracts
/// the Zero Reading from the measurement.
/// </summary>
/// <remarks>
///	
/// </remarks>
HRESULT Agilent34980A::IIviDmmAdvanced_put_AutoZero(IviDmmAutoZeroEnum Val)
{
	HRESULT hr = S_OK;

	CString sFunc;
	hr = _GetInstrFunction( sFunc );
	if( FAILED(hr) ) return hr;
	(sFunc += ":ZERO:AUTO ") += EnumToString<IviDmmAutoZeroEnum>(Val);
	hr = InstrPrintf( sFunc );

	return hr;
}

/// <summary>
///	The power line frequency in Hertz.
/// </summary>
/// <remarks>
///	
/// </remarks>
HRESULT Agilent34980A::IIviDmmAdvanced_get_PowerlineFrequency(double* Val)
{
	HRESULT hr = S_OK;
	if( !Val) return E_POINTER;

	hr = InstrQueryCommand(Val);

	return hr;
}

/// <summary>
///	The power line frequency in Hertz.
/// </summary>
/// <remarks>
///	
/// </remarks>
HRESULT Agilent34980A::IIviDmmAdvanced_put_PowerlineFrequency(double Val)
{
	HRESULT hr = S_OK;

	hr = InstrPrintCommand();

	return hr;
}


