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






/// <summary>
///	This property can be used to get (read) the contents of the Module Condition
/// and Event registers for the device in the specified slot, and to set (write)
/// or get (read) the Module Enable register for the device in the specified slot.
/// </summary>
/// <remarks>
///	
/// </remarks>
/// <param name="Slot">
///	Slot number (1 to 8) from which to read the specified register.
/// </param>
/// <param name="SubRegister">
///	Sub-register on the module.
/// </param>
HRESULT Agilent34980A::IAgilent34980AStatus2_get_ModuleRegister(long Slot, Agilent34980AStatusSubRegisterEnum SubRegister, long* val)
{
	HRESULT hr = S_OK;

	switch( SubRegister )
	{
		case Agilent34980AStatusSubRegisterCondition:
			hr = InstrQueryf( "STAT:MOD:SLOT%d:COND?", val , Slot);
			break;

		case Agilent34980AStatusSubRegisterEnable:
			hr = InstrQueryf( "STAT:MOD:SLOT%d:ENAB?", val , Slot);
			break;

		case Agilent34980AStatusSubRegisterEvent:
			hr = InstrQueryf( "STAT:MOD:SLOT%d:EVEN?", val , Slot);
			break;

		default:
			return ReportInvalidValueError(_T("get_ModuleRegister"), _T("SubRegister"), (long)(SubRegister));
			break;
	}	

	return hr;
}




/// <summary>
///	This property can be used to get (read) the contents of the Module Condition
/// and Event registers for the device in the specified slot, and to set (write)
/// or get (read) the Module Enable register for the device in the specified slot.
/// </summary>
/// <remarks>
///	
/// </remarks>
/// <param name="Slot">
///	Slot number (1 to 8) from which to read the specified register.
/// </param>
/// <param name="SubRegister">
///	Sub-register on the module.
/// </param>
HRESULT Agilent34980A::IAgilent34980AStatus2_put_ModuleRegister(long Slot, Agilent34980AStatusSubRegisterEnum SubRegister, long val)
{
	HRESULT hr = S_OK;

	switch( SubRegister )
	{
		case Agilent34980AStatusSubRegisterEnable:
			// 16-bit register
			val &= 0xFFFF;
			hr = InstrPrintf( "STAT:MOD:SLOT%ld:ENAB %ld", Slot, val );
			break;

		default:
			return ReportInvalidValueError(_T("put_ModuleRegister"), _T("SubRegister"), (long)SubRegister);
			break;
	}

	return hr;
}
