Skip to content

Commit f2c14d4

Browse files
committed
DC_GenerateStimsetFingerprint: Move from StringCRC to HashString
And add a textual helper wave for data acquisition to store the hash.
1 parent a0f2acf commit f2c14d4

File tree

3 files changed

+53
-25
lines changed

3 files changed

+53
-25
lines changed

Packages/MIES/MIES_DAEphys.ipf

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,8 +1220,11 @@ Function DAP_OneTimeCallBeforeDAQ(string device, variable runMode)
12201220
NVAR fifoPosition = $GetFifoPosition(device)
12211221
fifoPosition = NaN
12221222

1223-
WAVE stimsetAcqIDHelper = GetStimsetAcqIDHelperWave(device)
1224-
stimsetAcqIDHelper = NaN
1223+
WAVE stimsetAcqIDNumericalHelper = GetStimsetAcqIDNumericalHelperWave(device)
1224+
stimsetAcqIDNumericalHelper = NaN
1225+
1226+
WAVE/T stimsetAcqIDTextualHelper = GetStimsetAcqIDTextualHelperWave(device)
1227+
stimsetAcqIDTextualHelper = ""
12251228

12261229
DAP_ClearDelayedClampModeChange(device)
12271230

Packages/MIES/MIES_DataConfigurator.ipf

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,8 +1105,8 @@ End
11051105

11061106
static Function DC_PrepareLBNEntries(string device, STRUCT DataConfigurationResult &s)
11071107

1108-
variable i, j, maxITI, channel, headstage, fingerprint, stimsetCycleID, isoodDAQMember, samplingInterval
1109-
string func, ctrl, str, setChecksum
1108+
variable i, j, maxITI, channel, headstage, stimsetCycleID, isoodDAQMember, samplingInterval
1109+
string func, ctrl, str, fingerprint, setChecksum
11101110

11111111
WAVE config = GetDAQConfigWave(device)
11121112

@@ -1865,20 +1865,21 @@ End
18651865
/// @param device device
18661866
/// @param fingerprint fingerprint as returned by DC_GenerateStimsetFingerprint()
18671867
/// @param DAC DA channel
1868-
static Function DC_GetStimsetAcqCycleID(string device, variable fingerprint, variable DAC)
1868+
static Function DC_GetStimsetAcqCycleID(string device, string fingerprint, variable DAC)
18691869

1870-
WAVE stimsetAcqIDHelper = GetStimsetAcqIDHelperWave(device)
1870+
WAVE stimsetAcqIDNumericalHelper = GetStimsetAcqIDNumericalHelperWave(device)
1871+
WAVE/T stimsetAcqIDTextualHelper = GetStimsetAcqIDTextualHelperWave(device)
18711872

1872-
ASSERT(IsFinite(fingerprint), "Invalid fingerprint")
1873+
ASSERT(IsEmpty(fingerprint), "Invalid fingerprint")
18731874

1874-
if(fingerprint == stimsetAcqIDHelper[DAC][%fingerprint])
1875-
return stimsetAcqIDHelper[DAC][%id]
1875+
if(!cmpstr(fingerprint, stimsetAcqIDTextualHelper[DAC][%fingerprint]))
1876+
return stimsetAcqIDNumericalHelper[DAC][%id]
18761877
endif
18771878

1878-
stimsetAcqIDHelper[DAC][%fingerprint] = fingerprint
1879-
stimsetAcqIDHelper[DAC][%id] = GetNextRandomNumberForDevice(device)
1879+
stimsetAcqIDTextualHelper[DAC][%fingerprint] = fingerprint
1880+
stimsetAcqIDNumericalHelper[DAC][%id] = GetNextRandomNumberForDevice(device)
18801881

1881-
return stimsetAcqIDHelper[DAC][%id]
1882+
return stimsetAcqIDNumericalHelper[DAC][%id]
18821883
End
18831884

18841885
/// @brief Generate the stimset fingerprint
@@ -1891,21 +1892,21 @@ End
18911892
///
18921893
/// Always then this fingerprint changes, a new stimset acquisition cycle ID has
18931894
/// to be generated.
1894-
static Function DC_GenerateStimsetFingerprint(variable raCycleID, string setName, variable setCycleCount, string setChecksum)
1895+
static Function/S DC_GenerateStimsetFingerprint(variable raCycleID, string setName, variable setCycleCount, string setChecksum)
18951896

