Skip navigation.
Home
The QNX Community Portal

View topic - Commands not going in order

Commands not going in order

Isn't the name clear?

Commands not going in order

Postby perezj » Wed Jun 23, 2010 12:33 am

I am not sure if this is a photon/PhAB problem or if it is a C problem to be honest. I have a function wait(n) where n is the number of seconds it should idle. The context is I hit a button, it says "Testing..." for the duration, then hides the Testing label after the n seconds. My problem is that even though I put the PtRealizeWidget() before wait(5), during runtime, it will wait the full time, then realize the widget after the time has elapsed. Here is the wait function and the way it is set up in my program.

void wait(int seconds)
{
clock_t endwait;
endwait = clock() + seconds * CLOCKS_PER_SEC;
while(clock() < endwait) {}
}

...
{
...
PtRealizeWidget(ABW_testing);
wait(5)
PtUnrealizeWidget(ABW_testing);
..
}

If I take out the unrealize function, it will realize after the waiting, but I cannot get it to realize before. Any suggestions as too why this would be?
perezj
Active Member
 
Posts: 11
Joined: Tue Jun 15, 2010 4:16 pm

RE: Commands not going in order

Postby ianc » Wed Jun 23, 2010 1:17 am

This won't work because you are not returning to the photon processing loop.
You can call PtFlush after PtRealizeWidget for immediate processing.

It seems to me you need to re-read the photon architecture and programming guides.
Good luck.
ianc
Active Member
 
Posts: 80
Joined: Wed Jan 22, 2003 6:04 am
Location: Bendigo, Australia

RE: Commands not going in order

Postby perezj » Wed Jun 23, 2010 5:48 pm

That did it, thanks. Another issue I just ran into is that when I call PtSetResources, to change the time remaining in a label, I call:
PtSetResource(ABW_time_remaining, Pt_TEXT_STRING, num, 0);
Where num is a string with the number in it. My problem is that when I compile, it says that PtSetResource was not prototyped and errors out, but I made sure (and PhAB did it for me) to include Pt.h. Is there something more that has to be done? I've gone through the programmer's guide and function library and cannot figure this out. Thanks.

Edit: I was able to get resources set by using SetArg and SetResources, not sure why SetResource doesn't work still.
perezj
Active Member
 
Posts: 11
Joined: Tue Jun 15, 2010 4:16 pm

RE: Commands not going in order

Postby perezj » Wed Jun 23, 2010 10:50 pm

Ok that worked fine for having a timer when nothing is happening in the background, but now I need an abort button to quit it early in the case that the user wants to. Like you said, it's not in the photon main loop, so is there a way to continue allowing photon to run while waiting for real time to pass to do something (like update the timer)?

Edit:
PtBkgdHandlerProcess() will allow photon to continue working. In my base, I put it into the empty while loop, works perfectly.
perezj
Active Member
 
Posts: 11
Joined: Tue Jun 15, 2010 4:16 pm

RE: Commands not going in order

Postby ianc » Wed Jun 23, 2010 11:15 pm

PtSetResources not PtSetResource

PtSetResources has only three arguments i.e PtSetResources(widget, numargs, argarray)

you set up the args with PtSetArg and then callPtSetResources to set those args

e.g

PtArg_t arg;
char *num;

setup num then

PtSetArg (&arg, Pt_ARG_STRING_TEXT, &num, 0);
PtSetResources(widget, 1, &arg);

like I said before, it's all in the programmers guide.
I think the section is called "Manipulating Resources In Application Code".
ianc
Active Member
 
Posts: 80
Joined: Wed Jan 22, 2003 6:04 am
Location: Bendigo, Australia

RE: Commands not going in order

Postby perezj » Thu Jun 24, 2010 12:15 am

Well if you look a bit further in that chapter, it does address PtSetResource, singular. Maybe it's a newer version and I have an old one. I don't know. Either way, thanks for helpin' out. Much appreciated.
perezj
Active Member
 
Posts: 11
Joined: Tue Jun 15, 2010 4:16 pm


Return to GUI Programming

Who is online

Users browsing this forum: No registered users and 3 guests

cron