I again modified the example code of BatchIndividualRangeChart.cs:
-------------------------------------------
public void InitializeChart()
{
........
this.EnableScrollBar = true;
//################################################
SPCControlLimitRecord secondaryuppercontrollimit = ChartData.GetControlLimitRecord(SPCControlChartData.SPC_SECONDARY_LOWER_CONTROL_LIMIT);
secondaryuppercontrollimit.ControlLimitType = SPCControlLimitRecord.SPC_NOTA_LIMIT;
//################################################
SimulateData2();
// Calculate the SPC control limits for both graphs of the current SPC chart (X-Bar R)
this.AutoCalculateControlLimits();
//############### code inserted for getting the alarm trap #####################
this.ResetSPCChartData();
this.ChartData.AlarmStateEventHandler += new SPCControlLimitAlarmEventDelegate(this.AlarmEvent);
this.ChartData.AlarmStateEventEnable = true;
SimulateData2();
//############### code inserted for getting the alarm trap #####################
// Scale the y-axis of the X-Bar chart to display all data and control limits
this.AutoScalePrimaryChartYRange();
// Scale the y-axis of the Range chart to display all data and control limits
this.AutoScaleSecondaryChartYRange();
// Rebuild the chart using the current data and settings
this.RebuildChartUsingCurrentData();
}
-------------------------------------------------
private void SimulateData2()
{
double[] data = new double[]{
45.27,44.67,45.67,44.07,41.67,43.27,45.47,44.47,46.27,45.67,43.87,45.47,
45.07,45.47,43.67,43.87,43.67,44.87,43.27,43.27,41.27,44.27,45.27,48.08,
47.48,46.27,48.48,46.87,46.27,46.27,46.27,45.87,46.07,43.47,46.87,45.47,
};
for (int i = 0; i < data.Length; i++)
{
ChartCalendar timestamp = new ChartCalendar(DateTime.Now);
DoubleArray samples = new DoubleArray(new double[] { data[i] });
this.ChartData.AddNewSampleRecord(timestamp, samples);
//alarm event raised after AddNewSampleRecord,remove the alarmed records from chart
if (this.alarms.Contains(i))
{
//remove the record in alarm status
this.ChartData.DeleteSampleRecord();
}
}
}
private ArrayList alarms = new ArrayList();
private void AlarmEvent(object sender, SPCControlLimitAlarmArgs e)
{
SPCControlLimitRecord alarm = e.EventAlarm;
if (alarm.AlarmState == false)
{
return;
}
SPCControlChartData spcData = alarm.SPCProcessVar;
int id = spcData.CurrentNumberRecords;
alarms.Add(id);
}
Now,the chart raised some incorrect alarms even if the points are between UCL and LCL,is it a bug?