Skip to content

Commit

Permalink
TP: Determine timeStamp on pushing to the threaded analysis
Browse files Browse the repository at this point in the history
The determination of the timestamp was moved to an earlier moment because
then the timestamp can be published through zeromq as part of the TP publish
and it is then identical to the recorded TP timestamp in TP_RecordTP.

There is the same timestamp for all headstages of one TP.
  • Loading branch information
MichaelHuth committed Aug 16, 2024
1 parent 5c33db6 commit d3b169f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 19 deletions.
4 changes: 4 additions & 0 deletions Packages/MIES/MIES_Oscilloscope.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,10 @@ Function SCOPE_UpdateOscilloscopeData(device, dataAcqOrTP, [chunk, fifoPos, devi
hsList = ""
endif

// Use same time for all headstages
tpInput.timeStamp = DateTime
tpInput.timeStampUTC = DateTimeInUTC()

for(j = 0; j < numADCs; j += 1)
if(ADCmode[j] == DAQ_CHANNEL_TYPE_TP)

Expand Down
2 changes: 2 additions & 0 deletions Packages/MIES/MIES_Structures.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,8 @@ Structure TPAnalysisInput
string device
variable measurementMarker
variable activeADCs
variable timeStamp
variable timeStampUTC
EndStructure

/// @brief Helper structure for GetPlotArea()
Expand Down
38 changes: 19 additions & 19 deletions Packages/MIES/MIES_TestPulse.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,14 @@ Function TP_ROAnalysis(dfr, err, errmsg)
ASSERT(0, "RTError " + num2str(err) + " in TP_Analysis thread: " + errmsg)
endif

WAVE/SDFR=dfr inData = outData
NVAR/SDFR=dfr now = now
NVAR/SDFR=dfr hsIndex = hsIndex
SVAR/SDFR=dfr device = device
NVAR/SDFR=dfr marker = marker
NVAR/SDFR=dfr activeADCs = activeADCs
WAVE/SDFR=dfr inData = outData
NVAR/SDFR=dfr now = now
NVAR/SDFR=dfr hsIndex = hsIndex
SVAR/SDFR=dfr device = device
NVAR/SDFR=dfr marker = marker
NVAR/SDFR=dfr activeADCs = activeADCs
NVAR/SDFR=dfr timeStamp = timeStamp
NVAR/SDFR=dfr timeStampUTC = timeStampUTC

WAVE asyncBuffer = GetTPResultAsyncBuffer(device)

Expand Down Expand Up @@ -268,7 +270,7 @@ Function TP_ROAnalysis(dfr, err, errmsg)

TP_AutoAmplitudeAndBaseline(device, TPResults, marker)
DQ_ApplyAutoBias(device, TPResults)
TP_RecordTP(device, TPResults, now, marker)
TP_RecordTP(device, TPResults, now, marker, timeStamp, timeStampUTC)
endif
End

Expand Down Expand Up @@ -900,6 +902,8 @@ threadsafe Function/DF TP_TSAnalysis(dfrInp)
SVAR/SDFR=dfrInp device = param8
NVAR/SDFR=dfrInp marker = param9
NVAR/SDFR=dfrInp activeADCs = param10
NVAR/SDFR=dfrInp timeStamp = param11
NVAR/SDFR=dfrInp timeStampUTC = param12

#if defined(TP_ANALYSIS_DEBUGGING)
DEBUGPRINT_TS("Marker: ", var = marker)
Expand Down Expand Up @@ -1016,6 +1020,8 @@ threadsafe Function/DF TP_TSAnalysis(dfrInp)
JSON_AddVariable(jsonID, "properties/baseline fraction", baselineFrac)
JSON_AddVariable(jsonID, "properties/length of tp in sample points", lengthTPInPoints)
JSON_AddVariable(jsonID, "properties/sample interval", sampleInt)
JSON_AddVariable(jsonID, "properties/timeStamp", timeStamp)
JSON_AddVariable(jsonID, "properties/timeStampUTC", timeStampUTC)
JSON_AddTreeObject(jsonID, "results")
JSON_AddVariable(jsonID, "results/average baseline steady state", avgBaselineSS)
JSON_AddVariable(jsonID, "results/average tp steady state", avgTPSS)
Expand Down Expand Up @@ -1090,12 +1096,9 @@ End
/// @brief Records values from TPResults into TPStorage at defined intervals.
///
/// Used for analysis of TP over time.
static Function TP_RecordTP(device, TPResults, now, tpMarker)
string device
WAVE TPResults
variable now, tpMarker
static Function TP_RecordTP(string device, WAVE TPResults, variable now, variable tpMarker, variable timeStamp, variable timeStampUTC)

variable delta, i, ret, lastPressureCtrl, timestamp, cycleID
variable delta, i, ret, lastPressureCtrl, cycleID
WAVE TPStorage = GetTPStorage(device)
WAVE hsProp = GetHSProperties(device)
variable count = GetNumberFromWaveNote(TPStorage, NOTE_INDEX)
Expand Down Expand Up @@ -1135,14 +1138,9 @@ static Function TP_RecordTP(device, TPResults, now, tpMarker)
: TPStorage[count][q][%HoldingCmd_IC]
endif

TPStorage[count][][%TimeInSeconds] = now

// store the current time in a variable first
// so that all columns have the same timestamp
timestamp = DateTime
TPStorage[count][][%TimeInSeconds] = now
TPStorage[count][][%TimeStamp] = timestamp
timestamp = DateTimeInUTC()
TPStorage[count][][%TimeStampSinceIgorEpochUTC] = timestamp
TPStorage[count][][%TimeStampSinceIgorEpochUTC] = timeStampUTC

TPStorage[count][][%PeakResistance] = min(TPResults[%ResistanceInst][q], TP_MAX_VALID_RESISTANCE)
TPStorage[count][][%SteadyStateResistance] = min(TPResults[%ResistanceSteadyState][q], TP_MAX_VALID_RESISTANCE)
Expand Down Expand Up @@ -1597,6 +1595,8 @@ Function/DF TP_PrepareAnalysisDF(string device, STRUCT TPAnalysisInput &tpInput)
ASYNC_AddParam(threadDF, str = tpInput.device)
ASYNC_AddParam(threadDF, var = tpInput.measurementMarker)
ASYNC_AddParam(threadDF, var = tpInput.activeADCs)
ASYNC_AddParam(threadDF, var = tpInput.timeStamp)
ASYNC_AddParam(threadDF, var = tpInput.timeStampUTC)

return threadDF
End
Expand Down

0 comments on commit d3b169f

Please sign in to comment.