Skip to content

Commit afb0f25

Browse files
committed
MIES_Publish.ipf: Add TESTPULSE_SET_VALUE_FILTER
Send a message when changing a TP setting in the DAEphys panel.
1 parent 24ef1e9 commit afb0f25

7 files changed

+138
-4
lines changed

Packages/MIES/MIES_Constants.ipf

+1
Original file line numberDiff line numberDiff line change
@@ -1887,6 +1887,7 @@ StrConstant PRESSURE_STATE_FILTER = "pressure:state"
18871887
StrConstant PRESSURE_SEALED_FILTER = "pressure:sealed"
18881888
StrConstant PRESSURE_BREAKIN_FILTER = "pressure:break in"
18891889
StrConstant AUTO_TP_FILTER = "testpulse:autotune result"
1890+
StrConstant TESTPULSE_SET_VALUE_FILTER = "testpulse:set value"
18901891
StrConstant ZMQ_FILTER_TPRESULT_NOW = "testpulse:results live"
18911892
StrConstant ZMQ_FILTER_TPRESULT_1S = "testpulse:results 1s update"
18921893
StrConstant ZMQ_FILTER_TPRESULT_5S = "testpulse:results 5s update"

Packages/MIES/MIES_DAEphys.ipf

+44-2
Original file line numberDiff line numberDiff line change
@@ -5513,11 +5513,47 @@ static Function/S DAP_TPControlToLabel(string ctrl)
55135513
endswitch
55145514
End
55155515

5516+
/// @brief Get the physical unit for the control name
5517+
static Function/S DAP_TPControlToUnit(string ctrl)
5518+
5519+
strswitch(ctrl)
5520+
case "SetVar_DataAcq_TPDuration":
5521+
return "ms"
5522+
case "SetVar_DataAcq_TPBaselinePerc":
5523+
return "%"
5524+
case "SetVar_DataAcq_TPAmplitude":
5525+
return "pA"
5526+
case "SetVar_DataAcq_TPAmplitudeIC":
5527+
return "mV"
5528+
case "setvar_Settings_TPBuffer":
5529+
return "a.u."
5530+
case "setvar_Settings_TP_RTolerance":
5531+
return "MΩ"
5532+
case "check_DataAcq_AutoTP":
5533+
return "On/Off"
5534+
case "setvar_DataAcq_IinjMax":
5535+
return "pA"
5536+
case "setvar_DataAcq_targetVoltage":
5537+
return "mV"
5538+
case "setvar_DataAcq_targetVoltageRange":
5539+
return "mV"
5540+
case "Check_TP_SendToAllHS":
5541+
return "On/Off"
5542+
case "setvar_Settings_autoTP_perc":
5543+
return "%"
5544+
case "setvar_Settings_autoTP_int":
5545+
return "s"
5546+
default:
5547+
ASSERT(0, "invalid control")
5548+
break
5549+
endswitch
5550+
End
5551+
55165552
/// @brief Write a new TP setting value to the wave
55175553
static Function DAP_TPGUISettingToWave(string device, string ctrl, variable val)
55185554

5519-
string lbl, entry
5520-
variable first, last, TPState, needsTPRestart
5555+
string lbl, entry, unit
5556+
variable first, last, TPState, needsTPRestart, headstage, i
55215557

55225558
needsTPRestart = WhichListItem(ctrl, DAEPHYS_TP_CONTROLS_NO_RESTART) == -1
55235559

@@ -5546,6 +5582,12 @@ static Function DAP_TPGUISettingToWave(string device, string ctrl, variable val)
55465582

55475583
TPSettings[%$lbl][first, last] = val
55485584

5585+
unit = DAP_TPControlToUnit(ctrl)
5586+
for(i = first; i <= last; i += 1)
5587+
headstage = IsValidHeadstage(i) ? i : NaN
5588+
PUB_TPSettingChange(device, headstage, lbl, val, unit)
5589+
endfor
5590+
55495591
if(!cmpstr(lbl, "autoTPEnable"))
55505592
TP_AutoTPGenerateNewCycleID(device, first = first, last = last)
55515593
DAP_AdaptAutoTPColorAndDependent(device)

Packages/MIES/MIES_ForeignFunctionInterface.ipf

+2-1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ End
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
8888
/// :cpp:var:AMPLIFIER_SET_VALUE Amplifier setting was changed through MIES :cpp:func:PUB_AmplifierSettingChange
89+
/// :cpp:var:TESTPULSE_SET_VALUE_FILTER Testpulse setting change :cpp:func:PUB_TPSettingChange
8990
/// ============================================ ==================================================== =============================================
9091
///
9192
/// \endrst
@@ -98,7 +99,7 @@ Function/WAVE FFI_GetAvailableMessageFilters()
9899
ANALYSIS_FUNCTION_VM, DAQ_TP_STATE_CHANGE_FILTER, \
99100
ANALYSIS_FUNCTION_AR, ZMQ_FILTER_TPRESULT_NOW, ZMQ_FILTER_TPRESULT_1S, \
100101
ZMQ_FILTER_TPRESULT_5S, ZMQ_FILTER_TPRESULT_10S, ZMQ_FILTER_TPRESULT_NOW_WITH_DATA, \
101-
CONFIG_FINISHED_FILTER, AMPLIFIER_SET_VALUE}
102+
CONFIG_FINISHED_FILTER, AMPLIFIER_SET_VALUE, TESTPULSE_SET_VALUE_FILTER}
102103

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

