Skip to content

Commit

Permalink
DAP: Move sampInt check for sutter to DAP_GetSampInt, apply GUI to AD…
Browse files Browse the repository at this point in the history
… type chan

- Check the validity of the sample interval determined from the GUI settings
  directly in DAP_GetSampInt
- Use the GUI settings only to determine AD sample rates for sutter,
  for DA and TTL use the minimum sample interval
  • Loading branch information
MichaelHuth committed Jan 9, 2024
1 parent d51b2c1 commit 75c7551
Showing 1 changed file with 28 additions and 26 deletions.
54 changes: 28 additions & 26 deletions Packages/MIES/MIES_DAEphys.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -1660,12 +1660,16 @@ Function DAP_GetSampInt(string device, variable dataAcqOrTP, variable channelTyp
endif

if(dataAcqOrTP == DATA_ACQUISITION_MODE)
if(IsDeviceNameFromSutter(device) && channelType != XOP_CHANNEL_TYPE_ADC)
return SI_CalculateMinSampInterval(device, dataAcqOrTP, channelType)
endif

fixedFreqkHzStr = DAG_GetTextualValue(device, "Popup_Settings_FixedFreq")
if(cmpstr(fixedFreqkHzStr, "Maximum"))
sampInt = 1 / (str2num(fixedFreqkHzStr) * KILO_TO_ONE) * ONE_TO_MICRO

if(!ParamIsDefault(valid))
valid = sampInt >= SI_CalculateMinSampInterval(device, DATA_ACQUISITION_MODE, channelType)
valid = DAP_IsSampleIntervalValid(device, channelType, sampInt)
endif

return sampInt
Expand All @@ -1680,6 +1684,29 @@ Function DAP_GetSampInt(string device, variable dataAcqOrTP, variable channelTyp
endif
End

static Function DAP_IsSampleIntervalValid(string device, variable channelType, variable sampInt)

if(!IsDeviceNameFromSutter(device))
return sampInt >= SI_CalculateMinSampInterval(device, DATA_ACQUISITION_MODE, channelType)
endif

switch(channelType)
case XOP_CHANNEL_TYPE_DAC: // intended drop-through
case XOP_CHANNEL_TYPE_TTL:
WAVE allowedIntervals = GetSutterDACTTLSampleInterval()
FindValue/Z/V=(sampInt) allowedIntervals
return V_value >= 0
case XOP_CHANNEL_TYPE_ADC:
WAVE allowedIntervals = GetSutterADCSampleInterval()
FindValue/Z/V=(sampInt) allowedIntervals
return V_value >= 0
default:
ASSERT(0, "Invalid channel type")
endswitch

ASSERT(0, "If that location is reached a case was not handled that should be handled.")
End

Function DAP_UpdateSweepSetVariables(device)
string device

Expand Down Expand Up @@ -1940,7 +1967,6 @@ End
static Function DAP_CheckSampleInterval(string device, variable mode)

variable sampIntADC, sampIntDAC, sampIntTTL, validSampInt
variable hardwareType

sampIntDAC = DAP_GetSampInt(device, mode, XOP_CHANNEL_TYPE_DAC, valid=validSampInt)
if(!validSampInt)
Expand All @@ -1962,30 +1988,6 @@ static Function DAP_CheckSampleInterval(string device, variable mode)
ControlWindowToFront()
return 1
endif
return 0
hardwareType = GetHardwareType(device)
if(hardwareType == HARDWARE_SUTTER_DAC)
WAVE allowedIntervals = GetSutterDACTTLSampleInterval()
FindValue/Z/V=(sampIntDAC) allowedIntervals
if(V_value == -1)
printf "%s: The selected sampling interval is not available for DAC on sutter hardware: %f\r", device, sampIntDAC
ControlWindowToFront()
return 1
endif
FindValue/Z/V=(sampIntTTL) allowedIntervals
if(V_value == -1)
printf "%s: The selected sampling interval is not available for TTL on sutter hardware: %f\r", device, sampIntTTL
ControlWindowToFront()
return 1
endif
WAVE allowedIntervals = GetSutterADCSampleInterval()
FindValue/Z/V=(sampIntADC) allowedIntervals
if(V_value == -1)
printf "%s: The selected sampling interval is not available for ADC on sutter hardware: %f\r", device, sampIntADC
ControlWindowToFront()
return 1
endif
endif

return 0
End
Expand Down

0 comments on commit 75c7551

Please sign in to comment.