Re: ActiveX.exe more problems
- From: "Galen Somerville" <galen@xxxxxxxxxxxx>
- Date: Fri, 2 Jun 2006 12:13:31 -0700
"Schmidt" <sss@xxxxxxxxx> wrote in message
news:OPJUn0mhGHA.3496@xxxxxxxxxxxxxxxxxxxxxxx
flag
"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
If .CallbackHwnd Then PostMessage .CallbackHwnd, &H100, 0, 0I hear you but my thinking goes this way.
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
Both the App and the USB device know exactly what is happening. So in
MainLoop would be this:
For Index = 0 To Count - 1
Stat = WDU_TransferInterrupt(Dev, 129, True, 0, VarPtr(DatAry(0)),
Quant, Xsfrd, Twait)
If Stat <> STATUS_SUCCESS Then
sMsg2 = Stat2Str(Stat)
End If
RaiseEvent CheckBuffer
Next Index
Where Count would be 170 (1020 HorPixels / 6 sets of samples) and exiting
the For would kill the thread.
And in Cmain would be this:
Private Sub CallbackForm_CheckBuffer()
RaiseEvent BurstEvent(DatAry)
End Sub
Public Event BurstEvent(DatAry() As Byte)
In the WDU_ call above, Twait is generally 5 seconds. If no response then
Stat returns non-zero and could be made to kill the thread and return error
to App
Galen
.
- Follow-Ups:
- Re: ActiveX.exe more problems
- From: Schmidt
- 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
- From: Schmidt
- Re: ActiveX.exe more problems
- Prev by Date: Re: ADODB problems after 2005 upgrade from 2003 problems
- Next by Date: MS Flex Grid control, controlling keyboard
- Previous by thread: Re: ActiveX.exe more problems
- Next by thread: Re: ActiveX.exe more problems
- Index(es):
Relevant Pages
|
Loading