/******************************************************************************
 *                                                                         
 *               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">
///	Thermocouple type {B|E|J|K|N|R|S|T}.
/// </param>
HRESULT Agilent34980A::IAgilent34980AThermocouple_Configure(BSTR ChannelList, Agilent34980AResolutionEnum Resolution, Agilent34980AThermocoupleEnum 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 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="Type">
///	Thermocouple type {B|E|J|K|N|R|S|T}.
/// </param>
/// <param name="Resolution">
///	Select from Least (4.5 digits), DEFault (5.5 digits) and Best (6.5 digits).
/// </param>
HRESULT Agilent34980A::IAgilent34980AThermocouple_Measure(BSTR ChannelList, Agilent34980AThermocoupleEnum Type, Agilent34980AResolutionEnum Resolution, SAFEARRAY** val)
{
	HRESULT hr = S_OK;

	CorrectChannelList( ChannelList );

	RETURN_IF_FAIL( InstrPrintCommandNoPoll() );

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

	return hr;
}

/// <summary>
///	Sets or gets the temperature transducer probe type to use for measurements on the specified channels. If you supply 
/// 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::IAgilent34980AThermocouple_get_ThermocoupleType(BSTR ChannelList, Agilent34980AThermocoupleEnum* 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("IAgilent34980AThermocouple_get_ThermocoupleType"), _T("ChannelList"));
	}
	CorrectChannelList( ChannelList, false );
	hr = InstrQueryCommandEnum(Val);

	return hr;
}

/// <summary>
///	Sets or gets the temperature transducer probe type to use for 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::IAgilent34980AThermocouple_put_ThermocoupleType(BSTR ChannelList, Agilent34980AThermocoupleEnum Val)
{
	HRESULT hr = S_OK;

	CorrectChannelList( ChannelList );

	hr = InstrPrintCommand();

	return hr;
}

/// <summary>
///	Sets or gets the reference junction source for thermocouple 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::IAgilent34980AThermocouple_get_ReferenceJunctionType(BSTR ChannelList, Agilent34980ARJunctionEnum* 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("IAgilent34980AThermocouple_get_ReferenceJunctionType"), _T("ChannelList"));
	}
	CorrectChannelList( ChannelList, false );
	hr = InstrQueryCommandEnum(Val);

	return hr;
}

/// <summary>
///	Sets or gets the reference junction source for thermocouple 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::IAgilent34980AThermocouple_put_ReferenceJunctionType(BSTR ChannelList, Agilent34980ARJunctionEnum Val)
{
	HRESULT hr = S_OK;

	CorrectChannelList( ChannelList );

	hr = InstrPrintCommand();

	return hr;
}




/// <summary>
///	Gets the fixed reference junction temperature in degrees Celsius for thermocouple
///   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::IAgilent34980AThermocouple_get_FixedReferenceJunction(BSTR ChannelList, double* 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 );
	hr = InstrQueryCommand(Val);

	return hr;
}


/// <summary>
///	Gets the fixed reference junction temperature in degrees Celsius for thermocouple
///   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::IAgilent34980AThermocouple_put_FixedReferenceJunction(BSTR ChannelList, double val)
{
	HRESULT hr = S_OK;

	CorrectChannelList( ChannelList );

	hr = InstrPrintCommand();

	return hr;
}

/// <summary>
///	Disables or enables the thermocouple check feature to verify that your thermocouples
/// are properly connected to the screw terminals for measurements.
/// </summary>
/// <remarks>
///	If you enable this feature, the instrument measures the channel resistance after
/// each thermocouple measurement to ensure a proper connection.
/// </remarks>
/// <param name="ChannelList">
///	One or more channels in the form sccc. Must contain only 1 entry for the getter.
/// </param>
HRESULT Agilent34980A::IAgilent34980AThermocouple_get_Check(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("IAgilent34980AThermocouple_get_Check"), _T("ChannelList"));
	}
	CorrectChannelList( ChannelList, false );
	hr = InstrQueryCommandBool(Val);

	return hr;
}

/// <summary>
///	Disables or enables the thermocouple check feature to verify that your thermocouples
/// are properly connected to the screw terminals for measurements.
/// </summary>
/// <remarks>
///	If you enable this feature, the instrument measures the channel resistance after
/// each thermocouple measurement to ensure a proper connection.
/// </remarks>
/// <param name="ChannelList">
///	One or more channels in the form sccc. Must contain only 1 entry for the getter.
/// </param>
HRESULT Agilent34980A::IAgilent34980AThermocouple_put_Check(BSTR ChannelList, VARIANT_BOOL Val)
{
	HRESULT hr = S_OK;

	CorrectChannelList( ChannelList );

	hr = InstrPrintCommand();

	return hr;
}

/// <summary>
///	Disables or enables the automatic input resistance mode for dc voltage measurements
/// on the specified channels.
/// </summary>
/// <remarks>
///	Normally, the instrument's input resistance is fixed at 10 MOhm for all dc voltage
/// ranges to minimize noise pickup. To reduce the effects of measurement loading
/// errors, you can set the input resistance to greater than 10 GOhm for the 100
/// mVdc, 1 Vdc, and 10 Vdc ranges. 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::IAgilent34980AThermocouple_get_AutoImpedance(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("IAgilent34980AThermocouple_get_AutoImpedance"), _T("ChannelList"));
	}
	CorrectChannelList( ChannelList, false );
	hr = InstrQueryCommandBool(Val);

	return hr;
}

/// <summary>
///	Disables or enables the automatic input resistance mode for dc voltage measurements
/// on the specified channels.
/// </summary>
/// <remarks>
///	Normally, the instrument's input resistance is fixed at 10 MOhm for all dc voltage
/// ranges to minimize noise pickup. To reduce the effects of measurement loading
/// errors, you can set the input resistance to greater than 10 GOhm for the 100
/// mVdc, 1 Vdc, and 10 Vdc ranges. 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::IAgilent34980AThermocouple_put_AutoImpedance(BSTR ChannelList, VARIANT_BOOL Val)
{
	HRESULT hr = S_OK;

	CorrectChannelList( ChannelList );

	hr = InstrPrintCommand();

	return hr;
}









/// <summary>
///	Returns the most-recently stored external reference temperature value for thermocouple measurements.
/// </summary>
/// <remarks>
///	
/// </remarks>
HRESULT Agilent34980A::IAgilent34980AThermocouple_get_ExternalReferenceJunction(double* val)
{
	HRESULT hr = S_OK;

	hr = InstrQueryCommand(val);

	return hr;
}



/// <summary>
///	Returns the internal reference junction temperature for thermocouple measurements
/// on the specified channels
/// </summary>
/// <remarks>
///	
/// </remarks>
/// <param name="ChannelList">
///	One or more channels in the form sccc.
/// </param>
HRESULT Agilent34980A::IAgilent34980AThermocouple_get_InternalReferenceJunction(BSTR ChannelList, double* val)
{
	HRESULT hr = S_OK;

	CString sList(ChannelList);
	if( -1 != sList.Find( ',' ) || -1!=sList.Find( ':' ) || -1 != sList.Find( '-' ) )
	{
		return ReportInvalidValueError( _T("IAgilent34980AThermocouple_get_InternalReferenceJunction"), _T("ChannelList"), sList );
	}
	CorrectChannelList( ChannelList, false );
	hr = InstrQueryCommand(val);

	return hr;
}

