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# .NET Example

Remote temperature data acquisition 

Publisher and Subscriber Hardware Diagram


using System;
using netacquire.ClientToolkit.NAPS;
using netacquire.ClientToolkit;

namespace SubscribeSimpleExample
{
	class Example
	{
	static void Main(string[] args)
		{
			NAServer server = NAServer.GetServer("netacquirehost");
			Subscription subscription = server.GetSubscription("reactor_temperature");
			Console.WriteLine(subscription.Value);
		}
	}
}

This fully functional example illustrates a complete application requiring only three lines of publish/subscribe executable code.

The first line of the main program creates an object that represents a NetAcquire server. The second line retrieves an object that represents a specific data subscription. Subscriptions can be given convenient names on the NetAcquire server. 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 final call to Console.WriteLine.

When inserting a subscription object directly into an output stream as done here, the implementation formats the value using the most suitable type for the published quantity. For more control over the data type one can retrieve the subscription's value using an explicit accessor. Integers of width 8, 16, 32, and 64 bits as well as 32 and 64-bit floating-point types are supported.

Notice that there is no "clean-up" code at the end of this example; NetAcquire Publish/Subscribe automatically handles all memory and buffer deallocation and network shutdown.

The above example illustrates that NetAcquire Publish/Subscribe automatically keeps the value of the variable reactor_temperature up-to-date without any coding on the application's part.

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 | Avionics
Aerospace Test | Communication | Remote Monitoring | Industrial Automation | Extreme | Protocol Conversion
Simulation | Hardware Overview | Analog I/O | Digital I/O | GPIB/IEEE 488 | SpaceWire | FPGA
Source Selection
| High Availability | Software Overview | WWW | Storage | Publish/Subscribe
Java | Windows | Data Flow | Time | Extensions | Decom | CCSDS | Mux/Demux | Demos



Last modified 12/2/2016
Copyright 1996 - 2016
NetAcquire Corporation
All rights reserved.
webmaster@netacquire.com