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







/// <summary>
/// Sets up all the handshaking parameters for a bank
/// </summary>
/// <remarks>
/// The threshold can range from 0V to 5V in 20mV steps. The default for threshold
/// is 2.5V (TTL).
/// </remarks>
/// <returns>
///	
/// </returns>
/// <param name="ChannelList">
///	One or more channels in the form sccc.
/// </param>
/// <param name="Mode">
///	Handshake mode.
/// </param>
/// <param name="Threshold">
///	The input threshold for any lines which will be inputs.
/// </param>
/// <param name="Level">
///	The output level of any lines that will be outputs.
/// </param>
HRESULT Agilent34950A::IAgilent34950AHandshake_Configure(BSTR ChannelList, Agilent34950AHandshakeModeEnum Mode, double Threshold, double Level)
{
	HRESULT hr = S_OK;

	hr = InstrPrintCommand();

	return hr;
}

/// <summary>
///	Sets or gets the timeout for an asynchronous transfer.
/// </summary>
/// <remarks>
///	If an async transfer, does not complete within the specified timeout, an SRQ
/// is reported and the transaction is cancelled.  If a timeout occurs in the middle
/// of a buffered transfer, the transfer will be aborted.  If the timeout is finite,
/// it can range from 1ms to 10s.  The default for the timeout is infinite (INF).
///   The query form returns the current setting for the timeout or INF.  Can be
/// set any time, but is only used in async mode.
/// </remarks>
/// <param name="ChannelList">
///	One or more channels in the form sccc.
/// </param>
HRESULT Agilent34950A::IAgilent34950AHandshake_get_AsyncTimeout(BSTR ChannelList, double* val)
{
	HRESULT hr = S_OK;

	hr = InstrQueryCommand(val);

	return hr;
}

/// <summary>
///	Sets or gets the timeout for an asynchronous transfer.
/// </summary>
/// <remarks>
///	If an async transfer, does not complete within the specified timeout, an SRQ
/// is reported and the transaction is cancelled.  If a timeout occurs in the middle
/// of a buffered transfer, the transfer will be aborted.  If the timeout is finite,
/// it can range from 1ms to 10s.  The default for the timeout is infinite (INF).
///   The query form returns the current setting for the timeout or INF.  Can be
/// set any time, but is only used in async mode.
/// </remarks>
/// <param name="ChannelList">
///	One or more channels in the form sccc.
/// </param>
HRESULT Agilent34950A::IAgilent34950AHandshake_put_AsyncTimeout(BSTR ChannelList, double val)
{
	HRESULT hr = S_OK;

	if( val<0 || val>=1000 ) // user wants infinity
	{
		hr = InstrPrintf(":CONF:DIG:HAND:ASYN:TIM %g, (@%s)", +9.900000E+37, LPCTSTR(COLE2T(ChannelList)) );
	}
	else
	{
		hr = InstrPrintCommand();
	}

	return hr;
}

/// <summary>
///	Sets or gets the general speed of the bank, in seconds, from which the clock
/// rate, setup and hold time parameters are derived for the handshaking signals.
/// </summary>
/// <remarks>
///	The cycle time can range from 0.1us (default) to 10seconds.  The query form
/// returns the current setting, and can optionally return the min or max.  Can
/// be sent anytime.
/// </remarks>
/// <param name="ChannelList">
///	One or more digital input or output channels in the form sccc.
/// </param>
HRESULT Agilent34950A::IAgilent34950AHandshake_get_CycleTime(BSTR ChannelList, double* val)
{
	HRESULT hr = S_OK;

	hr = InstrQueryCommand(val);

	return hr;
}

/// <summary>
///	Sets or gets the general speed of the bank, in seconds, from which the clock
/// rate, setup and hold time parameters are derived for the handshaking signals.
/// </summary>
/// <remarks>
///	The cycle time can range from 0.1us (default) to 10seconds.  The query form
/// returns the current setting, and can optionally return the min or max.  Can
/// be sent anytime.
/// </remarks>
/// <param name="ChannelList">
///	One or more digital input or output channels in the form sccc.
/// </param>
HRESULT Agilent34950A::IAgilent34950AHandshake_put_CycleTime(BSTR ChannelList, double val)
{
	HRESULT hr = S_OK;

	hr = InstrPrintCommand();

	return hr;
}

/// <summary>
///	Sets or gets up the high output voltage on the H0, H1 handshaking lines as well
/// as the interrupt line (when it is an output).
/// </summary>
/// <remarks>
///	The level setting ranges from 1.66V (default) to 5V in 20mV steps. The query
/// form returns the current setting .
/// </remarks>
/// <param name="ChannelList">
///	One or more channels in the form sccc.
/// </param>
HRESULT Agilent34950A::IAgilent34950AHandshake_get_Level(BSTR ChannelList, double* val)
{
	HRESULT hr = S_OK;

	hr = InstrQueryCommand(val);

	return hr;
}

