/* * Triggers a measurement and retrieves results while measurements are ongoing. * The instrument will continue to make measurements untill the number of measurements * specified with ":samp:count" has been made, possibly multiplied with the number of triggers * to accept, specified with ":trig:count". Depends on the measurement mode, RTFM. * * Runs untill aborted with ctrl-c, or times out. * * To do: * Add option to NOT sent INIT:IMM, if instrument gets triggered from some other source. * Add option to specify number of readings to fetch in total, then exit. * */ static void Main(string[] args) { Ag53230A instr = new Ag53230A(); int pts = 1; // Default retrieve 1 pt per call if (args.Length != 0) { if (!Int32.TryParse(args[0], out pts)) { Console.WriteLine("Could not parse parameter '{0}'", args[0]); return; } } // Trigger instr.WriteString("ABORT;*WAI;INIT:IMM"); System.Threading.Thread.Sleep(20); // The instrument will beep if the :DATA:REM follows too fast after INIT:IMM string query = String.Format(":DATA:REMOVE? {0},WAIT", pts.ToString()); while (true) { instr.WriteString(query); String str = instr.ReadString().Trim(); if (String.IsNullOrEmpty(str)) break; String[] readings = str.Split(new char[] { ',' }); foreach (string r in readings) Console.WriteLine(r); } }
static void Main(string[] args) { Ag53230A instr = new Ag53230A(); if (args.Length > 0) { instr.WriteString(args[0]); if (!args[0].Contains("?")){ Console.WriteLine("Not a query."); // Queries usually ends with ?, but at least contains ? ("TRIG:SOUR?", ":DATA:REM? 1,WAIT") return; } } else return; String str = instr.ReadString(); String[] res = str.Split(new char[] { ',' }); foreach (string r in res) Console.WriteLine(r); // Write errorlog - if any. string[] errors = instr.ReadErrors(); foreach (string error in errors) Console.Error.WriteLine(error); }
static void Main(string[] args) { Ag53230A instr = new Ag53230A(); string[] errors = instr.ReadErrors(); foreach (string error in errors) Console.Error.WriteLine(error); }
/* * Send a "Read?" command to counter, which triggers a new measurement. The counter will take the number of samples * specified with ":Sample:count", and return them. * * Splits the returned batch of readings into separate text-files, named "0.txt" to "<n>.txt" * * If auxQuery != null, runs this query once per trigger, and logs the result to q.txt * * Runs untill terminated with ctrl-c, or timeout */ static void Main(string[] args) { Ag53230A instr = new Ag53230A(); StreamWriter[] writers = null; string auxQuery = "SYST:TEMP?"; StreamWriter auxQueryWr = null; char[] splitchar = new char[] { ',' }; while (true) { instr.WriteString("READ?"); String str = instr.ReadString().TrimEnd(); String[] readings = str.Split(splitchar); // Create readings.Count() streamwriters. if (writers == null) { writers = new StreamWriter[readings.Count()]; for (int i = 0; i < readings.Count(); i++) { writers[i] = new StreamWriter(i.ToString() + ".txt"); writers[i].AutoFlush = true; } } if (readings.Count() != writers.Length) Console.WriteLine("Error! Expected {0} samples, got {1}!", writers.Length, readings.Count()); // This will break unless every "batch" has the same number of readings. for (int i = 0; i < readings.Count(); i++) writers[i].WriteLine(readings[i]); // Additional Query if(auxQuery != null) { if (auxQueryWr == null) { auxQueryWr = new StreamWriter("q.txt"); auxQueryWr.AutoFlush = true; } instr.WriteString(auxQuery); auxQueryWr.WriteLine(instr.ReadString().TrimEnd()); } } }
static void Main(string[] args) { Ag53230A instr = new Ag53230A(); instr.WriteString("READ?"); String str = instr.ReadString(); String[] readings = str.Split(new char[] { ',' }); foreach(string r in readings) Console.WriteLine(r); string[] errors = instr.ReadErrors(); if (errors.Length > 1) foreach (string error in errors) Console.Error.WriteLine(error); }
/* TO-DO: * Add option -a to show all settings, even if they are the default * Add option to show "protected" settings? "ROSC:*" */ static void Main(string[] args) { Ag53230A instr = new Ag53230A(); List<string> input = new List<string>(); // If input is redirected, assume it is from a file we want to upload to the instrument. if (Console.IsInputRedirected) { input.Add(Console.In.ReadToEnd()); } // If arguments are given, assume it is strings to be sent to the instrument input.AddRange(args); // Send whatever we got. foreach(string s in input){ string[] stmts = s.Split(new char[] { ';', '\n' }); foreach (string stmt in stmts) instr.WriteString(stmt.Trim()); } // If no input, get current configuration state from instrument if(input.Count == 0) { instr.WriteString("*LRN?"); string s = instr.ReadString(); s = s.Trim(); string[] stmts = s.Split(new char[] { ';' }); // Filter out default settings foreach (string stmt in stmts) if (!Defaultsettings.Contains(stmt)) Console.WriteLine(stmt + ";"); } // If errors, print. string[] errors = instr.ReadErrors(); foreach (string error in errors) Console.Error.WriteLine(error); }