Main Page | Features | Central Services | csv-Files | Types | Transfer | Access | API-C | API-VB/ActiveX | API-Java | Examples | Downloads

NETMEX Server File Reference

TINE NETMEX server engine plus API routines. More...


Functions

int RegisterKeywordEx (char *keyword, char *description, short format, unsigned short size, short(*fcn)(float *, unsigned short, short))
 The extended version of RegisterKeyword(). Registers a Keyword with the TINE NETMEX engine.

int RegisterKeyword (char *keyword, short format, unsigned short size, short(*fcn)(float *, unsigned short, short))
 Registers a Keyword with the TINE NETMEX engine.

int RegisterKeywordDeviceName (char *keyword, char *devicename, int index)
 Registers a device name associated with the input Keyword.

void setKeywordRefreshRoutine (void(*fcn)(void), int rate)
 Registers a background refresh routine to be called at the interval given.

int initNetmexServer (void)
 Initializes the TINE NETMEX engine and starts the server.


Detailed Description

TINE NETMEX server engine plus API routines.


Function Documentation

int initNetmexServer void   ) 
 

Initializes the TINE NETMEX engine and starts the server.

This call should follow the call to SystemInit() inside the main() routine.

Returns:
none.
Example:

#include "prolog.h"
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/time.h>
#include "servdef.h"
#include "netmex.h"

int main(int argc, char *argv[])
{
  switch (argc)                           /* initial debug level */
  {                  /* on UNIX stations: set debug = 1 (2,or 3) */
    case 2:              /* will dynamically set the debug level */
      NGdebug = atoi(argv[1]);
      break;
    default:
      NGdebug = 0;                              /* default level */
  }
  if (SystemInit(FALSE)) { printf("RPC init error\n"); exit(1); }
  if (initNetmexServer()) { printf("Netmex init error\n"); exit(1); }
  printf("NEXTMEX server running (debug level %d)\n",NGdebug);
  for(;;)
  {
    SystemCycle(TRUE);
  }
  return 0;
}

int RegisterKeyword char *  keyword,
short  format,
unsigned short  size,
short(*  fcn)(float *, unsigned short, short)
 

Registers a Keyword with the TINE NETMEX engine.

This is analogous to RegisterProperty() in a pure TINE server interface. A server registers a Keyword, its size and data type, plus a background function to be called upon to update the data associated with the keyword.

Parameters:
keyword is the NETMEX keyword to be registered. Up to 32 characters are allowed, but it is preferable to stick to 16 or fewer.
format is the TINE data type of the keyword
size is the number of elements associated with the keyword (i.e. the 'array size').
fcn is the background function which refreshes the data associated with the keyword, to be called at regular intervals (see setKeywordRefreshRoutine()). This function must have the prototype fcn(float *data,unsigned short size,short index), which allows the keyword data set to be updated piecemeal, i.e. 'size' elements beginning at element number 'index' from the data object specified by 'data'. If this data object is not a 'float' it needs to be cast into the appropriate data set inside the refresh function.
Returns:
0 upon success, otherwise a TINE completion code.
See also:
RegisterKeywordEx, RegisterKeywordDeviceName.
Example:

short MyDataCpy(float *data,unsigned short size,short index)
{
  int i;
  double ts = getDataTimeStamp();
  setDataTimeStamp(ts);    /* set timestamp if you want to */
  for (i=0; i<size; i++) data[i] = myDataArray[(i+index) % MYDATASIZE];
  return 0;
}
int RegisterNetmexKeywords(void)
{
  int cc=0;
  int i;
  char devstr[17];
  
  if ((cc=RegisterKeyword("MYDATA",CF_FLOAT,100,MyDataCpy)) != 0) return 0;
  
  for (i=0; i<100; i++)
  {
    sprintf(devstr,"DEVICE%d",i);
    RegisterKeywordDeviceName("MYDATA",devstr,i);
  }

  setKeywordRefreshRoutine(fakeMyData,500);

  return cc;
}

int RegisterKeywordDeviceName char *  keyword,
char *  devicename,
int  index
 

Registers a device name associated with the input Keyword.

This is analogous to RegisterDeviceName() in a pure TINE server interface. A registered NETMEX Keyword might be an array of elements. The individual elements can of course be addressed individually by number, but it is 'polite' to associate the individual elements with device names where possible.

