Skip to content

Commit

Permalink
FFI_QueryLogbook: Add it
Browse files Browse the repository at this point in the history
  • Loading branch information
t-b committed Sep 3, 2024
1 parent 24765b2 commit b94acc5
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Packages/MIES/MIES_ForeignFunctionInterface.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,33 @@ Function FFI_SetCellElectrodeName(string device, variable headstage, string name

cellElectrodeNames[headstage] = name
End

/// @brief Query logbook entries from devices
///
/// This allows to query labnotebook/results entries from associated channels.
///
/// @param device Name of the hardware device panel, @sa GetLockedDevices()
/// @param logbookType One of #LBT_LABNOTEBOOK or #LBT_RESULTS
/// @param sweepNo Sweep number
/// @param setting Name of the entry
/// @param entrySourceType One of #DATA_ACQUISITION_MODE/#UNKNOWN_MODE/#TEST_PULSE_MODE
///
/// @return Numerical/Textual wave with #LABNOTEBOOK_LAYER_COUNT rows or a null wave reference if nothing could be found
Function/WAVE FFI_QueryLogbook(string device, variable logbookType, variable sweepNo, string setting, variable entrySourceType)

ASSERT(logbookType != LBT_TPSTORAGE, "Invalid logbook type")

WAVE/T numericalValues = GetLogbookWaves(logbookType, LBN_NUMERICAL_VALUES, device = device)

WAVE/Z settings = GetLastSetting(numericalValues, sweepNo, setting, entrySourceType)

if(WaveExists(settings))
return settings
endif

WAVE/T textualValues = GetLogbookWaves(logbookType, LBN_TEXTUAL_VALUES, device = device)

WAVE/Z settings = GetLastSetting(textualValues, sweepNo, setting, entrySourceType)

return settings
End
13 changes: 13 additions & 0 deletions Packages/tests/Basic/UTF_ForeignFunctionInterface.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,16 @@ static Function TestMessageFilters()

CHECK_PROPER_STR(wvNote)
End

static Function TestLogbookQuery()
string key, keyTxT, device

device = "ITC16USB_0_DEV"
[key, keyTxt] = PrepareLBN_IGNORE(device)

WAVE/Z settings = FFI_QueryLogbook(device, LBT_LABNOTEBOOK, 0, key, DATA_ACQUISITION_MODE)
CHECK_WAVE(settings, NUMERIC_WAVE)

WAVE/Z settings = FFI_QueryLogbook(device, LBT_LABNOTEBOOK, 0, keyTxt, DATA_ACQUISITION_MODE)
CHECK_WAVE(settings, TEXT_WAVE)
End

0 comments on commit b94acc5

Please sign in to comment.