[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

FXRuby addInput for general win32 eventrs

parisnight

10/17/2003 1:14:00 PM

Hello,
I'd like to use addInput to detect events occuring in
another thread. Is there a way to take advantage of
MsgWaitForMultipleObjects() for things like event objects
and mutexes from FXRuby?
It looks like you can pass any HANDLE to the FOX C++ API
but FXRuby addInput expects Ruby IO objects. I don't know
MSWindows much.
Bob
3 Answers

Lyle Johnson

10/17/2003 2:25:00 PM

0

anderson wrote:

> I'd like to use addInput to detect events occuring in
> another thread. Is there a way to take advantage of
> MsgWaitForMultipleObjects() for things like event objects
> and mutexes from FXRuby?

I don't think that there is any way for you to do this, currently. I'm
certainly open to adding support for it if I can get more details.

> It looks like you can pass any HANDLE to the FOX C++ API
> but FXRuby addInput expects Ruby IO objects. I don't know
> MSWindows much.

You are correct that the C++ version of addInput() just takes a HANDLE
on Windows. I mapped that to Ruby I/O objects since, at the time, it
seemed like the obvious choice.

What are the other librari(es) you're using with Ruby that would be the
source of the HANDLE that you would want to pass into addInput() as an
argument? If I can figure out what kind of object they're using (on the
Ruby side) to represent a Win32 HANDLE, I can probably work with those
too (he says, optimistically ;)

-- Lyle

P.S.

I did try to respond to your previous private e-mail to me about this
question, but the e-mail bounced (your mailbox was full, I think).

parisnight

10/17/2003 6:36:00 PM

0

> What are the other librari(es) you're using with Ruby that would be the
> source of the HANDLE that you would want to pass into addInput() as an
> argument? If I can figure out what kind of object they're using (on the
> Ruby side) to represent a Win32 HANDLE, I can probably work with those
> too (he says, optimistically ;)
>
> -- Lyle

Hello Lyle,
I wrote a Ruby extension that processes a serial port stream and
divides it up into messages using the SLIP protocol. I'd like to
trigger the FXRuby GUI to read the message buffer when a complete
frame has arrived and plot things using the beautiful FXRuby.
If I were a MSWindows programmer I would write a proper device driver
that looked like a file and just addInput on it but alas that is
beyond my MSWindows skills. I could just open the serial port in
Ruby but processing the protocol takes some overhead.
I could write a separate process and
addInput pipe but I don't know how processes work on W2k and I've
had occasional troubles with threads in forked child processes
hanging on to MSWindowy dll things (probably due to me).
I did see that there is PulseEvent(HANDLE event) in win32 that
I thought could be used to trigger FXRuby to run the Ruby level callback.

I'm open to any suggestion how FXRuby can process the messages as
they arrive.
Bob

parisnight

10/17/2003 9:04:00 PM

0

Lyle Johnson <lyle@users.sourceforge.net> wrote in message

> What are the other librari(es) you're using with Ruby that would be the

I wrote a Ruby extension that gathers serial port data into
messages. I'd like to pass the completed messages to the
FXRuby GUI for plotting.
I'm open to any ideas to get the data into FXRuby land.
Here were some alternatives I had consided
1. Write a proper device driver but I don't know MSWindows
2. Open the serial device in FXRuby but this seems inefficient
3. addInput pipe to separate process doing the serial protocol

I noticed that win32 has a PulseEvent(HANDLE event) which I
thought might be handy for triggering FXRuby to run the
callback routine to process the message. Any ideas or
suggestions are appreciated.