Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
        /*
         * 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:
         *   -i Add option to NOT sent INIT:IMM, if instrument gets triggered from some other source.
         *   -c Add option to specify number of readings to fetch in total, then exit.
         *   -b Add option to specify a command to send before starting the acquisition -"ABORT;:TRIG:SOUR BUS;*TRG"
         *   -a Add option to specify a command to send before every "R?" - "*TRG"
         *   -v Add option verbose, show number of measurements read
         *   -p Option number of points to receive each call
         *   -l do not learn instrument config?
         *   -h Help
         *
         */

        static void Main(string[] args)
        {
            Ag53230A instr = new Ag53230A();

            instr.LearnConfig();

            StreamWriter err = new StreamWriter(Console.OpenStandardError());

            err.AutoFlush = true;

            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;
                }
            }

            double[] readings;

            // 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());

            instr.WriteString("*TRG");
            while (true)
            {
                instr.WriteString("*TRG");
                instr.WriteString(query);

                readings = instr.GetReadings();

                if (readings.Length != pts)
                {
                    err.WriteLine("Warning: Expected {0} readings, received {1}.", pts, readings.Length);
                }

                foreach (double d in readings)
                {
                    Console.WriteLine(d.ToString("E15", CultureInfo.InvariantCulture));
                }

                /*
                 * String str = instr.ReadString().Trim();
                 * if (String.IsNullOrEmpty(str))
                 *  break;
                 *
                 * String[] readings = str.Split(new char[] { ',' });
                 *
                 * foreach (string r in readings)
                 *  Console.WriteLine(r);
                 */
            }
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            Ag53230A instr = new Ag53230A();

            string[] errors = instr.ReadErrors();
            foreach (string error in errors)
            {
                Console.Error.WriteLine(error);
            }
        }
Esempio n. 4
0
        /*
         *  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);
            }
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            Ag53230A instr = new Ag53230A();

            instr.LearnConfig();

            int repeat = -1;

            if (args.Length > 0)
            {
                if (!Int32.TryParse(args[0], out repeat))
                {
                    Console.Error.WriteLine("Warning! Unable to parse argument {0}", args[0]);
                }
            }

            while (repeat == -1 || repeat-- > 0)
            {
                instr.WriteString("READ?");

                double[] res = instr.GetReadings();

                foreach (double d in res)
                {
                    Console.WriteLine(d.ToString());    // Todo: formatstring
                }

                //String str = instr.ReadString().Trim();

                //String[] readings = str.Split(new char[] { ',' });

                //foreach (string r in readings)
                //    Console.WriteLine(r);
            }

            string[] errors = instr.ReadErrors();
            foreach (string error in errors)
            {
                Console.Error.WriteLine(error);
            }
        }