Skip to content

Commit c8f258b

Browse files
authored
Merge pull request #2408 from AllenInstitute/feature/2408-mh_precise_tp_start_times
Save precise start times per TP
2 parents de3a849 + 693d185 commit c8f258b

20 files changed

+238
-145
lines changed

Packages/MIES/MIES_AnalysisFunctions_PatchSeq.ipf

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5970,8 +5970,7 @@ Function PSQ_Ramp(string device, STRUCT AnalysisFunction_V3 &s)
59705970
// stop DAQ, set DA to zero from now to the end and start DAQ again
59715971

59725972
// fetch the very last fifo position immediately before we stop it
5973-
NVAR tgID = $GetThreadGroupIDFIFO(device)
5974-
fifoOffset = TS_GetNewestFromThreadQueue(tgID, "fifoPos")
5973+
fifoOffset = HW_ITC_ReadFifoPos(device)
59755974
TFH_StopFIFODaemon(HARDWARE_ITC_DAC, deviceID)
59765975
HW_StopAcq(HARDWARE_ITC_DAC, deviceID)
59775976
HW_ITC_PrepareAcq(deviceID, DATA_ACQUISITION_MODE, offset = fifoOffset)
@@ -5988,14 +5987,13 @@ Function PSQ_Ramp(string device, STRUCT AnalysisFunction_V3 &s)
59885987

59895988
// fetch newest fifo position, blocks until it gets a valid value
59905989
// its zero is now fifoOffset
5991-
NVAR tgID = $GetThreadGroupIDFIFO(device)
5992-
fifoPos = TS_GetNewestFromThreadQueue(tgID, "fifoPos")
5990+
fifoPos = HW_ITC_ReadFifoPos(device)
59935991
ASSERT(fifoPos > 0, "Invalid fifo position, has the thread died?")
59945992

59955993
// wait until the hardware is finished with writing this chunk
59965994
// this is to avoid that two threads write simultaneously into the DAQDataWave
59975995
for(;;)
5998-
val = TS_GetNewestFromThreadQueue(tgID, "fifoPos")
5996+
val = HW_ITC_ReadFifoPos(device)
59995997

60005998
if(val > fifoPos)
60015999
break

Packages/MIES/MIES_Constants.ipf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2427,4 +2427,8 @@ StrConstant CONF_DEFAULT_SAVE_LOCATION = "C:MiesSave"
24272427
// TP_TSAnalysis
24282428
// GetTPResultAsyncBuffer
24292429
// GetTPResults (reuses same dimlabels partially)
2430-
StrConstant TP_ANALYSIS_DATA_LABELS = "BASELINE;STEADYSTATERES;INSTANTRES;ELEVATED_SS;ELEVATED_INST;NOW;HEADSTAGE;MARKER;NUMBER_OF_TP_CHANNELS;TIMESTAMP;TIMESTAMPUTC;CLAMPMODE;CLAMPAMP;BASELINEFRAC;CYCLEID;TPLENGTHPOINTSADC;PULSELENGTHPOINTSADC;PULSESTARTPOINTSADC;SAMPLINGINTERVALADC;TPLENGTHPOINTSDAC;PULSELENGTHPOINTSDAC;PULSESTARTPOINTSDAC;SAMPLINGINTERVALDAC;"
2430+
StrConstant TP_ANALYSIS_DATA_LABELS = "BASELINE;STEADYSTATERES;INSTANTRES;ELEVATED_SS;ELEVATED_INST;HEADSTAGE;MARKER;NUMBER_OF_TP_CHANNELS;TIMESTAMP;TIMESTAMPUTC;CLAMPMODE;CLAMPAMP;BASELINEFRAC;CYCLEID;TPLENGTHPOINTSADC;PULSELENGTHPOINTSADC;PULSESTARTPOINTSADC;SAMPLINGINTERVALADC;TPLENGTHPOINTSDAC;PULSELENGTHPOINTSDAC;PULSESTARTPOINTSDAC;SAMPLINGINTERVALDAC;"
2431+
2432+
// Object names for thread data transfer out of ITC Fifothread @ref TFH_FifoLoop
2433+
StrConstant ITC_THREAD_FIFOPOS = "fifopos"
2434+
StrConstant ITC_THREAD_TIMESTAMP = "timestamp"

