LazStats: Implement individuals xbar chart in XBarChartUnit. Add variable-selection buttons to SPC forms like in most other forms. Fix TabOrder in all SPC forms.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7663 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2020-09-12 16:28:22 +00:00
parent e13d7e6e25
commit f3a750effb
13 changed files with 619 additions and 280 deletions

View File

@ -31,7 +31,7 @@ object BasicSPCForm: TBasicSPCForm
BevelOuter = bvNone BevelOuter = bvNone
ClientHeight = 42 ClientHeight = 42
ClientWidth = 357 ClientWidth = 357
TabOrder = 0 TabOrder = 3
object CloseBtn: TButton object CloseBtn: TButton
AnchorSideTop.Control = ButtonPanel AnchorSideTop.Control = ButtonPanel
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
@ -48,7 +48,7 @@ object BasicSPCForm: TBasicSPCForm
Caption = 'Close' Caption = 'Close'
ModalResult = 11 ModalResult = 11
OnClick = CloseBtnClick OnClick = CloseBtnClick
TabOrder = 0 TabOrder = 3
end end
object ComputeBtn: TButton object ComputeBtn: TButton
AnchorSideTop.Control = ButtonPanel AnchorSideTop.Control = ButtonPanel
@ -63,7 +63,7 @@ object BasicSPCForm: TBasicSPCForm
BorderSpacing.Around = 8 BorderSpacing.Around = 8
Caption = 'Compute' Caption = 'Compute'
OnClick = ComputeBtnClick OnClick = ComputeBtnClick
TabOrder = 1 TabOrder = 2
end end
object ResetBtn: TButton object ResetBtn: TButton
AnchorSideTop.Control = ButtonPanel AnchorSideTop.Control = ButtonPanel
@ -78,7 +78,7 @@ object BasicSPCForm: TBasicSPCForm
BorderSpacing.Around = 8 BorderSpacing.Around = 8
Caption = 'Reset' Caption = 'Reset'
OnClick = ResetBtnClick OnClick = ResetBtnClick
TabOrder = 2 TabOrder = 1
end end
object HelpBtn: TButton object HelpBtn: TButton
AnchorSideTop.Control = ButtonPanel AnchorSideTop.Control = ButtonPanel
@ -92,7 +92,7 @@ object BasicSPCForm: TBasicSPCForm
BorderSpacing.Around = 8 BorderSpacing.Around = 8
Caption = 'Help' Caption = 'Help'
OnClick = HelpBtnClick OnClick = HelpBtnClick
TabOrder = 3 TabOrder = 0
end end
object Bevel1: TBevel object Bevel1: TBevel
AnchorSideLeft.Control = ButtonPanel AnchorSideLeft.Control = ButtonPanel
@ -124,13 +124,12 @@ object BasicSPCForm: TBasicSPCForm
AnchorSideLeft.Control = SpecsPanel AnchorSideLeft.Control = SpecsPanel
AnchorSideTop.Control = VarListLabel AnchorSideTop.Control = VarListLabel
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Bevel2 AnchorSideRight.Control = MeasInBtn
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ButtonPanel AnchorSideBottom.Control = ButtonPanel
Left = 8 Left = 8
Height = 363 Height = 363
Top = 25 Top = 25
Width = 174 Width = 150
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8 BorderSpacing.Left = 8
BorderSpacing.Top = 2 BorderSpacing.Top = 2
@ -138,32 +137,33 @@ object BasicSPCForm: TBasicSPCForm
BorderSpacing.Bottom = 8 BorderSpacing.Bottom = 8
ItemHeight = 0 ItemHeight = 0
OnClick = VarListClick OnClick = VarListClick
TabOrder = 1 TabOrder = 0
end end
object GroupLabel: TLabel object GroupLabel: TLabel
AnchorSideLeft.Control = VarList AnchorSideLeft.Control = GroupEdit
AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = GroupInBtn
AnchorSideTop.Control = VarListLabel Left = 198
Left = 190
Height = 15 Height = 15
Top = 8 Top = 93
Width = 105 Width = 105
BorderSpacing.Top = 2
BorderSpacing.Bottom = 2 BorderSpacing.Bottom = 2
Caption = 'Group (Lot) Variable' Caption = 'Group (Lot) Variable'
ParentColor = False ParentColor = False
end end
object GroupEdit: TEdit object GroupEdit: TEdit
AnchorSideLeft.Control = VarList AnchorSideLeft.Control = GroupInBtn
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = GroupLabel AnchorSideTop.Control = GroupLabel
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = SpecsPanel AnchorSideRight.Control = SpecsPanel
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 190 Left = 198
Height = 23 Height = 23
Top = 25 Top = 110
Width = 167 Width = 159
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 8
BorderSpacing.Top = 2 BorderSpacing.Top = 2
BorderSpacing.Bottom = 8 BorderSpacing.Bottom = 8
ReadOnly = True ReadOnly = True
@ -171,34 +171,34 @@ object BasicSPCForm: TBasicSPCForm
Text = 'GroupEdit' Text = 'GroupEdit'
end end
object MeasLabel: TLabel object MeasLabel: TLabel
AnchorSideLeft.Control = VarList AnchorSideLeft.Control = MeasEdit
AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = MeasInBtn
AnchorSideTop.Control = GroupEdit Left = 198
AnchorSideTop.Side = asrBottom
Left = 190
Height = 15 Height = 15
Top = 56 Top = 27
Width = 117 Width = 117
BorderSpacing.Top = 2
BorderSpacing.Bottom = 2 BorderSpacing.Bottom = 2
Caption = 'Measurement Variable' Caption = 'Measurement Variable'
ParentColor = False ParentColor = False
end end
object MeasEdit: TEdit object MeasEdit: TEdit
AnchorSideLeft.Control = VarList AnchorSideLeft.Control = MeasInBtn
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = MeasLabel AnchorSideTop.Control = MeasLabel
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = SpecsPanel AnchorSideRight.Control = SpecsPanel
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 190 Left = 198
Height = 23 Height = 23
Top = 73 Top = 44
Width = 167 Width = 159
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 8
BorderSpacing.Top = 2 BorderSpacing.Top = 2
BorderSpacing.Bottom = 8 BorderSpacing.Bottom = 8
ReadOnly = True ReadOnly = True
TabOrder = 3 TabOrder = 1
Text = 'MeasEdit' Text = 'MeasEdit'
end end
object Bevel2: TBevel object Bevel2: TBevel
@ -210,6 +210,60 @@ object BasicSPCForm: TBasicSPCForm
Width = 23 Width = 23
Shape = bsSpacer Shape = bsSpacer
end end
object MeasInBtn: TSpeedButton
AnchorSideLeft.Control = SpecsPanel
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = VarList
Left = 166
Height = 24
Top = 25
Width = 24
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = MeasInBtnClick
end
object MeasOutBtn: TSpeedButton
AnchorSideLeft.Control = SpecsPanel
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = MeasInBtn
AnchorSideTop.Side = asrBottom
Left = 167
Height = 22
Top = 53
Width = 23
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = MeasOutBtnClick
end
object GroupInBtn: TSpeedButton
AnchorSideLeft.Control = SpecsPanel
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = MeasOutBtn
AnchorSideTop.Side = asrBottom
Left = 166
Height = 24
Top = 91
Width = 24
BorderSpacing.Top = 16
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = GroupInBtnClick
end
object GroupOutBtn: TSpeedButton
AnchorSideLeft.Control = SpecsPanel
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = GroupInBtn
AnchorSideTop.Side = asrBottom
Left = 167
Height = 22
Top = 119
Width = 23
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = GroupOutBtnClick
end
end end
object SpecsSplitter: TSplitter object SpecsSplitter: TSplitter
Left = 360 Left = 360
@ -218,7 +272,7 @@ object BasicSPCForm: TBasicSPCForm
Width = 5 Width = 5
ResizeStyle = rsPattern ResizeStyle = rsPattern
end end
object PageControl1: TPageControl object PageControl: TPageControl
Left = 368 Left = 368
Height = 426 Height = 426
Top = 6 Top = 6
@ -262,7 +316,7 @@ object BasicSPCForm: TBasicSPCForm
TabOrder = 0 TabOrder = 0
end end
end end
object ToolBar2: TToolBar object ReportToolBar: TToolBar
Left = 0 Left = 0
Height = 22 Height = 22
Top = 6 Top = 6
@ -271,7 +325,7 @@ object BasicSPCForm: TBasicSPCForm
BorderSpacing.Top = 6 BorderSpacing.Top = 6
BorderSpacing.Right = 4 BorderSpacing.Right = 4
BorderSpacing.Bottom = 6 BorderSpacing.Bottom = 6
Caption = 'ToolBar2' Caption = 'ReportToolBar'
EdgeBorders = [] EdgeBorders = []
Images = MainDataModule.ImageList Images = MainDataModule.ImageList
TabOrder = 1 TabOrder = 1
@ -306,7 +360,7 @@ object BasicSPCForm: TBasicSPCForm
Caption = 'Chart' Caption = 'Chart'
ClientHeight = 398 ClientHeight = 398
ClientWidth = 545 ClientWidth = 545
object ToolBar1: TToolBar object ChartToolBar: TToolBar
Left = 0 Left = 0
Height = 22 Height = 22
Top = 6 Top = 6
@ -315,7 +369,7 @@ object BasicSPCForm: TBasicSPCForm
BorderSpacing.Top = 6 BorderSpacing.Top = 6
BorderSpacing.Right = 4 BorderSpacing.Right = 4
BorderSpacing.Bottom = 6 BorderSpacing.Bottom = 6
Caption = 'ToolBar1' Caption = 'ChartToolBar'
EdgeBorders = [] EdgeBorders = []
Images = MainDataModule.ImageList Images = MainDataModule.ImageList
TabOrder = 0 TabOrder = 0

