feed = Open Datafeed( );
myScript = Expr(
line = feed << Get Line;
If( Length( line ) >= 14,
x = Num( Substr( line, 11, 3 ) );
If( !Is Missing( x ),
dt << Add Row( {thickness = x} )
);
);
);
feed << Set Script( myScript );
dt = New Table( "Gap Width" ); // make a data table with one column
dc = dt << New Column( "gap", Numeric, Best );
// set up control chart properties
dt << Set Property(
"Control Limits",
{XBar( Avg( 20 ), LCL( 19.8 ), UCL( 20.2 ) )}
);
dt << Set Property( "Sigma", 0.1 );
// make the data feed
feed = Open Datafeed();
feedScript = Expr(
line = feed << Get Line;
z = Num( line );
Show( line, z ); // if logging or debugging
If( !Is Missing( z ),
dt << Add Row( {:gap = z} )
);
);
feed << Set Script( feedScript );
// start the control chart
Control Chart(
Sample Size( 5 ),
K Sigma( 3 ),
Chart Col(
gap,
XBar(
Connect Points( 1 ),
Show Points( 1 ),
Show Center Line( 1 ),
Show Control Limits( 1 )
),
R(
Connect Points( 1 ),
Show Points( 1 ),
Show Center Line( 1 ),
Show Control Limits( 1 )
)
)
);
/* Either start the feed from the device or test-feed some data
to see it work (comment out one of the lines):
feed << Connect( Port( "com1:" ), Baud( 9600 ) );*/
For( i = 1, i < 20, i++,
feed << Queue Line( Char( 20 + Random Uniform() * .1 ) )
);
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.
Open Data Feed Data Feed |
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. Data Feed 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 |
|
Get Lines |
feed << Get Lines |
|
Queue Line |
feed << Queue Line( string ) |
|
Stop |
feed << Stop |
|
Restart |
feed << Restart |
|
Close |
feed << Close |
|
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 ) ) |
|
Disconnect |
feed << Disconnect |