diff --git a/Packages/MIES/MIES_DAEphys.ipf b/Packages/MIES/MIES_DAEphys.ipf index ae9f2461ba..674fec6593 100644 --- a/Packages/MIES/MIES_DAEphys.ipf +++ b/Packages/MIES/MIES_DAEphys.ipf @@ -5611,8 +5611,12 @@ Function [variable minimum, variable maximum] DAP_GetDataLimits(string device, v variable minVolt, maxVolt, gain, hardwareType, DAC, minStimset, maxStimset, activeDACIndex string ctrl, text, msg + if(DAP_DeviceIsUnLocked(device)) + return [NaN, NaN] + endif + DAC = AFH_GetDACFromHeadstage(device, headstage) - if(IsNaN(DAC)) + if(!IsValidHeadstage(DAC)) return [NaN, NaN] endif @@ -5632,7 +5636,6 @@ Function [variable minimum, variable maximum] DAP_GetDataLimits(string device, v WAVE DAQConfigWave = GetDAQConfigWave(device) WAVE DACs = GetDACListFromConfig(DAQConfigWave) activeDACIndex = GetRowIndex(DACs, val = DAC) - ASSERT(IsFinite(activeDACIndex), "Invalid DAC") WAVE gains = SWS_GetChannelGains(device, timing = GAIN_BEFORE_DAQ) gain = gains[activeDACIndex] diff --git a/Packages/tests/HardwareBasic/UTF_BasicHardwareTests.ipf b/Packages/tests/HardwareBasic/UTF_BasicHardwareTests.ipf index 0734bb1985..207f1a763e 100644 --- a/Packages/tests/HardwareBasic/UTF_BasicHardwareTests.ipf +++ b/Packages/tests/HardwareBasic/UTF_BasicHardwareTests.ipf @@ -2491,3 +2491,60 @@ static Function TestCustomElectrodeNamesInNWB_REENTRY([string str]) CHECK_EQUAL_VAR(GetSetVariable(str, "SetVar_Sweep"), 1) TestNwbExportV2() End + +// UTF_TD_GENERATOR DeviceNameGeneratorMD1 +static Function GetDataLimitsChecksWorks([string str]) + + variable minimum, maximum + + // unlocked device + [minimum, maximum] = DAP_GetDataLimits(str, 1, "StimulusSetA_DA_0", 0) + CHECK(IsNaN(minimum)) + CHECK(IsNaN(maximum)) + + STRUCT DAQSettings s + InitDAQSettingsFromString(s, "MD1_RA1_I0_L0_BKG1_TP1" + \ + "__HS1_DA1_AD2_CM:IC:_ST:StimulusSetA_DA_0:") + + AcquireData_NG(s, str) + + CtrlNamedBackGround StopTPAfterSomeTime, start=(ticks + 120), period=60, proc=StopTP_IGNORE +End + +static Function GetDataLimitsChecksWorks_REENTRY([string str]) + + string stimset + variable minimum, maximum, headstage + + headstage = 1 + stimset = "StimulusSetA_DA_0" + + // unassociated/unused headstage + [minimum, maximum] = DAP_GetDataLimits(str, 0, stimset, 0) + CHECK(IsNaN(minimum)) + CHECK(IsNaN(maximum)) + + // invalid setColumn + try + [minimum, maximum] = DAP_GetDataLimits(str, headstage, stimset, 4711) + FAIL() + catch + CHECK_NO_RTE() + endtry + + [minimum, maximum] = DAP_GetDataLimits(str, headstage, stimset, 0) + CHECK_EQUAL_VAR(minimum, -Inf) + CHECK_EQUAL_VAR(maximum, 4095) + + // @todo more proper test cases + + // third party + WB_MakeStimsetThirdParty(stimset) + + try + [minimum, maximum] = DAP_GetDataLimits(str, headstage, stimset, 0) + FAIL() + catch + CHECK_NO_RTE() + endtry +End diff --git a/Packages/tests/UTF_HardwareHelperFunctions.ipf b/Packages/tests/UTF_HardwareHelperFunctions.ipf index fe40fbc167..373b56c724 100644 --- a/Packages/tests/UTF_HardwareHelperFunctions.ipf +++ b/Packages/tests/UTF_HardwareHelperFunctions.ipf @@ -1293,7 +1293,9 @@ Function InitDAQSettingsFromString(s, str) continue endif - headstage = ParseNumber(elem, "HS") + headstage = ParseNumber(elem, "HS") + REQUIRE(IsValidHeadstage(headstage)) + s.hs[headstage] = 1 s.da[headstage] = ParseNumber(elem, "_DA")