Previously, Francesco Jatta wrote in qdn.public.qnx4.photon:
sorry for the silly question(s), but I cannot get out of it!
I am writing a simple application that just displays
data gathered (via shared memory) from another process.
I use PtText to display data and PtTextModifyText inside an infinite
loop to modify the text itself.
The question is: where do I put the function call?
If I attach a callback to the window opening, data will never be
displayed, the only chance seems to have a custom mainloop instead of
the PtMainloop() provided by photon, but this is unreccomended in the
manuals.
Two choices pop to mind:
- Create an Idle function with PtAppAddWorkProc, and put your PtText
update in there. It will consume a lot of CPU, and is generally
not a good thing to do. PtAppAddWorkProc is meant for temporary
CPU-intensive activities.
- Create a proxy, and attach a callback to it using PtAppAddInput.
Whenever your other program puts new data into shared memory, have
it Trigger() the proxy. Your Photon app must tell the data
acquisition app which proxy to Trigger. Put your PtText update in
the callback you attach with PtAppAddInput.
Solution 2 is infinitely better than solution 1 in my opinion, as it
uses only enough CPU to update the screen when necessary, and the
latency between data acquisition and display is minimized.
And also if a give a .cpp extension to a function callback a get weird
messages at compile time. Where am I wrong?
It’s not a C++ file. It’s a C file and wants a C extension. You
might be able to compile with C++ if you liberally sprinkle
extern “C”
throughout your code.
Cheers,
Andrew