/// <summary>
///	Sets or gets up the high output voltage on the H0, H1 handshaking lines as well
/// as the interrupt line (when it is an output).
/// </summary>
/// <remarks>
///	The level setting ranges from 1.66V (default) to 5V in 20mV steps. The query
/// form returns the current setting .
/// </remarks>
/// <param name="ChannelList">
///	One or more channels in the form sccc.
/// </param>
HRESULT Agilent34950A::IAgilent34950AHandshake_put_Level(BSTR ChannelList, double val)
{
	HRESULT hr = S_OK;

	hr = InstrPrintCommand();

	return hr;
}


/// <summary>
///	Sets or gets all the handshaking parameters for a bank.
/// </summary>
/// <remarks>
///	
/// </remarks>
/// <param name="ChannelList">
///	One or more channels in the form sccc.
/// </param>
HRESULT Agilent34950A::IAgilent34950AHandshake_get_Mode(BSTR ChannelList, Agilent34950AHandshakeModeEnum* val)
{
	HRESULT hr = S_OK;

	hr = InstrQueryCommandEnum(val);

	return hr;
}


/// <summary>
///	Sets or gets all the handshaking parameters for a bank.
/// </summary>
/// <remarks>
///	
/// </remarks>
/// <param name="ChannelList">
///	One or more channels in the form sccc.
/// </param>
HRESULT Agilent34950A::IAgilent34950AHandshake_put_Mode(BSTR ChannelList, Agilent34950AHandshakeModeEnum val)
{
	HRESULT hr = S_OK;

	hr = InstrPrintCommand();

	return hr;
}

/// <summary>
///	Sets or gets the general speed of the bank, in Hz, from which the clock rate,
/// setup and hold time parameters are derived for the handshaking signals.
/// </summary>
/// <remarks>
///	The handshake rate can range from 0.1 Hz to 10MHz (default).  The query form
/// returns the current setting. Can be set anytime.
/// </remarks>
/// <param name="ChannelList">
///	One or more channels in the form sccc.
/// </param>
HRESULT Agilent34950A::IAgilent34950AHandshake_get_Rate(BSTR ChannelList, double* val)
{
	HRESULT hr = S_OK;

	hr = InstrQueryCommand(val);

	return hr;
}

/// <summary>
///	Sets or gets the general speed of the bank, in Hz, from which the clock rate,
/// setup and hold time parameters are derived for the handshaking signals.
/// </summary>
/// <remarks>
///	The handshake rate can range from 0.1 Hz to 10MHz (default).  The query form
/// returns the current setting. Can be set anytime.
/// </remarks>
/// <param name="ChannelList">
///	One or more channels in the form sccc.
/// </param>
HRESULT Agilent34950A::IAgilent34950AHandshake_put_Rate(BSTR ChannelList, double val)
{
	HRESULT hr = S_OK;

	hr = InstrPrintCommand();

	return hr;
}


/// <summary>
///	Sets or gets the behavior of the handshaking pins.
/// </summary>
/// <remarks>
///	HIMPedance (default) means output lines (H0, H1) are in a disconnected (Hi Impedance)
/// state.  OFF means the handshaking lines are driven, but they don’t change state
/// when the digital lines are written or read.  ON means handshaking is on and
/// working.  Enabling Buffered (memory) transfers will set the state to ON.
/// </remarks>
/// <param name="ChannelList">
///	One or more channels in the form sccc.
/// </param>
HRESULT Agilent34950A::IAgilent34950AHandshake_get_State(BSTR ChannelList, Agilent34950AStateEnum* val)
{
	HRESULT hr = S_OK;

	hr = InstrQueryCommandEnum(val);

	return hr;
}


/// <summary>
///	Sets or gets the behavior of the handshaking pins.
/// </summary>
/// <remarks>
///	HIMPedance (default) means output lines (H0, H1) are in a disconnected (Hi Impedance)
/// state.  OFF means the handshaking lines are driven, but they don’t change state
/// when the digital lines are written or read.  ON means handshaking is on and
/// working.  Enabling Buffered (memory) transfers will set the state to ON.
/// </remarks>
/// <param name="ChannelList">
///	One or more channels in the form sccc.
/// </param>
HRESULT Agilent34950A::IAgilent34950AHandshake_put_State(BSTR ChannelList, Agilent34950AStateEnum val)
{
	HRESULT hr = S_OK;

	hr = InstrPrintCommand();

	return hr;
}



/// <summary>
///	Sets or gets the strobe (aka clock) source for SYNC handshaking mode.
/// </summary>
/// <remarks>
///	
/// </remarks>
/// <param name="ChannelList">
///	One or more channels in the form sccc.
/// </param>
HRESULT Agilent34950A::IAgilent34950AHandshake_get_SyncStrobe(BSTR ChannelList, Agilent34950AHandshakeStrobeSourceEnum* val)
{
	HRESULT hr = S_OK;

	hr = InstrQueryCommandEnum(val);

	return hr;
}



