using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Threading; namespace HTOLHAST { public partial class Form1 : Form { HMP4040 PSU1; HMP4040 PSU2; Keithley6485 PAM; Agilent34970a DAQ; public Form1() { InitializeComponent(); } public void InitializeInstruments() { // Mandatory instruments: InitializePSU1(tbResourceStringPSU1.Text); InitializeDAQ(tbResourceStringDAQ.Text); // Optional Instruments check if to be used if (cbPSU1Enabled.Checked) { InitializePSU2(tbResourceStringPSU2.Text); } if (cbPAMEnabled.Checked) { InitializePAM(tbResourceStringPAM.Text); } } public void InitializePSU1(string resourceString) { try { PSU1 = new HMP4040(resourceString); } catch (Exception) { throw; } } public void InitializePSU2(string resourceString) { try { PSU2 = new HMP4040(resourceString); } catch (Exception) { throw; } } public void InitializePAM(string resourceString) { try { PAM = new Keithley6485(resourceString); } catch (Exception) { throw; } } public void InitializeDAQ(string resourceString) { try { DAQ = new Agilent34970a(resourceString); } catch (Exception) { throw; } } public void HamegValidationOfMethods() { string resourceString = "ASRL4::INSTR"; // Replace with your instrument's resource string HMP4040 hameg = new HMP4040(resourceString); hameg.GetID(); string voltageResponse = hameg.MeasureVolt(1); Console.WriteLine($"Measured Voltage: {voltageResponse} V"); string currentResponse = hameg.MeasureCurrent(1); Console.WriteLine($"Measured Current: {currentResponse} A"); string voltageSetpoint = hameg.SetVoltage(1.1, 1); Console.WriteLine($"Voltage Setpoint: {currentResponse} V"); string currentSetpoint = hameg.SetCurrent(0.1, 1); Console.WriteLine($"Current Setpoint: {currentResponse} A"); hameg.PowerUpSequence(hameg.GenerateSimulationPowerUpSequence()); hameg.PowerDownSequence(hameg.GenerateSimulationPowerUpSequence()); } public void KeithleyValidationOfMethods() { // Example usage string resourceString = "ASRL3::INSTR"; // Replace with your instrument's resource string Keithley6485 keithley = new Keithley6485(resourceString); // Query the instrument ID keithley.Reset(); string idnResponse = keithley.GetID(); Console.WriteLine($"Instrument ID: {idnResponse}"); // Measure DC current keithley.PerformZeroCheck(); string currentResponse = keithley.MeasureDCCurrent(); Console.WriteLine($"Measured Current: {currentResponse}"); // Close the instrument connection keithley.Close(); } private void btnInitializeInstruments_Click(object sender, EventArgs e) { InitializeInstruments(); } } }