SampleEveryDataPoint example does not work in playback mode

35 views
Skip to first unread message

Mark Richman

unread,
May 21, 2012, 5:20:28 PM5/21/12
to IADS
I would like to be able to process every data point, so I am modeling
my active-X control after your SampleEveryDataPoint example. However,
there seems to be an issue processing the data in playback mode. The
SampleEveryDataPoint control works correctly when data is streaming,
but shows incorrect values when paused in playback mode . For
example, I defined a derived parameter named THREE that is an INTand
always evaluates to the value 3. I dropped the THREE parameter on a
TEXT control (IadsPrimitives.IadsText) and selected the "Value"
property. I also dropped the THREE parameter on a
SampleEveryDataPoint control
(SampleAxControlVS2005.SampleEveryDataPoint) and selected the
"EveryDataPoint"property. The Text control always shows "3".
However, the SampleEveryDataPoint control shows only shows "3" in
RealTime mode (when the traffic light is green). Before starting
RealTime mode and after stopping RealTime mode (by dragging the scroll
bar button), the SampleEveryDataPoint control shows garbage
(-859045885.000000). Please let me know what I can do, if anything,
to correct this issue.

James Bretz

unread,
May 21, 2012, 5:40:58 PM5/21/12
to IADS
Hi Mark,

Assuming you have the latest example from the web site, there is a section
of code at "Step 24" that handles the "scrollback".

After examining the example, looks like I made yet another error. I forgot
to call the function "put_CurrentTime" before the "Value2" function was
called, so it's probably returning failure and the value is undefined.

Here's the corrected code:

// Step 24. Check to see if the user is in scroll back mode (and thus the
time could be randomly jumping)
// or the display is streaming data at the current time
if ( mIsRealTime == VARIANT_FALSE )
{
// The user is scrolling back with the scrollbar, so let's just read
data from the current time
// Depending on your display needs, you could actually read a block of
data from the current time for N seconds

// Set the current time in the parameter
mParameters[0]->put_CurrentTime( parentContainerTime );

// Now get the value from the parameter
CComVariant dataValue;
mParameters[0]->Value2( iadsTimeNoChange, &dataValue,
NULL/*OptionTimeReturn*/ );

// Extract the value from the variant returned
mValueToDisplay = GetArrayValueHelper( dataValue.vt, &dataValue, 0 );
this->FireViewChange(); // Ask that our display be redrawn with the
new value

// Reset the state of the streaming frame read
mParameters[0]->put_HaveStartedFrameRead( VARIANT_FALSE );
return S_OK;
}

Let me know how it goes. If you're still getting garbage, step into the
'GetArrayValueHelper' and make sure it's extracting the value from the
variant correctly.

I'll try to get the example update asap,
Jim

--------------------------------------------------
From: "Mark Richman" <markari...@gmail.com>
Sent: Monday, May 21, 2012 2:20 PM
To: "IADS" <ia...@googlegroups.com>
Subject: [IADS] SampleEveryDataPoint example does not work in playback mode
> --
> You received this message because you are subscribed to the Google Groups
> "IADS" group.
> To post to this group, send email to ia...@googlegroups.com.
> To unsubscribe from this group, send email to
> iads+uns...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/iads?hl=en.
>

James Bretz

unread,
May 21, 2012, 5:58:41 PM5/21/12
to IADS
Mark,

I shouldn't have passed the variant value from Value2 into the
GetArrayValueHelper. That function was only meant to parse arrays returned
from the GetNextFrameRead function.

I'll need to build another function to simplify the returned variant... but
basically, the value is a variant
(http://msdn.microsoft.com/en-us/library/windows/desktop/aa380072(v=vs.85).aspx)
so simply access the appropriate type inside the 'dataValue' variant.

I'll post the corrections soon,
Jim

--------------------------------------------------
From: "James Bretz" <j...@iads-soft.com>
Sent: Monday, May 21, 2012 2:40 PM
To: "IADS" <ia...@googlegroups.com>
Subject: Re: [IADS] SampleEveryDataPoint example does not work in playback

James Bretz

unread,
May 21, 2012, 6:15:23 PM5/21/12
to ia...@googlegroups.com
Mark,

Ok, add the 'GetVariantValueHelper' function below to the
SampleEveryDataPoint.h file, then modify the code in step 24 that sets
mValueToDisplay to call this new function (vs the previous call to the
GetArrayValueHelper function):

// Extract the value from the variant returned
mValueToDisplay = GetVariantValueHelper( dataValue );

I just tested and it works as expected.

I'll upload the corrected example soon. Sorry for the problems. I guess I
was too focused on processing blobs,
Jim


// Helper function to demonstrate extracting data from a variant. For
long/ulong/blob/ascii it might be best to create other function(s)
double GetVariantValueHelper( VARIANT& v )
{
switch( v.vt )
{
case VT_R8: return v.dblVal;
case VT_R4: return (double)v.fltVal;
case VT_INT:
case VT_I4: return (double)v.lVal;
case VT_UI4: return (double)v.ulVal;
case VT_I2: return (double)v.iVal;
case VT_UI2: return (double)v.uiVal;
case VT_I1:
case VT_UI1: return (double)v.bVal;
case VT_I8: return (double)v.llVal;
case VT_UI8: return (double)(__int64)v.ullVal; // This conversion
could loose precision
}

VARIANT v2;
if ( ::VariantChangeType(&v2,&v,VARIANT_ALPHABOOL,VT_R8) != S_OK )
return 0.0;
return v2.dblVal;
}


--------------------------------------------------
From: "James Bretz" <j...@iads-soft.com>
Sent: Monday, May 21, 2012 2:58 PM

Mark Richman

unread,
May 21, 2012, 6:59:35 PM5/21/12
to IADS
Jim,

It works like a charm!

Thanks,
Mark

James Bretz

unread,
May 21, 2012, 7:00:14 PM5/21/12
to ia...@googlegroups.com
;)

--------------------------------------------------
From: "Mark Richman" <markari...@gmail.com>
Sent: Monday, May 21, 2012 3:59 PM
To: "IADS" <ia...@googlegroups.com>
Subject: [IADS] Re: SampleEveryDataPoint example does not work in playback
mode

James Bretz

unread,
May 21, 2012, 8:28:15 PM5/21/12
to ia...@googlegroups.com
Ok, we've updated the web site with these changes to the example project.

Thanks for pointing that out,
Jim

--------------------------------------------------
From: "James Bretz" <j...@iads-soft.com>
Sent: Monday, May 21, 2012 4:00 PM
To: <ia...@googlegroups.com>
Subject: Re: [IADS] Re: SampleEveryDataPoint example does not work in
Reply all
Reply to author
Forward
0 new messages