/// <summary>
///	Sets or gets the strobe (aka clock) source for SYNC handshaking mode.
/// </summary>
/// <remarks>
///	
/// </remarks>
/// <param name="ChannelList">
///	One or more channels in the form sccc.
/// </param>
HRESULT Agilent34950A::IAgilent34950AHandshake_put_SyncStrobe(BSTR ChannelList, Agilent34950AHandshakeStrobeSourceEnum val)
{
	HRESULT hr = S_OK;

	hr = InstrPrintCommand();

	return hr;
}

/// <summary>
///	Sets or gets the input threshold for the H2 handshaking line as well as the
/// interrupt line (when it is an input).
/// </summary>
/// <remarks>
///	The allowable values range from 0 to 5 volts, with default value of 0.8V.
/// </remarks>
/// <param name="ChannelList">
///	One or more channels in the form sccc.
/// </param>
HRESULT Agilent34950A::IAgilent34950AHandshake_get_Threshold(BSTR ChannelList, double* val)
{
	HRESULT hr = S_OK;

	hr = InstrQueryCommand(val);

	return hr;
}

/// <summary>
///	Sets or gets the input threshold for the H2 handshaking line as well as the
/// interrupt line (when it is an input).
/// </summary>
/// <remarks>
///	The allowable values range from 0 to 5 volts, with default value of 0.8V.
/// </remarks>
/// <param name="ChannelList">
///	One or more channels in the form sccc.
/// </param>
HRESULT Agilent34950A::IAgilent34950AHandshake_put_Threshold(BSTR ChannelList, double val)
{
	HRESULT hr = S_OK;

	hr = InstrPrintCommand();

	return hr;
}







/// <summary>
/// Gets the polarity of the specified lines.
/// </summary>
/// <remarks>
/// 
/// </remarks>
/// <returns>
///	
/// </returns>
/// <param name="ChannelList">
///	One or more channels in the form sccc.
/// </param>
/// <param name="Mode">
///	Lines to query for.
/// </param>
HRESULT Agilent34950A::IAgilent34950AHandshake_GetPolarity(BSTR ChannelList, Agilent34950AHandshakeLineIDEnum Mode, Agilent34950APolarityEnum* Val)
{
	HRESULT hr = S_OK;

	hr = InstrQueryCommandEnum( Val );

	return hr;
}



/// <summary>
/// Sets the polarity on the specified lines.
/// </summary>
/// <remarks>
/// 
/// </remarks>
/// <returns>
///	
/// </returns>
/// <param name="ChannelList">
///	One or more channels in the form sccc.
/// </param>
/// <param name="Mode">
///	Lines to set polarity for.
/// </param>
/// <param name="Polarity">
///	Polarity to be set.
/// </param>
HRESULT Agilent34950A::IAgilent34950AHandshake_SetPolarity(BSTR ChannelList, Agilent34950AHandshakeLineIDEnum Mode, Agilent34950APolarityEnum Polarity)
{
	HRESULT hr = S_OK;

	hr = InstrPrintCommand();

	return hr;
}



/// <summary>
///	Gets the drive type for any handshaking lines that are outputs.
/// </summary>
/// <remarks>
///	Active (default) means the handshaking line will be driven by the module.  Open
/// Collector means that the handshaking line will be driven low, but will go to
/// HiZ when in the High state.  Open collector mode requires external pull-ups
/// and allows multiple outputs to be connected together.  NOTE: Using Open collector
/// drive will slow down the handshaking signal.
/// </remarks>
/// <param name="ChannelList">
///	One or more channels in the form sccc.
/// </param>
HRESULT Agilent34950A::IAgilent34950AHandshake_get_Drive(BSTR ChannelList, Agilent34950AHandshakeLineTypeEnum* val)
{
	HRESULT hr = S_OK;

	hr = InstrQueryCommandEnum(val);

	return hr;
}

/// <summary>
///	Gets the drive type for any handshaking lines that are outputs.
/// </summary>
/// <remarks>
///	Active (default) means the handshaking line will be driven by the module.  Open
/// Collector means that the handshaking line will be driven low, but will go to
/// HiZ when in the High state.  Open collector mode requires external pull-ups
/// and allows multiple outputs to be connected together.  NOTE: Using Open collector
/// drive will slow down the handshaking signal.
/// </remarks>
/// <param name="ChannelList">
///	One or more channels in the form sccc.
/// </param>
HRESULT Agilent34950A::IAgilent34950AHandshake_put_Drive(BSTR ChannelList, Agilent34950AHandshakeLineTypeEnum val)
{
	HRESULT hr = S_OK;

	hr = InstrPrintCommand();

	return hr;
}
