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

/// <summary>
///	The maximum AC current the channel can carry, in amperes.
/// </summary>
/// <remarks>
///	
/// </remarks>
HRESULT Agilent34980AChannel::IIviSwtchCharacteristics_get_ACCurrentCarryMax(double* Val)
{
	HRESULT hr = S_OK;
	SwitchUtils::PModuleInfo pInfo = GetModule();
	if( !pInfo )
		return *Val = (GetRoot()->m_bPlayWithDummy)? 2 : -1, S_OK;
	*Val = pInfo->characteristics.ACCurrentCarryMax;
	if( pInfo->type==SwitchUtils::ModuleType34937 )
	{
		CString sName = TranslateVirtualName( GetInstanceName() );
		int nChannel = atoi( sName.Mid( 2, 2 ) );
		if(  nChannel >= 29 )
		{
			*Val = 8; // special case for Form A relays.
		}
	}
	return hr;
}

/// <summary>
///	The maximum AC current the channel can switch, in amperes.
/// </summary>
/// <remarks>
///	
/// </remarks>
HRESULT Agilent34980AChannel::IIviSwtchCharacteristics_get_ACCurrentSwitchingMax(double* Val)
{
	HRESULT hr = S_OK;

	SwitchUtils::PModuleInfo pInfo = GetModule();
	if( !pInfo )
		return *Val = (GetRoot()->m_bPlayWithDummy)? 2 : -1, S_OK;
	*Val = pInfo->characteristics.ACCurrentSwitchingMax;
	if( pInfo->type==SwitchUtils::ModuleType34937 )
	{
		CString sName = TranslateVirtualName( GetInstanceName() );
		int nChannel = atoi( sName.Mid( 2, 2 ) );
		if(  nChannel >= 29 )
		{
			*Val = 5; // special case for Form A relays.
		}
	}
	return hr;
}

/// <summary>
///	The maximum AC power the channel can handle, in volt-amperes.
/// </summary>
/// <remarks>
///	
/// </remarks>
HRESULT Agilent34980AChannel::IIviSwtchCharacteristics_get_ACPowerCarryMax(double* Val)
{
	HRESULT hr = S_OK;

	SwitchUtils::PModuleInfo pInfo = GetModule();
	if( !pInfo )
		return *Val = (GetRoot()->m_bPlayWithDummy)? 200 : -1, S_OK;
	*Val = pInfo->characteristics.ACPowerCarryMax;
	if( pInfo->type==SwitchUtils::ModuleType34937 )
	{
		CString sName = TranslateVirtualName( GetInstanceName() );
		int nChannel = atoi( sName.Mid( 2, 2 ) );
		if(  nChannel >= 29 )
		{
			*Val = 150; // special case for Form A relays.
		}
	}
	return hr;
}

/// <summary>
///	The maximum AC power the channel can switch, in volt-amperes.
/// </summary>
/// <remarks>
///	
/// </remarks>
HRESULT Agilent34980AChannel::IIviSwtchCharacteristics_get_ACPowerSwitchingMax(double* Val)
{
	HRESULT hr = S_OK;

	SwitchUtils::PModuleInfo pInfo = GetModule();
	if( !pInfo )
		return *Val = (GetRoot()->m_bPlayWithDummy)? 200 : -1, S_OK;
	*Val = pInfo->characteristics.ACPowerSwitchingMax;
	if( pInfo->type==SwitchUtils::ModuleType34937 )
	{
		CString sName = TranslateVirtualName( GetInstanceName() );
		int nChannel = atoi( sName.Mid( 2, 2 ) );
		if(  nChannel >= 29 )
		{
			*Val = 8; // special case for Form A relays.
		}
	}
	return hr;
}