View File

@ -6,7 +6,7 @@ interface
uses uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls,
StdCtrls, ComCtrls, PrintersDlgs, StdCtrls, ComCtrls, Buttons, PrintersDlgs,
Globals, MainUnit, ContextHelpUnit, ChartFrameUnit; Globals, MainUnit, ContextHelpUnit, ChartFrameUnit;
type type
@ -23,7 +23,7 @@ type
MeasEdit: TEdit; MeasEdit: TEdit;
PrintDialog: TPrintDialog; PrintDialog: TPrintDialog;
ReportMemo: TMemo; ReportMemo: TMemo;
PageControl1: TPageControl; PageControl: TPageControl;
Panel1: TPanel; Panel1: TPanel;
ResetBtn: TButton; ResetBtn: TButton;
ComputeBtn: TButton; ComputeBtn: TButton;
@ -34,12 +34,16 @@ type
SpecsSplitter: TSplitter; SpecsSplitter: TSplitter;
ReportPage: TTabSheet; ReportPage: TTabSheet;
ChartPage: TTabSheet; ChartPage: TTabSheet;
MeasInBtn: TSpeedButton;
MeasOutBtn: TSpeedButton;
GroupInBtn: TSpeedButton;
GroupOutBtn: TSpeedButton;
tbPrintChart: TToolButton; tbPrintChart: TToolButton;
tbPrintReport: TToolButton; tbPrintReport: TToolButton;
tbSaveChart: TToolButton; tbSaveChart: TToolButton;
tbSaveReport: TToolButton; tbSaveReport: TToolButton;
ToolBar1: TToolBar; ChartToolBar: TToolBar;
ToolBar2: TToolBar; ReportToolBar: TToolBar;
tbCopyReport: TToolButton; tbCopyReport: TToolButton;
tbCopyChart: TToolButton; tbCopyChart: TToolButton;
VarList: TListBox; VarList: TListBox;
@ -49,7 +53,11 @@ type
procedure FormActivate(Sender: TObject); procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject); procedure FormShow(Sender: TObject);
procedure GroupInBtnClick(Sender: TObject);
procedure GroupOutBtnClick(Sender: TObject);
procedure HelpBtnClick(Sender: TObject); procedure HelpBtnClick(Sender: TObject);
procedure MeasInBtnClick(Sender: TObject);
procedure MeasOutBtnClick(Sender: TObject);
procedure ResetBtnClick(Sender: TObject); procedure ResetBtnClick(Sender: TObject);
procedure tbCopyChartClick(Sender: TObject); procedure tbCopyChartClick(Sender: TObject);
procedure tbCopyReportClick(Sender: TObject); procedure tbCopyReportClick(Sender: TObject);
@ -59,11 +67,13 @@ type
procedure tbSaveReportClick(Sender: TObject); procedure tbSaveReportClick(Sender: TObject);
procedure VarListClick(Sender: TObject); procedure VarListClick(Sender: TObject);
private private
FNoGroupsAllowed: Boolean;
protected protected
FPrintY: Integer; FPrintY: Integer;
GrpVar: Integer; GrpVar: Integer;
MeasVar: Integer; MeasVar: Integer;
procedure Compute; virtual;
function GetGroups: StrDyneVec; function GetGroups: StrDyneVec;
function GetFileName: String; function GetFileName: String;
procedure PlotMeans(ATitle, AXTitle, AYTitle, ADataTitle, AGrandMeanTitle: String; procedure PlotMeans(ATitle, AXTitle, AYTitle, ADataTitle, AGrandMeanTitle: String;
@ -71,17 +81,37 @@ type
UCL, LCL, GrandMean, TargetSpec, LowerSpec, UpperSpec: double); virtual; UCL, LCL, GrandMean, TargetSpec, LowerSpec, UpperSpec: double); virtual;
procedure PrintText; virtual; procedure PrintText; virtual;
procedure Reset; virtual; procedure Reset; virtual;
procedure Compute; virtual; procedure UpdateBtnStates; virtual;
function Validate(out AMsg: String; out AControl: TWinControl): Boolean; virtual; function Validate(out AMsg: String; out AControl: TWinControl): Boolean; virtual;
public public
FChartFrame: TChartFrame; FChartFrame: TChartFrame;
property NoGroupsAllowed: Boolean read FNoGroupsAllowed write FNoGroupsAllowed;
end; end;
var var
BasicSPCForm: TBasicSPCForm; BasicSPCForm: TBasicSPCForm;
// Constants for correction of standard deviation, needed by some charts.
const
C4: array[1..24] of double = (
0.7979, 0.8862, 0.9213, 0.9400, 0.9515, 0.9594, 0.9650, 0.9693,
0.9727, 0.9754, 0.9776, 0.9794, 0.9810, 0.9823, 0.9835, 0.9845, 0.9854, 0.9862,
0.9869, 0.9876, 0.9882, 0.9887, 0.9892, 0.9896);
D3: array[1..24] of double = (
0, 0, 0, 0, 0, 0.076, 0.136, 0.184, 0.223, 0.256, 0.283, 0.307, 0.328,
0.347, 0.363, 0.378, 0.391, 0.403, 0.415, 0.425, 0.434, 0.443,
0.451, 0.459
);
D4: array[1..24] of double = (
3.267, 2.574, 2.282, 2.114, 2.004, 1.924, 1.864, 1.816, 1.777,
1.744, 1.717, 1.693, 1.672, 1.653, 1.637, 1.622, 1.608, 1.597,
1.585, 1.575, 1.566, 1.557, 1.548, 1.541
);
implementation implementation
{$R *.lfm} {$R *.lfm}
@ -109,6 +139,7 @@ end;
procedure TBasicSPCForm.Compute; procedure TBasicSPCForm.Compute;
begin begin
//
end; end;
@ -133,7 +164,7 @@ begin
if GroupEdit.Visible and (cellstring = GroupEdit.Text) then GrpVar := i; if GroupEdit.Visible and (cellstring = GroupEdit.Text) then GrpVar := i;
if MeasEdit.Visible and (cellstring = MeasEdit.Text) then MeasVar := i; if MeasEdit.Visible and (cellstring = MeasEdit.Text) then MeasVar := i;
end; end;
if GroupEdit.Visible and (GrpVar = -1) then if not NoGroupsAllowed and GroupEdit.Visible and (GrpVar = -1) then
begin begin
GroupEdit.SetFocus; GroupEdit.SetFocus;
ErrorMsg('Group variable not found.'); ErrorMsg('Group variable not found.');
@ -147,6 +178,8 @@ begin
end; end;
Compute; Compute;
UpdateBtnStates;
end; end;
procedure TBasicSPCForm.FormActivate(Sender: TObject); procedure TBasicSPCForm.FormActivate(Sender: TObject);
@ -225,6 +258,31 @@ begin
end; end;
procedure TBasicSPCForm.GroupInBtnClick(Sender: TObject);
var
index: integer;
begin
index := VarList.ItemIndex;
if (index > -1) and (GroupEdit.Text = '') then
begin
GroupEdit.Text := VarList.Items[index];
VarList.Items.Delete(index);
UpdateBtnStates;
end;
end;
procedure TBasicSPCForm.GroupOutBtnClick(Sender: TObject);
begin
if GroupEdit.Text <> '' then
begin
VarList.Items.Add(GroupEdit.Text);
GroupEdit.Text := '';
UpdateBtnStates;
end;
end;
procedure TBasicSPCForm.HelpBtnClick(Sender: TObject); procedure TBasicSPCForm.HelpBtnClick(Sender: TObject);
begin begin
if ContextHelpForm = nil then if ContextHelpForm = nil then
@ -233,6 +291,31 @@ begin
end; end;
procedure TBasicSPCForm.MeasInBtnClick(Sender: TObject);
var
index: integer;
begin
index := VarList.ItemIndex;
if (index > -1) and (MeasEdit.Text = '') then
begin
MeasEdit.Text := VarList.Items[index];
VarList.Items.Delete(index);
UpdateBtnStates;
end;
end;
procedure TBasicSPCForm.MeasOutBtnClick(Sender: TObject);
begin
if MeasEdit.Text <> '' then
begin
VarList.Items.Add(MeasEdit.Text);
MeasEdit.Text := '';
UpdateBtnStates;
end;
end;
procedure TBasicSPCForm.PlotMeans(ATitle, AXTitle, AYTitle, ADataTitle, AGrandMeanTitle: String; procedure TBasicSPCForm.PlotMeans(ATitle, AXTitle, AYTitle, ADataTitle, AGrandMeanTitle: String;
const Groups: StrDyneVec; const Means: DblDyneVec; const Groups: StrDyneVec; const Means: DblDyneVec;
UCL, LCL, GrandMean, TargetSpec, LowerSpec, UpperSpec: double); UCL, LCL, GrandMean, TargetSpec, LowerSpec, UpperSpec: double);
@ -368,6 +451,7 @@ begin
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]); VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
FChartFrame.Clear; FChartFrame.Clear;
(FChartFrame.Chart.AxisList[2].Marks.Source as TListChartSource).Clear; (FChartFrame.Chart.AxisList[2].Marks.Source as TListChartSource).Clear;
UpdateBtnStates;
end; end;
@ -376,6 +460,7 @@ begin
Reset; Reset;
end; end;
procedure TBasicSPCForm.tbCopyChartClick(Sender: TObject); procedure TBasicSPCForm.tbCopyChartClick(Sender: TObject);
begin begin
FChartFrame.Chart.CopyToClipboardBitmap; FChartFrame.Chart.CopyToClipboardBitmap;
@ -429,6 +514,23 @@ begin
end; end;
procedure TBasicSPCForm.UpdateBtnStates;
begin
MeasInBtn.Enabled := (VarList.ItemIndex <> -1) and (MeasEdit.Text = '');
MeasOutBtn.Enabled := (MeasEdit.Text <> '');
GroupInBtn.Enabled := (VarList.ItemIndex <> -1) and (GroupEdit.Text = '');
GroupOutBtn.Enabled := (GroupEdit.Text <> '');
tbSaveReport.Enabled := ReportMemo.Lines.Count > 0;
tbPrintReport.Enabled := ReportMemo.Lines.Count > 0;
tbCopyReport.Enabled := ReportMemo.Lines.Count > 0;
tbSaveChart.Enabled := FChartFrame.Chart.SeriesCount > 0;
tbPrintChart.Enabled := FChartFrame.Chart.SeriesCount > 0;
tbCopyChart.Enabled := FChartFrame.Chart.SeriesCount > 0;
end;
function TBasicSPCForm.Validate(out AMsg: String; out AControl: TWinControl): Boolean; function TBasicSPCForm.Validate(out AMsg: String; out AControl: TWinControl): Boolean;
var var
x: Double; x: Double;
@ -450,9 +552,11 @@ end;
procedure TBasicSPCForm.VarListClick(Sender: TObject); procedure TBasicSPCForm.VarListClick(Sender: TObject);
var //var
index: integer; // index: integer;
begin begin
UpdateBtnStates;
{
index := VarList.ItemIndex; index := VarList.ItemIndex;
if index > -1 then if index > -1 then
begin begin
@ -462,6 +566,7 @@ begin
MeasEdit.Text := VarList.Items[index]; MeasEdit.Text := VarList.Items[index];
VarList.Items.Delete(index); VarList.Items.Delete(index);
end; end;
}
end; end;
end. end.

