Various updates

This commit is contained in:
Wesley Hofman
2025-09-15 20:24:09 +02:00
parent 9292dcfad5
commit 14e8e2f267
18 changed files with 1241 additions and 483 deletions

View File

@@ -8,18 +8,40 @@ namespace HTOLHAST
{
public class Agilent34970a : SCPIInstrument
{
//00926 20 Channel Actuator / GP Switch Module SLOT1
//02700 20 Channel Multiplexer Module (BLR) SLOT2
public Agilent34970a(string resourceString) : base(resourceString) { }
public override Sample CreateSample(string response)
public Sample MeasureVolt(int channel)
{
string Channel = channel.ToString();
WriteCommand($"MEAS:VOLT:DC? (@{channel})");
string response = ReadResponse();
Console.WriteLine($"[Agilent] Measured Voltage : {response}");
Sample sample = CreateSample(response, "V");
return sample;
}
public void CloseChannel(int channel)
{
WriteCommand($"ROUT:CLOS (@{channel})");
}
public void OpenChannel(int channel)
{
WriteCommand($"ROUT:OPEN (@{channel})");
}
public void ConfigVoltageChannel(int channel)
{
string Channel = channel.ToString();
WriteCommand($"CONF:VOLT:DC (@{channel})");
}
public override Sample CreateSample(string response, string unit)
{
string Response = response;
// Parse the Keithley output
string[] parts = Response.Split(',');
if (parts.Length >= 1 && double.TryParse(parts[0].Replace("V", ""), out double current))
if (double.TryParse(Response, out double voltage))
{
Agilent34970aSample sample = new Agilent34970aSample(DateTime.Now, current, "V");
Agilent34970aSample sample = new Agilent34970aSample(DateTime.Now, voltage, unit);
// Optionally, store or process the sample here
Console.WriteLine($"[Agilent34970] Sample Created, Value: {sample.Value} {sample.Unit}");

View File

@@ -19,4 +19,12 @@
<add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" />
<remove invariant="System.Data.SQLite" /><add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" /></DbProviderFactories>
</system.data>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

File diff suppressed because it is too large Load Diff

View File

@@ -8,25 +8,203 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
using System.Text.RegularExpressions;
using Maser.Palantir.Model;
namespace HTOLHAST
{
public partial class Form1 : Form
{
public int PositionIncrement
{
get
{
int result;
if (int.TryParse(tbPositionIncrement.Text, out result))
{
return result;
}
else
{
// Handle the case where the conversion fails
throw new FormatException("Invalid input for PAMMaxCurrent.");
}
}
set
{
tbPositionIncrement.Text = value.ToString();
}
}
public int CurrentPosition
{
get
{
int result;
if (int.TryParse(tbCurrentPosition.Text, out result))
{
return result;
}
else
{
// Handle the case where the conversion fails
throw new FormatException("Invalid input for PAMMaxCurrent.");
}
}
set
{
tbCurrentPosition.Text = value.ToString();
}
}
HMP4040 PSU1;
HMP4040 PSU2;
Keithley6485 PAM;
Agilent34970a DAQ;
Project Project;
List<SwitchMatrix> switchMatrix;
List<PowerUpSequence> powerUpSequences;
List<PowerUpSequence> powerDownSequences;
List<Measurement> measurements;
List<HeaderSetting> headerSettings = new List<HeaderSetting>();
DataTable dataTablePowersupplySettings = new DataTable();
List<PowerSupplySetting> powerSupplySettings = new List<PowerSupplySetting>();
List<int> voltageChannels = new List<int>() { 201, 202, 203, 204, 205, 206, 207, 208, 209, 210,
214, 215, 216, 217, 218, 219 };
public double PAMMaxCurrent
{
get
{
double result;
if (double.TryParse(tbPamMaxCurrent.Text, out result))
{
return result;
}
else
{
// Handle the case where the conversion fails
throw new FormatException("Invalid input for PAMMaxCurrent.");
}
}
}
public Form1()
{
InitializeComponent();
InitializeEvents();
//InitializeDataTablePowerSupplySettings();
//InitializeDgvPowerSupplySettings();
//KeithleyValidationOfMethods();
InitDgvPowersupply();
InitDgvHeaderSetting();
InitDgvMeasurements();
InitSwitchMatrix();
InitializePowerupSequence();
}
private void InitDgvMeasurements()
{
measurements = new List<Measurement>();
dgvMeasurements.DataSource = measurements;
}
private void InitBeginPositionOfSwitches()
{
foreach (var sw in switchMatrix)
{
DAQ.CloseChannel(sw.SW1);
DAQ.OpenChannel(sw.SW2);
DAQ.CloseChannel(sw.SW3);
}
}
private void InitSwitchMatrix()
{
switchMatrix = new List<SwitchMatrix>()
{
//00926 20 Channel Actuator / GP Switch Module SLOT1
new SwitchMatrix { Channel = 1, SW1 = 102, SW2 = 103, SW3 = 104 },
new SwitchMatrix { Channel = 2, SW1 = 105, SW2 = 106, SW3 = 107 },
new SwitchMatrix { Channel = 3, SW1 = 108, SW2 = 109, SW3 = 110 },
new SwitchMatrix { Channel = 4, SW1 = 111, SW2 = 112, SW3 = 113 },
new SwitchMatrix { Channel = 5, SW1 = 114, SW2 = 115, SW3 = 116 },
new SwitchMatrix { Channel = 6, SW1 = 117, SW2 = 118, SW3 = 119 }
};
}
public void InitDgvHeaderSetting()
{
for (int headerpin = 1; headerpin <= 10; headerpin++)
{
HeaderSetting headerSetting = new HeaderSetting() { HeaderPin = headerpin.ToString(), Channel = voltageChannels[headerpin -1], Description = "-", Setpoint = 0.0, Tolerance = 0.0 };
headerSettings.Add(headerSetting);
}
dgvHeaderSettings.DataSource = headerSettings;
dgvHeaderSettings.Update();
}
public void InitDgvPowersupply ()
{
for (int channel = 1; channel <= 6; channel++)
{
PowerSupplySetting powerSupplySetting = new PowerSupplySetting() { Channel = channel, Description = "-", Voltage = 0.0, Tolerance = 1, CurrentLimit = 0.1, Enabled = false };
powerSupplySettings.Add(powerSupplySetting);
}
dgvPowerSupplies.DataSource = powerSupplySettings;
dgvPowerSupplies.Update();
}
public void InitializeDataTablePowerSupplySettings()
{
dataTablePowersupplySettings.Columns.Add("Channel", typeof(int));
dataTablePowersupplySettings.Columns.Add("Description", typeof(string));
dataTablePowersupplySettings.Columns.Add("Voltage", typeof(double));
dataTablePowersupplySettings.Columns.Add("Tolerance", typeof(double));
dataTablePowersupplySettings.Columns.Add("CurrentLimit", typeof(double));
dataTablePowersupplySettings.Columns.Add("Enabled", typeof(bool));
}
public void InitializeDgvPowerSupplySettings()
{
dgvPowerSupplies.DataSource = dataTablePowersupplySettings;
for (int channel = 1; channel <= 6; channel++)
{
PowerSupplySetting powerSupplySetting = new PowerSupplySetting() { Channel = channel, Description = "-", Voltage = 0.0, Tolerance = 1, CurrentLimit = 0.1, Enabled = false };
dataTablePowersupplySettings.Rows.Add(powerSupplySetting.Channel, powerSupplySetting.Description, powerSupplySetting.Voltage,
powerSupplySetting.Tolerance, powerSupplySetting.CurrentLimit, powerSupplySetting.Enabled);
}
dgvPowerSupplies.Update();
}
private void InitializeEvents ()
{
cbCH1.CheckedChanged += OnPowerSupplyCheckboxClicked;
cbCH2.CheckedChanged += OnPowerSupplyCheckboxClicked;
cbCH3.CheckedChanged += OnPowerSupplyCheckboxClicked;
cbCH4.CheckedChanged += OnPowerSupplyCheckboxClicked;
cbCH5.CheckedChanged += OnPowerSupplyCheckboxClicked;
cbCH6.CheckedChanged += OnPowerSupplyCheckboxClicked;
cbCH7.Enabled = false;
cbCH8.Enabled = false;
}
private void InitializePowerupSequence()
{
powerUpSequences = new List<PowerUpSequence>()
{ new PowerUpSequence { Channel = 1, Delay = 100},
new PowerUpSequence { Channel = 2, Delay = 100},
new PowerUpSequence { Channel = 3, Delay = 100},
new PowerUpSequence { Channel = 4, Delay = 100}
};
}
private void InitializePowerDownSequence()
{
powerDownSequences = new List<PowerUpSequence>()
{ new PowerUpSequence { Channel = 1, Delay = 1},
new PowerUpSequence { Channel = 2, Delay = 1},
new PowerUpSequence { Channel = 3, Delay = 1},
new PowerUpSequence { Channel = 4, Delay = 1}
};
}
public void InitializeInstruments()
{
@@ -35,7 +213,7 @@ namespace HTOLHAST
InitializeDAQ(tbResourceStringDAQ.Text);
// Optional Instruments check if to be used
if (cbPSU1Enabled.Checked)
if (cbPSU2Enabled.Checked)
{
InitializePSU2(tbResourceStringPSU2.Text);
}
@@ -50,10 +228,19 @@ namespace HTOLHAST
try
{
PSU1 = new HMP4040(resourceString);
foreach (var setting in powerSupplySettings)
{
if (setting.Channel <=4)
{
setting.Voltage = PSU1.ReadSetpoint(setting.Channel);
}
}
dgvPowerSupplies.Refresh();
}
catch (Exception)
{
MessageBox.Show("Unable to Connect to HAMEG 1 PowerSupply");
throw;
}
@@ -66,7 +253,7 @@ namespace HTOLHAST
}
catch (Exception)
{
MessageBox.Show("Unable to Connect to HAMEG 2 PowerSupply");
throw;
}
@@ -76,10 +263,17 @@ namespace HTOLHAST
try
{
PAM = new Keithley6485(resourceString);
// Query the instrument ID
PAM.Reset();
string idnResponse = PAM.GetID();
Console.WriteLine($"Instrument ID: {idnResponse}");
// Measure DC current
PAM.PerformZeroCheck();
}
catch (Exception)
{
MessageBox.Show("Unable to Connect to PicoAmmeter");
throw;
}
@@ -90,24 +284,24 @@ namespace HTOLHAST
{
DAQ = new Agilent34970a(resourceString);
}
catch (Exception)
catch (Exception e)
{
MessageBox.Show("Unable to Connect to DAQ");
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");
HMP4040Sample voltageResponse = (HMP4040Sample)hameg.MeasureVolt(1);
Console.WriteLine($"Measured Voltage: {voltageResponse.Value} V");
string currentResponse = hameg.MeasureCurrent(1);
Console.WriteLine($"Measured Current: {currentResponse} A");
HMP4040Sample currentResponse = (HMP4040Sample)hameg.MeasureCurrent(1);
Console.WriteLine($"Measured Current: {currentResponse.Value} A");
string voltageSetpoint = hameg.SetVoltage(1.1, 1);
@@ -132,17 +326,282 @@ namespace HTOLHAST
// Measure DC current
keithley.PerformZeroCheck();
string currentResponse = keithley.MeasureDCCurrent();
Console.WriteLine($"Measured Current: {currentResponse}");
Keithley6485Sample currentResponse = (Keithley6485Sample) keithley.MeasureDCCurrent();
Console.WriteLine($"Measured Current: {currentResponse.Value}");
// Close the instrument connection
keithley.Close();
}
public void AgilentValidationOfMethods()
{
// Example usage
string resourceString = "ASRL9::INSTR"; // Replace with your instrument's resource string
Agilent34970a agilent = new Agilent34970a(resourceString);
// Query the instrument ID
agilent.Reset();
string idnResponse = agilent.GetID();
Console.WriteLine($"Instrument ID: {idnResponse}");
//Measure DC Voltage
foreach (var channel in voltageChannels)
{
agilent.ConfigVoltageChannel(channel);
Agilent34970aSample sample =(Agilent34970aSample) agilent.MeasureVolt(channel);
Console.WriteLine($"Measured voltage CH{channel} : {sample.Value}");
}
// Close the instrument connection
agilent.Close();
}
private void btnInitializeInstruments_Click(object sender, EventArgs e)
{
InitializeInstruments();
}
private void btnSelectProject_Click(object sender, EventArgs e)
{
// Create new Form and show in showdialog window.
FormSelectProject formSelectProject = new FormSelectProject();
if (formSelectProject.ShowDialog() == DialogResult.OK)
{
// Get Project information from formSelectProject Form.
Project = formSelectProject.Project;
// Update Project information
UpdateProjectInfoTextboxes(Project);
}
}
private void UpdateProjectInfoTextboxes(Project project)
{
// Fill in project information textboxes.
tbProject.Text = $"Project: P{project.MIDSProject} Sub: {project.MIDSSubProject} Step: {project.MIDSStep}";
tbProjectDescription.Text = project.MIDSProjectDescription;
tbSubProjectDescription.Text = project.MIDSSubProjectDescription;
tbStepDescription.Text = project.MIDSStepDescription;
}
public void OnPowerSupplyCheckboxClicked (object sender, EventArgs e)
{
CheckBox SelectedChannel = (CheckBox)sender;
Console.WriteLine(SelectedChannel.Name);
int.TryParse(SelectedChannel.Name[4].ToString(), out int channel);
//DataRow row = dataTablePowersupplySettings.Rows[channel-1];
//row["Enabled"] = SelectedChannel.Checked;
foreach (var setting in powerSupplySettings)
{
if (setting.Channel == channel)
{
setting.Enabled = SelectedChannel.Checked;
dgvPowerSupplies.Refresh();
}
}
}
private void btnMeasure_Click(object sender, EventArgs e)
{
InitBeginPositionOfSwitches();
PowerUpPSU(powerUpSequences);
MeasurePSUVoltage();
MeasureHeaderVoltage();
MeasureCurrent();
PowerDownPSU(powerUpSequences);
UpdateMeasureDGV();
// Timestamp, Position, Device, Measurement, Voltage, Current
// 2025-01-09, 1, HAMEG1, CH1, 1.0, 0.1
// 2025-01-09, 1, HAMEG2, CH5, 1.0, 0.1
// 2025-01-09, 1, KEITHLEY, CH1, -, 1.0
// 2025-01-09, 1, AGILENT, HEADER1, 1.0, -
}
private void UpdateMeasureDGV()
{
dgvMeasurements.DataSource = null;
dgvMeasurements.DataSource = measurements;
dgvMeasurements.Refresh();
}
private void PowerUpPSU(List<PowerUpSequence> powerUpsequences)
{
PSU1.PowerUpSequence(powerUpsequences);
PSU1.SetGeneralOutputState(true);
}
private void PowerDownPSU(List<PowerUpSequence> powerUpsequences)
{
PSU1.PowerDownSequence(powerUpsequences);
PSU1.SetGeneralOutputState(false);
}
private void MeasureHeaderVoltage()
{
//02700 20 Channel Multiplexer Module (BLR) SLOT2
foreach (var header in headerSettings)
{
DAQ.ConfigVoltageChannel(header.Channel);
Agilent34970aSample sample =(Agilent34970aSample)DAQ.MeasureVolt(header.Channel);
this.measurements.Add(new Measurement
{
Description = $"Headerpin : {header.HeaderPin}",
Device = "Agilent34970A",
Position = CurrentPosition,
Timestamp = sample.TimeStamp,
Value = sample.Value,
Unit = sample.Unit
});
Console.WriteLine($"Measured voltage CH{header.Channel} : {sample.Value}");
}
}
private void MeasurePSUVoltage()
{
var powerSupplies = GetEnabledPowerSupplies();
foreach (var powersupply in powerSupplies)
{
if (powersupply.Channel <= 4)
{
HMP4040Sample sample = (HMP4040Sample)PSU1.MeasureVolt(powersupply.Channel);
this.measurements.Add(new Measurement
{
Description = $"PSU1_CH{powersupply.Channel}",
Device = "HAMEG4040",
Position = CurrentPosition,
Timestamp = sample.TimeStamp,
Value = sample.Value,
Unit = sample.Unit
});
sample = (HMP4040Sample)PSU1.MeasureCurrent(powersupply.Channel);
this.measurements.Add(new Measurement
{
Description = $"PSU1_CH{powersupply.Channel}",
Device = "HAMEG4040",
Position = CurrentPosition,
Timestamp = sample.TimeStamp,
Value = sample.Value,
Unit = sample.Unit
});
}
else
{
HMP4040Sample sample = (HMP4040Sample)PSU2.MeasureVolt(powersupply.Channel);
this.measurements.Add(new Measurement
{
Description = $"PSU2_CH{powersupply.Channel}",
Device = "HAMEG4040",
Position = CurrentPosition,
Timestamp = sample.TimeStamp,
Value = sample.Value,
Unit = sample.Unit
});
sample = (HMP4040Sample)PSU2.MeasureCurrent(powersupply.Channel);
this.measurements.Add(new Measurement
{
Description = $"PSU1_CH{powersupply.Channel}",
Device = "HAMEG4040",
Position = CurrentPosition,
Timestamp = sample.TimeStamp,
Value = sample.Value,
Unit = sample.Unit
});
}
}
}
private void MeasureCurrent()
{
var enabledPowersupplies = GetEnabledPowerSupplies();
foreach (var powersupply in enabledPowersupplies)
{
if (powersupply.Channel <= 4)
{
HMP4040Sample current = (HMP4040Sample) PSU1.MeasureCurrent(powersupply.Channel);
if (PAM == null) { return; }
if (current.Value < PAMMaxCurrent )
{
DAQ.CloseChannel(101); // Switch relay for PAM measurement
SetSwitchesBeforeCurrentMeasurement(powersupply.Channel);
Keithley6485Sample sample = (Keithley6485Sample) PAM.MeasureDCCurrent();
this.measurements.Add(new Measurement
{
Description = $"PSU1_CH{powersupply.Channel}",
Device = "Keithley6485",
Position = CurrentPosition,
Timestamp = sample.TimeStamp,
Value = sample.Value,
Unit = sample.Unit
});
SetSwitchesAfterCurrentMeasurement(powersupply.Channel);
}
}
else
{
DAQ.CloseChannel(101); // Switch relay for PAM measurement
HMP4040Sample current = (HMP4040Sample)PSU2.MeasureCurrent(powersupply.Channel);
if (PAM == null) { return; }
if (current.Value < PAMMaxCurrent)
{
SetSwitchesBeforeCurrentMeasurement(powersupply.Channel);
PAM.MeasureDCCurrent();
Keithley6485Sample sample = (Keithley6485Sample)PAM.MeasureDCCurrent();
this.measurements.Add(new Measurement
{
Description = $"PSU2_CH{powersupply.Channel}",
Device = "Keithley6485",
Position = CurrentPosition,
Timestamp = sample.TimeStamp,
Value = sample.Value,
Unit = sample.Unit
});
SetSwitchesAfterCurrentMeasurement(powersupply.Channel);
}
}
}
}
private void SetSwitchesBeforeCurrentMeasurement(int channel)
{
SwitchMatrix switches = switchMatrix.Where(x => x.Channel == channel).First();
DAQ.CloseChannel(switches.SW1);
DAQ.CloseChannel(switches.SW2);
DAQ.CloseChannel(switches.SW3);
DAQ.OpenChannel(switches.SW1);
}
private void SetSwitchesAfterCurrentMeasurement(int channel)
{
SwitchMatrix switches = switchMatrix.Where(x => x.Channel == channel).First();
DAQ.CloseChannel(switches.SW1);
DAQ.OpenChannel(switches.SW2);
DAQ.OpenChannel(switches.SW3);
}
private List<PowerSupplySetting> GetEnabledPowerSupplies()
{
var enabledPowerSupplies = powerSupplySettings.Where(x => x.Enabled == true).ToList();
return enabledPowerSupplies;
}
private void btnSendPsuSettings_Click(object sender, EventArgs e)
{
foreach (PowerSupplySetting powerSupplySetting in powerSupplySettings)
{
PSU1.SetVoltage(powerSupplySetting.Voltage, powerSupplySetting.Channel);
PSU1.SetCurrent(powerSupplySetting.CurrentLimit, powerSupplySetting.Channel);
}
}
private void btnNextPosition_Click(object sender, EventArgs e)
{
CurrentPosition += PositionIncrement;
}
private void btnClear_Click(object sender, EventArgs e)
{
measurements.Clear(); // Clear the list
dgvMeasurements.DataSource = null; // Clear the data source
dgvMeasurements.DataSource = measurements;
}
}
}

View File

@@ -141,64 +141,4 @@
<metadata name="Delay.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Supply.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Description.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="VSetpoint.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Tolerance.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="CurrentLimitTotal.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Supply.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Description.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="VSetpoint.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Tolerance.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="CurrentLimitTotal.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dataGridViewTextBoxColumn3.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dataGridViewTextBoxColumn4.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dataGridViewTextBoxColumn5.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dataGridViewTextBoxColumn6.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dataGridViewTextBoxColumn3.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dataGridViewTextBoxColumn4.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dataGridViewTextBoxColumn5.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dataGridViewTextBoxColumn6.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ID.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ID.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

58
HTOLHAST/FormSelectProject.Designer.cs generated Normal file
View File

@@ -0,0 +1,58 @@

namespace HTOLHAST
{
partial class FormSelectProject
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.midsProjectRetriever = new Maser.Palantir.MIDSProjectRetriever.MIDSProjectRetriever();
this.SuspendLayout();
//
// midsProjectRetriever
//
this.midsProjectRetriever.Location = new System.Drawing.Point(12, 12);
this.midsProjectRetriever.Name = "midsProjectRetriever";
this.midsProjectRetriever.Size = new System.Drawing.Size(963, 243);
this.midsProjectRetriever.TabIndex = 0;
//
// FormSelectProject
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1000, 270);
this.Controls.Add(this.midsProjectRetriever);
this.Name = "FormSelectProject";
this.Text = "FormSelectProject";
this.ResumeLayout(false);
}
#endregion
private Maser.Palantir.MIDSProjectRetriever.MIDSProjectRetriever midsProjectRetriever;
}
}

View File

@@ -0,0 +1,30 @@
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 Maser.Palantir.Model;
namespace HTOLHAST
{
public partial class FormSelectProject : Form
{
public Project Project;
public FormSelectProject()
{
InitializeComponent();
midsProjectRetriever.OK_Clicked += MidsProjectRetriever_OK_Clicked;
}
private void MidsProjectRetriever_OK_Clicked(object sender, EventArgs e)
{
Project = midsProjectRetriever.Project;
this.DialogResult = DialogResult.OK;
this.Close();
}
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -10,19 +10,33 @@ namespace HTOLHAST
public class HMP4040 : SCPIInstrument
{
public HMP4040(string resourceString) : base(resourceString) { }
public string MeasureCurrent(int channel)
public Sample MeasureCurrent(int channel)
{
string Channel = channel.ToString();
WriteCommand($"INST:NSEL {Channel}");
WriteCommand("MEAS:CURR?");
return ReadResponse();
string response = ReadResponse();
Console.WriteLine($"[Hameg] Measured Current : {response}");
Sample sample = CreateSample(response, "A");
return sample;
}
public string MeasureVolt(int channel)
public double ReadSetpoint(int channel)
{
double response = double.NaN;
WriteCommand($"INST OUT{channel}");
WriteCommand($"VOLT? CH{channel}");
double.TryParse(ReadResponse(), out response);
return response;
}
public Sample MeasureVolt(int channel)
{
string Channel = channel.ToString();
WriteCommand($"INST:NSEL {Channel}");
WriteCommand("MEAS:VOLT?");
return ReadResponse();
string response = ReadResponse();
Console.WriteLine($"[Hameg] Measured Voltage : {response}");
Sample sample = CreateSample(response,"V");
return sample;
}
public string SetVoltage (double setpoint, int channel)
{
@@ -91,9 +105,20 @@ namespace HTOLHAST
return powerUpSequence;
}
public override Sample CreateSample(string response)
public override Sample CreateSample(string response, string unit)
{
throw new NotImplementedException();
string Response = response;
if (double.TryParse(Response, out double voltage))
{
HMP4040Sample sample = new HMP4040Sample(DateTime.Now, voltage, unit);
// Optionally, store or process the sample here
Console.WriteLine($"[HMP4040] Sample Created, Value: {sample.Value} {sample.Unit}");
return sample;
}
throw new InvalidOperationException("Unsupported instrument type.");
}
}
}

View File

@@ -44,7 +44,32 @@
<HintPath>..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.SqlServer.dll</HintPath>
</Reference>
<Reference Include="Ivi.Visa, Version=7.2.0.0, Culture=neutral, PublicKeyToken=a128c98f1d7717c1, processorArchitecture=MSIL" />
<Reference Include="Maser.Palantir.MIDSinterface">
<HintPath>Z:\software\MASER software\Source\C# Maser Libraries\Released\Maser.Palantir.MIDSinterface.dll</HintPath>
</Reference>
<Reference Include="Maser.Palantir.MIDSProjectRetriever, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Z:\software\MASER software\Source\C# Maser Libraries\Released\Maser.Palantir.MIDSProjectRetriever.dll</HintPath>
</Reference>
<Reference Include="Maser.Palantir.Model">
<HintPath>Z:\software\MASER software\Source\C# Maser Libraries\Released\Maser.Palantir.Model.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions, Version=8.0.0.2, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.8.0.2\lib\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=8.0.0.2, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Extensions.Logging.Abstractions.8.0.2\lib\net462\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
</Reference>
<Reference Include="MySqlConnector, Version=2.0.0.0, Culture=neutral, PublicKeyToken=d33d3e53aa5f8c92, processorArchitecture=MSIL">
<HintPath>..\packages\MySqlConnector.2.4.0\lib\net471\MySqlConnector.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Data.SQLite, Version=1.0.119.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
@@ -56,6 +81,23 @@
<Reference Include="System.Data.SQLite.Linq, Version=1.0.119.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>..\packages\System.Data.SQLite.Linq.1.0.119.0\lib\net46\System.Data.SQLite.Linq.dll</HintPath>
</Reference>
<Reference Include="System.Diagnostics.DiagnosticSource, Version=8.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Diagnostics.DiagnosticSource.8.0.1\lib\net462\System.Diagnostics.DiagnosticSource.dll</HintPath>
</Reference>
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Transactions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
@@ -75,16 +117,29 @@
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="FormSelectProject.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FormSelectProject.Designer.cs">
<DependentUpon>FormSelectProject.cs</DependentUpon>
</Compile>
<Compile Include="HeaderSetting.cs" />
<Compile Include="HMP4040.cs" />
<Compile Include="Keithley6485.cs" />
<Compile Include="Measurement.cs" />
<Compile Include="PowerSupplySetting.cs" />
<Compile Include="PowerUpSequence.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Sample.cs" />
<Compile Include="ScpiInstrument.cs" />
<Compile Include="SwitchMatrix.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FormSelectProject.resx">
<DependentUpon>FormSelectProject.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>

22
HTOLHAST/HeaderSetting.cs Normal file
View File

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HTOLHAST
{
public class HeaderSetting
{
public string HeaderPin { get; set; }
public int Channel { get; set; }
public string Description { get; set; }
public double Setpoint { get; set; }
public double Tolerance { get; set; }
public HeaderSetting()
{
}
}
}

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
namespace HTOLHAST
{
@@ -46,24 +47,27 @@ namespace HTOLHAST
WriteCommand("RANG:AUTO ON"); // Enable AUTO range
WriteCommand("READ?"); // trigger and return one reading
Console.WriteLine("Read Command Initiated");
Thread.Sleep(100);
}
public string MeasureDCCurrent()
public Sample MeasureDCCurrent()
{
InitiateRead();
string response = ReadResponse();
CreateSample(response);
return response;
Console.WriteLine($"Current reading from PAM : { response }");
Sample sample = CreateSample(response, "A");
return sample;
}
public override Sample CreateSample(string response)
public override Sample CreateSample(string response, string unit)
{
string Response = response;
// Parse the Keithley output
string[] parts = Response.Split(',');
if (parts.Length >= 1 && double.TryParse(parts[0].Replace("A", ""), out double current))
if (double.TryParse(parts[0].Replace("A", ""), out double current))
{
Keithley6485Sample sample = new Keithley6485Sample(DateTime.Now, current, "A");
Keithley6485Sample sample = new Keithley6485Sample(DateTime.Now, current, unit);
// Optionally, store or process the sample here
Console.WriteLine($"[Keithley] Sample Created, Value: {sample.Value} {sample.Unit}");
@@ -71,8 +75,7 @@ namespace HTOLHAST
}
throw new InvalidOperationException("Unsupported instrument type.");
}
}
// Add more specific methods for Keithley 6485 as needed
}
}

