Skip to content

Commit b8f663e

Browse files
committed
MIES_Publish.ipf: Add AMPLIFIER_SET_VALUE
1 parent be0cfa0 commit b8f663e

6 files changed

+91
-2
lines changed

Packages/MIES/MIES_AmplifierInteraction.ipf

+6-1
Original file line numberDiff line numberDiff line change
@@ -1449,7 +1449,7 @@ End
14491449
static Function AI_SendToAmp(string device, variable headStage, variable mode, variable func, variable accessType, [variable checkBeforeWrite, variable usePrefixes, variable selectAmp, variable value])
14501450

14511451
variable ret, headstageMode, scale
1452-
string str
1452+
string str, name
14531453

14541454
ASSERT(func > MCC_BEGIN_INVALID_FUNC && func < MCC_END_INVALID_FUNC, "MCC function constant is out for range")
14551455
ASSERT(IsValidHeadstage(headstage), "invalid headStage index")
@@ -1532,6 +1532,11 @@ static Function AI_SendToAmp(string device, variable headStage, variable mode, v
15321532
endif
15331533
endswitch
15341534

1535+
if(accessType == MCC_WRITE)
1536+
name = AI_MapFunctionConstantToName(func, mode)
1537+
PUB_AmplifierSettingChange(device, headstage, mode, name, value)
1538+
endif
1539+
15351540
if(!IsFinite(ret))
15361541
print "Amp communication error. Check associations in hardware tab and/or use Query connected amps button"
15371542
ControlWindowToFront()

Packages/MIES/MIES_Constants.ipf

+1
Original file line numberDiff line numberDiff line change
@@ -1863,6 +1863,7 @@ StrConstant ZMQ_FILTER_TPRESULT_10S = "testpulse:results 10s update"
18631863
StrConstant ZMQ_FILTER_TPRESULT_NOW_WITH_DATA = "testpulse:results live with data"
18641864
StrConstant AMPLIFIER_CLAMP_MODE_FILTER = "amplifier:clamp mode"
18651865
StrConstant AMPLIFIER_AUTO_BRIDGE_BALANCE = "amplifier:auto bridge balance"
1866+
StrConstant AMPLIFIER_SET_VALUE = "amplifier:set value"
18661867
StrConstant ANALYSIS_FUNCTION_PB = "analysis function:pipette in bath"
18671868
StrConstant ANALYSIS_FUNCTION_SE = "analysis function:seal evaluation"
18681869
StrConstant ANALYSIS_FUNCTION_VM = "analysis function:true resting membrane potential"

Packages/MIES/MIES_ForeignFunctionInterface.ipf

+2-1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ End
8585
/// :cpp:var:ZMQ_FILTER_TPRESULT_10s TP evaluation result (every 10s) :cpp:func:PUB_TPResult
8686
/// :cpp:var:ZMQ_FILTER_TPRESULT_NOW_WITH_DATA TP evaluation result with AD data (all TPs) :cpp:func:PUB_TPResult
8787
/// :cpp:var:CONFIG_FINISHED_FILTER JSON configuration for panel has finished :cpp:func:PUB_ConfigurationFinished
88+
/// :cpp:var:AMPLIFIER_SET_VALUE Amplifier setting was changed through MIES :cpp:func:PUB_AmplifierSettingChange
8889
/// ============================================ ==================================================== =============================================
8990
///
9091
/// \endrst
@@ -97,7 +98,7 @@ Function/WAVE FFI_GetAvailableMessageFilters()
9798
ANALYSIS_FUNCTION_VM, DAQ_TP_STATE_CHANGE_FILTER, \
9899
ANALYSIS_FUNCTION_AR, ZMQ_FILTER_TPRESULT_NOW, ZMQ_FILTER_TPRESULT_1S, \
99100
ZMQ_FILTER_TPRESULT_5S, ZMQ_FILTER_TPRESULT_10S, ZMQ_FILTER_TPRESULT_NOW_WITH_DATA, \
100-
CONFIG_FINISHED_FILTER}
101+
CONFIG_FINISHED_FILTER, AMPLIFIER_SET_VALUE}
101102

102103
Note/K wv, "Heartbeat is sent every 5 seconds."
103104

Packages/MIES/MIES_Publish.ipf

