Example #1
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";
     }
 }