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 Python Example

Remote temperature data acquisition 

Publisher and Subscriber Hardware Diagram

import time
import os
import sys
na_python_dir = os.environ.get("NAWCTDIR") + "\\Python"

from NaException import NaException
from NA_Server import NA_Server
from NA_Credentials import NA_Credentials
from NA_Connection import NA_Connection
from NA_Subscription import NA_Subscription

def main(argv):

	server = NA_Server("netacquirehost")
	sub = NaServer.GetSubscription("reactor_temperature") 

	# can now access real-time decommutated data as a regular Python variable!
	print ("Temperature: " + sub)

if __name__ == "__main__":

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 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 obtained, the current value of the subscription can be displayed at any time as illustrated by the final print line.

When using the subscription object directly in an output stream as done here the implementation displays all the information associated with the subscription (name, type, raw value, timestamp, etc.). For more control over the display of the raw data 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.

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.


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.