+36
Original file line numberDiff line numberDiff line change
@@ -888,3 +888,39 @@ Function PUB_ConfigurationFinished(string windowName, string panelType, string f
888888

889889
PUB_Publish(jsonID, CONFIG_FINISHED_FILTER)
890890
End
891+
892+
/// Filter: #AMPLIFIER_SET_VALUE
893+
///
894+
/// The available names are listed in AI_MapFunctionConstantToName().
895+
///
896+
/// Example:
897+
///
898+
/// \rst
899+
/// .. code-block:: json
900+
///
901+
/// {
902+
/// "amplifier action": {
903+
/// "name": "some entry",
904+
/// "value": 123
905+
/// },
906+
/// "clamp mode": "V_CLAMP_MODE",
907+
/// "device": "my_device",
908+
/// "headstage": 1,
909+
/// "sweep number": "NaN",
910+
/// "timestamp": "2025-02-25T20:30:24Z"
911+
/// }
912+
///
913+
/// \endrst
914+
Function PUB_AmplifierSettingChange(string device, variable headstage, variable mode, string name, variable value)
915+
916+
variable jsonID
917+
918+
jsonID = PUB_GetJSONTemplate(device, headstage)
919+
920+
JSON_AddString(jsonID, "clamp mode", ConvertAmplifierModeToString(mode))
921+
JSON_AddTreeObject(jsonID, "/amplifier action")
922+
JSON_AddString(jsonID, "/amplifier action/name", name)
923+
JSON_AddVariable(jsonID, "/amplifier action/value", value)
924+
925+
PUB_Publish(jsonID, AMPLIFIER_SET_VALUE)
926+
End

Packages/tests/Basic/UTF_ZeroMQPublishing.ipf

+38
Original file line numberDiff line numberDiff line change
@@ -638,3 +638,41 @@ static Function CheckConfigurationFinished()
638638

639639
JSON_Release(jsonID)
640640
End
641+
642+
static Function CheckAmplifierSettingChange()
643+
644+
string device, actual, expected, name
645+
variable jsonID, valActual, valExpected, headstage, mode, value
646+
647+
device = "my_device"
648+
headstage = 1
649+
mode = V_CLAMP_MODE
650+
name = "some entry"
651+
value = 123
652+
653+
PUB_AmplifierSettingChange(device, headstage, mode, name, value)
654+
655+
jsonID = FetchAndParseMessage(AMPLIFIER_SET_VALUE)
656+
657+
actual = JSON_GetString(jsonID, "/device")
658+
expected = device
659+
CHECK_EQUAL_STR(actual, expected)
660+
661+
valActual = JSON_GetVariable(jsonID, "/headstage")
662+
valExpected = headstage
663+
CHECK_EQUAL_VAR(valActual, valExpected)
664+
665+
actual = JSON_GetString(jsonID, "/clamp mode")
666+
expected = ConvertAmplifierModeToString(mode)
667+
CHECK_EQUAL_STR(actual, expected)
668+
669+
actual = JSON_GetString(jsonID, "/amplifier action/name")
670+
expected = name
671+
CHECK_EQUAL_STR(actual, expected)
672+
673+
valActual = JSON_GetVariable(jsonID, "/amplifier action/value")
674+
valExpected = value
675+
CHECK_EQUAL_VAR(valActual, valExpected)
676+
677+
JSON_Release(jsonID)
678+
End

Packages/tests/HardwareBasic/UTF_ConfigurationHardware.ipf

+8
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ static Function CheckIfConfigurationRestoresMCCFilterGain([string str])
103103
string rewrittenConfig, fName
104104
variable val, gain, filterFreq, headStage, jsonID
105105

106+
PrepareForPublishTest()
107+
106108
fName = PrependExperimentFolder_IGNORE("CheckIfConfigurationRestoresMCCFilterGain.json")
107109

108110
STRUCT DAQSettings s
@@ -119,6 +121,12 @@ static Function CheckIfConfigurationRestoresMCCFilterGain([string str])
119121
AI_WriteToAmplifier(str, headStage + 1, I_CLAMP_MODE, MCC_PRIMARYSIGNALLPF_FUNC, filterFreq)
120122
AI_WriteToAmplifier(str, headStage + 1, I_CLAMP_MODE, MCC_PRIMARYSIGNALGAIN_FUNC, gain)
121123

124+
jsonID = FetchAndParseMessage(AMPLIFIER_SET_VALUE)
125+
CHECK_EQUAL_VAR(JSON_GetVariable(jsonID, "/headstage"), headStage)
126+
CHECK_EQUAL_STR(JSON_GetString(jsonID, "/amplifier action/name"), "SetPrimarySignalLPF")
127+
CHECK_EQUAL_VAR(JSON_GetVariable(jsonID, "/amplifier action/value"), filterFreq)
128+
JSON_Release(jsonID)
129+
122130
PGC_SetAndActivateControl(str, "check_Settings_SyncMiesToMCC", val = 1)
123131

124132
CONF_SaveWindow(fName)

0 commit comments

Comments
 (0)