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






/// <summary>
///	Assigns a user-defined label to the specified channels.
/// </summary>
/// <remarks>
///	You can assign a user-defined label to any channel, including Analog Bus 
/// channels on the multiplexer and matrix modules. User-defined channel labels 
/// are available for identification purposes only and cannot be used in place 
///  of a channel number within a command string. 
/// </remarks>
/// <param name="ChannelList">
///	One or more channels in the form sccc.
/// </param>
HRESULT Agilent34980A::IAgilent34980ARoute2_get_ChannelLabel(BSTR ChannelList, BSTR* val)
{
	HRESULT hr = S_OK;


	CString strResult;
	hr = InstrQueryCommand(strResult, DEFAULT_STRING_LENGTH);
	if (SUCCEEDED(hr))
	{
		*val = ::SysAllocString(CT2OLE(strResult.Trim("\"")));
	}

	return hr;
}





/// <summary>
///	Assigns a user-defined label to the specified channels.
/// </summary>
/// <remarks>
///	You can assign a user-defined label to any channel, including Analog Bus 
/// channels on the multiplexer and matrix modules. User-defined channel labels 
/// are available for identification purposes only and cannot be used in place 
///  of a channel number within a command string. 
/// </remarks>
/// <param name="ChannelList">
///	One or more channels in the form sccc.
/// </param>
HRESULT Agilent34980A::IAgilent34980ARoute2_put_ChannelLabel(BSTR ChannelList, BSTR val)
{
	HRESULT hr = S_OK;

	hr = InstrPrintCommand();

	return hr;
}

/// <summary>
///	Returns a comma-separated list of all of the sequence names that have been defined.
/// </summary>
/// <remarks>
///	If no sequences have been defined, then an empty string is returned.
/// </remarks>
HRESULT Agilent34980A::IAgilent34980ARoute2_get_SequenceCatalog(BSTR* val)
{
	HRESULT hr = S_OK;

	hr = InstrQueryCommand(val);

	return hr;
}

/// <summary>
/// Associates a user-specified name with a SCPI sequence and stores it in non-volatile memory.
/// </summary>
/// <remarks>
/// A Sequence is a compiled series of SCPI commands stored in nonvolatile memory and identified 
/// by a user-specified name.  The primary purpose of a Sequence is to provide the user with a 
/// limited shorthand (macro) capability for switching operations, such as opening and closing 
/// channels and waiting for these operations to complete.  Static D/A converter output and static 
/// digital output operations are also supported.
/// </remarks>
/// <returns>
///	
/// </returns>
/// <param name="SequenceName">
///	A user-specified name for the sequence.  The name must be IEEE 488.2 character data
/// and can be up to 30 characters in length.
/// </param>
/// <param name="CommandString">
///	Sequence of SCPI commands to be stored and associated with SequenceName.  
/// The command string may consist of multiple SCPI commands separated by semicolons.
/// </param>
HRESULT Agilent34980A::IAgilent34980ARoute2_SequenceDefine(BSTR SequenceName, BSTR CommandString)
{
	HRESULT hr = S_OK;

	hr = InstrPrintCommand();

	return hr;
}

/// <summary>
/// Deletes a single sequence from non-volatile memory.
/// </summary>
/// <remarks>
/// Deleting a Sequence will remove its association with an alarm, if any exists.  
/// Any attempt to delete a Sequence while it is executing will generate an error.
/// </remarks>
/// <returns>
///	
/// </returns>
/// <param name="SequenceName">
///	Name of the SCPI sequence to delete.
/// </param>
HRESULT Agilent34980A::IAgilent34980ARoute2_SequenceDelete(BSTR SequenceName)
{
	HRESULT hr = S_OK;

	hr = InstrPrintCommand();

	return hr;
}

/// <summary>
/// Deletes all defined sequences from non-volatile memory.
/// </summary>
/// <remarks>
/// Deleting a Sequence will remove its association with an alarm, if any exists.  
/// Any attempt to delete a Sequence while it is executing will generate an error.
/// </remarks>
/// <returns>
///	
/// </returns>
HRESULT Agilent34980A::IAgilent34980ARoute2_SequenceDeleteAll()
{
	HRESULT hr = S_OK;

	hr = InstrPrintCommand();

	return hr;
}


/// <summary>
/// Executes the SCPI sequence specified by SequenceName.
/// </summary>
/// <remarks>
/// The effect of this command is to execute the stored commands as if they had been sent explicitly, 
/// so errors will result if parameter values are out of range or if the commands are not valid for 
/// the modules they attempt to operate on.
/// </remarks>
/// <returns>
///	
/// </returns>
/// <param name="SequenceName">
///	Name of the SCPI sequence to execute.
/// </param>
HRESULT Agilent34980A::IAgilent34980ARoute2_SequenceTriggerImmediate(BSTR SequenceName)
{
	HRESULT hr = S_OK;

	hr = InstrPrintCommand();

	return hr;
}


/// <summary>
///	Associates sequence execution with a particular alarm, or removes a previously defined association.
/// </summary>
/// <remarks>
///	Associating a sequence with an alarm causes the sequence to execute when the specified
/// alarm occurs.  Specifying "Manual" trigger source removes a sequence-alarm association.
/// The sequence will execute once the specified alarm occurs. The sequence will not execute 
/// again until the alarm has been cleared, the association of sequence to alarm is reestablished, 
/// and the alarm re-occurs.
/// </remarks>
/// <param name="SequenceName">
///	Name of the sequence to be associated with the specified alarm.
/// </param>
HRESULT Agilent34980A::IAgilent34980ARoute2_get_SequenceTriggerSource(BSTR SequenceName, Agilent34980ASequenceTriggerSourceEnum* val)
{
	HRESULT hr = S_OK;

	hr = InstrQueryCommandEnum(val);

	return hr;
}


/// <summary>
///	Associates sequence execution with a particular alarm, or removes a previously defined association.
/// </summary>
/// <remarks>
///	Associating a sequence with an alarm causes the sequence to execute when the specified
/// alarm occurs.  Specifying "Manual" trigger source removes a sequence-alarm association.
/// The sequence will execute once the specified alarm occurs. The sequence will not execute 
/// again until the alarm has been cleared, the association of sequence to alarm is reestablished, 
/// and the alarm re-occurs.
/// </remarks>
/// <param name="SequenceName">
///	Name of the sequence to be associated with the specified alarm.
/// </param>
HRESULT Agilent34980A::IAgilent34980ARoute2_put_SequenceTriggerSource(BSTR SequenceName, Agilent34980ASequenceTriggerSourceEnum val)
{
	HRESULT hr = S_OK;

	hr = InstrPrintCommand();

	return hr;
}
