Agilent Technologies N5183A Portable Generator User Manual


 
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide 331
Creating and Downloading User-Data Files
Save and Recall Instrument State Files
string catalog = ReadDevice(device);
/* Match the catalog listing for state files which are named
(sequence#)_(register#) e.g. 0_01, 1_01, 2_05*/
Match m = Regex.Match(catalog, "\"(\\d_\\d\\d),");
while (m.Success)
{
// Grab the matched filename from the regular expresssion
string nextFile = m.Groups[1].ToString();
// Retrieve the file and store with a .STA extension
// in the current directory
Console.WriteLine("Retrieving state file: " + nextFile);
WriteDevice(device, "MEM:DATA? \"/USER/STATE/" + nextFile + "\"\n", true);
ReadFileBlock(device, nextFile + ".STA");
// Clear newline
ReadDevice(device);
// Advance to next match in catalog string
m = m.NextMatch();
}
}
/* This method writes an ASCII text string (SCPI command) to the signal generator.
If the bool "sendEnd" is true, the END line character will be sent at the
conclusion of the write. If "sendEnd is false the END line will not be sent.*/
static public void WriteDevice(uint device, string scpiCmd, bool sendEnd)
{
byte[] buf = Encoding.ASCII.GetBytes(scpiCmd);
if (!sendEnd) // Do not send the END line character
{
VisaInterop.SetAttribute(device, VisaAttribute.SendEndEnable, 0);
}
uint retCount;
VisaInterop.Write(device, buf, (uint)buf.Length, out retCount);
if (!sendEnd) // Set the bool sendEnd true.
{
VisaInterop.SetAttribute(device, VisaAttribute.SendEndEnable, 1);
}
}
// This method reads an ASCII string from the specified device
static public string ReadDevice(uint device)
{