For the latest version of JMP Help, visit JMP.com/help.


Publication date: 11/10/2021

Create a Data Feed Object

To create a data feed object, use the Open Datafeed() function with arguments specifying details about the connection:

feed = Open Datafeed( options );

No arguments are required. You can simply create the data feed object and then send messages to it. Messages might include connecting to a port or setting up a script to process the data coming in. However, you would typically set up the basic operation of the data feed in the Open Datafeed() function and subsequently send messages as needed to manage the data feed. Any of the options below work both as options inside Open Datafeed() or as messages sent to a data feed object.

It’s a good idea to store a reference to the object in a global variable, such as feed above, so that you can easily send messages to the object. You can store a reference to an existing object by using a subscript; for example, to store a reference to the second data feed created:

feed2 = Datafeed[2];

Data Feed Options

To connect to a live data source, use Connect( ) and specify details for the port. Each setting takes only one argument; in this syntax summary the symbol | between argument choices means “or.” The Port specification is needed if you want to connect, otherwise the object still works, but is not connected to a data feed. The last three items, DTR_DSR, RTS_CTS, and XON_XOFF, are Boolean to specify which control characters are sent back and forth to indicate when the data feed is ready to get data. Typically, you would turn on at most one of them.

feed = Open Datafeed(
	Connect(
		Port( "com1:" | "com2:" | "lpt1:" | ... ),
		Baud( 9600 | 4800 | ... ),
		Data Bits( 8 | 7 ),
		Parity( None | Odd | Even ),
		Stop Bits( 1 | 0 | 2 ),
		DTR_DSR( 0 | 1 ), // Data Terminal Ready
		RTS_CTS( 0 | 1 ), // Request To Send | Clear To Send
		XON_XOFF( 1 | 0 ) // Transmitter On | Transmitter Off
	)
);

This command creates a scriptable data feed object and stores a reference to it in the global variable feed. The Connect() argument starts up a thread to watch a communications port and collect lines. The thread collects characters until it has a line, and then appends it to the line queue and schedules an event to call the script.

Note: A line of data from the feed might generate multiple rows in a data table or might be a fraction of one row. You provide JSL to parse the data lines and to add rows to a data table as needed.

Set Script() attaches a script to the data feed object. This script is triggered by the Open Datafeed message whenever a line of data arrives. The argument for Set Script() is simply the script to run, or a global containing a script.

feed = Open Datafeed( Set Script( myScript ) );
feed = Open Datafeed( Set Script( Print( feed << Get Line ) ) );

A data feed script typically uses Get Line to get a copy of one line and then does something with that line. Often it parses the line for data and adds it to some data table.

Want more information? Have questions? Get answers in the JMP User Community (community.jmp.com).