OpenQNX :: The QNX Community Portal

Oct 06, 2008 - 07:19 PM
Google
  Web openqnx.com   
     Create an account Home · Submit News · QNX Forums · QNX Download · Search   
_
Main Menu
Who's Online
There are 35 unlogged users and 1 registered user online.

You can log-in or register for a user account here.

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
dman3021
Post subject: Pop Up Dialog Box  PostPosted: Nov 22, 2006 - 04:17 PM
Active Member


Joined: Feb 16, 2006
Posts: 23

I was wondering if there is an easy way of creating a PopUp Dialog Box in a QNX Project using PhAB.

What I need is a PopUp Dialog to appear on screen when a certain event or alarm is raised in my program.

I figure I can build the whole thing from code and dynamically generate the dialog box, but I was wondering if there is an option in PhAB for this kind of action.

Thanks,

Dan...
 
 View user's profile Send private message  
Reply with quote Back to top
ingraham
Post subject:   PostPosted: Nov 27, 2006 - 03:31 PM
Active Member


Joined: Nov 05, 2003
Posts: 83
Location: Texas
Sure... sorta. The dialog itself can be generated in PhAB. The event itself is a little trickier, but basically drop a timer on your base window and check for the event in the timer's activate callback. When the event happens call ApCreateModule(). In PhAB, make sure you create a link (Project -> Internal Links) to define the location & setup function.

To summarize:
In PhAB, create dialog and it's internal link, and create a timer on the base window.

In code, watch for the event in the timer callback and call ApCreateModule().

That's it.

-James Ingraham
Sage Automation, Inc.
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
dman3021
Post subject:   PostPosted: Nov 30, 2006 - 04:08 PM
Active Member


Joined: Feb 16, 2006
Posts: 23

I've modified your solution a little. Very Happy Instead of having a timer cicle every x seconds, I've setup signal handlers that receive signals when a pop-up is required. Signal hanlders work great, but I'm crashing when I call ApCreateModule (ABM_Stuff, NULL, NULL). It sucks because the debugger doesn't seem to be able to step through the signal handler.

Ah well, can't have all I want I guess. I'll keep on working on this signal stuff, but if I start running around in circles, I may just use a timer afterall! Razz

Thanks!

Dan...
 
 View user's profile Send private message  
Reply with quote Back to top
jkohler
Post subject:   PostPosted: Dec 01, 2006 - 05:19 PM
Active Member


Joined: Jun 28, 2005
Posts: 12

When you say 'signal handler' are you using PtAppAddSignalProc() or a raw signal handler (i.e. signal() and friends)?

Calling into the photon libraries from within a raw signal handler would not work - use PtAppAddSignalProc to get photon/phab friendly handlers.
 
 View user's profile Send private message  
Reply with quote Back to top
dman3021
Post subject:   PostPosted: Dec 06, 2006 - 03:31 PM
Active Member


Joined: Feb 16, 2006
Posts: 23

I've been using signal() for a while, and everything was working fine, until I attempted to call ApCreateModule using my raw signal handler.

I've set the whole thing up with a timer, but didnt know about PtAppAddSignalProc()... I'll check it out.

Thanks
 
 View user's profile Send private message  
Reply with quote Back to top
dman3021
Post subject:   PostPosted: Dec 06, 2006 - 07:39 PM
Active Member


Joined: Feb 16, 2006
Posts: 23

Ok, step two... I want the popup box to beep when it appears. Should be simple, yes?

I basically added printf("\a"); before I call ApCreateModule(), but no sound... So I figure I did something wrong, and when I close the application I hear a beep.

So I try different things, moving the printf around, adding another, adding text after \a... nothing seems to get the system to beep until I shut down the app.

Any ideas?
 
 View user's profile Send private message  
Reply with quote Back to top
ingraham
Post subject:   PostPosted: Dec 07, 2006 - 03:40 PM
Active Member


Joined: Nov 05, 2003
Posts: 83
Location: Texas
"...nothing seems to get the system to beep until I shut down the app."

You're not going to believe me, but this code should work:

printf("\a\n");

Alternately:

printf("\a");
fflush(stdout);

-James Ingraham
Sage Automation, Inc.
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
dman3021
Post subject:   PostPosted: Dec 11, 2006 - 08:58 PM
Active Member


Joined: Feb 16, 2006
Posts: 23

Hehe,

yea, a coworker explained that prinf wont print until it hits a \n or is full.

I guess this is part of those embarrassing little things that you learn while doing...

Thanks,

Dan...
 
 View user's profile Send private message  
Reply with quote Back to top
dman3021
Post subject:   PostPosted: Apr 18, 2007 - 06:00 PM
Active Member


Joined: Feb 16, 2006
Posts: 23

dman3021 wrote:
Ok, step two... I want the popup box to beep when it appears.


Well, turns out the /a works fine, as long as a terminal window is open. If I close the terminal window I've started the app in, I no longer hear beeps.

So now I figure I might want to play a wave file instead of just a simple beep, and was wondering if anyone knew if there is an easy way to do so?

Thanks,

Dan...
 
 View user's profile Send private message  
Reply with quote Back to top
mario
Post subject:   PostPosted: Apr 18, 2007 - 09:23 PM
QNX Master


Joined: Sep 01, 2002
Posts: 2897

Tip of the day: puts() is MUCH faster then printf()
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
maschoen
Post subject:   PostPosted: Apr 18, 2007 - 09:32 PM
QNX Master


Joined: Jun 25, 2003
Posts: 1095

It's not printf that is the problem, but rather the behavior of stdout.
A friendly snipe at Mario: Do you think you will hear the beep faster if you send the "\a\n" via puts rather than printf, Wink.
 
 View user's profile Send private message Send e-mail Visit poster's website  
Reply with quote Back to top
dman3021
Post subject:   PostPosted: Apr 19, 2007 - 02:42 PM
Active Member


Joined: Feb 16, 2006
Posts: 23

fp = fopen( "/dev/con1", "w" );
if( fp != NULL ) {
putc('\a', fp);
putc('\n', fp);
fclose( fp );
}

So basically opening a stream to con1 and printing the beep character there works (as I've done with the above code).

Thanks for the push!

Dan...
 
 View user's profile Send private message  
Reply with quote Back to top
mario
Post subject:   PostPosted: Apr 19, 2007 - 03:44 PM
QNX Master


Joined: Sep 01, 2002
Posts: 2897

In that case you don't need the putc() because fclose will flush it for you.

Hey Mitch, lol! I jumped on the occasion to mention puts, because I recently wrote some benchmark program to evaluate performance of printf, sprintf, puts and their C++ counter part cout, strstream stringstream.

I was amazed to see that puts was almost 10 times faster then printf. That's understandable because puts doesn't have to parse the string to look for format (%...).

I was also surprised to see that cout was also faster the printf ( almost as fast a puts ) and for the same reason; no parsing. It however makes the code bigger, each value use in the cout expression results in a call.

strstream, stringstream also proved much faster then sprintf even if they perform memory allocation.
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2007 The PNphpBB Group
Credits
All logos and trademarks in this site are property of their respective owners. The comments are property of their posters.
Powered by OpenQNX: The QNX Community Portal Site
QNX and the QNX logo are registered trademarks of QNX Software Systems.