55 lines
1.8 KiB
C#
55 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
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 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;
|
|
|
|
if (double.TryParse(Response, out double voltage))
|
|
{
|
|
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}");
|
|
return sample;
|
|
}
|
|
|
|
throw new InvalidOperationException("Unsupported instrument type.");
|
|
}
|
|
}
|
|
}
|