Skip to content

Commit 0d674dc

Browse files
committed
changes
1 parent b549ec2 commit 0d674dc

File tree

1 file changed

+155
-145
lines changed

1 file changed

+155
-145
lines changed

Packages/MIES/MIES_AmplifierInteraction.ipf

+155-145
Original file line numberDiff line numberDiff line change
@@ -802,151 +802,6 @@ static Function/S AI_GetMCCWinFilePath()
802802
return "ERROR"
803803
End
804804

805-
#ifdef AMPLIFIER_XOPS_PRESENT
806-
807-
///@brief Returns the holding command of the amplifier
808-
Function AI_GetHoldingCommand(string device, variable headstage)
809-
810-
if(AI_SelectMultiClamp(device, headstage) != AMPLIFIER_CONNECTION_SUCCESS)
811-
return NaN
812-
endif
813-
814-
return MCC_GetHoldingEnable() ? (MCC_GetHolding() * AI_GetMCCScale(MCC_GetMode(), MCC_GETHOLDING_FUNC)) : 0
815-
End
816-
817-
/// @brief Return the clamp mode of the headstage as returned by the amplifier
818-
///
819-
/// Should only be used during the setup phase when you don't know if the
820-
/// clamp mode in MIES matches already. It is always better to prefer
821-
/// DAP_ChangeHeadStageMode() if possible.
822-
///
823-
/// @brief One of @ref AmplifierClampModes or NaN if no amplifier is connected
824-
Function AI_GetMode(string device, variable headstage)
825-
826-
if(AI_SelectMultiClamp(device, headstage) != AMPLIFIER_CONNECTION_SUCCESS)
827-
return NaN
828-
endif
829-
830-
return MCC_GetMode()
831-
End
832-
833-
/// @brief Return the DA/AD gains of the given headstage
834-
///
835-
/// Internally we query the External Command Sensitivity of the Amplifier (MCC) GUI.
836-
///
837-
/// =========== ==========================
838-
/// ClampMode MultiClampCommander GUI
839-
/// =========== ==========================
840-
/// VC Off
841-
/// 20 mV/V
842-
/// 100 mV/V
843-
/// =========== ==========================
844-
/// IC Off
845-
/// 400 pA/V
846-
/// 2 nA/V
847-
/// =========== ==========================
848-
///
849-
/// Gain is returned in mV/V for #V_CLAMP_MODE and pA/V for #I_CLAMP_MODE/#I_EQUAL_ZERO_MODE
850-
///
851-
/// @param device device
852-
/// @param headstage headstage [0, NUM_HEADSTAGES[
853-
/// @param clampMode clamp mode
854-
/// @param[out] ADGain ADC gain
855-
/// @param[out] DAGain DAC gain
856-
static Function AI_RetrieveGains(string device, variable headstage, variable clampMode, variable &ADGain, variable &DAGain)
857-
858-
variable axonSerial = AI_GetAmpAxonSerial(device, headstage)
859-
variable channel = AI_GetAmpChannel(device, headStage)
860-
861-
[STRUCT AxonTelegraph_DataStruct tds] = AI_GetTelegraphStruct(axonSerial, channel)
862-
863-
ASSERT(clampMode == tds.OperatingMode, "Non matching clamp mode from MCC application")
864-
865-
ADGain = tds.ScaleFactor * tds.Alpha / ONE_TO_MILLI
866-
clampMode = tds.OperatingMode
867-
868-
if(tds.OperatingMode == V_CLAMP_MODE)
869-
DAGain = tds.ExtCmdSens * ONE_TO_MILLI
870-
elseif(tds.OperatingMode == I_CLAMP_MODE || tds.OperatingMode == I_EQUAL_ZERO_MODE)
871-
DAGain = tds.ExtCmdSens * ONE_TO_PICO
872-
endif
873-
End
874-
875-
/// @brief Changes the mode of the amplifier between I-Clamp and V-Clamp depending on the currently set mode
876-
///
877-
/// Assumes that the correct amplifier is selected.
878-
static Function AI_SwitchAxonAmpMode()
879-
880-
variable mode
881-
882-
mode = MCC_GetMode()
883-
884-
if(mode == V_CLAMP_MODE)
885-
MCC_SetMode(I_CLAMP_MODE)
886-
elseif(mode == I_CLAMP_MODE || mode == I_EQUAL_ZERO_MODE)
887-
MCC_SetMode(V_CLAMP_MODE)
888-
else
889-
// do nothing
890-
endif
891-
End
892-
893-
/// @brief Wrapper for MCC_SelectMultiClamp700B
894-
///
895-
/// @param device device
896-
/// @param headStage MIES headstage number, must be in the range [0, NUM_HEADSTAGES]
897-
///
898-
/// @returns one of @ref AISelectMultiClampReturnValues
899-
Function AI_SelectMultiClamp(string device, variable headStage)
900-
901-
variable channel, axonSerial, err
902-
string mccSerial
903-
904-
// checking axonSerial is done as a service to the caller
905-
axonSerial = AI_GetAmpAxonSerial(device, headStage)
906-
mccSerial = AI_GetAmpMCCSerial(device, headStage)
907-
channel = AI_GetAmpChannel(device, headStage)
908-
909-
if(!AI_IsValidSerialAndChannel(mccSerial = mccSerial, axonSerial = axonSerial, channel = channel))
910-
return AMPLIFIER_CONNECTION_INVAL_SER
911-
endif
912-
913-
AssertOnAndClearRTError()
914-
MCC_SelectMultiClamp700B(mccSerial, channel); err = GetRTError(1) // see developer docu section Preventing Debugger Popup
915-
916-
if(err)
917-
return AMPLIFIER_CONNECTION_MCC_FAILED
918-
endif
919-
920-
return AMPLIFIER_CONNECTION_SUCCESS
921-
End
922-
923-
/// @brief Set the clamp mode of user linked MCC based on the headstage number
924-
Function AI_SetClampMode(string device, variable headStage, variable mode, [variable zeroStep])
925-
926-
if(ParamIsDefault(zeroStep))
927-
zeroStep = 0
928-
else
929-
zeroStep = !!zeroStep
930-
endif
931-
932-
AI_AssertOnInvalidClampMode(mode)
933-
934-
if(AI_SelectMultiClamp(device, headStage) != AMPLIFIER_CONNECTION_SUCCESS)
935-
return NaN
936-
endif
937-
938-
if(zeroStep && (mode == I_CLAMP_MODE || mode == V_CLAMP_MODE))
939-
if(!IsFinite(MCC_SetMode(I_EQUAL_ZERO_MODE)))
940-
printf "MCC amplifier cannot be switched to mode %d. Linked MCC is no longer present\r", mode
941-
endif
942-
Sleep/Q/T/C=-1 6
943-
endif
944-
945-
if(!IsFinite(MCC_SetMode(mode)))
946-
printf "MCC amplifier cannot be switched to mode %d. Linked MCC is no longer present\r", mode
947-
endif
948-
End
949-
950805
/// @brief Map from amplifier control names to @ref AI_SendToAmpConstants constants and clamp mode
951806
Function [variable func, variable clampMode] AI_MapControlNameToFunctionConstant(string ctrl)
952807

