Skip to content

Commit d309547

Browse files
committed
AI: Refactor AmplifierInteraction
- Moved MCC specific Amplifier functions to MIES_AmplifierInteraction_MolecularDevices.ipf - prefixed these functions with AIMCC_ - For all non-static AI_ functions, added abstraction that depending on device the MCC functions is called or a placeholder for Sutter amplifier is used. - Added device argument to AI_ functions that did not used one, adapted depending call sites - Kept checks of optional arguments in public AI_ functions - Changed function declaration of public AIMCC_ functions to not use optional arguments The reason is that optional arguments can not easily promoted through function calls. - Added updateView argument to AIMCC_UpdateAmpModel as ParamIsDefault state of value was used also for decision for updating the AmpView. This does not change the previous behavior. - Adapted function declaration of all AIMCC_ functions to use modern syntax
1 parent b54b06e commit d309547

10 files changed

+1752
-1566
lines changed

Packages/MIES/MIES_AmplifierInteraction.ipf

+118-1,549
Large diffs are not rendered by default.

Packages/MIES/MIES_AmplifierInteraction_MolecularDevices.ipf

+1,607
Large diffs are not rendered by default.

Packages/MIES/MIES_Configuration.ipf

+1-1
Original file line numberDiff line numberDiff line change
@@ -2012,7 +2012,7 @@ static Function CONF_RestoreHeadstageAssociation(device, jsonID, midExp)
20122012
WAVE telegraphServers = GetAmplifierTelegraphServers()
20132013
numRows = DimSize(telegraphServers, ROWS)
20142014
if(!numRows)
2015-
Assert(AI_OpenMCCs(ampSerialList, ampTitleList = ampTitleList), "Evil kittens prevented MultiClamp from opening - FULL STOP")
2015+
Assert(AI_OpenMCCs(device, ampSerialList, ampTitleList = ampTitleList), "Evil kittens prevented MultiClamp from opening - FULL STOP")
20162016
endif
20172017

20182018
CONF_Position_MCC_Win(ampSerialList, ampTitleList, CONF_GetStringFromSettings(jsonID, EXPCONFIG_JSON_POSITION_MCC))

Packages/MIES/MIES_Constants.ipf

+2-2
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,8 @@ Constant I_EQUAL_ZERO_MODE = 2
399399

400400
Constant NUM_CLAMP_MODES = 3
401401

402-
/// @name Possible values for the function parameter of AI_SendToAmp
403-
/// @anchor AI_SendToAmpConstants
402+
/// @name Possible values for the function parameter of AIMCC_SendToAmp
403+
/// @anchor AIMCC_SendToAmpConstants
404404
/// @{
405405
Constant MCC_BEGIN_INVALID_FUNC = 10000
406406
Constant MCC_SETHOLDING_FUNC = 10001

Packages/MIES/MIES_DAEphys.ipf

+11-8
Original file line numberDiff line numberDiff line change
@@ -1106,7 +1106,7 @@ Function GetHeadstageFromSettings(device, channelType, channelNumber, clampMode)
11061106

11071107
variable i, row
11081108

1109-
if(!AI_IsValidClampMode(clampMode))
1109+
if(!AI_IsValidClampMode(device, clampMode))
11101110
return NaN
11111111
endif
11121112

@@ -1748,9 +1748,12 @@ End
17481748
Function DAP_ButtonCtrlFindConnectedAmps(ba) : ButtonControl
17491749
STRUCT WMButtonAction &ba
17501750

1751+
string device
1752+
17511753
switch(ba.eventcode)
17521754
case 2: // mouse up
1753-
AI_FindConnectedAmps()
1755+
device = ba.win
1756+
AI_FindConnectedAmps(device)
17541757
break
17551758
endswitch
17561759
End
@@ -2552,7 +2555,7 @@ static Function DAP_CheckHeadStage(device, headStage, mode)
25522555

25532556
// needs to be at the beginning as DAP_ApplyClmpModeSavdSettngs writes into
25542557
// ChanAmpAssign/ChanAmpAssignUnit
2555-
if(ampConnState == AMPLIFIER_CONNECTION_SUCCESS && AI_IsValidClampMode(clampMode))
2558+
if(ampConnState == AMPLIFIER_CONNECTION_SUCCESS && AI_IsValidClampMode(device, clampMode))
25562559
DAP_ApplyClmpModeSavdSettngs(device, headstage, clampMode)
25572560
endif
25582561

@@ -2579,7 +2582,7 @@ static Function DAP_CheckHeadStage(device, headStage, mode)
25792582
if(ampConnState == AMPLIFIER_CONNECTION_SUCCESS)
25802583

25812584
AI_EnsureCorrectMode(device, headStage)
2582-
AI_QueryGainsUnitsForClampMode(device, headStage, clampMode, DAGainMCC, ADGainMCC, DAUnitMCC, ADUnitMCC)
2585+
[DAGainMCC, ADGainMCC, DAUnitMCC, ADUnitMCC] = AI_QueryGainsUnitsForClampMode(device, headStage, clampMode)
25832586

25842587
if(cmpstr(DAUnit, DAUnitMCC))
25852588
printf "(%s) The configured unit for the DA channel %d differs from the one in the \"DAC Channel and Device Associations\" menu (%s vs %s).\r", device, DACchannel, DAUnit, DAUnitMCC
@@ -3263,7 +3266,7 @@ Function DAP_GetInfoFromControl(device, ctrl, mode, headStage)
32633266
ASSERT(0, "unhandled control")
32643267
endif
32653268

3266-
AI_AssertOnInvalidClampMode(mode)
3269+
AI_AssertOnInvalidClampMode(device, mode)
32673270
End
32683271

