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

@@ -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
}
}