View File

@ -14,6 +14,7 @@ inherited CChartForm: TCChartForm
Top = 378 Top = 378
Width = 440 Width = 440
ClientWidth = 440 ClientWidth = 440
TabOrder = 4
inherited CloseBtn: TButton inherited CloseBtn: TButton
Left = 385 Left = 385
end end
@ -32,42 +33,62 @@ inherited CChartForm: TCChartForm
end end
inherited VarList: TListBox inherited VarList: TListBox
Height = 345 Height = 345
Width = 216 Width = 192
end end
inherited GroupLabel: TLabel inherited GroupLabel: TLabel
Left = 232 Left = 240
Top = 274
Visible = False Visible = False
end end
inherited GroupEdit: TEdit inherited GroupEdit: TEdit
Left = 232 Left = 240
Width = 208 Top = 291
Width = 200
TabOrder = 3
Visible = False Visible = False
end end
inherited MeasLabel: TLabel inherited MeasLabel: TLabel
Left = 232 Left = 240
end end
inherited MeasEdit: TEdit inherited MeasEdit: TEdit
Left = 232 Left = 240
Width = 208 Width = 200
end end
inherited Bevel2: TBevel inherited Bevel2: TBevel
Left = 209 Left = 209
end end
object SigmaOptns: TRadioGroup[8] inherited MeasInBtn: TSpeedButton
Left = 208
end
inherited MeasOutBtn: TSpeedButton
Left = 209
end
inherited GroupInBtn: TSpeedButton
Left = 208
Top = 272
Anchors = [akLeft]
Visible = False
end
inherited GroupOutBtn: TSpeedButton
Left = 209
Top = 300
Visible = False
end
object SigmaOptns: TRadioGroup[12]
AnchorSideLeft.Control = MeasEdit AnchorSideLeft.Control = MeasEdit
AnchorSideTop.Control = MeasEdit AnchorSideTop.Control = MeasEdit
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = SpecsPanel AnchorSideRight.Control = SpecsPanel
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 232 Left = 240
Height = 128 Height = 128
Top = 128 Top = 99
Width = 208 Width = 200
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
AutoFill = True AutoFill = True
BorderSpacing.Top = 32 BorderSpacing.Top = 32
BorderSpacing.Bottom = 8 BorderSpacing.Bottom = 8
Caption = 'No. of Sigma Units for UCL and LCL' Caption = 'Sigma Units for UCL and LCL'
ChildSizing.LeftRightSpacing = 12 ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6 ChildSizing.TopBottomSpacing = 6
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
@ -77,15 +98,15 @@ inherited CChartForm: TCChartForm
ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1 ChildSizing.ControlsPerLine = 1
ClientHeight = 108 ClientHeight = 108
ClientWidth = 204 ClientWidth = 196
ItemIndex = 0 ItemIndex = 0
Items.Strings = ( Items.Strings = (
'3 Sigma (default)' '3 Sigma'
'2 Sigma' '2 Sigma'
'1 Sigma' '1 Sigma'
'x Sigmas with x = ' 'x Sigmas with x = '
) )
TabOrder = 4 TabOrder = 2
object XSigmaEdit: TEdit object XSigmaEdit: TEdit
AnchorSideRight.Control = SigmaOptns AnchorSideRight.Control = SigmaOptns
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
@ -93,7 +114,7 @@ inherited CChartForm: TCChartForm
Left = 128 Left = 128
Height = 23 Height = 23
Top = 80 Top = 80
Width = 64 Width = 56
Alignment = taRightJustify Alignment = taRightJustify
Anchors = [akLeft, akRight, akBottom] Anchors = [akLeft, akRight, akBottom]
TabOrder = 0 TabOrder = 0
@ -105,7 +126,7 @@ inherited CChartForm: TCChartForm
Left = 443 Left = 443
Height = 420 Height = 420
end end
inherited PageControl1: TPageControl inherited PageControl: TPageControl
Left = 451 Left = 451
Height = 408 Height = 408
Width = 470 Width = 470
@ -113,15 +134,26 @@ inherited CChartForm: TCChartForm
ClientHeight = 380 ClientHeight = 380
ClientWidth = 462 ClientWidth = 462
inherited Panel1: TPanel inherited Panel1: TPanel
Height = 368 Height = 340
Width = 450 Width = 450
ClientHeight = 364 ClientHeight = 336
ClientWidth = 446 ClientWidth = 446
inherited ReportMemo: TMemo inherited ReportMemo: TMemo
Height = 356 Height = 328
Width = 438 Width = 438
end end
end end
inherited ReportToolBar: TToolBar
Width = 458
end
end end
end end
inherited SaveDialog: TSaveDialog
Left = 536
Top = 96
end
inherited PrintDialog: TPrintDialog
Left = 536
Top = 154
end
end end

View File

@ -80,17 +80,17 @@ begin
try try
lReport.Add('DEFECTS c CONTROL CHART RESULTS'); lReport.Add('DEFECTS c CONTROL CHART RESULTS');
lReport.Add(''); lReport.Add('');
lReport.Add('No. of samples: %8d', [numData]); //NoCases]);
lReport.Add('Total Nonconformities: %8.3f', [GrandMean]);
lReport.Add('Poisson mean and variance: %8.3f', [meanc]);
lReport.Add('Lower Control Limit: %8.3f', [LCL]);
lReport.Add('Upper Control Limit: %8.3f', [UCL]);
lReport.Add('');
lReport.Add('Sample Number of '); lReport.Add('Sample Number of ');
lReport.Add(' Nonconformities'); lReport.Add(' Nonconformities');
lReport.Add('------ ---------------'); lReport.Add('------ ---------------');
for i := 1 to NoCases do for i := 1 to NoCases do
lReport.Add('%6d %15.2f', [i, means[i]]); lReport.Add('%6d %15.2f', [i, means[i]]);
lReport.Add('');
lReport.Add('Total Nonconformities: %8.3f', [GrandMean]);
lReport.Add('No. of samples: %8d', [numData]); //NoCases]);
lReport.Add('Poisson mean and variance: %8.3f', [meanc]);
lReport.Add('Lower Control Limit: %8.3f', [LCL]);
lReport.Add('Upper Control Limit: %8.3f', [UCL]);
ReportMemo.Lines.Assign(lReport); ReportMemo.Lines.Assign(lReport);
finally finally

View File

