cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
New to using JMP? Hit the ground running with the Early User Edition of Discovery Summit. Register now, free of charge.
Register for our Discovery Summit 2024 conference, Oct. 21-24, where you’ll learn, connect, and be inspired.
Choose Language Hide Translation Bar
BrianK
Level I

Alarm Script not writing to a file.

Hi there,

 

I'm struggling with an alarm script, like in the below. This CuSum chart is generating 7 alarms, and therefore should be generating the log file, however it is not, or not every time the script is run, which is strange. Any ideas on what's going on? I'm using version 17.2 pro. 

 

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Quality Control/Oil1 Cusum.jmp" );
obj = dt << CUSUM Control Chart(
Y( :weight ),
H( 2 ),
Lower Side( 1 ),
Target( 8.1 ),
K( 0.025 ),
Sigma( 0.02 ),
Head Start( 0.05 ),
Alarm Script(
contents = Substitute( "^QCTEST in column ^QCCOL in sample ^QCSAMPLE.",
"^QCTEST", Choose( qc_test,
"One point beyond the control limits" ),
"^QCCOL", qc_col,
"^QCSAMPLE", char( qc_sample ));
filename = Convert File Path("$TEMP/test log.txt", absolute);
if (File Exists( filename ), Save Text File( filename, contents, Mode("Append") ), Save Text File( filename, contents) );
),
);
// Turn on Test 1
obj << Test 1(1);

5 REPLIES 5
txnelson
Super User

Re: Alarm Script not writing to a file.

I am not a control chart expert, however, I was able to trigger the writing of the file by adding 

Test beyond limits( 1 )

to the CUSUM Control Chart specification

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Quality Control/Oil1 Cusum.jmp" );
obj = dt << CUSUM Control Chart(
	Y( :weight ),
	H( 2 ),
	Lower Side( 1 ),
	Target( 8.1 ),
	K( 0.025 ),
	Sigma( 0.02 ),
	Head Start( 0.05 ),
	Test beyond limits( 1 ),
	Alarm Script(
		contents = Substitute( "^QCTEST in column ^QCCOL in sample ^QCSAMPLE.",
			"^QCTEST", Choose( qc_test, "One point beyond the control limits" ),
			"^QCCOL", qc_col,
			"^QCSAMPLE", Char( qc_sample )
		);
		filename = Convert File Path( "$TEMP/test log.txt", absolute );
		If( File Exists( filename ),
			Save Text File( filename, contents, Mode( "Append" ) ),
			Save Text File( filename, contents )
		);
	),

);
// Turn on Test 1
obj << Test 1( 1 );

txnelson_0-1725791859342.png

P.S.  Please use the JSL icon at the top of the preview page when adding your JMP code.  It provides a display of your JSL that is much easier to read and understand.

Jim
BrianK
Level I

Re: Alarm Script not writing to a file.

Hi Jim,

 

Thanks for that.  But its not quite what I was looking for. In the control chart as per below, there are 7 points on which a shift is detected, as indicated by the vertical lines below. Screenshot 2024-09-08 162150.png

I was then expecting my code below to populate the ReportOut Datatable, with 7 rows of data, with the alarm script running once for each shift detected. 

Names Default To Here( 1 );

ReportOutDataTable = New Table( "ReportOut",
//Add Rows(1),
New Column( "Name",
Character,
"Nominal",
)
);
dt = Open( "$SAMPLE_DATA/Quality Control/Oil1 Cusum.jmp" );
ReportOUtDataTable = Data Table("ReportOut");
obj = dt << CUSUM Control Chart(
	Y( :weight ),
	H( 2 ),
	Lower Side( 1 ),
	Target( 8.1 ),
	K( 0.025 ),
	Sigma( 0.02 ),
	Head Start( 0.05 ),
	//Test beyond limits( 1 ),
Alarm Script(
	ReportOutDataTable<<Add Rows({:Name="test1"}); 					
	),
);

However looks like the alarm script wont run at all, unless Test beyond limits (1) is used. This then results in all points out of control in the chart being circled (71 in my example) , and therefore 71 rows of data being added to my ReportOut Data table.

 

Ultimately, I want  the alarm script to run only when a shift is detected, and then output information on the shift to a ReportOut Data table, with information like the Sample Number on which the shift was detected. Maybe I'm misunderstanding how the Alarm script is indented to function?

jthi
Super User

Re: Alarm Script not writing to a file.

Maybe shift "test" isn't considered an alarm so it won't trigger the alarm script.

-Jarmo
BrianK
Level I

Re: Alarm Script not writing to a file.

possibly, but would seem strange, given the purpose of a CuSum graph is to detect a shift in data, and this is indicated in Jmp with the vertical purple lines as per above.  Its on a shift in data a user would want the alarm script to run.

jthi
Super User

Re: Alarm Script not writing to a file.

Might be so but currently it seems that it only triggers on alarms, not on shift change. Maybe create a wish list item in hopes to get a support for "shift change script" or something similar? Currently you can get those into a separate table and trigger your own actions based on the table

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Quality Control/Oil1 Cusum.jmp");
obj = dt << CUSUM Control Chart(
	Y(:weight),
	H(2),
	Lower Side(1),
	Target(8.1),
	K(0.025),
	Sigma(0.05),
	Head Start(0.05)
);
dt_summary = obj << Save Summaries;

r = dt_summary << Get Rows Where(Is Missing(:Shift Start));
dt_summary << Delete Rows(r)
-Jarmo