Re: ActiveX.exe more problems




"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 transfers
of 24 byte packets.
I meant a (screen-) scanline - and the thread should be alive, as long as
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 traces
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.
You will have no problems with this using the demo-approach.

RaiseEvent CheckBuffer
No, 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 the
"CheckRingBufferQueue"
Raising the event was just moved from the Form to the Class
But the Form is instantiated inside CMain, receiving PostMessage-
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 your
Data into the MainApp.

If the DatAry was Public in the bas module isn't it visible
to both threads just like the ring buffer?
No - only if it is defined inside the SharedArray as a RingBuffer-
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


.



Relevant Pages

  • Re: ActiveX.exe more problems
    ... after 1,020 pixels of data. ... flag it starts interrogating the USB device until it sees that the ... As said above - there's absolutely no problem, to signalize from CThread ... to CMain, that the scanline is completed and it ...
    (microsoft.public.vb.general.discussion)
  • Re: ActiveX.exe more problems
    ... Does Cmain and Cthread share the data in SharedData.bas? ... Public Type TBurstData ... The RingBuffer currently has 64 slots, to fill independent 'DatArys' in. ...
    (microsoft.public.vb.general.discussion)
  • Re: ActiveX.exe more problems
    ... The real-time in my App is controlled by a USB ... that the MainThread (CMain) is checking ... for new data, that you just filled in (inside CThread), then simply ... CMain (over the Helperforms-KeyDown -> triggering an Event inside ...
    (microsoft.public.vb.general.discussion)
  • Re: ActiveX.exe more problems
    ... Does Cmain and Cthread share the data in SharedData.bas? ... Both the App and the USB device know exactly what is happening. ...
    (microsoft.public.vb.general.discussion)