14.03.2014 Views

Scripting Guide - SAS

Scripting Guide - SAS

Scripting Guide - SAS

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

470 Extending JMP Chapter 14<br />

Real-Time Data Capture<br />

feed = Open Datafeed(<br />

Connect(<br />

Port( "com1:" | "com2:" | "lpt1:" | ... ),<br />

Baud( 9600 | 4800 | ... ),<br />

Data Bits( 8 | 7 ),<br />

Parity( None | Odd | Even ),<br />

Stop Bits( 1 | 0 | 2 ),<br />

DTR_DSR( 0 | 1 ), // Data Terminal Ready<br />

RTS_CTS( 0 | 1 ), // Request To Send | Clear To Send<br />

XON_XOFF( 1 | 0 ) // Transmitter On | Transmitter Off<br />

)<br />

);<br />

This command creates a scriptable data feed object and stores a reference to it in the global variable feed.<br />

The Connect argument starts up a thread to watch a communications port and collect lines. The thread<br />

collects characters until it has a line, and then appends it to the line queue and schedules an event to call the<br />

script.<br />

Note: For Datafeed purposes, a line of data is a single value (a datum). A line is not to<br />

be confused with a data table row, which can contain values for many variables on a<br />

subject.<br />

Set Script attaches a script to the Datafeed object. This script is triggered by the On DataFeed handler<br />

whenever a line of data arrives. The argument for Set Script is simply the script to run, or a global<br />

containing a script.<br />

feed = Open Datafeed( set script( myScript ) );<br />

feed = Open Datafeed( set script( Print( feed

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!