GTK and devices over TCP and serial ports



Hi

Lately I became a user of GTK 
and I do not have problem with GTK GUI, libraries or whatever
I think it is great. and Puxbif is quite good - either for animations I
think - however I am not the expert. 

But .... Yeah alway those but 

I need now to write and GUI/Application (in GTK) which will connect to 
Pan Tilt Unit (PTU) and camera which is mounted on top of PTU. 
OK the problem is that the GUI need to show the image from the camera
(data comes through TCP/IP) and abibilty to control/monitor the PTU (it
means I need to read position of the PTU - two angles and to be able to
send a command to the PTU to move camera in other direction)

OK. Now how you think what is better - which solution

1.  
  Write the GTK windows and ect. 
  
  Write in main.c
  {
    g_thread_init(NULL);
    gdk_threads_init(); 

 ....
   // to read position of PTU - inside thread is a loop which runs in
max 200ms
   if (!g_thread_create(readPTU_thread, mData, FALSE, &error)) {
    g_printerr ("Failed to create readPTU thread: %s\n",
error->message);
    return 1;
  }

   // to read camera RGB - inside loop thread is a loop which runs in
max 200ms
   if (!g_thread_create(readCamera_thread, mData, FALSE, &error)) {
    g_printerr ("Failed to create readCamera thread: %s\n",
error->message);
    return 1;
  }

  gdk_threads_enter();  
  gtk_main();
  gdk_threads_leave(); 

 }

  and to control the PTU by callbacks from GTK Window


2. 
  Write the GTK windows and ect. 
  
  Write in main.c instead of g_thread_create and all those thread stuff
 to use gtk_timeout_add(200ms, 
		    (GtkFunction)readPTU_thread,NULL) ;
  
 
 Or even there is maybe a better alternative.

Because the first one - I have implemented it and it doesnt work well.
I have checked how much I need to spend  time to recieve data from PTU 
and it is only 150ms  but the thread is running - I mean the loop is
running every 1940ms - just example. Why it is so slow? Do I do
something wrong? The use of g_timeout will make better peformance. 

Hmm and I am affraid that I will have many camera/PTU in this
application. 

Can somebody give me ideas how to solve it in nice way ? 
How to read those PTUs and Cameras in let say every 200-300 ms and show
the data in GTK windows? 

Zbigniew Wasik
PS. BTW what you think what is better to use Pixbuff or GdkRGB  to show
images in GTK ? (and have ability to resize it if possible)

 






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]