First Commit

This commit is contained in:
Wesley Hofman
2025-08-29 18:13:03 +02:00
commit ecb076ce8b
39 changed files with 6982 additions and 0 deletions

145
daq_testing/Instrument.cs Normal file
View File

@@ -0,0 +1,145 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Agilent.Agilent34970.Interop;
namespace daq_testing
{
public class Instrument
{
public Agilent34970 DAQInstrument = new Agilent34970();
public string ResourceDesc { get; set; }
public string InitOptions { get; set; }
public bool IdQuery { get; set; }
public bool Reset { get; set; }
public string ScanList { get; set; }
public string SerialNumber { get; set; }
public Instrument()
{
}
public void CheckCardConfig ()
{
const int NUMBEROFCARDS = 3;
string cardType;
for (int card = 0; card < NUMBEROFCARDS; card++)
{
cardType = DAQInstrument.System.CardType[0];
Console.WriteLine($"Cardtype slot {card}: {cardType}");
}
}
public bool InitializeInstrument ()
{
#if DEBUG
this.InitOptions = "QueryInstrStatus=true, Simulate=true, DriverSetup= Model=, Trace=false, TraceName=c:\\temp\\traceOut";
#else
this.InitOptions = "QueryInstrStatus=true, Simulate=false, DriverSetup= Model=, Trace=false, TraceName=c:\\temp\\traceOut";
#endif
this.IdQuery = true;
this.Reset = true;
try
{
DAQInstrument.Initialize(ResourceDesc, IdQuery, Reset, InitOptions);
GetSerialNumber();
//CheckCardConfig();
Console.WriteLine("Driver Initialized");
return true;
}
catch (Exception)
{
Console.WriteLine("Cannot Initialize Instrument");
return false;
}
}
private void GetSerialNumber ()
{
try
{
SerialNumber = DAQInstrument.Identity.Description;
}
catch (Exception)
{
SerialNumber = null;
throw;
}
}
public string DummyList()
{
List<string> myList = new List<string>();
string joinedlist;
//Sled 1
for (int i = 101; i < 139 +1; i++)
{
myList.Add(i.ToString());
}
//Sled 2
//for (int i = 201; i < 240 + 1; i++)
//{
// myList.Add(i.ToString());
//}
//Sled 3
//for (int i = 301; i < 340 + 1; i++)
//{
// myList.Add(i.ToString());
//}
joinedlist = string.Join(",", myList);
return joinedlist;
}
public void SetScanlist()
{
//string scanList ="@" + DummyList();
//this.ScanList = "@121:140,221:240,321:340";
//this.ScanList = "101:120";
this.ScanList = ScanList;
// Console.WriteLine(String.Format("@{0}",scanList));
}
public void ConfigInstrument()
{
SetScanlist();
DAQInstrument.Voltage.DCVoltage.Configure(ScanList, 10, 0.01);
//DAQInstrument.Voltage.DCVoltage.AutoRangeListConfig(ScanList, true);
DAQInstrument.Scan.SweepCount = 1;
}
public string[] GetMeasurementByScanList (string scanList)
{
this.ScanList = scanList;
string[] result;
DAQInstrument.Scan.Initiate();
DAQInstrument.System.WaitForOperationComplete(10000); // Wait for scan to complete
try
{
result = DAQInstrument.Scan.Fetch();
}
catch (Exception)
{
throw;
}
return result;
}
}
}