Here is from when the time column was created in a data table to the calling of show()
Column( SqlQry1, "DateTime" ) << data type( "Numeric" );
SqlQry1 << New Column( "Time", formula( Round( :DateTime, 0 ) ) );
Column( SqlQry1, "Time" ) << Format( "m/d/y h:m:s" ) << delete formula;
//Column( SqlQry1, "Time") << Modeling Type( "Nominal");
SqlQry1 << delete column( "DateTime" );
dt0 = SqlQry1 << split( split by( :TagName ), Split( :vValue ), group( :Time ) );
Close( SqlQry1, no save );
//move everything that's not a mass/position to the beginning such that we can stack all the other columns at the end.
dt0 << Move Selected Columns(
{"Data", "Data", "Data",
"Data", "Data", "Data",
"Data", "Data"},
after( "Time" )
);
//duplicate columns so we can downfill some without modifying the originals. since we dont have roll begin/end markers we may need the originals
dt0 << New Column( "Part Number",
after( :Time ),
"character",
"nominal",
formula( :Data )
) << MoveSelectedColumns( {:Part Number}, After( :Data ) );
dt0:Part Number << delete formula;
dt0 << New Column( "Lot Number", "character", "nominal", formula( :Data ) ) <<
MoveSelectedColumns( {:Lot Number}, After( :Data ) );
dt0:Lot Number << delete formula;
dt0 << New Column( "Split",
after( :Data ),
"Numeric",
"nominal",
formula( :Data )
) << MoveSelectedColumns( {:Split}, After( :Data ) );
dt0:Split << delete formula;
//This down fills the part number tag so that it can be associated with each roll
For( i = 1, i <= N Rows( dt0 ), i++,
/*If( Is Missing( :Part Number[i] ),
:Part Number[i] = Part Number[i - 1]);*/
Try(
If( Is Missing( :Lot Number[i] ),
:Lot Number[i] = Lot Number[i - 1]
);
If( Is Missing( :Part Number[i] ),
:Part Number[i] = Part Number[i - 1]
);
If( Is Missing( :Split[i] ),
:Split[i] = Split[i - 1]
);
)
);
//This makes all the mass, position columns numeric but not the part/lot # ones
For( i = 9, i <= N Col(), i++,
Column( i ) << data type( numeric ) << modeling type( "Continuous" )
);
//assign each mass point a CW position
For( i = 0, i < 512, i++,
x = "Position Lane " || Char( i );
dt0 << New Column( x,
formula( :Data+ (:Data) * (i + 1) )
);
Column( dt0, x ) << delete formula;
);
//form a list of all the mass and position columns without having to use 1000 lines of code
col_list = dt0 << get column names( string );
For( i = N Items( col_list ), i > 0, i--,
If(
(!Contains( col_list[i], "Data" )) & (!
Contains( col_list[i], "Position Lane" )),
Remove From( col_list, i )
)
);
//Stack the mass and position columns
dt1 = dt0 << Stack(
columns( col_list ),
Source Label Column( "Label" ),
Stacked Data Column( "Data" ),
Number of Series( 2 ),
Contiguous
);
Close( dt0, no save );
//renames the appropriate columns as mass / positions
:Data << Set Name( "Mass (g/m2)" );
:Data 2 << Set Name( "Position (cm)" );
dt1 << delete column( "Label" );
dt1 << delete column( "Label 2" );
dt1 << New Script(
"CW Graph",
Graph Builder(
Size( 522, 571 ),
Show Control Panel( 0 ),
Variables( X( :Name( "Position (cm)" ) ), Y( :Name( "Data" ) ) ),
Elements( Smoother( X, Y, Legend( 6 ) ) ),
Local Data Filter(
Add Filter(
columns( :Lot Number ),
Display( :Lot Number, Size( 178, 276 ), Height( 276 ) )
)
)
)
);
dt1 << set name( "Data" );
dt1 << Delete Table Property( "Source" );
dt1 << Delete Table Property( "Update from DB" );
dt1 << Delete Table Property( "Save To DB" );
dt1 << New Column( "Lanes",
numeric,
continuous,
formula( 10 + 10 * Floor( (:Name( "Position (cm)" ) - 10) / 10 ) )
);
Column( dt1, "Mach.StartLength" ) << set name( "Start Length" );
//Deleting empty Lane rows
dt1 << Select Where( Is Missing( :Name( "Lanes" ) ) ) << Delete Rows;
//Variables for the Summary Stats
pNumLot = {:Part Number, :Lot Number};
Summarize(
pNum = By( :Part Number ),
//lNum = By( :Lot Number ), //this needs to be added
//pLNum = By( Eval( pNumLot ) ),
minL = Min( :Start Length ),
maxL = Max( :Start Length ),
massM = Mean( :Name( "Mass (g/m2)" ) ),
sDevM = Std Dev( :Name( "Mass (g/m2)" ) ),
minT = Min( :Time ),
maxT = Max( :Time )
);
Show( Format( minT, "m/d/y h:m:s" ), Format( maxT, "m/d/y h:m:s" ) );
Daryl Hurwitz