NetAcquire Corporation Logo Image Image Image Image Image Image Image Image    
NetAcquire Corporation Logo Home Search Products News Services Careers Support Contact  

NetAcquire Publish/Subscribe C Example

Remote temperature data acquisition 

Publisher and Subscriber Hardware Diagram


 #include <stdio.h>
 #include "naps.h"
 int main(void)
 {
    NAPS_Connection netacquire1;
    NAPS_Subscription reactor_temperature;
    Real_64 temperature;

    netacquire1 = naps_open("na1");
    reactor_temperature = naps_subscribe(netacquire1, "reactor_temperature");
    naps_as_real64(reactor_temperature, &temperature);
    printf("Reactor temperature: %lf\n", temperature);
 
    naps_close(reactor_temperature);
    naps_close(netacquire1);
    return 0;
 }

The main function declares two variables to represent a data publisher and a specific data subscription, respectively. The first executable line opens a connection to the data publisher named "na1". The next line creates an object that represents a specific data subscription. Subscriptions can be given convenient names on the NetAcquire; in this case the subscription represents an analog voltage from a reactor temperature sensor. Once a subscription is created, the current value of the subscription can be displayed at any time, as illustrated by the printf statement.

In the example, the value of the subscription is retrieved using an accessor that returns a 64 bit real value. Accessors with different return types are also available, integers of width 8, 16, 32, and 64 bits, as well as 32 and 64 bit floating point types are supported. The application can also query the subscription for the most appropriate data type.

In addition to keeping subscriptions automatically up-to-date, NetAcquire Publish/Subscribe can also notify applications when the value of a subscription changes (see the C notification example).


Home | Search | Products | News | Services | Careers | Support | Contact | Telemetry | Range/Radar
Aerospace | Communication | Remote Monitoring | Industrial Automation | Extreme | Protocol Conversion
Simulation | Hardware Overview | Analog I/O | Digital I/O | GPIB/IEEE 488 | Digital Multimeter | FPGA
Source Selection
| High Availability | Software Overview | WWW | Storage | Publish/Subscribe
Java | Windows | Data Flow | Time | Extensions | Decom | CCSDS | Mux/Demux | Demos



Last modified 06/16/2006
Copyright © 1996 - 2006
NetAcquire Corporation
All rights reserved.
webmaster@netacquire.com