Parameters:
keyword is the associated NETMEX keyword.
devicename is the device name to be bound to the index given.
index is the array element to be bound to the input devicename. The index given must of course be smaller than the 'size' of the keyword, (counting from 0).
Returns:
0 upon success, otherwise a TINE completion code.
See also:
RegisterKeywordEx, RegisterKeyword.
Example:

int RegisterNetmexKeywords(void)
{
  int cc=0;
  int i;
  char devstr[17];
  
  if ((cc=RegisterKeyword("MYDATA",CF_FLOAT,100,MyDataCpy)) != 0) return 0;
  
  for (i=0; i<100; i++)
  {
    sprintf(devstr,"DEVICE%d",i);
    RegisterKeywordDeviceName("MYDATA",devstr,i);
  }

  setKeywordRefreshRoutine(fakeMyData,500);

  return cc;
}

int RegisterKeywordEx char *  keyword,
char *  description,
short  format,
unsigned short  size,
short(*  fcn)(float *, unsigned short, short)
 

The extended version of RegisterKeyword(). Registers a Keyword with the TINE NETMEX engine.

This is analogous to RegisterProperty() in a pure TINE server interface. A server registers a Keyword, its size and data type, plus a background function to be called upon to update the data associated with the keyword. This call differs from RegisterKeyword() in that it offers a 'decription' parameter allowing the caller to provide a description of the NETMEX keyword.

Parameters:
keyword is the NETMEX keyword to be registered. Up to 32 characters are allowed, but it is preferable to stick to 16 or fewer.
description is the description of the keyword.
format is the TINE data type of the keyword
size is the number of elements associated with the keyword (i.e. the 'array size').
fcn is the background function which refreshes the data associated with the keyword, to be called at regular intervals (see setKeywordRefreshRoutine()). This function must have the prototype fcn(float *data,unsigned short size,short index), which allows the keyword data set to be updated piecemeal, i.e. 'size' elements beginning at element number 'index' from the data object specified by 'data'. If this data object is not a 'float' it needs to be cast into the appropriate data set inside the refresh function.
Returns:
0 upon success, otherwise a TINE completion code.
See also:
RegisterKeyword, RegisterKeywordDeviceName.
Example:

short MyDataCpy(float *data,unsigned short size,short index)
{
  int i;
  double ts = getDataTimeStamp();
  setDataTimeStamp(ts);    /* set timestamp if you want to */
  for (i=0; i<size; i++) data[i] = myDataArray[(i+index) % MYDATASIZE];
  return 0;
}
int RegisterNetmexKeywords(void)
{
  int cc=0;
  int i;
  char devstr[17];
  
  if ((cc=RegisterKeywordEx("MYDATA","[0:100 bozos]Test data from test server",CF_FLOAT,100,MyDataCpy)) != 0) return 0;
  
  for (i=0; i<100; i++)
  {
    sprintf(devstr,"DEVICE%d",i);
    RegisterKeywordDeviceName("MYDATA",devstr,i);
  }

  setKeywordRefreshRoutine(fakeMyData,500);

  return cc;
}

void setKeywordRefreshRoutine void(*  fcn)(void),
int  rate
 

Registers a background refresh routine to be called at the interval given.

This call will intruct the TINE NETMEX engine to call the routine provided at the refresh rate interval provided. This routine should be regarded as a timer whose trigger should update the NETMEX keywords exported from the server.

Parameters:
fcn is the background refresh routine to be called. It must have the prototype void fcn(void) and will be called by the TINE engine at the rate specified.
rate is the polling interval in milliseconds for which the background refresh routine will be called.
Returns:
none.
Example:

short MyDataCpy(float *data,unsigned short size,short index)
{
  int i;
  double ts = getDataTimeStamp();
  setDataTimeStamp(ts);    /* set timestamp if you want to */
  for (i=0; i<size; i++) data[i] = myDataArray[(i+index) % MYDATASIZE];
  return 0;
}
int RegisterNetmexKeywords(void)
{
  int cc=0;
  int i;
  char devstr[17];
  
  if ((cc=RegisterKeyword("MYDATA",CF_FLOAT,100,MyDataCpy)) != 0) return 0;
  
  for (i=0; i<100; i++)
  {
    sprintf(devstr,"DEVICE%d",i);
    RegisterKeywordDeviceName("MYDATA",devstr,i);
  }

  setKeywordRefreshRoutine(fakeMyData,500);

  return cc;
}


Generated on Sun Mar 21 14:20:45 2004 for NETMEX API by doxygen 1.3.2