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

@@ -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.");
}
}
}