30
HTOLHAST/Measurement.cs Normal file
View File

@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HTOLHAST
{
public class Measurement
{
// Timestamp, Position, Device, Measurement, Value, Unit
// 2025-01-09, 1, HAMEG1, CH1, 1.0, 0.1
// 2025-01-09, 1, HAMEG2, CH5, 1.0, 0.1
// 2025-01-09, 1, KEITHLEY, CH1, -, 1.0
// 2025-01-09, 1, AGILENT, HEADER1, 1.0, -
public DateTime Timestamp { get; set; }
public int Position { get; set; }
public string Device { get; set; }
public string Description { get; set; }
public double Value { get; set; }
public string Unit { get; set; }
public Measurement()
{
}
}
}

View File

@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HTOLHAST
{
public class PowerSupplySetting
{
public int Channel { get; set; }
public string Description { get; set; }
public double Voltage { get; set; }
public double Tolerance { get; set; }
public double CurrentLimit { get; set; }
public bool Enabled { get; set; }
public PowerSupplySetting()
{
}
}
}

View File

@@ -54,7 +54,6 @@ namespace HTOLHAST
public class Agilent34970aSample : Sample
{
public double Value { get; set; }
public Agilent34970aSample(DateTime timeStamp, double value, string unit) : base(timeStamp, unit)
{
Value = value;

View File

@@ -13,7 +13,7 @@ namespace HTOLHAST
{
protected ResourceManager resourceManager;
protected Ivi.Visa.Interop.FormattedIO488 instrument;
public abstract Sample CreateSample(string response);
public abstract Sample CreateSample(string response, string unit);
protected SCPIInstrument(string resourceString)
{
resourceManager = new ResourceManager();

16
HTOLHAST/SwitchMatrix.cs Normal file
View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HTOLHAST
{
public class SwitchMatrix
{
public int Channel { get; set; }
public int SW1 { get; set; }
public int SW2 { get; set; }
public int SW3 { get; set; }
}
}

View File

@@ -1,9 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityFramework" version="6.4.4" targetFramework="net472" />
<package id="Microsoft.Bcl.AsyncInterfaces" version="8.0.0" targetFramework="net472" />
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="8.0.2" targetFramework="net472" />
<package id="Microsoft.Extensions.Logging.Abstractions" version="8.0.2" targetFramework="net472" />
<package id="MySqlConnector" version="2.4.0" targetFramework="net472" />
<package id="Stub.System.Data.SQLite.Core.NetFramework" version="1.0.119.0" targetFramework="net472" />
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />
<package id="System.Data.SQLite" version="1.0.119.0" targetFramework="net472" />
<package id="System.Data.SQLite.Core" version="1.0.119.0" targetFramework="net472" />
<package id="System.Data.SQLite.EF6" version="1.0.119.0" targetFramework="net472" />
<package id="System.Data.SQLite.Linq" version="1.0.119.0" targetFramework="net472" />
<package id="System.Diagnostics.DiagnosticSource" version="8.0.1" targetFramework="net472" />
<package id="System.Memory" version="4.5.5" targetFramework="net472" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net472" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net472" />
</packages>