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









/// <summary>
/// Configures the Counter sub-system.
/// </summary>
/// <remarks>
/// 
/// </remarks>
/// <returns>
///	
/// </returns>
/// <param name="ChannelList">
///	One or more channels in the form sccc.
/// </param>
/// <param name="Function">
///	Function to be set.
/// </param>
/// <param name="GateTime">
///	Gate time.
/// </param>
HRESULT Agilent34950A::IAgilent34950ACounter_Configure(BSTR ChannelList, Agilent34950AFunctionEnum Function, double GateTime)
{
	HRESULT hr = S_OK;

	if( Function == Agilent34950AFunctionTotalizer )
		hr = InstrPrintf(":COUN:FUNC %s, (@%s);  TOT:TYPE READ, (@%s)", 
		EnumToString<Agilent34950AFunctionEnum>(Function), 
		LPCTSTR(COLE2T(ChannelList)), 
		LPCTSTR(COLE2T(ChannelList)));
	else
		hr = InstrPrintCommand();

	return hr;
}

/// <summary>
///	Sets or gets the counter function.
/// </summary>
/// <remarks>
///	
/// </remarks>
/// <param name="ChannelList">
///	One or more channels in the form sccc.
/// </param>
HRESULT Agilent34950A::IAgilent34950ACounter_get_Function(BSTR ChannelList, Agilent34950AFunctionEnum* val)
{
	HRESULT hr = S_OK;

	hr = InstrQueryCommandEnum(val);

	return hr;
}

/// <summary>
///	Sets or gets the counter function.
/// </summary>
/// <remarks>
///	
/// </remarks>
/// <param name="ChannelList">
///	One or more channels in the form sccc.
/// </param>
HRESULT Agilent34950A::IAgilent34950ACounter_put_Function(BSTR ChannelList, Agilent34950AFunctionEnum val)
{
	HRESULT hr = S_OK;

	hr = InstrPrintCommand();

	return hr;
}

/// <summary>
///	Sets or gets the gate time.
/// </summary>
/// <remarks>
///	
/// </remarks>
/// <param name="ChannelList">
///	One or more channels in the form sccc.
/// </param>
HRESULT Agilent34950A::IAgilent34950ACounter_get_GateTime(BSTR ChannelList, double* val)
{
	HRESULT hr = S_OK;

	hr = InstrQueryCommand(val);

	return hr;
}

/// <summary>
///	Sets or gets the gate time.
/// </summary>
/// <remarks>
///	
/// </remarks>
/// <param name="ChannelList">
///	One or more channels in the form sccc.
/// </param>
HRESULT Agilent34950A::IAgilent34950ACounter_put_GateTime(BSTR ChannelList, double val)
{
	HRESULT hr = S_OK;

	hr = InstrPrintCommand();

	return hr;
}


/// <summary>
///	Sets or gets the gate source.
/// </summary>
/// <remarks>
///	INTernal gate source setting will cause the measurement to proceed immediately
/// after the initiate for the gate time duration. The EXTernal gate source setting
/// will wait after the initiate for the gate line to be assertted before takintg
/// measurement yof gate time duration.  For the Totalizer function only, an INTernal
/// gate source setting will cause totalizing to occur continuously, while EXTernal
/// gate source setting will cause the Totalizer to count only when the Gate line
/// iz asserted and stop when the Gate line is de-asserted.
/// </remarks>
/// <param name="ChannelList">
///	One or more channels in the form sccc.
/// </param>
HRESULT Agilent34950A::IAgilent34950ACounter_get_GateSource(BSTR ChannelList, Agilent34950AGateSourceEnum* val)
{
	HRESULT hr = S_OK;

	hr = InstrQueryCommandEnum(val);

	return hr;
}


/// <summary>
///	Sets or gets the gate source.
/// </summary>
/// <remarks>
///	INTernal gate source setting will cause the measurement to proceed immediately
/// after the initiate for the gate time duration. The EXTernal gate source setting
/// will wait after the initiate for the gate line to be assertted before takintg
/// measurement yof gate time duration.  For the Totalizer function only, an INTernal
/// gate source setting will cause totalizing to occur continuously, while EXTernal
/// gate source setting will cause the Totalizer to count only when the Gate line
/// iz asserted and stop when the Gate line is de-asserted.
/// </remarks>
/// <param name="ChannelList">
///	One or more channels in the form sccc.
/// </param>
HRESULT Agilent34950A::IAgilent34950ACounter_put_GateSource(BSTR ChannelList, Agilent34950AGateSourceEnum val)
{
	HRESULT hr = S_OK;

	hr = InstrPrintCommand();

	return hr;
}

/// <summary>
///	Sets or gets the polarity of the gate to either active high (default; NORMal),
/// or active low (INVerted).  The query returns NORM or INV.
/// </summary>
/// <remarks>
///	
/// </remarks>
/// <param name="ChannelList">
///	One or more channels in the form sccc.
/// </param>
HRESULT Agilent34950A::IAgilent34950ACounter_get_GatePolarity(BSTR ChannelList, Agilent34950APolarityEnum* val)
{
	HRESULT hr = S_OK;

	hr = InstrQueryCommandEnum(val);

	return hr;
}

