@@ -645,3 +645,87 @@ Function PUB_AccessResistanceSmoke(string device, variable sweepNo, variable hea
645
645
646
646
PUB_Publish ( jsonID, ANALYSIS_FUNCTION_AR)
647
647
End
648
+
649
+ threadsafe static Function PUB_AddTPResultEntry ( variable jsonId, string path, variable value, string unit)
650
+
651
+ JSON_AddTreeObject ( jsonID, path)
652
+ JSON_AddVariable ( jsonID, path + "/value" , value)
653
+ if ( ! IsEmpty ( unit))
654
+ JSON_AddString ( jsonID, path + "/unit" , unit)
655
+ endif
656
+ End
657
+
658
+ threadsafe Function PUB_TPResult ( STRUCT TPZMQData &tpzmq)
659
+
660
+ string path
661
+ variable jsonId = JSON_New ()
662
+ string adUnit = GetADChannelUnit ( tpzmq. clampMode)
663
+ string daUnit = GetDAChannelUnit ( tpzmq. clampMode)
664
+
665
+ path = "properties"
666
+ JSON_AddTreeObject ( jsonID, path)
667
+ JSON_AddVariable ( jsonID, path + "/tp marker" , tpzmq. marker)
668
+ JSON_AddString ( jsonID, path + "/device" , tpzmq. device)
669
+ JSON_AddVariable ( jsonID, path + "/headstage" , tpzmq. headstage)
670
+ JSON_AddVariable ( jsonID, path + "/clamp mode" , tpzmq. clampMode)
671
+
672
+ PUB_AddTPResultEntry ( jsonId, path + "/time of tp acquisition" , tpzmq. now, "s" )
673
+ PUB_AddTPResultEntry ( jsonId, path + "/clamp amplitude" , tpzmq. clampAmp, daUnit)
674
+ PUB_AddTPResultEntry ( jsonId, path + "/tp length ADC" , tpzmq. tpLengthPointsADC, "points" )
675
+ PUB_AddTPResultEntry ( jsonId, path + "/pulse duration ADC" , tpzmq. pulseLengthPointsADC, "points" )
676
+ PUB_AddTPResultEntry ( jsonId, path + "/pulse start point ADC" , tpzmq. pulseStartPointsADC, "point" )
677
+ PUB_AddTPResultEntry ( jsonId, path + "/sample interval ADC" , tpzmq. samplingIntervalADC, "ms" )
678
+ PUB_AddTPResultEntry ( jsonId, path + "/tp length DAC" , tpzmq. tpLengthPointsDAC, "points" )
679
+ PUB_AddTPResultEntry ( jsonId, path + "/pulse duration DAC" , tpzmq. pulseLengthPointsDAC, "points" )
680
+ PUB_AddTPResultEntry ( jsonId, path + "/pulse start point DAC" , tpzmq. pulseStartPointsDAC, "point" )
681
+ PUB_AddTPResultEntry ( jsonId, path + "/sample interval DAC" , tpzmq. samplingIntervalDAC, "ms" )
682
+ PUB_AddTPResultEntry ( jsonId, path + "/baseline fraction" , tpzmq. baselineFrac * ONE_TO_PERCENT, "%" )
683
+ PUB_AddTPResultEntry ( jsonId, path + "/timestamp" , tpzmq. timeStamp, "s" )
684
+ PUB_AddTPResultEntry ( jsonId, path + "/timestampUTC" , tpzmq. timeStampUTC, "s" )
685
+ PUB_AddTPResultEntry ( jsonId, path + "/tp cycle id" , tpzmq. cycleId, "" )
686
+
687
+ path = "results"
688
+ JSON_AddTreeObject ( jsonID, path)
689
+ PUB_AddTPResultEntry ( jsonId, path + "/average baseline steady state" , tpzmq. avgBaselineSS, adUnit)
690
+ PUB_AddTPResultEntry ( jsonId, path + "/average tp steady state" , tpzmq. avgTPSS, adUnit)
691
+ PUB_AddTPResultEntry ( jsonId, path + "/instantaneous" , tpzmq. instVal, adUnit)
692
+ PUB_AddTPResultEntry ( jsonId, path + "/steady state resistance" , tpzmq. resistanceSS, "MΩ" )
693
+ PUB_AddTPResultEntry ( jsonId, path + "/instantaneous resistance" , tpzmq. resistanceInst, "MΩ" )
694
+
695
+ PUB_Publish ( jsonID, ZMQ_FILTER_TPRESULT_NOW, releaseJSON = 0 )
696
+ if ( PUB_CheckPublishingTime ( ZMQ_FILTER_TPRESULT_1 S, 1 ))
697
+ PUB_Publish ( jsonID, ZMQ_FILTER_TPRESULT_1 S, releaseJSON = 0 )
698
+ endif
699
+ if ( PUB_CheckPublishingTime ( ZMQ_FILTER_TPRESULT_5 S, 5 ))
700
+ PUB_Publish ( jsonID, ZMQ_FILTER_TPRESULT_5 S, releaseJSON = 0 )
701
+ endif
702
+ if ( PUB_CheckPublishingTime ( ZMQ_FILTER_TPRESULT_10 S, 10 ))
703
+ PUB_Publish ( jsonID, ZMQ_FILTER_TPRESULT_10 S, releaseJSON = 0 )
704
+ endif
705
+ JSON_Release ( jsonID)
706
+ End
707
+
708
+ /// @brief Updates the publishing timestamp in the TUFXOP storage and returns 1 if an update is due (0 otherwise)
709
+ threadsafe static Function PUB_CheckPublishingTime ( string pubFilter, variable period)
710
+
711
+ variable curTime
712
+
713
+ TUFXOP_AcquireLock / N= ( pubFilter)
714
+ TUFXOP_GetStorage / Z/ Q/ N= ( pubFilter) lastUpdated
715
+ if ( V_flag)
716
+ TUFXOP_Init / N= ( pubFilter)
717
+ TUFXOP_GetStorage / Z/ N= ( pubFilter) lastUpdated
718
+ Make / FREE/ D dTime = { DateTime }
719
+ lastUpdated[ 0 ] = dTime
720
+ endif
721
+ curTime = DateTime
722
+ WAVE lastTime = lastUpdated[ 0 ]
723
+ if ( lastTime[ 0 ] + period > curTime)
724
+ lastTime[ 0 ] = curTime + period
725
+ TUFXOP_ReleaseLock / N= ( pubFilter)
726
+ return 1
727
+ endif
728
+ TUFXOP_ReleaseLock / N= ( pubFilter)
729
+
730
+ return 0
731
+ End
0 commit comments