Skip to content

Commit

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

bugfix: FIFO2WAVE does not work with single point ranges
  • Loading branch information
t-b authored Mar 6, 2024
2 parents 5bb3ee1 + 380c9b8 commit a0f016e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 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 @@ -2362,3 +2362,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

0 comments on commit a0f016e

Please sign in to comment.