national-instruments-helper-linux

This commit is contained in:
2025-08-18 12:46:31 -07:00
parent 5671959051
commit f41583c533
8 changed files with 167 additions and 171 deletions

2
.vscode/launch.json vendored
View File

@ -9,7 +9,7 @@
"type": "coreclr", "type": "coreclr",
"request": "launch", "request": "launch",
"preLaunchTask": "Build", "preLaunchTask": "Build",
"program": "${workspaceFolder}/bin/Debug/net8.0/win-x64/File-Watcher.dll", "program": "${workspaceFolder}/bin/Debug/net8.0/linux-x64/File-Watcher.dll",
"args": [ "args": [
"s" "s"
], ],

4
.vscode/tasks.json vendored
View File

@ -64,7 +64,7 @@
"args": [ "args": [
"publish", "publish",
"-r", "-r",
"win-x64", "linux-x64",
"-c", "-c",
"Release", "Release",
"-p:PublishAot=true" "-p:PublishAot=true"
@ -74,7 +74,7 @@
{ {
"label": "File-Folder-Helper AOT s X Day-Helper-2025-03-20", "label": "File-Folder-Helper AOT s X Day-Helper-2025-03-20",
"type": "shell", "type": "shell",
"command": "L:/DevOps/Mesa_FI/File-Folder-Helper/bin/Release/net8.0/win-x64/publish/File-Folder-Helper.exe", "command": "L:/DevOps/Mesa_FI/File-Folder-Helper/bin/Release/net8.0/linux-x64/publish/File-Folder-Helper.exe",
"args": [ "args": [
"s", "s",
"X", "X",

View File

@ -3,8 +3,9 @@
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<RuntimeIdentifier>win-x64</RuntimeIdentifier> <RuntimeIdentifier>linux-x64</RuntimeIdentifier>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild> <EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<UserSecretsIdBeforeOracle>b6f34b8e-5026-41d4-9c28-6516d19d6569</UserSecretsIdBeforeOracle> <UserSecretsIdBeforeOracle>b6f34b8e-5026-41d4-9c28-6516d19d6569</UserSecretsIdBeforeOracle>
<UserSecretsId>6062c774-99a9-4f4a-b42d-a9cb7fcbd8be</UserSecretsId> <UserSecretsId>6062c774-99a9-4f4a-b42d-a9cb7fcbd8be</UserSecretsId>
@ -20,7 +21,6 @@
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.1" /> <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.EventLog" Version="8.0.1" /> <PackageReference Include="Microsoft.Extensions.Logging.EventLog" Version="8.0.1" />
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="23.7.0" /> <PackageReference Include="Oracle.ManagedDataAccess.Core" Version="23.7.0" />
<PackageReference Include="runtime.win-x64.Microsoft.DotNet.ILCompiler" Version="8.0.16" />
<PackageReference Include="ShellProgressBar" Version="5.2.0" /> <PackageReference Include="ShellProgressBar" Version="5.2.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.6" /> <PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
<PackageReference Include="System.Drawing.Common" Version="8.0.16" /> <PackageReference Include="System.Drawing.Common" Version="8.0.16" />

View File

@ -7,7 +7,7 @@ public static class DAQmx
public static string GetErrorString(int errorCode) public static string GetErrorString(int errorCode)
{ {
StringBuilder errorString = new(256); StringBuilder errorString = new(256);
_ = Interop.DAQmxGetErrorString(errorCode, errorString, (uint)(errorString.Capacity + 1)); _ = Interop.DAQmxBaseGetErrorString(errorCode, errorString, (uint)(errorString.Capacity + 1));
return errorString.ToString(); return errorString.ToString();
} }
} }

View File

@ -26,7 +26,7 @@ public class DAQmxTask
{ {
DAQmxTask result; DAQmxTask result;
IntPtr taskHandle; IntPtr taskHandle;
int task = Interop.DAQmxCreateTask(taskName, out taskHandle); int task = Interop.DAQmxBaseCreateTask(taskName, out taskHandle);
if (task < 0) if (task < 0)
throw new DAQmxException(task, "Could not create Task"); throw new DAQmxException(task, "Could not create Task");
result = new() { taskHandle = taskHandle, Channels = 0 }; result = new() { taskHandle = taskHandle, Channels = 0 };
@ -35,14 +35,14 @@ public class DAQmxTask
public void ConfigureLoggingTechnicalDataManagementStreaming(string filePath, DAQmxLoggingMode loggingMode, string groupName, DAQmxLoggingTDMSOperation operation) public void ConfigureLoggingTechnicalDataManagementStreaming(string filePath, DAQmxLoggingMode loggingMode, string groupName, DAQmxLoggingTDMSOperation operation)
{ {
int errorCode = Interop.DAQmxConfigureLogging(taskHandle, filePath, (int)loggingMode, groupName, (int)operation); int errorCode = Interop.DAQmxBaseConfigureLogging(taskHandle, filePath, (int)loggingMode, groupName, (int)operation);
if (errorCode < 0) if (errorCode < 0)
throw new DAQmxException(errorCode, "Could not configure technical data management streaming logging"); throw new DAQmxException(errorCode, "Could not configure technical data management streaming logging");
} }
public void CreateAnalogInputVoltageChannel(string physicalChannel, string nameToAssignToChannel, DAQmxInputTerminalConfiguration terminalConfig, double minVal, double maxVal, DAQmxUnits units, string customScaleName) public void CreateAnalogInputVoltageChannel(string physicalChannel, string nameToAssignToChannel, DAQmxInputTerminalConfiguration terminalConfig, double minVal, double maxVal, DAQmxUnits units, string customScaleName)
{ {
int analogInputVoltageChan = Interop.DAQmxCreateAIVoltageChan(taskHandle, physicalChannel, nameToAssignToChannel, (int)terminalConfig, minVal, maxVal, (int)units, customScaleName); int analogInputVoltageChan = Interop.DAQmxBaseCreateAIVoltageChan(taskHandle, physicalChannel, nameToAssignToChannel, (int)terminalConfig, minVal, maxVal, (int)units, customScaleName);
if (analogInputVoltageChan < 0) if (analogInputVoltageChan < 0)
throw new DAQmxException(analogInputVoltageChan, "Could not create analog input voltage channel"); throw new DAQmxException(analogInputVoltageChan, "Could not create analog input voltage channel");
++Channels; ++Channels;
@ -50,7 +50,7 @@ public class DAQmxTask
public void CreateAnalogOutputVoltageChan(string physicalChannel, string nameToAssignToChannel, double minVal, double maxVal, DAQmxUnits units, string customScaleName) public void CreateAnalogOutputVoltageChan(string physicalChannel, string nameToAssignToChannel, double minVal, double maxVal, DAQmxUnits units, string customScaleName)
{ {
int analogOutputVoltageChan = Interop.DAQmxCreateAOVoltageChan(taskHandle, physicalChannel, nameToAssignToChannel, minVal, maxVal, (int)units, customScaleName); int analogOutputVoltageChan = Interop.DAQmxBaseCreateAOVoltageChan(taskHandle, physicalChannel, nameToAssignToChannel, minVal, maxVal, (int)units, customScaleName);
if (analogOutputVoltageChan < 0) if (analogOutputVoltageChan < 0)
throw new DAQmxException(analogOutputVoltageChan, "Could not create analog output voltage channel"); throw new DAQmxException(analogOutputVoltageChan, "Could not create analog output voltage channel");
++Channels; ++Channels;
@ -58,13 +58,13 @@ public class DAQmxTask
public void CreateDigitalOutputChanel(string lines, string nameToAssignToLines, DAQmxLineGrouping lineGrouping) public void CreateDigitalOutputChanel(string lines, string nameToAssignToLines, DAQmxLineGrouping lineGrouping)
{ {
int doChan = Interop.DAQmxCreateDOChan(taskHandle, lines, nameToAssignToLines, (int)lineGrouping); int doChan = Interop.DAQmxBaseCreateDOChan(taskHandle, lines, nameToAssignToLines, (int)lineGrouping);
if (doChan < 0) if (doChan < 0)
throw new DAQmxException(doChan, "Could not create digital output channel"); throw new DAQmxException(doChan, "Could not create digital output channel");
++Channels; ++Channels;
} }
#if unsafe #if !unsafe
public unsafe void ReadAnalogF64(int numSamplesPerChan, double timeout, DAQmxFillMode fillMode, Span<double> data) public unsafe void ReadAnalogF64(int numSamplesPerChan, double timeout, DAQmxFillMode fillMode, Span<double> data)
{ {
int arraySizeInSamples = numSamplesPerChan * Channels; int arraySizeInSamples = numSamplesPerChan * Channels;
@ -73,7 +73,7 @@ public class DAQmxTask
fixed (double* readArray = &data.GetPinnableReference()) fixed (double* readArray = &data.GetPinnableReference())
{ {
IntPtr samplesPerChanRead; IntPtr samplesPerChanRead;
int errorCode = Interop.DAQmxReadAnalogF64(taskHandle, numSamplesPerChan, timeout, (int)fillMode, readArray, (uint)arraySizeInSamples, out samplesPerChanRead, IntPtr.Zero); int errorCode = Interop.DAQmxBaseReadAnalogF64(taskHandle, numSamplesPerChan, timeout, (int)fillMode, readArray, (uint)arraySizeInSamples, out samplesPerChanRead, IntPtr.Zero);
if (errorCode < 0) if (errorCode < 0)
throw new DAQmxException(errorCode, "Could not read samples"); throw new DAQmxException(errorCode, "Could not read samples");
int int32 = samplesPerChanRead.ToInt32(); int int32 = samplesPerChanRead.ToInt32();
@ -88,14 +88,14 @@ public class DAQmxTask
public double ReadAnalogScalarF64(double timeout) public double ReadAnalogScalarF64(double timeout)
{ {
double result; double result;
int errorCode = Interop.DAQmxReadAnalogScalarF64(taskHandle, timeout, out result, IntPtr.Zero); int errorCode = Interop.DAQmxBaseReadAnalogScalarF64(taskHandle, timeout, out result, IntPtr.Zero);
if (errorCode < 0) if (errorCode < 0)
throw new DAQmxException(errorCode, "Could not read samples"); throw new DAQmxException(errorCode, "Could not read samples");
++TotalSamplesRead; ++TotalSamplesRead;
return result; return result;
} }
#if unsafe #if !unsafe
public double ReadAnalogF64(double timeout) public double ReadAnalogF64(double timeout)
{ {
double result = DAQmxReadAnalogF64(timeout); double result = DAQmxReadAnalogF64(timeout);
@ -103,7 +103,7 @@ public class DAQmxTask
} }
#endif #endif
#if unsafe #if !unsafe
private unsafe double DAQmxReadAnalogF64(double timeout) private unsafe double DAQmxReadAnalogF64(double timeout)
{ {
double results; double results;
@ -112,7 +112,7 @@ public class DAQmxTask
IntPtr samplesPerChanRead = IntPtr.Zero; IntPtr samplesPerChanRead = IntPtr.Zero;
double* readArray = stackalloc double[1]; double* readArray = stackalloc double[1];
int fillMode = (int)DAQmxFillMode.GroupByChannel; int fillMode = (int)DAQmxFillMode.GroupByChannel;
int errorCode = Interop.DAQmxReadAnalogF64(taskHandle, int errorCode = Interop.DAQmxBaseReadAnalogF64(taskHandle,
numSamplesPerChan, numSamplesPerChan,
timeout, timeout,
fillMode, fillMode,
@ -129,7 +129,7 @@ public class DAQmxTask
public void Start() public void Start()
{ {
int errorCode = Interop.DAQmxStartTask(taskHandle); int errorCode = Interop.DAQmxBaseStartTask(taskHandle);
if (errorCode < 0) if (errorCode < 0)
throw new DAQmxException(errorCode, "Could not start Task"); throw new DAQmxException(errorCode, "Could not start Task");
TaskStartedUtc = DateTime.UtcNow; TaskStartedUtc = DateTime.UtcNow;
@ -137,21 +137,21 @@ public class DAQmxTask
public void Stop() public void Stop()
{ {
int errorCode = Interop.DAQmxStopTask(taskHandle); int errorCode = Interop.DAQmxBaseStopTask(taskHandle);
if (errorCode < 0) if (errorCode < 0)
throw new DAQmxException(errorCode, "Could not stop Task"); throw new DAQmxException(errorCode, "Could not stop Task");
} }
public void Clear() public void Clear()
{ {
int errorCode = Interop.DAQmxClearTask(taskHandle); int errorCode = Interop.DAQmxBaseClearTask(taskHandle);
if (errorCode < 0) if (errorCode < 0)
throw new DAQmxException(errorCode, "Could not clear Task"); throw new DAQmxException(errorCode, "Could not clear Task");
} }
public void CfgSampleClkTiming(string source, double rate, DAQmxActiveEdge activeEdge, DAQmxSampleMode sampleMode, ulong samplesPerChan) public void CfgSampleClkTiming(string source, double rate, DAQmxActiveEdge activeEdge, DAQmxSampleMode sampleMode, ulong samplesPerChan)
{ {
int errorCode = Interop.DAQmxCfgSampClkTiming(taskHandle, source, rate, (int)activeEdge, (int)sampleMode, samplesPerChan); int errorCode = Interop.DAQmxBaseCfgSampClkTiming(taskHandle, source, rate, (int)activeEdge, (int)sampleMode, samplesPerChan);
if (errorCode < 0) if (errorCode < 0)
throw new DAQmxException(errorCode, "CfgSampleClkTiming failed."); throw new DAQmxException(errorCode, "CfgSampleClkTiming failed.");
DT = 1.0 / SampleClockRate; DT = 1.0 / SampleClockRate;
@ -159,42 +159,42 @@ public class DAQmxTask
public void DAQmxCfgHandshakingTiming(DAQmxSampleMode sampleMode, ulong samplesPerChan) public void DAQmxCfgHandshakingTiming(DAQmxSampleMode sampleMode, ulong samplesPerChan)
{ {
int errorCode = Interop.DAQmxCfgHandshakingTiming(taskHandle, (int)sampleMode, samplesPerChan); int errorCode = Interop.DAQmxBaseCfgHandshakingTiming(taskHandle, (int)sampleMode, samplesPerChan);
if (errorCode < 0) if (errorCode < 0)
throw new DAQmxException(errorCode, "DAQmxCfgHandshakingTiming failed."); throw new DAQmxException(errorCode, "DAQmxCfgHandshakingTiming failed.");
} }
public void DAQmxCfgBurstHandshakingTimingImportClock(DAQmxSampleMode sampleMode, ulong samplesPerChan, double sampleClkRate, string sampleClkSrc, DAQmxPolarity sampleClkActiveEdge, DAQmxLevel pauseWhen, DAQmxPolarity readyEventActiveLevel) public void DAQmxCfgBurstHandshakingTimingImportClock(DAQmxSampleMode sampleMode, ulong samplesPerChan, double sampleClkRate, string sampleClkSrc, DAQmxPolarity sampleClkActiveEdge, DAQmxLevel pauseWhen, DAQmxPolarity readyEventActiveLevel)
{ {
int errorCode = Interop.DAQmxCfgBurstHandshakingTimingImportClock(taskHandle, (int)sampleMode, samplesPerChan, sampleClkRate, sampleClkSrc, (int)sampleClkActiveEdge, (int)pauseWhen, (int)readyEventActiveLevel); int errorCode = Interop.DAQmxBaseCfgBurstHandshakingTimingImportClock(taskHandle, (int)sampleMode, samplesPerChan, sampleClkRate, sampleClkSrc, (int)sampleClkActiveEdge, (int)pauseWhen, (int)readyEventActiveLevel);
if (errorCode < 0) if (errorCode < 0)
throw new DAQmxException(errorCode, "DAQmxCfgBurstHandshakingTimingImportClock failed."); throw new DAQmxException(errorCode, "DAQmxCfgBurstHandshakingTimingImportClock failed.");
} }
public void DAQmxCfgBurstHandshakingTimingExportClock(DAQmxSampleMode sampleMode, ulong samplesPerChan, double sampleClkRate, string sampleClkOutputTerm, DAQmxPolarity sampleClkPulsePolarity, DAQmxLevel pauseWhen, DAQmxPolarity readyEventActiveLevel) public void DAQmxCfgBurstHandshakingTimingExportClock(DAQmxSampleMode sampleMode, ulong samplesPerChan, double sampleClkRate, string sampleClkOutputTerm, DAQmxPolarity sampleClkPulsePolarity, DAQmxLevel pauseWhen, DAQmxPolarity readyEventActiveLevel)
{ {
int errorCode = Interop.DAQmxCfgBurstHandshakingTimingExportClock(taskHandle, (int)sampleMode, samplesPerChan, sampleClkRate, sampleClkOutputTerm, (int)sampleClkPulsePolarity, (int)pauseWhen, (int)readyEventActiveLevel); int errorCode = Interop.DAQmxBaseCfgBurstHandshakingTimingExportClock(taskHandle, (int)sampleMode, samplesPerChan, sampleClkRate, sampleClkOutputTerm, (int)sampleClkPulsePolarity, (int)pauseWhen, (int)readyEventActiveLevel);
if (errorCode < 0) if (errorCode < 0)
throw new DAQmxException(errorCode, "DAQmxCfgBurstHandshakingTimingExportClock failed."); throw new DAQmxException(errorCode, "DAQmxCfgBurstHandshakingTimingExportClock failed.");
} }
public void DAQmxCfgChangeDetectionTiming(string risingEdgeChan, string fallingEdgeChan, DAQmxSampleMode sampleMode, ulong samplesPerChan) public void DAQmxCfgChangeDetectionTiming(string risingEdgeChan, string fallingEdgeChan, DAQmxSampleMode sampleMode, ulong samplesPerChan)
{ {
int errorCode = Interop.DAQmxCfgChangeDetectionTiming(taskHandle, risingEdgeChan, fallingEdgeChan, (int)sampleMode, samplesPerChan); int errorCode = Interop.DAQmxBaseCfgChangeDetectionTiming(taskHandle, risingEdgeChan, fallingEdgeChan, (int)sampleMode, samplesPerChan);
if (errorCode < 0) if (errorCode < 0)
throw new DAQmxException(errorCode, "DAQmxCfgChangeDetectionTiming failed."); throw new DAQmxException(errorCode, "DAQmxCfgChangeDetectionTiming failed.");
} }
public void DAQmxCfgImplicitTiming(DAQmxSampleMode sampleMode, ulong samplesPerChan) public void DAQmxCfgImplicitTiming(DAQmxSampleMode sampleMode, ulong samplesPerChan)
{ {
int errorCode = Interop.DAQmxCfgImplicitTiming(taskHandle, (int)sampleMode, samplesPerChan); int errorCode = Interop.DAQmxBaseCfgImplicitTiming(taskHandle, (int)sampleMode, samplesPerChan);
if (errorCode < 0) if (errorCode < 0)
throw new DAQmxException(errorCode, "DAQmxCfgImplicitTiming failed."); throw new DAQmxException(errorCode, "DAQmxCfgImplicitTiming failed.");
} }
public void DAQmxCfgPipelinedSampleClkTiming(string source, double rate, DAQmxActiveEdge activeEdge, DAQmxSampleMode sampleMode, ulong samplesPerChan) public void DAQmxCfgPipelinedSampleClkTiming(string source, double rate, DAQmxActiveEdge activeEdge, DAQmxSampleMode sampleMode, ulong samplesPerChan)
{ {
int errorCode = Interop.DAQmxCfgPipelinedSampClkTiming(taskHandle, source, rate, (int)activeEdge, (int)sampleMode, samplesPerChan); int errorCode = Interop.DAQmxBaseCfgPipelinedSampClkTiming(taskHandle, source, rate, (int)activeEdge, (int)sampleMode, samplesPerChan);
if (errorCode < 0) if (errorCode < 0)
throw new DAQmxException(errorCode, "DAQmxCfgPipelinedSampleClkTiming failed."); throw new DAQmxException(errorCode, "DAQmxCfgPipelinedSampleClkTiming failed.");
} }
@ -204,14 +204,14 @@ public class DAQmxTask
get get
{ {
double result = 0.0; double result = 0.0;
int sampleClkRate = Interop.DAQmxGetSampClkRate(taskHandle, ref result); int sampleClkRate = Interop.DAQmxBaseGetSampClkRate(taskHandle, ref result);
if (sampleClkRate < 0) if (sampleClkRate < 0)
throw new DAQmxException(sampleClkRate, "Could not get SampleClockRate"); throw new DAQmxException(sampleClkRate, "Could not get SampleClockRate");
return result; return result;
} }
set set
{ {
int errorCode = Interop.DAQmxSetSampClkRate(taskHandle, value); int errorCode = Interop.DAQmxBaseSetSampClkRate(taskHandle, value);
if (errorCode < 0) if (errorCode < 0)
throw new DAQmxException(errorCode, "Could not set SampleClockRate"); throw new DAQmxException(errorCode, "Could not set SampleClockRate");
} }
@ -222,7 +222,7 @@ public class DAQmxTask
get get
{ {
double result = 0.0; double result = 0.0;
int sampleClkMaxRate = Interop.DAQmxGetSampClkMaxRate(taskHandle, ref result); int sampleClkMaxRate = Interop.DAQmxBaseGetSampClkMaxRate(taskHandle, ref result);
if (sampleClkMaxRate < 0) if (sampleClkMaxRate < 0)
throw new DAQmxException(sampleClkMaxRate, "Could not get SampleClockMaxRate"); throw new DAQmxException(sampleClkMaxRate, "Could not get SampleClockMaxRate");
return result; return result;
@ -231,21 +231,21 @@ public class DAQmxTask
public void DisableStartTrig() public void DisableStartTrig()
{ {
int errorCode = Interop.DAQmxDisableStartTrig(taskHandle); int errorCode = Interop.DAQmxBaseDisableStartTrig(taskHandle);
if (errorCode < 0) if (errorCode < 0)
throw new DAQmxException(errorCode, "DisableStartTrig failed."); throw new DAQmxException(errorCode, "DisableStartTrig failed.");
} }
public void CfgDigEdgeStartTrig(string triggerSource, DAQmxEdge triggerEdge) public void CfgDigEdgeStartTrig(string triggerSource, DAQmxEdge triggerEdge)
{ {
int errorCode = Interop.DAQmxCfgDigEdgeStartTrig(taskHandle, triggerSource, (int)triggerEdge); int errorCode = Interop.DAQmxBaseCfgDigEdgeStartTrig(taskHandle, triggerSource, (int)triggerEdge);
if (errorCode < 0) if (errorCode < 0)
throw new DAQmxException(errorCode, "CfgDigEdgeStartTrig failed."); throw new DAQmxException(errorCode, "CfgDigEdgeStartTrig failed.");
} }
public void CfgAnalogEdgeStartTrig(string triggerSource, DAQmxEdge triggerSlope, double triggerLevel) public void CfgAnalogEdgeStartTrig(string triggerSource, DAQmxEdge triggerSlope, double triggerLevel)
{ {
int errorCode = Interop.DAQmxCfgAnlgEdgeStartTrig(taskHandle, triggerSource, (int)triggerSlope, triggerLevel); int errorCode = Interop.DAQmxBaseCfgAnlgEdgeStartTrig(taskHandle, triggerSource, (int)triggerSlope, triggerLevel);
if (errorCode < 0) if (errorCode < 0)
throw new DAQmxException(errorCode, "CfgAnalogEdgeStartTrig failed."); throw new DAQmxException(errorCode, "CfgAnalogEdgeStartTrig failed.");
} }
@ -255,42 +255,42 @@ public class DAQmxTask
public void CfgAnalogWindowStartTrig(string triggerSource, DAQmxWindowTriggerWhen triggerWhen, double windowTop, double windowBottom) public void CfgAnalogWindowStartTrig(string triggerSource, DAQmxWindowTriggerWhen triggerWhen, double windowTop, double windowBottom)
{ {
int errorCode = Interop.DAQmxCfgAnlgWindowStartTrig(taskHandle, triggerSource, (int)triggerWhen, windowTop, windowBottom); int errorCode = Interop.DAQmxBaseCfgAnlgWindowStartTrig(taskHandle, triggerSource, (int)triggerWhen, windowTop, windowBottom);
if (errorCode < 0) if (errorCode < 0)
throw new DAQmxException(errorCode, "CfgAnalogWindowStartTrig failed."); throw new DAQmxException(errorCode, "CfgAnalogWindowStartTrig failed.");
} }
public void CfgTimeStartTrig(CVIAbsoluteTime when, DAQmxTimescale timescale) public void CfgTimeStartTrig(CVIAbsoluteTime when, DAQmxTimescale timescale)
{ {
int errorCode = Interop.DAQmxCfgTimeStartTrig(taskHandle, when, (int)timescale); int errorCode = Interop.DAQmxBaseCfgTimeStartTrig(taskHandle, when, (int)timescale);
if (errorCode < 0) if (errorCode < 0)
throw new DAQmxException(errorCode, "CfgTimeStartTrig failed."); throw new DAQmxException(errorCode, "CfgTimeStartTrig failed.");
} }
public void CfgDigPatternStartTrig(string triggerSource, string triggerPattern, DAQmxDigitalPatternTriggerWhen triggerWhen) public void CfgDigPatternStartTrig(string triggerSource, string triggerPattern, DAQmxDigitalPatternTriggerWhen triggerWhen)
{ {
int errorCode = Interop.DAQmxCfgDigPatternStartTrig(taskHandle, triggerSource, triggerPattern, (int)triggerWhen); int errorCode = Interop.DAQmxBaseCfgDigPatternStartTrig(taskHandle, triggerSource, triggerPattern, (int)triggerWhen);
if (errorCode < 0) if (errorCode < 0)
throw new DAQmxException(errorCode, "CfgDigPatternStartTrig failed."); throw new DAQmxException(errorCode, "CfgDigPatternStartTrig failed.");
} }
public void DisableRefTrig() public void DisableRefTrig()
{ {
int errorCode = Interop.DAQmxDisableRefTrig(taskHandle); int errorCode = Interop.DAQmxBaseDisableRefTrig(taskHandle);
if (errorCode < 0) if (errorCode < 0)
throw new DAQmxException(errorCode, "DisableRefTrig failed."); throw new DAQmxException(errorCode, "DisableRefTrig failed.");
} }
public void CfgDigEdgeRefTrig(string triggerSource, DAQmxEdge triggerEdge, uint pretriggerSamples) public void CfgDigEdgeRefTrig(string triggerSource, DAQmxEdge triggerEdge, uint pretriggerSamples)
{ {
int errorCode = Interop.DAQmxCfgDigEdgeRefTrig(taskHandle, triggerSource, (int)triggerEdge, pretriggerSamples); int errorCode = Interop.DAQmxBaseCfgDigEdgeRefTrig(taskHandle, triggerSource, (int)triggerEdge, pretriggerSamples);
if (errorCode < 0) if (errorCode < 0)
throw new DAQmxException(errorCode, "CfgDigEdgeRefTrig failed."); throw new DAQmxException(errorCode, "CfgDigEdgeRefTrig failed.");
} }
public void CfgAnalogEdgeRefTrig(string triggerSource, DAQmxEdge triggerSlope, double triggerLevel, uint pretriggerSamples) public void CfgAnalogEdgeRefTrig(string triggerSource, DAQmxEdge triggerSlope, double triggerLevel, uint pretriggerSamples)
{ {
int errorCode = Interop.DAQmxCfgAnlgEdgeRefTrig(taskHandle, triggerSource, (int)triggerSlope, triggerLevel, pretriggerSamples); int errorCode = Interop.DAQmxBaseCfgAnlgEdgeRefTrig(taskHandle, triggerSource, (int)triggerSlope, triggerLevel, pretriggerSamples);
if (errorCode < 0) if (errorCode < 0)
throw new DAQmxException(errorCode, "CfgAnalogEdgeRefTrig failed."); throw new DAQmxException(errorCode, "CfgAnalogEdgeRefTrig failed.");
} }
@ -300,14 +300,14 @@ public class DAQmxTask
public void CfgAnalogWindowRefTrig(string triggerSource, DAQmxWindowTriggerWhen triggerWhen, double windowTop, double windowBottom, uint pretriggerSamples) public void CfgAnalogWindowRefTrig(string triggerSource, DAQmxWindowTriggerWhen triggerWhen, double windowTop, double windowBottom, uint pretriggerSamples)
{ {
int errorCode = Interop.DAQmxCfgAnlgWindowRefTrig(taskHandle, triggerSource, (int)triggerWhen, windowTop, windowBottom, pretriggerSamples); int errorCode = Interop.DAQmxBaseCfgAnlgWindowRefTrig(taskHandle, triggerSource, (int)triggerWhen, windowTop, windowBottom, pretriggerSamples);
if (errorCode < 0) if (errorCode < 0)
throw new DAQmxException(errorCode, "CfgAnalogWindowRefTrig failed."); throw new DAQmxException(errorCode, "CfgAnalogWindowRefTrig failed.");
} }
public void CfgDigPatternRefTrig(string triggerSource, string triggerPattern, DAQmxDigitalPatternTriggerWhen triggerWhen, uint pretriggerSamples) public void CfgDigPatternRefTrig(string triggerSource, string triggerPattern, DAQmxDigitalPatternTriggerWhen triggerWhen, uint pretriggerSamples)
{ {
int errorCode = Interop.DAQmxCfgDigPatternRefTrig(taskHandle, triggerSource, triggerPattern, (int)triggerWhen, pretriggerSamples); int errorCode = Interop.DAQmxBaseCfgDigPatternRefTrig(taskHandle, triggerSource, triggerPattern, (int)triggerWhen, pretriggerSamples);
if (errorCode < 0) if (errorCode < 0)
throw new DAQmxException(errorCode, "CfgDigPatternRefTrig failed."); throw new DAQmxException(errorCode, "CfgDigPatternRefTrig failed.");
} }
@ -318,7 +318,7 @@ public class DAQmxTask
if (data.Length < num) if (data.Length < num)
throw new DAQmxMemoryException("Span length too short. (Span length: " + data.Length.ToString() + ", required length: " + num.ToString() + ")"); throw new DAQmxMemoryException("Span length too short. (Span length: " + data.Length.ToString() + ", required length: " + num.ToString() + ")");
IntPtr samplesPerChanWritten; IntPtr samplesPerChanWritten;
int errorCode = Interop.DAQmxWriteAnalogF64(taskHandle, numSamplesPerChan, autoStart, timeout, dataLayout > DAQmxDataLayout.GroupByChannel, data.ToArray(), out samplesPerChanWritten, IntPtr.Zero); int errorCode = Interop.DAQmxBaseWriteAnalogF64(taskHandle, numSamplesPerChan, autoStart, timeout, dataLayout > DAQmxDataLayout.GroupByChannel, data.ToArray(), out samplesPerChanWritten, IntPtr.Zero);
if (errorCode < 0) if (errorCode < 0)
throw new DAQmxException(errorCode, "Could not write samples"); throw new DAQmxException(errorCode, "Could not write samples");
int int32 = samplesPerChanWritten.ToInt32(); int int32 = samplesPerChanWritten.ToInt32();
@ -334,7 +334,7 @@ public class DAQmxTask
if (data.Length < num) if (data.Length < num)
throw new DAQmxMemoryException("Span length too short. (Span length: " + data.Length.ToString() + ", required length: " + num.ToString() + ")"); throw new DAQmxMemoryException("Span length too short. (Span length: " + data.Length.ToString() + ", required length: " + num.ToString() + ")");
IntPtr samplesPerChanWritten; IntPtr samplesPerChanWritten;
int errorCode = Interop.DAQmxWriteDigitalLines(taskHandle, numSamplesPerChan, autoStart, timeout, dataLayout > DAQmxDataLayout.GroupByChannel, data.ToArray(), out samplesPerChanWritten, IntPtr.Zero); int errorCode = Interop.DAQmxBaseWriteDigitalLines(taskHandle, numSamplesPerChan, autoStart, timeout, dataLayout > DAQmxDataLayout.GroupByChannel, data.ToArray(), out samplesPerChanWritten, IntPtr.Zero);
if (errorCode < 0) if (errorCode < 0)
throw new DAQmxException(errorCode, "Could not write samples"); throw new DAQmxException(errorCode, "Could not write samples");
int int32 = samplesPerChanWritten.ToInt32(); int int32 = samplesPerChanWritten.ToInt32();

View File

@ -10,7 +10,7 @@ namespace Helpers.DAQmx;
internal class Interop internal class Interop
{ // cSpell:disable { // cSpell:disable
private const string lib = "DAQmx"; private const string lib = "DAQmxBase";
private static IntPtr libHandle = IntPtr.Zero; private static IntPtr libHandle = IntPtr.Zero;
static Interop() => static Interop() =>
@ -18,7 +18,7 @@ internal class Interop
private static IntPtr ImportResolver(string libraryName, Assembly assembly, DllImportSearchPath? searchPath) private static IntPtr ImportResolver(string libraryName, Assembly assembly, DllImportSearchPath? searchPath)
{ {
if (libraryName == "DAQmx" && !(libHandle != IntPtr.Zero)) if (libraryName == "DAQmxBase" && !(libHandle != IntPtr.Zero))
{ {
bool loaded; bool loaded;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
@ -41,20 +41,20 @@ internal class Interop
return libHandle; return libHandle;
} }
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
internal static extern int DAQmxGetSampClkRate(IntPtr taskHandle, ref double data); internal static extern int DAQmxBaseGetSampClkRate(IntPtr taskHandle, ref double data);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
internal static extern int DAQmxSetSampClkRate(IntPtr taskHandle, double data); internal static extern int DAQmxBaseSetSampClkRate(IntPtr taskHandle, double data);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
internal static extern int DAQmxGetSampClkMaxRate(IntPtr taskHandle, ref double data); internal static extern int DAQmxBaseGetSampClkMaxRate(IntPtr taskHandle, ref double data);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
internal static extern int DAQmxSetWriteRegenMode(IntPtr taskHandle, int data); internal static extern int DAQmxBaseSetWriteRegenMode(IntPtr taskHandle, int data);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
internal static extern int DAQmxCreateAIVoltageChan( internal static extern int DAQmxBaseCreateAIVoltageChan(
IntPtr taskHandle, IntPtr taskHandle,
string physicalChannel, string physicalChannel,
string nameToAssignToChannel, string nameToAssignToChannel,
@ -64,8 +64,8 @@ internal class Interop
int units, int units,
string customScaleName); string customScaleName);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
internal static extern int DAQmxCreateAOVoltageChan( internal static extern int DAQmxBaseCreateAOVoltageChan(
IntPtr taskHandle, IntPtr taskHandle,
string physicalChannel, string physicalChannel,
string nameToAssignToChannel, string nameToAssignToChannel,
@ -74,22 +74,22 @@ internal class Interop
int units, int units,
string customScaleName); string customScaleName);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
internal static extern int DAQmxCreateDOChan( internal static extern int DAQmxBaseCreateDOChan(
IntPtr taskHandle, IntPtr taskHandle,
string lines, string lines,
string nameToAssignToLines, string nameToAssignToLines,
int lineGrouping); int lineGrouping);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
public static extern int DAQmxGetErrorString( public static extern int DAQmxBaseGetErrorString(
int errorCode, int errorCode,
StringBuilder errorString, StringBuilder errorString,
uint buffersize); uint buffersize);
#if unsafe #if !unsafe
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
public static extern unsafe int DAQmxReadAnalogF64( public static extern unsafe int DAQmxBaseReadAnalogF64(
IntPtr taskHandle, IntPtr taskHandle,
int numSampsPerChan, int numSampsPerChan,
double timeout, double timeout,
@ -100,16 +100,16 @@ internal class Interop
IntPtr reserved); IntPtr reserved);
#endif #endif
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
public static extern int DAQmxReadAnalogScalarF64( public static extern int DAQmxBaseReadAnalogScalarF64(
IntPtr taskHandle, IntPtr taskHandle,
double timeout, double timeout,
out double value, out double value,
IntPtr reserved); IntPtr reserved);
#if unsafe #if unsafe
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
public static extern unsafe int DAQmxReadBinaryI16( public static extern unsafe int DAQmxBaseReadBinaryI16(
IntPtr taskHandle, IntPtr taskHandle,
int numSampsPerChan, int numSampsPerChan,
double timeout, double timeout,
@ -121,8 +121,8 @@ internal class Interop
#endif #endif
#if unsafe #if unsafe
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
public static extern unsafe int DAQmxReadBinaryU16( public static extern unsafe int DAQmxBaseReadBinaryU16(
IntPtr taskHandle, IntPtr taskHandle,
int numSampsPerChan, int numSampsPerChan,
double timeout, double timeout,
@ -134,8 +134,8 @@ internal class Interop
#endif #endif
#if unsafe #if unsafe
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
public static extern unsafe int DAQmxReadBinaryI32( public static extern unsafe int DAQmxBaseReadBinaryI32(
IntPtr taskHandle, IntPtr taskHandle,
int numSampsPerChan, int numSampsPerChan,
double timeout, double timeout,
@ -147,8 +147,8 @@ internal class Interop
#endif #endif
#if unsafe #if unsafe
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
public static extern unsafe int DAQmxReadBinaryU32( public static extern unsafe int DAQmxBaseReadBinaryU32(
IntPtr taskHandle, IntPtr taskHandle,
int numSampsPerChan, int numSampsPerChan,
double timeout, double timeout,
@ -159,59 +159,59 @@ internal class Interop
IntPtr reserved); IntPtr reserved);
#endif #endif
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
public static extern int DAQmxConfigureLogging( public static extern int DAQmxBaseConfigureLogging(
IntPtr taskHandle, IntPtr taskHandle,
string filePath, string filePath,
int loggingMode, int loggingMode,
string groupName, string groupName,
int operation); int operation);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
internal static extern int DAQmxLoadTask(string taskName, out IntPtr taskHandle); internal static extern int DAQmxBaseLoadTask(string taskName, out IntPtr taskHandle);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
internal static extern int DAQmxCreateTask(string taskName, out IntPtr taskHandle); internal static extern int DAQmxBaseCreateTask(string taskName, out IntPtr taskHandle);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
internal static extern int DAQmxAddGlobalChansToTask(IntPtr taskHandle, string[] channelNames); internal static extern int DAQmxBaseAddGlobalChansToTask(IntPtr taskHandle, string[] channelNames);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
internal static extern int DAQmxStartTask(IntPtr taskHandle); internal static extern int DAQmxBaseStartTask(IntPtr taskHandle);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
internal static extern int DAQmxStopTask(IntPtr taskHandle); internal static extern int DAQmxBaseStopTask(IntPtr taskHandle);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
internal static extern int DAQmxClearTask(IntPtr taskHandle); internal static extern int DAQmxBaseClearTask(IntPtr taskHandle);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
internal static extern int DAQmxWaitUntilTaskDone(IntPtr taskHandle, double timeToWait); internal static extern int DAQmxBaseWaitUntilTaskDone(IntPtr taskHandle, double timeToWait);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
internal static extern int DAQmxWaitForValidTimestamp( internal static extern int DAQmxBaseWaitForValidTimestamp(
IntPtr taskHandle, IntPtr taskHandle,
int timestampEvent, int timestampEvent,
double timeout, double timeout,
CVIAbsoluteTime timestamp); CVIAbsoluteTime timestamp);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
internal static extern int DAQmxIsTaskDone(IntPtr taskHandle, out uint isTaskDone); internal static extern int DAQmxBaseIsTaskDone(IntPtr taskHandle, out uint isTaskDone);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
internal static extern int DAQmxTaskControl(IntPtr taskHandle); internal static extern int DAQmxBaseTaskControl(IntPtr taskHandle);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
internal static extern int DAQmxGetNthTaskChannel(IntPtr taskHandle); internal static extern int DAQmxBaseGetNthTaskChannel(IntPtr taskHandle);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
internal static extern int DAQmxGetNthTaskDevice(IntPtr taskHandle); internal static extern int DAQmxBaseGetNthTaskDevice(IntPtr taskHandle);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
internal static extern int DAQmxGetTaskAttribute(IntPtr taskHandle); internal static extern int DAQmxBaseGetTaskAttribute(IntPtr taskHandle);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
internal static extern int DAQmxCfgSampClkTiming( internal static extern int DAQmxBaseCfgSampClkTiming(
IntPtr taskHandle, IntPtr taskHandle,
string source, string source,
double rate, double rate,
@ -219,14 +219,14 @@ internal class Interop
int sampleMode, int sampleMode,
ulong sampsPerChan); ulong sampsPerChan);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
internal static extern int DAQmxCfgHandshakingTiming( internal static extern int DAQmxBaseCfgHandshakingTiming(
IntPtr taskHandle, IntPtr taskHandle,
int sampleMode, int sampleMode,
ulong sampsPerChan); ulong sampsPerChan);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
internal static extern int DAQmxCfgBurstHandshakingTimingImportClock( internal static extern int DAQmxBaseCfgBurstHandshakingTimingImportClock(
IntPtr taskHandle, IntPtr taskHandle,
int sampleMode, int sampleMode,
ulong sampsPerChan, ulong sampsPerChan,
@ -236,8 +236,8 @@ internal class Interop
int pauseWhen, int pauseWhen,
int readyEventActiveLevel); int readyEventActiveLevel);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
internal static extern int DAQmxCfgBurstHandshakingTimingExportClock( internal static extern int DAQmxBaseCfgBurstHandshakingTimingExportClock(
IntPtr taskHandle, IntPtr taskHandle,
int sampleMode, int sampleMode,
ulong sampsPerChan, ulong sampsPerChan,
@ -247,22 +247,22 @@ internal class Interop
int pauseWhen, int pauseWhen,
int readyEventActiveLevel); int readyEventActiveLevel);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
internal static extern int DAQmxCfgChangeDetectionTiming( internal static extern int DAQmxBaseCfgChangeDetectionTiming(
IntPtr taskHandle, IntPtr taskHandle,
string risingEdgeChan, string risingEdgeChan,
string fallingEdgeChan, string fallingEdgeChan,
int sampleMode, int sampleMode,
ulong sampsPerChan); ulong sampsPerChan);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
internal static extern int DAQmxCfgImplicitTiming( internal static extern int DAQmxBaseCfgImplicitTiming(
IntPtr taskHandle, IntPtr taskHandle,
int sampleMode, int sampleMode,
ulong sampsPerChan); ulong sampsPerChan);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
internal static extern int DAQmxCfgPipelinedSampClkTiming( internal static extern int DAQmxBaseCfgPipelinedSampClkTiming(
IntPtr taskHandle, IntPtr taskHandle,
string source, string source,
double rate, double rate,
@ -270,106 +270,106 @@ internal class Interop
int sampleMode, int sampleMode,
ulong sampsPerChan); ulong sampsPerChan);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
internal static extern int DAQmxGetTimingAttribute( internal static extern int DAQmxBaseGetTimingAttribute(
IntPtr taskHandle, IntPtr taskHandle,
int attribute, int attribute,
out object value); out object value);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
internal static extern int DAQmxSetTimingAttribute( internal static extern int DAQmxBaseSetTimingAttribute(
IntPtr taskHandle, IntPtr taskHandle,
int attribute, int attribute,
object value); object value);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
internal static extern int DAQmxResetTimingAttribute(IntPtr taskHandle, int attribute); internal static extern int DAQmxBaseResetTimingAttribute(IntPtr taskHandle, int attribute);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
internal static extern int DAQmxGetTimingAttributeEx( internal static extern int DAQmxBaseGetTimingAttributeEx(
IntPtr taskHandle, IntPtr taskHandle,
string deviceNames, string deviceNames,
int attribute, int attribute,
out object value); out object value);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
internal static extern int DAQmxSetTimingAttributeEx( internal static extern int DAQmxBaseSetTimingAttributeEx(
IntPtr taskHandle, IntPtr taskHandle,
string deviceNames, string deviceNames,
int attribute, int attribute,
object value); object value);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
internal static extern int DAQmxResetTimingAttributeEx( internal static extern int DAQmxBaseResetTimingAttributeEx(
IntPtr taskHandle, IntPtr taskHandle,
string deviceNames, string deviceNames,
int attribute); int attribute);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
public static extern int DAQmxDisableStartTrig(IntPtr taskHandle); public static extern int DAQmxBaseDisableStartTrig(IntPtr taskHandle);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
public static extern int DAQmxCfgDigEdgeStartTrig( public static extern int DAQmxBaseCfgDigEdgeStartTrig(
IntPtr taskHandle, IntPtr taskHandle,
string triggerSource, string triggerSource,
int triggerEdge); int triggerEdge);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
public static extern int DAQmxCfgAnlgEdgeStartTrig( public static extern int DAQmxBaseCfgAnlgEdgeStartTrig(
IntPtr taskHandle, IntPtr taskHandle,
string triggerSource, string triggerSource,
int triggerSlope, int triggerSlope,
double triggerLevel); double triggerLevel);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
public static extern int DAQmxCfgAnlgMultiEdgeStartTrig( public static extern int DAQmxBaseCfgAnlgMultiEdgeStartTrig(
IntPtr taskHandle, IntPtr taskHandle,
string triggerSources, string triggerSources,
int[] triggerSlopeArray, int[] triggerSlopeArray,
double[] triggerLevelArray, double[] triggerLevelArray,
uint arraySize); uint arraySize);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
public static extern int DAQmxCfgAnlgWindowStartTrig( public static extern int DAQmxBaseCfgAnlgWindowStartTrig(
IntPtr taskHandle, IntPtr taskHandle,
string triggerSource, string triggerSource,
int triggerWhen, int triggerWhen,
double windowTop, double windowTop,
double windowBottom); double windowBottom);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
public static extern int DAQmxCfgTimeStartTrig( public static extern int DAQmxBaseCfgTimeStartTrig(
IntPtr taskHandle, IntPtr taskHandle,
CVIAbsoluteTime when, CVIAbsoluteTime when,
int timescale); int timescale);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
public static extern int DAQmxCfgDigPatternStartTrig( public static extern int DAQmxBaseCfgDigPatternStartTrig(
IntPtr taskHandle, IntPtr taskHandle,
string triggerSource, string triggerSource,
string triggerPattern, string triggerPattern,
int triggerWhen); int triggerWhen);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
public static extern int DAQmxDisableRefTrig(IntPtr taskHandle); public static extern int DAQmxBaseDisableRefTrig(IntPtr taskHandle);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
public static extern int DAQmxCfgDigEdgeRefTrig( public static extern int DAQmxBaseCfgDigEdgeRefTrig(
IntPtr taskHandle, IntPtr taskHandle,
string triggerSource, string triggerSource,
int triggerEdge, int triggerEdge,
uint pretriggerSamples); uint pretriggerSamples);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
public static extern int DAQmxCfgAnlgEdgeRefTrig( public static extern int DAQmxBaseCfgAnlgEdgeRefTrig(
IntPtr taskHandle, IntPtr taskHandle,
string triggerSource, string triggerSource,
int triggerSlope, int triggerSlope,
double triggerLevel, double triggerLevel,
uint pretriggerSamples); uint pretriggerSamples);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
public static extern int DAQmxCfgAnlgMultiEdgeRefTrig( public static extern int DAQmxBaseCfgAnlgMultiEdgeRefTrig(
IntPtr taskHandle, IntPtr taskHandle,
string triggerSources, string triggerSources,
int[] triggerSlopeArray, int[] triggerSlopeArray,
@ -377,8 +377,8 @@ internal class Interop
uint pretriggerSamples, uint pretriggerSamples,
uint arraySize); uint arraySize);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
public static extern int DAQmxCfgAnlgWindowRefTrig( public static extern int DAQmxBaseCfgAnlgWindowRefTrig(
IntPtr taskHandle, IntPtr taskHandle,
string triggerSource, string triggerSource,
int triggerWhen, int triggerWhen,
@ -386,28 +386,28 @@ internal class Interop
double windowBottom, double windowBottom,
uint pretriggerSamples); uint pretriggerSamples);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
public static extern int DAQmxCfgDigPatternRefTrig( public static extern int DAQmxBaseCfgDigPatternRefTrig(
IntPtr taskHandle, IntPtr taskHandle,
string triggerSource, string triggerSource,
string triggerPattern, string triggerPattern,
int triggerWhen, int triggerWhen,
uint pretriggerSamples); uint pretriggerSamples);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
public static extern int DAQmxGetTrigAttribute( public static extern int DAQmxBaseGetTrigAttribute(
IntPtr taskHandle, IntPtr taskHandle,
int attribute, int attribute,
out object value); out object value);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
public static extern int DAQmxSetTrigAttribute(IntPtr taskHandle, int attribute, object value); public static extern int DAQmxBaseSetTrigAttribute(IntPtr taskHandle, int attribute, object value);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
public static extern int DAQmxResetTrigAttribute(IntPtr taskHandle, int attribute); public static extern int DAQmxBaseResetTrigAttribute(IntPtr taskHandle, int attribute);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
public static extern int DAQmxWriteAnalogF64( public static extern int DAQmxBaseWriteAnalogF64(
IntPtr taskHandle, IntPtr taskHandle,
int numSampsPerChan, int numSampsPerChan,
bool autoStart, bool autoStart,
@ -417,8 +417,8 @@ internal class Interop
out IntPtr sampsPerChanWritten, out IntPtr sampsPerChanWritten,
IntPtr reserved); IntPtr reserved);
[DllImport("DAQmx", CallingConvention = CallingConvention.StdCall)] [DllImport("DAQmxBase", CallingConvention = CallingConvention.StdCall)]
public static extern int DAQmxWriteDigitalLines( public static extern int DAQmxBaseWriteDigitalLines(
IntPtr taskHandle, IntPtr taskHandle,
int numSampsPerChan, int numSampsPerChan,
bool autoStart, bool autoStart,

View File

@ -39,7 +39,8 @@ internal static partial class NationalInstrumentsHelper
foreach (KeyValuePair<string, DAQmxTask> keyValuePair in _DataAcquisitionTasks) foreach (KeyValuePair<string, DAQmxTask> keyValuePair in _DataAcquisitionTasks)
{ {
if (appSettings.NationalInstrumentsConfiguration.UsePointerMethod) if (appSettings.NationalInstrumentsConfiguration.UsePointerMethod)
throw new NotSupportedException("Pointer method is not supported in this implementation."); value = keyValuePair.Value.ReadAnalogF64(appSettings.NationalInstrumentsConfiguration.ReadTimeout);
else
value = keyValuePair.Value.ReadAnalogScalarF64(appSettings.NationalInstrumentsConfiguration.ReadTimeout); value = keyValuePair.Value.ReadAnalogScalarF64(appSettings.NationalInstrumentsConfiguration.ReadTimeout);
logger.LogInformation("{key}-{read}: {value}", keyValuePair.Key, keyValuePair.Value.TotalSamplesRead, value); logger.LogInformation("{key}-{read}: {value}", keyValuePair.Key, keyValuePair.Value.TotalSamplesRead, value);
} }

View File

@ -43,11 +43,6 @@ public partial class Worker : BackgroundService
private async Task Body(CancellationToken cancellationToken) private async Task Body(CancellationToken cancellationToken)
{ {
if (!_IsWindowsService)
{
_Logger.LogInformation("Set break point and skip to run {_AppSettings.FileWatcherConfiguration.Helper}!", _AppSettings.FileWatcherConfiguration.Helper);
throw new EvaluateException($"Set break point and skip to run {_AppSettings.FileWatcherConfiguration.Helper}!");
}
if (!_IsWindowsService) if (!_IsWindowsService)
{ {
for (int i = 0; i < int.MaxValue; i++) for (int i = 0; i < int.MaxValue; i++)