This project has moved and is read-only. For the latest updates, please go here.

SynchronizedSubscribe vs. UnsynchronizedSubscribe

Jun 16, 2011 at 3:27 PM

I'm trying to understand when DataSubscriber.SynchronizedSubscribe should be called and when call DataSubscriber.UnsynchronizedSubscribe should be called.

From a test harness to test both these methods, I notice that when we have an InputMeasurement Filter specified to both these calls, SynchronizedSubscribe still seems to return all measurement values, where as UnsynchronizedSubscribe filters returns only the measurement that we asked for. Can you please explain this behavior so I can understand better. Thanks!

By debugging into DataSubscriber this is what I see getting passed into public virtual bool Subscribe(bool synchronized, bool compactFormat, string connectionString)

For SynchronizedSubscribe call: connectionstring = "password=<>; framesPerSecond=30; lagTime=0.1; leadTime=1; inputMeasurementKeys={PPA:818}; useLocalClockAsRealTime=False; ignoreBadTimestamps=False; allowSortsByArrival=True; timeResolution=10000; allowPreemptivePublishing=True; downsamplingMethod=LastReceived", synchronized =true, compactFormat=true

For UnsynchronizedSubscribe call: connectionString="password=<>; trackLatestMeasurements=True; lagTime=0.1; leadTime=1; inputMeasurementKeys={PPA:818}; useLocalClockAsRealTime=False", synchronized =false, compactFormat=true

Jun 16, 2011 at 6:04 PM

Hi Uma - technically both the synchronized and unsynchrnonized should both filter down to the specified points - are you using a precompiled version of the library or building from scratch (trying to figure out which version is experiencing the behavior you mention).

The difference between the two call is that the "Synchronized" API call returns data time-sorted, the "Unsynchronized" API call returns data on change as recevied in no particular order - as you may expect, the latency on the "Unsynchronized" call will be smaller since you are not having to wait for measurement arrival and sorting. The "Unsynchronized" call also allows for slower intervals for data reception (e.g., once every few seconds).

Hope that helps!
Ritchie

Jun 16, 2011 at 6:50 PM

Thanks Ritchie for the response. I see this behavior with both the precompiled version as well as the version built from source code.

I see that when I debug into ActionAdapterBase (this = dataPublisher.SynchronizedClientSubscription), ProcessMeasurementFilter value is false, measurements count = 137, so they all get sorted.

        public virtual void QueueMeasurementsForProcessing(IEnumerable<IMeasurement> measurements)
        {
            if (m_disposed)
                return;

            if (ProcessMeasurementFilter)
            {
                List<IMeasurement> inputMeasurements = new List<IMeasurement>();

                foreach (IMeasurement measurement in measurements)
                {
                    if (IsInputMeasurement(measurement.Key))
                        inputMeasurements.Add(measurement);
                }

                if (inputMeasurements.Count > 0)
                    SortMeasurements(inputMeasurements);
            }
            else
            {
                SortMeasurements(measurements);
            }
        }

 Whereas when using the UnsynchronizedSubscribe, it goes into the dataPublisher.UnSynchronizedSubscription.QueueMeasurementsForProcessing and filters the measurements and then calls the base.QueueMeasurementsForProcessing with the filteredMeasurements whose count = 1

            public override void QueueMeasurementsForProcessing(IEnumerable<IMeasurement> measurements)
            {
                List<IMeasurement> filteredMeasurements = new List<IMeasurement>();

                lock (this)
                {
                    foreach (IMeasurement measurement in measurements)
                    {
                        if (IsInputMeasurement(measurement.Key))
                            filteredMeasurements.Add(measurement);
                    }
                }
                if (filteredMeasurements.Count > 0 && Enabled)
                {
                    if (TrackLatestMeasurements)
                    {
                        // Keep track of latest measurements
                        base.QueueMeasurementsForProcessing(filteredMeasurements);

When I set breakpoints on AdapterBase.IsInputMeasurement and ActionAdapterBase.IsInputMeasurement methods, the AdapterBase.IsInputMeasurement method gets hit when using UnsynchronizedSubscribe, where as SynchronizedSubscribe does not hit either of these 2 methods. I'm not sure if this is the expected behavior or if I'm missing setting some config value.

Thanks,

Uma


Jun 17, 2011 at 3:55 PM

Thanks Uma - you are correct. I remember fixing this now - this was corrected in build 67611 on 6/7 earlier this month. This update should be available as soon as we are able to roll TSF updates into openPDC - we'll try to get this updated ASAP.

Ritchie

Jun 17, 2011 at 4:01 PM

Thanks Ritchie!