A Datafeed Window Shows the Status and Offers Controls
To create a DataFeed object, use the Open DataFeed command with arguments specifying details about the connection:
No arguments are required. You can simply create the Datafeed 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 command 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 Datafeed 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:
(Windows only) 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 Datafeed is ready to get data. Typically, you would turn on at most one of them.
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.
Set Script attaches a script to the Datafeed object. This script is triggered by the On DataFeed handler whenever a line of data arrives. The argument for Set Script is simply the script to run, or a global containing a script.
A Datafeed 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.
The term live data feed describes the way an external data source sends information via a physical or a logical communication link to another device. You can connect JMP to a live data feed through the serial port of your Windows computer to read a stream of incoming data in real time. Remember the following:
Once you obtain the numbers for your device, enter them into the Open Datafeed() command in the script below. (The 4800, even, 2, and 7 in the script below are examples, so replace them with your information). Then connect the data feed to your computer and open and run the script:
To ensure harmony between the communications settings for JMP and the instrument reading data from an external source, select File > Preferences > Communications. Refer to the documentation for your instrument to find the appropriate settings.
A Datafeed 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 Datafeed object that already exists:
The following messages could also be used as arguments to On Data Feed. However, it would be more common to send them as messages to a Datafeed object that is already present.
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:
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.
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:
You can further automate the production setting by placing a Datafeed script such as the one above in an On Open data table property. A property with this name is run automatically each time the table is opened (unless you set a preference to suppress execution). If you save such a data table as a Template, opening the template runs the Datafeed script and saves data to a new data table file.
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. Data Feed is a synonym.
Assigns the script that is run each time a line of data is received.