Question about Photon and IPC

Hello,

I want to make an application that does this:

Photon displays some graphics and text on screen.

Application enters a loop in which the user can select one of the following
commands:

Add graphic (provide path) (This will be a PtLabel?)
Add text
Update text

So basically I want to be able to dynamically create and update the Photon
GUI. I am not using AP Builder at all for this.

What’s the easiest way to do this? I was thinking of having 1 process be the
Photon App which will InitGraphics and then enter the MainLoop. A second
thread will block on user input. When the user selects something, it will
message the Photon process to update the display.

Does this sound right? How exactly do I do something like this?
Specifically, how can my Photon application accept messages while in its
MainEventLoop.

Thanks!

Multi-threading in a Photon Application should be use as a last resort
only !

One word PtRaw.

1 ) Create a PtRaw (PtCreateWidget() ).
2 ) Set the Pt_ARG_RAW_DRAW_F of your PtRaw. This will be called when
your widget is damage ( you do your drawing in it ).
3 ) Add a event handler to your PtRaw use PtAddEventHandler(). This will
be call on user inputs.At the end of your event handler, if your need to
redraw, damage ( PtDamageWidget ) your PtRaw.

Multi-threading is a nice feature, but it is like C++, it should not be
abuse.

Michel Belanger

Sachin Agarwal wrote:

Hello,

I want to make an application that does this:

Photon displays some graphics and text on screen.

Application enters a loop in which the user can select one of the following
commands:

Add graphic (provide path) (This will be a PtLabel?)
Add text
Update text

So basically I want to be able to dynamically create and update the Photon
GUI. I am not using AP Builder at all for this.

What’s the easiest way to do this? I was thinking of having 1 process be the
Photon App which will InitGraphics and then enter the MainLoop. A second
thread will block on user input. When the user selects something, it will
message the Photon process to update the display.

Does this sound right? How exactly do I do something like this?
Specifically, how can my Photon application accept messages while in its
MainEventLoop.

Thanks!

Thanks for the info. I have a couple questions:

With a PtRaw widget, do you never enter the MainEventLoop? Basically I’ll
execute my own user input code and redraw as needed?

I forgot to mention that I may be updating my GUI based on input from
another process

Is this most easily done with Pulses or messages? I saw some documentation
but no real examples. I just want to be able to easily send quick messages
to a running Photon application.

Thanks!




in article 3CE9A846.2000400@videotron.ca, Michel Belanger at
micbel@videotron.ca wrote on 5/20/02 6:52 PM:

Multi-threading in a Photon Application should be use as a last resort
only !

One word PtRaw.

1 ) Create a PtRaw (PtCreateWidget() ).
2 ) Set the Pt_ARG_RAW_DRAW_F of your PtRaw. This will be called when
your widget is damage ( you do your drawing in it ).
3 ) Add a event handler to your PtRaw use PtAddEventHandler(). This will
be call on user inputs.At the end of your event handler, if your need to
redraw, damage ( PtDamageWidget ) your PtRaw.

Multi-threading is a nice feature, but it is like C++, it should not be
abuse.

Michel Belanger

Sachin Agarwal wrote:

Hello,

I want to make an application that does this:

Photon displays some graphics and text on screen.

Application enters a loop in which the user can select one of the following
commands:

Add graphic (provide path) (This will be a PtLabel?)
Add text
Update text

So basically I want to be able to dynamically create and update the Photon
GUI. I am not using AP Builder at all for this.

What’s the easiest way to do this? I was thinking of having 1 process be the
Photon App which will InitGraphics and then enter the MainLoop. A second
thread will block on user input. When the user selects something, it will
message the Photon process to update the display.

Does this sound right? How exactly do I do something like this?
Specifically, how can my Photon application accept messages while in its
MainEventLoop.

Thanks!
\

Sachin Agarwal wrote:

Thanks for the info. I have a couple questions:

With a PtRaw widget, do you never enter the MainEventLoop?

You still call PtMainLoop to enter the Photon cycle of life, but after you have
initialize and created all you need.

Basically I’ll
execute my own user input code and redraw as needed?

Does it sound to easy ? PtRaw is a do it your self widget, but sill a widget. What
I mean is by using PtRaw your are working within the Photon architecture instead of
working agains it. The PtRaw is one of the rare thing well documented, so first
things to do is launching your helpviewer, doing a search on PtRaw and reading it
all.

I forgot to mention that I may be updating my GUI based on input from
another process

Is this most easily done with Pulses or messages? I saw some documentation
but no real examples. I just want to be able to easily send quick messages
to a running Photon application.

Here is an example on pulses.
http://qdn.qnx.com/support/docs/photon_2.0_en/prog_guide/ipc.html#PhotonPulses

As for witch one is easiest, it depends on what you need to transfert between
application. If it is only an event notification, pulse is the way to go and you
use the 4 byte of pulse data to specify the event type. But for bigger data
transfer you will have to use messages.

Thanks!

in article > 3CE9A846.2000400@videotron.ca> , Michel Belanger at
micbel@videotron.ca > wrote on 5/20/02 6:52 PM:

Ok, great. Looks like I’m going to be using messages.

Last question: If I enter PtMainLoop, how do I accept messages? It seems at
that point the code execution is out of my hands and I can’t call
MsgReceive()

Thanks

Sachin


in article 3CEA226F.73B4EDBD@videotron.ca, Michel Belanger at
micbel@videotron.ca wrote on 5/21/02 3:33 AM:

Sachin Agarwal wrote:

Thanks for the info. I have a couple questions:

With a PtRaw widget, do you never enter the MainEventLoop?

You still call PtMainLoop to enter the Photon cycle of life, but after you
have
initialize and created all you need.

Basically I’ll
execute my own user input code and redraw as needed?


Does it sound to easy ? PtRaw is a do it your self widget, but sill a widget.
What
I mean is by using PtRaw your are working within the Photon architecture
instead of
working agains it. The PtRaw is one of the rare thing well documented, so
first
things to do is launching your helpviewer, doing a search on PtRaw and reading
it
all.


I forgot to mention that I may be updating my GUI based on input from
another process

Is this most easily done with Pulses or messages? I saw some documentation
but no real examples. I just want to be able to easily send quick messages
to a running Photon application.


Here is an example on pulses.
http://qdn.qnx.com/support/docs/photon_2.0_en/prog_guide/ipc.html#PhotonPulses

As for witch one is easiest, it depends on what you need to transfert between
application. If it is only an event notification, pulse is the way to go and
you
use the 4 byte of pulse data to specify the event type. But for bigger data
transfer you will have to use messages.


Thanks!

in article > 3CE9A846.2000400@videotron.ca> , Michel Belanger at
micbel@videotron.ca > wrote on 5/20/02 6:52 PM:

Sachin Agarwal wrote:

Ok, great. Looks like I’m going to be using messages.

Last question: If I enter PtMainLoop, how do I accept messages? It seems at
that point the code execution is out of my hands and I can’t call
MsgReceive()

Read this. ( there is even an example ).

http://qdn.qnx.com/support/docs/photon_2.0_en/prog_guide/ipc.html#ReceivingQNXMessages


Michel Belanger