Ejemplo n.º 1
0
        static int Main(string[] args)
        {
            HP8753DotNet hp8753;

            Console.WriteLine("Application Init....");

            try
            {
                hp8753 = new HP8753DotNet(24);
                hp8753.VISAtoGPIBTimeout(10000);
                hp8753.Initialize();
                hp8753.setNumPoints(201);
                hp8753.setDataTransferFormat("FORM4");
                hp8753.isRemote = true;
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: {0}", ex.Message);
                Console.ReadKey();
                return -1;
            }

            Console.WriteLine("Init successfull\nReading data from instrument...");

            try
            {
                string raw = hp8753.getRawMeasurementData();
                char[] delimiter = { ',' };
                string[] data = raw.Split(delimiter, StringSplitOptions.RemoveEmptyEntries);

                Console.WriteLine("Printing the data in form");
                uint n = (uint)data.Count();
                uint i = 0;
                while (n >= 0)
                {
                    Console.WriteLine("\t{0}\t{1}", data[i], data[i + 1]);
                    i += 2;
                    n -= 2;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: {0}", ex.Message);
                Console.ReadKey();
                return -2;
            }
            Console.ReadKey();
            Console.WriteLine("Processing ended, releasing instrument");
            hp8753.isRemote = false;
            hp8753.GoToLocal();

            return 0;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Handles the Click event of the connect button control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
 private void connect_button_Click(object sender, RoutedEventArgs e)
 {
     if (isConnected == false)
     {
         try
         {
             int gpibAddress = (int)Convert.ToDecimal(GpibAddress.Value);
             hp8753 = new HP8753DotNet(gpibAddress);
             hp8753.Initialize();
             string IdString = hp8753.Query("*IDN?");
             if (hp8753.RecognizedIdString(IdString) == false)
             {
                 errDlg("Agilent/HP 8753 not recognized\nContinuing anyway...");
                 //throw new NotSupportedException("Agilent/HP 8753 not recognized");
             }
             hp8753.setNumPoints(Convert.ToUInt16(points.Value));
             hp8753.setDataTransferFormat("FORM4");
             if (hp8753.setRemote() == true)
             {
                 connect_button.Content = "Remote -> Local";
             }
             else
             {
                 connect_button.Content = "Local -> Remote";
             }
         }
         catch (Exception ex)
         {
             hp8753.GoToLocal();
             hp8753.isRemote = false;
             connect_button.Content = "Local -> Remote";
             errDlg("Error Connecting to Remote Device: " + ex.Message);
         }
     }
     else
     {
         hp8753.isRemote = false;
         hp8753.GoToLocal();
         isConnected = false;
         connect_button.Content = "Local";
     }
 }