Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
t-b committed Oct 18, 2024
1 parent fba2809 commit 9fdf459
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 3 deletions.
7 changes: 5 additions & 2 deletions Packages/MIES/MIES_DAEphys.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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]
Expand Down
57 changes: 57 additions & 0 deletions Packages/tests/HardwareBasic/UTF_BasicHardwareTests.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion Packages/tests/UTF_HardwareHelperFunctions.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 9fdf459

Please sign in to comment.