Initialisation and global routines


Functions

int glencode_set_param (PARAM *p)
int pvsystem (const char *command)
int pvXYAllocate (PARAM *p, int n)
int pvSetXY (PARAM *p, int i, float x, float y)
int pvInitInternal (PARAM *p)
int pvInit (int ac, char **av, PARAM *p)
int pvAccept (PARAM *p)
int pvCreateThread (PARAM *p, int s)
int pvGetInitialMask (PARAM *p)
int pvMain (PARAM *p)
int pvSetCleanup (PARAM *p, int(*cleanup)(void *), void *app_data)
char * pvGetEvent (PARAM *p)
int pvPollEvent (PARAM *p, char *event)
int pvWait (PARAM *p, const char *pattern)
int pvGlUpdate (PARAM *p, int id)
int pvSleep (int milliseconds)
int pvWarning (PARAM *p, const char *text)
int pvMainFatal (PARAM *p, const char *text)
int pvThreadFatal (PARAM *p, const char *text)
int pvScreenHint (PARAM *p, int w, int h)

Detailed Description

These routines are used for initialisation. And also some global usable routines are available.

Function Documentation

int glencode_set_param PARAM p  ) 
 

int pvAccept PARAM p  ) 
 

see pvInit

int pvCreateThread PARAM p,
int  s
 

see pvInit

char* pvGetEvent PARAM p  ) 
 

If it is necessary to cleanup your application when the main worker thread terminates
you can set an exit handler that receives the data in app_data.
Call this function in pvMain. See also pvMain.

int pvGetInitialMask PARAM p  ) 
 

Get the initial mask the user wants to see
p->initial_mask is a string identifying the initial mask 

int pvGlUpdate PARAM p,
int  id
 

update OpenGL widget

int pvInit int  ac,
char **  av,
PARAM p
 

(Test) pvInit must be called in main(). It interprets the command line switches that it knows.
Afterwards you can interpret your command line switches. It is possible to set p.user to data
of your choice. This data will be available in the worker threads. (Caution: the worker threads are
only allowed to read the p.user data because it is shared among all clients)
Then there must be a while(1) in which new clients are accepted. For each client a new thread
is created.

 int main(int ac, char **av)
 {
 PARAM p;
 int   s;

   pvInit(ac,av,&p);
here you may interpret ac,av and set p.user to your data
   while(1)
   {
     s = pvAccept(&p);
     if(s != -1) pvCreateThread(&p,s);
   }
   return 0;
 }

int pvInitInternal PARAM p  ) 
 

see pvInit
Init for script languages

int pvMain PARAM p  ) 
 

pvMain is your main worker thread. It could look as follows.
The main worker thread is never closed. It will be closed automatically when the client disconnects.

int pvMain(PARAM *p)
{
int ret;

here you can initialize your worker thread
  pvSetCleanup(p,your_exit_handler,your_app_data); // if cleanup is necessary
  pvResize(p,0,970,600);  // this will resize your working area
  ret = showMask1(p);
  while(1)
  {
    switch(ret)
    {
      case 1:
        ret = showMask1(p);
        break;
      case 2:
        ret = showMask2(p);
        break;
      case 3:
        ret = showMask3(p);
        break;
      default:
        return 0;
    }
  }
}

int pvMainFatal PARAM p,
const char *  text
 

Output a fatal message and terminate the whole server.

int pvPollEvent PARAM p,
char *  event
 

This function will return the next event as soon as it is available.
The maximum wait time is p->sleep in milliseconds (default 100).
You can specify a different wait time on the commandline (-sleep=1000)

Example:

 int showMask1(PARAM *p)
 {
 DATA d;
 char event[MAX_EVENT_LENGTH];
 int  i;
 char text[MAX_EVENT_LENGTH];

   defineMask1(p);
   readData1(&d); // from shared memory or out of database
   showData1(p,&d);
   while(1)
   {
     pvPollEvent(p,event);
     switch(pvParseEvent(event, &i, text))
     {
       case NULL_EVENT:
         readData1(&d); // from shared memory or out of database
         showData1(p,&d);
         break;
       case BUTTON_EVENT:
         ...
         break;
       case TEXT_EVENT:
         ...
         break;
       default:
         printf("UNKNOWN_EVENT id=\%d \%s\\n",i,text);
         break;
     }
   }
 }

int pvScreenHint PARAM p,
int  w,
int  h
 

Output a screenHint for calculating the zoom factor
Optimal screen width=w height=h .

int pvSetCleanup PARAM p,
int(*)(void *)  cleanup,
void *  app_data
 

If it is necessary to cleanup your application when the main worker thread terminates
you can set an exit handler that receives the data in app_data.
Call this function in pvMain. See also pvMain.

int pvSetXY PARAM p,
int  i,
float  x,
float  y
 

Set x,y array for script language

int pvSleep int  milliseconds  ) 
 

Sleep for milliseconds.

int pvsystem const char *  command  ) 
 

Same as system(command); but portable

int pvThreadFatal PARAM p,
const char *  text
 

Output a fatal message and terminate the worker thread.

int pvWait PARAM p,
const char *  pattern
 

waits for an event.

int pvWarning PARAM p,
const char *  text
 

Output a warning message.

int pvXYAllocate PARAM p,
int  n
 

Allocate x,y array for script language


Generated on Mon Jun 5 08:33:36 2006 for ProcessViewBrowser-ServerProgramming by  doxygen 1.4.6