root / UFProfilP.pas @ 5
Historique | Voir | Annoter | Télécharger (72,191 ko)
1 | 3 | avalancogn | unit UFProfilP;
|
---|---|---|---|
2 | |||
3 | interface
|
||
4 | |||
5 | uses
|
||
6 | Windows, Forms, Classes, Controls, StdCtrls, Buttons, ExtCtrls, ComCtrls, |
||
7 | Grids, DB, Chart, Series, TeEngine, TeeProcs, PBNumEdit, PBSuperSpin, |
||
8 | JvExControls, JvEnterTab, ASGSQLite3, UVariables; |
||
9 | |||
10 | type
|
||
11 | TFProfilP = class(TForm)
|
||
12 | GBProfil: TGroupBox; |
||
13 | SBAddProfil: TSpeedButton; |
||
14 | SBDelProfil: TSpeedButton; |
||
15 | CBProfil: TComboBox; |
||
16 | PC: TPageControl; |
||
17 | TSPerf: TTabSheet; |
||
18 | PPerfLeft: TPanel; |
||
19 | GBInit: TGroupBox; |
||
20 | LPV: TLabel; |
||
21 | LAge: TLabel; |
||
22 | RBProt: TRadioButton; |
||
23 | RBLip: TRadioButton; |
||
24 | PBLipInit: TPBSuperSpin; |
||
25 | PBProtInit: TPBSuperSpin; |
||
26 | PBAgeInit: TPBSuperSpin; |
||
27 | PBPVInit: TPBSuperSpin; |
||
28 | GBFin: TGroupBox; |
||
29 | LCarcasse: TLabel; |
||
30 | RBFinDuree: TRadioButton; |
||
31 | PBDuree: TPBSuperSpin; |
||
32 | PBPVFin: TPBSuperSpin; |
||
33 | PBCarcasse: TPBSuperSpin; |
||
34 | RBFinPoids: TRadioButton; |
||
35 | GBPotential: TGroupBox; |
||
36 | LEntretien: TLabel; |
||
37 | LComport: TLabel; |
||
38 | LPDMoy: TLabel; |
||
39 | PBPDMoy: TPBSuperSpin; |
||
40 | PBEntretien: TPBSuperSpin; |
||
41 | PBComport: TPBSuperSpin; |
||
42 | PPerfRight: TPanel; |
||
43 | PGraphTop: TPanel; |
||
44 | Graph: TChart; |
||
45 | LigneAdLib: TLineSeries; |
||
46 | LPVmr2: TLabel; |
||
47 | SBGraph3D: TSpeedButton; |
||
48 | PBPVmr2: TPBSuperSpin; |
||
49 | TSConso: TTabSheet; |
||
50 | GBAdLib: TGroupBox; |
||
51 | LCoefA: TLabel; |
||
52 | LUnite: TLabel; |
||
53 | RBCoef: TRadioButton; |
||
54 | RBIngere: TRadioButton; |
||
55 | LEquation: TLabel; |
||
56 | CBEquation: TComboBox; |
||
57 | CBUnite: TComboBox; |
||
58 | LCoefB: TLabel; |
||
59 | LIng50: TLabel; |
||
60 | LIng100: TLabel; |
||
61 | GBGraphY: TGroupBox; |
||
62 | CBGraphYD: TComboBox; |
||
63 | GBGraphX: TGroupBox; |
||
64 | CBGraphXD: TComboBox; |
||
65 | SBRename: TSpeedButton; |
||
66 | SBComment: TSpeedButton; |
||
67 | GBResults: TGroupBox; |
||
68 | GBGraphT: TGroupBox; |
||
69 | CBGraphT: TComboBox; |
||
70 | CBGraphXP: TComboBox; |
||
71 | BarreAdLib: TBarSeries; |
||
72 | CBGraphYP: TComboBox; |
||
73 | SBSave: TSpeedButton; |
||
74 | SBPrint: TSpeedButton; |
||
75 | PBCoefA: TPBSuperSpin; |
||
76 | PBCoefB: TPBSuperSpin; |
||
77 | PBIng50: TPBSuperSpin; |
||
78 | PBIng100: TPBSuperSpin; |
||
79 | JvEnterAsTab: TJvEnterAsTab; |
||
80 | PCoef: TPanel; |
||
81 | PIngere: TPanel; |
||
82 | LSeqAli: TLabel; |
||
83 | LRation: TLabel; |
||
84 | LSexe: TLabel; |
||
85 | CBSeqAli: TComboBox; |
||
86 | CBRation: TComboBox; |
||
87 | CBSexe: TComboBox; |
||
88 | LigneRation: TLineSeries; |
||
89 | BarreRation: TBarSeries; |
||
90 | GBSimul: TGroupBox; |
||
91 | ASQLite3DBInraPorc: TASQLite3DB; |
||
92 | ASQLite3TableObservProfilP: TASQLite3Table; |
||
93 | ASQLite3TableObservProfilPProfile: TIntegerField; |
||
94 | ASQLite3TableObservProfilPLine: TIntegerField; |
||
95 | ASQLite3TableObservProfilPAge: TIntegerField; |
||
96 | ASQLite3TableObservProfilPFeed: TFloatField; |
||
97 | ASQLite3TableObservProfilPWeight: TFloatField; |
||
98 | ASQLite3TableObservProfilPBackfat: TFloatField; |
||
99 | ASQLite3TableObservProfilPLean: TFloatField; |
||
100 | ASQLite3QueryCreate: TASQLite3Query; |
||
101 | SBCalibrage: TSpeedButton; |
||
102 | GBParameters: TGroupBox; |
||
103 | PResults: TPanel; |
||
104 | SGResult: TStringGrid; |
||
105 | CBGraphYU: TComboBox; |
||
106 | procedure FormShow(Sender: TObject);
|
||
107 | procedure FormClose(Sender: TObject; var Action: TCloseAction); |
||
108 | procedure CBProfilChange(Sender: TObject);
|
||
109 | procedure SBAddProfilClick(Sender: TObject);
|
||
110 | procedure SBDelProfilClick(Sender: TObject);
|
||
111 | procedure PCChange(Sender: TObject);
|
||
112 | procedure CBUniteChange(Sender: TObject);
|
||
113 | procedure CBEquationChange(Sender: TObject);
|
||
114 | procedure RBCoefClick(Sender: TObject);
|
||
115 | procedure PBCoefAChange(Sender: TObject);
|
||
116 | procedure PBCoefBChange(Sender: TObject);
|
||
117 | procedure PBIng50Change(Sender: TObject);
|
||
118 | procedure PBIng100Change(Sender: TObject);
|
||
119 | procedure PBAgeInitChange(Sender: TObject);
|
||
120 | procedure PBPVInitChange(Sender: TObject);
|
||
121 | procedure RBProtLipClick(Sender: TObject);
|
||
122 | procedure PBProtInitChange(Sender: TObject);
|
||
123 | procedure PBLipInitChange(Sender: TObject);
|
||
124 | procedure RBFinClick(Sender: TObject);
|
||
125 | procedure PBDureeChange(Sender: TObject);
|
||
126 | procedure PBPVFinChange(Sender: TObject);
|
||
127 | procedure PBCarcasseChange(Sender: TObject);
|
||
128 | procedure PBPDMoyChange(Sender: TObject);
|
||
129 | procedure PBComportChange(Sender: TObject);
|
||
130 | procedure PBEntretienChange(Sender: TObject);
|
||
131 | procedure PBPVmr2Change(Sender: TObject);
|
||
132 | procedure SBGraph3DClick(Sender: TObject);
|
||
133 | procedure CBSeqAliChange(Sender: TObject);
|
||
134 | procedure FormActivate(Sender: TObject);
|
||
135 | procedure FormDeactivate(Sender: TObject);
|
||
136 | procedure SGResultDrawCell(Sender: TObject; ACol, ARow: Integer;
|
||
137 | Rect: TRect; State: TGridDrawState); |
||
138 | procedure SBRenameClick(Sender: TObject);
|
||
139 | procedure SBCommentClick(Sender: TObject);
|
||
140 | procedure SGResultMouseMove(Sender: TObject; Shift: TShiftState; X,
|
||
141 | Y: Integer); |
||
142 | procedure CBGraphTChange(Sender: TObject);
|
||
143 | procedure SBSaveClick(Sender: TObject);
|
||
144 | procedure SBPrintClick(Sender: TObject);
|
||
145 | procedure FormCreate(Sender: TObject);
|
||
146 | procedure CBSexeChange(Sender: TObject);
|
||
147 | procedure CBRationChange(Sender: TObject);
|
||
148 | procedure SBCalibrageClick(Sender: TObject);
|
||
149 | procedure CBGraphYUChange(Sender: TObject);
|
||
150 | procedure CBGraphXPChange(Sender: TObject);
|
||
151 | procedure CBGraphXDChange(Sender: TObject);
|
||
152 | procedure CBGraphYPChange(Sender: TObject);
|
||
153 | procedure CBGraphYDChange(Sender: TObject);
|
||
154 | private
|
||
155 | { D?clarations priv?es }
|
||
156 | Update, Modified, Modal: boolean; |
||
157 | IdxProfilP: integer; |
||
158 | RCStd: double; // rendement carcasse standardis? (t?te, pieds et queue)
|
||
159 | PResAdLib, PResRestrict: PTabResSimulP; |
||
160 | Tab: array[1..8, 1..2] of double; |
||
161 | procedure Save;
|
||
162 | procedure AffGraph;
|
||
163 | procedure AffLigne(PResSimul: PTabResSimulP; Serie: TLineSeries);
|
||
164 | procedure AffBarre(PResSimul: PTabResSimulP; Serie: TBarSeries);
|
||
165 | procedure CalcTab(Ligne: Integer; PResSimul: PTabResSimulP);
|
||
166 | procedure AffTab;
|
||
167 | procedure SuperSpinDecimals(Field: TPBSuperSpin; Count: Shortint);
|
||
168 | public
|
||
169 | { D?clarations publiques }
|
||
170 | end;
|
||
171 | |||
172 | var
|
||
173 | FProfilP: TFProfilP; |
||
174 | |||
175 | implementation
|
||
176 | |||
177 | uses
|
||
178 | Dialogs, Graphics, Math, SysUtils, gnugettext, UStrings, UInit, UUtil, |
||
179 | UFindRec, UCalcul, UEchelle, UFComment, UFWarning, UCalcSimulP, UFRapProfilP, |
||
180 | UFGraph3D, UFObservProfilP, UFCalibrProfilP; |
||
181 | |||
182 | {$R *.dfm}
|
||
183 | |||
184 | { TFProfilP }
|
||
185 | |||
186 | procedure TFProfilP.FormCreate(Sender: TObject);
|
||
187 | begin
|
||
188 | if Screen.Fonts.IndexOf('Arial Unicode MS') <> -1 |
||
189 | then
|
||
190 | Font.Name := 'Arial Unicode MS';
|
||
191 | TranslateComponent(Self); |
||
192 | Constraints.MinWidth := 776 + (Width - ClientWidth);
|
||
193 | Width := Constraints.MinWidth; |
||
194 | Constraints.MinHeight := 464 + (Height - ClientHeight);
|
||
195 | Height := Constraints.MinHeight; |
||
196 | ASQLite3DBInraPorc.DriverDLL := ExtractFilePath(Application.ExeName) + 'sqlite3.dll';
|
||
197 | ASQLite3DBInraPorc.DefaultDir := GetCurrentDir; |
||
198 | ASQLite3DBInraPorc.Database := 'InraPorc.sqb';
|
||
199 | if not FileExists(ASQLite3DBInraPorc.DriverDLL) |
||
200 | then // Erreur |
||
201 | MessageDlg(_('SQLite') + sLineBreak + Format(_('%s: driver missing'), [ASQLite3DBInraPorc.DriverDLL]), mtError, [mbOK], 0) |
||
202 | else
|
||
203 | if not FileExists(IncludeTrailingPathDelimiter(ASQLite3DBInraPorc.DefaultDir) + ASQLite3DBInraPorc.Database) |
||
204 | then // Cr?ation |
||
205 | with ASQLite3QueryCreate do |
||
206 | begin
|
||
207 | SQL.Clear; |
||
208 | SQL.Add('CREATE TABLE ObservProfilP (');
|
||
209 | SQL.Add(' Profile INTEGER,');
|
||
210 | SQL.Add(' Line INTEGER,');
|
||
211 | SQL.Add(' Age INTEGER,');
|
||
212 | SQL.Add(' Feed REAL,');
|
||
213 | SQL.Add(' Weight REAL,');
|
||
214 | SQL.Add(' Backfat REAL,');
|
||
215 | SQL.Add(' Lean REAL)');
|
||
216 | StartTransaction; |
||
217 | try
|
||
218 | ExecSQL; |
||
219 | Commit; |
||
220 | except
|
||
221 | RollBack; |
||
222 | end;
|
||
223 | Close; |
||
224 | SQL.Clear; |
||
225 | SQL.Add('CREATE INDEX IdxObservProfilP ON ObservProfilP (Profile, Line)');
|
||
226 | StartTransaction; |
||
227 | try
|
||
228 | ExecSQL; |
||
229 | Commit; |
||
230 | except
|
||
231 | RollBack; |
||
232 | end;
|
||
233 | Close; |
||
234 | end;
|
||
235 | CBGraphT.ItemIndex := 0;
|
||
236 | CBGraphXD.ItemIndex := XCrois; |
||
237 | CBGraphXP.ItemIndex := 1;
|
||
238 | CBGraphYD.ItemIndex := 0;
|
||
239 | CBGraphYP.ItemIndex := 0;
|
||
240 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('Weight gain'), _('g'), _('d')])); |
||
241 | CBGraphYU.Items.Add(Format('%s (%s)', [_('Body weight'), _('kg')])); |
||
242 | CBGraphYU.ItemIndex := 0;
|
||
243 | end;
|
||
244 | |||
245 | procedure TFProfilP.FormShow(Sender: TObject);
|
||
246 | begin
|
||
247 | Modified := False; |
||
248 | Modal := False; |
||
249 | ASQLite3DBInraPorc.Open; |
||
250 | ASQLite3TableObservProfilP.Open; |
||
251 | // Abscisses par d?faut
|
||
252 | CBGraphXD.ItemIndex := XCrois; |
||
253 | New(PResAdLib); |
||
254 | New(PResRestrict); |
||
255 | StringsProfilP(CBProfil.Items, True); |
||
256 | SBAddProfil.Enabled := IsComplete or (ListProfilP.Count < 5); |
||
257 | SBSave.Enabled := IsComplete or IsEducation;
|
||
258 | IdxProfilP := -1;
|
||
259 | // CBProfilChange(nil);
|
||
260 | end;
|
||
261 | |||
262 | procedure TFProfilP.FormClose(Sender: TObject; var Action: TCloseAction); |
||
263 | begin
|
||
264 | if Modified then Save; |
||
265 | Dispose(PResRestrict); |
||
266 | Dispose(PResAdLib); |
||
267 | Action := caFree; |
||
268 | NumWinProfilP := -1;
|
||
269 | ASQLite3TableObservProfilP.Close; |
||
270 | ASQLite3DBInraPorc.Close; |
||
271 | // Compacter la base
|
||
272 | with ASQLite3QueryCreate do |
||
273 | begin
|
||
274 | SQL.Clear; |
||
275 | SQL.Add('VACUUM');
|
||
276 | ExecSQL; |
||
277 | end;
|
||
278 | end;
|
||
279 | |||
280 | procedure TFProfilP.FormActivate(Sender: TObject);
|
||
281 | var
|
||
282 | i: integer; |
||
283 | begin
|
||
284 | if not Modal |
||
285 | then
|
||
286 | begin
|
||
287 | StringsSeqAliP(CBSeqAli.Items, False); |
||
288 | StringsRationP(CBRation.Items, False); |
||
289 | // if IdxProfilP <> -1
|
||
290 | // then
|
||
291 | // begin
|
||
292 | // PProfilP := ListProfilP[IdxProfilP] ;
|
||
293 | // with PProfilP^ do
|
||
294 | // if SeqAli <> -1
|
||
295 | // then
|
||
296 | // CBSeqAli.ItemIndex := CBSeqAli.Items.IndexOf (FindNomSeqAliP (SeqAli)) ;
|
||
297 | // end ;
|
||
298 | CBProfilChange(nil);
|
||
299 | for i := 0 to PC.PageCount - 1 do |
||
300 | PC.Pages[i].Enabled := IsComplete or IsEducation or IsEvaluation; |
||
301 | end;
|
||
302 | end;
|
||
303 | |||
304 | procedure TFProfilP.FormDeactivate(Sender: TObject);
|
||
305 | begin
|
||
306 | if Modified and not Modal then Save; |
||
307 | end;
|
||
308 | |||
309 | procedure TFProfilP.Save;
|
||
310 | var
|
||
311 | s: string;
|
||
312 | n: Integer; |
||
313 | begin
|
||
314 | Modified := False; |
||
315 | if IsComplete or IsEducation |
||
316 | then
|
||
317 | if MessageDlg (Caption + sLineBreak + MsgSave, mtConfirmation, [mbYes, mbNo], 0) = mrYes |
||
318 | then
|
||
319 | begin
|
||
320 | SaveProfilP; |
||
321 | if not ProfilPValid(PProfilP) |
||
322 | then
|
||
323 | MessageDlg(Format(MsgInvalidData, [Caption, PProfilP.Nom]), mtWarning, [mbOK], 0);
|
||
324 | end
|
||
325 | else
|
||
326 | begin
|
||
327 | n := PProfilP.Num; |
||
328 | LoadProfilP; |
||
329 | s := CBProfil.Text; |
||
330 | StringsProfilP(CBProfil.Items, True); |
||
331 | if FindIdxProfilP(s) = -1 |
||
332 | then
|
||
333 | begin
|
||
334 | IdxProfilP := -1;
|
||
335 | // Supprimer les observations
|
||
336 | with ASQLite3QueryCreate do |
||
337 | begin
|
||
338 | SQL.Clear; |
||
339 | SQL.Add(Format('DELETE FROM ObservProfilP WHERE Profile = ''%d''', [n]));
|
||
340 | StartTransaction; |
||
341 | try
|
||
342 | ExecSQL; |
||
343 | Commit; |
||
344 | except
|
||
345 | RollBack; |
||
346 | end;
|
||
347 | Close; |
||
348 | end;
|
||
349 | CBProfilChange(nil);
|
||
350 | end
|
||
351 | else
|
||
352 | CBProfil.ItemIndex := CBProfil.Items.IndexOf(s); |
||
353 | end;
|
||
354 | end;
|
||
355 | |||
356 | procedure TFProfilP.CBProfilChange(Sender: TObject);
|
||
357 | begin
|
||
358 | if (IdxProfilP <> -1) and (CBProfil.Text <> PProfilP.Nom) |
||
359 | then
|
||
360 | if Modified then Save; |
||
361 | IdxProfilP := FindIdxProfilP(CBProfil.Text); |
||
362 | if IdxProfilP = -1 |
||
363 | then // Pas d'enregistrement |
||
364 | begin
|
||
365 | CBProfil.Repaint; |
||
366 | SBDelProfil.Enabled := False; |
||
367 | SBRename.Enabled := False; |
||
368 | SBComment.Enabled := False; |
||
369 | SBSave.Enabled := False; |
||
370 | SBPrint.Enabled := False; |
||
371 | PC.ActivePageIndex := 0;
|
||
372 | PC.Visible := False; |
||
373 | if not ASQLite3TableObservProfilP.Active then ASQLite3TableObservProfilP.Open; |
||
374 | ASQLite3TableObservProfilP.Filtered := False; |
||
375 | ASQLite3TableObservProfilP.Filter := '';
|
||
376 | ASQLite3TableObservProfilP.Refresh; |
||
377 | end
|
||
378 | else // Affichage de l'enregistrement |
||
379 | begin
|
||
380 | SBDelProfil.Enabled := True; |
||
381 | SBRename.Enabled := True; |
||
382 | SBComment.Enabled := True; |
||
383 | SBSave.Enabled := True; |
||
384 | SBPrint.Enabled := True; |
||
385 | PC.Visible := True; |
||
386 | PProfilP := ListProfilP[IdxProfilP]; |
||
387 | with PProfilP^ do |
||
388 | begin
|
||
389 | if not ASQLite3TableObservProfilP.Active then ASQLite3TableObservProfilP.Open; |
||
390 | ASQLite3TableObservProfilP.Filter := Format('Profile = %d', [Num]);
|
||
391 | ASQLite3TableObservProfilP.Filtered := True; |
||
392 | ASQLite3TableObservProfilP.Refresh; |
||
393 | Update := True; |
||
394 | CBProfil.Hint := Memo; |
||
395 | // Conditions d'?levage
|
||
396 | CBSexe.ItemIndex := Sexe; |
||
397 | if SeqAli = -1 |
||
398 | then
|
||
399 | CBSeqAli.ItemIndex := -1
|
||
400 | else
|
||
401 | CBSeqAli.ItemIndex := CBSeqAli.Items.IndexOf(FindNomSeqAliP(SeqAli)); |
||
402 | if CBSeqAli.ItemIndex = -1 |
||
403 | then
|
||
404 | CBSeqAli.Hint := ''
|
||
405 | else
|
||
406 | begin
|
||
407 | PSeqAliP := ListSeqAliP[FindIdxSeqAliP(CBSeqAli.Text)]; |
||
408 | CBSeqAli.Hint := PSeqAliP.Memo; |
||
409 | end;
|
||
410 | if Ration = -1 |
||
411 | then
|
||
412 | CBRation.ItemIndex := -1
|
||
413 | else
|
||
414 | CBRation.ItemIndex := CBRation.Items.IndexOf(FindNomRationP(Ration)); |
||
415 | if CBRation.ItemIndex = -1 |
||
416 | then
|
||
417 | CBRation.Hint := ''
|
||
418 | else
|
||
419 | begin
|
||
420 | PRationP := ListRationP[FindIdxRationP(CBRation.Text)]; |
||
421 | CBRation.Hint := PRationP.Memo; |
||
422 | end;
|
||
423 | PBAgeInit.AsInteger := AgeInit; |
||
424 | PBPVInit.AsFloat := PVInit; |
||
425 | PBProtInit.MinValue := 0;
|
||
426 | PBProtInit.MaxValue := 0;
|
||
427 | PBProtInit.AsFloat := ProtInit; |
||
428 | PBProtInit.MaxValue := 0.18 * CalcPVV(PVInit);
|
||
429 | PBProtInit.MinValue := 0.14 * CalcPVV(PVInit);
|
||
430 | PBLipInit.MinValue := 0;
|
||
431 | PBLipInit.MaxValue := 0;
|
||
432 | PBLipInit.AsFloat := LipInit; |
||
433 | PBLipInit.MaxValue := CalcLipProt(PVInit, PBProtInit.MinValue); |
||
434 | PBLipInit.MinValue := CalcLipProt(PVInit, PBProtInit.MaxValue); |
||
435 | if ModeFin = 0 |
||
436 | then // Dur?e |
||
437 | RBFinDuree.Checked := True |
||
438 | else // poids vif |
||
439 | RBFinPoids.Checked := True; |
||
440 | PBDuree.AsInteger := Duree ; |
||
441 | PBPVFin.MinValue := PBPVInit.AsFloat; |
||
442 | PBPVFin.AsFloat := PVFin; |
||
443 | PBCarcasse.AsFloat := Carcasse * 100;
|
||
444 | // Consommation et performances AdLib
|
||
445 | CBUnite.ItemIndex := Unite; |
||
446 | CBUniteChange(nil);
|
||
447 | CBEquation.ItemIndex := Equation; |
||
448 | CBEquationChange(nil);
|
||
449 | PBCoefA.AsFloat := a; |
||
450 | PBCoefB.AsFloat := b; |
||
451 | PBIng50.AsFloat := CalcIngere(Equation, Unite, a, b, 50);
|
||
452 | PBIng100.AsFloat := CalcIngere(Equation, Unite, a, b, 100);
|
||
453 | PBPDMoy.AsFloat := PDMoy; |
||
454 | PBComport.AsFloat := BGompertz; |
||
455 | PBEntretien.AsFloat := Entretien; |
||
456 | // R?ponse ? une restriction alimentaire
|
||
457 | PBPVmr2.AsFloat := PVmr2; |
||
458 | Update := False; |
||
459 | PCChange(nil);
|
||
460 | end;
|
||
461 | end;
|
||
462 | end;
|
||
463 | |||
464 | procedure TFProfilP.SBAddProfilClick (Sender : TObject) ;
|
||
465 | var
|
||
466 | i, n, q : integer ; |
||
467 | s : string ;
|
||
468 | ok : boolean ; |
||
469 | PBackup : PRecProfilP ; |
||
470 | begin
|
||
471 | if Modified then Save ; |
||
472 | if IdxProfilP = -1 |
||
473 | then
|
||
474 | q := mrNo |
||
475 | else
|
||
476 | q := MessageDlg (MsgCopy, mtConfirmation, [mbYes, mbNo], 0) ;
|
||
477 | // saisie du nouveau nom
|
||
478 | s := '' ;
|
||
479 | repeat
|
||
480 | if InputQuery (FProfilP.Caption, MsgName, s)
|
||
481 | then // V?rification du nom |
||
482 | begin
|
||
483 | s := Trim (s) ; // Suppression des espaces au d?but et ? la fin
|
||
484 | if s = '' |
||
485 | then // Pas de nom |
||
486 | begin
|
||
487 | ok := FALSE ; |
||
488 | MessageDlg (MsgNameEmpty, mtWarning, [mbOk], 0) ;
|
||
489 | end
|
||
490 | else
|
||
491 | if Length (s) > 25 |
||
492 | then // Nom trop long |
||
493 | begin
|
||
494 | ok := FALSE ; |
||
495 | MessageDlg (Format (MsgNameTooLarge, [25]), mtWarning, [mbOk], 0) ; |
||
496 | s := Copy (s, 1, 25) ; |
||
497 | end
|
||
498 | else
|
||
499 | begin
|
||
500 | ok := TRUE ; |
||
501 | i := 0 ;
|
||
502 | while ok and (i < ListProfilP.Count) do |
||
503 | begin
|
||
504 | PProfilP := ListProfilP[i] ; |
||
505 | if PProfilP.Nom = s
|
||
506 | then // Nom d?j? utilis? |
||
507 | begin
|
||
508 | ok := FALSE ; |
||
509 | MessageDlg (MsgNameExists, mtWarning, [mbOk], 0) ;
|
||
510 | end
|
||
511 | else
|
||
512 | Inc (i) ; |
||
513 | end ;
|
||
514 | end ;
|
||
515 | end
|
||
516 | else // Annulation |
||
517 | begin
|
||
518 | s := '' ;
|
||
519 | if (IdxProfilP <> -1) |
||
520 | then
|
||
521 | PProfilP := ListProfilP[IdxProfilP] ; |
||
522 | ok := TRUE ; |
||
523 | end ;
|
||
524 | until ok ;
|
||
525 | if s <> '' |
||
526 | then // Cr?ation du nouvel enregistrement |
||
527 | begin
|
||
528 | // recherche du premier num?ro libre
|
||
529 | n := 0 ;
|
||
530 | repeat
|
||
531 | Inc (n) ; |
||
532 | ok := TRUE ; |
||
533 | i := 0 ;
|
||
534 | while ok and (i < ListProfilP.Count) do |
||
535 | begin
|
||
536 | PProfilP := ListProfilP[i] ; |
||
537 | if PProfilP.Num = n
|
||
538 | then
|
||
539 | ok := FALSE |
||
540 | else
|
||
541 | Inc (i) ; |
||
542 | end ;
|
||
543 | until ok ;
|
||
544 | New (PProfilP) ; |
||
545 | with PProfilP^ do |
||
546 | begin
|
||
547 | Nom := s ; |
||
548 | Num := n ; |
||
549 | if q = mrYes
|
||
550 | then
|
||
551 | begin
|
||
552 | PBackup := ListProfilP[IdxProfilP] ; |
||
553 | Memo := PBackup.Memo ; |
||
554 | Sexe := PBackup.Sexe; |
||
555 | // Conditions d'?levage
|
||
556 | SeqAli := PBackup.SeqAli ; |
||
557 | Ration := PBackup.Ration; |
||
558 | AgeInit := PBackup.AgeInit ; |
||
559 | PVInit := PBackup.PVInit ; |
||
560 | ProtInit := PBackup.ProtInit; |
||
561 | LipInit := PBackup.LipInit; |
||
562 | ModeFin := PBackup.ModeFin ; |
||
563 | Duree := PBackup.Duree ; |
||
564 | PVFin := PBackup.PVFin ; |
||
565 | Carcasse := PBackup.Carcasse ; |
||
566 | // Consommation et performances ad libitum
|
||
567 | Unite := PBackup.Unite ; |
||
568 | Equation := PBackup.Equation ; |
||
569 | a := PBackup.a; |
||
570 | b := PBackup.b; |
||
571 | PDMoy := PBackup.PDMoy ; |
||
572 | BGompertz := PBackup.BGompertz ; |
||
573 | Entretien := PBackup.Entretien ; |
||
574 | // R?ponse ? une restriction alimentaire
|
||
575 | PVmr2 := PBackup.PVmr2 ; |
||
576 | end
|
||
577 | else
|
||
578 | begin
|
||
579 | Memo := '' ;
|
||
580 | Sexe := -1;
|
||
581 | // Conditions d'?levage
|
||
582 | SeqAli := -1 ;
|
||
583 | Ration := -1;
|
||
584 | AgeInit := 60 ;
|
||
585 | PVInit := 25 ;
|
||
586 | ProtInit := CalcProt(PVInit); |
||
587 | LipInit := CalcLipProt(PVInit, ProtInit); |
||
588 | ModeFin := 0 ;
|
||
589 | Duree := 100 ;
|
||
590 | PVFin := 120 ;
|
||
591 | Carcasse := 0.79 ;
|
||
592 | // Consommation et performances ad libitum
|
||
593 | Unite := 0 ;
|
||
594 | Equation := 1 ;
|
||
595 | a := 0.203;
|
||
596 | b := 0.5850;
|
||
597 | PDMoy := 150 ;
|
||
598 | BGompertz := 0.014 ;
|
||
599 | Entretien := 1 ;
|
||
600 | // R?ponse ? une restriction alimentaire
|
||
601 | PVmr2 := 70 ;
|
||
602 | end ;
|
||
603 | end ;
|
||
604 | ListProfilP.Add (PProfilP) ; |
||
605 | CBProfil.Items.Add (PProfilP.Nom) ; |
||
606 | CBProfil.ItemIndex := CBProfil.Items.IndexOf (PProfilP.Nom) ; |
||
607 | CBProfilChange (nil) ;
|
||
608 | Modified := TRUE ; |
||
609 | SBAddProfil.Enabled := IsComplete or (ListProfilP.Count < 5) ; |
||
610 | SBCommentClick (nil) ;
|
||
611 | end ;
|
||
612 | end ;
|
||
613 | |||
614 | procedure TFProfilP.SBDelProfilClick(Sender: TObject);
|
||
615 | begin
|
||
616 | if ProfilPUsed (PProfilP.Num)
|
||
617 | then // Enregistrement utilis? |
||
618 | MessageDlg (MsgDelErr, mtWarning, [mbOk], 0)
|
||
619 | else // Suppression de l'enregistrement |
||
620 | if MessageDlg(MsgDel, mtConfirmation, [mbYes, mbNo], 0) = mrYes |
||
621 | then
|
||
622 | begin
|
||
623 | // Supprimer les observations
|
||
624 | with ASQLite3QueryCreate do |
||
625 | begin
|
||
626 | SQL.Clear; |
||
627 | SQL.Add(Format('DELETE FROM ObservProfilP WHERE Profile = ''%d''', [PProfilP.Num]));
|
||
628 | StartTransaction; |
||
629 | try
|
||
630 | ExecSQL; |
||
631 | Commit; |
||
632 | except
|
||
633 | RollBack; |
||
634 | end;
|
||
635 | Close; |
||
636 | end;
|
||
637 | // Supprimer le profil
|
||
638 | Dispose(PProfilP); |
||
639 | ListProfilP.Delete(IdxProfilP); |
||
640 | SaveProfilP; // Sauvegarde !
|
||
641 | Modified := FALSE; |
||
642 | CBProfil.DeleteSelected; |
||
643 | IdxProfilP := -1;
|
||
644 | CBProfil.ItemIndex := -1;
|
||
645 | CBProfilChange(nil);
|
||
646 | SBAddProfil.Enabled := IsComplete or (ListProfilP.Count < 5); |
||
647 | end;
|
||
648 | end;
|
||
649 | |||
650 | procedure TFProfilP.SBRenameClick (Sender : TObject) ;
|
||
651 | var
|
||
652 | i : integer ; |
||
653 | s : string ;
|
||
654 | ok : boolean ; |
||
655 | begin
|
||
656 | // Saisie du nouveau nom
|
||
657 | s := CBProfil.Text ; |
||
658 | repeat
|
||
659 | if InputQuery (FProfilP.Caption, MsgRename, s) and (s <> CBProfil.Text) |
||
660 | then // V?rification du nom |
||
661 | begin
|
||
662 | s := Trim (s) ; // Suppression des espaces au d?but et ? la fin
|
||
663 | if s = '' |
||
664 | then // Pas de nom |
||
665 | begin
|
||
666 | ok := FALSE ; |
||
667 | MessageDlg (MsgNameEmpty, mtWarning, [mbOk], 0) ;
|
||
668 | end
|
||
669 | else
|
||
670 | if Length (s) > 25 |
||
671 | then // Nom trop long |
||
672 | begin
|
||
673 | ok := FALSE ; |
||
674 | MessageDlg (Format (MsgNameTooLarge, [25]), mtWarning, [mbOk], 0) ; |
||
675 | s := Copy (s, 1, 25) ; |
||
676 | end
|
||
677 | else
|
||
678 | begin
|
||
679 | ok := TRUE ; |
||
680 | i := 0 ;
|
||
681 | while ok and (i < ListProfilP.Count) do |
||
682 | begin
|
||
683 | PProfilP := ListProfilP[i] ; |
||
684 | if PProfilP.Nom = s
|
||
685 | then // Nom d?j? utilis? |
||
686 | begin
|
||
687 | ok := FALSE ; |
||
688 | MessageDlg (MsgNameExists, mtWarning, [mbOk], 0) ;
|
||
689 | end
|
||
690 | else
|
||
691 | Inc (i) ; |
||
692 | end ;
|
||
693 | end ;
|
||
694 | end
|
||
695 | else // Annulation |
||
696 | begin
|
||
697 | s := '' ;
|
||
698 | ok := TRUE ; |
||
699 | end ;
|
||
700 | until ok ;
|
||
701 | PProfilP := ListProfilP[IdxProfilP] ; |
||
702 | if s <> '' |
||
703 | then // Renommer l'enregistrement |
||
704 | begin
|
||
705 | PProfilP.Nom := s ; |
||
706 | Modified := TRUE ; |
||
707 | StringsProfilP (CBProfil.Items, TRUE) ; |
||
708 | CBProfil.ItemIndex := CBProfil.Items.IndexOf (s) ; |
||
709 | end ;
|
||
710 | end ;
|
||
711 | |||
712 | procedure TFProfilP.SBCommentClick (Sender : TObject) ;
|
||
713 | begin
|
||
714 | // Saisie du commentaire
|
||
715 | FComment := TFComment.Create (Self) ; |
||
716 | with FComment do |
||
717 | begin
|
||
718 | Memo.Text := PProfilP.Memo ; |
||
719 | if ShowModal = mrOk
|
||
720 | then // Commenter l'enregistrement |
||
721 | begin
|
||
722 | PProfilP.Memo := Memo.Text ; |
||
723 | Modified := TRUE ; |
||
724 | CBProfil.Hint := PProfilP.Memo ; |
||
725 | end ;
|
||
726 | Release ; |
||
727 | end ;
|
||
728 | end ;
|
||
729 | |||
730 | procedure TFProfilP.SBSaveClick(Sender: TObject);
|
||
731 | begin
|
||
732 | SaveProfilP ; |
||
733 | if not ProfilPValid (PProfilP) |
||
734 | then
|
||
735 | MessageDlg(Format (MsgInvalidData, [Caption, PProfilP.Nom]), mtWarning, [mbOK], 0) ;
|
||
736 | Modified := FALSE ; |
||
737 | end;
|
||
738 | |||
739 | procedure TFProfilP.SBPrintClick(Sender: TObject);
|
||
740 | begin
|
||
741 | FRapProfilP := TFRapProfilP.Create (Self) ; |
||
742 | FRapProfilP.QRRapport.PreviewModal ; |
||
743 | FRapProfilP.Release ; |
||
744 | end;
|
||
745 | |||
746 | procedure TFProfilP.PCChange(Sender: TObject);
|
||
747 | var
|
||
748 | i, j: integer; |
||
749 | begin
|
||
750 | if PC.ActivePageIndex = 1 |
||
751 | then // Graphiques et tableaux de r?sultats |
||
752 | begin
|
||
753 | for i := 1 to 8 do |
||
754 | for j := 1 to 2 do |
||
755 | Tab[i, j] := 0;
|
||
756 | for i := 1 to NB_COL_PORC do |
||
757 | for j := 1 to MAX_LIG_PORC do |
||
758 | PResAdLib.TabResult[i, j] := 0;
|
||
759 | PResAdLib.NbJSim := 0;
|
||
760 | for i := 1 to NB_COL_PORC do |
||
761 | for j := 1 to MAX_LIG_PORC do |
||
762 | PResRestrict.TabResult[i, j] := 0;
|
||
763 | PResRestrict.NbJSim := 0;
|
||
764 | LigneAdLib.Clear; |
||
765 | LigneRation.Clear; |
||
766 | BarreAdLib.Clear; |
||
767 | BarreRation.Clear; |
||
768 | SBCalibrage.Enabled := False; |
||
769 | SBGraph3D.Enabled := False; |
||
770 | if ProfilPValid(PProfilP)
|
||
771 | then
|
||
772 | begin
|
||
773 | if PProfilP.SeqAli <> -1 |
||
774 | then
|
||
775 | begin
|
||
776 | PSeqAliP := ListSeqAliP[FindIdxSeqAliP(FindNomSeqAliP(PProfilP.SeqAli))]; |
||
777 | if SeqAliPValid(PSeqAliP)
|
||
778 | then
|
||
779 | begin
|
||
780 | Screen.Cursor := crHourGlass; |
||
781 | try
|
||
782 | CalcSimulP(-1, PProfilP.Num, PProfilP.SeqAli, -1, -1, 1, PResAdLib); |
||
783 | if PProfilP.ModeFin = 0 |
||
784 | then // Dur?e |
||
785 | PProfilP.PVFin := PResAdLib.TabResult[2, PResAdLib.NbJSim];
|
||
786 | CalcTab(1, PResAdLib);
|
||
787 | finally
|
||
788 | Screen.Cursor := crDefault; |
||
789 | end;
|
||
790 | if PProfilP.Ration <> -1 |
||
791 | then
|
||
792 | begin
|
||
793 | PRationP := ListRationP[FindIdxRationP(FindNomRationP(PProfilP.Ration))]; |
||
794 | if RationPValid(PRationP)
|
||
795 | then
|
||
796 | begin
|
||
797 | SBCalibrage.Enabled := True; |
||
798 | SBGraph3D.Enabled := True; |
||
799 | Screen.Cursor := crHourGlass; |
||
800 | try
|
||
801 | CalcSimulP(-1, PProfilP.Num, PProfilP.SeqAli, PProfilP.Ration, -1, 1, PResRestrict); |
||
802 | if PProfilP.ModeFin = 0 |
||
803 | then // Dur?e |
||
804 | PProfilP.PVFin := PResRestrict.TabResult[2, PResRestrict.NbJSim];
|
||
805 | CalcTab(2, PResRestrict);
|
||
806 | finally
|
||
807 | Screen.Cursor := crDefault; |
||
808 | end;
|
||
809 | end;
|
||
810 | end;
|
||
811 | if PProfilP.ModeFin = 0 |
||
812 | then // Dur?e |
||
813 | begin
|
||
814 | Update := True; |
||
815 | PBPVFin.AsFloat := PProfilP.PVFin; |
||
816 | Update := False; |
||
817 | end;
|
||
818 | RCStd := CalcRCStd(PProfilP.PVFin, PProfilP.Carcasse); |
||
819 | end;
|
||
820 | end;
|
||
821 | end;
|
||
822 | AffTab; |
||
823 | AffGraph; |
||
824 | end;
|
||
825 | end;
|
||
826 | |||
827 | // Conditions d'?levage
|
||
828 | |||
829 | procedure TFProfilP.CBSexeChange(Sender: TObject);
|
||
830 | begin
|
||
831 | if not Update |
||
832 | then
|
||
833 | begin
|
||
834 | Modified := True; |
||
835 | PProfilP.Sexe := CBSexe.ItemIndex; |
||
836 | end;
|
||
837 | end;
|
||
838 | |||
839 | procedure TFProfilP.PBAgeInitChange(Sender: TObject);
|
||
840 | begin
|
||
841 | if not Update and (PBAgeInit.AsInteger >= PBAgeInit.MinValue) |
||
842 | then
|
||
843 | begin
|
||
844 | Modified := True; |
||
845 | PProfilP.AgeInit := PBAgeInit.AsInteger; |
||
846 | end;
|
||
847 | end;
|
||
848 | |||
849 | procedure TFProfilP.PBPVInitChange(Sender: TObject);
|
||
850 | begin
|
||
851 | if not Update and (PBPVInit.AsFloat >= PBPVInit.MinValue) |
||
852 | then
|
||
853 | begin
|
||
854 | Modified := True; |
||
855 | PProfilP.PVInit := PBPVInit.AsFloat; |
||
856 | PProfilP.ProtInit := CalcProt(PProfilP.PVInit); |
||
857 | PProfilP.LipInit := CalcLipProt(PProfilP.PVInit, PProfilP.ProtInit); |
||
858 | Update := True; |
||
859 | PBProtInit.MinValue := 0;
|
||
860 | PBProtInit.MaxValue := 0;
|
||
861 | PBProtInit.AsFloat := PProfilP.ProtInit; |
||
862 | PBProtInit.MaxValue := 0.18 * CalcPVV(PProfilP.PVInit);
|
||
863 | PBProtInit.MinValue := 0.14 * CalcPVV(PProfilP.PVInit);
|
||
864 | PBLipInit.MinValue := 0;
|
||
865 | PBLipInit.MaxValue := 0;
|
||
866 | PBLipInit.AsFloat := PProfilP.LipInit; |
||
867 | PBLipInit.MaxValue := CalcLipProt(PProfilP.PVInit, PBProtInit.MinValue); |
||
868 | PBLipInit.MinValue := CalcLipProt(PProfilP.PVInit, PBProtInit.MaxValue); |
||
869 | PBPVFin.MinValue := PProfilP.PVInit; |
||
870 | Update := False; |
||
871 | end;
|
||
872 | end;
|
||
873 | |||
874 | procedure TFProfilP.RBProtLipClick(Sender: TObject);
|
||
875 | begin
|
||
876 | PBProtInit.Enabled := RBProt.Checked; |
||
877 | PBLipInit.Enabled := RBLip.Checked; |
||
878 | end;
|
||
879 | |||
880 | procedure TFProfilP.PBProtInitChange(Sender: TObject);
|
||
881 | begin
|
||
882 | if not Update and (PBProtInit.AsFloat >= PBProtInit.MinValue) |
||
883 | then
|
||
884 | begin
|
||
885 | Modified := True; |
||
886 | PProfilP.ProtInit := PBProtInit.AsFloat; |
||
887 | PProfilP.LipInit := CalcLipProt(PProfilP.PVInit, PProfilP.ProtInit); |
||
888 | Update := True; |
||
889 | PBLipInit.AsFloat := PProfilP.LipInit; |
||
890 | Update := False; |
||
891 | end;
|
||
892 | end;
|
||
893 | |||
894 | procedure TFProfilP.PBLipInitChange(Sender: TObject);
|
||
895 | begin
|
||
896 | if not Update and (PBLipInit.AsFloat >= PBLipInit.MinValue) |
||
897 | then
|
||
898 | begin
|
||
899 | Modified := True; |
||
900 | PProfilP.LipInit := PBLipInit.AsFloat; |
||
901 | PProfilP.ProtInit := CalcProtLip(PProfilP.PVInit, PProfilP.LipInit); |
||
902 | Update := True; |
||
903 | PBProtInit.AsFloat := PProfilP.ProtInit; |
||
904 | Update := False; |
||
905 | end;
|
||
906 | end;
|
||
907 | |||
908 | procedure TFProfilP.RBFinClick(Sender: TObject);
|
||
909 | begin
|
||
910 | PBDuree.Enabled := RBFinDuree.Checked; |
||
911 | PBPVFin.Enabled := RBFinPoids.Checked; |
||
912 | if not Update |
||
913 | then
|
||
914 | begin
|
||
915 | Modified := True; |
||
916 | if RBFinDuree.Checked
|
||
917 | then // Dur?e |
||
918 | PProfilP.ModeFin := 0
|
||
919 | else // Poids vif |
||
920 | PProfilP.ModeFin := 1;
|
||
921 | end;
|
||
922 | end;
|
||
923 | |||
924 | procedure TFProfilP.PBDureeChange(Sender: TObject);
|
||
925 | begin
|
||
926 | if not Update and (PBDuree.AsFloat > 1) |
||
927 | then
|
||
928 | begin
|
||
929 | Modified := True; |
||
930 | PProfilP.Duree := PBDuree.AsInteger; |
||
931 | end;
|
||
932 | end;
|
||
933 | |||
934 | procedure TFProfilP.PBPVFinChange(Sender: TObject);
|
||
935 | begin
|
||
936 | if not Update and (PBPVFin.AsFloat > PBPVInit.AsFloat) |
||
937 | then
|
||
938 | begin
|
||
939 | Modified := True; |
||
940 | PProfilP.PVFin := PBPVFin.AsFloat; |
||
941 | end;
|
||
942 | end;
|
||
943 | |||
944 | procedure TFProfilP.PBCarcasseChange(Sender: TObject);
|
||
945 | begin
|
||
946 | if not Update and (PBCarcasse.AsFloat >= PBCarcasse.MinValue) |
||
947 | then
|
||
948 | begin
|
||
949 | Modified := True; |
||
950 | PProfilP.Carcasse := PBCarcasse.AsFloat / 100;
|
||
951 | end;
|
||
952 | end;
|
||
953 | |||
954 | // Consommation et performances ad libitum
|
||
955 | |||
956 | procedure TFProfilP.CBUniteChange(Sender: TObject);
|
||
957 | var
|
||
958 | etat: boolean; |
||
959 | d, m: Double; |
||
960 | begin
|
||
961 | etat := Update; |
||
962 | Update := True; |
||
963 | // Ajustement de la pr?cision de l'ing?r? ? 50 et 100 kg
|
||
964 | if (CBUnite.ItemIndex = 0) or (CBUnite.ItemIndex = 4) |
||
965 | then // kg (QI ou MS) |
||
966 | begin
|
||
967 | SuperSpinDecimals(PBIng50, 3);
|
||
968 | SuperSpinDecimals(PBIng100, 3);
|
||
969 | end
|
||
970 | else // MJ (ED, EM ou EN) |
||
971 | begin
|
||
972 | SuperSpinDecimals(PBIng50, 2);
|
||
973 | SuperSpinDecimals(PBIng100, 2);
|
||
974 | end ;
|
||
975 | Update := etat; |
||
976 | if not Update |
||
977 | then
|
||
978 | begin
|
||
979 | Update := True; |
||
980 | CBEquationChange(nil);
|
||
981 | Update := False; |
||
982 | // Ancienne unit? (diviseur)
|
||
983 | case PProfilP.Unite of |
||
984 | 0: // Quantit? (kg/j) |
||
985 | d := cGammaFrais; |
||
986 | 1: // ED (MJ/j) |
||
987 | d := cGammaED; |
||
988 | 2: // EM (MJ/j) |
||
989 | d := cGammaEM; |
||
990 | 3: // EN (MJ/j) |
||
991 | d := cGammaEN; |
||
992 | 4: // MS (kg/j) |
||
993 | d := cGammaMS; |
||
994 | else
|
||
995 | d := 1;
|
||
996 | end;
|
||
997 | // Nouvelle unit? (multiplicateur)
|
||
998 | case CBUnite.ItemIndex of |
||
999 | 0: // Quantit? (kg/j) |
||
1000 | m := cGammaFrais; |
||
1001 | 1: // ED (MJ/j) |
||
1002 | m := cGammaED; |
||
1003 | 2: // EM (MJ/j) |
||
1004 | m := cGammaEM; |
||
1005 | 3: // EN (MJ/j) |
||
1006 | m := cGammaEN; |
||
1007 | 4: // MS (kg/j) |
||
1008 | m := cGammaMS; |
||
1009 | else
|
||
1010 | m := 1;
|
||
1011 | end;
|
||
1012 | Modified := True; |
||
1013 | PProfilP.Unite := CBUnite.ItemIndex; |
||
1014 | if d <> m
|
||
1015 | then // Conversion |
||
1016 | begin
|
||
1017 | Update := True; |
||
1018 | RBIngere.Checked := True; |
||
1019 | PBIng50.AsFloat := m * PBIng50.AsFloat / d; |
||
1020 | PBIng100.AsFloat := m * PBIng100.AsFloat / d; |
||
1021 | with PProfilP^ do |
||
1022 | begin
|
||
1023 | CalcCoef(Equation, Unite, PBIng50.AsFloat, PBIng100.AsFloat, a, b); |
||
1024 | PBCoefA.AsFloat := a; |
||
1025 | PBCoefB.AsFloat := b; |
||
1026 | end;
|
||
1027 | Update := False; |
||
1028 | end;
|
||
1029 | PCChange(nil);
|
||
1030 | if AffUnitProfilP
|
||
1031 | then
|
||
1032 | begin
|
||
1033 | Modal := True; |
||
1034 | FWarning := TFWarning.Create(Self); |
||
1035 | with FWarning do |
||
1036 | begin
|
||
1037 | Msg := 'UnitProfilP';
|
||
1038 | ShowModal; |
||
1039 | Release; |
||
1040 | AffUnitProfilP := False; |
||
1041 | end;
|
||
1042 | Modal := False; |
||
1043 | end;
|
||
1044 | end;
|
||
1045 | end;
|
||
1046 | |||
1047 | procedure TFProfilP.CBEquationChange(Sender: TObject);
|
||
1048 | var
|
||
1049 | etat: boolean; |
||
1050 | begin
|
||
1051 | etat := Update; |
||
1052 | Update := True; |
||
1053 | // Ajustement de la pr?cision des coefficients a et b
|
||
1054 | case CBEquation.ItemIndex of |
||
1055 | 0: // a+b*PV |
||
1056 | if (CBUnite.ItemIndex = 0) or (CBUnite.ItemIndex = 4) |
||
1057 | then // kg (QI ou MS) |
||
1058 | begin
|
||
1059 | SuperSpinDecimals(PBCoefA, 3);
|
||
1060 | SuperSpinDecimals(PBCoefB, 3);
|
||
1061 | end
|
||
1062 | else // MJ (ED, EM ou EN) |
||
1063 | begin
|
||
1064 | SuperSpinDecimals(PBCoefA, 2);
|
||
1065 | SuperSpinDecimals(PBCoefB, 2);
|
||
1066 | end;
|
||
1067 | 1: // a*PV^b |
||
1068 | begin
|
||
1069 | if (CBUnite.ItemIndex = 0) or (CBUnite.ItemIndex = 4) |
||
1070 | then // kg (QI ou MS) |
||
1071 | SuperSpinDecimals(PBCoefA, 4)
|
||
1072 | else // MJ (ED, EM ou EN) |
||
1073 | SuperSpinDecimals(PBCoefA, 3);
|
||
1074 | SuperSpinDecimals(PBCoefB, 4);
|
||
1075 | end;
|
||
1076 | 2: // a*(1-exp(-b*PV)) |
||
1077 | begin
|
||
1078 | if (CBUnite.ItemIndex = 0) or (CBUnite.ItemIndex = 4) |
||
1079 | then // kg (QI ou MS) |
||
1080 | SuperSpinDecimals(PBCoefA, 3)
|
||
1081 | else // MJ (ED, EM ou EN) |
||
1082 | SuperSpinDecimals(PBCoefA, 2);
|
||
1083 | SuperSpinDecimals(PBCoefB, 5);
|
||
1084 | end;
|
||
1085 | 3: // Gamma(entretien) |
||
1086 | begin
|
||
1087 | SuperSpinDecimals(PBCoefA, 4);
|
||
1088 | SuperSpinDecimals(PBCoefB, 4);
|
||
1089 | end;
|
||
1090 | end;
|
||
1091 | Update := etat; |
||
1092 | if not Update |
||
1093 | then
|
||
1094 | begin
|
||
1095 | Modified := True; |
||
1096 | PProfilP.Equation := CBEquation.ItemIndex; |
||
1097 | Update := True; |
||
1098 | RBIngere.Checked := True; |
||
1099 | with PProfilP^ do |
||
1100 | begin
|
||
1101 | CalcCoef(Equation, Unite, PBIng50.AsFloat, PBIng100.AsFloat, a, b); |
||
1102 | PBCoefA.AsFloat := a; |
||
1103 | PBCoefB.AsFloat := b; |
||
1104 | end;
|
||
1105 | Update := False; |
||
1106 | PCChange(nil);
|
||
1107 | end;
|
||
1108 | end;
|
||
1109 | |||
1110 | procedure TFProfilP.RBCoefClick(Sender: TObject);
|
||
1111 | begin
|
||
1112 | PCoef.Enabled := RBCoef.Checked; |
||
1113 | PBCoefA.Enabled := RBCoef.Checked; |
||
1114 | PBCoefB.Enabled := RBCoef.Checked; |
||
1115 | PIngere.Enabled := RBIngere.Checked; |
||
1116 | PBIng50.Enabled := RBIngere.Checked; |
||
1117 | PBIng100.Enabled := RBIngere.Checked; |
||
1118 | end;
|
||
1119 | |||
1120 | procedure TFProfilP.PBCoefAChange(Sender: TObject);
|
||
1121 | begin
|
||
1122 | if not Update |
||
1123 | then
|
||
1124 | begin
|
||
1125 | Modified := True; |
||
1126 | PProfilP.a := PBCoefA.AsFloat; |
||
1127 | Update := True; |
||
1128 | with PProfilP^ do |
||
1129 | begin
|
||
1130 | PBIng50.AsFloat := CalcIngere(Equation, Unite, a, b, 50);
|
||
1131 | PBIng100.AsFloat := CalcIngere(Equation, Unite, a, b, 100);
|
||
1132 | end;
|
||
1133 | Update := False; |
||
1134 | PCChange(nil);
|
||
1135 | end;
|
||
1136 | end;
|
||
1137 | |||
1138 | procedure TFProfilP.PBCoefBChange(Sender: TObject);
|
||
1139 | begin
|
||
1140 | if not Update |
||
1141 | then
|
||
1142 | begin
|
||
1143 | Modified := True; |
||
1144 | PProfilP.b := PBCoefB.AsFloat; |
||
1145 | Update := True; |
||
1146 | with PProfilP^ do |
||
1147 | begin
|
||
1148 | PBIng50.AsFloat := CalcIngere(Equation, Unite, a, b, 50);
|
||
1149 | PBIng100.AsFloat := CalcIngere(Equation, Unite, a, b, 100);
|
||
1150 | end;
|
||
1151 | Update := False; |
||
1152 | PCChange(nil);
|
||
1153 | end;
|
||
1154 | end;
|
||
1155 | |||
1156 | procedure TFProfilP.PBIng50Change(Sender: TObject);
|
||
1157 | begin
|
||
1158 | if not Update |
||
1159 | then
|
||
1160 | begin
|
||
1161 | Modified := True; |
||
1162 | Update := True; |
||
1163 | with PProfilP^ do |
||
1164 | begin
|
||
1165 | CalcCoef(Equation, Unite, PBIng50.AsFloat, PBIng100.AsFloat, a, b); |
||
1166 | PBCoefA.AsFloat := a; |
||
1167 | PBCoefB.AsFloat := b; |
||
1168 | end;
|
||
1169 | Update := False; |
||
1170 | PCChange(nil);
|
||
1171 | end;
|
||
1172 | end;
|
||
1173 | |||
1174 | procedure TFProfilP.PBIng100Change(Sender: TObject);
|
||
1175 | begin
|
||
1176 | if not Update |
||
1177 | then
|
||
1178 | begin
|
||
1179 | Modified := True; |
||
1180 | Update := True; |
||
1181 | with PProfilP^ do |
||
1182 | begin
|
||
1183 | CalcCoef(Equation, Unite, PBIng50.AsFloat, PBIng100.AsFloat, a, b); |
||
1184 | PBCoefA.AsFloat := a; |
||
1185 | PBCoefB.AsFloat := b; |
||
1186 | end;
|
||
1187 | Update := False; |
||
1188 | PCChange(nil);
|
||
1189 | end;
|
||
1190 | end;
|
||
1191 | |||
1192 | procedure TFProfilP.PBPDMoyChange(Sender: TObject);
|
||
1193 | begin
|
||
1194 | if not Update and (PBPDMoy.AsFloat >= PBPDMoy.MinValue) |
||
1195 | then
|
||
1196 | begin
|
||
1197 | Modified := True; |
||
1198 | PProfilP.PDMoy := PBPDMoy.AsFloat; |
||
1199 | PCChange(nil);
|
||
1200 | if AffPDMoy
|
||
1201 | then
|
||
1202 | begin
|
||
1203 | Modal := True; |
||
1204 | FWarning := TFWarning.Create(Self); |
||
1205 | with FWarning do |
||
1206 | begin
|
||
1207 | Msg := 'PDMoy';
|
||
1208 | ShowModal; |
||
1209 | Release; |
||
1210 | AffPDMoy := False; |
||
1211 | end;
|
||
1212 | Modal := False; |
||
1213 | end;
|
||
1214 | end;
|
||
1215 | end;
|
||
1216 | |||
1217 | procedure TFProfilP.PBComportChange(Sender: TObject);
|
||
1218 | begin
|
||
1219 | if not Update and (PBComport.AsFloat >= PBComport.MinValue) |
||
1220 | then
|
||
1221 | begin
|
||
1222 | Modified := True; |
||
1223 | PProfilP.BGompertz := PBComport.AsFloat; |
||
1224 | PCChange(nil);
|
||
1225 | if AffPrecocite
|
||
1226 | then
|
||
1227 | begin
|
||
1228 | Modal := True; |
||
1229 | FWarning := TFWarning.Create(Self); |
||
1230 | with FWarning do |
||
1231 | begin
|
||
1232 | Msg := 'Precocite';
|
||
1233 | ShowModal; |
||
1234 | Release; |
||
1235 | AffPrecocite := False; |
||
1236 | end;
|
||
1237 | Modal := False; |
||
1238 | end;
|
||
1239 | end;
|
||
1240 | end;
|
||
1241 | |||
1242 | procedure TFProfilP.PBEntretienChange(Sender: TObject);
|
||
1243 | begin
|
||
1244 | if not Update and (PBEntretien.AsFloat >= PBEntretien.MinValue) |
||
1245 | then
|
||
1246 | begin
|
||
1247 | Modified := True; |
||
1248 | PProfilP.Entretien := PBEntretien.AsFloat; |
||
1249 | PCChange(nil);
|
||
1250 | if AffEntretien
|
||
1251 | then
|
||
1252 | begin
|
||
1253 | Modal := True; |
||
1254 | FWarning := TFWarning.Create(Self); |
||
1255 | with FWarning do |
||
1256 | begin
|
||
1257 | Msg := 'Entretien';
|
||
1258 | ShowModal; |
||
1259 | Release; |
||
1260 | AffEntretien := False; |
||
1261 | end;
|
||
1262 | Modal := False; |
||
1263 | end;
|
||
1264 | end;
|
||
1265 | end;
|
||
1266 | |||
1267 | procedure TFProfilP.CBSeqAliChange(Sender: TObject);
|
||
1268 | begin
|
||
1269 | PSeqAliP := ListSeqAliP[FindIdxSeqAliP(CBSeqAli.Text)]; |
||
1270 | CBSeqAli.Hint := PSeqAliP.Memo; |
||
1271 | if not Update |
||
1272 | then
|
||
1273 | begin
|
||
1274 | Modified := True; |
||
1275 | PProfilP.SeqAli := FindNumSeqAliP(CBSeqAli.Text); |
||
1276 | PCChange(nil);
|
||
1277 | end;
|
||
1278 | end;
|
||
1279 | |||
1280 | procedure TFProfilP.CBRationChange(Sender: TObject);
|
||
1281 | begin
|
||
1282 | PRationP := ListRationP[FindIdxRationP(CBRation.Text)]; |
||
1283 | CBRation.Hint := PRationP.Memo; |
||
1284 | if not Update |
||
1285 | then
|
||
1286 | begin
|
||
1287 | Modified := True; |
||
1288 | PProfilP.Ration := FindNumRationP(CBRation.Text); |
||
1289 | PCChange(nil);
|
||
1290 | end ;
|
||
1291 | end;
|
||
1292 | |||
1293 | procedure TFProfilP.PBPVmr2Change(Sender: TObject);
|
||
1294 | begin
|
||
1295 | if not Update and (PBPVmr2.AsFloat >= PBPVmr2.MinValue) |
||
1296 | then
|
||
1297 | begin
|
||
1298 | Modified := True; |
||
1299 | PProfilP.PVmr2 := PBPVmr2.AsFloat; |
||
1300 | PCChange(nil);
|
||
1301 | end;
|
||
1302 | end;
|
||
1303 | |||
1304 | procedure TFProfilP.SBGraph3DClick(Sender: TObject);
|
||
1305 | begin
|
||
1306 | Modal := True; |
||
1307 | FGraph3D := TFGraph3D.Create(Self); |
||
1308 | FGraph3D.ShowModal; |
||
1309 | if (PBCoefA.Text <> FGraph3D.SuperSpinA.Text)
|
||
1310 | or (PBCoefB.Text <> FGraph3D.SuperSpinB.Text)
|
||
1311 | or (PBPDMoy.Text <> FGraph3D.SuperSpinPDMoy.Text)
|
||
1312 | or (PBComport.Text <> FGraph3D.SuperSpinPrecocite.Text)
|
||
1313 | or (PBEntretien.Text <> FGraph3D.SuperSpinEntretien.Text)
|
||
1314 | or (PBPVmr2.Text <> FGraph3D.SuperSpinPVPDmax.Text)
|
||
1315 | then
|
||
1316 | if MessageDlg(MsgKeepValues, mtConfirmation, [mbYes, mbNo], 0) = mrYes |
||
1317 | then // Prise en compte des nouvelles valeurs du profil |
||
1318 | begin
|
||
1319 | Modified := True; |
||
1320 | Update := True; |
||
1321 | with PProfilP^ do |
||
1322 | begin
|
||
1323 | PBCoefA.AsFloat := a; |
||
1324 | PBCoefB.AsFloat := b; |
||
1325 | PBIng50.AsFloat := CalcIngere(Equation, Unite, a, b, 50);
|
||
1326 | PBIng100.AsFloat := CalcIngere(Equation, Unite, a, b, 100);
|
||
1327 | PBPDMoy.AsFloat := PDMoy; |
||
1328 | PBComport.AsFloat := BGompertz; |
||
1329 | PBEntretien.AsFloat := Entretien; |
||
1330 | PBPVmr2.AsFloat := PVmr2; |
||
1331 | end;
|
||
1332 | Update := False; |
||
1333 | end
|
||
1334 | else // Restauration des valeurs de l'enregistrement |
||
1335 | with PProfilP^ do |
||
1336 | begin
|
||
1337 | a := PBCoefA.AsFloat; |
||
1338 | b := PBCoefB.AsFloat; |
||
1339 | PDMoy := PBPDMoy.AsFloat; |
||
1340 | BGompertz := PBComport.AsFloat; |
||
1341 | Entretien := PBEntretien.AsFloat; |
||
1342 | PVmr2 := PBPVmr2.AsFloat; |
||
1343 | end;
|
||
1344 | FGraph3D.Release; |
||
1345 | Modal := False; |
||
1346 | end;
|
||
1347 | |||
1348 | procedure TFProfilP.SBCalibrageClick(Sender: TObject);
|
||
1349 | var
|
||
1350 | i: Integer; |
||
1351 | AdLib, Other: Boolean; |
||
1352 | begin
|
||
1353 | Modal := True; |
||
1354 | // Contr?ler le plan de rationnement
|
||
1355 | AdLib := False; |
||
1356 | Other := False; |
||
1357 | with PRationP^ do |
||
1358 | for i := 1 to NbRule do |
||
1359 | if Rule[i].RuleType = 0 |
||
1360 | then
|
||
1361 | AdLib := True |
||
1362 | else
|
||
1363 | Other := True; |
||
1364 | if not AdLib |
||
1365 | then // Il est n?cessaire d'avoir au moins une r?gle bas?e sur l'ad libitum |
||
1366 | MessageDlg(MsgCalibrAdLib, mtError, [mbOK], 0)
|
||
1367 | else
|
||
1368 | begin
|
||
1369 | if Other
|
||
1370 | then // Si une r?gle autre est pr?sente, afficher un avertissement |
||
1371 | MessageDlg(MsgCalibrOther, mtWarning, [mbOK], 0);
|
||
1372 | FObservProfilP := TFObservProfilP.Create(Self); |
||
1373 | ASQLite3TableObservProfilP.StartTransaction; |
||
1374 | if FObservProfilP.ShowModal = mrOK
|
||
1375 | then // Valider les observations |
||
1376 | begin
|
||
1377 | ASQLite3TableObservProfilP.Commit; |
||
1378 | FCalibrProfilP := TFCalibrProfilP.Create(Self); |
||
1379 | if FCalibrProfilP.ShowModal = mrOK
|
||
1380 | then
|
||
1381 | Modified := True; |
||
1382 | FCalibrProfilP.Release; |
||
1383 | CBProfilChange(nil);
|
||
1384 | end
|
||
1385 | else // Annuler les observations |
||
1386 | begin
|
||
1387 | ASQLite3TableObservProfilP.RollBack; |
||
1388 | ASQLite3TableObservProfilP.Refresh; |
||
1389 | end;
|
||
1390 | FObservProfilP.Release; |
||
1391 | end;
|
||
1392 | Modal := False; |
||
1393 | end;
|
||
1394 | |||
1395 | procedure TFProfilP.CBGraphTChange(Sender: TObject);
|
||
1396 | begin
|
||
1397 | CBGraphXD.Visible := CBGraphT.ItemIndex = 0;
|
||
1398 | CBGraphYD.Visible := CBGraphT.ItemIndex = 0;
|
||
1399 | CBGraphXP.Visible := CBGraphT.ItemIndex = 1;
|
||
1400 | CBGraphYP.Visible := CBGraphT.ItemIndex = 1;
|
||
1401 | if CBGraphYD.Visible then CBGraphYDChange(nil); |
||
1402 | if CBGraphYP.Visible then CBGraphYPChange(nil); |
||
1403 | end;
|
||
1404 | |||
1405 | procedure TFProfilP.CBGraphXDChange(Sender: TObject);
|
||
1406 | begin
|
||
1407 | AffGraph; |
||
1408 | end;
|
||
1409 | |||
1410 | procedure TFProfilP.CBGraphXPChange(Sender: TObject);
|
||
1411 | begin
|
||
1412 | AffGraph; |
||
1413 | end;
|
||
1414 | |||
1415 | procedure TFProfilP.CBGraphYDChange(Sender: TObject);
|
||
1416 | begin
|
||
1417 | CBGraphYU.Items.Clear; |
||
1418 | case CBGraphYD.ItemIndex of |
||
1419 | 0: // Body weight |
||
1420 | begin
|
||
1421 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('Weight gain'), _('g'), _('d')])); |
||
1422 | CBGraphYU.Items.Add(Format('%s (%s)', [_('Body weight'), _('kg')])); |
||
1423 | end;
|
||
1424 | 1: // Time |
||
1425 | CBGraphYU.Items.Add(Format('%s (%s)', [_('Age'), _('d')])); |
||
1426 | 2: // Feed usage |
||
1427 | begin
|
||
1428 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('Feed usage'), _('kg'), _('d')])); |
||
1429 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('Feed usage'), _('kg DM'), _('d')])); |
||
1430 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('Feed usage'), _('MJ DE'), _('d')])); |
||
1431 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('Feed usage'), _('MJ ME'), _('d')])); |
||
1432 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('Feed usage'), _('MJ NE'), _('d')])); |
||
1433 | CBGraphYU.Items.Add(Format('%s (%s)', [_('Total feed usage'), _('kg')])); |
||
1434 | CBGraphYU.Items.Add(Format('%s (%s)', [_('Total feed usage'), _('kg DM')])); |
||
1435 | CBGraphYU.Items.Add(Format('%s (%s)', [_('Total feed usage'), _('MJ DE')])); |
||
1436 | CBGraphYU.Items.Add(Format('%s (%s)', [_('Total feed usage'), _('MJ ME')])); |
||
1437 | CBGraphYU.Items.Add(Format('%s (%s)', [_('Total feed usage'), _('MJ NE')])); |
||
1438 | end;
|
||
1439 | 3: // Feed wastage |
||
1440 | begin
|
||
1441 | CBGraphYU.Items.Add(Format('%s (%%)', [_('Feed wastage')])); |
||
1442 | CBGraphYU.Items.Add(Format('%s (%s)', [_('Total feed wastage'), _('kg')])); |
||
1443 | end;
|
||
1444 | 4: // Feed intake |
||
1445 | begin
|
||
1446 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('Feed intake'), _('kg'), _('d')])); |
||
1447 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('Feed intake'), _('kg DM'), _('d')])); |
||
1448 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('Feed intake'), _('MJ DE'), _('d')])); |
||
1449 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('Feed intake'), _('MJ ME'), _('d')])); |
||
1450 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('Feed intake'), _('MJ NE'), _('d')])); |
||
1451 | CBGraphYU.Items.Add(Format('%s (%s)', [_('Total feed intake'), _('kg')])); |
||
1452 | CBGraphYU.Items.Add(Format('%s (%s)', [_('Total feed intake'), _('kg DM')])); |
||
1453 | CBGraphYU.Items.Add(Format('%s (%s)', [_('Total feed intake'), _('MJ DE')])); |
||
1454 | CBGraphYU.Items.Add(Format('%s (%s)', [_('Total feed intake'), _('MJ ME')])); |
||
1455 | CBGraphYU.Items.Add(Format('%s (%s)', [_('Total feed intake'), _('MJ NE')])); |
||
1456 | end;
|
||
1457 | 5: // Feed:Gain |
||
1458 | begin
|
||
1459 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('F:G'), _('kg'), _('kg')])); |
||
1460 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('F:G'), _('kg DM'), _('kg')])); |
||
1461 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('F:G'), _('MJ DE'), _('kg')])); |
||
1462 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('F:G'), _('MJ ME'), _('kg')])); |
||
1463 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('F:G'), _('MJ NE'), _('kg')])); |
||
1464 | end;
|
||
1465 | 6: // Gain:Feed |
||
1466 | begin
|
||
1467 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('G:F'), _('kg'), _('kg')])); |
||
1468 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('G:F'), _('kg'), _('kg DM')])); |
||
1469 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('G:F'), _('kg'), _('MJ DE')])); |
||
1470 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('G:F'), _('kg'), _('MJ ME')])); |
||
1471 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('G:F'), _('kg'), _('MJ NE')])); |
||
1472 | end;
|
||
1473 | 7: // Protein |
||
1474 | begin
|
||
1475 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('Protein deposition'), _('g'), _('d')])); |
||
1476 | CBGraphYU.Items.Add(Format('%s (%s)', [_('Protein mass'), _('kg')])); |
||
1477 | CBGraphYU.Items.Add(Format('%s (%s)', [_('Protein content'), _('% BW gain')])); |
||
1478 | CBGraphYU.Items.Add(Format('%s (%s)', [_('Protein content'), _('% BW')])); |
||
1479 | end;
|
||
1480 | 8: // Lipid |
||
1481 | begin
|
||
1482 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('Lipid deposition'), _('g'), _('d')])); |
||
1483 | CBGraphYU.Items.Add(Format('%s (%s)', [_('Lipid mass'), _('kg')])); |
||
1484 | CBGraphYU.Items.Add(Format('%s (%s)', [_('Lipid content'), _('% BW gain')])); |
||
1485 | CBGraphYU.Items.Add(Format('%s (%s)', [_('Lipid content'), _('% BW')])); |
||
1486 | end;
|
||
1487 | 9: // Carcass |
||
1488 | begin
|
||
1489 | CBGraphYU.Items.Add(_('Dressing percentage'));
|
||
1490 | if FatInfo = 0 |
||
1491 | then // P2 |
||
1492 | CBGraphYU.Items.Add(Format('%s (%s)', [_('Backfat thickness'), _('mm')])) |
||
1493 | else // User defined |
||
1494 | if Length(UserFatLongName) = 0 |
||
1495 | then
|
||
1496 | CBGraphYU.Items.Add(Format('%s (%s)', [_('User-defined backfat thickness'), _('mm')])) |
||
1497 | else
|
||
1498 | CBGraphYU.Items.Add(Format('%s (%s)', [UserFatLongName, _('mm')])); |
||
1499 | if LeanInfo = 0 |
||
1500 | then // TMP |
||
1501 | CBGraphYU.Items.Add(Format('%s (%%)', [_('Lean meat')])) |
||
1502 | else // User defined |
||
1503 | if Length(UserLeanLongName) = 0 |
||
1504 | then
|
||
1505 | CBGraphYU.Items.Add(Format('%s (%%)', [_('User-defined lean meat')])) |
||
1506 | else
|
||
1507 | CBGraphYU.Items.Add(Format('%s (%%)', [UserLeanLongName]));
|
||
1508 | end;
|
||
1509 | end;
|
||
1510 | CBGraphYU.ItemIndex := 0;
|
||
1511 | AffGraph; |
||
1512 | end;
|
||
1513 | |||
1514 | procedure TFProfilP.CBGraphYPChange(Sender: TObject);
|
||
1515 | begin
|
||
1516 | CBGraphYU.Items.Clear; |
||
1517 | case CBGraphYP.ItemIndex of |
||
1518 | 0: // Body weight |
||
1519 | begin
|
||
1520 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('Weight gain'), _('g'), _('d')])); |
||
1521 | CBGraphYU.Items.Add(Format('%s (%s)', [_('Weight gain'), _('kg')])); |
||
1522 | end;
|
||
1523 | 1: // Time |
||
1524 | CBGraphYU.Items.Add(Format('%s (%s)', [_('Duration'), _('d')])); |
||
1525 | 2: // Feed usage |
||
1526 | begin
|
||
1527 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('Feed usage'), _('kg'), _('d')])); |
||
1528 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('Feed usage'), _('kg DM'), _('d')])); |
||
1529 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('Feed usage'), _('MJ DE'), _('d')])); |
||
1530 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('Feed usage'), _('MJ ME'), _('d')])); |
||
1531 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('Feed usage'), _('MJ NE'), _('d')])); |
||
1532 | CBGraphYU.Items.Add(Format('%s (%s)', [_('Total feed usage'), _('kg')])); |
||
1533 | CBGraphYU.Items.Add(Format('%s (%s)', [_('Total feed usage'), _('kg DM')])); |
||
1534 | CBGraphYU.Items.Add(Format('%s (%s)', [_('Total feed usage'), _('MJ DE')])); |
||
1535 | CBGraphYU.Items.Add(Format('%s (%s)', [_('Total feed usage'), _('MJ ME')])); |
||
1536 | CBGraphYU.Items.Add(Format('%s (%s)', [_('Total feed usage'), _('MJ NE')])); |
||
1537 | end;
|
||
1538 | 3: // Feed wastage |
||
1539 | begin
|
||
1540 | CBGraphYU.Items.Add(Format('%s (%%)', [_('Feed wastage')])); |
||
1541 | CBGraphYU.Items.Add(Format('%s (%s)', [_('Total feed wastage'), _('kg')])); |
||
1542 | end;
|
||
1543 | 4: // Feed intake |
||
1544 | begin
|
||
1545 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('Feed intake'), _('kg'), _('d')])); |
||
1546 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('Feed intake'), _('kg DM'), _('d')])); |
||
1547 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('Feed intake'), _('MJ DE'), _('d')])); |
||
1548 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('Feed intake'), _('MJ ME'), _('d')])); |
||
1549 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('Feed intake'), _('MJ NE'), _('d')])); |
||
1550 | CBGraphYU.Items.Add(Format('%s (%s)', [_('Total feed intake'), _('kg')])); |
||
1551 | CBGraphYU.Items.Add(Format('%s (%s)', [_('Total feed intake'), _('kg DM')])); |
||
1552 | CBGraphYU.Items.Add(Format('%s (%s)', [_('Total feed intake'), _('MJ DE')])); |
||
1553 | CBGraphYU.Items.Add(Format('%s (%s)', [_('Total feed intake'), _('MJ ME')])); |
||
1554 | CBGraphYU.Items.Add(Format('%s (%s)', [_('Total feed intake'), _('MJ NE')])); |
||
1555 | end;
|
||
1556 | 5: // Feed:Gain |
||
1557 | begin
|
||
1558 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('F:G'), _('kg'), _('kg')])); |
||
1559 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('F:G'), _('kg DM'), _('kg')])); |
||
1560 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('F:G'), _('MJ DE'), _('kg')])); |
||
1561 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('F:G'), _('MJ ME'), _('kg')])); |
||
1562 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('F:G'), _('MJ NE'), _('kg')])); |
||
1563 | end;
|
||
1564 | 6: // Gain:Feed |
||
1565 | begin
|
||
1566 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('G:F'), _('kg'), _('kg')])); |
||
1567 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('G:F'), _('kg'), _('kg DM')])); |
||
1568 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('G:F'), _('kg'), _('MJ DE')])); |
||
1569 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('G:F'), _('kg'), _('MJ ME')])); |
||
1570 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('G:F'), _('kg'), _('MJ NE')])); |
||
1571 | end;
|
||
1572 | 7: // Protein |
||
1573 | begin
|
||
1574 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('Protein deposition'), _('g'), _('d')])); |
||
1575 | CBGraphYU.Items.Add(Format('%s (%s)', [_('Protein deposition'), _('kg')])); |
||
1576 | end;
|
||
1577 | 8: // Lipid |
||
1578 | begin
|
||
1579 | CBGraphYU.Items.Add(Format('%s (%s/%s)', [_('Lipid deposition'), _('g'), _('d')])); |
||
1580 | CBGraphYU.Items.Add(Format('%s (%s)', [_('Lipid deposition'), _('kg')])); |
||
1581 | end;
|
||
1582 | end;
|
||
1583 | CBGraphYU.ItemIndex := 0;
|
||
1584 | AffGraph; |
||
1585 | end;
|
||
1586 | |||
1587 | procedure TFProfilP.CBGraphYUChange(Sender: TObject);
|
||
1588 | begin
|
||
1589 | AffGraph; |
||
1590 | end;
|
||
1591 | |||
1592 | // Graphiques
|
||
1593 | |||
1594 | procedure TFProfilP.AffGraph;
|
||
1595 | begin
|
||
1596 | LigneAdLib.Active := CBGraphT.ItemIndex = 0;
|
||
1597 | LigneRation.Active := CBGraphT.ItemIndex = 0;
|
||
1598 | BarreAdLib.Active := CBGraphT.ItemIndex = 1;
|
||
1599 | BarreRation.Active := CBGraphT.ItemIndex = 1;
|
||
1600 | case CBGraphT.ItemIndex of |
||
1601 | 0: // Affichage dynamique |
||
1602 | begin
|
||
1603 | Graph.BottomAxis.Title.Caption := CBGraphXD.Text; |
||
1604 | Graph.LeftAxis.Title.Caption := CBGraphYU.Text; |
||
1605 | // Courbe AdLib
|
||
1606 | AffLigne(PResAdLib, LigneAdLib); |
||
1607 | // Courbe Ration
|
||
1608 | AffLigne(PResRestrict, LigneRation); |
||
1609 | if CBGraphXD.ItemIndex = 3 |
||
1610 | then // Semaines |
||
1611 | Graph.BottomAxis.Increment := 1
|
||
1612 | else // Jours |
||
1613 | Graph.BottomAxis.Increment := 10;
|
||
1614 | end;
|
||
1615 | 1: // Affichage par p?riode |
||
1616 | begin
|
||
1617 | Graph.BottomAxis.Title.Caption := CBGraphXP.Text; |
||
1618 | Graph.LeftAxis.Title.Caption := CBGraphYU.Text; |
||
1619 | // Barre AdLib
|
||
1620 | AffBarre(PResAdLib, BarreAdLib); |
||
1621 | // Barre Ration
|
||
1622 | AffBarre(PResRestrict, BarreRation); |
||
1623 | Graph.BottomAxis.Increment := 1;
|
||
1624 | end;
|
||
1625 | end;
|
||
1626 | Graph.BottomAxis.Grid.Visible := CBGraphT.ItemIndex = 0;
|
||
1627 | Graph.LeftAxis.Grid.Visible := CBGraphT.ItemIndex = 0;
|
||
1628 | AjustEchelle(Graph); |
||
1629 | end;
|
||
1630 | |||
1631 | procedure TFProfilP.AffLigne(PResSimul: PTabResSimulP; Serie: TLineSeries);
|
||
1632 | var
|
||
1633 | j: Integer; |
||
1634 | cumul: Double; |
||
1635 | // Abscisse
|
||
1636 | function LigneX: Double;
|
||
1637 | begin
|
||
1638 | case CBGraphXD.ItemIndex of |
||
1639 | 0: // Poids vif |
||
1640 | result := PResSimul.TabResult[2, j];
|
||
1641 | 1: // Age |
||
1642 | result := PResSimul.TabResult[1, j];
|
||
1643 | 2: // Jours |
||
1644 | result := j; |
||
1645 | 3: // Semaines |
||
1646 | result := j / 7;
|
||
1647 | else
|
||
1648 | result := 0;
|
||
1649 | end;
|
||
1650 | end;
|
||
1651 | // Ordonn?e
|
||
1652 | function LigneY: Double;
|
||
1653 | begin
|
||
1654 | case CBGraphYD.ItemIndex of |
||
1655 | 0: // Body weight |
||
1656 | case CBGraphYU.ItemIndex of |
||
1657 | 0: // Weight gain (g/d) |
||
1658 | result := PResSimul.TabResult[84, j] * 1000; |
||
1659 | 1: // Body weight (kg) |
||
1660 | result := PResSimul.TabResult[2, j];
|
||
1661 | else
|
||
1662 | result := 0;
|
||
1663 | end;
|
||
1664 | 1: // Time |
||
1665 | case CBGraphYU.ItemIndex of |
||
1666 | 0: // Age (d) |
||
1667 | result := PResSimul.TabResult[1, j];
|
||
1668 | else
|
||
1669 | result := 0;
|
||
1670 | end;
|
||
1671 | 2: // Feed usage |
||
1672 | case CBGraphYU.ItemIndex of |
||
1673 | 0: // Feed usage (kg/d) |
||
1674 | result := PResSimul.TabResult[113, j];
|
||
1675 | 1: // Feed usage (kg DM/d) |
||
1676 | result := PResSimul.TabResult[106, j] * PResSimul.TabResult[113, j]; |
||
1677 | 2: // Feed usage (MJ DE/d) |
||
1678 | result := PResSimul.TabResult[109, j] * PResSimul.TabResult[113, j]; |
||
1679 | 3: // Feed usage (MJ ME/d) |
||
1680 | result := PResSimul.TabResult[89, j] * PResSimul.TabResult[113, j]; |
||
1681 | 4: // Feed usage (MJ NE/d) |
||
1682 | result := PResSimul.TabResult[90, j] * PResSimul.TabResult[113, j]; |
||
1683 | 5: // Total feed usage (kg) |
||
1684 | begin
|
||
1685 | cumul := cumul + PResSimul.TabResult[113, j];
|
||
1686 | result := cumul; |
||
1687 | end;
|
||
1688 | 6: // Total feed usage (kg DM) |
||
1689 | begin
|
||
1690 | cumul := cumul + PResSimul.TabResult[106, j] * PResSimul.TabResult[113, j]; |
||
1691 | result := cumul; |
||
1692 | end;
|
||
1693 | 7: // Total feed usage (MJ DE) |
||
1694 | begin
|
||
1695 | cumul := cumul + PResSimul.TabResult[109, j] * PResSimul.TabResult[113, j]; |
||
1696 | result := cumul; |
||
1697 | end;
|
||
1698 | 8: // Total feed usage (MJ ME) |
||
1699 | begin
|
||
1700 | cumul := cumul + PResSimul.TabResult[89, j] * PResSimul.TabResult[113, j]; |
||
1701 | result := cumul; |
||
1702 | end;
|
||
1703 | 9: // Total feed usage (MJ NE) |
||
1704 | begin
|
||
1705 | cumul := cumul + PResSimul.TabResult[90, j] * PResSimul.TabResult[113, j]; |
||
1706 | result := cumul; |
||
1707 | end;
|
||
1708 | else
|
||
1709 | result := 0;
|
||
1710 | end;
|
||
1711 | 3: // Feed wastage |
||
1712 | case CBGraphYU.ItemIndex of |
||
1713 | 0: // Feed wastage (%) |
||
1714 | result := PResSimul.TabResult[112, j] * 100; |
||
1715 | 1: // Total feed wastage (kg) |
||
1716 | begin
|
||
1717 | cumul := cumul + PResSimul.TabResult[113, j] - PResSimul.TabResult[11, j]; |
||
1718 | result := cumul; |
||
1719 | end;
|
||
1720 | else
|
||
1721 | result := 0;
|
||
1722 | end;
|
||
1723 | 4: // Feed intake |
||
1724 | case CBGraphYU.ItemIndex of |
||
1725 | 0: // Feed intake (kg/d) |
||
1726 | result := PResSimul.TabResult[11, j];
|
||
1727 | 1: // Feed intake (kg DM/d) |
||
1728 | result := PResSimul.TabResult[106, j] * PResSimul.TabResult[11, j]; |
||
1729 | 2: // Feed intake (MJ DE/d) |
||
1730 | result := PResSimul.TabResult[109, j] * PResSimul.TabResult[11, j]; |
||
1731 | 3: // Feed intake (MJ ME/d) |
||
1732 | result := PResSimul.TabResult[89, j] * PResSimul.TabResult[11, j]; |
||
1733 | 4: // Feed intake (MJ NE/d) |
||
1734 | result := PResSimul.TabResult[90, j] * PResSimul.TabResult[11, j]; |
||
1735 | 5: // Total feed intake (kg) |
||
1736 | begin
|
||
1737 | cumul := cumul + PResSimul.TabResult[11, j];
|
||
1738 | result := cumul; |
||
1739 | end;
|
||
1740 | 6: // Total feed intake (kg DM) |
||
1741 | begin
|
||
1742 | cumul := cumul + PResSimul.TabResult[106, j] * PResSimul.TabResult[11, j]; |
||
1743 | result := cumul; |
||
1744 | end;
|
||
1745 | 7: // Total feed intake (MJ DE) |
||
1746 | begin
|
||
1747 | cumul := cumul + PResSimul.TabResult[109, j] * PResSimul.TabResult[11, j]; |
||
1748 | result := cumul; |
||
1749 | end;
|
||
1750 | 8: // Total feed intake (MJ ME) |
||
1751 | begin
|
||
1752 | cumul := cumul + PResSimul.TabResult[89, j] * PResSimul.TabResult[11, j]; |
||
1753 | result := cumul; |
||
1754 | end;
|
||
1755 | 9: // Total feed intake (MJ NE) |
||
1756 | begin
|
||
1757 | cumul := cumul + PResSimul.TabResult[90, j] * PResSimul.TabResult[11, j]; |
||
1758 | result := cumul; |
||
1759 | end;
|
||
1760 | else
|
||
1761 | result := 0;
|
||
1762 | end;
|
||
1763 | 5: // Feed:Gain |
||
1764 | if PResSimul.TabResult[84, j] <> 0 |
||
1765 | then
|
||
1766 | case CBGraphYU.ItemIndex of |
||
1767 | 0: // Feed:Gain (kg/kg) |
||
1768 | result := PResSimul.TabResult[113, j] / PResSimul.TabResult[84, j]; |
||
1769 | 1: // Feed:Gain (kg DM/kg) |
||
1770 | result := (PResSimul.TabResult[106, j] * PResSimul.TabResult[113, j]) / PResSimul.TabResult[84, j]; |
||
1771 | 2: // Feed:Gain (MJ DE/kg) |
||
1772 | result := (PResSimul.TabResult[109, j] * PResSimul.TabResult[113, j]) / PResSimul.TabResult[84, j]; |
||
1773 | 3: // Feed:Gain (MJ ME/kg) |
||
1774 | result := (PResSimul.TabResult[89, j] * PResSimul.TabResult[113, j]) / PResSimul.TabResult[84, j]; |
||
1775 | 4: // Feed:Gain (MJ NE/kg) |
||
1776 | result := (PResSimul.TabResult[90, j] * PResSimul.TabResult[113, j]) / PResSimul.TabResult[84, j]; |
||
1777 | else
|
||
1778 | result := 0;
|
||
1779 | end
|
||
1780 | else
|
||
1781 | result := 0;
|
||
1782 | 6: // Gain:Feed |
||
1783 | case CBGraphYU.ItemIndex of |
||
1784 | 0: // Gain:Feed (kg/kg) |
||
1785 | if PResSimul.TabResult[113, j] <> 0 |
||
1786 | then
|
||
1787 | result := PResSimul.TabResult[84, j] / PResSimul.TabResult[113, j] |
||
1788 | else
|
||
1789 | result := 0;
|
||
1790 | 1: // Gain:Feed (kg/kg DM) |
||
1791 | if (PResSimul.TabResult[113, j] <> 0) and (PResSimul.TabResult[106, j] <> 0) |
||
1792 | then
|
||
1793 | result := PResSimul.TabResult[84, j] / (PResSimul.TabResult[106, j] * PResSimul.TabResult[113, j]) |
||
1794 | else
|
||
1795 | result := 0;
|
||
1796 | 2: // Gain:Feed (kg/MJ DE) |
||
1797 | if (PResSimul.TabResult[113, j] <> 0) and (PResSimul.TabResult[109, j] <> 0) |
||
1798 | then
|
||
1799 | result := PResSimul.TabResult[84, j] / (PResSimul.TabResult[109, j] * PResSimul.TabResult[113, j]) |
||
1800 | else
|
||
1801 | result := 0;
|
||
1802 | 3: // Gain:Feed (kg/MJ ME) |
||
1803 | if (PResSimul.TabResult[113, j] <> 0) and (PResSimul.TabResult[89, j] <> 0) |
||
1804 | then
|
||
1805 | result := PResSimul.TabResult[84, j] / (PResSimul.TabResult[89, j] * PResSimul.TabResult[113, j]) |
||
1806 | else
|
||
1807 | result := 0;
|
||
1808 | 4: // Gain:Feed (kg/MJ NE) |
||
1809 | if (PResSimul.TabResult[113, j] <> 0) and (PResSimul.TabResult[90, j] <> 0) |
||
1810 | then
|
||
1811 | result := PResSimul.TabResult[84, j] / (PResSimul.TabResult[90, j] * PResSimul.TabResult[113, j]) |
||
1812 | else
|
||
1813 | result := 0;
|
||
1814 | else
|
||
1815 | result := 0;
|
||
1816 | end;
|
||
1817 | 7: // Protein |
||
1818 | case CBGraphYU.ItemIndex of |
||
1819 | 0: // Protein deposition (g/d) |
||
1820 | result := PResSimul.TabResult[79, j];
|
||
1821 | 1: // Protein mass (kg) |
||
1822 | result := PResSimul.TabResult[49, j];
|
||
1823 | 2: // Protein content (% of BW gain) |
||
1824 | if PResSimul.TabResult[84, j] <> 0 |
||
1825 | then
|
||
1826 | result := (PResSimul.TabResult[79, j] / 1000) / PResSimul.TabResult[84, j] * 100 |
||
1827 | else
|
||
1828 | result := 0;
|
||
1829 | 3: // Protein content (% in BW) |
||
1830 | if PResSimul.TabResult[2, j] <> 0 |
||
1831 | then
|
||
1832 | result := PResSimul.TabResult[49, j] / PResSimul.TabResult[2, j] * 100 |
||
1833 | else
|
||
1834 | result := 0;
|
||
1835 | else
|
||
1836 | result := 0;
|
||
1837 | end;
|
||
1838 | 8: // Lipid |
||
1839 | case CBGraphYU.ItemIndex of |
||
1840 | 0: // Lipid deposition (g/d) |
||
1841 | result := PResSimul.TabResult[80, j];
|
||
1842 | 1: // Lipid mass (kg) |
||
1843 | result := PResSimul.TabResult[50, j];
|
||
1844 | 2: // Lipid content (% of BW gain) |
||
1845 | if PResSimul.TabResult[84, j] <> 0 |
||
1846 | then
|
||
1847 | result := (PResSimul.TabResult[80, j] / 1000) / PResSimul.TabResult[84, j] * 100 |
||
1848 | else
|
||
1849 | result := 0;
|
||
1850 | 3: // Lipid content (% in BW) |
||
1851 | if PResSimul.TabResult[2, j] <> 0 |
||
1852 | then
|
||
1853 | result := PResSimul.TabResult[50, j] / PResSimul.TabResult[2, j] * 100 |
||
1854 | else
|
||
1855 | result := 0;
|
||
1856 | else
|
||
1857 | result := 0;
|
||
1858 | end;
|
||
1859 | 9: // Carcass |
||
1860 | case CBGraphYU.ItemIndex of |
||
1861 | 0: // Dressing percentage |
||
1862 | result := CalcRC(PResSimul.TabResult[2, PResSimul.NbJSim], RCStd, PResSimul.TabResult[2, j]) * 100; |
||
1863 | 1: // Backfat thickness |
||
1864 | if FatInfo = 0 |
||
1865 | then // P2 |
||
1866 | result := CalcP2(PResSimul.TabResult[50, j])
|
||
1867 | else // User defined |
||
1868 | result := CalcUserFat(PResSimul.TabResult[48, j], PResSimul.TabResult[49, j], PResSimul.TabResult[50, j]); |
||
1869 | 2: // Lean meat percentage |
||
1870 | if LeanInfo = 0 |
||
1871 | then // TMP |
||
1872 | result := CalcTMP(PResSimul.TabResult[48, j], PResSimul.TabResult[49, j], PResSimul.TabResult[50, j]) |
||
1873 | else // User defined |
||
1874 | result := CalcUserLean(PResSimul.TabResult[48, j], PResSimul.TabResult[49, j], PResSimul.TabResult[50, j]); |
||
1875 | else
|
||
1876 | result := 0;
|
||
1877 | end;
|
||
1878 | else
|
||
1879 | result := 0;
|
||
1880 | end;
|
||
1881 | end;
|
||
1882 | // AffLigne
|
||
1883 | begin
|
||
1884 | cumul := 0;
|
||
1885 | Serie.Clear; |
||
1886 | for j := 1 to PResSimul.NbJSim do |
||
1887 | Serie.AddXY (LigneX, LigneY, '', clTeeColor);
|
||
1888 | end;
|
||
1889 | |||
1890 | procedure TFProfilP.AffBarre(PResSimul: PTabResSimulP; Serie: TBarSeries);
|
||
1891 | var
|
||
1892 | j, k: Integer; |
||
1893 | c, p: Double; |
||
1894 | s: string;
|
||
1895 | // Abscisse
|
||
1896 | function BarreX: Double;
|
||
1897 | begin
|
||
1898 | case CBGraphXP.ItemIndex of |
||
1899 | 0: // Semaine |
||
1900 | result := (j - 1) div 7 + 1; |
||
1901 | 1: // R?gle qualit? |
||
1902 | result := PResSimul.TabResult[3, j];
|
||
1903 | 2: // R?gle quantit? |
||
1904 | result := PResSimul.TabResult[5, j];
|
||
1905 | else
|
||
1906 | result := 0;
|
||
1907 | end;
|
||
1908 | end;
|
||
1909 | // Ordonn?e
|
||
1910 | function BarreY: Double;
|
||
1911 | var
|
||
1912 | h: Integer; |
||
1913 | v, conso, gain: Double; |
||
1914 | begin
|
||
1915 | v := 0;
|
||
1916 | case CBGraphYP.ItemIndex of |
||
1917 | 0: // Body weight |
||
1918 | case CBGraphYU.ItemIndex of |
||
1919 | 0: // Weight gain (g/d) |
||
1920 | for h := k to j - 1 do |
||
1921 | v := v + PResSimul.TabResult[84, h] * 1000 / (j - k); |
||
1922 | 1: // Weight gain (kg) |
||
1923 | for h := k to j - 1 do |
||
1924 | v := v + PResSimul.TabResult[84, h];
|
||
1925 | end;
|
||
1926 | 1: // Time |
||
1927 | case CBGraphYU.ItemIndex of |
||
1928 | 0: // Duration (d) |
||
1929 | v := j - k; |
||
1930 | end;
|
||
1931 | 2: // Feed usage |
||
1932 | case CBGraphYU.ItemIndex of |
||
1933 | 0: // Feed usage (kg/d) |
||
1934 | for h := k to j - 1 do |
||
1935 | v := v + PResSimul.TabResult[113, h] / (j - k);
|
||
1936 | 1: // Feed usage (kg DM/d) |
||
1937 | for h := k to j - 1 do |
||
1938 | v := v + PResSimul.TabResult[106, h] * PResSimul.TabResult[113, h] / (j - k); |
||
1939 | 2: // Feed usage (MJ DE/d) |
||
1940 | for h := k to j - 1 do |
||
1941 | v := v + PResSimul.TabResult[109, h] * PResSimul.TabResult[113, h] / (j - k); |
||
1942 | 3: // Feed usage (MJ ME/d) |
||
1943 | for h := k to j - 1 do |
||
1944 | v := v + PResSimul.TabResult[89, h] * PResSimul.TabResult[113, h] / (j - k); |
||
1945 | 4: // Feed usage (MJ NE/d) |
||
1946 | for h := k to j - 1 do |
||
1947 | v := v + PResSimul.TabResult[90, h] * PResSimul.TabResult[113, h] / (j - k); |
||
1948 | 5: // Total feed usage (kg) |
||
1949 | for h := k to j - 1 do |
||
1950 | v := v + PResSimul.TabResult[113, h];
|
||
1951 | 6: // Total feed usage (kg DM) |
||
1952 | for h := k to j - 1 do |
||
1953 | v := v + PResSimul.TabResult[106, h] * PResSimul.TabResult[113, h]; |
||
1954 | 7: // Total feed usage (MJ DE) |
||
1955 | for h := k to j - 1 do |
||
1956 | v := v + PResSimul.TabResult[109, h] * PResSimul.TabResult[113, h]; |
||
1957 | 8: // Total feed usage (MJ ME) |
||
1958 | for h := k to j - 1 do |
||
1959 | v := v + PResSimul.TabResult[89, h] * PResSimul.TabResult[113, h]; |
||
1960 | 9: // Total feed usage (MJ NE) |
||
1961 | for h := k to j - 1 do |
||
1962 | v := v + PResSimul.TabResult[90, h] * PResSimul.TabResult[113, h]; |
||
1963 | end;
|
||
1964 | 3: // Feed wastage |
||
1965 | case CBGraphYU.ItemIndex of |
||
1966 | 0: // Feed wastage (%) |
||
1967 | for h := k to j - 1 do |
||
1968 | v := v + PResSimul.TabResult[112, h] * 100 / (j - k); |
||
1969 | 1: // Total feed wastage (kg) |
||
1970 | for h := k to j - 1 do |
||
1971 | v := v + PResSimul.TabResult[113, h] - PResSimul.TabResult[11, h]; |
||
1972 | end;
|
||
1973 | 4: // Feed intake |
||
1974 | case CBGraphYU.ItemIndex of |
||
1975 | 0: // Feed intake (kg/d) |
||
1976 | for h := k to j - 1 do |
||
1977 | v := v + PResSimul.TabResult[11, h] / (j - k);
|
||
1978 | 1: // Feed intake (kg DM/d) |
||
1979 | for h := k to j - 1 do |
||
1980 | v := v + PResSimul.TabResult[106, h] * PResSimul.TabResult[11, h] / (j - k); |
||
1981 | 2: // Feed intake (MJ DE/d) |
||
1982 | for h := k to j - 1 do |
||
1983 | v := v + PResSimul.TabResult[109, h] * PResSimul.TabResult[11, h] / (j - k); |
||
1984 | 3: // Feed intake (MJ ME/d) |
||
1985 | for h := k to j - 1 do |
||
1986 | v := v + PResSimul.TabResult[89, h] * PResSimul.TabResult[11, h] / (j - k); |
||
1987 | 4: // Feed intake (MJ NE/d) |
||
1988 | for h := k to j - 1 do |
||
1989 | v := v + PResSimul.TabResult[90, h] * PResSimul.TabResult[11, h] / (j - k); |
||
1990 | 5: // Total feed intake (kg) |
||
1991 | for h := k to j - 1 do |
||
1992 | v := v + PResSimul.TabResult[11, h];
|
||
1993 | 6: // Total feed intake (kg DM) |
||
1994 | for h := k to j - 1 do |
||
1995 | v := v + PResSimul.TabResult[106, h] * PResSimul.TabResult[11, h]; |
||
1996 | 7: // Total feed intake (MJ DE) |
||
1997 | for h := k to j - 1 do |
||
1998 | v := v + PResSimul.TabResult[109, h] * PResSimul.TabResult[11, h]; |
||
1999 | 8: // Total feed intake (MJ ME) |
||
2000 | for h := k to j - 1 do |
||
2001 | v := v + PResSimul.TabResult[89, h] * PResSimul.TabResult[11, h]; |
||
2002 | 9: // Total feed intake (MJ NE) |
||
2003 | for h := k to j - 1 do |
||
2004 | v := v + PResSimul.TabResult[90, h] * PResSimul.TabResult[11, h]; |
||
2005 | end;
|
||
2006 | 5: // Feed:Gain |
||
2007 | begin
|
||
2008 | conso := 0;
|
||
2009 | for h := k to j - 1 do |
||
2010 | case CBGraphYU.ItemIndex of |
||
2011 | 0: // Feed:Gain (kg/kg) |
||
2012 | conso := conso + PResSimul.TabResult[113, h];
|
||
2013 | 1: // Feed:Gain (kg DM/kg) |
||
2014 | conso := conso + PResSimul.TabResult[106, h] * PResSimul.TabResult[113, h]; |
||
2015 | 2: // Feed:Gain (MJ DE/kg) |
||
2016 | conso := conso + PResSimul.TabResult[109, h] * PResSimul.TabResult[113, h]; |
||
2017 | 3: // Feed:Gain (MJ ME/kg) |
||
2018 | conso := conso + PResSimul.TabResult[89, h] * PResSimul.TabResult[113, h]; |
||
2019 | 4: // Feed:Gain (MJ NE/kg) |
||
2020 | conso := conso + PResSimul.TabResult[90, h] * PResSimul.TabResult[113, h]; |
||
2021 | end;
|
||
2022 | gain := 0;
|
||
2023 | for h := k to j - 1 do |
||
2024 | gain := gain + PResSimul.TabResult[84, h];
|
||
2025 | if gain <> 0 |
||
2026 | then
|
||
2027 | v := conso / gain; |
||
2028 | end;
|
||
2029 | 6: // Gain:Feed |
||
2030 | begin
|
||
2031 | gain := 0;
|
||
2032 | for h := k to j - 1 do |
||
2033 | gain := gain + PResSimul.TabResult[84, h];
|
||
2034 | conso := 0;
|
||
2035 | for h := k to j - 1 do |
||
2036 | case CBGraphYU.ItemIndex of |
||
2037 | 0: // Gain:Feed (kg/kg) |
||
2038 | conso := conso + PResSimul.TabResult[113, h];
|
||
2039 | 1: // Gain:Feed (kg/kg DM) |
||
2040 | conso := conso + PResSimul.TabResult[106, h] * PResSimul.TabResult[113, h]; |
||
2041 | 2: // Gain:Feed (kg/MJ DE) |
||
2042 | conso := conso + PResSimul.TabResult[109, h] * PResSimul.TabResult[113, h]; |
||
2043 | 3: // Gain:Feed (kg/MJ ME) |
||
2044 | conso := conso + PResSimul.TabResult[89, h] * PResSimul.TabResult[113, h]; |
||
2045 | 4: // Gain:Feed (kg/MJ NE) |
||
2046 | conso := conso + PResSimul.TabResult[90, h] * PResSimul.TabResult[113, h]; |
||
2047 | end;
|
||
2048 | if conso <> 0 |
||
2049 | then
|
||
2050 | v := gain / conso; |
||
2051 | end;
|
||
2052 | 7: // Protein |
||
2053 | case CBGraphYU.ItemIndex of |
||
2054 | 0: // Protein deposition (g/d) |
||
2055 | for h := k to j - 1 do |
||
2056 | v := v + PResSimul.TabResult[79, h] / (j - k);
|
||
2057 | 1: // Protein deposition (kg) |
||
2058 | for h := k to j - 1 do |
||
2059 | v := v + PResSimul.TabResult[79, h] / 1000; |
||
2060 | end;
|
||
2061 | 8: // Lipid |
||
2062 | case CBGraphYU.ItemIndex of |
||
2063 | 0: // Lipid deposition (g/d) |
||
2064 | for h := k to j - 1 do |
||
2065 | v := v + PResSimul.TabResult[80, h] / (j - k);
|
||
2066 | 1: // Lipid deposition (kg) |
||
2067 | for h := k to j - 1 do |
||
2068 | v := v + PResSimul.TabResult[80, h] / 1000; |
||
2069 | end;
|
||
2070 | end;
|
||
2071 | result := v; |
||
2072 | end;
|
||
2073 | // AffBarre
|
||
2074 | begin
|
||
2075 | Serie.Clear; |
||
2076 | j := 1;
|
||
2077 | c := BarreX; |
||
2078 | k := 1;
|
||
2079 | if PResSimul.NbJSim > 1 |
||
2080 | then
|
||
2081 | for j := 2 to PResSimul.NbJSim do |
||
2082 | begin
|
||
2083 | p := BarreX; |
||
2084 | if (c <> p)
|
||
2085 | then // Changement de p?riode |
||
2086 | begin
|
||
2087 | s := Format('%1.0f', [c]);
|
||
2088 | Serie.AddBar(BarreY, s, clTeeColor); |
||
2089 | c := p; |
||
2090 | k := j; |
||
2091 | end;
|
||
2092 | end;
|
||
2093 | j := PResSimul.NbJSim + 1;
|
||
2094 | s := Format('%1.0f', [c]);
|
||
2095 | Serie.AddBar(BarreY, s, clTeeColor); |
||
2096 | with Serie do |
||
2097 | ValueFormat := AjustFormat(AjustPas(MaxYValue - MinYValue) / 10);
|
||
2098 | end;
|
||
2099 | |||
2100 | // Tableau
|
||
2101 | |||
2102 | procedure TFProfilP.CalcTab(Ligne: Integer; PResSimul: PTabResSimulP);
|
||
2103 | var
|
||
2104 | i, t: integer; |
||
2105 | gain, usage, intake, PD, LD, PVVFin, pFin, lFin: double; |
||
2106 | begin
|
||
2107 | t := PResSimul.NbJSim; |
||
2108 | // GMQ
|
||
2109 | // gain = gain de poids
|
||
2110 | gain := 0;
|
||
2111 | for i := 1 to t do |
||
2112 | gain := gain + PResSimul.TabResult[84, i] * 1000; |
||
2113 | Tab[1, Ligne] := gain / t;
|
||
2114 | // Consommation moyenne
|
||
2115 | // usage = aliment distribu? total
|
||
2116 | usage := 0;
|
||
2117 | for i := 1 to t do |
||
2118 | usage := usage + PResSimul.TabResult[113, i];
|
||
2119 | usage := usage * 1000; // kg -> g |
||
2120 | Tab[2, Ligne] := usage / t;
|
||
2121 | // Gaspillage
|
||
2122 | // intake = aliment ing?r? total
|
||
2123 | intake := 0;
|
||
2124 | for i := 1 to t do |
||
2125 | intake := intake + PResSimul.TabResult[11, i];
|
||
2126 | intake := intake * 1000; // kg -> g |
||
2127 | if usage = 0 |
||
2128 | then
|
||
2129 | Tab[3, Ligne] := 0 |
||
2130 | else
|
||
2131 | Tab[3, Ligne] := (1 - intake / usage) * 100; |
||
2132 | if FeedInfo = 0 |
||
2133 | then // Indice de consommation |
||
2134 | if gain = 0 |
||
2135 | then
|
||
2136 | Tab[4, Ligne] := 0 |
||
2137 | else
|
||
2138 | Tab[4, Ligne] := usage / gain
|
||
2139 | else // Efficacit? alimentaire |
||
2140 | if usage = 0 |
||
2141 | then
|
||
2142 | Tab[4, Ligne] := 0 |
||
2143 | else
|
||
2144 | Tab[4, Ligne] := gain / usage;
|
||
2145 | // D?pot de prot?ines moyen
|
||
2146 | PD := 0;
|
||
2147 | for i := 1 to t do |
||
2148 | PD := PD + PResSimul.TabResult[79, i];
|
||
2149 | Tab[5, Ligne] := PD / t;
|
||
2150 | // D?pot de lipides moyen
|
||
2151 | LD := 0;
|
||
2152 | for i := 1 to t do |
||
2153 | LD := LD + PResSimul.TabResult[80, i];
|
||
2154 | Tab[6, Ligne] := LD / t;
|
||
2155 | PVVFin := CalcPVV(PResSimul.TabResult[2, t] + PResSimul.TabResult[84, t]); |
||
2156 | pFin := PResSimul.TabResult[49, t] + PResSimul.TabResult[79, t] / 1000; |
||
2157 | lFin := PResSimul.TabResult[50, t] + PResSimul.TabResult[80, t] / 1000; |
||
2158 | if FatInfo = 0 |
||
2159 | then // P2 |
||
2160 | Tab[7, Ligne] := CalcP2(lFin)
|
||
2161 | else // User defined |
||
2162 | Tab[7, Ligne] := CalcUserFat(PVVFin, pFin, lFin);
|
||
2163 | if LeanInfo = 0 |
||
2164 | then // TMP |
||
2165 | Tab[8, Ligne] := CalcTMP(PVVFin, pFin, lFin)
|
||
2166 | else // User defined |
||
2167 | Tab[8, Ligne] := CalcUserLean(PVVFin, pFin, lFin);
|
||
2168 | end;
|
||
2169 | |||
2170 | procedure TFProfilP.AffTab;
|
||
2171 | var
|
||
2172 | i: Integer; |
||
2173 | begin
|
||
2174 | SGResult.Hint := '';
|
||
2175 | // Titres
|
||
2176 | SGResult.Cells[0, 0] := _('Gain'); |
||
2177 | SGResult.Cells[1, 0] := _('Feed usage (wastage)'); |
||
2178 | if FeedInfo = 0 |
||
2179 | then // Indice de consommation |
||
2180 | SGResult.Cells[2, 0] := _('F:G') |
||
2181 | else // Efficacit? alimentaire |
||
2182 | SGResult.Cells[2, 0] := _('G:F'); |
||
2183 | SGResult.Cells[3, 0] := _('PD'); |
||
2184 | SGResult.Cells[4, 0] := _('LD'); |
||
2185 | if FatInfo = 0 |
||
2186 | then // P2 |
||
2187 | SGResult.Cells[5, 0] := _('Backfat') |
||
2188 | else // User defined |
||
2189 | if Length(UserFatShortName) = 0 |
||
2190 | then
|
||
2191 | SGResult.Cells[5, 0] := _('Backfat') + '*' |
||
2192 | else
|
||
2193 | SGResult.Cells[5, 0] := UserFatShortName + '*'; |
||
2194 | if LeanInfo = 0 |
||
2195 | then // TMP |
||
2196 | SGResult.Cells[6, 0] := _('Lean meat') |
||
2197 | else // User defined |
||
2198 | if Length(UserLeanShortName) = 0 |
||
2199 | then
|
||
2200 | SGResult.Cells[6, 0] := _('Lean meat') + '*' |
||
2201 | else
|
||
2202 | SGResult.Cells[6, 0] := UserLeanShortName + '*'; |
||
2203 | // Donn?es
|
||
2204 | for i := 1 to 2 do |
||
2205 | begin
|
||
2206 | SGResult.Cells[0, i] := FloatToStrF(Tab[1, i], ffFixed, 15, 0); |
||
2207 | SGResult.Cells[1, i] := Format('%1.0f (%1.0f%%)', [Tab[2, i], Tab[3, i]]); |
||
2208 | SGResult.Cells[2, i] := FloatToStrF(Tab[4, i], ffFixed, 15, 2); |
||
2209 | SGResult.Cells[3, i] := FloatToStrF(Tab[5, i], ffFixed, 15, 0); |
||
2210 | SGResult.Cells[4, i] := FloatToStrF(Tab[6, i], ffFixed, 15, 0); |
||
2211 | SGResult.Cells[5, i] := FloatToStrF(Tab[7, i], ffFixed, 15, 1); |
||
2212 | SGResult.Cells[6, i] := FloatToStrF(Tab[8, i], ffFixed, 15, 1); |
||
2213 | end;
|
||
2214 | end;
|
||
2215 | |||
2216 | procedure TFProfilP.SGResultDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
|
||
2217 | var
|
||
2218 | i: integer; |
||
2219 | begin
|
||
2220 | with (Sender as TStringGrid).Canvas do |
||
2221 | begin
|
||
2222 | if ARow = 0 |
||
2223 | then // Titre |
||
2224 | Brush.Color := clBtnFace |
||
2225 | else // Donn?es |
||
2226 | Brush.Color := clWhite; |
||
2227 | // Fond
|
||
2228 | FillRect(Rect); |
||
2229 | case ARow of |
||
2230 | 1:
|
||
2231 | Font.Color := clBlack; |
||
2232 | 2:
|
||
2233 | Font.Color := clRed; |
||
2234 | else
|
||
2235 | Font.Color := clDefault; |
||
2236 | end;
|
||
2237 | SetTextAlign(Handle, TA_CENTER); |
||
2238 | i := Rect.Left + (Rect.Right - Rect.Left) div 2; |
||
2239 | TextRect(Rect, i, Rect.Top + 2, (Sender as TStringGrid).Cells[ACol, ARow]); |
||
2240 | end;
|
||
2241 | end;
|
||
2242 | |||
2243 | procedure TFProfilP.SGResultMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
|
||
2244 | var
|
||
2245 | Col, Lig: integer; |
||
2246 | Unite, s: String;
|
||
2247 | begin
|
||
2248 | SGResult.MouseToCell(X, Y, Col, Lig); |
||
2249 | if (Col < 0) or (Lig < 0) then Exit; |
||
2250 | // Unit?
|
||
2251 | case Col of |
||
2252 | 0, 1, 3, 4: Unite := Format('%s/%s', [_('g'), _('d')]); |
||
2253 | 2: // Affichage en fonction de la configuration |
||
2254 | if FeedInfo = 0 |
||
2255 | then // Indice de consommation |
||
2256 | Unite := Format('%s/%s', [_('kg feed'), _('kg gain')]) |
||
2257 | else // Efficacit? alimentaire |
||
2258 | Unite := Format('%s/%s', [_('kg gain'), _('kg feed')]); |
||
2259 | 5: Unite := _('mm'); |
||
2260 | 6: Unite := '%'; |
||
2261 | end;
|
||
2262 | // Hint
|
||
2263 | case Col of |
||
2264 | 0: s := Format('%s (%s)', [_('Average daily gain'), Unite]); |
||
2265 | 1: s := Format('%s (%s)', [_('Average daily feed usage and wastage'), Unite]); |
||
2266 | 2: // Affichage en fonction de la configuration |
||
2267 | if FeedInfo = 0 |
||
2268 | then // Indice de consommation |
||
2269 | s := Format('%s (%s)', [_('Average feed-to-gain ratio'), Unite]) |
||
2270 | else // Efficacit? alimentaire |
||
2271 | s := Format('%s (%s)', [_('Average gain-to-feed ratio'), Unite]); |
||
2272 | 3: s := Format('%s (%s)', [_('Average protein deposition'), Unite]); |
||
2273 | 4: s := Format('%s (%s)', [_('Average lipid deposition'), Unite]); |
||
2274 | 5: // Affichage en fonction de la configuration |
||
2275 | if FatInfo = 0 |
||
2276 | then // P2 |
||
2277 | s := Format('%s (%s)', [_('Backfat thickness at slaughter'), Unite]) |
||
2278 | else // User defined |
||
2279 | if Length(UserFatLongName) = 0 |
||
2280 | then
|
||
2281 | s := Format('%s (%s)', [_('User-defined backfat thickness'), Unite]) |
||
2282 | else
|
||
2283 | s := Format('%s (%s)', [UserFatLongName, Unite]);
|
||
2284 | 6: // Affichage en fonction de la configuration |
||
2285 | if LeanInfo = 0 |
||
2286 | then // TMP |
||
2287 | s := Format('%s (%s)', [_('Lean meat at slaughter'), Unite]) |
||
2288 | else // User defined |
||
2289 | if Length(UserLeanLongName) = 0 |
||
2290 | then
|
||
2291 | s := Format('%s (%s)', [_('User-defined lean meat'), Unite]) |
||
2292 | else
|
||
2293 | s := Format('%s (%s)', [UserLeanLongName, Unite]);
|
||
2294 | end;
|
||
2295 | if SGResult.Hint <> s
|
||
2296 | then // Changement de cellule |
||
2297 | begin
|
||
2298 | SGResult.Hint := s; |
||
2299 | Application.ActivateHint(Mouse.CursorPos); |
||
2300 | end;
|
||
2301 | end;
|
||
2302 | |||
2303 | procedure TFProfilP.SuperSpinDecimals(Field: TPBSuperSpin; Count: Shortint);
|
||
2304 | begin
|
||
2305 | Field.Decimals := Count; |
||
2306 | Field.Increment := Power(10, -Count);
|
||
2307 | end;
|
||
2308 | |||
2309 | end. |