Skip to content

Commit

Permalink
TP: Add more information that is transferred to the TP analysis thread
Browse files Browse the repository at this point in the history
- extended the TPAnalysisInput structure

This is a preparation commit for adding zeromq publishers that include
some of that information.
  • Loading branch information
MichaelHuth committed Aug 22, 2024
1 parent ef3f1d2 commit 27dac75
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 21 deletions.
45 changes: 28 additions & 17 deletions Packages/MIES/MIES_Oscilloscope.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ Function SCOPE_UpdateOscilloscopeData(device, dataAcqOrTP, [chunk, fifoPos, devi

STRUCT TPAnalysisInput tpInput
variable i, j
variable tpChannels, numADCs, numDACs, tpLengthPoints, tpStart, tpEnd, tpStartPos
variable tpChannels, numADCs, numDACs, tpLengthPointsADC, tpStart, tpEnd, tpStartPos
variable TPChanIndex, saveTP, clampAmp
variable headstage, fifoLatest, channelIndex
string hsList
Expand Down Expand Up @@ -530,10 +530,10 @@ Function SCOPE_UpdateOscilloscopeData(device, dataAcqOrTP, [chunk, fifoPos, devi
WAVE TPSettings = GetTPSettings(device)
WAVE TPSettingsCalc = GetTPSettingsCalculated(device)

tpLengthPoints = (dataAcqOrTP == TEST_PULSE_MODE) ? TPSettingsCalc[%totalLengthPointsTP_ADC] : TPSettingsCalc[%totalLengthPointsDAQ_ADC]
tpLengthPointsADC = (dataAcqOrTP == TEST_PULSE_MODE) ? TPSettingsCalc[%totalLengthPointsTP_ADC] : TPSettingsCalc[%totalLengthPointsDAQ_ADC]

// use a 'virtual' end position for fifoLatest for TP Mode since the input data contains one TP only
fifoLatest = (dataAcqOrTP == TEST_PULSE_MODE) ? tpLengthPoints : fifoPos
fifoLatest = (dataAcqOrTP == TEST_PULSE_MODE) ? tpLengthPointsADC : fifoPos

WAVE ADCs = GetADCListFromConfig(config)
WAVE DACs = GetDACListFromConfig(config)
Expand All @@ -544,33 +544,40 @@ Function SCOPE_UpdateOscilloscopeData(device, dataAcqOrTP, [chunk, fifoPos, devi
numADCs = DimSize(ADCs, ROWS)

// note: currently this works for multiplier = 1 only, see DC_PlaceDataInDAQDataWave
Make/FREE/N=(tpLengthPoints) channelData
Make/FREE/N=(tpLengthPointsADC) channelData
WAVE tpInput.data = channelData

tpInput.device = device
tpInput.duration = (dataAcqOrTP == TEST_PULSE_MODE) ? TPSettingsCalc[%pulseLengthPointsTP_ADC] : TPSettingsCalc[%pulseLengthPointsDAQ_ADC]
tpInput.baselineFrac = TPSettingsCalc[%baselineFrac]
tpInput.tpLengthPoints = tpLengthPoints
tpInput.readTimeStamp = ticks * TICKS_TO_SECONDS
tpInput.activeADCs = tpChannels

tpStart = trunc(fifoPosGlobal / tpLengthPoints)
tpEnd = trunc(fifoLatest / tpLengthPoints)
tpInput.device = device
tpInput.tpLengthPointsADC = tpLengthPointsADC
tpInput.pulseLengthPointsADC = (dataAcqOrTP == TEST_PULSE_MODE) ? TPSettingsCalc[%pulseLengthPointsTP_ADC] : TPSettingsCalc[%pulseLengthPointsDAQ_ADC]
tpInput.pulseStartPointsADC = (dataAcqOrTP == TEST_PULSE_MODE) ? TPSettingsCalc[%pulseStartPointsTP_ADC] : TPSettingsCalc[%pulseStartPointsDAQ_ADC]
tpInput.samplingIntervalADC = DimDelta(scaledDataWave[numDACs], ROWS)
tpInput.tpLengthPointsDAC = (dataAcqOrTP == TEST_PULSE_MODE) ? TPSettingsCalc[%totalLengthPointsTP] : TPSettingsCalc[%totalLengthPointsDAQ]
tpInput.pulseLengthPointsDAC = (dataAcqOrTP == TEST_PULSE_MODE) ? TPSettingsCalc[%pulseLengthPointsTP] : TPSettingsCalc[%pulseLengthPointsDAQ]
tpInput.pulseStartPointsDAC = (dataAcqOrTP == TEST_PULSE_MODE) ? TPSettingsCalc[%pulseStartPointsTP] : TPSettingsCalc[%pulseStartPointsDAQ]
tpInput.samplingIntervalDAC = DimDelta(scaledDataWave[0], ROWS)
tpInput.baselineFrac = TPSettingsCalc[%baselineFrac]
tpInput.readTimeStamp = ticks * TICKS_TO_SECONDS
tpInput.activeADCs = tpChannels
tpInput.cycleId = ROVAR(GetTestpulseCycleID(device))

tpStart = trunc(fifoPosGlobal / tpLengthPointsADC)
tpEnd = trunc(fifoLatest / tpLengthPointsADC)
ASSERT(tpStart <= tpEnd, "New fifopos is smaller than previous fifopos")
Make/FREE/D/N=(tpEnd - tpStart) tpMarker
NewRandomSeed()
tpMarker[] = GetUniqueInteger()

DEBUGPRINT("tpChannels: ", var = tpChannels)
DEBUGPRINT("tpLength: ", var = tpLengthPoints)
DEBUGPRINT("tpLength: ", var = tpLengthPointsADC)

for(i = tpStart; i < tpEnd; i += 1)

tpInput.measurementMarker = tpMarker[i - tpStart]
tpStartPos = i * tpLengthPoints
tpStartPos = i * tpLengthPointsADC

if(saveTP)
Make/FREE/N=(tpLengthPoints, tpChannels) StoreTPWave
Make/FREE/N=(tpLengthPointsADC, tpChannels) StoreTPWave
for(j = 0; j < tpChannels; j += 1)
WAVE scaledChannel = scaledDataWave[numDACs + j]
Multithread StoreTPWave[][j] = scaledChannel[tpStartPos + p]
Expand All @@ -580,6 +587,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 Expand Up @@ -622,7 +633,7 @@ Function SCOPE_UpdateOscilloscopeData(device, dataAcqOrTP, [chunk, fifoPos, devi
endfor

if(dataAcqOrTP == DATA_ACQUISITION_MODE && tpEnd > tpStart)
tpStartPos = (tpEnd - 1) * tpLengthPoints
tpStartPos = (tpEnd - 1) * tpLengthPointsADC
if(DAG_GetNumericalValue(device, "check_settings_show_power"))
WAVE tpOsciForPowerSpectrum = GetScaledTPTempWave(device)
Make/FREE/D/N=(numADCs) tpColumns
Expand Down
13 changes: 11 additions & 2 deletions Packages/MIES/MIES_Structures.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -306,14 +306,23 @@ Structure TPAnalysisInput
WAVE data
variable clampAmp
variable clampMode
variable duration // [points]
variable tpLengthPointsADC
variable pulseLengthPointsADC
variable pulseStartPointsADC
variable samplingIntervalADC
variable tpLengthPointsDAC
variable pulseLengthPointsDAC
variable pulseStartPointsDAC
variable samplingIntervalDAC
variable baselineFrac
variable tpLengthPoints
variable readTimeStamp
variable hsIndex
string device
variable measurementMarker
variable activeADCs
variable timeStamp
variable timeStampUTC
variable cycleId
EndStructure

/// @brief Helper structure for GetPlotArea()
Expand Down
13 changes: 11 additions & 2 deletions Packages/MIES/MIES_TestPulse.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -1530,14 +1530,23 @@ Function/DF TP_PrepareAnalysisDF(string device, STRUCT TPAnalysisInput &tpInput)
ASYNC_AddParam(threadDF, w = tpInput.data)
ASYNC_AddParam(threadDF, var = tpInput.clampAmp)
ASYNC_AddParam(threadDF, var = tpInput.clampMode)
ASYNC_AddParam(threadDF, var = tpInput.duration)
ASYNC_AddParam(threadDF, var = tpInput.pulseLengthPointsADC)
ASYNC_AddParam(threadDF, var = tpInput.baselineFrac)
ASYNC_AddParam(threadDF, var = tpInput.tpLengthPoints)
ASYNC_AddParam(threadDF, var = tpInput.tpLengthPointsADC)
ASYNC_AddParam(threadDF, var = tpInput.readTimeStamp)
ASYNC_AddParam(threadDF, var = tpInput.hsIndex)
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)
ASYNC_AddParam(threadDF, var = tpInput.cycleId)
ASYNC_AddParam(threadDF, var = tpInput.pulseStartPointsADC)
ASYNC_AddParam(threadDF, var = tpInput.samplingIntervalADC)
ASYNC_AddParam(threadDF, var = tpInput.tpLengthPointsDAC)
ASYNC_AddParam(threadDF, var = tpInput.pulseLengthPointsDAC)
ASYNC_AddParam(threadDF, var = tpInput.pulseStartPointsDAC)
ASYNC_AddParam(threadDF, var = tpInput.samplingIntervalDAC)

return threadDF
End
Expand Down

0 comments on commit 27dac75

Please sign in to comment.