@ -1,75 +1,90 @@
inherited CUSUMChartForm: TCUSUMChartForm inherited CUSUMChartForm: TCUSUMChartForm
Height = 424
HelpType = htKeyword HelpType = htKeyword
HelpKeyword = 'html/CUMSUMChart.htm' HelpKeyword = 'html/CUMSUMChart.htm'
Caption = 'Cumulative Sum Control Chart' Caption = 'Cumulative Sum Control Chart'
ClientHeight = 424
OnActivate = FormActivate OnActivate = FormActivate
ShowHint = True ShowHint = True
inherited SpecsPanel: TPanel inherited SpecsPanel: TPanel
Height = 424
Width = 432 Width = 432
ClientHeight = 424
ClientWidth = 432 ClientWidth = 432
inherited ButtonPanel: TPanel inherited ButtonPanel: TPanel
Top = 382
Width = 432 Width = 432
ClientWidth = 432 ClientWidth = 432
TabOrder = 5 TabOrder = 5
inherited CloseBtn: TButton inherited CloseBtn: TButton
Left = 377 Left = 377
TabOrder = 3
end end
inherited ComputeBtn: TButton inherited ComputeBtn: TButton
Left = 293 Left = 293
TabOrder = 2
end end
inherited ResetBtn: TButton inherited ResetBtn: TButton
Left = 231 Left = 231
TabOrder = 1
end end
inherited HelpBtn: TButton inherited HelpBtn: TButton
Left = 180 Left = 180
TabOrder = 0
end end
inherited Bevel1: TBevel inherited Bevel1: TBevel
Width = 424 Width = 424
end end
end end
inherited VarList: TListBox inherited VarList: TListBox
Width = 212 Height = 349
TabOrder = 0 Width = 188
end end
inherited GroupLabel: TLabel inherited GroupLabel: TLabel
Left = 228 Left = 236
end end
inherited GroupEdit: TEdit inherited GroupEdit: TEdit
Left = 228 Left = 236
Width = 204 Width = 196
TabOrder = 1
end end
inherited MeasLabel: TLabel inherited MeasLabel: TLabel
Left = 228 Left = 236
end end
inherited MeasEdit: TEdit inherited MeasEdit: TEdit
Left = 228 Left = 236
Width = 204 Width = 196
TabOrder = 2
end end
inherited Bevel2: TBevel inherited Bevel2: TBevel
Left = 205 Left = 205
end end
object GroupBox1: TGroupBox[8] inherited MeasInBtn: TSpeedButton
Left = 204
end
inherited MeasOutBtn: TSpeedButton
Left = 205
end
inherited GroupInBtn: TSpeedButton
AnchorSideLeft.Control = MeasInBtn
AnchorSideLeft.Side = asrTop
Left = 204
end
inherited GroupOutBtn: TSpeedButton
AnchorSideLeft.Control = GroupInBtn
Left = 205
end
object GroupBox1: TGroupBox[12]
AnchorSideLeft.Control = MeasEdit AnchorSideLeft.Control = MeasEdit
AnchorSideTop.Control = GroupBox2 AnchorSideTop.Control = GroupBox2
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = MeasEdit AnchorSideRight.Control = MeasEdit
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 228 Left = 236
Height = 153 Height = 153
Top = 202 Top = 239
Width = 204 Width = 196
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
AutoSize = True AutoSize = True
BorderSpacing.Top = 16 BorderSpacing.Top = 16
BorderSpacing.Bottom = 8
Caption = 'V-Mask Specifications' Caption = 'V-Mask Specifications'
ClientHeight = 133 ClientHeight = 133
ClientWidth = 200 ClientWidth = 192
TabOrder = 4 TabOrder = 4
object Label4: TLabel object Label4: TLabel
AnchorSideLeft.Control = GroupBox1 AnchorSideLeft.Control = GroupBox1
@ -116,7 +131,7 @@ inherited CUSUMChartForm: TCUSUMChartForm
Height = 23 Height = 23
Hint = 'Detection level for a shift in the process mean, '#13#10'expressed in data units (default), or'#13#10'as a multiple of the standard deviation of the '#13#10'data points (when "Normalized CUSUM" is checked).' Hint = 'Detection level for a shift in the process mean, '#13#10'expressed in data units (default), or'#13#10'as a multiple of the standard deviation of the '#13#10'data points (when "Normalized CUSUM" is checked).'
Top = 2 Top = 2
Width = 78 Width = 70
Alignment = taRightJustify Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 2 BorderSpacing.Top = 2
@ -136,7 +151,7 @@ inherited CUSUMChartForm: TCUSUMChartForm
Height = 23 Height = 23
Hint = 'Probability of concluding that a shift in the process has occurred, when in fact it did not. ' Hint = 'Probability of concluding that a shift in the process has occurred, when in fact it did not. '
Top = 29 Top = 29
Width = 78 Width = 70
Alignment = taRightJustify Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 8 BorderSpacing.Left = 8
@ -156,7 +171,7 @@ inherited CUSUMChartForm: TCUSUMChartForm
Height = 23 Height = 23
Hint = 'Probability of not detecting that a shift in the process mean has, in fact, occurred' Hint = 'Probability of not detecting that a shift in the process mean has, in fact, occurred'
Top = 56 Top = 56
Width = 78 Width = 70
Alignment = taRightJustify Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 4 BorderSpacing.Top = 4
@ -175,7 +190,7 @@ inherited CUSUMChartForm: TCUSUMChartForm
Left = 12 Left = 12
Height = 17 Height = 17
Top = 104 Top = 104
Width = 180 Width = 172
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 2 BorderSpacing.Top = 2
BorderSpacing.Bottom = 12 BorderSpacing.Bottom = 12
@ -194,23 +209,23 @@ inherited CUSUMChartForm: TCUSUMChartForm
ParentColor = False ParentColor = False
end end
end end
object GroupBox2: TGroupBox[9] object GroupBox2: TGroupBox[13]
AnchorSideLeft.Control = GroupBox1 AnchorSideLeft.Control = GroupBox1
AnchorSideTop.Control = MeasEdit AnchorSideTop.Control = GroupEdit
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = MeasEdit AnchorSideRight.Control = MeasEdit
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 228 Left = 236
Height = 74 Height = 74
Top = 112 Top = 149
Width = 204 Width = 196
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
AutoSize = True AutoSize = True
BorderSpacing.Top = 16 BorderSpacing.Top = 16
BorderSpacing.Bottom = 8 BorderSpacing.Bottom = 8
Caption = 'Option:' Caption = 'Option:'
ClientHeight = 54 ClientHeight = 54
ClientWidth = 200 ClientWidth = 192
TabOrder = 3 TabOrder = 3
object TargetChk: TCheckBox object TargetChk: TCheckBox
AnchorSideLeft.Control = GroupBox2 AnchorSideLeft.Control = GroupBox2
@ -261,19 +276,28 @@ inherited CUSUMChartForm: TCUSUMChartForm
end end
inherited SpecsSplitter: TSplitter inherited SpecsSplitter: TSplitter
Left = 435 Left = 435
Height = 424
end end
inherited PageControl1: TPageControl inherited PageControl: TPageControl
Left = 443 Left = 443
Height = 412
Width = 478 Width = 478
inherited ReportPage: TTabSheet inherited ReportPage: TTabSheet
ClientHeight = 384
ClientWidth = 470 ClientWidth = 470
inherited Panel1: TPanel inherited Panel1: TPanel
Height = 344
Width = 458 Width = 458
ClientHeight = 340
ClientWidth = 454 ClientWidth = 454
inherited ReportMemo: TMemo inherited ReportMemo: TMemo
Height = 332
Width = 446 Width = 446
end end
end end
inherited ReportToolBar: TToolBar
Width = 466
end
end end
end end
end end

View File

@ -175,6 +175,7 @@ begin
lReport.Clear; lReport.Clear;
lReport.Add('CUSUM Chart Results'); lReport.Add('CUSUM Chart Results');
lReport.Add(''); lReport.Add('');
lReport.Add('Number of Values: %8d', [numValues]);
lReport.Add('Mean of group deviations: %8.3f', [grandSum]); lReport.Add('Mean of group deviations: %8.3f', [grandSum]);
lReport.Add('Mean of all observations: %8.3f', [grandMean]); lReport.Add('Mean of all observations: %8.3f', [grandMean]);
lReport.Add('Std. Dev. of Observations: %8.3f', [grandSD]); lReport.Add('Std. Dev. of Observations: %8.3f', [grandSD]);
@ -239,14 +240,15 @@ begin
DisableAutoSizing; DisableAutoSizing;
try try
GroupBox2.Anchors := GroupBox2.Anchors - [akRight]; GroupBox1.Anchors := GroupBox1.Anchors - [akRight];
VarList.Constraints.MinWidth := VarListLabel.Width; VarList.Constraints.MinWidth := VarListLabel.Width;
SpecsPanel.Constraints.MinWidth := Max( SpecsPanel.Constraints.MinWidth := Max(
CloseBtn.Left + CloseBtn.Width - HelpBtn.Left + HelpBtn.BorderSpacing.Around, CloseBtn.Left + CloseBtn.Width - HelpBtn.Left + HelpBtn.BorderSpacing.Around,
GroupBox2.Width * 2 + VarList.BorderSpacing.Right + VarList.BorderSpacing.Left GroupBox2.Width * 2 + VarList.BorderSpacing.Right + VarList.BorderSpacing.Left
); );
Constraints.MinHeight := GroupBox2.Top + GroupBox2.Height + GroupBox2.BorderSpacing.Bottom + ButtonPanel.Height; Constraints.MinHeight := GroupBox1.Top + GroupBox1.Height + GroupBox1.BorderSpacing.Bottom + ButtonPanel.Height;
GroupBox2.Anchors := GroupBox2.Anchors + [akRight]; Height := 1; // enforce autosizing of height
GroupBox1.Anchors := GroupBox1.Anchors + [akRight];
finally finally
EnableAutoSizing; EnableAutoSizing;
end; end;

View File

