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


Scripting Guide > Extending JMP > Real-Time Data Capture on Windows > Manage a Data Feed with Messages
Publication date: 11/10/2021

Manage a Data Feed with Messages

A data feed object responds to several messages, including Connect and Set Script. These are detailed above as arguments for Open Datafeed(). They can also be sent as messages to a data feed object that already exists:

feed << Connect( port( "com1:" ), baud( 4800 ), databits( 7 ), parity( odd ), stopbits( 2 ) );
feed << Set Script( myScript );

The following messages could also be used as arguments to On Datafeed(). However, it would be more common to send them as messages to a data feed object that is already present.

You can send lines to a data feed from a script. This is a quick way to test a data feed. If you do not have a device available, Queue Line does not send data to a device; it simulates getting data from a device. Include a text argument or a global that stores text:

feed << Queue Line( "14" );
feed << Queue Line( myValue );

Here is a test script to queue five lines of data:

feed << Queue Line( "11" );
feed << Queue Line( "22" );
feed << Queue Line( "33" );
feed << Queue Line( "44" );
feed << Queue Line( "55" );

Figure 14.2 Datafeed: 5 Lines Queued 

Datafeed: 5 Lines Queued

To get the first line currently waiting in the queue, use a Get Line (singular) message. When you get a line, it is removed from the queue. Five lines were queued with the test script above, and Get Line returns the first line and removes it from the queue:

feed << Get Line

"11"

Figure 14.3 Datafeed: 4 Lines Queued 

Datafeed: 4 Lines Queued

To empty all lines from the queue into a list, use Get Lines (plural). This returns the next four lines from the test script in list { } format.

myList = feed << GetLines;

{ "22", "33", "44", "55" }

Figure 14.4 Datafeed: 0 Lines Queued 

Datafeed: 0 Lines Queued

To stop and later restart the processing of queued lines, either click the Stop and Restart buttons in the Datafeed window, or send the equivalent messages:

feed << Stop;
feed << Restart;

To close the data feed and its window:

feed << Close;

To disconnect from the live data source:

feed << Disconnect

Table 14.1 Datafeed Messages

Message

Syntax

Explanation

Open Datafeed

Datafeed

feed = Open Datafeed( commands )

Creates a data feed object. Any of the following can be used as commands inside Open Datafeed or sent as messages to an existing data feed object. Datafeed is a synonym.

Set Script

feed << Set Script( script )

Assigns the script that is run each time a line of data is received.

Get Line

feed << Get Line

Returns and removes one line from the data feed queue.

Get Lines

feed << Get Lines

Returns as a list and removes all lines from the data feed queue.

Queue Line

feed << Queue Line( string )

Sends one line to the end of the data feed queue.

Stop

feed << Stop

Stops processing queued lines.

Restart

feed << Restart

Restarts processing queued lines.

Close

feed << Close

Closes the data feed object and its window.

Connect

feed << Connect(

Port( "com1:" | "lpt1:" | ... ),

Baud( 9600 | 4800 | ... ),

Data Bits( 8 | 7 ),

Parity( None | Odd | Even ),

Stop Bits( 1 | 0 | 2 ),

DTR_DSR( 0 | 1 ),

RTS_CTS( 0 | 1 ),

XON_XOFF( 1 | 0 )

)

(Windows only) Sets up port settings for the connection to the device. The symbol | between arguments represents “or”; choose one argument for each setting.

Disconnect

feed << Disconnect

(Windows only) Disconnects the device from the data feed queue but leaves the data feed object active.

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