Skip to content

Commit 1a27f98

Browse files
committed
MIES_Publish.ipf: Add AMPLIFIER_SET_VALUE
1 parent c156ce1 commit 1a27f98

6 files changed

+107
-2
lines changed

Packages/MIES/MIES_AmplifierInteraction.ipf

+4
Original file line numberDiff line numberDiff line change
@@ -1745,6 +1745,10 @@ static Function AI_SendToAmp(string device, variable headStage, variable mode, v
17451745
endif
17461746
endswitch
17471747

1748+
if(accessType == MCC_WRITE)
1749+
PUB_AmplifierSettingChange(device, headstage, mode, func, value)
1750+
endif
1751+
17481752
if(!IsFinite(ret))
17491753
print "Amp communication error. Check associations in hardware tab and/or use Query connected amps button"
17501754
ControlWindowToFront()

Packages/MIES/MIES_Constants.ipf

+1
Original file line numberDiff line numberDiff line change
@@ -1864,6 +1864,7 @@ StrConstant ZMQ_FILTER_TPRESULT_10S = "testpulse:results 10s update"
18641864
StrConstant ZMQ_FILTER_TPRESULT_NOW_WITH_DATA = "testpulse:results live with data"
18651865
StrConstant AMPLIFIER_CLAMP_MODE_FILTER = "amplifier:clamp mode"
18661866
StrConstant AMPLIFIER_AUTO_BRIDGE_BALANCE = "amplifier:auto bridge balance"
1867+
StrConstant AMPLIFIER_SET_VALUE = "amplifier:set value"
18671868
StrConstant ANALYSIS_FUNCTION_PB = "analysis function:pipette in bath"
18681869
StrConstant ANALYSIS_FUNCTION_SE = "analysis function:seal evaluation"
18691870
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

+43
Original file line numberDiff line numberDiff line change
@@ -946,3 +946,46 @@ 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+
/// "HoldingPotentialEnable": {
962+
/// "unit": "On/Off",
963+
/// "value": 1
964+
/// }
965+
/// },
966+
/// "clamp mode": "V_CLAMP_MODE",
967+
/// "device": "my_device",
968+
/// "headstage": 1,
969+
/// "sweep number": "NaN",
970+
/// "timestamp": "2025-03-25T16:42:21Z"
971+
/// }
972+
///
973+
/// \endrst
974+
Function PUB_AmplifierSettingChange(string device, variable headstage, variable mode, variable func, variable value)
975+
976+
variable jsonID
977+
string path, unit, name
978+
979+
jsonID = PUB_GetJSONTemplate(device, headstage)
980+
981+
JSON_AddString(jsonID, "clamp mode", ConvertAmplifierModeToString(mode))
982+
983+
path = "/amplifier action"
984+
JSON_AddTreeObject(jsonID, path)
985+
986+
unit = AI_GetUnitForFunctionConstant(func, mode)
987+
name = AI_MapFunctionConstantToName(func, mode)
988+
PUB_AddValueWithUnit(jsonID, path + "/" + name, value, unit)
989+
990+
PUB_Publish(jsonID, AMPLIFIER_SET_VALUE)
991+
End

Packages/tests/Basic/UTF_ZeroMQPublishing.ipf

+47
Original file line numberDiff line numberDiff line change
@@ -664,3 +664,50 @@ static Function CheckConfigurationFinished()
664664

665665
JSON_Release(jsonID)
666666
End
667+
668+
static Function CheckAmplifierSettingChange()
669+
670+
string device, actual, expected, name, unit, path
671+
variable jsonID, valActual, valExpected, headstage, mode, value, func
672+
673+
device = "my_device"
674+
headstage = 1
675+
mode = V_CLAMP_MODE
676+
func = MCC_HOLDINGENABLE_FUNC
677+
name = "HoldingPotentialEnable"
678+
unit = "On/Off"
679+
value = 1
680+
681+
PUB_AmplifierSettingChange(device, headstage, mode, func, value)
682+
683+
jsonID = FetchAndParseMessage(AMPLIFIER_SET_VALUE)
684+
685+
actual = JSON_GetString(jsonID, "/device")
686+
expected = device
687+
CHECK_EQUAL_STR(actual, expected)
688+
689+
valActual = JSON_GetVariable(jsonID, "/headstage")
690+
valExpected = headstage
691+
CHECK_EQUAL_VAR(valActual, valExpected)
692+
693+
actual = JSON_GetString(jsonID, "/clamp mode")
694+
expected = ConvertAmplifierModeToString(mode)
695+
CHECK_EQUAL_STR(actual, expected)
696+
697+
path = "/amplifier action/" + name
698+
valActual = JSON_GetType(jsonID, path)
699+
valExpected = JSON_OBJECT
700+
CHECK_EQUAL_VAR(valActual, valExpected)
701+
702+
CHECK_EQUAL_STR(actual, expected)
703+
704+
valActual = JSON_GetVariable(jsonID, path + "/value")
705+
valExpected = value
706+
CHECK_EQUAL_VAR(valActual, valExpected)
707+
708+
actual = JSON_GetString(jsonID, path + "/unit")
709+
expected = unit
710+
CHECK_EQUAL_STR(actual, expected)
711+
712+
JSON_Release(jsonID)
713+
End

Packages/tests/HardwareBasic/UTF_ConfigurationHardware.ipf

+10-1
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,11 @@ End
100100
// UTF_TD_GENERATOR DeviceNameGeneratorMD1
101101
static Function CheckIfConfigurationRestoresMCCFilterGain([string str])
102102

103-
string rewrittenConfig, fName
103+
string rewrittenConfig, fName, path
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,13 @@ 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+
path = "/amplifier action/SetPrimarySignalLPF"
127+
CHECK_EQUAL_STR(JSON_GetString(jsonID, path + "/unit"), "kHz")
128+
CHECK_EQUAL_VAR(JSON_GetVariable(jsonID, path + "/value"), filterFreq)
129+
JSON_Release(jsonID)
130+
122131
PGC_SetAndActivateControl(str, "check_Settings_SyncMiesToMCC", val = 1)
123132

124133
CONF_SaveWindow(fName)

0 commit comments

Comments
 (0)