Re: ActiveX.exe more problems
- From: "Schmidt" <sss@xxxxxxxxx>
- Date: Fri, 2 Jun 2006 19:49:26 +0200
"Galen Somerville" <galen@xxxxxxxxxxxx> schrieb im Newsbeitrag
news:u1z7yPmhGHA.896@xxxxxxxxxxxxxxxxxxxxxxx
I have a simple 24 byte array and the third party call
requires "VarPtr(DatAry(0))" in Cthread. I can only test
in full blown app because of USB device.
Question.Yes, the whole communication between CMain and CThread is
Does Cmain and Cthread share the data in SharedData.bas?
done over this mechanism.
If so then I don't need to set up a SharedAry, etc and couldI would recommend, using the setup as it comes with the demo.
use DatAry directly.
I mean, adapt it to your real stuff, but don't change the principle -
and the usage of the SharedArr (and especially the RingBuffer)
is one of the most important pieces in the Demo-scenario.
Regarding the adaption to your DatAry()-Array:
In your original Code you probably have something like this:
Private DatAry(0 to 23) as Byte
'and somewhere inside a loop:
USBDll_GetNewDataFromDeviceInto VarPtr(DatAry(0)), ...
assuming all the 24 Bytes are filled in a single call.
You should change the following type inside SharedData.bas:
Public Type TBurstData
SixSamples(0 To 5) As Long
End Type
into:
Public Type TBurstData
DatAry(0 To 23) As Byte
End Type
Change the MainLoop inside CThread into something like this:
With SharedArr(0)
InitSuccess = InitDevice()
If InitSuccess Then
'tell the MainThread, that we've initialized our Device
.DeviceInitialized = True
Do Until .CancelProcessing 'loop, until the Main-Thread sets the flag
If .CallbackHwnd Then PostMessage .CallbackHwnd, &H100, 0, 0
Dim pDatAry As Long
pDatAry = VarPtr(.RingBuffer(CurRingIndex).DatAry(0))
USBDll_GetNewDataFromDeviceInto pDatAry,...
.RingIndex = CurRingIndex 'signalize, up to wich slot we are
'now let's switch our internal RingIndex again one step ahead
CurRingIndex = (CurRingIndex + 1) Mod (UBound(.RingBuffer) + 1)
Loop
....
And finally redefine in CMain:
Public Event BurstEvent(DatAry() As Byte)
....
inside
Private Sub CallbackForm_CheckRingBufferQueue
...
RaiseEvent BurstEvent(DataChunk.DatAry)
That's all.
Don't let out the already builtin RingBuffer-Support, wich gives
you much greater "freedom", regarding the decoupling of the
"streaming realtime-data" inside CThread and their (possible
much later) Handling inside CMain.
The RingBuffer currently has 64 slots, to fill independent 'DatArys' in.
If the capturing of one single DatAry inside CThread needs around
15msec, then this RingBuffer-Cache gives you a "React-TimeFrame"
of about one second (64*15) inside CMain.
Remember, CMain is running inside the Visualizer-App, wich can
block for all the wellknown good reasons, so having a cache of this
type, you are able to keep up from the last processed index up to
the current one without loosing any DatAry-Buffers, during a larger
"User-Interface-Blocking-TimeOut".
If the one second reserve is not enough, you can simply enhance
the Cache-Depth to 128 (2seconds) or 256 (4seconds).
Olaf
.
- Follow-Ups:
- Re: ActiveX.exe more problems
- From: Galen Somerville
- Re: ActiveX.exe more problems
- References:
- Re: ActiveX.exe more problems
- From: Schmidt
- Re: ActiveX.exe more problems
- From: Schmidt
- Re: ActiveX.exe more problems
- From: Galen Somerville
- Re: ActiveX.exe more problems
- Prev by Date: Re: VB Reference Site
- Next by Date: Re: VB Reference Site
- Previous by thread: Re: ActiveX.exe more problems
- Next by thread: Re: ActiveX.exe more problems
- Index(es):
Relevant Pages
|
Loading