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
        /*
         *  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);
            }
        }