@@ -1373,6 +1228,151 @@ static Function/S AI_AmpStorageControlToRowLabel(string ctrl)
13731228
endswitch
13741229
End
13751230

1231+
#ifdef AMPLIFIER_XOPS_PRESENT
1232+
1233+
///@brief Returns the holding command of the amplifier
1234+
Function AI_GetHoldingCommand(string device, variable headstage)
1235+
1236+
if(AI_SelectMultiClamp(device, headstage) != AMPLIFIER_CONNECTION_SUCCESS)
1237+
return NaN
1238+
endif
1239+
1240+
return MCC_GetHoldingEnable() ? (MCC_GetHolding() * AI_GetMCCScale(MCC_GetMode(), MCC_GETHOLDING_FUNC)) : 0
1241+
End
1242+
1243+
/// @brief Return the clamp mode of the headstage as returned by the amplifier
1244+
///
1245+
/// Should only be used during the setup phase when you don't know if the
1246+
/// clamp mode in MIES matches already. It is always better to prefer
1247+
/// DAP_ChangeHeadStageMode() if possible.
1248+
///
1249+
/// @brief One of @ref AmplifierClampModes or NaN if no amplifier is connected
1250+
Function AI_GetMode(string device, variable headstage)
1251+
1252+
if(AI_SelectMultiClamp(device, headstage) != AMPLIFIER_CONNECTION_SUCCESS)
1253+
return NaN
1254+
endif
1255+
1256+
return MCC_GetMode()
1257+
End
1258+
1259+
/// @brief Return the DA/AD gains of the given headstage
1260+
///
1261+
/// Internally we query the External Command Sensitivity of the Amplifier (MCC) GUI.
1262+
///
1263+
/// =========== ==========================
1264+
/// ClampMode MultiClampCommander GUI
1265+
/// =========== ==========================
1266+
/// VC Off
1267+
/// 20 mV/V
1268+
/// 100 mV/V
1269+
/// =========== ==========================
1270+
/// IC Off
1271+
/// 400 pA/V
1272+
/// 2 nA/V
1273+
/// =========== ==========================
1274+
///
1275+
/// Gain is returned in mV/V for #V_CLAMP_MODE and pA/V for #I_CLAMP_MODE/#I_EQUAL_ZERO_MODE
1276+
///
1277+
/// @param device device
1278+
/// @param headstage headstage [0, NUM_HEADSTAGES[
1279+
/// @param clampMode clamp mode
1280+
/// @param[out] ADGain ADC gain
1281+
/// @param[out] DAGain DAC gain
1282+
static Function AI_RetrieveGains(string device, variable headstage, variable clampMode, variable &ADGain, variable &DAGain)
1283+
1284+
variable axonSerial = AI_GetAmpAxonSerial(device, headstage)
1285+
variable channel = AI_GetAmpChannel(device, headStage)
1286+
1287+
[STRUCT AxonTelegraph_DataStruct tds] = AI_GetTelegraphStruct(axonSerial, channel)
1288+
1289+
ASSERT(clampMode == tds.OperatingMode, "Non matching clamp mode from MCC application")
1290+
1291+
ADGain = tds.ScaleFactor * tds.Alpha / ONE_TO_MILLI
1292+
clampMode = tds.OperatingMode
1293+
1294+
if(tds.OperatingMode == V_CLAMP_MODE)
1295+
DAGain = tds.ExtCmdSens * ONE_TO_MILLI
1296+
elseif(tds.OperatingMode == I_CLAMP_MODE || tds.OperatingMode == I_EQUAL_ZERO_MODE)
1297+
DAGain = tds.ExtCmdSens * ONE_TO_PICO
1298+
endif
1299+
End
1300+
1301+
/// @brief Changes the mode of the amplifier between I-Clamp and V-Clamp depending on the currently set mode
1302+
///
1303+
/// Assumes that the correct amplifier is selected.
1304+
static Function AI_SwitchAxonAmpMode()
1305+
1306+
variable mode
1307+
1308+
mode = MCC_GetMode()
1309+
1310+
if(mode == V_CLAMP_MODE)
1311+
MCC_SetMode(I_CLAMP_MODE)
1312+
elseif(mode == I_CLAMP_MODE || mode == I_EQUAL_ZERO_MODE)
1313+
MCC_SetMode(V_CLAMP_MODE)
1314+
else
1315+
// do nothing
1316+
endif
1317+
End
1318+
1319+
/// @brief Wrapper for MCC_SelectMultiClamp700B
1320+
///
1321+
/// @param device device
1322+
/// @param headStage MIES headstage number, must be in the range [0, NUM_HEADSTAGES]
1323+
///
1324+
/// @returns one of @ref AISelectMultiClampReturnValues
1325+
Function AI_SelectMultiClamp(string device, variable headStage)
1326+
1327+
variable channel, axonSerial, err
1328+
string mccSerial
1329+
1330+
// checking axonSerial is done as a service to the caller
1331+
axonSerial = AI_GetAmpAxonSerial(device, headStage)
1332+
mccSerial = AI_GetAmpMCCSerial(device, headStage)
1333+
channel = AI_GetAmpChannel(device, headStage)
1334+
1335+
if(!AI_IsValidSerialAndChannel(mccSerial = mccSerial, axonSerial = axonSerial, channel = channel))
1336+
return AMPLIFIER_CONNECTION_INVAL_SER
1337+
endif
1338+
1339+
AssertOnAndClearRTError()
1340+
MCC_SelectMultiClamp700B(mccSerial, channel); err = GetRTError(1) // see developer docu section Preventing Debugger Popup
1341+
1342+
if(err)
1343+
return AMPLIFIER_CONNECTION_MCC_FAILED
1344+
endif
1345+
1346+
return AMPLIFIER_CONNECTION_SUCCESS
1347+
End
1348+
1349+
/// @brief Set the clamp mode of user linked MCC based on the headstage number
1350+
Function AI_SetClampMode(string device, variable headStage, variable mode, [variable zeroStep])
1351+
1352+
if(ParamIsDefault(zeroStep))
1353+
zeroStep = 0
1354+
else
1355+
zeroStep = !!zeroStep
1356+
endif
1357+
1358+
AI_AssertOnInvalidClampMode(mode)
1359+
1360+
if(AI_SelectMultiClamp(device, headStage) != AMPLIFIER_CONNECTION_SUCCESS)
1361+
return NaN
1362+
endif
1363+
1364+
if(zeroStep && (mode == I_CLAMP_MODE || mode == V_CLAMP_MODE))
1365+
if(!IsFinite(MCC_SetMode(I_EQUAL_ZERO_MODE)))
1366+
printf "MCC amplifier cannot be switched to mode %d. Linked MCC is no longer present\r", mode
1367+
endif
1368+
Sleep/Q/T/C=-1 6
1369+
endif
1370+
1371+
if(!IsFinite(MCC_SetMode(mode)))
1372+
printf "MCC amplifier cannot be switched to mode %d. Linked MCC is no longer present\r", mode
1373+
endif
1374+
End
1375+
13761376
/// @brief Send the value to the amplifier
13771377
///
13781378
/// In addition the internal amplifier storage wave is updated as well and an amplifier state change message is sent
@@ -2118,6 +2118,16 @@ Function AI_SetClampMode(string device, variable headStage, variable mode, [vari
21182118
DEBUGPRINT("Unimplemented")
21192119
End
21202120

2121+
Function AI_ReadFromAmplifier(string device, variable headStage, variable mode, variable func, variable value, [variable checkBeforeWrite, variable usePrefixes, variable selectAmp])
2122+
2123+
DEBUGPRINT("Unimplemented")
2124+
End
2125+
2126+
Function AI_WriteToAmplifier(string device, variable headStage, variable mode, variable func, variable value, [variable sendToAll, variable checkBeforeWrite, variable selectAmp, variable GUIWrite])
2127+
2128+
DEBUGPRINT("Unimplemented")
2129+
End
2130+
21212131
Function AI_SendToAmp(string device, variable headStage, variable mode, variable func, variable value, [variable checkBeforeWrite, variable usePrefixes, variable selectAmp])
21222132

21232133
DEBUGPRINT("Unimplemented")

0 commit comments

Comments
 (0)