/// <summary>
///	The maximum AC voltage the channel can handle, in volts RMS.
/// </summary>
/// <remarks>
///	
/// </remarks>
HRESULT Agilent34980AChannel::IIviSwtchCharacteristics_get_ACVoltageMax(double* Val)
{
	HRESULT hr = S_OK;

	SwitchUtils::PModuleInfo pInfo = GetModule();
	if( !pInfo )
		return *Val = (GetRoot()->m_bPlayWithDummy)? 100 : -1, S_OK;
	*Val = pInfo->characteristics.ACVoltageMax;
	if( pInfo->type==SwitchUtils::ModuleType34937 )
	{
		CString sName = TranslateVirtualName( GetInstanceName() );
		int nChannel = atoi( sName.Mid( 2, 2 ) );
		if(  nChannel >= 29 )
		{
			*Val = 250; // special case for Form A relays.
		}
	}
	return hr;
}

/// <summary>
///	The bandwidth, in Hertz, for the channel.
/// </summary>
/// <remarks>
///	
/// </remarks>
HRESULT Agilent34980AChannel::IIviSwtchCharacteristics_get_Bandwidth(double* Val)
{
	HRESULT hr = S_OK;

	SwitchUtils::PModuleInfo pInfo = GetModule();
	if( !pInfo )
		return *Val = (GetRoot()->m_bPlayWithDummy)? 10*1000*1000 : -1, S_OK;
	*Val = pInfo->characteristics.Bandwidth;
	return hr;
}

/// <summary>
///	The maximum DC current the channel can carry, in amperes.
/// </summary>
/// <remarks>
///	
/// </remarks>
HRESULT Agilent34980AChannel::IIviSwtchCharacteristics_get_DCCurrentCarryMax(double* Val)
{
	HRESULT hr = S_OK;

	SwitchUtils::PModuleInfo pInfo = GetModule();
	if( !pInfo )
		return *Val = (GetRoot()->m_bPlayWithDummy)? 2 : -1, S_OK;
	*Val = pInfo->characteristics.DCCurrentCarryMax;
	if( pInfo->type==SwitchUtils::ModuleType34937 )
	{
		CString sName = TranslateVirtualName( GetInstanceName() );
		int nChannel = atoi( sName.Mid( 2, 2 ) );
		if(  nChannel >= 29 )
		{
			*Val = 8; // special case for Form A relays.
		}
	}
	return hr;
}

/// <summary>
///	The maximum DC current the channel can switch, in amperes.
/// </summary>
/// <remarks>
///	
/// </remarks>
HRESULT Agilent34980AChannel::IIviSwtchCharacteristics_get_DCCurrentSwitchingMax(double* Val)
{
	HRESULT hr = S_OK;

	SwitchUtils::PModuleInfo pInfo = GetModule();
	if( !pInfo )
		return *Val = (GetRoot()->m_bPlayWithDummy)? 2 : -1, S_OK;
	*Val = pInfo->characteristics.DCCurrentSwitchingMax;
	if( pInfo->type==SwitchUtils::ModuleType34937 )
	{
		CString sName = TranslateVirtualName( GetInstanceName() );
		int nChannel = atoi( sName.Mid( 2, 2 ) );
		if(  nChannel >= 29 )
		{
			*Val = 5; // special case for Form A relays.
		}
	}
	return hr;
}

/// <summary>
///	The maximum DC power the channel can handle, in watts.
/// </summary>
/// <remarks>
///	
/// </remarks>
HRESULT Agilent34980AChannel::IIviSwtchCharacteristics_get_DCPowerCarryMax(double* Val)
{
	HRESULT hr = S_OK;

	SwitchUtils::PModuleInfo pInfo = GetModule();
	if( !pInfo )
		return *Val = (GetRoot()->m_bPlayWithDummy)? 200 : -1, S_OK;
	*Val = pInfo->characteristics.DCPowerCarryMax;
	if( pInfo->type==SwitchUtils::ModuleType34937 )
	{
		CString sName = TranslateVirtualName( GetInstanceName() );
		int nChannel = atoi( sName.Mid( 2, 2 ) );
		if(  nChannel >= 29 )
		{
			*Val = 150; // special case for Form A relays.
		}
	}
	return hr;
}