1896-
variable crc
1897+
string hv = ""
18971898

18981899
ASSERT(IsInteger(raCycleID) && raCycleID > 0, "Invalid raCycleID")
18991900
ASSERT(IsInteger(setCycleCount), "Invalid setCycleCount")
19001901
ASSERT(!IsEmpty(setChecksum), "Invalid stimset checksum")
19011902
ASSERT(!IsEmpty(setName) && !cmpstr(setName, trimstring(setName)), "Invalid setName")
19021903

1903-
crc = StringCRC(crc, num2str(raCycleID))
1904-
crc = StringCRC(crc, num2str(setCycleCount))
1905-
crc = StringCRC(crc, setChecksum)
1906-
crc = StringCRC(crc, setName)
1904+
hv = HashNumber(hv, raCycleID)
1905+
hv = HashNumber(hv, setCycleCount)
1906+
hv = HashString(hv, setChecksum)
1907+
hv = HashString(hv, setName)
19071908

1908-
return crc
1909+
return hv
19091910
End
19101911

19111912
static Function [variable result, variable row, variable column] DC_CheckIfDataWaveHasBorderVals(string device, variable dataAcqOrTP)

Packages/MIES/MIES_WaveDataFolderGetters.ipf

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,7 +1251,33 @@ Function/WAVE GetTTLWave(string device)
12511251
endswitch
12521252
End
12531253

1254-
/// @brief Return the stimset acquistion cycle ID helper wave
1254+
/// @brief Return the stimset acquisition cycle ID helper wave (numerical)
1255+
///
1256+
/// Only valid during DAQ.
1257+
///
1258+
/// Rows:
1259+
/// - NUM_DA_TTL_CHANNELS
1260+
///
1261+
/// Columns:
1262+
/// - 0: Current stimset acquisition cycle ID
1263+
Function/WAVE GetStimsetAcqIDNumericalHelperWave(string device)
1264+
1265+
DFREF dfr = GetDevicePath(device)
1266+
1267+
WAVE/Z/D/SDFR=dfr wv = stimsetAcqIDNumericalHelper
1268+
1269+
if(WaveExists(wv))
1270+
return wv
1271+
endif
1272+
1273+
Make/D/N=(NUM_DA_TTL_CHANNELS, 1) dfr:stimsetAcqIDNumericalHelper/WAVE=wv
1274+
1275+
SetDimLabel COLS, 0, id, wv
1276+
1277+
return wv
1278+
End
1279+
1280+
/// @brief Return the stimset acquisition cycle ID helper wave (textual)
12551281
///
12561282
/// Only valid during DAQ.
12571283
///
@@ -1260,21 +1286,19 @@ End
12601286
///
12611287
/// Columns:
12621288
/// - 0: Stimset fingerprint of the previous sweep
1263-
/// - 1: Current stimset acquisition cycle ID
1264-
Function/WAVE GetStimsetAcqIDHelperWave(string device)
1289+
Function/WAVE GetStimsetAcqIDTextualHelperWave(string device)
12651290

12661291
DFREF dfr = GetDevicePath(device)
12671292

1268-
WAVE/Z/D/SDFR=dfr wv = stimsetAcqIDHelper
1293+
WAVE/Z/T/SDFR=dfr wv = stimsetAcqIDHelper
12691294

12701295
if(WaveExists(wv))
12711296
return wv
12721297
endif
12731298

1274-
Make/D/N=(NUM_DA_TTL_CHANNELS, 2) dfr:stimsetAcqIDHelper/WAVE=wv
1299+
Make/T/N=(NUM_DA_TTL_CHANNELS, 1) dfr:stimsetAcqIDTextualHelper/WAVE=wv
12751300

12761301
SetDimLabel COLS, 0, fingerprint, wv
1277-
SetDimLabel COLS, 1, id, wv
12781302

12791303
return wv
12801304
End

0 commit comments

Comments
 (0)