@ -11,6 +11,7 @@ inherited PChartForm: TPChartForm
inherited ButtonPanel: TPanel inherited ButtonPanel: TPanel
Width = 456 Width = 456
ClientWidth = 456 ClientWidth = 456
TabOrder = 6
inherited CloseBtn: TButton inherited CloseBtn: TButton
Left = 401 Left = 401
end end
@ -28,62 +29,82 @@ inherited PChartForm: TPChartForm
end end
end end
inherited VarList: TListBox inherited VarList: TListBox
Width = 224 Width = 200
end end
inherited GroupLabel: TLabel inherited GroupLabel: TLabel
Left = 240 Left = 248
Top = 328
Visible = False Visible = False
end end
inherited GroupEdit: TEdit inherited GroupEdit: TEdit
Left = 240 Left = 248
Width = 216 Top = 345
Width = 208
TabOrder = 5
Visible = False Visible = False
end end
inherited MeasLabel: TLabel inherited MeasLabel: TLabel
Left = 240 Left = 248
end end
inherited MeasEdit: TEdit inherited MeasEdit: TEdit
Left = 240 Left = 248
Width = 216 Width = 208
end end
inherited Bevel2: TBevel inherited Bevel2: TBevel
Left = 217 Left = 217
end end
object Label3: TLabel[8] inherited MeasInBtn: TSpeedButton
Left = 216
end
inherited MeasOutBtn: TSpeedButton
Left = 217
end
inherited GroupInBtn: TSpeedButton
Left = 216
Top = 326
Anchors = [akLeft]
Visible = False
end
inherited GroupOutBtn: TSpeedButton
Left = 217
Top = 354
Visible = False
end
object Label3: TLabel[12]
AnchorSideLeft.Control = Label4 AnchorSideLeft.Control = Label4
AnchorSideTop.Control = NEdit AnchorSideTop.Control = NEdit
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = NEdit AnchorSideRight.Control = NEdit
Left = 270 Left = 270
Height = 15 Height = 15
Top = 124 Top = 95
Width = 114 Width = 114
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
BorderSpacing.Right = 8 BorderSpacing.Right = 8
Caption = 'No. of Parts Sampled:' Caption = 'No. of Parts Sampled:'
ParentColor = False ParentColor = False
end end
object NEdit: TEdit[9] object NEdit: TEdit[13]
AnchorSideTop.Control = MeasEdit AnchorSideTop.Control = MeasEdit
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = MeasEdit AnchorSideRight.Control = MeasEdit
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 392 Left = 392
Height = 23 Height = 23
Top = 120 Top = 91
Width = 64 Width = 64
Alignment = taRightJustify Alignment = taRightJustify
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
BorderSpacing.Top = 24 BorderSpacing.Top = 24
TabOrder = 4 TabOrder = 2
Text = 'NEdit' Text = 'NEdit'
end end
object Label4: TLabel[10] object Label4: TLabel[14]
AnchorSideTop.Control = PEdit AnchorSideTop.Control = PEdit
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
Left = 272 Left = 272
Height = 30 Height = 30
Top = 147 Top = 118
Width = 108 Width = 108
Alignment = taRightJustify Alignment = taRightJustify
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
@ -91,36 +112,36 @@ inherited PChartForm: TPChartForm
Caption = 'Expected Proportion'#13#10'of Defects:' Caption = 'Expected Proportion'#13#10'of Defects:'
ParentColor = False ParentColor = False
end end
object PEdit: TEdit[11] object PEdit: TEdit[15]
AnchorSideTop.Control = NEdit AnchorSideTop.Control = NEdit
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = MeasEdit AnchorSideRight.Control = MeasEdit
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 392 Left = 392
Height = 23 Height = 23
Top = 151 Top = 122
Width = 64 Width = 64
Alignment = taRightJustify Alignment = taRightJustify
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
BorderSpacing.Top = 8 BorderSpacing.Top = 8
TabOrder = 5 TabOrder = 3
Text = 'PEdit' Text = 'PEdit'
end end
object SigmaOpts: TRadioGroup[12] object SigmaOpts: TRadioGroup[16]
AnchorSideLeft.Control = MeasEdit AnchorSideLeft.Control = MeasEdit
AnchorSideTop.Control = PEdit AnchorSideTop.Control = PEdit
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = SpecsPanel AnchorSideRight.Control = SpecsPanel
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 240 Left = 248
Height = 128 Height = 128
Top = 198 Top = 169
Width = 216 Width = 208
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
AutoFill = True AutoFill = True
BorderSpacing.Top = 24 BorderSpacing.Top = 24
BorderSpacing.Bottom = 8 BorderSpacing.Bottom = 8
Caption = 'No. of Sigma Units for UCL and LCL' Caption = 'Sigma Units for UCL and LCL'
ChildSizing.LeftRightSpacing = 12 ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6 ChildSizing.TopBottomSpacing = 6
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
@ -130,15 +151,15 @@ inherited PChartForm: TPChartForm
ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1 ChildSizing.ControlsPerLine = 1
ClientHeight = 108 ClientHeight = 108
ClientWidth = 212 ClientWidth = 204
ItemIndex = 0 ItemIndex = 0
Items.Strings = ( Items.Strings = (
'3 Sigma (default)' '3 Sigma'
'2 Sigma' '2 Sigma'
'1 Sigma' '1 Sigma'
'x Sigmas with x = ' 'x Sigmas with x = '
) )
TabOrder = 6 TabOrder = 4
object XSigmaEdit: TEdit object XSigmaEdit: TEdit
AnchorSideRight.Control = SigmaOpts AnchorSideRight.Control = SigmaOpts
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
@ -146,7 +167,7 @@ inherited PChartForm: TPChartForm
Left = 128 Left = 128
Height = 23 Height = 23
Top = 80 Top = 80
Width = 72 Width = 64
Alignment = taRightJustify Alignment = taRightJustify
Anchors = [akLeft, akRight, akBottom] Anchors = [akLeft, akRight, akBottom]
TabOrder = 0 TabOrder = 0
@ -157,7 +178,7 @@ inherited PChartForm: TPChartForm
inherited SpecsSplitter: TSplitter inherited SpecsSplitter: TSplitter
Left = 459 Left = 459
end end
inherited PageControl1: TPageControl inherited PageControl: TPageControl
Left = 467 Left = 467
Width = 454 Width = 454
inherited ReportPage: TTabSheet inherited ReportPage: TTabSheet
@ -169,6 +190,15 @@ inherited PChartForm: TPChartForm
Width = 422 Width = 422
end end
end end
inherited ReportToolBar: TToolBar
Width = 442
end
end end
end end
inherited SaveDialog: TSaveDialog
Left = 544
end
inherited PrintDialog: TPrintDialog
Left = 544
end
end end

View File

@ -23,24 +23,13 @@ implementation
uses uses
Math, Math,
Globals, Utils, MainUnit; Globals, Utils, MainUnit, DataProcs;
procedure TRChartForm.Compute; procedure TRChartForm.Compute;
const
D3: array[1..24] of double = (
0,0,0,0,0,0.076,0.136,0.184,0.223,0.256,0.283,0.307,0.328,
0.347,0.363,0.378,0.391,0.403,0.415,0.425,0.434,0.443,
0.451,0.459
);
D4: array[1..24] of double = (
3.267, 2.574, 2.282, 2.114, 2.004, 1.924, 1.864, 1.816,1.777,
1.744, 1.717, 1.693, 1.672, 1.653, 1.637, 1.622, 1.608,1.597,
1.585, 1.575, 1.566, 1.557, 1.548, 1.541
);
var var
i, j: Integer; i, j: Integer;
grp: String; grp: String;
grpIndex, grpSize, oldGrpSize, numGrps: Integer; grpIndex, grpSize, oldGrpSize, numGrps, numValues: Integer;
groups: StrDyneVec = nil; groups: StrDyneVec = nil;
means: DblDyneVec = nil; means: DblDyneVec = nil;
stddev: DblDyneVec = nil; stddev: DblDyneVec = nil;
@ -71,6 +60,11 @@ begin
grandRange := 0.0; grandRange := 0.0;
sizeError := false; sizeError := false;
// Count "good" data points
numValues := 0;
for i := 1 to NoCases do
if GoodRecord(i, Length(ColNoSelected), ColNoSelected) then inc(numValues);
// calculate group ranges, grand mean, group sd's, semeans // calculate group ranges, grand mean, group sd's, semeans
for j := 0 to numGrps-1 do for j := 0 to numGrps-1 do
begin begin
@ -115,12 +109,12 @@ begin
stddev[i] := sqrt(stddev[i]); stddev[i] := sqrt(stddev[i]);
means[i] := means[i] / count[i]; means[i] := means[i] / count[i];
end; end;
seMean := seMean - grandMean * grandMean / NoCases; seMean := seMean - grandMean * grandMean / numValues;
seMean := seMean / (NoCases - 1); seMean := seMean / (numValues - 1);
seMean := sqrt(seMean); seMean := sqrt(seMean);
GrandSD := seMean; GrandSD := seMean;
seMean := seMean / sqrt(NoCases); seMean := seMean / sqrt(numValues);
grandMean := grandMean / NoCases; grandMean := grandMean / numValues;
grandRange := grandRange / numGrps; grandRange := grandRange / numGrps;
D3Value := D3[grpSize-1]; D3Value := D3[grpSize-1];
D4Value := D4[grpSize-1]; D4Value := D4[grpSize-1];
@ -132,17 +126,19 @@ begin
try try
lReport.Add('Range Chart Results'); lReport.Add('Range Chart Results');
lReport.Add(''); lReport.Add('');
lReport.Add('Number of values: %8d', [numValues]);
lReport.Add('Grand Mean: %8.3f', [GrandMean]);
lReport.Add('Standard Deviation: %8.3f', [GrandSD]);
lReport.Add('Standard Error of Mean: %8.3f', [semean]);
lReport.Add('');
lReport.Add('Mean Range: %8.3f', [GrandRange]);
lReport.Add('Lower Control Limit: %8.3f', [LCL]);
lReport.Add('Upper Control Limit: %8.3f', [UCL]);
lReport.Add('');
lReport.Add(' Group Size Mean Std.Dev. Ranges '); lReport.Add(' Group Size Mean Std.Dev. Ranges ');
lReport.Add('------- ---- -------- -------- --------'); lReport.Add('------- ---- -------- -------- --------');
for i := 0 to numGrps-1 do for i := 0 to numGrps-1 do
lReport.Add('%7d %4d %8.2f %8.2f %8.2f', [i+1, count[i], means[i], stddev[i], ranges[i]]); lReport.Add('%7d %4d %8.2f %8.2f %8.2f', [i+1, count[i], means[i], stddev[i], ranges[i]]);
lReport.Add('');
lReport.Add('Grand Mean: %8.3f', [GrandMean]);
lReport.Add('Standard Deviation: %8.3f', [GrandSD]);
lReport.Add('Standard Error of Mean: %8.3f', [semean]);
lReport.Add('Mean Range: %8.3f', [GrandRange]);
lReport.Add('Lower Control Limit: %8.3f', [LCL]);
lReport.Add('Upper Control Limit: %8.3f', [UCL]);
ReportMemo.Lines.Assign(lReport); ReportMemo.Lines.Assign(lReport);
finally finally

