374 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide
Creating and Downloading User–Data Files
Save and Recall Instrument State Files
uint retCount;
if (VisaInterop.Read(device, buf, (uint)buf.Length -1, out
retCount) == 0)
{
retValue = Encoding.ASCII.GetString(buf, 0, (int)retCount);
}
return retValue;
}
/* The following method reads a SCPI definite block from the signal
generator
and writes the contents to a file on your computer. The trailing
newline character is NOT consumed by the read.*/
static public void ReadFileBlock(uint device, string fileName)
{
// Create the new, empty data file.
FileStream fs = new FileStream(fileName, FileMode.Create);
// Read the definite block header:
#{lengthDataLength}{dataLength}
uint retCount = 0;
byte[] buf = new byte[10];
VisaInterop.Read(device, buf, 2, out retCount);
VisaInterop.Read(device, buf, (uint)(buf[1]-'0'), out retCount);
uint fileSize = UInt32.Parse(Encoding.ASCII.GetString(buf, 0,
(int)retCount));
// Read the file block from the signal generator
byte[] readBuf = new byte[TRANSFER_BLOCK_SIZE];
uint bytesRemaining = fileSize;
while (bytesRemaining != 0)
{
uint bytesToRead = (bytesRemaining < TRANSFER_BLOCK_SIZE) ?
bytesRemaining : TRANSFER_BLOCK_SIZE;
VisaInterop.Read(device, readBuf, bytesToRead, out retCount);
Содержание X-Series
Страница 4: ...4 ...
Страница 10: ...10 Contents ...