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

/// <summary>
/// Resets the cycle count on the specified channels.  The instrument must be unsecured
/// to reset the cycle count.
/// </summary>
/// <remarks>
/// 
/// </remarks>
/// <returns>
///	
/// </returns>
/// <param name="ChannelList">
///	One or more channels in the form sccc. Must contain only 1 entry for the getter.
/// </param>
HRESULT Agilent34980A::IAgilent34980ADiagnostic_RelayCyclesClear(BSTR ChannelList)
{
	HRESULT hr = S_OK;

	CorrectChannelList( ChannelList );

	hr = InstrPrintCommand();

	return hr;
}



/// <summary>
/// Resets the relay cycle count on the specified internal DMM relay.
/// </summary>
/// <remarks>
/// 
/// </remarks>
/// <returns>
///	
/// </returns>
/// <param name="Index">
///	Indicates the relay number. The relays are numbered 1 through 6, which correspond to relays K102 through K107, respectively.
/// </param>
HRESULT Agilent34980A::IAgilent34980ADiagnostic_DMMCyclesClear(long Index)
{
	HRESULT hr = S_OK;

	hr = InstrPrintCommand();

	return hr;
}


/// <summary>
///	Reads the cycle count on one of the six relays associated with function selection
/// and isolation on the internal DMM.
/// </summary>
/// <remarks>
///	The internal DMM is an optional assembly for the Agilent 34980A. An error is
/// generated if the internal DMM is disabled or not installed in the mainframe.
/// </remarks>
/// <param name="Index">
///	The number of the relay. The relays are numbered 1 through 6, which correspond to relays K102 through K107, respectively.
/// </param>
HRESULT Agilent34980A::IAgilent34980ADiagnostic_get_DMMCycles(long Index, long* Val)
{
	HRESULT hr = S_OK;

	hr = InstrQueryCommand(Val);

	return hr;
}


/// <summary>
///	Reads the cycle count on the specified channels. In addition to the channel
/// relays, you can also query the count on the Analog Bus relays and bank relays.
/// </summary>
/// <remarks>
///	
/// </remarks>
/// <param name="ChannelList">
///	Channel name in the form sccc. 
/// </param>
HRESULT Agilent34980A::IAgilent34980ADiagnostic_get_RelayCycles(BSTR ChannelList, long* 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("IAgilent34980ADiagnostic_get_ReleyCycles"), _T("ChannelList"));
	}
	CorrectChannelList( ChannelList, false );
	hr = InstrQueryCommand(Val);

	return hr;
}