View File

@ -28,17 +28,6 @@ uses
Math, Globals, MathUnit, Utils, MainUnit, DataProcs; Math, Globals, MathUnit, Utils, MainUnit, DataProcs;
procedure TSChartForm.Compute; procedure TSChartForm.Compute;
const
D3: array[1..24] of double = (
0,0,0,0,0,0.076,0.136,0.184,0.223,0.256,0.283,0.307,0.328,
0.347,0.363,0.378,0.391,0.403,0.415,0.425,0.434,0.443,
0.451,0.459
);
D4 : array[1..24] of double = (
3.267,2.574,2.282,2.114,2.004,1.924,1.864,1.816,1.777,
1.744,1.717,1.693,1.672,1.653,1.637,1.622,1.608,1.597,
1.585,1.575,1.566,1.557,1.548,1.541
);
var var
UCL, LCL: Double; UCL, LCL: Double;
grpSize, oldGrpSize: Integer; grpSize, oldGrpSize: Integer;
@ -48,6 +37,7 @@ var
stddev: DblDyneVec = nil; stddev: DblDyneVec = nil;
count: IntDyneVec = nil; count: IntDyneVec = nil;
numGrps: Integer = 0; numGrps: Integer = 0;
numValues: Integer = 0;
grp: String; grp: String;
grpIndex: Integer; grpIndex: Integer;
X, Xsq: Double; X, Xsq: Double;
@ -75,6 +65,11 @@ begin
grandSigma := 0.0; grandSigma := 0.0;
sizeError := false; sizeError := false;
// Count "good" data points
numValues := 0;
for i := 1 to NoCases do
if GoodRecord(i, Length(ColNoSelected), ColNoSelected) then inc(numValues);
// calculate group ranges, grand mean, group sd's, semeans // calculate group ranges, grand mean, group sd's, semeans
for j := 0 to numGrps-1 do // groups for j := 0 to numGrps-1 do // groups
begin begin
@ -83,7 +78,7 @@ begin
for i := 1 to NoCases do for i := 1 to NoCases do
begin begin
if not GoodRecord(i, Length(ColNoSelected), ColNoSelected) then continue; if not GoodRecord(i, Length(ColNoSelected), ColNoSelected) then continue;
grp := Trim(OS3MainFrm.DataGrid.Cells[GrpVar,i]); grp := Trim(OS3MainFrm.DataGrid.Cells[GrpVar, i]);
grpIndex := IndexOfString(groups, grp); grpIndex := IndexOfString(groups, grp);
if grpIndex = j then if grpIndex = j then
begin begin
@ -115,12 +110,12 @@ begin
exit; exit;
end; end;
seMean := seMean - sqr(grandMean)/NoCases; seMean := seMean - sqr(grandMean)/numValues;
seMean := seMean / (NoCases - 1); seMean := seMean / (numValues - 1);
seMean := sqrt(seMean); seMean := sqrt(seMean);
grandSD := seMean; grandSD := seMean;
seMean := seMean / sqrt(NoCases); seMean := seMean / sqrt(numValues);
grandMean := grandMean / NoCases; grandMean := grandMean / numValues;
grandSigma := grandSigma / numGrps; grandSigma := grandSigma / numGrps;
D3Value := D3[grpSize-1]; D3Value := D3[grpSize-1];
D4Value := D4[grpSize-1]; D4Value := D4[grpSize-1];
@ -139,17 +134,19 @@ begin
try try
lReport.Add('Sigma Chart Results'); lReport.Add('Sigma Chart Results');
lReport.Add(''); lReport.Add('');
lReport.Add('Number of values: %8d', [numValues]);
lReport.Add('Grand Mean: %8.3f', [grandMean]);
lReport.Add('Standard Deviation: %8.3f', [grandSD]);
lReport.Add('Standard Error of Mean: %8.3f', [seMean]);
lReport.Add('');
lReport.Add('Mean Sigma: %8.3f', [grandSigma]);
lReport.Add('Lower Control Limit: %8.3f', [LCL]);
lReport.Add('Upper Control Limit: %8.3f', [UCL]);
lReport.Add('');
lReport.Add(' Group Size Mean Std.Dev.'); lReport.Add(' Group Size Mean Std.Dev.');
lReport.Add('------- ---- -------- --------'); lReport.Add('------- ---- -------- --------');
for i := 0 to numGrps - 1 do for i := 0 to numGrps - 1 do
lReport.Add('%7d %4d %8.2f %8.2f', [i+1, count[i], means[i], stddev[i]]); lReport.Add('%7d %4d %8.2f %8.2f', [i+1, count[i], means[i], stddev[i]]);
lReport.Add('');
lReport.Add('Grand Mean: %8.3f', [grandMean]);
lReport.Add('Standard Deviation: %8.3f', [grandSD]);
lReport.Add('Standard Error of Mean: %8.3f', [seMean]);
lReport.Add('Mean Sigma: %8.3f', [grandSigma]);
lReport.Add('Lower Control Limit: %8.3f', [LCL]);
lReport.Add('Upper Control Limit: %8.3f', [UCL]);
ReportMemo.Lines.Assign(lReport); ReportMemo.Lines.Assign(lReport);
finally finally

View File

@ -9,6 +9,7 @@ inherited UChartForm: TUChartForm
inherited ButtonPanel: TPanel inherited ButtonPanel: TPanel
Width = 432 Width = 432
ClientWidth = 432 ClientWidth = 432
TabOrder = 5
inherited CloseBtn: TButton inherited CloseBtn: TButton
Left = 377 Left = 377
end end
@ -26,34 +27,54 @@ inherited UChartForm: TUChartForm
end end
end end
inherited VarList: TListBox inherited VarList: TListBox
Width = 212 Width = 188
end end
inherited GroupLabel: TLabel inherited GroupLabel: TLabel
Left = 228 Left = 236
Top = 302
Visible = False Visible = False
end end
inherited GroupEdit: TEdit inherited GroupEdit: TEdit
Left = 228 Left = 236
Width = 204 Top = 319
Width = 196
TabOrder = 4
Visible = False Visible = False
end end
inherited MeasLabel: TLabel inherited MeasLabel: TLabel
Left = 228 Left = 236
end end
inherited MeasEdit: TEdit inherited MeasEdit: TEdit
Left = 228 Left = 236
Width = 204 Width = 196
end end
inherited Bevel2: TBevel inherited Bevel2: TBevel
Left = 205 Left = 205
end end
object Label3: TLabel[8] inherited MeasInBtn: TSpeedButton
Left = 204
end
inherited MeasOutBtn: TSpeedButton
Left = 205
end
inherited GroupInBtn: TSpeedButton
Left = 204
Top = 300
Anchors = [akLeft]
Visible = False
end
inherited GroupOutBtn: TSpeedButton
Left = 205
Top = 328
Visible = False
end
object Label3: TLabel[12]
AnchorSideTop.Control = NoInspEdit AnchorSideTop.Control = NoInspEdit
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = NoInspEdit AnchorSideRight.Control = NoInspEdit
Left = 288 Left = 288
Height = 30 Height = 30
Top = 112 Top = 83
Width = 73 Width = 73
Alignment = taRightJustify Alignment = taRightJustify
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
@ -61,36 +82,36 @@ inherited UChartForm: TUChartForm
Caption = 'No. inspected'#13#10'per group:' Caption = 'No. inspected'#13#10'per group:'
ParentColor = False ParentColor = False
end end
object NoInspEdit: TEdit[9] object NoInspEdit: TEdit[13]
AnchorSideTop.Control = MeasEdit AnchorSideTop.Control = MeasEdit
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = MeasEdit AnchorSideRight.Control = MeasEdit
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 369 Left = 369
Height = 23 Height = 23
Top = 116 Top = 87
Width = 63 Width = 63
Alignment = taRightJustify Alignment = taRightJustify
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
BorderSpacing.Top = 20 BorderSpacing.Top = 20
TabOrder = 4 TabOrder = 2
Text = 'NoInspEdit' Text = 'NoInspEdit'
end end
object SigmaOpts: TRadioGroup[10] object SigmaOpts: TRadioGroup[14]
AnchorSideLeft.Control = MeasEdit AnchorSideLeft.Control = MeasEdit
AnchorSideTop.Control = NoInspEdit AnchorSideTop.Control = NoInspEdit
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = SpecsPanel AnchorSideRight.Control = SpecsPanel
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 228 Left = 236
Height = 128 Height = 128
Top = 163 Top = 134
Width = 204 Width = 196
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
AutoFill = True AutoFill = True
BorderSpacing.Top = 24 BorderSpacing.Top = 24
BorderSpacing.Bottom = 8 BorderSpacing.Bottom = 8
Caption = 'No. of Sigma Units for UCL and LCL' Caption = 'Sigma Units for UCL and LCL'
ChildSizing.LeftRightSpacing = 12 ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6 ChildSizing.TopBottomSpacing = 6
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
@ -100,15 +121,15 @@ inherited UChartForm: TUChartForm
ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1 ChildSizing.ControlsPerLine = 1
ClientHeight = 108 ClientHeight = 108
ClientWidth = 200 ClientWidth = 192
ItemIndex = 0 ItemIndex = 0
Items.Strings = ( Items.Strings = (
'3 Sigma (default)' '3 Sigma'
'2 Sigma' '2 Sigma'
'1 Sigma' '1 Sigma'
'x Sigmas with x = ' 'x Sigmas with x = '
) )
TabOrder = 5 TabOrder = 3
object XSigmaEdit: TEdit object XSigmaEdit: TEdit
AnchorSideRight.Control = SigmaOpts AnchorSideRight.Control = SigmaOpts
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
@ -116,7 +137,7 @@ inherited UChartForm: TUChartForm
Left = 128 Left = 128
Height = 23 Height = 23
Top = 80 Top = 80
Width = 60 Width = 52
Alignment = taRightJustify Alignment = taRightJustify
Anchors = [akLeft, akRight, akBottom] Anchors = [akLeft, akRight, akBottom]
TabOrder = 0 TabOrder = 0
@ -127,7 +148,7 @@ inherited UChartForm: TUChartForm
inherited SpecsSplitter: TSplitter inherited SpecsSplitter: TSplitter
Left = 435 Left = 435
end end
inherited PageControl1: TPageControl inherited PageControl: TPageControl
Left = 443 Left = 443
Width = 478 Width = 478
inherited ReportPage: TTabSheet inherited ReportPage: TTabSheet
@ -139,15 +160,21 @@ inherited UChartForm: TUChartForm
Width = 446 Width = 446
end end
end end
inherited ToolBar2: TToolBar inherited ReportToolBar: TToolBar
Width = 466 Width = 466
end end
end end
inherited ChartPage: TTabSheet inherited ChartPage: TTabSheet
ClientWidth = 470 ClientWidth = 470
inherited ToolBar1: TToolBar inherited ChartToolBar: TToolBar
Width = 466 Width = 466
end end
end end
end end
inherited SaveDialog: TSaveDialog
Left = 544
end
inherited PrintDialog: TPrintDialog
Left = 544
end
end end

