From d3b169f493fc4ab608d1bac2cdaa09a70b6685b1 Mon Sep 17 00:00:00 2001 From: Michael Huth Date: Fri, 16 Aug 2024 13:50:12 +0200 Subject: [PATCH] TP: Determine timeStamp on pushing to the threaded analysis 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. --- Packages/MIES/MIES_Oscilloscope.ipf | 4 +++ Packages/MIES/MIES_Structures.ipf | 2 ++ Packages/MIES/MIES_TestPulse.ipf | 38 ++++++++++++++--------------- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/Packages/MIES/MIES_Oscilloscope.ipf b/Packages/MIES/MIES_Oscilloscope.ipf index 6d7c701c44..5a564a2b51 100644 --- a/Packages/MIES/MIES_Oscilloscope.ipf +++ b/Packages/MIES/MIES_Oscilloscope.ipf @@ -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) diff --git a/Packages/MIES/MIES_Structures.ipf b/Packages/MIES/MIES_Structures.ipf index 5ef93391a7..c54b171ac6 100644 --- a/Packages/MIES/MIES_Structures.ipf +++ b/Packages/MIES/MIES_Structures.ipf @@ -314,6 +314,8 @@ Structure TPAnalysisInput string device variable measurementMarker variable activeADCs + variable timeStamp + variable timeStampUTC EndStructure /// @brief Helper structure for GetPlotArea() diff --git a/Packages/MIES/MIES_TestPulse.ipf b/Packages/MIES/MIES_TestPulse.ipf index dbcdee0381..acfea6edc5 100644 --- a/Packages/MIES/MIES_TestPulse.ipf +++ b/Packages/MIES/MIES_TestPulse.ipf @@ -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) @@ -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 @@ -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) @@ -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) @@ -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) @@ -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) @@ -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