896 Keysight InfiniiVision DSOX1204A/G Oscilloscopes Programmer's Guide
36 Programming Examples
// ==============================================================
// Use auto-scale to automatically configure oscilloscope.
myScope.WriteLine(":AUToscale");
// Set trigger mode (EDGE, PULSe, PATTern, etc., and input source.
myScope.WriteLine(":TRIGger:MODE EDGE");
myScope.WriteLine(":TRIGger:MODE?");
strResults = myScope.ReadLine();
Console.WriteLine("Trigger mode: {0}", strResults);
// Set EDGE trigger parameters.
myScope.WriteLine(":TRIGger:EDGE:SOURce CHANnel1");
myScope.WriteLine(":TRIGger:EDGE:SOURce?");
strResults = myScope.ReadLine();
Console.WriteLine("Trigger edge source: {0}", strResults);
myScope.WriteLine(":TRIGger:EDGE:LEVel 1.5");
myScope.WriteLine(":TRIGger:EDGE:LEVel?");
strResults = myScope.ReadLine();
Console.WriteLine("Trigger edge level: {0}", strResults);
myScope.WriteLine(":TRIGger:EDGE:SLOPe POSitive");
myScope.WriteLine(":TRIGger:EDGE:SLOPe?");
strResults = myScope.ReadLine();
Console.WriteLine("Trigger edge slope: {0}", strResults);
// Save oscilloscope configuration.
byte[] ResultsArray; // Results array.
int nLength; // Number of bytes returned from instrument.
string strPath;
// Query and read setup string.
myScope.WriteLine(":SYSTem:SETup?");
ResultsArray = myScope.ReadLineBinaryBlockOfByte();
nLength = ResultsArray.Length;
// Write setup string to file.
strPath = "c:\\scope\\config\\setup.stp";
fStream = File.Open(strPath, FileMode.Create);
fStream.Write(ResultsArray, 0, nLength);
fStream.Close();
Console.WriteLine("Setup bytes saved: {0}", nLength);
// Change settings with individual commands:
// Set vertical scale and offset.
myScope.WriteLine(":CHANnel1:SCALe 0.05");
myScope.WriteLine(":CHANnel1:SCALe?");
strResults = myScope.ReadLine();
Console.WriteLine("Channel 1 vertical scale: {0}", strResults);
myScope.WriteLine(":CHANnel1:OFFSet -1.5");
myScope.WriteLine(":CHANnel1:OFFSet?");
strResults = myScope.ReadLine();
Console.WriteLine("Channel 1 vertical offset: {0}", strResults);
// Set horizontal scale and offset.