From 00941de290aecc125b85097ca6862360fd6484a5 Mon Sep 17 00:00:00 2001 From: Michael Huth Date: Fri, 23 Aug 2024 13:55:03 +0200 Subject: [PATCH] PUB: Add four publishers to publish TP data - The four publishers publish the same json, just with a different period. There is a filter for live, 1s, 5s and 10s publishing interval. - See PUB_TPResult for JSON description - publisher is called from TP_TSAnalysis thread --- Packages/MIES/MIES_Constants.ipf | 4 + .../MIES/MIES_ForeignFunctionInterface.ipf | 3 +- Packages/MIES/MIES_Publish.ipf | 185 +++++++++++++++++- Packages/MIES/MIES_TestPulse.ipf | 2 + Packages/tests/Basic/UTF_ZeroMQPublishing.ipf | 141 +++++++++++++ .../UTF_TestPulseAndTPDuringDAQ.ipf | 142 ++++++++++++++ Packages/tests/UTF_DataGenerators.ipf | 8 + 7 files changed, 480 insertions(+), 5 deletions(-) diff --git a/Packages/MIES/MIES_Constants.ipf b/Packages/MIES/MIES_Constants.ipf index 2714140ef7..fcfa46d641 100644 --- a/Packages/MIES/MIES_Constants.ipf +++ b/Packages/MIES/MIES_Constants.ipf @@ -1857,6 +1857,10 @@ StrConstant PRESSURE_STATE_FILTER = "pressure:state" StrConstant PRESSURE_SEALED_FILTER = "pressure:sealed" StrConstant PRESSURE_BREAKIN_FILTER = "pressure:break in" StrConstant AUTO_TP_FILTER = "testpulse:autotune result" +StrConstant ZMQ_FILTER_TPRESULT_NOW = "testpulse:results live" +StrConstant ZMQ_FILTER_TPRESULT_1S = "testpulse:results 1s update" +StrConstant ZMQ_FILTER_TPRESULT_5S = "testpulse:results 5s update" +StrConstant ZMQ_FILTER_TPRESULT_10S = "testpulse:results 10s update" StrConstant AMPLIFIER_CLAMP_MODE_FILTER = "amplifier:clamp mode" StrConstant AMPLIFIER_AUTO_BRIDGE_BALANCE = "amplifier:auto bridge balance" StrConstant ANALYSIS_FUNCTION_PB = "analysis function:pipette in bath" diff --git a/Packages/MIES/MIES_ForeignFunctionInterface.ipf b/Packages/MIES/MIES_ForeignFunctionInterface.ipf index d27507472b..dfc42c8581 100644 --- a/Packages/MIES/MIES_ForeignFunctionInterface.ipf +++ b/Packages/MIES/MIES_ForeignFunctionInterface.ipf @@ -66,7 +66,8 @@ Function/WAVE FFI_GetAvailableMessageFilters() PRESSURE_BREAKIN_FILTER, AUTO_TP_FILTER, AMPLIFIER_CLAMP_MODE_FILTER, \ AMPLIFIER_AUTO_BRIDGE_BALANCE, ANALYSIS_FUNCTION_PB, ANALYSIS_FUNCTION_SE, \ ANALYSIS_FUNCTION_VM, DAQ_TP_STATE_CHANGE_FILTER, \ - ANALYSIS_FUNCTION_AR} + ANALYSIS_FUNCTION_AR, ZMQ_FILTER_TPRESULT_NOW, ZMQ_FILTER_TPRESULT_1S, \ + ZMQ_FILTER_TPRESULT_5S, ZMQ_FILTER_TPRESULT_10S} Note/K wv, "Heartbeat is sent every 5 seconds." diff --git a/Packages/MIES/MIES_Publish.ipf b/Packages/MIES/MIES_Publish.ipf index 534719401e..ada8447bf6 100644 --- a/Packages/MIES/MIES_Publish.ipf +++ b/Packages/MIES/MIES_Publish.ipf @@ -24,19 +24,22 @@ static Function PUB_GetJSONTemplate(string device, variable headstage) End /// @brief Publish the given message as given by the JSON and the filter -static Function PUB_Publish(variable jsonID, string messageFilter) +threadsafe Function PUB_Publish(variable jsonID, string messageFilter, [variable releaseJSON]) variable err string payload - payload = JSON_Dump(jsonID) - JSON_Release(jsonID) + releaseJSON = ParamIsDefault(releaseJSON) ? 1 : !!releaseJSON + payload = JSON_Dump(jsonID) + if(releaseJSON) + JSON_Release(jsonID) + endif AssertOnAndClearRTError() try zeromq_pub_send(messageFilter, payload); AbortOnRTE catch err = ClearRTError() - BUG("Could not publish " + messageFilter + " due to: " + num2str(err)) + BUG_TS("Could not publish " + messageFilter + " due to: " + num2str(err)) endtry End @@ -642,3 +645,177 @@ Function PUB_AccessResistanceSmoke(string device, variable sweepNo, variable hea PUB_Publish(jsonID, ANALYSIS_FUNCTION_AR) End + +threadsafe static Function PUB_AddTPResultEntry(variable jsonId, string path, variable value, string unit) + + if(IsEmpty(unit)) + JSON_AddVariable(jsonID, path, value) + else + JSON_AddTreeObject(jsonID, path) + JSON_AddVariable(jsonID, path + "/value", value) + JSON_AddString(jsonID, path + "/unit", unit) + endif +End + +/// Filter: #ZMQ_FILTER_TPRESULT_NOW +/// Filter: #ZMQ_FILTER_TPRESULT_1S +/// Filter: #ZMQ_FILTER_TPRESULT_5S +/// Filter: #ZMQ_FILTER_TPRESULT_10S +/// +/// Example: +/// +/// \rst +/// .. code-block:: json +/// +/// { +/// "properties": { +/// "baseline fraction": { +/// "unit": "%", +/// "value": 35 +/// }, +/// "clamp amplitude": { +/// "unit": "mV", +/// "value": 10 +/// }, +/// "clamp mode": 0, +/// "device": "TestDevice", +/// "headstage": 1, +/// "pulse duration ADC": { +/// "unit": "points", +/// "value": 500 +/// }, +/// "pulse duration DAC": { +/// "unit": "points", +/// "value": 600 +/// }, +/// "pulse start point ADC": { +/// "unit": "point", +/// "value": 500 +/// }, +/// "pulse start point DAC": { +/// "unit": "point", +/// "value": 600 +/// }, +/// "sample interval ADC": { +/// "unit": "ms", +/// "value": 0.002 +/// }, +/// "sample interval DAC": { +/// "unit": "ms", +/// "value": 0.002 +/// }, +/// "time of tp acquisition": { +/// "unit": "s", +/// "value": 1000000 +/// }, +/// "timestamp": { +/// "unit": "s", +/// "value": 2000000 +/// }, +/// "timestampUTC": { +/// "unit": "s", +/// "value": 3000000 +/// }, +/// "tp cycle id": 456, +/// "tp length ADC": { +/// "unit": "points", +/// "value": 1500 +/// }, +/// "tp length DAC": { +/// "unit": "points", +/// "value": 1800 +/// }, +/// "tp marker": 1234 +/// }, +/// "results": { +/// "average baseline steady state": { +/// "unit": "pA", +/// "value": 2 +/// }, +/// "average tp steady state": { +/// "unit": "pA", +/// "value": 10 +/// }, +/// "instantaneous": { +/// "unit": "pA", +/// "value": 11 +/// }, +/// "instantaneous resistance": { +/// "unit": "MΩ", +/// "value": 2345 +/// }, +/// "steady state resistance": { +/// "unit": "MΩ", +/// "value": 1234 +/// } +/// } +/// } +/// +/// \endrst +threadsafe Function PUB_TPResult(string device, WAVE tpData) + + string path + variable jsonId = JSON_New() + string adUnit = GetADChannelUnit(tpData[%CLAMPMODE]) + string daUnit = GetDAChannelUnit(tpData[%CLAMPMODE]) + + path = "properties" + JSON_AddTreeObject(jsonID, path) + JSON_AddString(jsonID, path + "/device", device) + JSON_AddVariable(jsonID, path + "/tp marker", tpData[%MARKER]) + JSON_AddVariable(jsonID, path + "/headstage", tpData[%HEADSTAGE]) + JSON_AddVariable(jsonID, path + "/clamp mode", tpData[%CLAMPMODE]) + + PUB_AddTPResultEntry(jsonId, path + "/time of tp acquisition", tpData[%NOW], "s") + PUB_AddTPResultEntry(jsonId, path + "/clamp amplitude", tpData[%CLAMPAMP], daUnit) + PUB_AddTPResultEntry(jsonId, path + "/tp length ADC", tpData[%TPLENGTHPOINTSADC], "points") + PUB_AddTPResultEntry(jsonId, path + "/pulse duration ADC", tpData[%PULSELENGTHPOINTSADC], "points") + PUB_AddTPResultEntry(jsonId, path + "/pulse start point ADC", tpData[%PULSESTARTPOINTSADC], "point") + PUB_AddTPResultEntry(jsonId, path + "/sample interval ADC", tpData[%SAMPLINGINTERVALADC], "ms") + PUB_AddTPResultEntry(jsonId, path + "/tp length DAC", tpData[%TPLENGTHPOINTSDAC], "points") + PUB_AddTPResultEntry(jsonId, path + "/pulse duration DAC", tpData[%PULSELENGTHPOINTSDAC], "points") + PUB_AddTPResultEntry(jsonId, path + "/pulse start point DAC", tpData[%PULSESTARTPOINTSDAC], "point") + PUB_AddTPResultEntry(jsonId, path + "/sample interval DAC", tpData[%SAMPLINGINTERVALDAC], "ms") + PUB_AddTPResultEntry(jsonId, path + "/baseline fraction", tpData[%BASELINEFRAC] * ONE_TO_PERCENT, "%") + PUB_AddTPResultEntry(jsonId, path + "/timestamp", tpData[%TIMESTAMP], "s") + PUB_AddTPResultEntry(jsonId, path + "/timestampUTC", tpData[%TIMESTAMPUTC], "s") + PUB_AddTPResultEntry(jsonId, path + "/tp cycle id", tpData[%CYCLEID], "") + + path = "results" + JSON_AddTreeObject(jsonID, path) + PUB_AddTPResultEntry(jsonId, path + "/average baseline steady state", tpData[%BASELINE], adUnit) + PUB_AddTPResultEntry(jsonId, path + "/average tp steady state", tpData[%ELEVATED_SS], adUnit) + PUB_AddTPResultEntry(jsonId, path + "/instantaneous", tpData[%ELEVATED_INST], adUnit) + PUB_AddTPResultEntry(jsonId, path + "/steady state resistance", tpData[%STEADYSTATERES], "MΩ") + PUB_AddTPResultEntry(jsonId, path + "/instantaneous resistance", tpData[%INSTANTRES], "MΩ") + + PUB_Publish(jsonID, ZMQ_FILTER_TPRESULT_NOW, releaseJSON = 0) + if(PUB_CheckPublishingTime(ZMQ_FILTER_TPRESULT_1S, 1)) + PUB_Publish(jsonID, ZMQ_FILTER_TPRESULT_1S, releaseJSON = 0) + endif + if(PUB_CheckPublishingTime(ZMQ_FILTER_TPRESULT_5S, 5)) + PUB_Publish(jsonID, ZMQ_FILTER_TPRESULT_5S, releaseJSON = 0) + endif + if(PUB_CheckPublishingTime(ZMQ_FILTER_TPRESULT_10S, 10)) + PUB_Publish(jsonID, ZMQ_FILTER_TPRESULT_10S, releaseJSON = 0) + endif + JSON_Release(jsonID) +End + +/// @brief Updates the publishing timestamp in the TUFXOP storage and returns 1 if an update is due (0 otherwise) +threadsafe static Function PUB_CheckPublishingTime(string pubFilter, variable period) + + variable lastTime + variable curTime = DateTime + + TUFXOP_AcquireLock/N=(pubFilter) + lastTime = TSDS_ReadVar(pubFilter, defValue = 0, create = 1) + if(lastTime + period < curTime) + TSDS_Write(pubFilter, var = curTime + period) + TUFXOP_ReleaseLock/N=(pubFilter) + return 1 + endif + TUFXOP_ReleaseLock/N=(pubFilter) + + return 0 +End diff --git a/Packages/MIES/MIES_TestPulse.ipf b/Packages/MIES/MIES_TestPulse.ipf index cfaece27e5..164840e363 100644 --- a/Packages/MIES/MIES_TestPulse.ipf +++ b/Packages/MIES/MIES_TestPulse.ipf @@ -1020,6 +1020,8 @@ threadsafe Function/DF TP_TSAnalysis(dfrInp) tpData[%PULSESTARTPOINTSDAC] = pulseStartPointsDAC tpData[%SAMPLINGINTERVALDAC] = samplingIntervalDAC + PUB_TPResult(device, tpData) + return dfrOut End diff --git a/Packages/tests/Basic/UTF_ZeroMQPublishing.ipf b/Packages/tests/Basic/UTF_ZeroMQPublishing.ipf index a72edf4f16..eb225e5a8d 100644 --- a/Packages/tests/Basic/UTF_ZeroMQPublishing.ipf +++ b/Packages/tests/Basic/UTF_ZeroMQPublishing.ipf @@ -466,3 +466,144 @@ static Function CheckAccessResSmoke() JSON_Release(jsonID) End + +static Function/WAVE PrepareTPData() + + WAVE tpData = GetTPAnalysisDataWave() + tpData[%NOW] = 1E6 + tpData[%HEADSTAGE] = 1 + tpData[%MARKER] = 1234 + tpData[%NUMBER_OF_TP_CHANNELS] = 2 + tpData[%TIMESTAMP] = 2E6 + tpData[%TIMESTAMPUTC] = 3E6 + tpData[%CLAMPMODE] = V_CLAMP_MODE + tpData[%CLAMPAMP] = 10 + tpData[%BASELINEFRAC] = 0.35 + tpData[%CYCLEID] = 456 + tpData[%TPLENGTHPOINTSADC] = 1500 + tpData[%PULSELENGTHPOINTSADC] = 500 + tpData[%PULSESTARTPOINTSADC] = 500 + tpData[%SAMPLINGINTERVALADC] = 0.002 + tpData[%TPLENGTHPOINTSDAC] = 1800 + tpData[%PULSELENGTHPOINTSDAC] = 600 + tpData[%PULSESTARTPOINTSDAC] = 600 + tpData[%SAMPLINGINTERVALDAC] = 0.002 + + tpData[%BASELINE] = 2 + tpData[%ELEVATED_SS] = 10 + tpData[%ELEVATED_INST] = 11 + tpData[%STEADYSTATERES] = 1234 + tpData[%INSTANTRES] = 2345 + + return tpData +End + +static Function CheckTPData(variable jsonId) + + variable var + string stv, daUnit, adUnit + variable clampMode = V_CLAMP_MODE + + daUnit = GetDAChannelUnit(clampMode) + adUnit = GetADChannelUnit(clampMode) + + var = JSON_GetVariable(jsonID, "/properties/tp marker") + CHECK_EQUAL_VAR(var, 1234) + var = JSON_GetVariable(jsonID, "/properties/headstage") + CHECK_EQUAL_VAR(var, 1) + stv = JSON_GetString(jsonID, "/properties/device") + CHECK_EQUAL_STR(stv, "TestDevice") + var = JSON_GetVariable(jsonID, "/properties/clamp mode") + CHECK_EQUAL_VAR(var, clampMode) + var = JSON_GetVariable(jsonID, "/properties/time of tp acquisition/value") + CHECK_EQUAL_VAR(var, 1E6) + stv = JSON_GetString(jsonID, "/properties/time of tp acquisition/unit") + CHECK_EQUAL_STR(stv, "s") + var = JSON_GetVariable(jsonID, "/properties/clamp amplitude/value") + CHECK_EQUAL_VAR(var, 10) + stv = JSON_GetString(jsonID, "/properties/clamp amplitude/unit") + CHECK_EQUAL_STR(stv, daUnit) + var = JSON_GetVariable(jsonID, "/properties/tp length ADC/value") + CHECK_EQUAL_VAR(var, 1500) + stv = JSON_GetString(jsonID, "/properties/tp length ADC/unit") + CHECK_EQUAL_STR(stv, "points") + var = JSON_GetVariable(jsonID, "/properties/pulse duration ADC/value") + CHECK_EQUAL_VAR(var, 500) + stv = JSON_GetString(jsonID, "/properties/pulse duration ADC/unit") + CHECK_EQUAL_STR(stv, "points") + var = JSON_GetVariable(jsonID, "/properties/pulse start point ADC/value") + CHECK_EQUAL_VAR(var, 500) + stv = JSON_GetString(jsonID, "/properties/pulse start point ADC/unit") + CHECK_EQUAL_STR(stv, "point") + var = JSON_GetVariable(jsonID, "/properties/sample interval ADC/value") + CHECK_EQUAL_VAR(var, 0.002) + stv = JSON_GetString(jsonID, "/properties/sample interval ADC/unit") + CHECK_EQUAL_STR(stv, "ms") + var = JSON_GetVariable(jsonID, "/properties/tp length DAC/value") + CHECK_EQUAL_VAR(var, 1800) + stv = JSON_GetString(jsonID, "/properties/tp length DAC/unit") + CHECK_EQUAL_STR(stv, "points") + var = JSON_GetVariable(jsonID, "/properties/pulse duration DAC/value") + CHECK_EQUAL_VAR(var, 600) + stv = JSON_GetString(jsonID, "/properties/pulse duration DAC/unit") + CHECK_EQUAL_STR(stv, "points") + var = JSON_GetVariable(jsonID, "/properties/pulse start point DAC/value") + CHECK_EQUAL_VAR(var, 600) + stv = JSON_GetString(jsonID, "/properties/pulse start point DAC/unit") + CHECK_EQUAL_STR(stv, "point") + var = JSON_GetVariable(jsonID, "/properties/sample interval DAC/value") + CHECK_EQUAL_VAR(var, 0.002) + stv = JSON_GetString(jsonID, "/properties/sample interval DAC/unit") + CHECK_EQUAL_STR(stv, "ms") + var = JSON_GetVariable(jsonID, "/properties/baseline fraction/value") + CHECK_EQUAL_VAR(var, 35) + stv = JSON_GetString(jsonID, "/properties/baseline fraction/unit") + CHECK_EQUAL_STR(stv, "%") + var = JSON_GetVariable(jsonID, "/properties/timestamp/value") + CHECK_EQUAL_VAR(var, 2E6) + stv = JSON_GetString(jsonID, "/properties/timestamp/unit") + CHECK_EQUAL_STR(stv, "s") + var = JSON_GetVariable(jsonID, "/properties/timestampUTC/value") + CHECK_EQUAL_VAR(var, 3E6) + stv = JSON_GetString(jsonID, "/properties/timestampUTC/unit") + CHECK_EQUAL_STR(stv, "s") + + var = JSON_GetVariable(jsonID, "/properties/tp cycle id") + CHECK_EQUAL_VAR(var, 456) + + var = JSON_GetVariable(jsonID, "/results/average baseline steady state/value") + CHECK_EQUAL_VAR(var, 2) + stv = JSON_GetString(jsonID, "/results/average baseline steady state/unit") + CHECK_EQUAL_STR(stv, adUnit) + var = JSON_GetVariable(jsonID, "/results/average tp steady state/value") + CHECK_EQUAL_VAR(var, 10) + stv = JSON_GetString(jsonID, "/results/average tp steady state/unit") + CHECK_EQUAL_STR(stv, adUnit) + var = JSON_GetVariable(jsonID, "/results/instantaneous/value") + CHECK_EQUAL_VAR(var, 11) + stv = JSON_GetString(jsonID, "/results/instantaneous/unit") + CHECK_EQUAL_STR(stv, adUnit) + var = JSON_GetVariable(jsonID, "/results/steady state resistance/value") + CHECK_EQUAL_VAR(var, 1234) + stv = JSON_GetString(jsonID, "/results/steady state resistance/unit") + CHECK_EQUAL_STR(stv, "MΩ") + var = JSON_GetVariable(jsonID, "/results/instantaneous resistance/value") + CHECK_EQUAL_VAR(var, 2345) + stv = JSON_GetString(jsonID, "/results/instantaneous resistance/unit") + CHECK_EQUAL_STR(stv, "MΩ") +End + +// IUTF_TD_GENERATOR DataGenerators#PUB_TPFilters +static Function CheckTPPublishing([string str]) + + variable jsonId + + WAVE tpData = PrepareTPData() + + TUFXOP_Clear/Z/N=(str) + PUB_TPResult("TestDevice", tpData) + + jsonId = FetchAndParseMessage(str) + CheckTPData(jsonId) + JSON_Release(jsonID) +End diff --git a/Packages/tests/HardwareBasic/UTF_TestPulseAndTPDuringDAQ.ipf b/Packages/tests/HardwareBasic/UTF_TestPulseAndTPDuringDAQ.ipf index c050328907..9f18ffdd1b 100644 --- a/Packages/tests/HardwareBasic/UTF_TestPulseAndTPDuringDAQ.ipf +++ b/Packages/tests/HardwareBasic/UTF_TestPulseAndTPDuringDAQ.ipf @@ -1318,3 +1318,145 @@ static Function TPZerosDAC_REENTRY([STRUCT IUTF_MDATA &md]) CHECK_LE_VAR(HW_ReadADC(hardwareType, deviceID, ADC), 0.01) End + +/// UTF_TD_GENERATOR DeviceNameGeneratorMD1 +static Function TestTPPublishing([str]) + string str + + TUFXOP_Clear/Z/N=(ZMQ_FILTER_TPRESULT_1S) + TUFXOP_Clear/Z/N=(ZMQ_FILTER_TPRESULT_5S) + TUFXOP_Clear/Z/N=(ZMQ_FILTER_TPRESULT_10S) + + STRUCT DAQSettings s + InitDAQSettingsFromString(s, "MD1_RA0_I0_L0_BKG1_STP1_TP1" + \ + "__HS0_DA0_AD0_CM:IC:_ST:TestPulse:" + \ + "__HS1_DA1_AD1_CM:VC:_ST:TestPulse:") + + AcquireData_NG(s, str) + + PrepareForPublishTest() + + CtrlNamedBackGround StopTPAfterFiveSeconds, start=(ticks + TP_DURATION_S * 60), period=1, proc=StopTPAfterFiveSeconds_IGNORE +End + +static Function TestTPPublishing_REENTRY([str]) + string str + variable sweepNo, jsonId, var, index, dimMarker, headstage + string msg, filter, stv, adUnit, daUnit + + CHECK_EQUAL_VAR(GetSetVariable(str, "SetVar_Sweep"), 0) + + sweepNo = AFH_GetLastSweepAcquired(str) + CHECK_EQUAL_VAR(sweepNo, NaN) + + WaitAndCheckStoredTPs_IGNORE(str, 2) + + WAVE tpStorage = GetTPStorage(str) + dimMarker = FindDimLabel(tpStorage, LAYERS, "TPMarker") + + Make/FREE/T filters = {ZMQ_FILTER_TPRESULT_NOW, ZMQ_FILTER_TPRESULT_1S, ZMQ_FILTER_TPRESULT_5S, ZMQ_FILTER_TPRESULT_10S} + for(filter : filters) + msg = FetchPublishedMessage(filter) + jsonId = JSON_Parse(msg) + + var = JSON_GetVariable(jsonID, "/properties/tp marker") + CHECK_NEQ_VAR(var, NaN) + + FindValue/RMD=[][0][dimMarker]/V=(var) tpStorage + ASSERT(V_row >= 0, "Inconsistent TP data") + index = V_row + + var = JSON_GetVariable(jsonID, "/properties/headstage") + CHECK_GE_VAR(var, 0) + CHECK_LE_VAR(var, 1) + headstage = var + + stv = JSON_GetString(jsonID, "/properties/device") + CHECK_EQUAL_STR(stv, str) + var = JSON_GetVariable(jsonID, "/properties/clamp mode") + CHECK_EQUAL_VAR(var, tpStorage[index][headstage][%ClampMode]) + daUnit = GetDAChannelUnit(var) + adUnit = GetADChannelUnit(var) + + var = JSON_GetVariable(jsonID, "/properties/time of tp acquisition/value") + CHECK_EQUAL_VAR(var, tpStorage[index][headstage][%TimeInSeconds]) + stv = JSON_GetString(jsonID, "/properties/time of tp acquisition/unit") + CHECK_EQUAL_STR(stv, "s") + var = JSON_GetVariable(jsonID, "/properties/clamp amplitude/value") + CHECK_EQUAL_VAR(var, tpStorage[index][headstage][%CLAMPAMP]) + stv = JSON_GetString(jsonID, "/properties/clamp amplitude/unit") + CHECK_EQUAL_STR(stv, daUnit) + var = JSON_GetVariable(jsonID, "/properties/tp length ADC/value") + CHECK_EQUAL_VAR(var, tpStorage[index][headstage][%TPLENGTHPOINTSADC]) + stv = JSON_GetString(jsonID, "/properties/tp length ADC/unit") + CHECK_EQUAL_STR(stv, "points") + var = JSON_GetVariable(jsonID, "/properties/pulse duration ADC/value") + CHECK_EQUAL_VAR(var, tpStorage[index][headstage][%PULSELENGTHPOINTSADC]) + stv = JSON_GetString(jsonID, "/properties/pulse duration ADC/unit") + CHECK_EQUAL_STR(stv, "points") + var = JSON_GetVariable(jsonID, "/properties/pulse start point ADC/value") + CHECK_EQUAL_VAR(var, tpStorage[index][headstage][%PULSESTARTPOINTSADC]) + stv = JSON_GetString(jsonID, "/properties/pulse start point ADC/unit") + CHECK_EQUAL_STR(stv, "point") + var = JSON_GetVariable(jsonID, "/properties/sample interval ADC/value") + CHECK_EQUAL_VAR(var, tpStorage[index][headstage][%SAMPLINGINTERVALADC]) + stv = JSON_GetString(jsonID, "/properties/sample interval ADC/unit") + CHECK_EQUAL_STR(stv, "ms") + var = JSON_GetVariable(jsonID, "/properties/tp length DAC/value") + CHECK_EQUAL_VAR(var, tpStorage[index][headstage][%TPLENGTHPOINTSDAC]) + stv = JSON_GetString(jsonID, "/properties/tp length DAC/unit") + CHECK_EQUAL_STR(stv, "points") + var = JSON_GetVariable(jsonID, "/properties/pulse duration DAC/value") + CHECK_EQUAL_VAR(var, tpStorage[index][headstage][%PULSELENGTHPOINTSDAC]) + stv = JSON_GetString(jsonID, "/properties/pulse duration DAC/unit") + CHECK_EQUAL_STR(stv, "points") + var = JSON_GetVariable(jsonID, "/properties/pulse start point DAC/value") + CHECK_EQUAL_VAR(var, tpStorage[index][headstage][%PULSESTARTPOINTSDAC]) + stv = JSON_GetString(jsonID, "/properties/pulse start point DAC/unit") + CHECK_EQUAL_STR(stv, "point") + var = JSON_GetVariable(jsonID, "/properties/sample interval DAC/value") + CHECK_EQUAL_VAR(var, tpStorage[index][headstage][%SAMPLINGINTERVALDAC]) + stv = JSON_GetString(jsonID, "/properties/sample interval DAC/unit") + CHECK_EQUAL_STR(stv, "ms") + var = JSON_GetVariable(jsonID, "/properties/baseline fraction/value") + CHECK_EQUAL_VAR(var, 35) + stv = JSON_GetString(jsonID, "/properties/baseline fraction/unit") + CHECK_EQUAL_STR(stv, "%") + var = JSON_GetVariable(jsonID, "/properties/timestamp/value") + CHECK_EQUAL_VAR(var, tpStorage[index][headstage][%TimeStamp]) + stv = JSON_GetString(jsonID, "/properties/timestamp/unit") + CHECK_EQUAL_STR(stv, "s") + var = JSON_GetVariable(jsonID, "/properties/timestampUTC/value") + CHECK_EQUAL_VAR(var, tpStorage[index][headstage][%TimeStampSinceIgorEpochUTC]) + stv = JSON_GetString(jsonID, "/properties/timestampUTC/unit") + CHECK_EQUAL_STR(stv, "s") + + var = JSON_GetVariable(jsonID, "/properties/tp cycle id") + CHECK_EQUAL_VAR(var, tpStorage[index][headstage][%TPCycleID]) + + var = JSON_GetVariable(jsonID, "/results/average baseline steady state/value") + if(tpStorage[index][headstage][%ClampMode] == V_CLAMP_MODE) + CHECK_EQUAL_VAR(var, tpStorage[index][headstage][%Baseline_VC]) + else + CHECK_EQUAL_VAR(var, tpStorage[index][headstage][%Baseline_IC]) + endif + stv = JSON_GetString(jsonID, "/results/average baseline steady state/unit") + CHECK_EQUAL_STR(stv, adUnit) + var = JSON_GetVariable(jsonID, "/results/average tp steady state/value") + CHECK_NEQ_VAR(var, NaN) + stv = JSON_GetString(jsonID, "/results/average tp steady state/unit") + CHECK_EQUAL_STR(stv, adUnit) + var = JSON_GetVariable(jsonID, "/results/instantaneous/value") + CHECK_NEQ_VAR(var, NaN) + stv = JSON_GetString(jsonID, "/results/instantaneous/unit") + CHECK_EQUAL_STR(stv, adUnit) + var = JSON_GetVariable(jsonID, "/results/steady state resistance/value") + CHECK_EQUAL_VAR(var, tpStorage[index][headstage][%SteadyStateResistance]) + stv = JSON_GetString(jsonID, "/results/steady state resistance/unit") + CHECK_EQUAL_STR(stv, "MΩ") + var = JSON_GetVariable(jsonID, "/results/instantaneous resistance/value") + CHECK_EQUAL_VAR(var, tpStorage[index][headstage][%PeakResistance]) + stv = JSON_GetString(jsonID, "/results/instantaneous resistance/unit") + CHECK_EQUAL_STR(stv, "MΩ") + endfor +End diff --git a/Packages/tests/UTF_DataGenerators.ipf b/Packages/tests/UTF_DataGenerators.ipf index 6dd8dedcd8..eb6b2e771f 100644 --- a/Packages/tests/UTF_DataGenerators.ipf +++ b/Packages/tests/UTF_DataGenerators.ipf @@ -876,3 +876,11 @@ static Function/WAVE GetBasicMathOperations() return op End + +static Function/WAVE PUB_TPFilters() + + Make/FREE/T wv = {ZMQ_FILTER_TPRESULT_NOW, ZMQ_FILTER_TPRESULT_1S, ZMQ_FILTER_TPRESULT_5S, ZMQ_FILTER_TPRESULT_10S} + SetDimensionLabels(wv, "period_now;period_1s;period_5s;period_10s", ROWS) + + return wv +End