/// <summary>
///	The maximum DC power the channel can switch, in watts.
/// </summary>
/// <remarks>
///	
/// </remarks>
HRESULT Agilent34980AChannel::IIviSwtchCharacteristics_get_DCPowerSwitchingMax(double* Val)
{
	HRESULT hr = S_OK;

	SwitchUtils::PModuleInfo pInfo = GetModule();
	if( !pInfo )
		return *Val = (GetRoot()->m_bPlayWithDummy)? 200 : -1, S_OK;
	*Val = pInfo->characteristics.DCPowerSwitchingMax;
	if( pInfo->type==SwitchUtils::ModuleType34937 )
	{
		CString sName = TranslateVirtualName( GetInstanceName() );
		int nChannel = atoi( sName.Mid( 2, 2 ) );
		if(  nChannel >= 29 )
		{
			*Val = 150; // special case for Form A relays.
		}
	}
	return hr;
}

/// <summary>
///	The maximum DC voltage the channel can handle, in volts.
/// </summary>
/// <remarks>
///	
/// </remarks>
HRESULT Agilent34980AChannel::IIviSwtchCharacteristics_get_DCVoltageMax(double* Val)
{
	HRESULT hr = S_OK;

	SwitchUtils::PModuleInfo pInfo = GetModule();
	if( !pInfo )
		return *Val = (GetRoot()->m_bPlayWithDummy)? 100 : -1, S_OK;
	*Val = pInfo->characteristics.DCVoltageMax;
	if( pInfo->type==SwitchUtils::ModuleType34937 )
	{
		CString sName = TranslateVirtualName( GetInstanceName() );
		int nChannel = atoi( sName.Mid( 2, 2 ) );
		if(  nChannel >= 29 )
		{
			*Val = 30; // special case for Form A relays.
		}
	}
	return hr;
}

/// <summary>
///	The characteristic impedance of the channel, in ohms.
/// </summary>
/// <remarks>
///	
/// </remarks>
HRESULT Agilent34980AChannel::IIviSwtchCharacteristics_get_Impedance(double* Val)
{
	HRESULT hr = S_OK;

	SwitchUtils::PModuleInfo pInfo = GetModule();
	if( !pInfo )
		return *Val = (GetRoot()->m_bPlayWithDummy)? 15 : -1, S_OK;
	*Val = pInfo->characteristics.Impedance;
	return hr;
}

/// <summary>
///	The maximum total settling time, in seconds, for the channel before the signal
/// going through it is considered stable.  This includes both the activation time
/// for the channel as well as any debounce time.
/// </summary>
/// <remarks>
///	
/// </remarks>
HRESULT Agilent34980AChannel::IIviSwtchCharacteristics_get_SettlingTime(double* Val)
{
	HRESULT hr = S_OK;

	SwitchUtils::PModuleInfo pInfo = GetModule();
	if( !pInfo )
		return *Val = (GetRoot()->m_bPlayWithDummy)? .001 : -1, S_OK;
	*Val = pInfo->characteristics.SettlingTime;
	if( pInfo->type==SwitchUtils::ModuleType34937 )
	{
		CString sName = TranslateVirtualName( GetInstanceName() );
		int nChannel = atoi( sName.Mid( 2, 2 ) );
		if(  nChannel >= 29 )
		{
			*Val = 0.01; // special case for Form A relays.
		}
	}
	return hr;
}

/// <summary>
///	The number of conductors in the current channel.
/// </summary>
/// <remarks>
///	
/// </remarks>
HRESULT Agilent34980AChannel::IIviSwtchCharacteristics_get_WireMode(long* Val)
{
	HRESULT hr = S_OK;
	SwitchUtils::PModuleInfo pInfo = GetModule();
	if( !pInfo )
		return *Val = (GetRoot()->m_bPlayWithDummy)? 2 : -1, S_OK;
	*Val = pInfo->bSingleWire ? 1 : 2;

	return hr;
}


