Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/utilities/d/ds.html on line 1

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/utilities/d/ds.html on line 1

Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/utilities/d/ds.html on line 8

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/utilities/d/ds.html on line 8

ds

Data server that maintains a shared state among processes

Syntax:

ds &

Runs on:

Neutrino

Options:

None.

Description:

The data server is a process that maintains a shared state among other processes — it's like a global environment. Processes can store or retrieve data using a set of data server library calls. You can use it for many tasks, but specifically you can access it from the Slinger webserver in support of dynamic HTML. The HTTP server slinger makes use of the data server and the data server library.

Data is stored using variable names that represent buffers of data. All of the variables are global, any process can access them (no attempt is made to restrict access), so only one instance of the variable (name) can exist in the data server.

Data server library

The data server library consists of these functions, which are described in the Library Reference:

ds_register()
Register your application with the data server.
ds_deregister()
Deregister your application with the data server.
ds_create()
Create a data server variable.
ds_clear()
Delete a data server variable.
ds_set()
Set a data server variable.
ds_get()
Get a data server variable.
ds_flags()
Set the flags for a data server variable.

Examples:

Here's a simple (and nonfunctional) example of monitoring the temperature of an oven from a remote client:


Note: This example uses HTML as the interface to the data server, but the data server isn't limited to HTML.

Here's what the qnxvar tokens on the client's web page look like:

<!--Show the current oven temperature-->
<!--#qnxvar format="<P>The oven temperature is %s degrees F." -->
<!--#qnxvar read="oven1 5" -->

If the temperature of the oven is currently 500 degrees F, the output looks like:

<P>The oven temperature is 500 degrees F.

Here's what the application monitoring the oven looks like:

// This program obtains the temperature of an oven, and
// then updates a data variable in the data server, to
// be read by slinger if the appropriate token is in an
// html page slinger is serving. 

#include <stdlib.h>
#include <stdio.h>
#include <ds.h>
#include <string.h>

#define MAXLEN 4

int main(void)
{
  ds_t ds_descriptor;
  char ovenID[7], oven_temp[MAXLEN], flag=0;
  int length = MAXLEN;

  ds_descriptor = ds_register();
  if(ds_descriptor==-1){
    perror("ds_register");
    exit(1);
  }
  
  strcpy(ovenID,"oven1");

  if(ds_create(ds_descriptor, ovenID, flag, 0)==-1){
    perror("ds_create");
    exit(1);
  } 
  
  // Obtain the an initial temperature for the oven
  // to initialize the data server variable. strcpy
  // that value into oven_temp 
    
  ds_set(ds_descriptor,ovenID,oven_temp,length);
 
  //Now let's update the temperature at some time interval

  while(1)
  //you might want some kind of decision to exit the program. 
  {
    
     //obtain the current temperature from the oven

     //strcpy that temp reading into the oven_temp variable

     ds_set(ds_descriptor,ovenID,oven_temp,length);

     //wait a predetermined amount of time
 
   } 

   ds_clear(ds_descriptor,ovenID);
   ds_deregister(ds_descriptor);

}

The output HTML page reflects the current temperature stored in the data server.

When this process exits, the data server variable is no longer available because the flag argument passed to ds_create() was 0.

If this application needs some data passed from HTML text, another variable is created by calling ds_create() and is used to pass information to it by using the qnxvar write token in some HTML text. The application gets the data by calling ds_get() and/or react to the change in data by receiving a proxy or signal.

Here's what's happening:


Oven example


Monitoring an oven via the data server.

In summary:

For information about the qnxvar token, see slinger.

See also:

slinger

ds_clear(), ds_create(), ds_deregister(), ds_flags(), ds_get(), ds_register(), ds_set() in the Library Reference

Setting Up an Embedded Web Server in the Neutrino User's Guide


Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/utilities/d/ds.html on line 285

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/utilities/d/ds.html on line 285