[Prev][Next][Index][Thread]
Re: help with DUIM application
On Tue, 13 Jun 2000 22:45:02 -0400 (EDT), "John Whittaker"
<johncwhi@earthlink.net> wrote:
> What would be the correct way to use DUIM to create an application which
> periodically (about 1 Hz) reads a sequence of data received via a serial
> port and translates the data for display in a simple dialog window?
>
> My first thoughts were:
>
> 1. Have two threads. One for the serial input task and one for the display
> task. Assuming that to be the design, what is the proper way in DUIM to
> signal the display task that new data is available for translation and
> display. I know that DUIM has event queue processing, but I don't know how
> it works. Would it make sense to define a new subclass of <event>, say
> <io-ready-event>, and use it to signal from the serial input task to the
> display task? The display task would, of course, somehow have to have a
> modified event loop that recognizes the new class <io-ready-event>. The
> event handling for the event in the display task would be to grab the data
> from the input task and then translate and display it.
As Scott says you basically do it this way. However, you don't need to create
any new event class or modify any event loop stuff. You just call either
call-in-frame or apply-in-frame (depending on your needs) and that will create
an event behind the scenes and run the given method on the UI thread for that
frame. Its trivial.
e.g. in its simplest form (untested):
begin
let frame = make(<my-frame>);
make(<thread>, function: curry(start-data-capture, frame));
start-frame(frame); // NB uses up main thread
end;
define method start-data-capture (frame)
while (#t)
let data = blocking-read-for-device-data();
call-in-frame(frame, update-my-frame, data);
end;
end method;
define method update-my-frame (frame :: <my-frame>, data)
// insert display changing code here
end method;
__Jason
_____________________________________________________________________
This message has been checked for all known viruses by Star Internet delivered
through the MessageLabs Virus Control Centre. For further information visit
http://www.star.net.uk/stats.asp
References: