Skip to content

Commit 2f8fddd

Browse files
committed
MIES_Publish.ipf: Add AMPLIFIER_SET_VALUE
1 parent a63b197 commit 2f8fddd

6 files changed

+91
-2
lines changed

Packages/MIES/MIES_AmplifierInteraction.ipf

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

15761576
variable ret, headstageMode, scale
1577-
string str
1577+
string str, name
15781578

15791579
ASSERT(func > MCC_BEGIN_INVALID_FUNC && func < MCC_END_INVALID_FUNC, "MCC function constant is out for range")
15801580
ASSERT(IsValidHeadstage(headstage), "invalid headStage index")
@@ -1657,6 +1657,11 @@ static Function AI_SendToAmp(string device, variable headStage, variable mode, v
16571657
endif
16581658
endswitch
16591659

1660+
if(accessType == MCC_WRITE)
1661+
name = AI_MapFunctionConstantToName(func, mode)
1662+
PUB_AmplifierSettingChange(device, headstage, mode, name, value)
1663+
endif
1664+
16601665
if(!IsFinite(ret))
16611666
print "Amp communication error. Check associations in hardware tab and/or use Query connected amps button"
16621667
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
@@ -946,3 +946,39 @@ Function PUB_ConfigurationFinished(string windowName, string panelType, string f
946946

947947
PUB_Publish(jsonID, CONFIG_FINISHED_FILTER)
948948
End
949+
950+
/// Filter: #AMPLIFIER_SET_VALUE
951+
///
952+
/// The available names are listed in AI_MapFunctionConstantToName().
953+
///
954+
/// Example:
955+
///
956+
/// \rst
957+
/// .. code-block:: json
958+
///
959+
/// {
960+
/// "amplifier action": {
961+
/// "name": "some entry",
962+
/// "value": 123
963+
/// },
964+
/// "clamp mode": "V_CLAMP_MODE",
965+
/// "device": "my_device",
966+
/// "headstage": 1,
967+
/// "sweep number": "NaN",
968+
/// "timestamp": "2025-02-25T20:30:24Z"
969+
/// }
970+
///
971+
/// \endrst
972+
Function PUB_AmplifierSettingChange(string device, variable headstage, variable mode, string name, variable value)
973+
974+
variable jsonID
975+
976+
jsonID = PUB_GetJSONTemplate(device, headstage)
977+
978+
JSON_AddString(jsonID, "clamp mode", ConvertAmplifierModeToString(mode))
979+
JSON_AddTreeObject(jsonID, "/amplifier action")
980+
JSON_AddString(jsonID, "/amplifier action/name", name)
981+
JSON_AddVariable(jsonID, "/amplifier action/value", value)
982+
983+
PUB_Publish(jsonID, AMPLIFIER_SET_VALUE)
984+
End

Packages/tests/Basic/UTF_ZeroMQPublishing.ipf

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

660660
JSON_Release(jsonID)
661661
End
662+
663+
static Function CheckAmplifierSettingChange()
664+
665+
string device, actual, expected, name
666+
variable jsonID, valActual, valExpected, headstage, mode, value
667+
668+
device = "my_device"
669+
headstage = 1
670+
mode = V_CLAMP_MODE
671+
name = "some entry"
672+
value = 123
673+
674+
PUB_AmplifierSettingChange(device, headstage, mode, name, value)
675+
676+
jsonID = FetchAndParseMessage(AMPLIFIER_SET_VALUE)
677+
678+
actual = JSON_GetString(jsonID, "/device")
679+
expected = device
680+
CHECK_EQUAL_STR(actual, expected)
681+
682+
valActual = JSON_GetVariable(jsonID, "/headstage")
683+
valExpected = headstage
684+
CHECK_EQUAL_VAR(valActual, valExpected)
685+
686+
actual = JSON_GetString(jsonID, "/clamp mode")
687+
expected = ConvertAmplifierModeToString(mode)
688+
CHECK_EQUAL_STR(actual, expected)
689+
690+
actual = JSON_GetString(jsonID, "/amplifier action/name")
691+
expected = name
692+
CHECK_EQUAL_STR(actual, expected)
693+
694+
valActual = JSON_GetVariable(jsonID, "/amplifier action/value")
695+
valExpected = value
696+
CHECK_EQUAL_VAR(valActual, valExpected)
697+
698+
JSON_Release(jsonID)
699+
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)