Help! Question About PtTrend

Hi. I’m a beginner in QNX. I met a problem in using PtTrend widget in PhAB.
I want to it draw the trends graduately, but it draws it altogther.
The source code (for a button arm event)is list below.



#define Pi 3.14159265

/* ABW_trd_scope is a pointer to a PtTrend widget /
/
this widget has been set to show 3 trends */

int add( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo ){
int i,j;
static int isarm=0;
unsigned int step;
double error1, error2, error3;

widget = widget, apinfo = apinfo, cbinfo = cbinfo;

if(isarm==0){ /* the button has not been armed /
srand((int)time(NULL));
pbuff=(short )malloc(60sizeof(short));
ptestbuf=(short )malloc(20sizeof(short));
step=0;
for(i=0;i<200;i++){
/
generate the data for drawing /
for(j=0;j<20;j++){
error1=0.875+(rand()&0xff)/1024.0;
pbuff[j]=(short)(error1
150sin(0.01Pistep));
error2=1;
pbuff[20+j]=(short)(error2
120sin(0.01Pistep+0.25Pi));
error3=0.75+(rand()&0x7f)/256.0;
pbuff[40+j]=(short)(error380.0sin(0.01Pistep+0.5*Pi));
step++;
}

/* draw the data /
PtSetResource(ABW_trd_scope,Pt_ARG_TREND_DATA,pbuff,60);
/**************************************************/
/
I think it shall draw the data at this place /
/
just after setting the Pt_ARG_TREND_DATA resource /
/
for each i, I think it shall draw a part of trend /
/
but in fact, it does not draw the data until all the loop has
ended /
/
it means that, after about 200s, it draws these trends all at
once /
/
can someone tell me how to solve this problem */
/**************************************************/

sleep(1);
}
isarm=1;
free(pbuff);
}
return (Pt_CONTINUE);


}