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



/// <summary>
/// Resets all measurement parameters on the specified channels to their default
/// values. Then, configures the channels for temperature measurements but does
/// not initiate the scan.
/// </summary>
/// <remarks>
/// If you supply an empty ChannelList, this method applies to the internal DMM,
/// independent  of any channels or a scan list.
/// </remarks>
/// <returns>
///	
/// </returns>
/// <param name="ChannelList">
///	One or more channels in the form sccc
/// </param>
/// <param name="Resolution">
///	Select from Least (4.5 digits), DEFault (5.5 digits) and Best (6.5 digits).
/// </param>
/// <param name="Type">
///	Thermistor type {2252|5000|10000}.
/// </param>
HRESULT Agilent34980A::IAgilent34980AThermistor_Configure(BSTR ChannelList, Agilent34980AResolutionEnum Resolution, Agilent34980AThermistorEnum Type)
{
	HRESULT hr = S_OK;

	CorrectChannelList( ChannelList );

	hr = InstrPrintCommand();

	return hr;
}




/// <summary>
/// Resets all measurement parameters on the specified channels to their default
///  values. Then, configures the    channels for temperature measurements and immediately
/// sweeps through the specified  channels one time.
/// </summary>
/// <remarks>
/// The results are sent directly to the instrument's output buffer. If you supply
///  empty ChannelList, this    meethod applies to the internal DMM, independent
/// of any channels or a scan  list.
/// </remarks>
/// <returns>
///	
/// </returns>
/// <param name="ChannelList">
///	One or more channels in the form sccc
/// </param>
/// <param name="Type">
///	Thermistor type  {2252|5000|10000}.
/// </param>
/// <param name="Resolution">
///	Select from Least (4.5 digits), DEFault (5.5 digits) and Best (6.5 digits).
/// </param>
HRESULT Agilent34980A::IAgilent34980AThermistor_Measure(BSTR ChannelList, Agilent34980AThermistorEnum Type, Agilent34980AResolutionEnum Resolution, SAFEARRAY** val)
{
	HRESULT hr = S_OK;

	CorrectChannelList( ChannelList );

	RETURN_IF_FAIL( InstrPrintCommandNoPoll() );

	hr = FormattedReadList( NtlAsciiType_R8, ",", val );

	return hr;
}

/// <summary>
///	Sets/gets the thermistor type for temperature measurements on the specified channels. If you supply an empty ChannelList, 
/// this property applies to the internal DMM, independent of any channels or a scan list.
/// </summary>
/// <remarks>
///	
/// </remarks>
/// <param name="ChannelList">
///	One or more channels in the form sccc. Must contain only 1 entry for the getter.
/// </param>
HRESULT Agilent34980A::IAgilent34980AThermistor_get_Resistance(BSTR ChannelList, Agilent34980AThermistorEnum* Val)
{
	HRESULT hr = S_OK;

	CString sList(ChannelList);
	if( -1 != sList.Find( ',' ) || -1!=sList.Find( ':' ) || -1 != sList.Find( '-' ) )
	{
		return ReportError( E_AGILENT34980A_MULTIPLE_CHANNELS_IN_GET, _T("IAgilent34980AThermistor_get_Resistance"), _T("ChannelList"));
	}
	CorrectChannelList( ChannelList, false );
	CString resp;
	hr = InstrQueryCommand(resp, DEFAULT_STRING_LENGTH );
	resp.Remove( '+' );
	if( !EnumFromString<Agilent34980AThermistorEnum>( resp, *Val ) )
		return ReportError( IDS_E_IVI_UNEXPECTED_RESPONSE );

	//hr = InstrQueryCommandEnum(Val);

	return hr;
}

/// <summary>
///	Sets or gets the thermistor type for temperature measurements on the specified
/// channels.
/// </summary>
/// <remarks>
///	If you supply an empty ChannelList, this property applies to the internal DMM,
/// independent of any channels or a scan list.
/// </remarks>
/// <param name="ChannelList">
///	One or more channels in the form sccc. Must contain only 1 entry for the getter.
/// </param>
HRESULT Agilent34980A::IAgilent34980AThermistor_put_Resistance(BSTR ChannelList, Agilent34980AThermistorEnum Val)
{
	HRESULT hr = S_OK;

	CorrectChannelList( ChannelList );

	hr = InstrPrintCommand();

	return hr;
}




/// <summary>
///	Disables or enables the specified thermistor channels to be used as the reference
/// channel for subsequent thermocouple measurements that specify an external reference
/// source.
/// </summary>
/// <remarks>
///	If you supply an empty ChannelList parameter, this command applies to the internal
/// DMM, independent of any channels or a scan list.
/// </remarks>
/// <param name="ChannelList">
///	One or more channels in the form sccc. Must contain only 1 entry for the getter.
/// </param>
HRESULT Agilent34980A::IAgilent34980AThermistor_get_IsExternalReference(BSTR ChannelList, VARIANT_BOOL* Val)
{
	HRESULT hr = S_OK;

	CString sList(ChannelList);
	if( -1 != sList.Find( ',' ) || -1!=sList.Find( ':' ) || -1 != sList.Find( '-' ) )
	{
		return ReportError( E_AGILENT34980A_MULTIPLE_CHANNELS_IN_GET, _T(""), _T(""));
	}
	CorrectChannelList( ChannelList, false );
	CString resp;
	hr = InstrQueryCommand(resp, DEFAULT_STRING_LENGTH );
	resp.Remove( '+' );
	if( resp==GetBooleanFalseCommand() )
		*Val = VARIANT_FALSE;
	else if( resp==GetBooleanTrueCommand() )
		*Val = VARIANT_TRUE;
	else
		return ReportError( IDS_E_IVI_UNEXPECTED_RESPONSE );
	//hr = InstrQueryCommandBool(Val);

	return hr;
}




/// <summary>
///	Disables or enables the specified thermistor channels to be used as the reference
/// channel for subsequent thermocouple measurements that specify an external reference
/// source.
/// </summary>
/// <remarks>
///	If you supply an empty ChannelList parameter, this command applies to the internal
/// DMM, independent of any channels or a scan list.
/// </remarks>
/// <param name="ChannelList">
///	One or more channels in the form sccc. Must contain only 1 entry for the getter.
/// </param>
HRESULT Agilent34980A::IAgilent34980AThermistor_put_IsExternalReference(BSTR ChannelList, VARIANT_BOOL val)
{
	HRESULT hr = S_OK;

	CorrectChannelList( ChannelList );

	hr = InstrPrintCommand();

	return hr;
}