View File

@ -84,17 +84,17 @@ begin
try try
lReport.Add('DEFECTS c CONTROL CHART RESULTS'); lReport.Add('DEFECTS c CONTROL CHART RESULTS');
lReport.Add(''); lReport.Add('');
lReport.Add('Sample No Defects Defects Per Unit');
lReport.Add('------ ---------- ----------------');
for i := 0 to numSamples-1 do
lReport.Add('%6d %10.2f %16.2f', [i, means[i], defPerUnit[i]]);
lReport.Add('');
lReport.Add('Total Nonconformities: %8.2f', [grandMean]);
lReport.Add('No. of Samples: %8d', [numSamples]); lReport.Add('No. of Samples: %8d', [numSamples]);
lReport.Add('Total Nonconformities: %8.2f', [grandMean]);
lReport.Add('Def. / unit Mean: %8.3f', [meanC]); lReport.Add('Def. / unit Mean: %8.3f', [meanC]);
lReport.Add(' and StdDev: %8.3f', [stdDevC]); lReport.Add(' and StdDev: %8.3f', [stdDevC]);
lReport.Add('Lower Control Limit: %8.3f', [LCL]); lReport.Add('Lower Control Limit: %8.3f', [LCL]);
lReport.Add('Upper Control Limit: %8.3f', [UCL]); lReport.Add('Upper Control Limit: %8.3f', [UCL]);
lReport.Add('');
lReport.Add('Sample No Defects Defects Per Unit');
lReport.Add('------ ---------- ----------------');
for i := 0 to numSamples-1 do
lReport.Add('%6d %10.2f %16.2f', [i, means[i], defPerUnit[i]]);
ReportMemo.Lines.Assign(lReport); ReportMemo.Lines.Assign(lReport);
finally finally

View File

@ -1,16 +1,22 @@
inherited XBarChartForm: TXBarChartForm inherited XBarChartForm: TXBarChartForm
Left = 572 Left = 572
Height = 443
Top = 215 Top = 215
HelpType = htKeyword HelpType = htKeyword
HelpKeyword = 'html/XBarChart.htm' HelpKeyword = 'html/XBarChart.htm'
Caption = 'X-Bar Control Chart' Caption = 'X-Bar Control Chart'
ClientHeight = 443
OnActivate = FormActivate OnActivate = FormActivate
inherited SpecsPanel: TPanel inherited SpecsPanel: TPanel
Height = 443
Width = 475 Width = 475
ClientHeight = 443
ClientWidth = 475 ClientWidth = 475
inherited ButtonPanel: TPanel inherited ButtonPanel: TPanel
Top = 401
Width = 475 Width = 475
ClientWidth = 475 ClientWidth = 475
TabOrder = 5
inherited CloseBtn: TButton inherited CloseBtn: TButton
Left = 420 Left = 420
end end
@ -28,40 +34,53 @@ inherited XBarChartForm: TXBarChartForm
end end
end end
inherited VarList: TListBox inherited VarList: TListBox
Width = 233 Height = 368
Width = 209
end end
inherited GroupLabel: TLabel inherited GroupLabel: TLabel
Left = 249 Left = 257
end end
inherited GroupEdit: TEdit inherited GroupEdit: TEdit
Left = 249 Left = 257
Width = 226 Width = 218
end end
inherited MeasLabel: TLabel inherited MeasLabel: TLabel
Left = 249 Left = 257
end end
inherited MeasEdit: TEdit inherited MeasEdit: TEdit
AnchorSideRight.Control = LevelOptns AnchorSideRight.Control = LevelOptns
Left = 249 Left = 257
Width = 226 Width = 218
end end
inherited Bevel2: TBevel inherited Bevel2: TBevel
Left = 226 Left = 226
end end
object SigmaOpts: TRadioGroup[8] inherited MeasInBtn: TSpeedButton
Left = 225
end
inherited MeasOutBtn: TSpeedButton
Left = 226
end
inherited GroupInBtn: TSpeedButton
Left = 225
end
inherited GroupOutBtn: TSpeedButton
Left = 226
end
object SigmaOpts: TRadioGroup[12]
AnchorSideLeft.Control = MeasEdit AnchorSideLeft.Control = MeasEdit
AnchorSideTop.Control = MeasEdit AnchorSideTop.Control = GroupEdit
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = LevelOptns AnchorSideRight.Control = LevelOptns
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 249 Left = 257
Height = 128 Height = 128
Top = 108 Top = 145
Width = 226 Width = 218
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
AutoFill = True AutoFill = True
BorderSpacing.Top = 12 BorderSpacing.Top = 12
Caption = 'No. of Sigma Units for UCL and LCL' Caption = 'Sigma Units for UCL and LCL'
ChildSizing.LeftRightSpacing = 12 ChildSizing.LeftRightSpacing = 12
ChildSizing.TopBottomSpacing = 6 ChildSizing.TopBottomSpacing = 6
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
@ -71,15 +90,15 @@ inherited XBarChartForm: TXBarChartForm
ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1 ChildSizing.ControlsPerLine = 1
ClientHeight = 108 ClientHeight = 108
ClientWidth = 222 ClientWidth = 214
ItemIndex = 0 ItemIndex = 0
Items.Strings = ( Items.Strings = (
'3 Sigma (default)' '3 Sigma'
'2 Sigma' '2 Sigma'
'1 Sigma' '1 Sigma'
'x Sigmas with x = ' 'x Sigmas with x = '
) )
TabOrder = 4 TabOrder = 3
object XSigmaEdit: TEdit object XSigmaEdit: TEdit
AnchorSideRight.Control = SigmaOpts AnchorSideRight.Control = SigmaOpts
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
@ -87,31 +106,32 @@ inherited XBarChartForm: TXBarChartForm
Left = 128 Left = 128
Height = 23 Height = 23
Top = 80 Top = 80
Width = 82 Width = 74
Alignment = taRightJustify Alignment = taRightJustify
Anchors = [akLeft, akRight, akBottom] Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Right = 8
TabOrder = 0 TabOrder = 0
Text = 'XSigmaEdit' Text = 'XSigmaEdit'
end end
end end
object LevelOptns: TGroupBox[9] object LevelOptns: TGroupBox[13]
AnchorSideLeft.Control = MeasEdit AnchorSideLeft.Control = MeasEdit
AnchorSideTop.Control = SigmaOpts AnchorSideTop.Control = SigmaOpts
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = MeasEdit AnchorSideRight.Control = MeasEdit
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 249 Left = 257
Height = 103 Height = 103
Top = 248 Top = 285
Width = 226 Width = 218
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
AutoSize = True AutoSize = True
BorderSpacing.Top = 12 BorderSpacing.Top = 12
BorderSpacing.Bottom = 8 BorderSpacing.Bottom = 8
Caption = 'Show...' Caption = 'Show...'
ClientHeight = 83 ClientHeight = 83
ClientWidth = 222 ClientWidth = 214
TabOrder = 5 TabOrder = 4
object UpperSpecChk: TCheckBox object UpperSpecChk: TCheckBox
AnchorSideLeft.Control = LevelOptns AnchorSideLeft.Control = LevelOptns
AnchorSideTop.Control = UpperSpecEdit AnchorSideTop.Control = UpperSpecEdit
@ -202,26 +222,33 @@ inherited XBarChartForm: TXBarChartForm
end end
inherited SpecsSplitter: TSplitter inherited SpecsSplitter: TSplitter
Left = 478 Left = 478
Height = 443
end end
inherited PageControl1: TPageControl inherited PageControl: TPageControl
Left = 486 Left = 486
Height = 431
Width = 435 Width = 435
inherited ReportPage: TTabSheet inherited ReportPage: TTabSheet
ClientHeight = 403
ClientWidth = 427 ClientWidth = 427
inherited Panel1: TPanel inherited Panel1: TPanel
Height = 363
Width = 415 Width = 415
ClientHeight = 359
ClientWidth = 411 ClientWidth = 411
inherited ReportMemo: TMemo inherited ReportMemo: TMemo
Height = 351
Width = 403 Width = 403
end end
end end
inherited ToolBar2: TToolBar inherited ReportToolBar: TToolBar
Width = 423 Width = 423
end end
end end
inherited ChartPage: TTabSheet inherited ChartPage: TTabSheet
ClientHeight = 403
ClientWidth = 427 ClientWidth = 427
inherited ToolBar1: TToolBar inherited ChartToolBar: TToolBar
Width = 423 Width = 423
end end
end end