/// <summary>
///	Sets or gets the polarity of the gate to either active high (default; NORMal),
/// or active low (INVerted).  The query returns NORM or INV.
/// </summary>
/// <remarks>
///	
/// </remarks>
/// <param name="ChannelList">
///	One or more channels in the form sccc.
/// </param>
HRESULT Agilent34950A::IAgilent34950ACounter_put_GatePolarity(BSTR ChannelList, Agilent34950APolarityEnum val)
{
	HRESULT hr = S_OK;

	hr = InstrPrintCommand();

	return hr;
}

/// <summary>
///	Sets or gets the threshold voltage for the gate on the counter.
/// </summary>
/// <remarks>
///	The values range from 0 to 5V in steps of 20mV, with a default setting of 0.8V.
/// The gates for the two counters on the 34950 module share the same gate threshold
/// setting.
/// </remarks>
/// <param name="SlotNumber">
///	Slot number of the module.
/// </param>
HRESULT Agilent34950A::IAgilent34950ACounter_get_GateThreshold(long SlotNumber, double* val)
{
	HRESULT hr = S_OK;

	hr = InstrQueryCommand(val);

	return hr;
}

/// <summary>
///	Sets or gets the threshold voltage for the gate on the counter.
/// </summary>
/// <remarks>
///	The values range from 0 to 5V in steps of 20mV, with a default setting of 0.8V.
/// The gates for the two counters on the 34950 module share the same gate threshold
/// setting.
/// </remarks>
/// <param name="SlotNumber">
///	Slot number of the module.
/// </param>
HRESULT Agilent34950A::IAgilent34950ACounter_put_GateThreshold(long SlotNumber, double val)
{
	HRESULT hr = S_OK;

	hr = InstrPrintCommand();

	return hr;
}

/// <summary>
///	Sets or gets the slope of the input signal.
/// </summary>
/// <remarks>
///	
/// </remarks>
/// <param name="ChannelList">
///	One or more channels in the form sccc.
/// </param>
HRESULT Agilent34950A::IAgilent34950ACounter_get_Slope(BSTR ChannelList, Agilent34950ATotalizeSlopeEnum* val)
{
	HRESULT hr = S_OK;

	hr = InstrQueryCommandEnum(val);

	return hr;
}

/// <summary>
///	Sets or gets the slope of the input signal.
/// </summary>
/// <remarks>
///	
/// </remarks>
/// <param name="ChannelList">
///	One or more channels in the form sccc.
/// </param>
HRESULT Agilent34950A::IAgilent34950ACounter_put_Slope(BSTR ChannelList, Agilent34950ATotalizeSlopeEnum val)
{
	HRESULT hr = S_OK;

	hr = InstrPrintCommand();

	return hr;
}

/// <summary>
///	Pointer to the IAgilent34950ATotalizer interface.
/// </summary>
/// <remarks>
///	
/// </remarks>
HRESULT Agilent34950A::IAgilent34950ACounter_get_Totalizer(IAgilent34950ATotalizer** val)
{
	HRESULT hr = S_OK;

	hr = InternalQueryInterface(this, _GetEntries(), __uuidof(*val), reinterpret_cast<void**>(val));

	return hr;
}

/// <summary>
///	Pointer to the IAgilent34950AMeasurement interface.
/// </summary>
/// <remarks>
///	
/// </remarks>
HRESULT Agilent34950A::IAgilent34950ACounter_get_Measurement(IAgilent34950AMeasurement** val)
{
	HRESULT hr = S_OK;

	hr = InternalQueryInterface(this, _GetEntries(), __uuidof(*val), reinterpret_cast<void**>(val));

	return hr;
}

/// <summary>
///	Sets or gets the threshold voltage for the counter.
/// </summary>
/// <remarks>
///	The values may range from 0 to 5V in 20mV steps, with default setting of 0.8V.
/// </remarks>
/// <param name="ChannelList">
///	One or more channels in the form sccc.
/// </param>
HRESULT Agilent34950A::IAgilent34950ACounter_get_Threshold(BSTR ChannelList, double* val)
{
	HRESULT hr = S_OK;

	hr = InstrQueryCommand(val);

	return hr;
}

/// <summary>
///	Sets or gets the threshold voltage for the counter.
/// </summary>
/// <remarks>
///	The values may range from 0 to 5V in 20mV steps, with default setting of 0.8V.
/// </remarks>
/// <param name="ChannelList">
///	One or more channels in the form sccc.
/// </param>
HRESULT Agilent34950A::IAgilent34950ACounter_put_Threshold(BSTR ChannelList, double val)
{
	HRESULT hr = S_OK;

	hr = InstrPrintCommand();

	return hr;
}