Packages/MIES/MIES_Publish.ipf

+15
Original file line numberDiff line numberDiff line change
@@ -989,3 +989,18 @@ Function PUB_AmplifierSettingChange(string device, variable headstage, variable
989989

990990
PUB_Publish(jsonID, AMPLIFIER_SET_VALUE)
991991
End
992+
993+
Function PUB_TPSettingChange(string device, variable headstage, string name, variable value, string unit)
994+
995+
variable jsonID
996+
string path
997+
998+
jsonID = PUB_GetJSONTemplate(device, headstage)
999+
1000+
path = "/testpulse setting"
1001+
JSON_AddTreeObject(jsonID, path)
1002+
1003+
PUB_AddValueWithUnit(jsonID, path + "/" + name, value, unit)
1004+
1005+
PUB_Publish(jsonID, TESTPULSE_SET_VALUE_FILTER)
1006+
End

Packages/tests/Basic/UTF_ZeroMQPublishing.ipf

+62
Original file line numberDiff line numberDiff line change
@@ -711,3 +711,65 @@ static Function CheckAmplifierSettingChange()
711711

712712
JSON_Release(jsonID)
713713
End
714+
715+
/// Filter: #TESTPULSE_SET_VALUE_FILTER
716+
///
717+
/// Example:
718+
///
719+
/// \rst
720+
/// .. code-block:: json
721+
///
722+
/// {
723+
/// "device": "my_device",
724+
/// "headstage": 1,
725+
/// "sweep number": "NaN",
726+
/// "testpulse setting": {
727+
/// "my name": {
728+
/// "unit": "On/Off",
729+
/// "value": 1
730+
/// }
731+
/// },
732+
/// "timestamp": "2025-04-25T20:26:44Z"
733+
/// }
734+
///
735+
/// \endrst
736+
static Function CheckTestpulseSettingChange()
737+
738+
string device, name, unit, actual, expected, path
739+
variable value, headstage, jsonID, valActual, valExpected
740+
741+
device = "my_device"
742+
headstage = 1
743+
name = "my name"
744+
unit = "On/Off"
745+
value = 1
746+
747+
PUB_TPSettingChange(device, headstage, name, value, unit)
748+
749+
jsonID = FetchAndParseMessage(TESTPULSE_SET_VALUE_FILTER)
750+
751+
actual = JSON_GetString(jsonID, "/device")
752+
expected = device
753+
CHECK_EQUAL_STR(actual, expected)
754+
755+
valActual = JSON_GetVariable(jsonID, "/headstage")
756+
valExpected = headstage
757+
CHECK_EQUAL_VAR(valActual, valExpected)
758+
759+
path = "/testpulse setting/" + name
760+
valActual = JSON_GetType(jsonID, path)
761+
valExpected = JSON_OBJECT
762+
CHECK_EQUAL_VAR(valActual, valExpected)
763+
764+
CHECK_EQUAL_STR(actual, expected)
765+
766+
valActual = JSON_GetVariable(jsonID, path + "/value")
767+
valExpected = value
768+
CHECK_EQUAL_VAR(valActual, valExpected)
769+
770+
actual = JSON_GetString(jsonID, path + "/unit")
771+
expected = unit
772+
CHECK_EQUAL_STR(actual, expected)
773+
774+
JSON_Release(jsonID)
775+
End

Packages/tests/HardwareBasic/UTF_TestPulseAndTPDuringDAQ.ipf

+13
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,20 @@ End
125125

126126
static Function CheckTPEntriesFromLBN_PreAcq(string device)
127127

128+
variable jsonID
129+
string path
130+
131+
PrepareForPublishTest()
132+
128133
PGC_SetAndActivateControl(device, "setvar_Settings_TP_RTolerance", val = 2)
134+
135+
jsonID = FetchAndParseMessage(TESTPULSE_SET_VALUE_FILTER)
136+
CHECK_EQUAL_VAR(JSON_GetVariable(jsonID, "/headstage"), NaN)
137+
path = "/testpulse setting/resistanceTol"
138+
CHECK_EQUAL_STR(JSON_GetString(jsonID, path + "/unit"), "MΩ")
139+
CHECK_EQUAL_VAR(JSON_GetVariable(jsonID, path + "/value"), 2)
140+
JSON_Release(jsonID)
141+
129142
PGC_SetAndActivateControl(device, "setvar_Settings_TPBuffer", val = 3)
130143

131144
// turn off send to all HS

Packages/tests/UTF_HelperFunctions.ipf

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include "UTF_Constants"
1414
#include "UTF_DataGenerators"
1515

16-
// #define OUTPUT_DOCUMENTATION_JSON_DUMP
16+
#define OUTPUT_DOCUMENTATION_JSON_DUMP
1717

1818
/// @file UTF_HelperFunctions.ipf
1919
/// @brief This file holds helper functions for the tests

0 commit comments

Comments
 (0)