Skip to content

Commit

Permalink
Merge pull request #2037 from AllenInstitute/bugfix/2037-workaround_f…
Browse files Browse the repository at this point in the history
…or_fifo2wave_igor_bug-backport

bugfix: FIFO2WAVE does not work with single point ranges
  • Loading branch information
t-b authored Mar 11, 2024
2 parents f042655 + 2be4a2c commit 1d38644
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
10 changes: 6 additions & 4 deletions Packages/MIES/MIES_DataAcquisition_Multi.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Function DQM_FIFOMonitor(s)
STRUCT BackgroundStruct &s

variable deviceID, isFinished, hardwareType
variable i, j, err, fifoLatest, result, channel, lastTP, gotTPChannels
variable i, j, err, fifoLatest, result, channel, lastTP, gotTPChannels, newSamplesCount
variable bufferSize
string device, fifoChannelName, fifoName, errMsg
WAVE ActiveDeviceList = GetDQMActiveDeviceList()
Expand Down Expand Up @@ -44,7 +44,9 @@ Function DQM_FIFOMonitor(s)
fifoName = GetNIFIFOName(deviceID)
FIFOStatus/Q $fifoName
ASSERT(V_Flag != 0,"FIFO does not exist!")
if(fifoPosGlobal == V_FIFOChunks)
newSamplesCount = V_FIFOChunks - fifoPosGlobal
if(newSamplesCount < 2)
// workaround for Igor Pro bug 5092
continue // no new data -> next device
endif

Expand All @@ -55,11 +57,11 @@ Function DQM_FIFOMonitor(s)
fifoChannelName = StringByKey("NAME" + num2str(j), S_Info)
channel = str2num(fifoChannelName)
WAVE NIChannel = NIDataWave[channel]
FIFO2WAVE/R=[fifoPosGlobal, fifoPosGlobal + newSamplesCount - 1] $fifoName, $fifoChannelName, wNIReadOut; AbortOnRTE

bufferSize = DimSize(NIChannel, ROWS)
fifoLatest = min(V_FIFOChunks, bufferSize)
isFinished = (fifoLatest == bufferSize) ? 1 : isFinished

FIFO2WAVE/R=[fifoPosGlobal, fifoLatest - 1] $fifoName, $fifoChannelName, wNIReadOut; AbortOnRTE
multithread NIChannel[fifoPosGlobal, fifoLatest - 1] = wNIReadOut[p - fifoPosGlobal]
SetScale/P x, 0, DimDelta(wNIReadOut, ROWS) * ONE_TO_MILLI, "ms", NIChannel

Expand Down
19 changes: 19 additions & 0 deletions Packages/tests/HardwareBasic/UTF_BasicHardwareTests.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -2271,3 +2271,22 @@ End
static Function CheckIfNoTTLonTP_REENTRY([string str])
PASS()
End

#ifdef TESTS_WITH_NI_HARDWARE
// UTF_TD_GENERATOR DeviceNameGeneratorMD1
static Function TestNIAcquisitionReliability([str])
string str

STRUCT DAQSettings s
InitDAQSettingsFromString(s, "MD1_RA1_I0_L0_BKG1_FFR:10:_RES1000" + \
"__HS0_DA0_AD0_CM:VC:_ST:EpochTest6_DA_0:")

AcquireData_NG(s, str)
End

static Function TestNIAcquisitionReliability_REENTRY([str])
string str

CHECK_EQUAL_VAR(GetSetVariable(str, "SetVar_Sweep"), 1000)
End
#endif
2 changes: 1 addition & 1 deletion Packages/tests/UTF_HardwareHelperFunctions.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ Function RegisterReentryFunction(string testcase)
if(FuncRefIsAssigned(FuncRefInfo(reentryFuncPlain)) || FuncRefIsAssigned(FuncRefInfo(reentryFuncMDStr)) || FuncRefIsAssigned(FuncRefInfo(reentryFuncRefWave)) || FuncRefIsAssigned(FuncRefInfo(reentryFuncMDD)))
CtrlNamedBackGround DAQWatchdog, start, period=120, proc=WaitUntilDAQDone_IGNORE
CtrlNamedBackGround TPWatchdog, start, period=120, proc=WaitUntilTPDone_IGNORE
RegisterUTFMonitor(TASKNAMES + "DAQWatchdog;TPWatchdog", BACKGROUNDMONMODE_AND, reentryFuncName, timeout = 600, failOnTimeout = 1)
RegisterUTFMonitor(TASKNAMES + "DAQWatchdog;TPWatchdog", BACKGROUNDMONMODE_AND, reentryFuncName, timeout = 900, failOnTimeout = 1)
endif
End

Expand Down

0 comments on commit 1d38644

Please sign in to comment.