Skip to content

Commit 2fabe52

Browse files
committed
MIES_Publish.ipf: Add AMPLIFIER_SET_VALUE
1 parent 70b91b3 commit 2fabe52

6 files changed

+107
-2
lines changed

Packages/MIES/MIES_AmplifierInteraction.ipf

Lines changed: 4 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -943,3 +943,46 @@ Function PUB_ConfigurationFinished(string windowName, string panelType, string f
943943

944944
PUB_Publish(jsonID, CONFIG_FINISHED_FILTER)
945945
End
946+
947+
/// Filter: #AMPLIFIER_SET_VALUE
948+
///
949+
/// The available names are listed in AI_MapFunctionConstantToName().
950+
///
951+
/// Example:
952+
///
953+
/// \rst
954+
/// .. code-block:: json
955+
///
956+
/// {
957+
/// "amplifier action": {
958+
/// "HoldingPotentialEnable": {
959+
/// "unit": "On/Off",
960+
/// "value": 1
961+
/// }
962+
/// },
963+
/// "clamp mode": "V_CLAMP_MODE",
964+
/// "device": "my_device",
965+
/// "headstage": 1,
966+
/// "sweep number": "NaN",
967+
/// "timestamp": "2025-03-25T16:42:21Z"
968+
/// }
969+
///
970+
/// \endrst
971+
Function PUB_AmplifierSettingChange(string device, variable headstage, variable mode, variable func, variable value)
972+
973+
variable jsonID
974+
string path, unit, name
975+
976+
jsonID = PUB_GetJSONTemplate(device, headstage)
977+
978+
JSON_AddString(jsonID, "clamp mode", ConvertAmplifierModeToString(mode))
979+
980+
path = "/amplifier action"
981+
JSON_AddTreeObject(jsonID, path)
982+
983+
unit = AI_GetUnitForFunctionConstant(func, mode)
984+
name = AI_MapFunctionConstantToName(func, mode)
985+
PUB_AddValueWithUnit(jsonID, path + "/" + name, value, unit)
986+
987+
PUB_Publish(jsonID, AMPLIFIER_SET_VALUE)
988+
End

Packages/tests/Basic/UTF_ZeroMQPublishing.ipf

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,3 +659,50 @@ static Function CheckConfigurationFinished()
659659

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

Packages/tests/HardwareBasic/UTF_ConfigurationHardware.ipf

Lines changed: 10 additions & 1 deletion
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)