Packages/MIES/MIES_DAC-Hardware.ipf

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,15 @@ Function HW_WriteDeviceInfo(variable hardwareType, string device, WAVE deviceInf
626626
endswitch
627627
End
628628

629+
threadsafe Function/S HW_GetAcquisitionStartTimestamp([variable secondsSinceIgorEpoch])
630+
631+
if(ParamIsDefault(secondsSinceIgorEpoch))
632+
return GetIso8601TimeStamp(numFracSecondsDigits = 9)
633+
endif
634+
635+
return GetIso8601TimeStamp(secondsSinceIgorEpoch = secondsSinceIgorEpoch, numFracSecondsDigits = 9)
636+
End
637+
629638
/// @brief Start data acquisition
630639
///
631640
/// @param hardwareType One of @ref HardwareDACTypeConstants
@@ -635,12 +644,18 @@ End
635644
/// @param repeat [optional, default 0] for NI devices, repeats the scan after it ends
636645
Function HW_StartAcq(variable hardwareType, variable deviceID, [variable triggerMode, variable flags, variable repeat])
637646

647+
string device
648+
638649
HW_AssertOnInvalid(hardwareType, deviceID)
639650

640651
if(ParamIsDefault(triggerMode))
641652
triggerMode = HARDWARE_DAC_DEFAULT_TRIGGER
642653
endif
643654

655+
device = HW_GetMainDeviceName(hardwareType, deviceID, flags = flags)
656+
SVAR lastAcqStartTime = $GetLastAcquisitionStartTime(device)
657+
lastAcqStartTime = HW_GetAcquisitionStartTimestamp()
658+
644659
switch(hardwareType)
645660
case HARDWARE_ITC_DAC:
646661
HW_ITC_StartAcq(deviceID, triggerMode, flags = flags)
@@ -1515,7 +1530,7 @@ threadsafe Function HW_ITC_StartAcq_TS(variable deviceID, variable triggerMode,
15151530
End
15161531

15171532
/// @see HW_StartAcq
1518-
Function HW_ITC_StartAcq(variable deviceID, variable triggerMode, [variable flags])
1533+
static Function HW_ITC_StartAcq(variable deviceID, variable triggerMode, [variable flags])
15191534

15201535
variable tries
15211536

@@ -2153,6 +2168,28 @@ Function HW_ITC_IsValidDeviceName(string deviceName)
21532168
return !isEmpty(deviceName)
21542169
End
21552170

2171+
/// @brief Read out the fifopos from the ITC fifothread
2172+
Function HW_ITC_ReadFifoPos(string device, [variable timeout_tries, variable timeout_default])
2173+
2174+
timeout_default = ParamIsDefault(timeout_default) ? NaN : timeout_default
2175+
timeout_tries = ParamIsDefault(timeout_tries) ? Inf : timeout_tries
2176+
2177+
Make/FREE/T varNames = {ITC_THREAD_FIFOPOS, ITC_THREAD_TIMESTAMP}
2178+
2179+
NVAR tgID = $GetThreadGroupIDFIFO(device)
2180+
WAVE/Z data = TS_GetNewestFromThreadQueueMult(tgID, varNames, timeout_tries = timeout_tries, timeout_default = timeout_default)
2181+
if(!WaveExists(data))
2182+
// ITC TFH_FifoLoop thread stopped
2183+
return NaN
2184+
endif
2185+
if(!IsNaN(data[%$ITC_THREAD_TIMESTAMP]))
2186+
SVAR lastAcqStartTime = $GetLastAcquisitionStartTime(device)
2187+
lastAcqStartTime = HW_GetAcquisitionStartTimestamp(secondsSinceIgorEpoch = data[%$ITC_THREAD_TIMESTAMP])
2188+
endif
2189+
2190+
return data[%$ITC_THREAD_FIFOPOS]
2191+
End
2192+
21562193
///@}
21572194
///@}
21582195

@@ -2224,7 +2261,7 @@ static Constant HW_NI_FIFO_MIN_FREE_DISK_SPACE = 960000000
22242261
///
22252262

22262263
/// @see HW_StartAcq
2227-
Function HW_NI_StartAcq(variable deviceID, variable triggerMode, [variable flags, variable repeat])
2264+
static Function HW_NI_StartAcq(variable deviceID, variable triggerMode, [variable flags, variable repeat])
22282265

22292266
string device, realDeviceOrPressure, FIFONote, noteID, fifoName, errMsg
22302267
variable i, pos, endpos, channelTimeOffset, err
@@ -3499,7 +3536,7 @@ static Function [variable hwChannel, string encode] HW_SU_GetEncodeFromUnassocDA
34993536
return [hwChannel, encode]
35003537
End
35013538

3502-
Function HW_SU_StartAcq(variable deviceId, [variable flags])
3539+
static Function HW_SU_StartAcq(variable deviceId, [variable flags])
35033540

35043541
string device, cmdError, cmdDone
35053542

Packages/MIES/MIES_DataAcquisition_Multi.ipf

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ Function DQM_FIFOMonitor(STRUCT BackgroundStruct &s)
8787
endtry
8888
break
8989
case HARDWARE_ITC_DAC:
90-
NVAR tgID = $GetThreadGroupIDFIFO(device)
91-
fifoLatest = TS_GetNewestFromThreadQueue(tgID, "fifoPos", timeout_default = HARDWARE_ITC_FIFO_ERROR, timeout_tries = THREAD_QUEUE_TRIES)
90+
fifoLatest = HW_ITC_ReadFifoPos(device, timeout_default = HARDWARE_ITC_FIFO_ERROR, timeout_tries = THREAD_QUEUE_TRIES)
9291

9392
if(fifoLatest != s.lastReceivedFifoPos)
9493
s.ticksLastReceivedFifoPos = ticks
@@ -126,7 +125,7 @@ Function DQM_FIFOMonitor(STRUCT BackgroundStruct &s)
126125
endif
127126

128127
// once TFH_FifoLoop is finished the thread is done as well and
129-
// therefore we get NaN from TS_GetNewestFromThreadQueue
128+
// therefore we get NaN from HW_ITC_ReadFifoPos
130129
isFinished = IsNaN(fifoLatest)
131130

132131
// Update ActiveChunk Entry for ITC, not used in DAQ mode

Packages/MIES/MIES_GlobalStringAndVariableAccess.ipf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,12 @@ Function/S GetAnalysisExpSessionStartTime(string dataFolder)
524524
return GetSVARAsString(GetAnalysisExpFolder(dataFolder), "sessionStartTime", initialValue = "")
525525
End
526526

527+
/// @brief Returns the global that stores the last acquisition start time
528+
Function/S GetLastAcquisitionStartTime(string device)
529+
530+
return GetSVARAsString(GetDevicePath(device), "LastAcquisitionStartTime", initialValue = "")
531+
End
532+
527533
/// @brief Return the experiment session start time in NWB-speech
528534
///
529535
/// This is the time when the last device was locked.

Packages/MIES/MIES_MiesUtilities_Sweep.ipf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,10 @@ End
440440

441441
Function LeftOverSweepTime(string device, variable fifoPos)
442442

443-
ASSERT(IsFinite(fifoPos), "Unexpected non-finite fifoPos")
443+
if(IsNaN(fifopos))
444+
// TFH_FifoLoop thread finished -> sweep finished regular (or manually stopped)
445+
return 0
446+
endif
444447

445448
WAVE DAQDataWave = GetDAQDataWave(device, DATA_ACQUISITION_MODE)
446449
NVAR stopCollectionPoint = $GetStopCollectionPoint(device)

Packages/MIES/MIES_Oscilloscope.ipf

Lines changed: 14 additions & 4 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
@@ -543,7 +550,6 @@ Function SCOPE_UpdateOscilloscopeData(string device, variable dataAcqOrTP, [vari
543550
tpInput.pulseStartPointsDAC = (dataAcqOrTP == TEST_PULSE_MODE) ? TPSettingsCalc[%pulseStartPointsTP] : TPSettingsCalc[%pulseStartPointsDAQ]
544551
tpInput.samplingIntervalDAC = DimDelta(scaledDataWave[0], ROWS)
545552
tpInput.baselineFrac = TPSettingsCalc[%baselineFrac]
546-
tpInput.readTimeStamp = ticks * TICKS_TO_SECONDS
547553
tpInput.activeADCs = tpChannels
548554
tpInput.cycleId = ROVAR(GetTestpulseCycleID(device))
549555

@@ -557,6 +563,9 @@ Function SCOPE_UpdateOscilloscopeData(string device, variable dataAcqOrTP, [vari
557563
DEBUGPRINT("tpChannels: ", var = tpChannels)
558564
DEBUGPRINT("tpLength: ", var = tpLengthPointsADC)
559565

566+
// In TP mode the loop only runs once. Only the last TP is evaluated for ITC and SUTTER.
567+
// For NI the caller loops over all pending TPs.
568+
// In DAQ mode all TPs are evaluated in this loop
560569
for(i = tpStart; i < tpEnd; i += 1)
561570

562571
tpInput.measurementMarker = tpMarker[i - tpStart]
@@ -574,8 +583,9 @@ Function SCOPE_UpdateOscilloscopeData(string device, variable dataAcqOrTP, [vari
574583
endif
575584

576585
// Use same time for all headstages
577-
tpInput.timeStamp = DateTime
578-
tpInput.timeStampUTC = DateTimeInUTC()
586+
timeSinceAcqStart = (tpCounter + i) * tpInput.samplingIntervalDAC * tpInput.tpLengthPointsDAC * MILLI_TO_ONE
587+
tpInput.timeStampUTC = timeOfAcqStartUTC + timeSinceAcqStart
588+
tpInput.timeStamp = UTCTimeToLocal(tpInput.timeStampUTC)
579589
tpInput.sendTPMessage = 1
580590

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

Packages/MIES/MIES_Publish.ipf

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -785,17 +785,13 @@ End
785785
/// "unit": "ms",
786786
/// "value": 0.002
787787
/// },
788-
/// "time of tp acquisition": {
789-
/// "unit": "s",
790-
/// "value": 1000000
791-
/// },
792788
/// "timestamp": {
793789
/// "unit": "s",
794-
/// "value": 2000000
790+
/// "value": 3829047532.83
795791
/// },
796792
/// "timestampUTC": {
797793
/// "unit": "s",
798-
/// "value": 3000000
794+
/// "value": 3829040372.83
799795
/// },
800796
/// "tp cycle id": 456,
801797
/// "tp length ADC": {
@@ -847,7 +843,6 @@ threadsafe Function PUB_TPResult(string device, WAVE tpData, WAVE ampParamStorag
847843
JSON_AddVariable(jsonID, path + "/headstage", tpData[%HEADSTAGE])
848844
JSON_AddVariable(jsonID, path + "/clamp mode", tpData[%CLAMPMODE])
849845

850-
PUB_AddTPResultEntry(jsonId, path + "/time of tp acquisition", tpData[%NOW], "s")
851846
PUB_AddTPResultEntry(jsonId, path + "/clamp amplitude", tpData[%CLAMPAMP], daUnit)
852847
PUB_AddTPResultEntry(jsonId, path + "/tp length ADC", tpData[%TPLENGTHPOINTSADC], "points")
853848
PUB_AddTPResultEntry(jsonId, path + "/pulse duration ADC", tpData[%PULSELENGTHPOINTSADC], "points")

Packages/MIES/MIES_Structures.ipf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,6 @@ Structure TPAnalysisInput
308308
variable pulseStartPointsDAC
309309
variable samplingIntervalDAC
310310
variable baselineFrac
311-
variable readTimeStamp
312311
variable headstage
313312
string device
314313
variable measurementMarker

Packages/MIES/MIES_TestPulse.ipf

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,6 @@ Function TP_ROAnalysis(STRUCT ASYNC_ReadOutStruct &ar)
366366
MultiThread TPResults[%ResistanceInst][] = asyncBuffer[i][%INSTANTRES][q]
367367
MultiThread TPResults[%ElevatedSteadyState][] = asyncBuffer[i][%ELEVATED_SS][q]
368368
MultiThread TPResults[%ElevatedInst][] = asyncBuffer[i][%ELEVATED_INST][q]
369-
MultiThread TPResults[%NOW][] = asyncBuffer[i][%NOW][q]
370369
MultiThread TPResults[%HEADSTAGE][] = asyncBuffer[i][%HEADSTAGE][q]
371370
MultiThread TPResults[%MARKER][] = asyncBuffer[i][%MARKER][q]
372371
MultiThread TPResults[%NUMBER_OF_TP_CHANNELS][] = asyncBuffer[i][%NUMBER_OF_TP_CHANNELS][q]
@@ -405,7 +404,7 @@ Function TP_ROAnalysis(STRUCT ASYNC_ReadOutStruct &ar)
405404

406405
TP_AutoAmplitudeAndBaseline(device, TPResults, marker)
407406
DQ_ApplyAutoBias(device, TPResults)
408-
TP_RecordTP(device, TPResults, inData[%NOW])
407+
TP_RecordTP(device, TPResults)
409408
endif
410409
End
411410

@@ -1040,7 +1039,6 @@ threadsafe Function/DF TP_TSAnalysis(DFREF dfrInp)
10401039
variable pulseLengthPointsADC = ASYNC_FetchVariable(dfrInp, "pulseLengthPointsADC")
10411040
variable baselineFrac = ASYNC_FetchVariable(dfrInp, "baselineFrac")
10421041
variable tpLengthPointsADC = ASYNC_FetchVariable(dfrInp, "tpLengthPointsADC")
1043-
variable now = ASYNC_FetchVariable(dfrInp, "now")
10441042
variable headstage = ASYNC_FetchVariable(dfrInp, "headstage")
10451043
string device = ASYNC_FetchString(dfrInp, "device")
10461044
variable marker = ASYNC_FetchVariable(dfrInp, "marker")
@@ -1061,8 +1059,8 @@ threadsafe Function/DF TP_TSAnalysis(DFREF dfrInp)
10611059
Duplicate data, dfrOut:colors
10621060
Duplicate data, dfrOut:data
10631061
WAVE colors = dfrOut:colors
1064-
colors = 0
1065-
colors[0, lengthTPInPoints - 1] = 100
1062+
colors = 0
1063+
colors[0, tpLengthPointsADC - 1] = 100
10661064
#endif
10671065

10681066
WAVE tpData = GetTPAnalysisDataWave()
@@ -1098,7 +1096,7 @@ threadsafe Function/DF TP_TSAnalysis(DFREF dfrInp)
10981096
DEBUGPRINT_TS("steady state range eng (ms): ", var = refTime)
10991097
DEBUGPRINT_TS("steady state average: ", var = avgTPSS)
11001098
// color steady state
1101-
refpt = lengthTPInPoints - tpStartPoint - evalOffsetPointsCorrected
1099+
refpt = tpLengthPointsADC - tpStartPoint - evalOffsetPointsCorrected
11021100
colors[refpt - evalRange / samplingIntervalADC, refpt] = 50
11031101
// color instantaneous
11041102
refpt = tpStartPoint + evalOffsetPointsCorrected
@@ -1140,7 +1138,6 @@ threadsafe Function/DF TP_TSAnalysis(DFREF dfrInp)
11401138

11411139
// additional data copy
11421140
string/G dfrOut:device = device
1143-
tpData[%NOW] = now
11441141
tpData[%HEADSTAGE] = headstage
11451142
tpData[%MARKER] = marker
11461143
tpData[%NUMBER_OF_TP_CHANNELS] = activeADCs
@@ -1195,18 +1192,15 @@ End
11951192
/// @brief Records values from TPResults into TPStorage at defined intervals.
11961193
///
11971194
/// Used for analysis of TP over time.
1198-
static Function TP_RecordTP(string device, WAVE TPResults, variable now)
1195+
static Function TP_RecordTP(string device, WAVE TPResults)
11991196

1200-
variable delta, i, ret, lastPressureCtrl
1197+
variable delta, i, ret, lastPressureCtrl, now
12011198
WAVE TPStorage = GetTPStorage(device)
12021199
WAVE hsProp = GetHSProperties(device)
12031200
variable count = GetNumberFromWaveNote(TPStorage, NOTE_INDEX)
12041201
variable lastRescaling = GetNumberFromWaveNote(TPStorage, DIMENSION_SCALING_LAST_INVOC)
12051202

12061203
if(!count)
1207-
// time of the first sweep
1208-
TPStorage[0][][%TimeInSeconds] = now
1209-
12101204
WAVE statusHS = DAG_GetChannelState(device, CHANNEL_TYPE_HEADSTAGE)
12111205

12121206
for(i = 0; i < NUM_HEADSTAGES; i += 1)
@@ -1237,7 +1231,6 @@ static Function TP_RecordTP(string device, WAVE TPResults, variable now)
12371231
: TPStorage[count][q][%HoldingCmd_IC]
12381232
endif
12391233

1240-
TPStorage[count][][%TimeInSeconds] = TPResults[%NOW][q]
12411234
TPStorage[count][][%TimeStamp] = TPResults[%TIMESTAMP][q]
12421235
TPStorage[count][][%TimeStampSinceIgorEpochUTC] = TPResults[%TIMESTAMPUTC][q]
12431236

@@ -1255,7 +1248,7 @@ static Function TP_RecordTP(string device, WAVE TPResults, variable now)
12551248
TPStorage[count][][%Baseline_VC] = (hsProp[q][%ClampMode] == V_CLAMP_MODE) ? TPResults[%BaselineSteadyState][q] : NaN
12561249
TPStorage[count][][%Baseline_IC] = (hsProp[q][%ClampMode] == I_CLAMP_MODE) ? TPResults[%BaselineSteadyState][q] : NaN
12571250

1258-
TPStorage[count][][%DeltaTimeInSeconds] = (count > 0) ? (now - TPStorage[0][0][%TimeInSeconds]) : 0
1251+
TPStorage[count][][%DeltaTimeInSeconds] = TPResults[%TIMESTAMP][q] - TPStorage[0][q][%TimeStamp]
12591252
TPStorage[count][][%TPMarker] = TPResults[%MARKER][q]
12601253

12611254
TPStorage[count][][%TPCycleID] = TPResults[%CYCLEID][q]
@@ -1278,6 +1271,7 @@ static Function TP_RecordTP(string device, WAVE TPResults, variable now)
12781271
TPStorage[count][][%AutoTPCycleID] = hsProp[q][%Enabled] ? TPSettings[%autoTPCycleID][q] : NaN
12791272

12801273
lastPressureCtrl = GetNumberFromWaveNote(TPStorage, PRESSURE_CTRL_LAST_INVOC)
1274+
now = DateTime
12811275
if((now - lastPressureCtrl) > TP_PRESSURE_INTERVAL)
12821276
P_PressureControl(device)
12831277
SetNumberInWaveNote(TPStorage, PRESSURE_CTRL_LAST_INVOC, now, format = "%.06f")
@@ -1312,7 +1306,7 @@ threadsafe static Function TP_FitResistance(WAVE TPStorage, variable startRow, v
13121306
try
13131307
V_FitError = 0
13141308
V_AbortCode = 0
1315-
CurveFit/Q/N=1/NTHR=1/M=0/W=2 line, kwCWave=coefWave, TPStorage[startRow, endRow][headstage][%SteadyStateResistance]/X=TPStorage[startRow, endRow][headstage][%TimeInSeconds]/AD=0/AR=0; AbortOnRTE
1309+
CurveFit/Q/N=1/NTHR=1/M=0/W=2 line, kwCWave=coefWave, TPStorage[startRow, endRow][headstage][%SteadyStateResistance]/X=TPStorage[startRow, endRow][headstage][%TimeStamp]/AD=0/AR=0; AbortOnRTE
13161310
return coefWave[1]
13171311
catch
13181312
ClearRTError()
@@ -1679,7 +1673,6 @@ Function/DF TP_PrepareAnalysisDF(string device, STRUCT TPAnalysisInput &tpInput)
16791673
ASYNC_AddParam(threadDF, var = tpInput.pulseLengthPointsADC, name = "pulseLengthPointsADC")
16801674
ASYNC_AddParam(threadDF, var = tpInput.baselineFrac, name = "baselineFrac")
16811675
ASYNC_AddParam(threadDF, var = tpInput.tpLengthPointsADC, name = "tpLengthPointsADC")
1682-
ASYNC_AddParam(threadDF, var = tpInput.readTimeStamp, name = "now")
16831676
ASYNC_AddParam(threadDF, var = tpInput.headstage, name = "headstage")
16841677
ASYNC_AddParam(threadDF, str = tpInput.device, name = "device")
16851678
ASYNC_AddParam(threadDF, var = tpInput.measurementMarker, name = "marker")

0 commit comments

Comments
 (0)