Re: ActiveX.exe more problems
- From: "Schmidt" <sss@xxxxxxxxx>
- Date: Sat, 3 Jun 2006 04:38:46 +0200
"Galen Somerville" <galen@xxxxxxxxxxxx> schrieb im Newsbeitrag
news:ueP84uqhGHA.4504@xxxxxxxxxxxxxxxxxxxxxxx
Both the App and the USB device automatically stop processing
after 1,020 pixels of data. No communications between them
saying they are done. If the App doesn't see an Abort or Stop
flag it starts interrogating the USB device until it sees that the
Trigger level has been reached. Then the whole 1,020
pixel operation starts over again.
Independently if we define continous Data-Sampling using the Device-
API-Calls as streaming or not - it is not necessary, to shutdown and
restart the Device-Thread every 2.5 seconds.
If you really must have those interruptions after each completed scanline
(1020 pixels), then let the thread simply in its loop, until you set a flag
over the shared-array, to signalize the next round of sampling.
It's not a single line of data. The thread will be alive for 170 transfersI meant a (screen-) scanline - and the thread should be alive, as long as
of 24 byte packets.
the MainApplication is alive and the USB-Device is connected to the PC.
As said above - there's absolutely no problem, to signalize from CThread
to CMain (using the shared-array), that the scanline is completed and it
is also no problem for CMain, to tell CThread (wich is looping all the time)
that it has to begin data-sampling again for the next scanline (again using
the shared array with another additional flag).
Each packet will raise an event so the App can draw partial tracesYou will have no problems with this using the demo-approach.
while the next packet is being received. Packets are received every
14 ms typically. This depends on the Heart rate and number of beats
displayed. Could be shorter or much longer intervals.
RaiseEvent CheckBufferNo, no way, really - this is exactly the point, that brings all
the trouble into the game (CrossThread-Event-Marshaling
with all those potential blocking-issues)
The raised event "CheckBuffer" is just a rename of theBut the Form is instantiated inside CMain, receiving PostMessage-
"CheckRingBufferQueue"
Raising the event was just moved from the Form to the Class
Calls from CThread. The demo-code is a robust construct, as
long as you don't change the principle, how it works.
The usage of VBs RaiseEvent is tabu from inside CThread.
All what CThread has to do is:
Loop,
check for Command-Flags in the SharedArray (from CMain),
retreive new data from the device and store it in the next slot
PostMessage to CMain, to trigger the Callback-Event
Loop again
Nothing more, it is that simple.
All what CMain has to do is:
offer a userinterface to the Main-App, that hides the dirty
details of the device-handling (those are inside CThread)
StartDevice, CloseDevice (evtl. StartNewScanline)
and the Event wich transports the datasamples to the
MainApp + evtl. an Event "ScanLineReady".
Three Public Methods and two Events, simple.
Now the more complex part of CMain.
The PostMessage-Call from CThread is received in the
HelperForms KeyDown-Event. From there it is directed
to CMains CheckRingBufferQueue.
Inside this procedure, the shared-array is checked ("from the
other side"), up to the newest slot with the newest DatAry-Chunk.
From here you can safely do a RaiseEvent, beaming yourData into the MainApp.
If the DatAry was Public in the bas module isn't it visibleNo - only if it is defined inside the SharedArray as a RingBuffer-
to both threads just like the ring buffer?
Slot.
I've already posted you Code, how to implement the whole thing
using your DatAry inside the Ringbuffer-Slots - just try it this way.
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
- From: Schmidt
- Re: ActiveX.exe more problems
- From: Galen Somerville
- Re: ActiveX.exe more problems
- From: Schmidt
- Re: ActiveX.exe more problems
- From: Galen Somerville
- Re: ActiveX.exe more problems
- Prev by Date: Re: Normalizing internet header date/time stamps (Was: tif image conversion)
- Next by Date: Re: Normalizing internet header date/time stamps (Was: tif image conversion)
- Previous by thread: Re: ActiveX.exe more problems
- Next by thread: Re: ActiveX.exe more problems
- Index(es):
Relevant Pages
|