Skip to content

Commit e40aeab

Browse files
committed
SCOPE: Use precise timestamp per TP for tpInput data
In our TP data we used until now only simply DateTime of the moment the data was sent into analysis for the timestamp. This resulted in multiple TPs (all from the same new FIFO data) having nearly the same timestamp. Now the timestamp of each TP based on the acquisition start and TP position in the acquisition is determined. Note regarding the calculation: (tpCounter + i) * tpInput.samplingIntervalDAC * tpInput.tpLengthPointsDAC * MILLI_TO_ONE tpCounter originates from NI devices in TP acquisition mode. There the acquisition with a single TP repeats itself in hardware. The TPs are counted based on the FIFO data and each TP is sent to SCOPE_UpdateOscilloscopeData separately. Thus, i is always zero and tpCounter the number of the TP since acquisition start. For all other hardware devices and acquisition modes tpCounter is zero and i counts the absolute TP number based on the position of the data in the FIFO.
1 parent 77866fa commit e40aeab

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Packages/MIES/MIES_Oscilloscope.ipf

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ Function SCOPE_UpdateOscilloscopeData(string device, variable dataAcqOrTP, [vari
466466
STRUCT TPAnalysisInput tpInput
467467
variable i, j
468468
variable tpChannels, numADCs, numDACs, tpLengthPointsADC, tpStart, tpEnd, tpStartPos
469-
variable TPChanIndex, saveTP, clampAmp
469+
variable TPChanIndex, saveTP, clampAmp, timeSinceAcqStart, timeOfAcqStartUTC, tpCounter
470470
variable headstage, fifoLatest, channelIndex
471471
string hsList
472472

@@ -478,6 +478,7 @@ Function SCOPE_UpdateOscilloscopeData(string device, variable dataAcqOrTP, [vari
478478
chunk = 0
479479
endif
480480
ASSERT(ParamIsDefault(fifoPos), "optional parameter fifoPos is not possible with TEST_PULSE_MODE")
481+
tpCounter = chunk
481482
elseif(dataAcqOrTP == DATA_ACQUISITION_MODE)
482483
ASSERT(!ParamIsDefault(fifoPos), "optional parameter fifoPos missing")
483484
ASSERT(ParamIsDefault(chunk), "optional parameter chunk is not possible with DATA_ACQUISITION_MODE")
@@ -489,11 +490,15 @@ Function SCOPE_UpdateOscilloscopeData(string device, variable dataAcqOrTP, [vari
489490
case HARDWARE_NI_DAC:
490491
ASSERT(!ParamIsDefault(deviceID), "optional parameter deviceID missing (required for NI devices in TP mode)")
491492
SCOPE_NI_UpdateOscilloscope(device, dataAcqOrTP, deviceID, fifoPos)
493+
if(dataAcqOrTP == TEST_PULSE_MODE)
494+
tpCounter = ROVar(GetNITestPulseCounter(device))
495+
endif
492496
break
493497
case HARDWARE_SUTTER_DAC:
494498
if(dataAcqOrTP == TEST_PULSE_MODE)
495499
ASSERT(!ParamIsDefault(chunk), "optional parameter chunk is missing with TEST_PULSE_MODE")
496500
ASSERT(ParamIsDefault(fifoPos), "optional parameter fifoPos is not possible with TEST_PULSE_MODE")
501+
tpCounter = chunk
497502
elseif(dataAcqOrTP == DATA_ACQUISITION_MODE)
498503
ASSERT(!ParamIsDefault(fifoPos), "optional parameter fifoPos missing")
499504
ASSERT(ParamIsDefault(chunk), "optional parameter chunk is not possible with DATA_ACQUISITION_MODE")
@@ -529,6 +534,8 @@ Function SCOPE_UpdateOscilloscopeData(string device, variable dataAcqOrTP, [vari
529534
numDACs = DimSize(DACs, ROWS)
530535
numADCs = DimSize(ADCs, ROWS)
531536

537+
timeOfAcqStartUTC = ParseISO8601TimeStamp(ROStr(GetLastAcquisitionStartTime(device)))
538+
532539
// note: currently this works for multiplier = 1 only, see DC_PlaceDataInDAQDataWave
533540
Make/FREE/N=(tpLengthPointsADC) channelData
534541
WAVE tpInput.data = channelData
@@ -577,8 +584,9 @@ Function SCOPE_UpdateOscilloscopeData(string device, variable dataAcqOrTP, [vari
577584
endif
578585

579586
// Use same time for all headstages
580-
tpInput.timeStamp = DateTime
581-
tpInput.timeStampUTC = DateTimeInUTC()
587+
timeSinceAcqStart = (tpCounter + i) * tpInput.samplingIntervalDAC * tpInput.tpLengthPointsDAC * MILLI_TO_ONE
588+
tpInput.timeStampUTC = timeOfAcqStartUTC + timeSinceAcqStart
589+
tpInput.timeStamp = UTCTimeToLocal(tpInput.timeStampUTC)
582590
tpInput.sendTPMessage = 1
583591

584592
for(j = 0; j < numADCs; j += 1)

0 commit comments

Comments
 (0)