RPC and redrawing a window (long)



Hello All,
I hope someone can help me with this. Unfortunately it requires some
knowledge of rpcs, I think
(if you don't know what that is, you can probably forget the rest of this
message =) ).

I have a GUI application that is supposed to talk to another computer over a
network, using rpcs. While the connection is being created, a message is
supposed to be displayed in my drawing area that lets the user know that the
program is attempting to set up a connection. This worked fine under Motif:

if( (tval.tv_sec % Lc.interval) == 0)
{
    collecting_data_msg();        /*this is supposed to print the message.
See code below.*/

    /* get sample from temperature controller */
    if( (rc=rpc_temper_get_values( Lc.hostname, 0, &sam )) != ERR_NONE )
    {
        XmtCliPrintf(  Cli_w, "rpc_temper_get_values(): ERROR %s",
Error_string[abs(rc)]);
        return;
    }
    /* record ems of communication */
    Lc.rpc_ems = elapse_ms( &tval );

    blah blah
}


void collecting_data_msg( void )
{
    Widget widget = Status_w;
    Display *dpy  = XtDisplay( widget );
    Window window = XtWindow( widget );

    Dimension da_wid, da_hgt;

    int x, y, l,
    char_wid, char_hgt;
    char *c;

    char_wid = Nor_font_wid;
    char_hgt = Nor_font_hgt;

    XtVaGetValues( widget, XmNwidth,   &da_wid, XmNheight,  &da_hgt, NULL);

    c = " Collecting Data, Please Wait ";
    l = strlen( c );
    y = da_hgt - (2*char_hgt);
    x = (da_wid - (l*char_wid))/2;
    XSetForeground( dpy, Nor_gc, CM_color[CM_YELLOW]);
    XSetBackground( dpy, Nor_gc, CM_color[CM_RED]);
    XDrawImageString( dpy, window, Nor_gc, x, y, c, l);

    XSetBackground( dpy, Nor_gc, CM_color[CM_BLACK]);
    XFlush(dpy);
}


Okay, so when I rewrote these functions under GTK, my collecting_data_msg
looks like this:


void collecting_data_msg( )
{
    int x, y, l,
   char_wid, char_hgt,
   da_wid, da_hgt;
   char *c;

   gdk_window_get_size( Status_w->window, &da_wid, &da_hgt);

   char_wid = Fixed_font_wid;
   char_hgt = Fixed_font_hgt;

   c = " Collecting Data, Please Wait ";
   l = strlen( c );
   y = da_hgt - (2*char_hgt);
   x = (da_wid - (l*char_wid))/2;
   gdk_gc_set_foreground( Nor_gc, &CM.colors[CM_RED] );
   gdk_draw_rectangle( Status_w->window, Nor_gc, TRUE, x, y-(char_hgt-3),
l*char_wid, char_hgt );
   gdk_gc_set_foreground( Nor_gc, &CM.colors[CM_YELLOW] );
   gdk_draw_text( Status_w->window, Fixed_font, Nor_gc, x, y, c, l );
   printf( "collecting_data_msg: %s\n", c );

}


the function call is:


 if( (tval.tv_sec % Lc.interval) == 0)
 {
    Lc.collect = 1;
    collecting_data_msg( );
    printf( "TIMER_FUNCTION: if( (tval.tv_sec mod Lc.interval) == 0)\n" );

    /* get sample from temperature controller */
    if( (rc=rpc_temper_get_values( Lc.hostname, 0, &sam )) != ERR_NONE )
    {
        printTextOut( "rpc_temper_get_values():\n ERROR %s",
Error_string[abs(rc)] );
        return 0;
    }
    /* record ems of communication */
    Lc.rpc_ems = elapse_ms( &tval );

    blah blah
}

The strange part is that the printf statement in the collecting_data_msg
function is printed, but the string is not printed on the drawing area
widget until the rpc stuff times out. I'm afraid I don't know a lot about
RPCs, but as far as I can tell, the actually rpc calls are working fine.

Thank you so much if you can help,

Miranda


/------------------------------------------------------------------------\
| Miranda Hawarden-Ogata             Email: hawarden@irtf.ifa.hawaii.edu |
| NASA IRTF, Institute of Astronomy  Phone: (808) 974-4206               |
| 1175 Manono St., Bldg 393            Fax: (808) 974-4207               |
| Hilo, HI 96720                                                         |
\------------------------------------------------------------------------/




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