View File

@ -45,6 +45,8 @@ procedure TXBarChartForm.FormActivate(Sender: TObject);
var var
w: Integer; w: Integer;
begin begin
NoGroupsAllowed := true;
w := MaxValue([HelpBtn.Width, ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]); w := MaxValue([HelpBtn.Width, ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]);
HelpBtn.Constraints.MinWidth := w; HelpBtn.Constraints.MinWidth := w;
ResetBtn.Constraints.MinWidth := w; ResetBtn.Constraints.MinWidth := w;
@ -72,7 +74,10 @@ end;
procedure TXBarChartForm.Compute; procedure TXBarChartForm.Compute;
var var
i, j: Integer; i, j: Integer;
upperSpec, lowerSpec, targetSpec, sigma: Double; sigma: Double;
upperSpec: Double = NaN;
lowerSpec: Double = NaN;
targetSpec: Double = NaN;
ColNoSelected: IntDyneVec = nil; ColNoSelected: IntDyneVec = nil;
groups: StrDyneVec = nil; groups: StrDyneVec = nil;
means: DblDyneVec = nil; means: DblDyneVec = nil;
@ -81,101 +86,135 @@ var
numGrps: Integer; numGrps: Integer;
grp: String; grp: String;
grpIndex: Integer; grpIndex: Integer;
totalNumCases: Integer;
X, Xsq: Double; X, Xsq: Double;
UCL, LCL, grandMean, grandSD, seMean: Double; UCL, LCL, grandMean, grandSD, stdErrMean, C4Value: Double;
lReport: TStrings; lReport: TStrings;
begin begin
SetLength(ColNoSelected, 2); if GroupEdit.Text <> '' then
ColNoSelected[0] := GrpVar; begin
ColNoSelected[1] := MeasVar; SetLength(ColNoSelected, 2);
ColNoSelected[0] := GrpVar;
ColNoSelected[1] := MeasVar;
end else
begin
SetLength(ColNoSelected, 1);
ColNoSelected[0] := MeasVar;
end;
if UpperSpecChk.Checked and (UpperSpecEdit.Text <> '') then if UpperSpecChk.Checked and (UpperSpecEdit.Text <> '') then
upperSpec := StrToFloat(UpperSpecEdit.Text) upperSpec := StrToFloat(UpperSpecEdit.Text);
else
upperSpec := NaN;
if LowerSpecChk.Checked and (LowerSpecEdit.Text <> '') then if LowerSpecChk.Checked and (LowerSpecEdit.Text <> '') then
lowerSpec := StrToFloat(LowerSpecEdit.Text) lowerSpec := StrToFloat(LowerSpecEdit.Text);
else
lowerSpec := NaN;
if TargetChk.Checked and (TargetSpecEdit.Text <> '') then if TargetChk.Checked and (TargetSpecEdit.Text <> '') then
targetSpec := StrToFloat(TargetSpecEdit.Text) targetSpec := StrToFloat(TargetSpecEdit.Text);
else
targetSpec := Nan;
case SigmaOpts.ItemIndex of case SigmaOpts.ItemIndex of
0: sigma := 3.0; 0: sigma := 3.0;
1: sigma := 2.0; 1: sigma := 2.0;
2: sigma := 1.0; 2: sigma := 1.0;
3: sigma := StrToFloat(XSigmaEdit.Text); 3: sigma := StrToFloat(XSigmaEdit.Text);
else raise Exception.Create('Sigma case not handled.');
end; end;
groups := GetGroups; if GroupEdit.Text = '' then
SetLength(groups, NoCases)
else
groups := GetGroups;
numGrps := Length(groups); numGrps := Length(groups);
SetLength(means, numGrps); SetLength(means, numGrps);
SetLength(count, numGrps); SetLength(count, numGrps);
SetLength(stddev, numGrps); SetLength(stddev, numGrps);
seMean := 0.0; stdErrMean := 0.0;
grandMean := 0.0; grandMean := 0.0;
totalNumCases := 0;
// calculate group means, grand mean, group sd's, semeans // calculate group means, grand mean, group sd's, semeans
for i := 1 to NoCases do for i := 1 to NoCases do
begin begin
if not GoodRecord(i, Length(ColNoSelected), ColNoSelected) then continue; if not GoodRecord(i, Length(ColNoSelected), ColNoSelected) then continue;
grp := Trim(OS3MainFrm.DataGrid.Cells[GrpVar, i]); if GroupEdit.Text = '' then
grpIndex := IndexOfString(groups, grp); begin
// individuals x-bar chart
grpIndex := totalNumCases;
groups[grpIndex] := IntToStr(i);
end else
begin
// grouped x-bar chart
grp := Trim(OS3MainFrm.DataGrid.Cells[GrpVar, i]);
grpIndex := IndexOfString(groups, grp);
end;
X := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[MeasVar, i])); X := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[MeasVar, i]));
Xsq := X*X; Xsq := X*X;
inc(count[grpIndex]); inc(count[grpIndex]);
means[grpIndex] := means[grpIndex] + X; means[grpIndex] := means[grpIndex] + X;
stddev[grpIndex] := stddev[grpIndex] + Xsq; stddev[grpIndex] := stddev[grpIndex] + Xsq;
seMean := seMean + Xsq;
grandMean := grandMean + X; grandMean := grandMean + X;
stdErrMean := stdErrMean + Xsq;
inc(totalNumCases);
end; end;
for i := 0 to numGrps-1 do stdErrMean := stdErrMean - sqr(grandMean) / totalNumCases;
stdErrMean := sqrt(stderrMean / (totalNumCases - 1));
grandSD := stdErrMean;
stdErrMean := stdErrMean / sqrt(totalNumCases);
grandMean := grandMean / totalNumCases;
if (GroupEdit.Text = '') then
begin begin
if count[i] = 0 then // Individuals chart
SetLength(means, totalNumCases);
SetLength(stddev, totalNumCases);
Setlength(count, totalNumCases);
for i := 0 to totalNumCases-1 do
stddev[i] := stdErrMean;
C4Value := 1.0 / C4[totalNumCases-1];
UCL := grandMean + sigma * stdErrMean * C4Value;
LCL := grandMean - sigma * stdErrMean * C4Value;
end else
begin
// Grouped chart
for i := 0 to numGrps-1 do
begin begin
means[i] := NaN; if count[i] = 0 then
stddev[i] := NaN;
end else
begin
if count[i] = 1 then
stddev[i] := NaN
else
begin begin
stddev[i] := stddev[i] - sqr(means[i]) / count[i]; means[i] := NaN;
stddev[i] := stddev[i] / (count[i] - 1); stddev[i] := NaN;
stddev[i] := sqrt(stddev[i]); end else
begin
if count[i] = 1 then
stddev[i] := NaN
else
begin
stddev[i] := stddev[i] - sqr(means[i]) / count[i];
stddev[i] := stddev[i] / (count[i] - 1);
stddev[i] := sqrt(stddev[i]);
end;
means[i] := means[i] / count[i];
end; end;
means[i] := means[i] / count[i];
end; end;
UCL := grandMean + sigma * stdErrMean;
LCL := grandMean - sigma * stdErrMean;
end; end;
seMean := seMean - sqr(grandMean) / NoCases;
seMean := sqrt(seMean / (NoCases - 1));
grandSD := seMean;
seMean := seMean / sqrt(NoCases);
grandMean := grandMean / NoCases;
UCL := grandMean + sigma * seMean;
LCL := grandMean - sigma * seMean;
// printed results // Print results
lReport := TStringList.Create; lReport := TStringList.Create;
try try
lReport.Add('X BAR CHART RESULTS'); lReport.Add('X BAR CHART RESULTS');
lReport.Add(''); lReport.Add('');
lReport.Add('Number of samples: %8d', [totalNumCases]);
lReport.Add('Grand Mean: %8.3f', [grandMean]);
lReport.Add('Standard Deviation: %8.3f', [grandSD]);
lReport.Add('Standard Error of Mean: %8.3f', [stdErrMean]);
lReport.Add('');
lReport.Add('Lower Control Limit: %8.3f', [LCL]);
lReport.Add('Upper Control Limit: %8.3f', [UCL]);
lReport.Add('');
lReport.Add(' Group Size Mean Std.Dev.'); lReport.Add(' Group Size Mean Std.Dev.');
lReport.Add('------- ---- -------- --------'); lReport.Add('------- ---- -------- --------');
for i := 0 to numGrps-1 do for i := 0 to numGrps-1 do
lReport.Add('%7s %4d %8.2f %8.2f', [groups[i], count[i], means[i], stddev[i]]); lReport.Add('%7s %4d %8.2f %8.2f', [groups[i], count[i], means[i], stddev[i]]);
lReport.Add('');
lReport.Add('Grand Mean: %8.3f', [grandMean]);
lReport.Add('Standard Deviation: %8.3f', [grandSD]);
lReport.Add('Standard Error of Mean: %8.3f', [seMean]);
lReport.Add('');
lReport.Add('Lower Control Limit: %8.3f', [LCL]);
lReport.Add('Upper Control Limit: %8.3f', [UCL]);
ReportMemo.Lines.Assign(lReport); ReportMemo.Lines.Assign(lReport);
finally finally
@ -209,8 +248,14 @@ var
x: Double; x: Double;
begin begin
Result := inherited; Result := inherited;
if not Result then if (not Result) then
exit; begin
// This particular chart will handle individual data if GroupEdit is empty.
if GroupEdit.Visible and (GroupEdit.Text = '') then
Result := true
else
exit;
end;
Result := false; Result := false;