HOWTO-create-a-ProcessViewServer :


This HOWTO is obsolete. You can do everything using "pvbuilder" now. Only read on when you want more detailed info.


First you copy some files from the example to your directory.
These files are located at:
/usr/share/doc/packages/ProcessView/pvsdemo (SuSE Linux)
%doc/ProcessView/pvsdemo (other distributions)
.\ExampleServer (Windows)

Copy the following files to your directory:

copy main.cpp    your_dir/main.cpp
copy pvapp.h     your_dir/pvapp.h
copy pvsdemo.pro your_dir/your_server.pro (Linux/Unix)
copy pvsdemo.dsp your_dir/your_server.dsp (Windows)

Design the mask mymask:

Start Qt Designer with:
designer

Within designer choose the menu "Tools->Custom->Edit Custom Widgets ..."
You get a dialog. Within this dialog choose "Load Descriptions ..."
Then select the file designer.cw from your installation directory.
This makes the custom widgets available.

Now choose "New->Dialog" and set some objects you like in the dialog box.
When you are finished save the dialog as mymask.ui in your_dir.

On the commandline input the following commands:
cd your_dir
ui2pvc mymask.ui mymask.cpp

Edit the copied files to your needs:

pvapp.h should now look like this:
/***************************************************************************
                          pvapp.h  -  description
                             -------------------
    begin                : Sun Nov 12 2000
    copyright            : (C) 2000 by Rainer Lehrig
    email                : lehrig@t-online.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   I make one exception to the above statement:                          *
 *   You can use this software for commercial purposes                     *
 *   if you purchase a license                                             *
 *   You will not be allowed to make changes to the software               *
 *                                                                         *
 ***************************************************************************/
#ifndef _PVAPP_H_
#define _PVAPP_H_

#include "processviewserver.h"

int show_mymask(PARAM *p);

#endif

main.cpp should now look like this (There are only changes in pvMain):
/***************************************************************************
                          main.cpp  -  description
                             -------------------
    begin                : Son Nov 12 09:43:38 CET 2000
    copyright            : (C) 2000 by Rainer Lehrig
    email                : lehrig@t-online.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   I make one exception to the above statement:                          *
 *   You can use this software for commercial purposes                     *
 *   if you purchase a license                                             *
 *   You will not be allowed to make changes to the software               *
 *                                                                         *
 ***************************************************************************/
#include "pvapp.h"

int pvMain(PARAM *p)
{
int ret;

  pvResize(p,0,1280,1024);
  ret = 1;
  while(1)
  {
    switch(ret)
    {
      case 1:
        ret = show_mymask(p);
        break;
      default:
        return 0;
    }
  }
}

#ifdef USE_INETD
int main(int ac, char **av)
{
PARAM p;

  pvInit(ac,av,&p);
  /* here you may interpret ac,av and set p->user to your data */
  pvMain(&p);
  return 0;
}
#else  // multi threaded server
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);
    else        break;
  }
  return 0;
}
#endif

your_server.pro should now look like this (Linux/Unix):
######################################################################
# Rainer Lehrig                               Tue May 28 12:24:03 2002
######################################################################

TEMPLATE = app
CONFIG   = warn_on release

# Input
HEADERS += pvapp.h
SOURCES += main.cpp     \
           mymask.cpp
LIBS    += /usr/lib/libpvsmt.so /usr/lib/libpthread.so

After you have edited your_server.pro input the commands:
qmake your_server.pro -o Makefile
make

your_server.dsp (Windows) must be modified by deleting/adding files within your VisualC++ project.
Then you can build the server.

Testing your_server:

Start your_server.
Start ProcessViewBrowser.
You should see your_server.

Usage of your_server (Example) :

your_server -port=5050 -sleep=500 -cd=/working/directory

Use port = 5050
Cycle Time = 500 milliseconds
Working Directory = /working/directory

#define USE_INETD (Only Linux/Unix and OpenVMS)

You include the #define USE_INETD in pvapp.h
and change LIBS in your_server.pro to
LIBS += /usr/lib/libpvsid.so /usr/lib/libpthread.so
In order to use inetd.

Linux/Unix:

Your /etc/services should include:
your_server               5050/tcp        # ProcessViewServer your_server

Your /etc/inetd.conf should include:
your_server stream tcp nowait root /usr/sbin/tcpd /your/directory/your_server -sleep=200 -cd=/your/directory

OpenVMS:

$ type your_server_setup.com
$ ucx set service your_server /file=your_disk:[your.directory]your_server_startup.com -
                              /user=myself                                            -
                              /protocol=tcp                                           -
                              /port=5050                                              -
                              /process=your_server                                    -
                              /limit=100
$ ucx enable service your_server
$ ucx show service your_server /full

You can call your_server_setup.com from sys$manager:systartup_vms.com
$ type your_server_startup.com
$ set default your_disk:[your.directory]
$ your_server :== $ your_disk:[your.directory]your_server.exe
$ define/user_mode sys$output nla0:
$ your_server -sleep=200

Tips

Linux/Unix

Create a small shellscript pvdesign.sh looking like:
#!/bin/bash
designer $1.ui
ui2pvc $1.ui $1.cpp
make
And define an alias in your ~/.bashrc like:
alias pvdesign='~/shell/pvdesign.sh'
Then you can simply type:
pvdesign mymask
and everything will be updated automatically

With the following shellscript also lazy programmers can create a new ProcessViewServer
#!/bin/bash
#
# Create a new ProcessViewServer
#
cp /usr/share/doc/packages/ProcessView/pvsdemo/pvapp.h     .
cp /usr/share/doc/packages/ProcessView/pvsdemo/main.cpp    .
cp /usr/share/doc/packages/ProcessView/pvsdemo/pvsdemo.pro pvs.pro
kwrite pvapp.h
kwrite main.cpp
kwrite pvs.pro
qmake  pvs.pro -o Makefile

Now we will only have to define our masks with designer

Windows

Make pvdesigner.exe your default application when double clicking *.ui files.
pvdesigner will start Qt Designer. When you leave Qt Designer ui2pvc will be run automatically.