32693272
Function DAP_CheckProc_ClampMode(cba) : CheckBoxControl
@@ -3338,7 +3341,7 @@ Function DAP_ChangeHeadStageMode(device, clampMode, headstage, options)
33383341
string iZeroCtrl, VCctrl, ICctrl, headstageCtrl, ctrl
33393342
variable activeHS, testPulseMode, oppositeMode, DAC, ADC, i, oldTab, oldState, newSliderPos
33403343

3341-
AI_AssertOnInvalidClampMode(clampMode)
3344+
AI_AssertOnInvalidClampMode(device, clampMode)
33423345
DAP_AbortIfUnlocked(device)
33433346

33443347
if(options != MCC_SKIP_UPDATES)
@@ -3489,7 +3492,7 @@ static Function DAP_UpdateClampmodeTabs(device, headStage, clampMode)
34893492

34903493
string highlightSpec = "\\f01\\Z11"
34913494

3492-
AI_AssertOnInvalidClampMode(clampMode)
3495+
AI_AssertOnInvalidClampMode(device, clampMode)
34933496

34943497
AI_SyncAmpStorageToGUI(device, headStage)
34953498
PGC_SetAndActivateControl(device, "tab_DataAcq_Amp", val = clampMode)
@@ -4564,7 +4567,7 @@ Function DAP_LockDevice(string win)
45644567
locked = 1
45654568
DAP_UpdateDataFolderDisplay(deviceLocked, locked)
45664569

4567-
AI_FindConnectedAmps()
4570+
AI_FindConnectedAmps(deviceLocked)
45684571
DAP_UpdateListOfLockedDevices()
45694572
DAP_UpdateListOfPressureDevices()
45704573
headstage = str2num(GetPopupMenuString(deviceLocked, "Popup_Settings_HeadStage"))

Packages/MIES/MIES_DAEphys_GuiState.ipf

+1-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ End
330330
/// @brief Return a wave with `NUM_HEADSTAGES` rows with `1` where
331331
/// the given headstages is active and in the given clamp mode.
332332
Function/WAVE DAG_GetActiveHeadstages(string device, variable clampMode)
333-
AI_AssertOnInvalidClampMode(clampMode)
333+
AI_AssertOnInvalidClampMode(device, clampMode)
334334

335335
WAVE statusHS = DAG_GetChannelState(device, CHANNEL_TYPE_HEADSTAGE)
336336
WAVE GUIState = GetDA_EphysGuiStateNum(device)

Packages/MIES_Include.ipf

+1
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ End
160160
#include "MIES_AcceleratedModifyGraph"
161161
#include "MIES_AcquisitionStateHandling"
162162
#include "MIES_AmplifierInteraction"
163+
#include "MIES_AmplifierInteraction_MolecularDevices"
163164
#include "MIES_AnalysisBrowser"
164165
#include "MIES_AnalysisBrowser_Macro"
165166
#include "MIES_AnalysisBrowser_SweepBrowser"

Packages/tests/PAPlot/UTF_PA_Tests.ipf

+7-1
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,10 @@
419419
// data is properly NaNed on the left and right edge.
420420
static Constant PA_TEST_FP_EPSILON = 1E-6
421421

422+
static StrConstant DEVICENAME_SUTTER = "IPA_E_000000"
423+
static StrConstant DEVICENAME_NI = "Dev1"
424+
static StrConstant DEVICENAME_ITC = "ITC"
425+
422426
static Function TEST_BEGIN_OVERRIDE(string name)
423427
TestBeginCommon()
424428
End
@@ -926,7 +930,9 @@ static Function PAT_CheckPulseWaveNote(string win, WAVE pulse)
926930
CHECK_LT_VAR(first, last)
927931

928932
setting = PAT_GetNumberFromPulseWaveNote(pulse, NOTE_KEY_CLAMP_MODE)
929-
CHECK(AI_IsValidClampMode(setting))
933+
CHECK(AI_IsValidClampMode(DEVICENAME_ITC, setting))
934+
CHECK(AI_IsValidClampMode(DEVICENAME_NI, setting))
935+
CHECK(AI_IsValidClampMode(DEVICENAME_SUTTER, setting))
930936

931937
// no zeros inside the pulse
932938
// this requires that the DA and AD channels on the hardware are connected directly when acquiring this data

Packages/tests/UTF_HardwareHelperFunctions.ipf

+3-3
Original file line numberDiff line numberDiff line change
@@ -1100,8 +1100,8 @@ Function OpenDatabrowser()
11001100
PGC_SetAndActivateControl(bsPanel, "check_BrowserSettings_DS", val = 1)
11011101
End
11021102

1103-
Function EnsureMCCIsOpen()
1104-
AI_FindConnectedAmps()
1103+
Function EnsureMCCIsOpen(string device)
1104+
AI_FindConnectedAmps(device)
11051105

11061106
WAVE ampMCC = GetAmplifierMultiClamps()
11071107
WAVE ampTel = GetAmplifierTelegraphServers()
@@ -1422,7 +1422,7 @@ Function AcquireData_NG(STRUCT DAQSettings &s, string device)
14221422
variable i, activeHS
14231423

14241424
if(s.amp)
1425-
EnsureMCCIsOpen()
1425+
EnsureMCCIsOpen(device)
14261426
endif
14271427

14281428
FetchCustomizationFunctions(s)

Packages/tests/UTF_HelperFunctions.ipf

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Function FixupJSONConfigImplRig(variable jsonId)
4242
variable serialNum, i
4343

4444
// replace stored serial number with present serial number
45-
AI_FindConnectedAmps()
45+
AI_FindConnectedAmps("")
4646
WAVE ampMCC = GetAmplifierMultiClamps()
4747

4848
CHECK_GT_VAR(DimSize(ampMCC, ROWS), 0)

0 commit comments

Comments
 (0)