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. | |
|
|
Initializes the TINE NETMEX engine and starts the server. This call should follow the call to SystemInit() inside the main() routine.
#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; } |
|
||||||||||||||||||||
|
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.
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; } |
|
||||||||||||||||
|
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.
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; } |
|
||||||||||||||||||||||||
|
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.
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; } |
|
||||||||||||
|
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.
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; } |
1.3.2