root / UFResSimulP.pas
Historique | Voir | Annoter | Télécharger (196,008 ko)
1 |
unit UFResSimulP;
|
---|---|
2 |
|
3 |
interface
|
4 |
|
5 |
uses
|
6 |
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, |
7 |
Dialogs, StdCtrls, Buttons, ExtCtrls, ComCtrls, Contnrs, CheckLst, Menus, |
8 |
Printers, Math, PBNumEdit, Grids, TeEngine, Series, TeeProcs, Chart, |
9 |
UVariables, gnugettext; |
10 |
|
11 |
type
|
12 |
TFResSimulP = class(TForm)
|
13 |
PC: TPageControl; |
14 |
TabAli: TTabSheet; |
15 |
CBAli1: TComboBox; |
16 |
TabNRJ: TTabSheet; |
17 |
TabPD: TTabSheet; |
18 |
CBPD2: TComboBox; |
19 |
LBPD: TListBox; |
20 |
TabPerf: TTabSheet; |
21 |
TabAA: TTabSheet; |
22 |
CBAA1: TComboBox; |
23 |
CBAA3: TComboBox; |
24 |
CBAA4: TComboBox; |
25 |
CBPerf1: TComboBox; |
26 |
CBPerf2D: TComboBox; |
27 |
CBPerf3D: TComboBox; |
28 |
CBPerf4: TComboBox; |
29 |
CBAA2D: TComboBox; |
30 |
CBAli2D: TComboBox; |
31 |
CBAli4: TComboBox; |
32 |
CBNRJ1: TComboBox; |
33 |
CBNRJ2D: TComboBox; |
34 |
CBNRJ3: TComboBox; |
35 |
CBNRJ4: TComboBox; |
36 |
TabRej: TTabSheet; |
37 |
CBRej1: TComboBox; |
38 |
CBRej2D: TComboBox; |
39 |
CBRej3: TComboBox; |
40 |
CBRej4: TComboBox; |
41 |
CBAA5: TComboBox; |
42 |
GBPerfT: TGroupBox; |
43 |
GBPerfY: TGroupBox; |
44 |
GBPerfX: TGroupBox; |
45 |
GBPDF: TGroupBox; |
46 |
GBAliT: TGroupBox; |
47 |
GBAliY: TGroupBox; |
48 |
GBAliX: TGroupBox; |
49 |
GBPDT: TGroupBox; |
50 |
GBPDY: TGroupBox; |
51 |
GBPDX: TGroupBox; |
52 |
GBAAT: TGroupBox; |
53 |
GBAAY: TGroupBox; |
54 |
GBAAX: TGroupBox; |
55 |
GBNRJT: TGroupBox; |
56 |
GBNRJY: TGroupBox; |
57 |
GBNRJX: TGroupBox; |
58 |
GBRejT: TGroupBox; |
59 |
GBRejY: TGroupBox; |
60 |
GBRejX: TGroupBox; |
61 |
CBPerfAL: TCheckBox; |
62 |
Graph: TChart; |
63 |
LBNRJ: TListBox; |
64 |
LBRej: TListBox; |
65 |
LBAA: TListBox; |
66 |
CBAli2P: TComboBox; |
67 |
CBAA2P: TComboBox; |
68 |
CBNRJ2P: TComboBox; |
69 |
CBRej2P: TComboBox; |
70 |
CBPerf2P: TComboBox; |
71 |
CBPerf3P: TComboBox; |
72 |
CBNRJ3R: TComboBox; |
73 |
CBNRJ3V: TComboBox; |
74 |
CBAli3: TComboBox; |
75 |
TabMin: TTabSheet; |
76 |
LBMin: TListBox; |
77 |
GBMinX: TGroupBox; |
78 |
CBMin2D: TComboBox; |
79 |
CBMin2P: TComboBox; |
80 |
GBMinY: TGroupBox; |
81 |
CBMin3: TComboBox; |
82 |
CBMin4: TComboBox; |
83 |
GBMinT: TGroupBox; |
84 |
CBMin1: TComboBox; |
85 |
PM: TPopupMenu; |
86 |
MI3D: TMenuItem; |
87 |
MIPreview: TMenuItem; |
88 |
MIPrint: TMenuItem; |
89 |
PD: TPrintDialog; |
90 |
CBMin5: TComboBox; |
91 |
MIExport: TMenuItem; |
92 |
MExport: TMemo; |
93 |
SD: TSaveDialog; |
94 |
CBAli5: TComboBox; |
95 |
procedure FormCreate(Sender: TObject);
|
96 |
procedure FormShow(Sender: TObject);
|
97 |
procedure FormClose(Sender: TObject; var Action: TCloseAction); |
98 |
procedure MI3DClick(Sender: TObject);
|
99 |
procedure MIPreviewClick(Sender: TObject);
|
100 |
procedure MIPrintClick(Sender: TObject);
|
101 |
procedure PCChange(Sender: TObject);
|
102 |
procedure CBPerf1Change(Sender: TObject);
|
103 |
procedure CBPerf2Change(Sender: TObject);
|
104 |
procedure CBPerf3Change(Sender: TObject);
|
105 |
procedure CBPerf4Change(Sender: TObject);
|
106 |
procedure CBPerfALClick(Sender: TObject);
|
107 |
procedure CBAli1Change(Sender: TObject);
|
108 |
procedure CBAli2Change(Sender: TObject);
|
109 |
procedure CBAli3Change(Sender: TObject);
|
110 |
procedure CBAli4Change(Sender: TObject);
|
111 |
procedure CBPD2Change(Sender: TObject);
|
112 |
procedure LBPDClick(Sender: TObject);
|
113 |
procedure LBPDDrawItem(Control: TWinControl; Index: Integer;
|
114 |
Rect: TRect; State: TOwnerDrawState); |
115 |
procedure CBAA1Change(Sender: TObject);
|
116 |
procedure CBAA2Change(Sender: TObject);
|
117 |
procedure CBAA3Change(Sender: TObject);
|
118 |
procedure CBAA4Change(Sender: TObject);
|
119 |
procedure CBAA5Change(Sender: TObject);
|
120 |
procedure CBNRJ1Change(Sender: TObject);
|
121 |
procedure CBNRJ2Change(Sender: TObject);
|
122 |
procedure CBNRJ3Change(Sender: TObject);
|
123 |
procedure CBNRJ4Change(Sender: TObject);
|
124 |
procedure CBMin2Change(Sender: TObject);
|
125 |
procedure CBMin1Change(Sender: TObject);
|
126 |
procedure CBMin3Change(Sender: TObject);
|
127 |
procedure CBMin4Change(Sender: TObject);
|
128 |
procedure CBRej1Change(Sender: TObject);
|
129 |
procedure CBRej2Change(Sender: TObject);
|
130 |
procedure CBRej4Change(Sender: TObject);
|
131 |
procedure CBRej3Change(Sender: TObject);
|
132 |
procedure CBMin5Change(Sender: TObject);
|
133 |
procedure MIExportClick(Sender: TObject);
|
134 |
procedure CBAli5Change(Sender: TObject);
|
135 |
procedure WMSysCommand(var Mess: TWMSysCommand); message WM_SYSCOMMAND; |
136 |
private
|
137 |
{ D?clarations priv?es }
|
138 |
LinePerf: TLineSeries; |
139 |
LinePerfAL: TLineSeries; |
140 |
BarPerf: TBarSeries; |
141 |
ListAli, ListMat: TStrings; |
142 |
CompositionComplete: boolean; |
143 |
PieAli: TPieSeries; |
144 |
AreaAli: array of TAreaSeries; |
145 |
BarAli: array of TBarSeries; |
146 |
NbLimit: integer; |
147 |
ListPD: TStrings; |
148 |
LinePD: array of TLineSeries; |
149 |
ListAA: TStrings; |
150 |
PieAA: TPieSeries; |
151 |
AreaAA: array of TAreaSeries; |
152 |
BarAA: array of TBarSeries; |
153 |
LineAA: array[1..3] of TLineSeries; |
154 |
ListNRJ: TStrings; |
155 |
PieNRJ: TPieSeries; |
156 |
AreaNRJ: array of TAreaSeries; |
157 |
BarNRJ: array of TBarSeries; |
158 |
LineNRJ: array[1..2] of TLineSeries; |
159 |
ListMin: TStrings; |
160 |
PieMin: TPieSeries; |
161 |
AreaMin: array of TAreaSeries; |
162 |
BarMin: array of TBarSeries; |
163 |
LineMin: array[1..2] of TLineSeries; |
164 |
ListRej: TStrings; |
165 |
PieRej: TPieSeries; |
166 |
AreaRej: array of TAreaSeries; |
167 |
BarRej: array of TBarSeries; |
168 |
procedure ResetGraph;
|
169 |
procedure InitAli;
|
170 |
procedure AffGraphAli;
|
171 |
procedure InitNRJ;
|
172 |
procedure AffGraphNRJ;
|
173 |
procedure InitPD;
|
174 |
procedure AffGraphPD;
|
175 |
procedure InitPerf;
|
176 |
procedure AffGraphPerf;
|
177 |
procedure InitAA;
|
178 |
procedure AffGraphAA;
|
179 |
procedure InitMin;
|
180 |
procedure AffGraphMin;
|
181 |
procedure InitRej;
|
182 |
procedure AffGraphRej;
|
183 |
public
|
184 |
{ D?clarations publiques }
|
185 |
end;
|
186 |
|
187 |
var
|
188 |
FResSimulP: TFResSimulP; |
189 |
|
190 |
implementation
|
191 |
|
192 |
uses
|
193 |
UStrings, UFindRec, UUtil, UEchelle, UCalcul, UFSimulP, UFPrevGraph, |
194 |
UFWarning; |
195 |
|
196 |
{$R *.dfm}
|
197 |
|
198 |
{ TFResSimulP }
|
199 |
|
200 |
procedure TFResSimulP.FormCreate(Sender: TObject);
|
201 |
begin
|
202 |
if Screen.Fonts.IndexOf('Arial Unicode MS') <> -1 |
203 |
then
|
204 |
Font.Name := 'Arial Unicode MS';
|
205 |
TranslateComponent(Self); |
206 |
Constraints.MinWidth := 544 + (Width - ClientWidth);
|
207 |
Width := 640;
|
208 |
Constraints.MinHeight := 360 + (Height - ClientHeight);
|
209 |
Height := 480;
|
210 |
CBPerf1.ItemIndex := 0;
|
211 |
CBPerf2D.ItemIndex := 0;
|
212 |
CBPerf2P.ItemIndex := 0;
|
213 |
CBPerf3D.ItemIndex := 0;
|
214 |
CBPerf3P.ItemIndex := 0;
|
215 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('Weight gain'), _('g'), _('d')])); |
216 |
CBPerf4.Items.Add(Format('%s (%s)', [_('Body weight'), _('kg')])); |
217 |
CBPerf4.ItemIndex := 0;
|
218 |
CBAli1.ItemIndex := 0;
|
219 |
CBAli2D.ItemIndex := 0;
|
220 |
CBAli2P.ItemIndex := 0;
|
221 |
CBAli3.ItemIndex := 0;
|
222 |
CBAli4.Items.Add(StrKg); |
223 |
CBAli4.Items.Add('%');
|
224 |
CBAli4.ItemIndex := 0;
|
225 |
CBAli5.ItemIndex := 0;
|
226 |
CBPD2.ItemIndex := 0;
|
227 |
CBAA1.ItemIndex := 0;
|
228 |
CBAA2D.ItemIndex := 0;
|
229 |
CBAA2P.ItemIndex := 0;
|
230 |
CBAA3.ItemIndex := 1;
|
231 |
CBAA4.Items.Add(StrG); |
232 |
CBAA4.Items.Add('%');
|
233 |
CBAA4.ItemIndex := 0;
|
234 |
CBAA5.ItemIndex := 0;
|
235 |
CBNRJ1.ItemIndex := 0;
|
236 |
CBNRJ2D.ItemIndex := 0;
|
237 |
CBNRJ2P.ItemIndex := 0;
|
238 |
CBNRJ3.ItemIndex := 0;
|
239 |
CBNRJ3R.ItemIndex := 0;
|
240 |
CBNRJ3V.ItemIndex := 0;
|
241 |
CBNRJ4.Items.Add(StrMJ); |
242 |
CBNRJ4.Items.Add('%');
|
243 |
CBNRJ4.ItemIndex := 0;
|
244 |
CBMin1.ItemIndex := 0;
|
245 |
CBMin2D.ItemIndex := 0;
|
246 |
CBMin2P.ItemIndex := 0;
|
247 |
CBMin3.ItemIndex := 0;
|
248 |
CBMin4.Items.Add(StrG); |
249 |
CBMin4.Items.Add('%');
|
250 |
CBMin4.ItemIndex := 0;
|
251 |
CBMin5.ItemIndex := 0;
|
252 |
CBRej1.ItemIndex := 0;
|
253 |
CBRej2D.ItemIndex := 0;
|
254 |
CBRej2P.ItemIndex := 0;
|
255 |
CBRej3.ItemIndex := 0;
|
256 |
CBRej4.Items.Add(StrG); |
257 |
CBRej4.Items.Add('%');
|
258 |
CBRej4.ItemIndex := 0;
|
259 |
end;
|
260 |
|
261 |
procedure TFResSimulP.FormShow(Sender: TObject);
|
262 |
begin
|
263 |
MIPrint.Enabled := IsComplete or IsEducation;
|
264 |
MIExport.Enabled := MIPrint.Enabled; |
265 |
// Bas de page du graphique
|
266 |
Graph.Foot.Text.Clear; |
267 |
Graph.Foot.Text.Add(Format(StrSimul, [FSimulP.CBSimul.Text, FSimulP.CBProfil.Text, FSimulP.CBSeqAli.Text, FSimulP.CBRation.Text])); |
268 |
// Aliments
|
269 |
InitAli; |
270 |
// Performances
|
271 |
InitPerf; |
272 |
// D?p?t de prot?ines
|
273 |
InitPD; |
274 |
// Acides Amin?s
|
275 |
InitAA; |
276 |
// Energie
|
277 |
InitNRJ; |
278 |
// Min?raux
|
279 |
InitMin; |
280 |
// Rejets
|
281 |
InitRej; |
282 |
// Abscisses par d?faut
|
283 |
CBPerf2D.ItemIndex := XCrois; |
284 |
CBAli2D.ItemIndex := XCrois; |
285 |
CBPD2.ItemIndex := XCrois; |
286 |
CBAA2D.ItemIndex := XCrois; |
287 |
CBNRJ2D.ItemIndex := XCrois; |
288 |
CBMin2D.ItemIndex := XCrois; |
289 |
CBRej2D.ItemIndex := XCrois; |
290 |
// Affichage principal
|
291 |
PC.ActivePageIndex := 0;
|
292 |
PCChange(nil);
|
293 |
end;
|
294 |
|
295 |
procedure TFResSimulP.FormClose(Sender: TObject; var Action: TCloseAction); |
296 |
var
|
297 |
i: integer; |
298 |
begin
|
299 |
// Performances
|
300 |
BarPerf.Free; |
301 |
LinePerfAL.Free; |
302 |
LinePerf.Free; |
303 |
// Aliments
|
304 |
for i := 0 to ListAli.Count - 1 do |
305 |
BarAli[i].Free; |
306 |
SetLength(BarAli, 0);
|
307 |
for i := 0 to ListAli.Count - 1 do |
308 |
AreaAli[i].Free; |
309 |
SetLength(AreaAli, 0);
|
310 |
PieAli.Free; |
311 |
ListMat.Free; |
312 |
ListAli.Free; |
313 |
// D?p?t de prot?ines
|
314 |
for i := 0 to ListPD.Count do |
315 |
LinePD[i].Free; |
316 |
SetLength(LinePD, 0);
|
317 |
ListPD.Free; |
318 |
// Acides Amin?s
|
319 |
for i := 1 to 3 do |
320 |
LineAA[i].Free; |
321 |
for i := 0 to ListAA.Count - 1 do |
322 |
BarAA[i].Free; |
323 |
SetLength(BarAA, 0);
|
324 |
for i := 0 to ListAA.Count - 1 do |
325 |
AreaAA[i].Free; |
326 |
SetLength(AreaAA, 0);
|
327 |
PieAA.Free; |
328 |
ListAA.Free; |
329 |
// Energie
|
330 |
for i := 1 to 2 do |
331 |
LineNRJ[i].Free; |
332 |
for i := 0 to ListNRJ.Count - 1 do |
333 |
BarNRJ[i].Free; |
334 |
SetLength(BarNRJ, 0);
|
335 |
for i := 0 to ListNRJ.Count - 1 do |
336 |
AreaNRJ[i].Free; |
337 |
SetLength(AreaNRJ, 0);
|
338 |
PieNRJ.Free; |
339 |
ListNRJ.Free; |
340 |
// Min?raux
|
341 |
for i := 1 to 2 do |
342 |
LineMin[i].Free; |
343 |
for i := 0 to ListMin.Count - 1 do |
344 |
BarMin[i].Free; |
345 |
SetLength(BarMin, 0);
|
346 |
for i := 0 to ListMin.Count - 1 do |
347 |
AreaMin[i].Free; |
348 |
SetLength(AreaMin, 0);
|
349 |
PieMin.Free; |
350 |
ListMin.Free; |
351 |
// Rejets
|
352 |
for i := 0 to ListRej.Count - 1 do |
353 |
BarRej[i].Free; |
354 |
SetLength(BarRej, 0);
|
355 |
for i := 0 to ListRej.Count - 1 do |
356 |
AreaRej[i].Free; |
357 |
SetLength(AreaRej, 0);
|
358 |
PieRej.Free; |
359 |
ListRej.Free; |
360 |
end;
|
361 |
|
362 |
procedure TFResSimulP.PCChange(Sender: TObject);
|
363 |
begin
|
364 |
GBPDF.Visible := (PC.ActivePageIndex = 2);
|
365 |
case PC.ActivePageIndex of |
366 |
0: // Performances |
367 |
AffGraphPerf; |
368 |
1: // Aliments |
369 |
AffGraphAli; |
370 |
2: // D?p?t de prot?ines |
371 |
AffGraphPD; |
372 |
3: // Acides Amin?s |
373 |
AffGraphAA; |
374 |
4: // Energie |
375 |
AffGraphNRJ; |
376 |
5: // Min?raux |
377 |
AffGraphMin; |
378 |
6: // Rejets |
379 |
AffGraphRej; |
380 |
end;
|
381 |
end;
|
382 |
|
383 |
procedure TFResSimulP.ResetGraph;
|
384 |
var
|
385 |
i: integer; |
386 |
begin
|
387 |
Graph.UndoZoom; |
388 |
// Graph.View3D := FALSE;
|
389 |
Graph.Legend.Visible := TRUE; |
390 |
Graph.Legend.Alignment := laRight; |
391 |
Graph.Title.Text.Clear; |
392 |
Graph.SubTitle.Text.Clear; |
393 |
Graph.BottomAxis.MinimumOffset := 0;
|
394 |
Graph.BottomAxis.MaximumOffset := 0;
|
395 |
// Performances
|
396 |
LinePerf.Active := FALSE; |
397 |
LinePerfAL.Active := FALSE; |
398 |
BarPerf.Active := FALSE; |
399 |
// Aliments
|
400 |
PieAli.Active := FALSE; |
401 |
for i := 0 to ListAli.Count - 1 do |
402 |
AreaAli[i].Active := FALSE; |
403 |
for i := 0 to ListAli.Count - 1 do |
404 |
BarAli[i].Active := FALSE; |
405 |
// D?p?t de prot?ines
|
406 |
for i := 0 to ListPD.Count do |
407 |
LinePD[i].Active := FALSE; |
408 |
// Acides Amin?s
|
409 |
PieAA.Active := FALSE; |
410 |
for i := 0 to ListAA.Count - 1 do |
411 |
AreaAA[i].Active := FALSE; |
412 |
for i := 0 to ListAA.Count - 1 do |
413 |
BarAA[i].Active := FALSE; |
414 |
for i := 1 to 3 do |
415 |
LineAA[i].Active := FALSE; |
416 |
// Energie
|
417 |
PieNRJ.Active := FALSE; |
418 |
for i := 0 to ListNRJ.Count - 1 do |
419 |
AreaNRJ[i].Active := FALSE; |
420 |
for i := 0 to ListNRJ.Count - 1 do |
421 |
BarNRJ[i].Active := FALSE; |
422 |
for i := 1 to 2 do |
423 |
LineNRJ[i].Active := FALSE; |
424 |
// Min?raux
|
425 |
PieMin.Active := FALSE; |
426 |
for i := 0 to ListMin.Count - 1 do |
427 |
AreaMin[i].Active := FALSE; |
428 |
for i := 0 to ListMin.Count - 1 do |
429 |
BarMin[i].Active := FALSE; |
430 |
for i := 1 to 2 do |
431 |
LineMin[i].Active := FALSE; |
432 |
// Rejets
|
433 |
PieRej.Active := FALSE; |
434 |
for i := 0 to ListRej.Count - 1 do |
435 |
AreaRej[i].Active := FALSE; |
436 |
for i := 0 to ListRej.Count - 1 do |
437 |
BarRej[i].Active := FALSE; |
438 |
// Export
|
439 |
MExport.Clear; |
440 |
end;
|
441 |
|
442 |
procedure TFResSimulP.MI3DClick(Sender: TObject);
|
443 |
begin
|
444 |
Graph.View3D := not (Graph.View3D);
|
445 |
end;
|
446 |
|
447 |
procedure TFResSimulP.MIPreviewClick(Sender: TObject);
|
448 |
begin
|
449 |
FPrevGraph := TFPrevGraph.Create(Self); |
450 |
with FPrevGraph do |
451 |
begin
|
452 |
TPPGraph.Panels.Add(Graph); |
453 |
ShowModal; |
454 |
Release; |
455 |
end;
|
456 |
end;
|
457 |
|
458 |
procedure TFResSimulP.MIPrintClick(Sender: TObject);
|
459 |
begin
|
460 |
if PD.Execute
|
461 |
then
|
462 |
begin
|
463 |
Printer.Orientation := poLandscape; |
464 |
Graph.Print; |
465 |
end;
|
466 |
end;
|
467 |
|
468 |
procedure TFResSimulP.MIExportClick(Sender: TObject);
|
469 |
begin
|
470 |
SD.InitialDir := GetCurrentDir; |
471 |
if SD.Execute
|
472 |
then
|
473 |
MExport.Lines.SaveToFile(SD.FileName); |
474 |
end;
|
475 |
|
476 |
//////////////////////
|
477 |
// Performances //
|
478 |
//////////////////////
|
479 |
procedure TFResSimulP.InitPerf;
|
480 |
begin
|
481 |
// LinePerf : s?rie (ligne) graphique
|
482 |
LinePerf := TLineSeries.Create(Graph); |
483 |
LinePerf.ParentChart := Graph; |
484 |
// LinePerf.Title := ' ';
|
485 |
LinePerf.SeriesColor := clTeal; |
486 |
LinePerf.LinePen.Color := LinePerf.SeriesColor; |
487 |
LinePerf.LinePen.Width := 2;
|
488 |
Graph.AddSeries(LinePerf); |
489 |
// LinePerfAL : s?rie (ligne) graphique
|
490 |
LinePerfAL := TLineSeries.Create(Graph); |
491 |
LinePerfAL.ParentChart := Graph; |
492 |
// LinePerfAL.Title := ' ';
|
493 |
LinePerfAL.SeriesColor := clRed; |
494 |
Graph.AddSeries(LinePerfAL); |
495 |
// BarPerf : s?rie (barre) graphique
|
496 |
BarPerf := TBarSeries.Create(Graph); |
497 |
BarPerf.ParentChart := Graph; |
498 |
// BarPerf.Title := ' ';
|
499 |
BarPerf.SeriesColor := clTeal; |
500 |
BarPerf.BarPen.Color := BarPerf.SeriesColor; |
501 |
//BarPerf.Marks.Visible := FALSE;
|
502 |
BarPerf.Marks.ArrowLength := -16;
|
503 |
BarPerf.Marks.Arrow.Visible := FALSE; |
504 |
BarPerf.Marks.Brush.Style := bsClear; |
505 |
BarPerf.Marks.Frame.Visible := FALSE; |
506 |
BarPerf.Marks.Style := smsValue; |
507 |
//BarPerf.AutoMarkPosition := FALSE;
|
508 |
Graph.AddSeries(BarPerf); |
509 |
end;
|
510 |
|
511 |
procedure TFResSimulP.AffGraphPerf;
|
512 |
var
|
513 |
j, k: integer; |
514 |
x, p, cumul: double; |
515 |
s, csv: string;
|
516 |
|
517 |
// Abscisse
|
518 |
function PerfX: double;
|
519 |
begin
|
520 |
case CBPerf1.ItemIndex of |
521 |
0: // Affichage dynamique |
522 |
case CBPerf2D.ItemIndex of |
523 |
0: // Poids vif |
524 |
result := PResSimulP.TabResult[2, j];
|
525 |
1: // Age |
526 |
result := PResSimulP.TabResult[1, j];
|
527 |
2: // Jours |
528 |
result := j; |
529 |
3: // Semaines |
530 |
result := j / 7;
|
531 |
else
|
532 |
result := 0;
|
533 |
end;
|
534 |
1: // Affichage par p?riode |
535 |
case CBPerf2P.ItemIndex of |
536 |
0: // Semaine |
537 |
result := (j - 1) div 7 + 1; |
538 |
1: // R?gle qualit? |
539 |
result := PResSimulP.TabResult[3, j];
|
540 |
2: // R?gle quantit? |
541 |
result := PResSimulP.TabResult[5, j];
|
542 |
else
|
543 |
result := 0;
|
544 |
end;
|
545 |
else
|
546 |
result := 0;
|
547 |
end;
|
548 |
end;
|
549 |
|
550 |
// Ordonn?e
|
551 |
function PerfY: double;
|
552 |
var
|
553 |
h: integer; |
554 |
v, conso, ingere, gain: double; |
555 |
begin
|
556 |
case CBPerf1.ItemIndex of |
557 |
0: // Affichage dynamique |
558 |
case CBPerf3D.ItemIndex of |
559 |
0: // Body weight |
560 |
case CBPerf4.ItemIndex of |
561 |
0: // Weight gain (g/d) |
562 |
result := PResSimulP.TabResult[84, j] * 1000; |
563 |
1: // Body weight (kg) |
564 |
result := PResSimulP.TabResult[2, j];
|
565 |
else
|
566 |
result := 0;
|
567 |
end;
|
568 |
1: // Time |
569 |
case CBPerf4.ItemIndex of |
570 |
0: // Age (d) |
571 |
result := PResSimulP.TabResult[1, j];
|
572 |
else
|
573 |
result := 0;
|
574 |
end;
|
575 |
2: // Feed usage |
576 |
case CBPerf4.ItemIndex of |
577 |
0: // Feed usage (kg/d) |
578 |
result := PResSimulP.TabResult[113, j];
|
579 |
1: // Feed usage (kg DM/d) |
580 |
result := PResSimulP.TabResult[106, j] * PResSimulP.TabResult[113, j]; |
581 |
2: // Feed usage (MJ DE/d) |
582 |
result := PResSimulP.TabResult[109, j] * PResSimulP.TabResult[113, j]; |
583 |
3: // Feed usage (MJ ME/d) |
584 |
result := PResSimulP.TabResult[89, j] * PResSimulP.TabResult[113, j]; |
585 |
4: // Feed usage (MJ NE/d) |
586 |
result := PResSimulP.TabResult[90, j] * PResSimulP.TabResult[113, j]; |
587 |
5: // Total feed usage (kg) |
588 |
begin
|
589 |
cumul := cumul + PResSimulP.TabResult[113, j];
|
590 |
result := cumul; |
591 |
end;
|
592 |
6: // Total feed usage (kg DM) |
593 |
begin
|
594 |
cumul := cumul + PResSimulP.TabResult[106, j] * PResSimulP.TabResult[113, j]; |
595 |
result := cumul; |
596 |
end;
|
597 |
7: // Total feed usage (MJ DE) |
598 |
begin
|
599 |
cumul := cumul + PResSimulP.TabResult[109, j] * PResSimulP.TabResult[113, j]; |
600 |
result := cumul; |
601 |
end;
|
602 |
8: // Total feed usage (MJ ME) |
603 |
begin
|
604 |
cumul := cumul + PResSimulP.TabResult[89, j] * PResSimulP.TabResult[113, j]; |
605 |
result := cumul; |
606 |
end;
|
607 |
9: // Total feed usage (MJ NE) |
608 |
begin
|
609 |
cumul := cumul + PResSimulP.TabResult[90, j] * PResSimulP.TabResult[113, j]; |
610 |
result := cumul; |
611 |
end;
|
612 |
else
|
613 |
result := 0;
|
614 |
end;
|
615 |
3: // Feed wastage |
616 |
case CBPerf4.ItemIndex of |
617 |
0: // Feed wastage (%) |
618 |
result := PResSimulP.TabResult[112, j] * 100; |
619 |
1: // Total feed wastage (kg) |
620 |
begin
|
621 |
cumul := cumul + PResSimulP.TabResult[113, j] - PResSimulP.TabResult[11, j]; |
622 |
result := cumul; |
623 |
end;
|
624 |
else
|
625 |
result := 0;
|
626 |
end;
|
627 |
4: // Feed intake |
628 |
case CBPerf4.ItemIndex of |
629 |
0: // Feed intake (kg/d) |
630 |
result := PResSimulP.TabResult[11, j];
|
631 |
1: // Feed intake (kg DM/d) |
632 |
result := PResSimulP.TabResult[106, j] * PResSimulP.TabResult[11, j]; |
633 |
2: // Feed intake (MJ DE/d) |
634 |
result := PResSimulP.TabResult[109, j] * PResSimulP.TabResult[11, j]; |
635 |
3: // Feed intake (MJ ME/d) |
636 |
result := PResSimulP.TabResult[89, j] * PResSimulP.TabResult[11, j]; |
637 |
4: // Feed intake (MJ NE/d) |
638 |
result := PResSimulP.TabResult[90, j] * PResSimulP.TabResult[11, j]; |
639 |
5: // Total feed intake (kg) |
640 |
begin
|
641 |
cumul := cumul + PResSimulP.TabResult[11, j];
|
642 |
result := cumul; |
643 |
end;
|
644 |
6: // Total feed intake (kg DM) |
645 |
begin
|
646 |
cumul := cumul + PResSimulP.TabResult[106, j] * PResSimulP.TabResult[11, j]; |
647 |
result := cumul; |
648 |
end;
|
649 |
7: // Total feed intake (MJ DE) |
650 |
begin
|
651 |
cumul := cumul + PResSimulP.TabResult[109, j] * PResSimulP.TabResult[11, j]; |
652 |
result := cumul; |
653 |
end;
|
654 |
8: // Total feed intake (MJ ME) |
655 |
begin
|
656 |
cumul := cumul + PResSimulP.TabResult[89, j] * PResSimulP.TabResult[11, j]; |
657 |
result := cumul; |
658 |
end;
|
659 |
9: // Total feed intake (MJ NE) |
660 |
begin
|
661 |
cumul := cumul + PResSimulP.TabResult[90, j] * PResSimulP.TabResult[11, j]; |
662 |
result := cumul; |
663 |
end;
|
664 |
else
|
665 |
result := 0;
|
666 |
end;
|
667 |
5: // Feed:Gain |
668 |
if PResSimulP.TabResult[84, j] <> 0 |
669 |
then
|
670 |
case CBPerf4.ItemIndex of |
671 |
0: // Feed:Gain (kg/kg) |
672 |
result := PResSimulP.TabResult[113, j] / PResSimulP.TabResult[84, j]; |
673 |
1: // Feed:Gain (kg DM/kg) |
674 |
result := (PResSimulP.TabResult[106, j] * PResSimulP.TabResult[113, j]) / PResSimulP.TabResult[84, j]; |
675 |
2: // Feed:Gain (MJ DE/kg) |
676 |
result := (PResSimulP.TabResult[109, j] * PResSimulP.TabResult[113, j]) / PResSimulP.TabResult[84, j]; |
677 |
3: // Feed:Gain (MJ ME/kg) |
678 |
result := (PResSimulP.TabResult[89, j] * PResSimulP.TabResult[113, j]) / PResSimulP.TabResult[84, j]; |
679 |
4: // Feed:Gain (MJ NE/kg) |
680 |
result := (PResSimulP.TabResult[90, j] * PResSimulP.TabResult[113, j]) / PResSimulP.TabResult[84, j]; |
681 |
else
|
682 |
result := 0;
|
683 |
end
|
684 |
else
|
685 |
result := 0;
|
686 |
6: // Gain:Feed |
687 |
case CBPerf4.ItemIndex of |
688 |
0: // Gain:Feed (kg/kg) |
689 |
if PResSimulP.TabResult[113, j] <> 0 |
690 |
then
|
691 |
result := PResSimulP.TabResult[84, j] / PResSimulP.TabResult[113, j] |
692 |
else
|
693 |
result := 0;
|
694 |
1: // Gain:Feed (kg/kg DM) |
695 |
if (PResSimulP.TabResult[113, j] <> 0) and (PResSimulP.TabResult[106, j] <> 0) |
696 |
then
|
697 |
result := PResSimulP.TabResult[84, j] / (PResSimulP.TabResult[106, j] * PResSimulP.TabResult[113, j]) |
698 |
else
|
699 |
result := 0;
|
700 |
2: // Gain:Feed (kg/MJ DE) |
701 |
if (PResSimulP.TabResult[113, j] <> 0) and (PResSimulP.TabResult[109, j] <> 0) |
702 |
then
|
703 |
result := PResSimulP.TabResult[84, j] / (PResSimulP.TabResult[109, j] * PResSimulP.TabResult[113, j]) |
704 |
else
|
705 |
result := 0;
|
706 |
3: // Gain:Feed (kg/MJ ME) |
707 |
if (PResSimulP.TabResult[113, j] <> 0) and (PResSimulP.TabResult[89, j] <> 0) |
708 |
then
|
709 |
result := PResSimulP.TabResult[84, j] / (PResSimulP.TabResult[89, j] * PResSimulP.TabResult[113, j]) |
710 |
else
|
711 |
result := 0;
|
712 |
4: // Gain:Feed (kg/MJ NE) |
713 |
if (PResSimulP.TabResult[113, j] <> 0) and (PResSimulP.TabResult[90, j] <> 0) |
714 |
then
|
715 |
result := PResSimulP.TabResult[84, j] / (PResSimulP.TabResult[90, j] * PResSimulP.TabResult[113, j]) |
716 |
else
|
717 |
result := 0;
|
718 |
else
|
719 |
result := 0;
|
720 |
end;
|
721 |
7: // Protein |
722 |
case CBPerf4.ItemIndex of |
723 |
0: // Protein deposition (g/d) |
724 |
result := PResSimulP.TabResult[79, j];
|
725 |
1: // Protein mass (kg) |
726 |
result := PResSimulP.TabResult[49, j];
|
727 |
2: // Protein content (% of BW gain) |
728 |
if PResSimulP.TabResult[84, j] <> 0 |
729 |
then
|
730 |
result := (PResSimulP.TabResult[79, j] / 1000) / PResSimulP.TabResult[84, j] * 100 |
731 |
else
|
732 |
result := 0;
|
733 |
3: // Protein content (% in BW) |
734 |
if PResSimulP.TabResult[2, j] <> 0 |
735 |
then
|
736 |
result := PResSimulP.TabResult[49, j] / PResSimulP.TabResult[2, j] * 100 |
737 |
else
|
738 |
result := 0;
|
739 |
else
|
740 |
result := 0;
|
741 |
end;
|
742 |
8: // Lipid |
743 |
case CBPerf4.ItemIndex of |
744 |
0: // Lipid deposition (g/d) |
745 |
result := PResSimulP.TabResult[80, j];
|
746 |
1: // Lipid mass (kg) |
747 |
result := PResSimulP.TabResult[50, j];
|
748 |
2: // Lipid content (% of BW gain) |
749 |
if PResSimulP.TabResult[84, j] <> 0 |
750 |
then
|
751 |
result := (PResSimulP.TabResult[80, j] / 1000) / PResSimulP.TabResult[84, j] * 100 |
752 |
else
|
753 |
result := 0;
|
754 |
3: // Lipid content (% in BW) |
755 |
if PResSimulP.TabResult[2, j] <> 0 |
756 |
then
|
757 |
result := PResSimulP.TabResult[50, j] / PResSimulP.TabResult[2, j] * 100 |
758 |
else
|
759 |
result := 0;
|
760 |
else
|
761 |
result := 0;
|
762 |
end;
|
763 |
9: // Carcass |
764 |
case CBPerf4.ItemIndex of |
765 |
0: // Dressing percentage |
766 |
result := CalcRC(PResSimulP.TabResult[2, PResSimulP.NbJSim], CalcRCStd(PProfilP.PVFin, PProfilP.Carcasse), PResSimulP.TabResult[2, j]) * 100; |
767 |
1: // Backfat thickness |
768 |
if FatInfo = 0 |
769 |
then // P2 |
770 |
result := CalcP2(PResSimulP.TabResult[50, j])
|
771 |
else // User defined |
772 |
result := CalcUserFat(PResSimulP.TabResult[48, j], PResSimulP.TabResult[49, j], PResSimulP.TabResult[50, j]); |
773 |
2: // Lean meat percentage |
774 |
if LeanInfo = 0 |
775 |
then // TMP |
776 |
result := CalcTMP(PResSimulP.TabResult[48, j], PResSimulP.TabResult[49, j], PResSimulP.TabResult[50, j]) |
777 |
else // User defined |
778 |
result := CalcUserLean(PResSimulP.TabResult[48, j], PResSimulP.TabResult[49, j], PResSimulP.TabResult[50, j]); |
779 |
else
|
780 |
result := 0;
|
781 |
end;
|
782 |
else
|
783 |
result := 0;
|
784 |
end;
|
785 |
1: // Affichage par p?riode |
786 |
begin
|
787 |
v := 0;
|
788 |
case CBPerf3P.ItemIndex of |
789 |
0: // Body weight |
790 |
case CBPerf4.ItemIndex of |
791 |
0: // Weight gain (g/d) |
792 |
for h := k to j - 1 do |
793 |
v := v + PResSimulP.TabResult[84, h] * 1000 / (j - k); |
794 |
1: // Weight gain (kg) |
795 |
for h := k to j - 1 do |
796 |
v := v + PResSimulP.TabResult[84, h];
|
797 |
end;
|
798 |
1: // Time |
799 |
case CBPerf4.ItemIndex of |
800 |
0: // Duration (d) |
801 |
v := j - k; |
802 |
end;
|
803 |
2: // Feed usage |
804 |
case CBPerf4.ItemIndex of |
805 |
0: // Feed usage (kg/d) |
806 |
for h := k to j - 1 do |
807 |
v := v + PResSimulP.TabResult[113, h] / (j - k);
|
808 |
1: // Feed usage (kg DM/d) |
809 |
for h := k to j - 1 do |
810 |
v := v + PResSimulP.TabResult[106, h] * PResSimulP.TabResult[113, h] / (j - k); |
811 |
2: // Feed usage (MJ DE/d) |
812 |
for h := k to j - 1 do |
813 |
v := v + PResSimulP.TabResult[109, h] * PResSimulP.TabResult[113, h] / (j - k); |
814 |
3: // Feed usage (MJ ME/d) |
815 |
for h := k to j - 1 do |
816 |
v := v + PResSimulP.TabResult[89, h] * PResSimulP.TabResult[113, h] / (j - k); |
817 |
4: // Feed usage (MJ NE/d) |
818 |
for h := k to j - 1 do |
819 |
v := v + PResSimulP.TabResult[90, h] * PResSimulP.TabResult[113, h] / (j - k); |
820 |
5: // Total feed usage (kg) |
821 |
for h := k to j - 1 do |
822 |
v := v + PResSimulP.TabResult[113, h];
|
823 |
6: // Total feed usage (kg DM) |
824 |
for h := k to j - 1 do |
825 |
v := v + PResSimulP.TabResult[106, h] * PResSimulP.TabResult[113, h]; |
826 |
7: // Total feed usage (MJ DE) |
827 |
for h := k to j - 1 do |
828 |
v := v + PResSimulP.TabResult[109, h] * PResSimulP.TabResult[113, h]; |
829 |
8: // Total feed usage (MJ ME) |
830 |
for h := k to j - 1 do |
831 |
v := v + PResSimulP.TabResult[89, h] * PResSimulP.TabResult[113, h]; |
832 |
9: // Total feed usage (MJ NE) |
833 |
for h := k to j - 1 do |
834 |
v := v + PResSimulP.TabResult[90, h] * PResSimulP.TabResult[113, h]; |
835 |
end;
|
836 |
3: // Feed wastage |
837 |
case CBPerf4.ItemIndex of |
838 |
0: // Feed wastage (%) |
839 |
begin
|
840 |
conso := 0;
|
841 |
for h := k to j - 1 do |
842 |
conso := conso + PResSimulP.TabResult[113, h];
|
843 |
ingere := 0;
|
844 |
for h := k to j - 1 do |
845 |
ingere := ingere + PResSimulP.TabResult[11, h];
|
846 |
for h := k to j - 1 do |
847 |
v := v + PResSimulP.TabResult[112, h] * 100 / (j - k); |
848 |
if conso <> 0 |
849 |
then
|
850 |
v := (1 - ingere / conso) * 100; |
851 |
end;
|
852 |
1: // Total feed wastage (kg) |
853 |
for h := k to j - 1 do |
854 |
v := v + PResSimulP.TabResult[113, h] - PResSimulP.TabResult[11, h]; |
855 |
end;
|
856 |
4: // Feed intake |
857 |
case CBPerf4.ItemIndex of |
858 |
0: // Feed intake (kg/d) |
859 |
for h := k to j - 1 do |
860 |
v := v + PResSimulP.TabResult[11, h] / (j - k);
|
861 |
1: // Feed intake (kg DM/d) |
862 |
for h := k to j - 1 do |
863 |
v := v + PResSimulP.TabResult[106, h] * PResSimulP.TabResult[11, h] / (j - k); |
864 |
2: // Feed intake (MJ DE/d) |
865 |
for h := k to j - 1 do |
866 |
v := v + PResSimulP.TabResult[109, h] * PResSimulP.TabResult[11, h] / (j - k); |
867 |
3: // Feed intake (MJ ME/d) |
868 |
for h := k to j - 1 do |
869 |
v := v + PResSimulP.TabResult[89, h] * PResSimulP.TabResult[11, h] / (j - k); |
870 |
4: // Feed intake (MJ NE/d) |
871 |
for h := k to j - 1 do |
872 |
v := v + PResSimulP.TabResult[90, h] * PResSimulP.TabResult[11, h] / (j - k); |
873 |
5: // Total feed intake (kg) |
874 |
for h := k to j - 1 do |
875 |
v := v + PResSimulP.TabResult[11, h];
|
876 |
6: // Total feed intake (kg DM) |
877 |
for h := k to j - 1 do |
878 |
v := v + PResSimulP.TabResult[106, h] * PResSimulP.TabResult[11, h]; |
879 |
7: // Total feed intake (MJ DE) |
880 |
for h := k to j - 1 do |
881 |
v := v + PResSimulP.TabResult[109, h] * PResSimulP.TabResult[11, h]; |
882 |
8: // Total feed intake (MJ ME) |
883 |
for h := k to j - 1 do |
884 |
v := v + PResSimulP.TabResult[89, h] * PResSimulP.TabResult[11, h]; |
885 |
9: // Total feed intake (MJ NE) |
886 |
for h := k to j - 1 do |
887 |
v := v + PResSimulP.TabResult[90, h] * PResSimulP.TabResult[11, h]; |
888 |
end;
|
889 |
5: // Feed:Gain |
890 |
begin
|
891 |
conso := 0;
|
892 |
for h := k to j - 1 do |
893 |
case CBPerf4.ItemIndex of |
894 |
0: // Feed:Gain (kg/kg) |
895 |
conso := conso + PResSimulP.TabResult[113, h];
|
896 |
1: // Feed:Gain (kg DM/kg) |
897 |
conso := conso + PResSimulP.TabResult[106, h] * PResSimulP.TabResult[113, h]; |
898 |
2: // Feed:Gain (MJ DE/kg) |
899 |
conso := conso + PResSimulP.TabResult[109, h] * PResSimulP.TabResult[113, h]; |
900 |
3: // Feed:Gain (MJ ME/kg) |
901 |
conso := conso + PResSimulP.TabResult[89, h] * PResSimulP.TabResult[113, h]; |
902 |
4: // Feed:Gain (MJ NE/kg) |
903 |
conso := conso + PResSimulP.TabResult[90, h] * PResSimulP.TabResult[113, h]; |
904 |
end;
|
905 |
gain := 0;
|
906 |
for h := k to j - 1 do |
907 |
gain := gain + PResSimulP.TabResult[84, h];
|
908 |
if gain <> 0 |
909 |
then
|
910 |
v := conso / gain; |
911 |
end;
|
912 |
6: // Gain:Feed |
913 |
begin
|
914 |
gain := 0;
|
915 |
for h := k to j - 1 do |
916 |
gain := gain + PResSimulP.TabResult[84, h];
|
917 |
conso := 0;
|
918 |
for h := k to j - 1 do |
919 |
case CBPerf4.ItemIndex of |
920 |
0: // Gain:Feed (kg/kg) |
921 |
conso := conso + PResSimulP.TabResult[113, h];
|
922 |
1: // Gain:Feed (kg/kg DM) |
923 |
conso := conso + PResSimulP.TabResult[106, h] * PResSimulP.TabResult[113, h]; |
924 |
2: // Gain:Feed (kg/MJ DE) |
925 |
conso := conso + PResSimulP.TabResult[109, h] * PResSimulP.TabResult[113, h]; |
926 |
3: // Gain:Feed (kg/MJ ME) |
927 |
conso := conso + PResSimulP.TabResult[89, h] * PResSimulP.TabResult[113, h]; |
928 |
4: // Gain:Feed (kg/MJ NE) |
929 |
conso := conso + PResSimulP.TabResult[90, h] * PResSimulP.TabResult[113, h]; |
930 |
end;
|
931 |
if conso <> 0 |
932 |
then
|
933 |
v := gain / conso; |
934 |
end;
|
935 |
7: // Protein |
936 |
case CBPerf4.ItemIndex of |
937 |
0: // Protein deposition (g/d) |
938 |
for h := k to j - 1 do |
939 |
v := v + PResSimulP.TabResult[79, h] / (j - k);
|
940 |
1: // Protein deposition (kg) |
941 |
for h := k to j - 1 do |
942 |
v := v + PResSimulP.TabResult[79, h] / 1000; |
943 |
end;
|
944 |
8: // Lipid |
945 |
case CBPerf4.ItemIndex of |
946 |
0: // Lipid deposition (g/d) |
947 |
for h := k to j - 1 do |
948 |
v := v + PResSimulP.TabResult[80, h] / (j - k);
|
949 |
1: // Lipid deposition (kg) |
950 |
for h := k to j - 1 do |
951 |
v := v + PResSimulP.TabResult[80, h] / 1000; |
952 |
end;
|
953 |
end;
|
954 |
result := v; |
955 |
end;
|
956 |
else
|
957 |
result := 0;
|
958 |
end;
|
959 |
end;
|
960 |
|
961 |
// AffGraphPerf
|
962 |
begin
|
963 |
ResetGraph; |
964 |
Graph.Legend.Visible := FALSE; |
965 |
Graph.Title.Text.Add(Format('%s (%s)', [TabPerf.Caption, CBPerf1.Text]));
|
966 |
case CBPerf1.ItemIndex of |
967 |
0: // Affichage dynamique |
968 |
begin
|
969 |
Graph.LeftAxis.Title.Caption := CBPerf4.Text; |
970 |
Graph.BottomAxis.Title.Caption := CBPerf2D.Text; |
971 |
csv := CBPerf2D.Text; |
972 |
if (CBPerf3D.ItemIndex = 3) and CBPerfAL.Checked |
973 |
then // Ing?r? AdLib |
974 |
csv := csv + ';' + Format('%s (%s)', [CBPerfAL.Caption, CBPerf4.Text]); |
975 |
csv := csv + ';' + Format('%s (%s)', [CBPerf3D.Text, CBPerf4.Text]); |
976 |
MExport.Lines.Append(csv); |
977 |
if (CBPerf3D.ItemIndex = 3) and CBPerfAL.Checked |
978 |
then // Ing?r? AdLib |
979 |
begin
|
980 |
LinePerfAL.Active := TRUE; |
981 |
LinePerfAL.Clear; |
982 |
for j := 1 to PResSimulP.NbJSim do |
983 |
LinePerfAL.AddXY(PerfX, PResSimulP.TabResult[78, j] * PerfY / PResSimulP.TabResult[113, j]); |
984 |
end;
|
985 |
// Affichage de la ligne
|
986 |
LinePerf.Active := TRUE; |
987 |
LinePerf.Clear; |
988 |
cumul := 0;
|
989 |
for j := 1 to PResSimulP.NbJSim do |
990 |
LinePerf.AddXY(PerfX, PerfY, '', clTeeColor);
|
991 |
if CBPerf2D.ItemIndex = 3 |
992 |
then // Dur?e (semaine) |
993 |
Graph.BottomAxis.Increment := 1
|
994 |
else
|
995 |
Graph.BottomAxis.Increment := 10;
|
996 |
// Export
|
997 |
cumul := 0;
|
998 |
for j := 1 to PResSimulP.NbJSim do |
999 |
begin
|
1000 |
csv := FloatToStrF(PerfX, ffFixed, 15, 15); |
1001 |
if (CBPerf3D.ItemIndex = 3) and CBPerfAL.Checked |
1002 |
then // Ing?r? AdLib |
1003 |
csv := csv + ';' + FloatToStrF(PResSimulP.TabResult[78, j] * PerfY / PResSimulP.TabResult[113, j], ffFixed, 15, 15); |
1004 |
csv := csv + ';' + FloatToStrF(PerfY, ffFixed, 15, 15); |
1005 |
MExport.Lines.Append(csv); |
1006 |
end;
|
1007 |
end;
|
1008 |
1: // Affichage par p?riode |
1009 |
begin
|
1010 |
Graph.LeftAxis.Title.Caption := CBPerf4.Text; |
1011 |
Graph.BottomAxis.Title.Caption := CBPerf2P.Text; |
1012 |
csv := CBPerf2P.Text; |
1013 |
csv := csv + ';' + Format('%s (%s)', [CBPerf3P.Text, CBPerf4.Text]); |
1014 |
MExport.Lines.Append(csv); |
1015 |
// Affichage de la barre
|
1016 |
BarPerf.Active := TRUE; |
1017 |
BarPerf.Clear; |
1018 |
j := 1;
|
1019 |
x := PerfX; |
1020 |
k := 1;
|
1021 |
if PResSimulP.NbJSim > 1 |
1022 |
then
|
1023 |
for j := 2 to PResSimulP.NbJSim do |
1024 |
begin
|
1025 |
p := PerfX; |
1026 |
if x <> p
|
1027 |
then
|
1028 |
begin
|
1029 |
// Changement de p?riode
|
1030 |
s := Format('%1.0f', [x]);
|
1031 |
BarPerf.AddBar(PerfY, s, clTeeColor); |
1032 |
csv := s; |
1033 |
csv := csv + ';' + FloatToStrF(PerfY, ffFixed, 15, 15); |
1034 |
MExport.Lines.Append(csv); |
1035 |
x := p; |
1036 |
k := j; |
1037 |
end;
|
1038 |
end;
|
1039 |
j := PResSimulP.NbJSim + 1;
|
1040 |
if j > k
|
1041 |
then
|
1042 |
begin
|
1043 |
if CBPerf2P.ItemIndex = 3 |
1044 |
then // Globale |
1045 |
s := ' '
|
1046 |
else
|
1047 |
s := Format('%1.0f', [x]);
|
1048 |
BarPerf.AddBar(PerfY, s, clTeeColor); |
1049 |
csv := s; |
1050 |
csv := csv + ';' + FloatToStrF(PerfY, ffFixed, 15, 15); |
1051 |
MExport.Lines.Append(csv); |
1052 |
end;
|
1053 |
BarPerf.ValueFormat := AjustFormat(AjustPas(Graph.MaxYValue(Graph.LeftAxis) - Graph.MinYValue(Graph.LeftAxis))); |
1054 |
end;
|
1055 |
end;
|
1056 |
Graph.View3DOptions.Orthogonal := TRUE; |
1057 |
Graph.View3DOptions.Elevation := 345;
|
1058 |
Graph.View3DOptions.Rotation := 345;
|
1059 |
Graph.View3DOptions.Perspective := 15;
|
1060 |
AjustEchelle(Graph); |
1061 |
end;
|
1062 |
|
1063 |
procedure TFResSimulP.CBPerf1Change(Sender: TObject);
|
1064 |
begin
|
1065 |
CBPerf2D.Visible := CBPerf1.ItemIndex = 0;
|
1066 |
CBPerf3D.Visible := CBPerf1.ItemIndex = 0;
|
1067 |
CBPerf2P.Visible := CBPerf1.ItemIndex = 1;
|
1068 |
CBPerf3P.Visible := CBPerf1.ItemIndex = 1;
|
1069 |
CBPerf3Change(nil);
|
1070 |
end;
|
1071 |
|
1072 |
procedure TFResSimulP.CBPerf2Change(Sender: TObject);
|
1073 |
begin
|
1074 |
AffGraphPerf; |
1075 |
end;
|
1076 |
|
1077 |
procedure TFResSimulP.CBPerf3Change(Sender: TObject);
|
1078 |
begin
|
1079 |
CBPerf4.Items.Clear; |
1080 |
case CBPerf1.ItemIndex of |
1081 |
0: // Affichage dynamique |
1082 |
case CBPerf3D.ItemIndex of |
1083 |
0: // Body weight |
1084 |
begin
|
1085 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('Weight gain'), _('g'), _('d')])); |
1086 |
CBPerf4.Items.Add(Format('%s (%s)', [_('Body weight'), _('kg')])); |
1087 |
end;
|
1088 |
1: // Time |
1089 |
CBPerf4.Items.Add(Format('%s (%s)', [_('Age'), _('d')])); |
1090 |
2: // Feed usage |
1091 |
begin
|
1092 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('Feed usage'), _('kg'), _('d')])); |
1093 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('Feed usage'), _('kg DM'), _('d')])); |
1094 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('Feed usage'), _('MJ DE'), _('d')])); |
1095 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('Feed usage'), _('MJ ME'), _('d')])); |
1096 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('Feed usage'), _('MJ NE'), _('d')])); |
1097 |
CBPerf4.Items.Add(Format('%s (%s)', [_('Total feed usage'), _('kg')])); |
1098 |
CBPerf4.Items.Add(Format('%s (%s)', [_('Total feed usage'), _('kg DM')])); |
1099 |
CBPerf4.Items.Add(Format('%s (%s)', [_('Total feed usage'), _('MJ DE')])); |
1100 |
CBPerf4.Items.Add(Format('%s (%s)', [_('Total feed usage'), _('MJ ME')])); |
1101 |
CBPerf4.Items.Add(Format('%s (%s)', [_('Total feed usage'), _('MJ NE')])); |
1102 |
end;
|
1103 |
3: // Feed wastage |
1104 |
begin
|
1105 |
CBPerf4.Items.Add(Format('%s (%%)', [_('Feed wastage')])); |
1106 |
CBPerf4.Items.Add(Format('%s (%s)', [_('Total feed wastage'), _('kg')])); |
1107 |
end;
|
1108 |
4: // Feed intake |
1109 |
begin
|
1110 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('Feed intake'), _('kg'), _('d')])); |
1111 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('Feed intake'), _('kg DM'), _('d')])); |
1112 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('Feed intake'), _('MJ DE'), _('d')])); |
1113 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('Feed intake'), _('MJ ME'), _('d')])); |
1114 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('Feed intake'), _('MJ NE'), _('d')])); |
1115 |
CBPerf4.Items.Add(Format('%s (%s)', [_('Total feed intake'), _('kg')])); |
1116 |
CBPerf4.Items.Add(Format('%s (%s)', [_('Total feed intake'), _('kg DM')])); |
1117 |
CBPerf4.Items.Add(Format('%s (%s)', [_('Total feed intake'), _('MJ DE')])); |
1118 |
CBPerf4.Items.Add(Format('%s (%s)', [_('Total feed intake'), _('MJ ME')])); |
1119 |
CBPerf4.Items.Add(Format('%s (%s)', [_('Total feed intake'), _('MJ NE')])); |
1120 |
end;
|
1121 |
5: // Feed:Gain |
1122 |
begin
|
1123 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('F:G'), _('kg'), _('kg')])); |
1124 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('F:G'), _('kg DM'), _('kg')])); |
1125 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('F:G'), _('MJ DE'), _('kg')])); |
1126 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('F:G'), _('MJ ME'), _('kg')])); |
1127 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('F:G'), _('MJ NE'), _('kg')])); |
1128 |
end;
|
1129 |
6: // Gain:Feed |
1130 |
begin
|
1131 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('G:F'), _('kg'), _('kg')])); |
1132 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('G:F'), _('kg'), _('kg DM')])); |
1133 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('G:F'), _('kg'), _('MJ DE')])); |
1134 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('G:F'), _('kg'), _('MJ ME')])); |
1135 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('G:F'), _('kg'), _('MJ NE')])); |
1136 |
end;
|
1137 |
7: // Protein |
1138 |
begin
|
1139 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('Protein deposition'), _('g'), _('d')])); |
1140 |
CBPerf4.Items.Add(Format('%s (%s)', [_('Protein mass'), _('kg')])); |
1141 |
CBPerf4.Items.Add(Format('%s (%s)', [_('Protein content'), _('% BW gain')])); |
1142 |
CBPerf4.Items.Add(Format('%s (%s)', [_('Protein content'), _('% BW')])); |
1143 |
end;
|
1144 |
8: // Lipid |
1145 |
begin
|
1146 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('Lipid deposition'), _('g'), _('d')])); |
1147 |
CBPerf4.Items.Add(Format('%s (%s)', [_('Lipid mass'), _('kg')])); |
1148 |
CBPerf4.Items.Add(Format('%s (%s)', [_('Lipid content'), _('% BW gain')])); |
1149 |
CBPerf4.Items.Add(Format('%s (%s)', [_('Lipid content'), _('% BW')])); |
1150 |
end;
|
1151 |
9: // Carcass |
1152 |
begin
|
1153 |
CBPerf4.Items.Add(_('Dressing percentage'));
|
1154 |
if FatInfo = 0 |
1155 |
then // P2 |
1156 |
CBPerf4.Items.Add(Format('%s (%s)', [_('Backfat thickness'), _('mm')])) |
1157 |
else // User defined |
1158 |
if Length(UserFatLongName) = 0 |
1159 |
then
|
1160 |
CBPerf4.Items.Add(Format('%s (%s)', [_('User-defined backfat thickness'), _('mm')])) |
1161 |
else
|
1162 |
CBPerf4.Items.Add(Format('%s (%s)', [UserFatLongName, _('mm')])); |
1163 |
if LeanInfo = 0 |
1164 |
then // TMP |
1165 |
CBPerf4.Items.Add(Format('%s (%%)', [_('Lean meat')])) |
1166 |
else // User defined |
1167 |
if Length(UserLeanLongName) = 0 |
1168 |
then
|
1169 |
CBPerf4.Items.Add(Format('%s (%%)', [_('User-defined lean meat')])) |
1170 |
else
|
1171 |
CBPerf4.Items.Add(Format('%s (%%)', [UserLeanLongName]));
|
1172 |
end;
|
1173 |
end;
|
1174 |
1: // Affichage par p?riode |
1175 |
case CBPerf3P.ItemIndex of |
1176 |
0: // Body weight |
1177 |
begin
|
1178 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('Weight gain'), _('g'), _('d')])); |
1179 |
CBPerf4.Items.Add(Format('%s (%s)', [_('Weight gain'), _('kg')])); |
1180 |
end;
|
1181 |
1: // Time |
1182 |
CBPerf4.Items.Add(Format('%s (%s)', [_('Duration'), _('d')])); |
1183 |
2: // Feed usage |
1184 |
begin
|
1185 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('Feed usage'), _('kg'), _('d')])); |
1186 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('Feed usage'), _('kg DM'), _('d')])); |
1187 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('Feed usage'), _('MJ DE'), _('d')])); |
1188 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('Feed usage'), _('MJ ME'), _('d')])); |
1189 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('Feed usage'), _('MJ NE'), _('d')])); |
1190 |
CBPerf4.Items.Add(Format('%s (%s)', [_('Total feed usage'), _('kg')])); |
1191 |
CBPerf4.Items.Add(Format('%s (%s)', [_('Total feed usage'), _('kg DM')])); |
1192 |
CBPerf4.Items.Add(Format('%s (%s)', [_('Total feed usage'), _('MJ DE')])); |
1193 |
CBPerf4.Items.Add(Format('%s (%s)', [_('Total feed usage'), _('MJ ME')])); |
1194 |
CBPerf4.Items.Add(Format('%s (%s)', [_('Total feed usage'), _('MJ NE')])); |
1195 |
end;
|
1196 |
3: // Feed wastage |
1197 |
begin
|
1198 |
CBPerf4.Items.Add(Format('%s (%%)', [_('Feed wastage')])); |
1199 |
CBPerf4.Items.Add(Format('%s (%s)', [_('Total feed wastage'), _('kg')])); |
1200 |
end;
|
1201 |
4: // Feed intake |
1202 |
begin
|
1203 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('Feed intake'), _('kg'), _('d')])); |
1204 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('Feed intake'), _('kg DM'), _('d')])); |
1205 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('Feed intake'), _('MJ DE'), _('d')])); |
1206 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('Feed intake'), _('MJ ME'), _('d')])); |
1207 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('Feed intake'), _('MJ NE'), _('d')])); |
1208 |
CBPerf4.Items.Add(Format('%s (%s)', [_('Total feed intake'), _('kg')])); |
1209 |
CBPerf4.Items.Add(Format('%s (%s)', [_('Total feed intake'), _('kg DM')])); |
1210 |
CBPerf4.Items.Add(Format('%s (%s)', [_('Total feed intake'), _('MJ DE')])); |
1211 |
CBPerf4.Items.Add(Format('%s (%s)', [_('Total feed intake'), _('MJ ME')])); |
1212 |
CBPerf4.Items.Add(Format('%s (%s)', [_('Total feed intake'), _('MJ NE')])); |
1213 |
end;
|
1214 |
5: // Feed:Gain |
1215 |
begin
|
1216 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('F:G'), _('kg'), _('kg')])); |
1217 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('F:G'), _('kg DM'), _('kg')])); |
1218 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('F:G'), _('MJ DE'), _('kg')])); |
1219 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('F:G'), _('MJ ME'), _('kg')])); |
1220 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('F:G'), _('MJ NE'), _('kg')])); |
1221 |
end;
|
1222 |
6: // Gain:Feed |
1223 |
begin
|
1224 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('G:F'), _('kg'), _('kg')])); |
1225 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('G:F'), _('kg'), _('kg DM')])); |
1226 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('G:F'), _('kg'), _('MJ DE')])); |
1227 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('G:F'), _('kg'), _('MJ ME')])); |
1228 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('G:F'), _('kg'), _('MJ NE')])); |
1229 |
end;
|
1230 |
7: // Protein |
1231 |
begin
|
1232 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('Protein deposition'), _('g'), _('d')])); |
1233 |
CBPerf4.Items.Add(Format('%s (%s)', [_('Protein deposition'), _('kg')])); |
1234 |
end;
|
1235 |
8: // Lipid |
1236 |
begin
|
1237 |
CBPerf4.Items.Add(Format('%s (%s/%s)', [_('Lipid deposition'), _('g'), _('d')])); |
1238 |
CBPerf4.Items.Add(Format('%s (%s)', [_('Lipid deposition'), _('kg')])); |
1239 |
end;
|
1240 |
end;
|
1241 |
end;
|
1242 |
CBPerf4.ItemIndex := 0;
|
1243 |
CBPerfAL.Visible := (CBPerf1.ItemIndex = 0) and (CBPerf3D.ItemIndex = 3); |
1244 |
AffGraphPerf; |
1245 |
end;
|
1246 |
|
1247 |
procedure TFResSimulP.CBPerf4Change(Sender: TObject);
|
1248 |
begin
|
1249 |
AffGraphPerf; |
1250 |
end;
|
1251 |
|
1252 |
procedure TFResSimulP.CBPerfALClick(Sender: TObject);
|
1253 |
begin
|
1254 |
AffGraphPerf; |
1255 |
end;
|
1256 |
|
1257 |
//////////////////
|
1258 |
// Aliments //
|
1259 |
//////////////////
|
1260 |
procedure TFResSimulP.InitAli;
|
1261 |
var
|
1262 |
i, j: integer; |
1263 |
nom: string;
|
1264 |
begin
|
1265 |
// ListAli : liste des aliments utilis?s
|
1266 |
ListAli := TStringList.Create; |
1267 |
for i := 1 to 2 do // 2 aliments |
1268 |
for j := 1 to PResSimulP.NbJSim do |
1269 |
if PResSimulP.TabResult[8 + i, j] > 0 |
1270 |
then
|
1271 |
begin
|
1272 |
nom := FindNomAliment(Trunc(PResSimulP.TabResult[6 + i, j]));
|
1273 |
if ListAli.IndexOf(nom) = -1 |
1274 |
then
|
1275 |
ListAli.Add(nom); |
1276 |
end;
|
1277 |
// ListMat : liste des mati?res premi?res utilis?es
|
1278 |
CompositionComplete := TRUE; |
1279 |
ListMat := TStringList.Create; |
1280 |
for i := 0 to ListAli.Count - 1 do |
1281 |
begin
|
1282 |
PAliment := ListAliment[FindIdxAliment(ListAli[i])]; |
1283 |
if PAliment.MP.NbMat > 0 |
1284 |
then
|
1285 |
for j := 0 to PAliment.MP.NbMat - 1 do |
1286 |
begin
|
1287 |
nom := FindNomMatiere(PAliment.MP.NumMat[j]); |
1288 |
if ListMat.IndexOf(nom) = -1 |
1289 |
then
|
1290 |
ListMat.Add(nom); |
1291 |
end
|
1292 |
else
|
1293 |
CompositionComplete := FALSE; |
1294 |
end;
|
1295 |
CBAli5.Visible := ConfAffMP and CompositionComplete;
|
1296 |
// PieAli : s?rie (camembert) graphique
|
1297 |
PieAli := TPieSeries.Create(Graph); |
1298 |
PieAli.ParentChart := Graph; |
1299 |
PieAli.SeriesColor := clBlack; |
1300 |
PieAli.Circled := TRUE; |
1301 |
PieAli.Marks.ArrowLength := 24;
|
1302 |
PieAli.Marks.Arrow.Color := clBlack; |
1303 |
PieAli.Marks.Brush.Style := bsClear; |
1304 |
PieAli.Marks.Frame.Visible := FALSE; |
1305 |
PieAli.OtherSlice.Style := poBelowPercent; |
1306 |
PieAli.OtherSlice.Value := 1;
|
1307 |
PieAli.OtherSlice.Text := StrAutres; |
1308 |
Graph.AddSeries(PieAli); |
1309 |
// AreaAli : s?ries (aires) graphiques
|
1310 |
SetLength(AreaAli, ListAli.Count); |
1311 |
for i := 0 to ListAli.Count - 1 do |
1312 |
begin
|
1313 |
AreaAli[i] := TAreaSeries.Create(Graph); |
1314 |
AreaAli[i].ParentChart := Graph; |
1315 |
AreaAli[i].Title := ListAli[i]; |
1316 |
AreaAli[i].AreaLinesPen.Visible := FALSE; |
1317 |
Graph.AddSeries(AreaAli[i]); |
1318 |
end;
|
1319 |
// BarAli : s?ries (barres) graphiques
|
1320 |
SetLength(BarAli, ListAli.Count); |
1321 |
for i := 0 to ListAli.Count - 1 do |
1322 |
begin
|
1323 |
BarAli[i] := TBarSeries.Create(Graph); |
1324 |
BarAli[i].ParentChart := Graph; |
1325 |
BarAli[i].Title := ListAli[i]; |
1326 |
BarAli[i].SeriesColor := AreaAli[i].SeriesColor; |
1327 |
BarAli[i].BarPen.Color := BarAli[i].SeriesColor; |
1328 |
BarAli[i].Marks.Visible := FALSE; |
1329 |
Graph.AddSeries(BarAli[i]); |
1330 |
end;
|
1331 |
end;
|
1332 |
|
1333 |
procedure TFResSimulP.AffGraphAli;
|
1334 |
var
|
1335 |
i, j, k: integer; |
1336 |
x, y, t, p: double; |
1337 |
s, csv: string;
|
1338 |
|
1339 |
// Abscisse
|
1340 |
function AliX: double;
|
1341 |
begin
|
1342 |
case CBAli1.ItemIndex of |
1343 |
1: // R?partition dynamique |
1344 |
case CBAli2D.ItemIndex of |
1345 |
0: // Poids vif |
1346 |
result := PResSimulP.TabResult[2, j];
|
1347 |
1: // Age |
1348 |
result := PResSimulP.TabResult[1, j];
|
1349 |
2: // Jours |
1350 |
result := j; |
1351 |
3: // Semaines |
1352 |
result := j / 7;
|
1353 |
else
|
1354 |
result := 0;
|
1355 |
end;
|
1356 |
2: // R?partition par p?riode |
1357 |
case CBAli2P.ItemIndex of |
1358 |
0: // Semaine |
1359 |
result := (j - 1) div 7 + 1; |
1360 |
1: // R?gle qualit? |
1361 |
result := PResSimulP.TabResult[3, j];
|
1362 |
2: // R?gle quantit? |
1363 |
result := PResSimulP.TabResult[5, j];
|
1364 |
else
|
1365 |
result := 0;
|
1366 |
end;
|
1367 |
else
|
1368 |
result := 0;
|
1369 |
end;
|
1370 |
end;
|
1371 |
|
1372 |
// Ordonn?e (Aliments)
|
1373 |
function AliY: double;
|
1374 |
var
|
1375 |
h: integer; |
1376 |
v, d: double; |
1377 |
begin
|
1378 |
case CBAli1.ItemIndex of |
1379 |
0: // R?partition globale |
1380 |
begin
|
1381 |
v := 0;
|
1382 |
for h := 1 to PResSimulP.NbJSim do |
1383 |
begin
|
1384 |
if (PResSimulP.TabResult[7, h] <> -1) and (FindNomAliment (Trunc (PResSimulP.TabResult[7, h])) = ListAli[i]) |
1385 |
then // Aliment 1 |
1386 |
v := v + (PResSimulP.TabResult[113, h] * PResSimulP.TabResult[9, h] / 100); |
1387 |
if (PResSimulP.TabResult[8, h] <> -1) and (FindNomAliment (Trunc (PResSimulP.TabResult[8, h])) = ListAli[i]) |
1388 |
then // Aliment 2 |
1389 |
v := v + (PResSimulP.TabResult[113, h] * PResSimulP.TabResult[10, h] / 100); |
1390 |
end;
|
1391 |
if CBAli3.ItemIndex = 1 |
1392 |
then // Co?t |
1393 |
begin
|
1394 |
PAliment := ListAliment[FindIdxAliment (ListAli[i])]; |
1395 |
v := v * PAliment.Prix / 1000;
|
1396 |
end;
|
1397 |
result := v; |
1398 |
end;
|
1399 |
1: // R?partition dynamique |
1400 |
begin
|
1401 |
// Diviseur
|
1402 |
case CBAli3.ItemIndex of |
1403 |
1: // Co?t |
1404 |
case CBAli4.ItemIndex of |
1405 |
1: // GMQ |
1406 |
d := PResSimulP.TabResult[84, j];
|
1407 |
2: // Aliment |
1408 |
d := PResSimulP.TabResult[113, j];
|
1409 |
else
|
1410 |
d := 1;
|
1411 |
end;
|
1412 |
else
|
1413 |
d := 1;
|
1414 |
end;
|
1415 |
v := 0;
|
1416 |
if (PResSimulP.TabResult[7, j] <> -1) and (FindNomAliment (Trunc (PResSimulP.TabResult[7, j])) = ListAli[i]) |
1417 |
then // Aliment 1 |
1418 |
v := v + (PResSimulP.TabResult[113, j] * PResSimulP.TabResult[9, j] / 100); |
1419 |
if (PResSimulP.TabResult[8, j] <> -1) and (FindNomAliment (Trunc (PResSimulP.TabResult[8, j])) = ListAli[i]) |
1420 |
then // Aliment 2 |
1421 |
v := v + (PResSimulP.TabResult[113, j] * PResSimulP.TabResult[10, j] / 100); |
1422 |
if CBAli3.ItemIndex = 1 |
1423 |
then // Co?t |
1424 |
begin
|
1425 |
PAliment := ListAliment[FindIdxAliment (ListAli[i])]; |
1426 |
v := v * PAliment.Prix / 1000;
|
1427 |
end;
|
1428 |
result := v / d; |
1429 |
end;
|
1430 |
2: // R?partition par p?riode |
1431 |
begin
|
1432 |
// Diviseur
|
1433 |
case CBAli3.ItemIndex of |
1434 |
0: // Quantit? |
1435 |
case CBAli4.ItemIndex of |
1436 |
1: // Dur?e |
1437 |
d := j - k; |
1438 |
else
|
1439 |
d := 1;
|
1440 |
end;
|
1441 |
1: // Co?t |
1442 |
case CBAli4.ItemIndex of |
1443 |
1: // Dur?e |
1444 |
d := j - k; |
1445 |
2: // GMQ |
1446 |
begin
|
1447 |
d := 0;
|
1448 |
for h := k to j - 1 do |
1449 |
d := d + PResSimulP.TabResult[84, h];
|
1450 |
end;
|
1451 |
3: // Aliment |
1452 |
begin
|
1453 |
d := 0;
|
1454 |
for h := k to j - 1 do |
1455 |
d := d + PResSimulP.TabResult[113, h];
|
1456 |
end;
|
1457 |
else
|
1458 |
d := 1;
|
1459 |
end;
|
1460 |
else
|
1461 |
d := 1;
|
1462 |
end;
|
1463 |
v := 0;
|
1464 |
for h := k to j - 1 do |
1465 |
begin
|
1466 |
if (PResSimulP.TabResult[7, h] <> -1) and (FindNomAliment (Trunc (PResSimulP.TabResult[7, h])) = ListAli[i]) |
1467 |
then // Aliment 1 |
1468 |
v := v + (PResSimulP.TabResult[113, h] * PResSimulP.TabResult[9, h] / 100); |
1469 |
if (PResSimulP.TabResult[8, h] <> -1) and (FindNomAliment (Trunc (PResSimulP.TabResult[8, h])) = ListAli[i]) |
1470 |
then // Aliment 2 |
1471 |
v := v + (PResSimulP.TabResult[113, h] * PResSimulP.TabResult[10, h] / 100); |
1472 |
end;
|
1473 |
if CBAli3.ItemIndex = 1 |
1474 |
then // Co?t |
1475 |
begin
|
1476 |
PAliment := ListAliment[FindIdxAliment (ListAli[i])]; |
1477 |
v := v * PAliment.Prix / 1000;
|
1478 |
end;
|
1479 |
result := v / d; |
1480 |
end;
|
1481 |
else
|
1482 |
result := 0;
|
1483 |
end;
|
1484 |
end;
|
1485 |
|
1486 |
// Ordonn?es (Mati?res premi?res)
|
1487 |
function MatY: double;
|
1488 |
var
|
1489 |
g, h: integer; |
1490 |
v: double; |
1491 |
begin
|
1492 |
v := 0;
|
1493 |
for h := 1 to PResSimulP.NbJSim do |
1494 |
begin
|
1495 |
if PResSimulP.TabResult[7, h] <> -1 |
1496 |
then // Aliment 1 |
1497 |
begin
|
1498 |
PAliment := ListAliment[FindIdxAliment (FindNomAliment (Trunc (PResSimulP.TabResult[7, h])))];
|
1499 |
for g := 0 to PAliment.MP.NbMat - 1 do |
1500 |
if FindNomMatiere (PAliment.MP.NumMat[g]) = ListMat[i]
|
1501 |
then
|
1502 |
v := v + (PAliment.MP.Qte[g] * PResSimulP.TabResult[113, h] * PResSimulP.TabResult[9, h] / 100); |
1503 |
end;
|
1504 |
if PResSimulP.TabResult[8, h] <> -1 |
1505 |
then // Aliment 2 |
1506 |
begin
|
1507 |
PAliment := ListAliment[FindIdxAliment (FindNomAliment (Trunc (PResSimulP.TabResult[8, h])))];
|
1508 |
for g := 0 to PAliment.MP.NbMat - 1 do |
1509 |
if FindNomMatiere (PAliment.MP.NumMat[g]) = ListMat[i]
|
1510 |
then
|
1511 |
v := v + (PAliment.MP.Qte[g] * PResSimulP.TabResult[113, h] * PResSimulP.TabResult[10, h] / 100); |
1512 |
end;
|
1513 |
end;
|
1514 |
result := v / 1000; // Conversion g -> kg |
1515 |
end;
|
1516 |
|
1517 |
// AffGraphAli
|
1518 |
begin
|
1519 |
ResetGraph; |
1520 |
Graph.Title.Text.Add(Format('%s (%s)', [CBAli5.Text, CBAli1.Text]));
|
1521 |
Graph.LeftAxis.Title.Caption := Format('%s (%s)', [CBAli3.Text, CBAli4.Text]);
|
1522 |
case CBAli1.ItemIndex of |
1523 |
0: // R?partition globale |
1524 |
begin
|
1525 |
// Graph.View3D := TRUE;
|
1526 |
Graph.Legend.Visible := FALSE; |
1527 |
csv := '';
|
1528 |
for i := 0 to ListAli.Count - 1 do |
1529 |
csv := csv + Format('%s (%s)', [ListAli[i], CBAli4.Text]) + ';'; |
1530 |
MExport.Lines.Append(csv); |
1531 |
// Affichage du camembert
|
1532 |
PieAli.Active := TRUE; |
1533 |
PieAli.Clear; |
1534 |
if CBAli4.ItemIndex = 1 |
1535 |
then
|
1536 |
PieAli.Marks.Style := smsLabelPercent |
1537 |
else
|
1538 |
PieAli.Marks.Style := smsLabelValue; |
1539 |
t := 0;
|
1540 |
csv := '';
|
1541 |
if CBAli5.ItemIndex = 1 |
1542 |
then // Mati?res premi?res |
1543 |
for i := 0 to ListMat.Count - 1 do |
1544 |
begin
|
1545 |
y := MatY; |
1546 |
PieAli.AddPie(y, ListMat[i], clTeeColor); |
1547 |
t := t + y; |
1548 |
csv := csv + FloatToStrF(y, ffFixed, 15, 15) + ';'; |
1549 |
end
|
1550 |
else // Aliments |
1551 |
for i := 0 to ListAli.Count - 1 do |
1552 |
begin
|
1553 |
y := AliY; |
1554 |
PieAli.AddPie(y, ListAli[i], AreaAli[i].SeriesColor); |
1555 |
t := t + y; |
1556 |
csv := csv + FloatToStrF(y, ffFixed, 15, 15) + ';'; |
1557 |
end;
|
1558 |
Graph.SubTitle.Text.Add(Format('%s = %1.0f %s', [StrTotal, t, CBAli4.Items[0]])); |
1559 |
MExport.Lines.Append(csv); |
1560 |
PieAli.PercentFormat := Format('%s %s', [AjustFormat(1), CBAli4.Text]); |
1561 |
PieAli.ValueFormat := Format('%s %s', [AjustFormat(1), CBAli4.Text]); |
1562 |
end;
|
1563 |
1: // R?partition dynamique |
1564 |
begin
|
1565 |
Graph.BottomAxis.Title.Caption := CBAli2D.Text; |
1566 |
csv := CBAli2D.Text; |
1567 |
for i := 0 to ListAli.Count - 1 do |
1568 |
csv := csv + ';' + Format('%s (%s)', [ListAli[i], CBAli4.Text]); |
1569 |
MExport.Lines.Append(csv); |
1570 |
// Affichage des aires
|
1571 |
for i := 0 to ListAli.Count - 1 do |
1572 |
AreaAli[i].Active := TRUE; |
1573 |
for i := 0 to ListAli.Count - 1 do |
1574 |
AreaAli[i].Clear; |
1575 |
if (CBAli4.ItemIndex = 1) and (CBAli3.ItemIndex = 0) |
1576 |
then
|
1577 |
for i := 0 to ListAli.Count - 1 do |
1578 |
AreaAli[i].MultiArea := maStacked100 |
1579 |
else
|
1580 |
for i := 0 to ListAli.Count - 1 do |
1581 |
AreaAli[i].MultiArea := maStacked; |
1582 |
for j := 1 to PResSimulP.NbJSim do |
1583 |
begin
|
1584 |
csv := FloatToStrF(AliX, ffFixed, 15, 15); |
1585 |
for i := 0 to ListAli.Count - 1 do |
1586 |
begin
|
1587 |
AreaAli[i].AddXY(AliX, AliY, '', clTeeColor);
|
1588 |
csv := csv + ';' + FloatToStrF(AliY, ffFixed, 15, 15); |
1589 |
end;
|
1590 |
MExport.Lines.Append(csv); |
1591 |
end;
|
1592 |
if CBAli2D.ItemIndex = 3 |
1593 |
then // Dur?e (semaine) |
1594 |
Graph.BottomAxis.Increment := 1
|
1595 |
else
|
1596 |
Graph.BottomAxis.Increment := 10;
|
1597 |
end;
|
1598 |
2: // R?partition par p?riode |
1599 |
begin
|
1600 |
Graph.BottomAxis.Title.Caption := CBAli2P.Text; |
1601 |
csv := CBAli2P.Text; |
1602 |
for i := 0 to ListAli.Count - 1 do |
1603 |
csv := csv + ';' + Format('%s (%s)', [ListAli[i], CBAli4.Text]); |
1604 |
MExport.Lines.Append(csv); |
1605 |
// Affichage des barres
|
1606 |
for i := 0 to ListAli.Count - 1 do |
1607 |
BarAli[i].Active := TRUE; |
1608 |
for i := 0 to ListAli.Count - 1 do |
1609 |
BarAli[i].Clear; |
1610 |
if (CBAli4.ItemIndex = 2) and (CBAli3.ItemIndex = 0) |
1611 |
then
|
1612 |
for i := 0 to ListAli.Count - 1 do |
1613 |
BarAli[i].MultiBar := mbStacked100 |
1614 |
else
|
1615 |
for i := 0 to ListAli.Count - 1 do |
1616 |
BarAli[i].MultiBar := mbStacked; |
1617 |
j := 1;
|
1618 |
x := AliX; |
1619 |
k := 1;
|
1620 |
if PResSimulP.NbJSim > 1 |
1621 |
then
|
1622 |
for j := 2 to PResSimulP.NbJSim do |
1623 |
begin
|
1624 |
p := AliX; |
1625 |
if x <> p
|
1626 |
then
|
1627 |
begin
|
1628 |
// Changement de p?riode
|
1629 |
s := Format('%1.0f', [x]);
|
1630 |
csv := s; |
1631 |
for i := 0 to ListAli.Count - 1 do |
1632 |
begin
|
1633 |
y := AliY; |
1634 |
if y > 0 |
1635 |
then
|
1636 |
BarAli[i].AddBar(y, s, clTeeColor) |
1637 |
else
|
1638 |
BarAli[i].AddNull (s); |
1639 |
csv := csv + ';' + FloatToStrF(y, ffFixed, 15, 15); |
1640 |
end;
|
1641 |
MExport.Lines.Append(csv); |
1642 |
x := p; |
1643 |
k := j; |
1644 |
end;
|
1645 |
end;
|
1646 |
j := PResSimulP.NbJSim + 1;
|
1647 |
if j > k
|
1648 |
then
|
1649 |
begin
|
1650 |
if CBAli2P.ItemIndex = 3 |
1651 |
then // Globale |
1652 |
s := ' '
|
1653 |
else
|
1654 |
s := Format('%1.0f', [x]);
|
1655 |
csv := s; |
1656 |
for i := 0 to ListAli.Count - 1 do |
1657 |
begin
|
1658 |
y := AliY; |
1659 |
if y > 0 |
1660 |
then
|
1661 |
BarAli[i].AddBar(y, s, clTeeColor) |
1662 |
else
|
1663 |
BarAli[i].AddNull (s); |
1664 |
csv := csv + ';' + FloatToStrF(y, ffFixed, 15, 15); |
1665 |
end;
|
1666 |
MExport.Lines.Append(csv); |
1667 |
end;
|
1668 |
end;
|
1669 |
end;
|
1670 |
if PieAli.Active
|
1671 |
then
|
1672 |
begin
|
1673 |
Graph.View3DOptions.Orthogonal := FALSE; |
1674 |
Graph.View3DOptions.Elevation := 315;
|
1675 |
Graph.View3DOptions.Rotation := 360;
|
1676 |
Graph.View3DOptions.Perspective := 0;
|
1677 |
end
|
1678 |
else
|
1679 |
begin
|
1680 |
Graph.View3DOptions.Orthogonal := TRUE; |
1681 |
Graph.View3DOptions.Elevation := 345;
|
1682 |
Graph.View3DOptions.Rotation := 345;
|
1683 |
Graph.View3DOptions.Perspective := 15;
|
1684 |
end;
|
1685 |
AjustEchelle (Graph); |
1686 |
end;
|
1687 |
|
1688 |
procedure TFResSimulP.CBAli1Change(Sender: TObject);
|
1689 |
begin
|
1690 |
case CBAli1.ItemIndex of |
1691 |
0: // R?partition globale |
1692 |
begin
|
1693 |
CBAli2D.Visible := FALSE; |
1694 |
CBAli2P.Visible := FALSE; |
1695 |
CBAli5.Visible := ConfAffMP and CompositionComplete;
|
1696 |
end;
|
1697 |
1: // R?partition dynamique |
1698 |
begin
|
1699 |
CBAli2D.Visible := TRUE; |
1700 |
CBAli2P.Visible := FALSE; |
1701 |
CBAli3.Enabled := TRUE; |
1702 |
CBAli5.ItemIndex := 0; // Aliments |
1703 |
CBAli5.Visible := FALSE; |
1704 |
end;
|
1705 |
2: // R?partition par p?riode |
1706 |
begin
|
1707 |
CBAli2D.Visible := FALSE; |
1708 |
CBAli2P.Visible := TRUE; |
1709 |
CBAli3.Enabled := TRUE; |
1710 |
CBAli5.ItemIndex := 0; // Aliments |
1711 |
CBAli5.Visible := FALSE; |
1712 |
end;
|
1713 |
end;
|
1714 |
CBAli3Change(nil);
|
1715 |
end;
|
1716 |
|
1717 |
procedure TFResSimulP.CBAli2Change(Sender: TObject);
|
1718 |
begin
|
1719 |
AffGraphAli; |
1720 |
end;
|
1721 |
|
1722 |
procedure TFResSimulP.CBAli3Change(Sender: TObject);
|
1723 |
begin
|
1724 |
CBAli4.Items.Clear; |
1725 |
case CBAli1.ItemIndex of |
1726 |
0: // R?partition globale |
1727 |
case CBAli3.ItemIndex of |
1728 |
0: // Quantit? |
1729 |
begin
|
1730 |
CBAli4.Items.Add(StrKg); |
1731 |
CBAli4.Items.Add('%');
|
1732 |
end;
|
1733 |
1: // Co?t |
1734 |
begin
|
1735 |
CBAli4.Items.Add(CurrencySign); |
1736 |
CBAli4.Items.Add('%');
|
1737 |
end;
|
1738 |
end;
|
1739 |
1: // R?partition dynamique |
1740 |
case CBAli3.ItemIndex of |
1741 |
0: // Quantit? |
1742 |
begin
|
1743 |
CBAli4.Items.Add(Format('%s/%s', [StrKg, StrJ]));
|
1744 |
CBAli4.Items.Add('%');
|
1745 |
end;
|
1746 |
1: // Co?t |
1747 |
begin
|
1748 |
CBAli4.Items.Add(Format('%s/%s', [CurrencySign, StrJ]));
|
1749 |
CBAli4.Items.Add(Format('%s/%s %s', [CurrencySign, StrKg, StrGMQUnit]));
|
1750 |
CBAli4.Items.Add(Format('%s/%s %s', [CurrencySign, StrKg, StrAlimentUnit]));
|
1751 |
end;
|
1752 |
end;
|
1753 |
2: // R?partition par p?riode |
1754 |
case CBAli3.ItemIndex of |
1755 |
0: // Quantit? |
1756 |
begin
|
1757 |
CBAli4.Items.Add(StrKg); |
1758 |
CBAli4.Items.Add(Format('%s/%s', [StrKg, StrJ]));
|
1759 |
CBAli4.Items.Add('%');
|
1760 |
end;
|
1761 |
1: // Co?t |
1762 |
begin
|
1763 |
CBAli4.Items.Add(CurrencySign); |
1764 |
CBAli4.Items.Add(Format('%s/%s', [CurrencySign, StrJ]));
|
1765 |
CBAli4.Items.Add(Format('%s/%s %s', [CurrencySign, StrKg, StrGMQUnit]));
|
1766 |
CBAli4.Items.Add(Format('%s/%s %s', [CurrencySign, StrKg, StrAlimentUnit]));
|
1767 |
end;
|
1768 |
end;
|
1769 |
end;
|
1770 |
CBAli4.ItemIndex := 0;
|
1771 |
AffGraphAli; |
1772 |
end;
|
1773 |
|
1774 |
procedure TFResSimulP.CBAli4Change(Sender: TObject);
|
1775 |
begin
|
1776 |
AffGraphAli; |
1777 |
end;
|
1778 |
|
1779 |
procedure TFResSimulP.CBAli5Change(Sender: TObject);
|
1780 |
begin
|
1781 |
CBAli3.Enabled := CBAli5.ItemIndex = 0; // Aliments |
1782 |
if (CBAli5.ItemIndex = 1) and (CBAli3.ItemIndex <> 0) |
1783 |
then // Mati?res premi?res => Quantit? |
1784 |
begin
|
1785 |
CBAli3.ItemIndex := 0;
|
1786 |
CBAli4.Items.Clear; |
1787 |
CBAli4.Items.Add(StrKg); |
1788 |
CBAli4.Items.Add('%');
|
1789 |
CBAli4.ItemIndex := 0;
|
1790 |
end;
|
1791 |
AffGraphAli; |
1792 |
end;
|
1793 |
|
1794 |
////////////////////////////
|
1795 |
// D?p?t de prot?ines //
|
1796 |
////////////////////////////
|
1797 |
procedure TFResSimulP.InitPD;
|
1798 |
const
|
1799 |
TabColor: array[0..14] of TColor = (clRed, clGreen, clYellow, clBlue, |
1800 |
clFuchsia, clTeal, clNavy, clLime, clMaroon, clOlive, clPurple, clAqua, |
1801 |
clMoneyGreen, clSkyBlue, clCream); |
1802 |
type
|
1803 |
TRecTriPD = record
|
1804 |
Idx: integer; |
1805 |
Min: double; |
1806 |
Moy: double; |
1807 |
end;
|
1808 |
var
|
1809 |
i, j: integer; |
1810 |
TabTriPD: array of TRecTriPD; |
1811 |
TabTemp: array of double; |
1812 |
RecTemp: TRecTriPD; |
1813 |
begin
|
1814 |
// ListPD : liste pour le d?p?t de prot?ines
|
1815 |
ListPD := TStringList.Create; |
1816 |
ListPD.Assign(LBPD.Items); |
1817 |
// Initialisation du tableau
|
1818 |
SetLength(TabTriPD, ListPD.Count); |
1819 |
SetLength(TabTemp, PResSimulP.NbJSim); |
1820 |
for i := 0 to ListPD.Count - 1 do |
1821 |
begin
|
1822 |
TabTriPD[i].Idx := i; |
1823 |
case i of |
1824 |
0: // Energie |
1825 |
for j := 1 to PResSimulP.NbJSim do |
1826 |
TabTemp[j - 1] := PResSimulP.TabResult[77, j] / GEProtJaap |
1827 |
/ PResSimulP.TabResult[79, j];
|
1828 |
1: // PDmax |
1829 |
for j := 1 to PResSimulP.NbJSim do |
1830 |
TabTemp[j - 1] := PResSimulP.TabResult[69, j] / GEProtJaap |
1831 |
/ PResSimulP.TabResult[79, j];
|
1832 |
2: // Lysine |
1833 |
for j := 1 to PResSimulP.NbJSim do |
1834 |
TabTemp[j - 1] := PResSimulP.TabResult[33, j] |
1835 |
/ PResSimulP.TabResult[79, j];
|
1836 |
3: // Thr?onine |
1837 |
for j := 1 to PResSimulP.NbJSim do |
1838 |
TabTemp[j - 1] := PResSimulP.TabResult[37, j] |
1839 |
/ PResSimulP.TabResult[79, j];
|
1840 |
4: // Tryptophane |
1841 |
for j := 1 to PResSimulP.NbJSim do |
1842 |
TabTemp[j - 1] := PResSimulP.TabResult[36, j] |
1843 |
/ PResSimulP.TabResult[79, j];
|
1844 |
5: // M?thionine |
1845 |
for j := 1 to PResSimulP.NbJSim do |
1846 |
TabTemp[j - 1] := PResSimulP.TabResult[34, j] |
1847 |
/ PResSimulP.TabResult[79, j];
|
1848 |
6: // M?thionine+Cystine |
1849 |
for j := 1 to PResSimulP.NbJSim do |
1850 |
TabTemp[j - 1] := PResSimulP.TabResult[45, j] |
1851 |
/ PResSimulP.TabResult[79, j];
|
1852 |
7: // Valine |
1853 |
for j := 1 to PResSimulP.NbJSim do |
1854 |
TabTemp[j - 1] := PResSimulP.TabResult[42, j] |
1855 |
/ PResSimulP.TabResult[79, j];
|
1856 |
8: // Isoleucine |
1857 |
for j := 1 to PResSimulP.NbJSim do |
1858 |
TabTemp[j - 1] := PResSimulP.TabResult[41, j] |
1859 |
/ PResSimulP.TabResult[79, j];
|
1860 |
9: // Leucine |
1861 |
for j := 1 to PResSimulP.NbJSim do |
1862 |
TabTemp[j - 1] := PResSimulP.TabResult[40, j] |
1863 |
/ PResSimulP.TabResult[79, j];
|
1864 |
10: // Ph?nylalanine |
1865 |
for j := 1 to PResSimulP.NbJSim do |
1866 |
TabTemp[j - 1] := PResSimulP.TabResult[38, j] |
1867 |
/ PResSimulP.TabResult[79, j];
|
1868 |
11: // Ph?nylalanine+Tyrosine |
1869 |
for j := 1 to PResSimulP.NbJSim do |
1870 |
TabTemp[j - 1] := PResSimulP.TabResult[46, j] |
1871 |
/ PResSimulP.TabResult[79, j];
|
1872 |
12: // Arginine |
1873 |
for j := 1 to PResSimulP.NbJSim do |
1874 |
TabTemp[j - 1] := PResSimulP.TabResult[44, j] |
1875 |
/ PResSimulP.TabResult[79, j];
|
1876 |
13: // Histidine |
1877 |
for j := 1 to PResSimulP.NbJSim do |
1878 |
TabTemp[j - 1] := PResSimulP.TabResult[43, j] |
1879 |
/ PResSimulP.TabResult[79, j];
|
1880 |
14: // MAT |
1881 |
for j := 1 to PResSimulP.NbJSim do |
1882 |
TabTemp[j - 1] := PResSimulP.TabResult[32, j] |
1883 |
/ PResSimulP.TabResult[79, j];
|
1884 |
end;
|
1885 |
TabTriPD[i].Min := MinValue(TabTemp); |
1886 |
TabTriPD[i].Moy := Mean(TabTemp); |
1887 |
end;
|
1888 |
// D?termination du nombre de facteurs limitants
|
1889 |
NbLimit := 0;
|
1890 |
for i := 0 to ListPD.Count - 1 do |
1891 |
if TabTriPD[i].Min - 1 < PICO then Inc(NbLimit); |
1892 |
// Tri du tableau (tri ? bulle) sur Min et Moy
|
1893 |
for i := ListPD.Count - 1 downto 1 do |
1894 |
for j := 0 to i - 1 do |
1895 |
if (TabTriPD[j].Min > TabTriPD[j + 1].Min) |
1896 |
// or ((TabTriPD[j].Min = TabTriPD[j + 1].Min)
|
1897 |
or ((Abs (TabTriPD[j].Min - TabTriPD[j + 1].Min) < PICO) |
1898 |
and (TabTriPD[j].Moy > TabTriPD[j + 1].Moy)) |
1899 |
then
|
1900 |
begin
|
1901 |
RecTemp.Idx := TabTriPD[j].Idx; |
1902 |
RecTemp.Min := TabTriPD[j].Min; |
1903 |
RecTemp.Moy := TabTriPD[j].Moy; |
1904 |
TabTriPD[j].Idx := TabTriPD[j + 1].Idx;
|
1905 |
TabTriPD[j].Min := TabTriPD[j + 1].Min;
|
1906 |
TabTriPD[j].Moy := TabTriPD[j + 1].Moy;
|
1907 |
TabTriPD[j + 1].Idx := RecTemp.Idx;
|
1908 |
TabTriPD[j + 1].Min := RecTemp.Min;
|
1909 |
TabTriPD[j + 1].Moy := RecTemp.Moy;
|
1910 |
end;
|
1911 |
// Construction de la liste tri?e
|
1912 |
LBPD.Items.Clear; |
1913 |
for i := 0 to ListPD.Count - 1 do |
1914 |
LBPD.Items.Add(ListPD[TabTriPD[i].Idx]); |
1915 |
// LinePD : s?ries (lignes) graphiques
|
1916 |
SetLength(LinePD, ListPD.Count + 1);
|
1917 |
// D?p?t de prot?ines
|
1918 |
LinePD[ListPD.Count] := TLineSeries.Create(Graph); |
1919 |
LinePD[ListPD.Count].ParentChart := Graph; |
1920 |
LinePD[ListPD.Count].Title := StrMinimum; |
1921 |
LinePD[ListPD.Count].SeriesColor := clBlack; |
1922 |
LinePD[ListPD.Count].LinePen.Color := LinePD[ListPD.Count].SeriesColor; |
1923 |
LinePD[ListPD.Count].LinePen.Width := 2;
|
1924 |
Graph.AddSeries(LinePD[ListPD.Count]); |
1925 |
// Facteurs potentiellement limitants
|
1926 |
for i := 0 to ListPD.Count - 1 do |
1927 |
begin
|
1928 |
LinePD[i] := TLineSeries.Create(Graph); |
1929 |
LinePD[i].ParentChart := Graph; |
1930 |
LinePD[i].Title := ListPD[i]; |
1931 |
LinePD[i].SeriesColor := TabColor[LBPD.Items.IndexOf (ListPD[i])]; |
1932 |
LinePD[i].LinePen.Color := LinePD[i].SeriesColor; |
1933 |
LinePD[i].LinePen.Width := 2;
|
1934 |
Graph.AddSeries(LinePD[i]); |
1935 |
end;
|
1936 |
// S?lection des facteurs effectivement limitants
|
1937 |
for i := 0 to NbLimit - 1 do |
1938 |
LBPD.Selected[i] := TRUE; |
1939 |
end;
|
1940 |
|
1941 |
procedure TFResSimulP.AffGraphPD;
|
1942 |
var
|
1943 |
i, j: integer; |
1944 |
csv: string;
|
1945 |
|
1946 |
// Abscisse
|
1947 |
function PDX: double;
|
1948 |
begin
|
1949 |
case CBPD2.ItemIndex of |
1950 |
0: // Poids vif |
1951 |
result := PResSimulP.TabResult[2, j];
|
1952 |
1: // Age |
1953 |
result := PResSimulP.TabResult[1, j];
|
1954 |
2: // Jours |
1955 |
result := j; |
1956 |
3: // Semaines |
1957 |
result := j / 7;
|
1958 |
else
|
1959 |
result := 0;
|
1960 |
end;
|
1961 |
end;
|
1962 |
|
1963 |
// Ordonn?e
|
1964 |
function PDY: double;
|
1965 |
begin
|
1966 |
case i of |
1967 |
0: // Energie |
1968 |
result := PResSimulP.TabResult[77, j] / GEProtJaap;
|
1969 |
1: // PDmax |
1970 |
result := PResSimulP.TabResult[69, j] / GEProtJaap;
|
1971 |
2: // Lysine |
1972 |
result := PResSimulP.TabResult[33, j];
|
1973 |
3: // Thr?onine |
1974 |
result := PResSimulP.TabResult[37, j];
|
1975 |
4: // Tryptophane |
1976 |
result := PResSimulP.TabResult[36, j];
|
1977 |
5: // M?thionine |
1978 |
result := PResSimulP.TabResult[34, j];
|
1979 |
6: // M?thionine+Cystine |
1980 |
result := PResSimulP.TabResult[45, j];
|
1981 |
7: // Valine |
1982 |
result := PResSimulP.TabResult[42, j];
|
1983 |
8: // Isoleucine |
1984 |
result := PResSimulP.TabResult[41, j];
|
1985 |
9: // Leucine |
1986 |
result := PResSimulP.TabResult[40, j];
|
1987 |
10: // Ph?nylalanine |
1988 |
result := PResSimulP.TabResult[38, j];
|
1989 |
11: // Ph?nylalanine+Tyrosine |
1990 |
result := PResSimulP.TabResult[46, j];
|
1991 |
12: // Arginine |
1992 |
result := PResSimulP.TabResult[44, j];
|
1993 |
13: // Histidine |
1994 |
result := PResSimulP.TabResult[43, j];
|
1995 |
14: // MAT |
1996 |
result := PResSimulP.TabResult[32, j];
|
1997 |
15: // D?p?t de prot?ines |
1998 |
result := PResSimulP.TabResult[79, j];
|
1999 |
else
|
2000 |
result := 0;
|
2001 |
end;
|
2002 |
end;
|
2003 |
|
2004 |
// AffGraphPD
|
2005 |
begin
|
2006 |
ResetGraph; |
2007 |
Graph.Legend.Visible := FALSE; |
2008 |
Graph.Title.Text.Add(TabPD.Caption); |
2009 |
Graph.LeftAxis.Title.Caption := Format('%s (%s/%s)', [TabPD.Caption, StrG, StrJ]);
|
2010 |
Graph.BottomAxis.Title.Caption := CBPD2.Text; |
2011 |
csv := CBPD2.Text; |
2012 |
for i := 0 to ListPD.Count - 1 do |
2013 |
csv := csv + ';' + Format('%s (%s %s/%s)', [ListPD[i], StrG, StrPD, StrJ]); |
2014 |
csv := csv + ';' + StrMinimum;
|
2015 |
MExport.Lines.Append(csv); |
2016 |
// Affichage des lignes
|
2017 |
for i := 0 to ListPD.Count do |
2018 |
LinePD[i].Active := TRUE; |
2019 |
for i := 0 to ListPD.Count do |
2020 |
LinePD[i].Clear; |
2021 |
for j := 1 to PResSimulP.NbJSim do |
2022 |
begin
|
2023 |
csv := FloatToStrF(PDX, ffFixed, 15, 15); |
2024 |
for i := 0 to ListPD.Count - 1 do |
2025 |
begin
|
2026 |
if LBPD.Selected[LBPD.Items.IndexOf(ListPD[i])]
|
2027 |
then
|
2028 |
LinePD[i].AddXY(PDX, PDY); |
2029 |
csv := csv + ';' + FloatToStrF(PDY, ffFixed, 15, 15); |
2030 |
end;
|
2031 |
i := ListPD.Count; |
2032 |
LinePD[i].AddXY(PDX, PDY); |
2033 |
csv := csv + ';' + FloatToStrF(PDY, ffFixed, 15, 15); |
2034 |
MExport.Lines.Append(csv); |
2035 |
end;
|
2036 |
if CBPD2.ItemIndex = 3 |
2037 |
then // Dur?e (semaine) |
2038 |
Graph.BottomAxis.Increment := 1
|
2039 |
else
|
2040 |
Graph.BottomAxis.Increment := 10;
|
2041 |
Graph.View3DOptions.Orthogonal := TRUE; |
2042 |
Graph.View3DOptions.Elevation := 345;
|
2043 |
Graph.View3DOptions.Rotation := 345;
|
2044 |
Graph.View3DOptions.Perspective := 15;
|
2045 |
AjustEchelle(Graph); |
2046 |
end;
|
2047 |
|
2048 |
procedure TFResSimulP.CBPD2Change(Sender: TObject);
|
2049 |
begin
|
2050 |
AffGraphPD; |
2051 |
end;
|
2052 |
|
2053 |
procedure TFResSimulP.LBPDClick(Sender: TObject);
|
2054 |
begin
|
2055 |
AffGraphPD; |
2056 |
end;
|
2057 |
|
2058 |
procedure TFResSimulP.LBPDDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
|
2059 |
begin
|
2060 |
with (Control as TListBox).Canvas do |
2061 |
begin
|
2062 |
// Cadre principal
|
2063 |
FillRect(Rect); |
2064 |
// Etoile
|
2065 |
SetTextAlign(Handle, TA_RIGHT); |
2066 |
if Index < NbLimit
|
2067 |
then // Facteur limitant |
2068 |
TextRect(Rect, Rect.Right - 4, Rect.Top, '*'); |
2069 |
Rect.Right := Rect.Right - 16;
|
2070 |
// Texte
|
2071 |
SetTextAlign (Handle, TA_LEFT); |
2072 |
TextRect(Rect, Rect.Left + 32, Rect.Top, LBPD.Items[Index]);
|
2073 |
Rect.Right := 32;
|
2074 |
// Num?ro
|
2075 |
SetTextAlign (Handle, TA_RIGHT); |
2076 |
TextRect(Rect, Rect.Right - 8, Rect.Top, Format('%d', [Index + 1])); |
2077 |
// Couleur
|
2078 |
if odSelected in State |
2079 |
then
|
2080 |
begin
|
2081 |
// Cadre noir
|
2082 |
Brush.Color := clBlack; |
2083 |
Rect.Top := Rect.Top + 2;
|
2084 |
Rect.Bottom := Rect.Bottom - 2;
|
2085 |
Rect.Left := Rect.Left + 2;
|
2086 |
Rect.Right := Rect.Left + (Rect.Bottom - Rect.Top); |
2087 |
FillRect(Rect); |
2088 |
// Carr? de couleur
|
2089 |
Brush.Color := LinePD[ListPD.IndexOf(LBPD.Items[Index])].SeriesColor; |
2090 |
Rect.Top := Rect.Top + 1;
|
2091 |
Rect.Bottom := Rect.Bottom - 1;
|
2092 |
Rect.Left := Rect.Left + 1;
|
2093 |
Rect.Right := Rect.Right - 1;
|
2094 |
FillRect(Rect); |
2095 |
end;
|
2096 |
end;
|
2097 |
end;
|
2098 |
|
2099 |
///////////////////////
|
2100 |
// Acides amin?s //
|
2101 |
///////////////////////
|
2102 |
procedure TFResSimulP.InitAA;
|
2103 |
const
|
2104 |
TabColor1: array[0..8] of TColor |
2105 |
= (clBlack, clTeal, clAqua, clOlive, clSilver, clPink, clGray, clRed, clGreen); |
2106 |
TabColor2: array[1..3] of TColor |
2107 |
= (clGreen, clRed, clRed); |
2108 |
var
|
2109 |
i: integer; |
2110 |
begin
|
2111 |
// ListAA : liste pour les acides amin?s
|
2112 |
ListAA := TStringList.Create; |
2113 |
ListAA.Assign(LBAA.Items); |
2114 |
// PieAA : s?rie (camembert) graphique
|
2115 |
PieAA := TPieSeries.Create(Graph); |
2116 |
PieAA.ParentChart := Graph; |
2117 |
PieAA.Circled := TRUE; |
2118 |
PieAA.Marks.ArrowLength := 24;
|
2119 |
PieAA.Marks.Arrow.Color := clBlack; |
2120 |
PieAA.Marks.Brush.Style := bsClear; |
2121 |
PieAA.Marks.Frame.Visible := FALSE; |
2122 |
PieAA.ValueFormat := Format('# ##0 %s', [StrG]);
|
2123 |
PieAA.PercentFormat := '##0 %';
|
2124 |
Graph.AddSeries(PieAA); |
2125 |
// AreaAA : s?ries (aires) graphiques
|
2126 |
SetLength(AreaAA, ListAA.Count); |
2127 |
for i := 0 to ListAA.Count - 1 do |
2128 |
begin
|
2129 |
AreaAA[i] := TAreaSeries.Create(Graph); |
2130 |
AreaAA[i].ParentChart := Graph; |
2131 |
AreaAA[i].Title := ListAA[i]; |
2132 |
AreaAA[i].SeriesColor := TabColor1[i]; |
2133 |
AreaAA[i].AreaLinesPen.Visible := FALSE; |
2134 |
Graph.AddSeries(AreaAA[i]); |
2135 |
end;
|
2136 |
// BarAA : s?ries (barres) graphiques
|
2137 |
SetLength(BarAA, ListAA.Count); |
2138 |
for i := 0 to ListAA.Count - 1 do |
2139 |
begin
|
2140 |
BarAA[i] := TBarSeries.Create(Graph); |
2141 |
BarAA[i].ParentChart := Graph; |
2142 |
BarAA[i].Title := ListAA[i]; |
2143 |
BarAA[i].SeriesColor := TabColor1[i]; |
2144 |
BarAA[i].BarPen.Color := BarAA[i].SeriesColor; |
2145 |
BarAA[i].Marks.Visible := FALSE; |
2146 |
Graph.AddSeries(BarAA[i]); |
2147 |
end;
|
2148 |
// LineAA : s?ries (lignes) graphiques
|
2149 |
for i := 1 to 3 do |
2150 |
begin
|
2151 |
LineAA[i] := TLineSeries.Create(Graph); |
2152 |
LineAA[i].ParentChart := Graph; |
2153 |
case i of |
2154 |
2: // Besoin (population) |
2155 |
LineAA[i].Title := StrBesoinPopulation; |
2156 |
3: // Besoin (animal moyen) |
2157 |
LineAA[i].Title := StrBesoinMoyen; |
2158 |
else // Apport |
2159 |
LineAA[i].Title := StrApport; |
2160 |
end;
|
2161 |
LineAA[i].SeriesColor := TabColor2[i]; |
2162 |
if i <> 2 |
2163 |
then // Ligne |
2164 |
begin
|
2165 |
LineAA[i].LinePen.Color := LineAA[i].SeriesColor; |
2166 |
LineAA[i].LinePen.Width := 2;
|
2167 |
end
|
2168 |
else // Pointill?s |
2169 |
begin
|
2170 |
LineAA[i].LinePen.Style := psClear; |
2171 |
LineAA[i].Pointer.Visible := TRUE; |
2172 |
LineAA[i].Pointer.HorizSize := 2;
|
2173 |
LineAA[i].Pointer.VertSize := 1;
|
2174 |
LineAA[i].Pointer.Frame.Visible := FALSE; |
2175 |
end;
|
2176 |
Graph.AddSeries(LineAA[i]); |
2177 |
end;
|
2178 |
end;
|
2179 |
|
2180 |
procedure TFResSimulP.AffGraphAA;
|
2181 |
const
|
2182 |
TriAA: array[0..8] of integer = (2, 3, 4, 6, 7, 8, 5, 0, 1); |
2183 |
var
|
2184 |
i, j, k: integer; |
2185 |
x, y, t, p, PD, py1: double; |
2186 |
s, csv: string;
|
2187 |
|
2188 |
// Abscisse
|
2189 |
function AAX: double;
|
2190 |
begin
|
2191 |
case CBAA1.ItemIndex of |
2192 |
1: // R?partition dynamique |
2193 |
case CBAA2D.ItemIndex of |
2194 |
0: // Poids vif |
2195 |
result := PResSimulP.TabResult[2, j];
|
2196 |
1: // Age |
2197 |
result := PResSimulP.TabResult[1, j];
|
2198 |
2: // Jours |
2199 |
result := j; |
2200 |
3: // Semaines |
2201 |
result := j / 7;
|
2202 |
else
|
2203 |
result := 0;
|
2204 |
end;
|
2205 |
2: // R?partition par p?riode |
2206 |
case CBAA2P.ItemIndex of |
2207 |
0: // Semaine |
2208 |
result := (j - 1) div 7 + 1; |
2209 |
1: // R?gle qualit? |
2210 |
result := PResSimulP.TabResult[3, j];
|
2211 |
2: // R?gle quantit? |
2212 |
result := PResSimulP.TabResult[5, j];
|
2213 |
else
|
2214 |
result := 0;
|
2215 |
end;
|
2216 |
3: // Besoin et apport |
2217 |
case CBAA2D.ItemIndex of |
2218 |
0: // Poids vif |
2219 |
result := PResSimulP.TabResult[2, j];
|
2220 |
1: // Age |
2221 |
result := PResSimulP.TabResult[1, j];
|
2222 |
2: // Jours |
2223 |
result := j; |
2224 |
3: // Semaines |
2225 |
result := j / 7;
|
2226 |
else
|
2227 |
result := 0;
|
2228 |
end;
|
2229 |
else
|
2230 |
result := 0;
|
2231 |
end;
|
2232 |
end;
|
2233 |
|
2234 |
// Ordonn?e
|
2235 |
function AAY: double;
|
2236 |
var
|
2237 |
h: integer; |
2238 |
v, d, endogeneAA, m75AA, AAk, bodyAA, AAingere, AAdigestible, PDAA, |
2239 |
IngereSec, PV, AAPD, AAAA, AAenergie, PD3, PDapport, Gaspillage: double; |
2240 |
begin
|
2241 |
case CBAA1.ItemIndex of |
2242 |
0: // R?partition globale |
2243 |
begin
|
2244 |
v := 0;
|
2245 |
case i of |
2246 |
0: // Gaspillage |
2247 |
if CBAA5.ItemIndex = 2 |
2248 |
then // Total |
2249 |
for h := 1 to PResSimulP.NbJSim do |
2250 |
begin
|
2251 |
AAingere := PResSimulP.TabResult[93 + CBAA3.ItemIndex, h];
|
2252 |
Gaspillage := PResSimulP.TabResult[112, h];
|
2253 |
v := v + AAingere / (1 - Gaspillage) - AAingere;
|
2254 |
if (CBAA3.ItemIndex = 3) or (CBAA3.ItemIndex = 7) |
2255 |
then // met + cys, phe + tyr |
2256 |
begin
|
2257 |
AAingere := PResSimulP.TabResult[92 + CBAA3.ItemIndex, h];
|
2258 |
v := v + AAingere / (1 - Gaspillage) - AAingere;
|
2259 |
end;
|
2260 |
end;
|
2261 |
1: // Indigestible |
2262 |
if CBAA5.ItemIndex = 2 |
2263 |
then // Total |
2264 |
for h := 1 to PResSimulP.NbJSim do |
2265 |
begin
|
2266 |
AAingere := PResSimulP.TabResult[93 + CBAA3.ItemIndex, h];
|
2267 |
AAdigestible := PResSimulP.TabResult[19 + CBAA3.ItemIndex, h];
|
2268 |
v := v + (AAingere - AAdigestible); |
2269 |
if (CBAA3.ItemIndex = 3) or (CBAA3.ItemIndex = 7) |
2270 |
then // met + cys, phe + tyr |
2271 |
begin
|
2272 |
AAingere := PResSimulP.TabResult[92 + CBAA3.ItemIndex, h];
|
2273 |
AAdigestible := PResSimulP.TabResult[18 + CBAA3.ItemIndex, h];
|
2274 |
v := v + (AAingere - AAdigestible); |
2275 |
end;
|
2276 |
end;
|
2277 |
2: // Endog?ne basal |
2278 |
if CBAA5.ItemIndex <> 1 |
2279 |
then // Total ou Digestible standardis? |
2280 |
for h := 1 to PResSimulP.NbJSim do |
2281 |
begin
|
2282 |
IngereSec := PResSimulP.TabResult[106, h] * PResSimulP.TabResult[11, h]; |
2283 |
endogeneAA := AAendogene[CBAA3.ItemIndex]; |
2284 |
v := v + (IngereSec * endogeneAA); |
2285 |
if (CBAA3.ItemIndex = 3) or (CBAA3.ItemIndex = 7) |
2286 |
then // met + cys, phe + tyr |
2287 |
begin
|
2288 |
endogeneAA := AAendogene[CBAA3.ItemIndex - 1];
|
2289 |
v := v + (IngereSec * endogeneAA); |
2290 |
end;
|
2291 |
end;
|
2292 |
3: // Entretien |
2293 |
for h := 1 to PResSimulP.NbJSim do |
2294 |
begin
|
2295 |
PV := PResSimulP.TabResult[2, h];
|
2296 |
m75AA := AAm75[CBAA3.ItemIndex]; |
2297 |
v := v + (m75AA * Power (PV, 0.75));
|
2298 |
if (CBAA3.ItemIndex = 3) or (CBAA3.ItemIndex = 7) |
2299 |
then // met + cys, phe + tyr |
2300 |
begin
|
2301 |
m75AA := AAm75[CBAA3.ItemIndex - 1];
|
2302 |
v := v + (m75AA * Power (PV, 0.75));
|
2303 |
end;
|
2304 |
end;
|
2305 |
4: // Oxydation minimale |
2306 |
for h := 1 to PResSimulP.NbJSim do |
2307 |
begin
|
2308 |
PD := PResSimulP.TabResult[79, h];
|
2309 |
bodyAA := AAbody[CBAA3.ItemIndex]; |
2310 |
AAk := kAA[CBAA3.ItemIndex]; |
2311 |
if AAk <= 1 |
2312 |
then
|
2313 |
v := v + (PD * bodyAA / AAk * (1 - AAk));
|
2314 |
if (CBAA3.ItemIndex = 3) or (CBAA3.ItemIndex = 7) |
2315 |
then // met + cys, phe + tyr |
2316 |
begin
|
2317 |
bodyAA := AAbody[CBAA3.ItemIndex - 1];
|
2318 |
AAk := kAA[CBAA3.ItemIndex - 1];
|
2319 |
if AAk <= 1 |
2320 |
then
|
2321 |
v := v + (PD * bodyAA / AAk * (1 - AAk));
|
2322 |
end;
|
2323 |
end;
|
2324 |
5: // D?pot |
2325 |
for h := 1 to PResSimulP.NbJSim do |
2326 |
begin
|
2327 |
PD := PResSimulP.TabResult[79, h];
|
2328 |
bodyAA := AAbody[CBAA3.ItemIndex]; |
2329 |
v := v + (PD * bodyAA); |
2330 |
if (CBAA3.ItemIndex = 3) or (CBAA3.ItemIndex = 7) |
2331 |
then // met + cys, phe + tyr |
2332 |
begin
|
2333 |
bodyAA := AAbody[CBAA3.ItemIndex - 1];
|
2334 |
v := v + (PD * bodyAA); |
2335 |
end;
|
2336 |
end;
|
2337 |
6: // D?s?quilibre |
2338 |
if CBAA3.ItemIndex = 12 |
2339 |
then // Arginine |
2340 |
for h := 1 to PResSimulP.NbJSim do |
2341 |
begin
|
2342 |
PD := PResSimulP.TabResult[79, h];
|
2343 |
py1 := PResSimulP.TabResult[77, h];
|
2344 |
PD3 := py1 / GEProtJaap; |
2345 |
PDAA := PResSimulP.TabResult[44, h];
|
2346 |
AAk := kAA[12];
|
2347 |
PDapport := PDAA / AAk; |
2348 |
bodyAA := AAbody[12];
|
2349 |
if (PD < PD3) and (PD < PDAA) |
2350 |
then
|
2351 |
if (PDapport > PD3) or (PD3 < PDAA) |
2352 |
then
|
2353 |
v := v + ((PD3 - PD) * bodyAA) |
2354 |
else
|
2355 |
v := v + ((PDAA - PD) * bodyAA); |
2356 |
end
|
2357 |
else
|
2358 |
for h := 1 to PResSimulP.NbJSim do |
2359 |
begin
|
2360 |
PDAA := PResSimulP.TabResult[32 + CBAA3.ItemIndex, h];
|
2361 |
bodyAA := AAbody[CBAA3.ItemIndex]; |
2362 |
AAk := kAA[CBAA3.ItemIndex]; |
2363 |
AAAA := PDAA * bodyAA / AAk; |
2364 |
PD := PResSimulP.TabResult[79, h];
|
2365 |
AAPD := PD * bodyAA / AAk; |
2366 |
py1 := PResSimulP.TabResult[77, h];
|
2367 |
AAenergie := py1 / GEProtJaap * bodyAA / AAk; |
2368 |
if (CBAA3.ItemIndex = 3) or (CBAA3.ItemIndex = 7) |
2369 |
then // met + cys, phe + tyr |
2370 |
begin
|
2371 |
PDAA := PResSimulP.TabResult[31 + CBAA3.ItemIndex, h];
|
2372 |
bodyAA := AAbody[CBAA3.ItemIndex - 1];
|
2373 |
AAk := kAA[CBAA3.ItemIndex - 1];
|
2374 |
AAAA := AAAA + (PDAA * bodyAA / AAk); |
2375 |
AAPD := AAPD + (PD * bodyAA / AAk); |
2376 |
AAenergie := AAenergie + (py1 / GEProtJaap * bodyAA / AAk); |
2377 |
end;
|
2378 |
if AAPD < AAAA
|
2379 |
then
|
2380 |
if AAAA < AAenergie
|
2381 |
then
|
2382 |
v := v + (AAAA - AAPD) |
2383 |
else
|
2384 |
v := v + (AAenergie - AAPD); |
2385 |
end;
|
2386 |
7: // D?ficit |
2387 |
if CBAA3.ItemIndex = 12 |
2388 |
then // Arginine |
2389 |
for h := 1 to PResSimulP.NbJSim do |
2390 |
begin
|
2391 |
py1 := PResSimulP.TabResult[77, h];
|
2392 |
PD3 := py1 / GEProtJaap; |
2393 |
PDAA := PResSimulP.TabResult[44, h];
|
2394 |
bodyAA := AAbody[12];
|
2395 |
if PDAA < PD3
|
2396 |
then
|
2397 |
v := v + ((PD3 - PDAA) * bodyAA); |
2398 |
end
|
2399 |
else
|
2400 |
for h := 1 to PResSimulP.NbJSim do |
2401 |
begin
|
2402 |
PDAA := PResSimulP.TabResult[32 + CBAA3.ItemIndex, h];
|
2403 |
bodyAA := AAbody[CBAA3.ItemIndex]; |
2404 |
AAk := kAA[CBAA3.ItemIndex]; |
2405 |
AAAA := PDAA * bodyAA / AAk; |
2406 |
py1 := PResSimulP.TabResult[77, h];
|
2407 |
AAenergie := py1 / GEProtJaap * bodyAA / AAk; |
2408 |
if (CBAA3.ItemIndex = 3) or (CBAA3.ItemIndex = 7) |
2409 |
then // met + cys, phe + tyr |
2410 |
begin
|
2411 |
PDAA := PResSimulP.TabResult[31 + CBAA3.ItemIndex, h];
|
2412 |
bodyAA := AAbody[CBAA3.ItemIndex - 1];
|
2413 |
AAk := kAA[CBAA3.ItemIndex - 1];
|
2414 |
AAAA := AAAA + (PDAA * bodyAA / AAk); |
2415 |
AAenergie := AAenergie + (py1 / GEProtJaap * bodyAA / AAk); |
2416 |
end;
|
2417 |
if AAAA < AAenergie
|
2418 |
then
|
2419 |
v := v + (AAenergie - AAAA); |
2420 |
end;
|
2421 |
8: // Exc?s |
2422 |
if CBAA3.ItemIndex = 12 |
2423 |
then // Arginine |
2424 |
for h := 1 to PResSimulP.NbJSim do |
2425 |
begin
|
2426 |
py1 := PResSimulP.TabResult[77, h];
|
2427 |
PD3 := py1 / GEProtJaap; |
2428 |
PDAA := PResSimulP.TabResult[44, h];
|
2429 |
AAk := kAA[12];
|
2430 |
PDapport := PDAA / AAk; |
2431 |
bodyAA := AAbody[12];
|
2432 |
if PD3 < PDapport
|
2433 |
then
|
2434 |
v := v + ((PDapport - PD3) * bodyAA); |
2435 |
end
|
2436 |
else
|
2437 |
for h := 1 to PResSimulP.NbJSim do |
2438 |
begin
|
2439 |
PDAA := PResSimulP.TabResult[32 + CBAA3.ItemIndex, h];
|
2440 |
bodyAA := AAbody[CBAA3.ItemIndex]; |
2441 |
AAk := kAA[CBAA3.ItemIndex]; |
2442 |
AAAA := PDAA * bodyAA / AAk; |
2443 |
py1 := PResSimulP.TabResult[77, h];
|
2444 |
AAenergie := py1 / GEProtJaap * bodyAA / AAk; |
2445 |
if (CBAA3.ItemIndex = 3) or (CBAA3.ItemIndex = 7) |
2446 |
then // met + cys, phe + tyr |
2447 |
begin
|
2448 |
PDAA := PResSimulP.TabResult[31 + CBAA3.ItemIndex, h];
|
2449 |
bodyAA := AAbody[CBAA3.ItemIndex - 1];
|
2450 |
AAk := kAA[CBAA3.ItemIndex - 1];
|
2451 |
AAAA := AAAA + (PDAA * bodyAA / AAk); |
2452 |
AAenergie := AAenergie + (py1 / GEProtJaap * bodyAA / AAk); |
2453 |
end;
|
2454 |
if AAenergie < AAAA
|
2455 |
then
|
2456 |
v := v + (AAAA - AAenergie); |
2457 |
end;
|
2458 |
end;
|
2459 |
result := v; |
2460 |
end;
|
2461 |
1: // R?partition dynamique |
2462 |
begin
|
2463 |
// Diviseur
|
2464 |
if CBAA4.ItemIndex = 1 |
2465 |
then // Aliment ing?r? |
2466 |
d := PResSimulP.TabResult[113, j]
|
2467 |
else
|
2468 |
d := 1;
|
2469 |
case i of |
2470 |
0: // Gaspillage |
2471 |
if CBAA5.ItemIndex = 2 |
2472 |
then // Total |
2473 |
begin
|
2474 |
AAingere := PResSimulP.TabResult[93 + CBAA3.ItemIndex, j];
|
2475 |
Gaspillage := PResSimulP.TabResult[112, j];
|
2476 |
v := AAingere / (1 - Gaspillage) - AAingere;
|
2477 |
if (CBAA3.ItemIndex = 3) or (CBAA3.ItemIndex = 7) |
2478 |
then // met + cys, phe + tyr |
2479 |
begin
|
2480 |
AAingere := PResSimulP.TabResult[92 + CBAA3.ItemIndex, j];
|
2481 |
v := v + AAingere / (1 - Gaspillage) - AAingere;
|
2482 |
end;
|
2483 |
end
|
2484 |
else
|
2485 |
v := 0;
|
2486 |
1: // Indigestible |
2487 |
if CBAA5.ItemIndex = 2 |
2488 |
then // Total |
2489 |
begin
|
2490 |
AAingere := PResSimulP.TabResult[93 + CBAA3.ItemIndex, j];
|
2491 |
AAdigestible := PResSimulP.TabResult[19 + CBAA3.ItemIndex, j];
|
2492 |
v := AAingere - AAdigestible; |
2493 |
if (CBAA3.ItemIndex = 3) or (CBAA3.ItemIndex = 7) |
2494 |
then // met + cys, phe + tyr |
2495 |
begin
|
2496 |
AAingere := PResSimulP.TabResult[92 + CBAA3.ItemIndex, j];
|
2497 |
AAdigestible := PResSimulP.TabResult[18 + CBAA3.ItemIndex, j];
|
2498 |
v := v + (AAingere - AAdigestible); |
2499 |
end;
|
2500 |
end
|
2501 |
else
|
2502 |
v := 0;
|
2503 |
2: // Endog?ne basal |
2504 |
if CBAA5.ItemIndex <> 1 |
2505 |
then // Total ou Digestible standardis? |
2506 |
begin
|
2507 |
IngereSec := PResSimulP.TabResult[106, j] * PResSimulP.TabResult[11, j]; |
2508 |
endogeneAA := AAendogene[CBAA3.ItemIndex]; |
2509 |
v := IngereSec * endogeneAA; |
2510 |
if (CBAA3.ItemIndex = 3) or (CBAA3.ItemIndex = 7) |
2511 |
then // met + cys, phe + tyr |
2512 |
begin
|
2513 |
endogeneAA := AAendogene[CBAA3.ItemIndex - 1];
|
2514 |
v := v + (IngereSec * endogeneAA); |
2515 |
end;
|
2516 |
end
|
2517 |
else
|
2518 |
v := 0;
|
2519 |
3: // Entretien |
2520 |
begin
|
2521 |
PV := PResSimulP.TabResult[2, j];
|
2522 |
m75AA := AAm75[CBAA3.ItemIndex]; |
2523 |
v := m75AA * Power (PV, 0.75);
|
2524 |
if (CBAA3.ItemIndex = 3) or (CBAA3.ItemIndex = 7) |
2525 |
then // met + cys, phe + tyr |
2526 |
begin
|
2527 |
m75AA := AAm75[CBAA3.ItemIndex - 1];
|
2528 |
v := v + (m75AA * Power (PV, 0.75));
|
2529 |
end;
|
2530 |
end;
|
2531 |
4: // Oxydation minimale |
2532 |
begin
|
2533 |
PD := PResSimulP.TabResult[79, j];
|
2534 |
bodyAA := AAbody[CBAA3.ItemIndex]; |
2535 |
AAk := kAA[CBAA3.ItemIndex]; |
2536 |
if AAk <= 1 |
2537 |
then
|
2538 |
v := PD * bodyAA / AAk * (1 - AAk)
|
2539 |
else
|
2540 |
v := 0;
|
2541 |
if (CBAA3.ItemIndex = 3) or (CBAA3.ItemIndex = 7) |
2542 |
then // met + cys, phe + tyr |
2543 |
begin
|
2544 |
bodyAA := AAbody[CBAA3.ItemIndex - 1];
|
2545 |
AAk := kAA[CBAA3.ItemIndex - 1];
|
2546 |
if AAk <= 1 |
2547 |
then
|
2548 |
v := v + (PD * bodyAA / AAk * (1 - AAk));
|
2549 |
end;
|
2550 |
end;
|
2551 |
5: // D?pot |
2552 |
begin
|
2553 |
PD := PResSimulP.TabResult[79, j];
|
2554 |
bodyAA := AAbody[CBAA3.ItemIndex]; |
2555 |
v := PD * bodyAA; |
2556 |
if (CBAA3.ItemIndex = 3) or (CBAA3.ItemIndex = 7) |
2557 |
then // met + cys, phe + tyr |
2558 |
begin
|
2559 |
bodyAA := AAbody[CBAA3.ItemIndex - 1];
|
2560 |
v := v + (PD * bodyAA); |
2561 |
end;
|
2562 |
end;
|
2563 |
6: // D?s?quilibre |
2564 |
if CBAA3.ItemIndex = 12 |
2565 |
then // Arginine |
2566 |
begin
|
2567 |
PD := PResSimulP.TabResult[79, j];
|
2568 |
py1 := PResSimulP.TabResult[77, j];
|
2569 |
PD3 := py1 / GEProtJaap; |
2570 |
PDAA := PResSimulP.TabResult[44, j];
|
2571 |
AAk := kAA[12];
|
2572 |
PDapport := PDAA / AAk; |
2573 |
bodyAA := AAbody[12];
|
2574 |
if (PD < PD3) and (PD < PDAA) |
2575 |
then
|
2576 |
if (PDapport > PD3) or (PD3 < PDAA) |
2577 |
then
|
2578 |
v := (PD3 - PD) * bodyAA |
2579 |
else
|
2580 |
v := (PDAA - PD) * bodyAA |
2581 |
else
|
2582 |
v := 0;
|
2583 |
end
|
2584 |
else
|
2585 |
begin
|
2586 |
PDAA := PResSimulP.TabResult[32 + CBAA3.ItemIndex, j];
|
2587 |
bodyAA := AAbody[CBAA3.ItemIndex]; |
2588 |
AAk := kAA[CBAA3.ItemIndex]; |
2589 |
AAAA := PDAA * bodyAA / AAk; |
2590 |
PD := PResSimulP.TabResult[79, j];
|
2591 |
py1 := PResSimulP.TabResult[77, j];
|
2592 |
AAPD := PD * bodyAA / AAk; |
2593 |
AAenergie := py1 / GEProtJaap * bodyAA / AAk; |
2594 |
if (CBAA3.ItemIndex = 3) or (CBAA3.ItemIndex = 7) |
2595 |
then // met + cys, phe + tyr |
2596 |
begin
|
2597 |
PDAA := PResSimulP.TabResult[31 + CBAA3.ItemIndex, j];
|
2598 |
bodyAA := AAbody[CBAA3.ItemIndex - 1];
|
2599 |
AAk := kAA[CBAA3.ItemIndex - 1];
|
2600 |
AAAA := AAAA + (PDAA * bodyAA / AAk); |
2601 |
AAPD := AAPD + (PD * bodyAA / AAk); |
2602 |
AAenergie := AAenergie + (py1 / GEProtJaap * bodyAA / AAk); |
2603 |
end;
|
2604 |
if AAPD < AAAA
|
2605 |
then
|
2606 |
if AAAA < AAenergie
|
2607 |
then
|
2608 |
v := AAAA - AAPD |
2609 |
else
|
2610 |
v := Max (AAenergie - AAPD, 0)
|
2611 |
else
|
2612 |
v := 0;
|
2613 |
end;
|
2614 |
7: // D?ficit |
2615 |
if CBAA3.ItemIndex = 12 |
2616 |
then // Arginine |
2617 |
begin
|
2618 |
py1 := PResSimulP.TabResult[77, j];
|
2619 |
PD3 := py1 / GEProtJaap; |
2620 |
PDAA := PResSimulP.TabResult[44, j];
|
2621 |
bodyAA := AAbody[12];
|
2622 |
if PDAA < PD3
|
2623 |
then
|
2624 |
v := (PD3 - PDAA) * bodyAA |
2625 |
else
|
2626 |
v := 0;
|
2627 |
end
|
2628 |
else
|
2629 |
begin
|
2630 |
PDAA := PResSimulP.TabResult[32 + CBAA3.ItemIndex, j];
|
2631 |
bodyAA := AAbody[CBAA3.ItemIndex]; |
2632 |
AAk := kAA[CBAA3.ItemIndex]; |
2633 |
AAAA := PDAA * bodyAA / AAk; |
2634 |
py1 := PResSimulP.TabResult[77, j];
|
2635 |
AAenergie := py1 / GEProtJaap * bodyAA / AAk; |
2636 |
if (CBAA3.ItemIndex = 3) or (CBAA3.ItemIndex = 7) |
2637 |
then // met + cys, phe + tyr |
2638 |
begin
|
2639 |
PDAA := PResSimulP.TabResult[31 + CBAA3.ItemIndex, j];
|
2640 |
bodyAA := AAbody[CBAA3.ItemIndex - 1];
|
2641 |
AAk := kAA[CBAA3.ItemIndex - 1];
|
2642 |
AAAA := AAAA + (PDAA * bodyAA / AAk); |
2643 |
AAenergie := AAenergie + (py1 / GEProtJaap * bodyAA / AAk); |
2644 |
end;
|
2645 |
if AAAA < AAenergie
|
2646 |
then
|
2647 |
v := AAenergie - AAAA |
2648 |
else
|
2649 |
v := 0;
|
2650 |
end;
|
2651 |
8: // Exc?s |
2652 |
if CBAA3.ItemIndex = 12 |
2653 |
then // Arginine |
2654 |
begin
|
2655 |
py1 := PResSimulP.TabResult[77, j];
|
2656 |
PD3 := py1 / GEProtJaap; |
2657 |
PDAA := PResSimulP.TabResult[44, j];
|
2658 |
AAk := kAA[12];
|
2659 |
PDapport := PDAA / AAk; |
2660 |
bodyAA := AAbody[12];
|
2661 |
if PD3 < PDapport
|
2662 |
then
|
2663 |
v := (PDapport - PD3) * bodyAA |
2664 |
else
|
2665 |
v := 0;
|
2666 |
end
|
2667 |
else
|
2668 |
begin
|
2669 |
PDAA := PResSimulP.TabResult[32 + CBAA3.ItemIndex, j];
|
2670 |
bodyAA := AAbody[CBAA3.ItemIndex]; |
2671 |
AAk := kAA[CBAA3.ItemIndex]; |
2672 |
AAAA := PDAA * bodyAA / AAk; |
2673 |
py1 := PResSimulP.TabResult[77, j];
|
2674 |
AAenergie := py1 / GEProtJaap * bodyAA / AAk; |
2675 |
if (CBAA3.ItemIndex = 3) or (CBAA3.ItemIndex = 7) |
2676 |
then // met + cys, phe + tyr |
2677 |
begin
|
2678 |
PDAA := PResSimulP.TabResult[31 + CBAA3.ItemIndex, j];
|
2679 |
bodyAA := AAbody[CBAA3.ItemIndex - 1];
|
2680 |
AAk := kAA[CBAA3.ItemIndex - 1];
|
2681 |
AAAA := AAAA + (PDAA * bodyAA / AAk); |
2682 |
AAenergie := AAenergie + (py1 / GEProtJaap * bodyAA / AAk); |
2683 |
end;
|
2684 |
if AAenergie < AAAA
|
2685 |
then
|
2686 |
v := AAAA - AAenergie |
2687 |
else
|
2688 |
v := 0;
|
2689 |
end;
|
2690 |
else
|
2691 |
v := 0;
|
2692 |
end;
|
2693 |
result := v / d; |
2694 |
end;
|
2695 |
2: // R?partition par p?riode |
2696 |
begin
|
2697 |
// Diviseur
|
2698 |
case CBAA4.ItemIndex of |
2699 |
1: // Dur?e |
2700 |
d := j - k; |
2701 |
2: // Aliment ing?r? |
2702 |
begin
|
2703 |
d := 0;
|
2704 |
for h := k to j - 1 do |
2705 |
d := d + PResSimulP.TabResult[113, h];
|
2706 |
end;
|
2707 |
else
|
2708 |
d := 1;
|
2709 |
end;
|
2710 |
v := 0;
|
2711 |
case i of |
2712 |
0: // Gaspillage |
2713 |
if CBAA5.ItemIndex = 2 |
2714 |
then // Total |
2715 |
for h := k to j - 1 do |
2716 |
begin
|
2717 |
AAingere := PResSimulP.TabResult[93 + CBAA3.ItemIndex, h];
|
2718 |
Gaspillage := PResSimulP.TabResult[112, h];
|
2719 |
v := v + AAingere / (1 - Gaspillage) - AAingere;
|
2720 |
if (CBAA3.ItemIndex = 3) or (CBAA3.ItemIndex = 7) |
2721 |
then // met + cys, phe + tyr |
2722 |
begin
|
2723 |
AAingere := PResSimulP.TabResult[92 + CBAA3.ItemIndex, h];
|
2724 |
v := v + AAingere / (1 - Gaspillage) - AAingere;
|
2725 |
end;
|
2726 |
end;
|
2727 |
1: // Indigestible |
2728 |
if CBAA5.ItemIndex = 2 |
2729 |
then // Total |
2730 |
for h := k to j - 1 do |
2731 |
begin
|
2732 |
AAingere := PResSimulP.TabResult[93 + CBAA3.ItemIndex, h];
|
2733 |
AAdigestible := PResSimulP.TabResult[19 + CBAA3.ItemIndex, h];
|
2734 |
v := v + (AAingere - AAdigestible); |
2735 |
if (CBAA3.ItemIndex = 3) or (CBAA3.ItemIndex = 7) |
2736 |
then // met + cys, phe + tyr |
2737 |
begin
|
2738 |
AAingere := PResSimulP.TabResult[92 + CBAA3.ItemIndex, h];
|
2739 |
AAdigestible := PResSimulP.TabResult[18 + CBAA3.ItemIndex, h];
|
2740 |
v := v + (AAingere - AAdigestible); |
2741 |
end;
|
2742 |
end;
|
2743 |
2: // Endog?ne basal |
2744 |
if CBAA5.ItemIndex <> 1 |
2745 |
then // Total ou Digestible standardis? |
2746 |
for h := k to j - 1 do |
2747 |
begin
|
2748 |
IngereSec := PResSimulP.TabResult[106, h] * PResSimulP.TabResult[11, h]; |
2749 |
endogeneAA := AAendogene[CBAA3.ItemIndex]; |
2750 |
v := v + (IngereSec * endogeneAA); |
2751 |
if (CBAA3.ItemIndex = 3) or (CBAA3.ItemIndex = 7) |
2752 |
then // met + cys, phe + tyr |
2753 |
begin
|
2754 |
endogeneAA := AAendogene[CBAA3.ItemIndex - 1];
|
2755 |
v := v + (IngereSec * endogeneAA); |
2756 |
end;
|
2757 |
end;
|
2758 |
3: // Entretien |
2759 |
for h := k to j - 1 do |
2760 |
begin
|
2761 |
PV := PResSimulP.TabResult[2, h];
|
2762 |
m75AA := AAm75[CBAA3.ItemIndex]; |
2763 |
v := v + (m75AA * Power (PV, 0.75));
|
2764 |
if (CBAA3.ItemIndex = 3) or (CBAA3.ItemIndex = 7) |
2765 |
then // met + cys, phe + tyr |
2766 |
begin
|
2767 |
m75AA := AAm75[CBAA3.ItemIndex - 1];
|
2768 |
v := v + (m75AA * Power (PV, 0.75));
|
2769 |
end;
|
2770 |
end;
|
2771 |
4: // Oxydation minimale |
2772 |
for h := k to j - 1 do |
2773 |
begin
|
2774 |
PD := PResSimulP.TabResult[79, h];
|
2775 |
bodyAA := AAbody[CBAA3.ItemIndex]; |
2776 |
AAk := kAA[CBAA3.ItemIndex]; |
2777 |
if AAk <= 1 |
2778 |
then
|
2779 |
v := v + (PD * bodyAA / AAk * (1 - AAk));
|
2780 |
if (CBAA3.ItemIndex = 3) or (CBAA3.ItemIndex = 7) |
2781 |
then // met + cys, phe + tyr |
2782 |
begin
|
2783 |
bodyAA := AAbody[CBAA3.ItemIndex - 1];
|
2784 |
AAk := kAA[CBAA3.ItemIndex - 1];
|
2785 |
if AAk <= 1 |
2786 |
then
|
2787 |
v := v + (PD * bodyAA / AAk * (1 - AAk));
|
2788 |
end;
|
2789 |
end;
|
2790 |
5: // D?pot |
2791 |
for h := k to j - 1 do |
2792 |
begin
|
2793 |
PD := PResSimulP.TabResult[79, h];
|
2794 |
bodyAA := AAbody[CBAA3.ItemIndex]; |
2795 |
v := v + (PD * bodyAA); |
2796 |
if (CBAA3.ItemIndex = 3) or (CBAA3.ItemIndex = 7) |
2797 |
then // met + cys, phe + tyr |
2798 |
begin
|
2799 |
bodyAA := AAbody[CBAA3.ItemIndex - 1];
|
2800 |
v := v + (PD * bodyAA); |
2801 |
end;
|
2802 |
end;
|
2803 |
6: // D?s?quilibre |
2804 |
if CBAA3.ItemIndex = 12 |
2805 |
then // Arginine |
2806 |
for h := k to j - 1 do |
2807 |
begin
|
2808 |
PD := PResSimulP.TabResult[79, h];
|
2809 |
py1 := PResSimulP.TabResult[77, h];
|
2810 |
PD3 := py1 / GEProtJaap; |
2811 |
PDAA := PResSimulP.TabResult[44, h];
|
2812 |
AAk := kAA[12];
|
2813 |
PDapport := PDAA / AAk; |
2814 |
bodyAA := AAbody[12];
|
2815 |
if (PD < PD3) and (PD < PDAA) |
2816 |
then
|
2817 |
if (PDapport > PD3) or (PD3 < PDAA) |
2818 |
then
|
2819 |
v := v + ((PD3 - PD) * bodyAA) |
2820 |
else
|
2821 |
v := v + ((PDAA - PD) * bodyAA); |
2822 |
end
|
2823 |
else
|
2824 |
for h := k to j - 1 do |
2825 |
begin
|
2826 |
PDAA := PResSimulP.TabResult[32 + CBAA3.ItemIndex, h];
|
2827 |
bodyAA := AAbody[CBAA3.ItemIndex]; |
2828 |
AAk := kAA[CBAA3.ItemIndex]; |
2829 |
AAAA := PDAA * bodyAA / AAk; |
2830 |
PD := PResSimulP.TabResult[79, h];
|
2831 |
py1 := PResSimulP.TabResult[77, h];
|
2832 |
AAPD := PD * bodyAA / AAk; |
2833 |
AAenergie := py1 / GEProtJaap * bodyAA / AAk; |
2834 |
if (CBAA3.ItemIndex = 3) or (CBAA3.ItemIndex = 7) |
2835 |
then // met + cys, phe + tyr |
2836 |
begin
|
2837 |
PDAA := PResSimulP.TabResult[31 + CBAA3.ItemIndex, h];
|
2838 |
bodyAA := AAbody[CBAA3.ItemIndex - 1];
|
2839 |
AAk := kAA[CBAA3.ItemIndex - 1];
|
2840 |
AAAA := AAAA + (PDAA * bodyAA / AAk); |
2841 |
AAPD := AAPD + (PD * bodyAA / AAk); |
2842 |
AAenergie := AAenergie + (py1 / GEProtJaap * bodyAA / AAk); |
2843 |
end;
|
2844 |
if AAPD < AAAA
|
2845 |
then
|
2846 |
if AAAA < AAenergie
|
2847 |
then
|
2848 |
v := v + (AAAA - AAPD) |
2849 |
else
|
2850 |
v := v + (AAenergie - AAPD); |
2851 |
end;
|
2852 |
7: // D?ficit |
2853 |
if CBAA3.ItemIndex = 12 |
2854 |
then // Arginine |
2855 |
for h := k to j - 1 do |
2856 |
begin
|
2857 |
py1 := PResSimulP.TabResult[77, h];
|
2858 |
PD3 := py1 / GEProtJaap; |
2859 |
PDAA := PResSimulP.TabResult[44, h];
|
2860 |
bodyAA := AAbody[12];
|
2861 |
if PDAA < PD3
|
2862 |
then
|
2863 |
v := v + ((PD3 - PDAA) * bodyAA); |
2864 |
end
|
2865 |
else
|
2866 |
for h := k to j - 1 do |
2867 |
begin
|
2868 |
PDAA := PResSimulP.TabResult[32 + CBAA3.ItemIndex, h];
|
2869 |
bodyAA := AAbody[CBAA3.ItemIndex]; |
2870 |
AAk := kAA[CBAA3.ItemIndex]; |
2871 |
AAAA := PDAA * bodyAA / AAk; |
2872 |
py1 := PResSimulP.TabResult[77, h];
|
2873 |
AAenergie := py1 / GEProtJaap * bodyAA / AAk; |
2874 |
if (CBAA3.ItemIndex = 3) or (CBAA3.ItemIndex = 7) |
2875 |
then // met + cys, phe + tyr |
2876 |
begin
|
2877 |
PDAA := PResSimulP.TabResult[31 + CBAA3.ItemIndex, h];
|
2878 |
bodyAA := AAbody[CBAA3.ItemIndex - 1];
|
2879 |
AAk := kAA[CBAA3.ItemIndex - 1];
|
2880 |
AAAA := AAAA + (PDAA * bodyAA / AAk); |
2881 |
AAenergie := AAenergie + (py1 / GEProtJaap * bodyAA / AAk); |
2882 |
end;
|
2883 |
if AAAA < AAenergie
|
2884 |
then
|
2885 |
v := v + (AAenergie - AAAA); |
2886 |
end;
|
2887 |
8: // Exc?s |
2888 |
if CBAA3.ItemIndex = 12 |
2889 |
then // Arginine |
2890 |
for h := k to j - 1 do |
2891 |
begin
|
2892 |
py1 := PResSimulP.TabResult[77, h];
|
2893 |
PD3 := py1 / GEProtJaap; |
2894 |
PDAA := PResSimulP.TabResult[44, h];
|
2895 |
AAk := kAA[12];
|
2896 |
PDapport := PDAA / AAk; |
2897 |
bodyAA := AAbody[12];
|
2898 |
if PD3 < PDapport
|
2899 |
then
|
2900 |
v := v + ((PDapport - PD3) * bodyAA); |
2901 |
end
|
2902 |
else
|
2903 |
for h := k to j - 1 do |
2904 |
begin
|
2905 |
PDAA := PResSimulP.TabResult[32 + CBAA3.ItemIndex, h];
|
2906 |
bodyAA := AAbody[CBAA3.ItemIndex]; |
2907 |
AAk := kAA[CBAA3.ItemIndex]; |
2908 |
AAAA := PDAA * bodyAA / AAk; |
2909 |
py1 := PResSimulP.TabResult[77, h];
|
2910 |
AAenergie := py1 / GEProtJaap * bodyAA / AAk; |
2911 |
if (CBAA3.ItemIndex = 3) or (CBAA3.ItemIndex = 7) |
2912 |
then // met + cys, phe + tyr |
2913 |
begin
|
2914 |
PDAA := PResSimulP.TabResult[31 + CBAA3.ItemIndex, h];
|
2915 |
bodyAA := AAbody[CBAA3.ItemIndex - 1];
|
2916 |
AAk := kAA[CBAA3.ItemIndex - 1];
|
2917 |
AAAA := AAAA + (PDAA * bodyAA / AAk); |
2918 |
AAenergie := AAenergie + (py1 / GEProtJaap * bodyAA / AAk); |
2919 |
end;
|
2920 |
if AAenergie < AAAA
|
2921 |
then
|
2922 |
v := v + (AAAA - AAenergie); |
2923 |
end;
|
2924 |
end;
|
2925 |
result := v / d; |
2926 |
end;
|
2927 |
3: // Besoin et apport |
2928 |
begin
|
2929 |
IngereSec := PResSimulP.TabResult[106, j] * PResSimulP.TabResult[11, j]; |
2930 |
PV := PResSimulP.TabResult[2, j];
|
2931 |
// Diviseur
|
2932 |
case CBAA4.ItemIndex of |
2933 |
1: // Lysine |
2934 |
begin
|
2935 |
case i of |
2936 |
1: // Apport |
2937 |
begin
|
2938 |
AAdigestible := PResSimulP.TabResult[20, j];
|
2939 |
case CBAA5.ItemIndex of |
2940 |
0: // Standardis? |
2941 |
d := AAdigestible; |
2942 |
1: // Apparent |
2943 |
begin
|
2944 |
endogeneAA := AAendogene[1];
|
2945 |
d := AAdigestible |
2946 |
- IngereSec * endogeneAA; // Basal
|
2947 |
end;
|
2948 |
2: // Total |
2949 |
begin
|
2950 |
AAingere := PResSimulP.TabResult[94, j];
|
2951 |
d := AAingere; |
2952 |
end;
|
2953 |
else
|
2954 |
d := 1;
|
2955 |
end;
|
2956 |
end;
|
2957 |
2: // Besoin |
2958 |
begin
|
2959 |
AAk := kAA[1];
|
2960 |
bodyAA := AAbody[1];
|
2961 |
m75AA := AAm75[1];
|
2962 |
py1 := PResSimulP.TabResult[77, j];
|
2963 |
AAenergie := py1 / GEProtJaap * bodyAA / AAk; |
2964 |
case CBAA5.ItemIndex of |
2965 |
0: // Standardis? |
2966 |
begin
|
2967 |
endogeneAA := AAendogene[1];
|
2968 |
d := AAenergie |
2969 |
+ m75AA * Power (PV, 0.75) // Entretien |
2970 |
+ IngereSec * endogeneAA; // Basal
|
2971 |
end;
|
2972 |
1: // Apparent |
2973 |
d := AAenergie |
2974 |
+ m75AA * Power (PV, 0.75); // Entretien |
2975 |
else
|
2976 |
d := 1;
|
2977 |
end;
|
2978 |
end;
|
2979 |
else
|
2980 |
d := 1;
|
2981 |
end;
|
2982 |
d := d / 100;
|
2983 |
end;
|
2984 |
2: // GMQ |
2985 |
d := PResSimulP.TabResult[84, j];
|
2986 |
3: // ED (DEcrois * Ing?r?) |
2987 |
d := PResSimulP.TabResult[109, j] * PResSimulP.TabResult[11, j]; |
2988 |
4: // EM (MEcrois * Ing?r?) |
2989 |
d := PResSimulP.TabResult[89, j] * PResSimulP.TabResult[11, j]; |
2990 |
5: // EN (NEcrois * Ing?r?) |
2991 |
d := PResSimulP.TabResult[90, j] * PResSimulP.TabResult[11, j]; |
2992 |
6: // Aliment ing?r? |
2993 |
d := PResSimulP.TabResult[11, j];
|
2994 |
else
|
2995 |
d := 1;
|
2996 |
end;
|
2997 |
case i of |
2998 |
1: // Apport |
2999 |
begin
|
3000 |
AAdigestible := PResSimulP.TabResult[19 + CBAA3.ItemIndex, j];
|
3001 |
case CBAA5.ItemIndex of |
3002 |
0: // Standardis? |
3003 |
v := AAdigestible; |
3004 |
1: // Apparent |
3005 |
begin
|
3006 |
endogeneAA := AAendogene[CBAA3.ItemIndex]; |
3007 |
v := AAdigestible |
3008 |
- IngereSec * endogeneAA; // Basal
|
3009 |
end;
|
3010 |
2: // Total |
3011 |
begin
|
3012 |
AAingere := PResSimulP.TabResult[93 + CBAA3.ItemIndex, j];
|
3013 |
v := AAingere; |
3014 |
end;
|
3015 |
else
|
3016 |
v := 0;
|
3017 |
end;
|
3018 |
if (CBAA3.ItemIndex = 3) or (CBAA3.ItemIndex = 7) |
3019 |
then // met + cys, phe + tyr |
3020 |
begin
|
3021 |
AAdigestible := PResSimulP.TabResult[18 + CBAA3.ItemIndex, j];
|
3022 |
case CBAA5.ItemIndex of |
3023 |
0: // Standardis? |
3024 |
v := v + AAdigestible; |
3025 |
1: // Apparent |
3026 |
begin
|
3027 |
endogeneAA := AAendogene[CBAA3.ItemIndex - 1];
|
3028 |
v := v + AAdigestible |
3029 |
- IngereSec * endogeneAA; // Basal
|
3030 |
end;
|
3031 |
2: // Total |
3032 |
begin
|
3033 |
AAingere := PResSimulP.TabResult[92 + CBAA3.ItemIndex, j];
|
3034 |
v := v + AAingere; |
3035 |
end;
|
3036 |
end;
|
3037 |
end;
|
3038 |
end;
|
3039 |
2: // Besoin |
3040 |
begin
|
3041 |
bodyAA := AAbody[CBAA3.ItemIndex]; |
3042 |
AAk := kAA[CBAA3.ItemIndex]; |
3043 |
py1 := PResSimulP.TabResult[77, j];
|
3044 |
AAenergie := py1 / GEProtJaap * bodyAA / AAk; |
3045 |
m75AA := AAm75[CBAA3.ItemIndex]; |
3046 |
case CBAA5.ItemIndex of |
3047 |
0: // Standardis? |
3048 |
begin
|
3049 |
endogeneAA := AAendogene[CBAA3.ItemIndex]; |
3050 |
v := AAenergie |
3051 |
+ m75AA * Power (PV, 0.75) // Entretien |
3052 |
+ IngereSec * endogeneAA; // Basal
|
3053 |
end;
|
3054 |
1: // Apparent |
3055 |
v := AAenergie |
3056 |
+ m75AA * Power (PV, 0.75); // Entretien |
3057 |
else
|
3058 |
v := 0;
|
3059 |
end;
|
3060 |
if (CBAA3.ItemIndex = 3) or (CBAA3.ItemIndex = 7) |
3061 |
then // met + cys, phe + tyr |
3062 |
begin
|
3063 |
bodyAA := AAbody[CBAA3.ItemIndex - 1];
|
3064 |
AAk := kAA[CBAA3.ItemIndex - 1];
|
3065 |
AAenergie := py1 / GEProtJaap * bodyAA / AAk; |
3066 |
m75AA := AAm75[CBAA3.ItemIndex - 1];
|
3067 |
case CBAA5.ItemIndex of |
3068 |
0: // Standardis? |
3069 |
begin
|
3070 |
endogeneAA := AAendogene[CBAA3.ItemIndex - 1];
|
3071 |
v := v + AAenergie |
3072 |
+ m75AA * Power (PV, 0.75) // Entretien |
3073 |
+ IngereSec * endogeneAA; // Basal
|
3074 |
end;
|
3075 |
1: // Apparent |
3076 |
v := v + AAenergie |
3077 |
+ m75AA * Power (PV, 0.75); // Entretien |
3078 |
end;
|
3079 |
end;
|
3080 |
end;
|
3081 |
else
|
3082 |
v := 0;
|
3083 |
end;
|
3084 |
result := v / d; |
3085 |
end;
|
3086 |
else
|
3087 |
result := 0;
|
3088 |
end;
|
3089 |
end;
|
3090 |
|
3091 |
// AffGraphAA
|
3092 |
begin
|
3093 |
ResetGraph; |
3094 |
Graph.Title.Text.Add(Format('%s (%s)', [CBAA3.Text, CBAA1.Text]));
|
3095 |
Graph.SubTitle.Text.Add(CBAA5.Text); |
3096 |
Graph.LeftAxis.Title.Caption := Format('%s (%s)', [CBAA3.Text, CBAA4.Text]);
|
3097 |
case CBAA1.ItemIndex of |
3098 |
0: // R?partition globale |
3099 |
begin
|
3100 |
// Graph.View3D := TRUE;
|
3101 |
Graph.Legend.Visible := FALSE; |
3102 |
csv := '';
|
3103 |
for i := 0 to ListAA.Count - 1 do |
3104 |
csv := csv + Format('%s (%s)', [ListAA[i], CBAA4.Text]) + ';'; |
3105 |
MExport.Lines.Append(csv); |
3106 |
// Affichage du camembert
|
3107 |
PieAA.Active := TRUE; |
3108 |
PieAA.Clear; |
3109 |
if CBAA4.ItemIndex = 1 |
3110 |
then
|
3111 |
PieAA.Marks.Style := smsLabelPercent |
3112 |
else
|
3113 |
PieAA.Marks.Style := smsLabelValue; |
3114 |
t := 0;
|
3115 |
csv := '';
|
3116 |
for k := 0 to ListAA.Count - 1 do |
3117 |
begin
|
3118 |
i := TriAA[k]; |
3119 |
y := AAY; |
3120 |
if y > PICO
|
3121 |
then
|
3122 |
PieAA.AddPie(y, ListAA[i], AreaAA[i].SeriesColor); |
3123 |
t := t + y; |
3124 |
csv := csv + FloatToStrF(y, ffFixed, 15, 15) + ';'; |
3125 |
end;
|
3126 |
Graph.SubTitle.Text.Add(Format('%s = %1.0f %s', [StrTotal, t, StrG]));
|
3127 |
MExport.Lines.Append(csv); |
3128 |
end;
|
3129 |
1: // R?partition dynamique |
3130 |
begin
|
3131 |
Graph.BottomAxis.Title.Caption := CBAA2D.Text; |
3132 |
csv := CBAA2D.Text; |
3133 |
for i := 0 to ListAA.Count - 1 do |
3134 |
csv := csv + ';' + Format('%s (%s)', [ListAA[i], CBAA4.Text]); |
3135 |
MExport.Lines.Append(csv); |
3136 |
// Affichage des aires
|
3137 |
for i := 0 to ListAA.Count - 1 do |
3138 |
AreaAA[i].Active := TRUE; |
3139 |
for i := 0 to ListAA.Count - 1 do |
3140 |
AreaAA[i].Clear; |
3141 |
if CBAA4.ItemIndex = 2 |
3142 |
then
|
3143 |
for i := 0 to ListAA.Count - 1 do |
3144 |
AreaAA[i].MultiArea := maStacked100 |
3145 |
else
|
3146 |
for i := 0 to ListAA.Count - 1 do |
3147 |
AreaAA[i].MultiArea := maStacked; |
3148 |
for j := 1 to PResSimulP.NbJSim do |
3149 |
begin
|
3150 |
csv := FloatToStrF(AAX, ffFixed, 15, 15); |
3151 |
for i := 0 to ListAA.Count - 1 do |
3152 |
begin
|
3153 |
AreaAA[i].AddXY(AAX, AAY, '', clTeeColor);
|
3154 |
csv := csv + ';' + FloatToStrF(AAY, ffFixed, 15, 15); |
3155 |
end;
|
3156 |
MExport.Lines.Append(csv); |
3157 |
end;
|
3158 |
if CBAA2D.ItemIndex = 3 |
3159 |
then // Dur?e (semaine) |
3160 |
Graph.BottomAxis.Increment := 1
|
3161 |
else
|
3162 |
Graph.BottomAxis.Increment := 10;
|
3163 |
end;
|
3164 |
2: // R?partition par p?riode |
3165 |
begin
|
3166 |
Graph.BottomAxis.Title.Caption := CBAA2P.Text; |
3167 |
csv := CBAA2P.Text; |
3168 |
for i := 0 to ListAA.Count - 1 do |
3169 |
csv := csv + ';' + Format('%s (%s)', [ListAA[i], CBAA4.Text]); |
3170 |
MExport.Lines.Append(csv); |
3171 |
// Affichage des barres
|
3172 |
for i := 0 to ListAA.Count - 1 do |
3173 |
BarAA[i].Active := TRUE; |
3174 |
for i := 0 to ListAA.Count - 1 do |
3175 |
BarAA[i].Clear; |
3176 |
if CBAA4.ItemIndex = 3 |
3177 |
then
|
3178 |
for i := 0 to ListAA.Count - 1 do |
3179 |
BarAA[i].MultiBar := mbStacked100 |
3180 |
else
|
3181 |
for i := 0 to ListAA.Count - 1 do |
3182 |
BarAA[i].MultiBar := mbStacked; |
3183 |
j := 1;
|
3184 |
x := AAX; |
3185 |
k := 1;
|
3186 |
if PResSimulP.NbJSim > 1 |
3187 |
then
|
3188 |
for j := 2 to PResSimulP.NbJSim do |
3189 |
begin
|
3190 |
p := AAX; |
3191 |
if x <> p
|
3192 |
then
|
3193 |
begin
|
3194 |
// Changement de p?riode
|
3195 |
s := Format('%1.0f', [x]);
|
3196 |
csv := s; |
3197 |
for i := 0 to ListAA.Count - 1 do |
3198 |
begin
|
3199 |
y := AAY; |
3200 |
if y > PICO
|
3201 |
then
|
3202 |
BarAA[i].AddBar(y, s, clTeeColor) |
3203 |
else
|
3204 |
BarAA[i].AddNull(s); |
3205 |
csv := csv + ';' + FloatToStrF(y, ffFixed, 15, 15); |
3206 |
end;
|
3207 |
MExport.Lines.Append(csv); |
3208 |
x := p; |
3209 |
k := j; |
3210 |
end;
|
3211 |
end;
|
3212 |
j := PResSimulP.NbJSim + 1;
|
3213 |
if j > k
|
3214 |
then
|
3215 |
begin
|
3216 |
if CBAA2P.ItemIndex = 3 |
3217 |
then // Globale |
3218 |
s := ' '
|
3219 |
else
|
3220 |
s := Format('%1.0f', [x]);
|
3221 |
csv := s; |
3222 |
for i := 0 to ListAA.Count - 1 do |
3223 |
begin
|
3224 |
y := AAY; |
3225 |
if y > PICO
|
3226 |
then
|
3227 |
BarAA[i].AddBar(y, s, clTeeColor) |
3228 |
else
|
3229 |
BarAA[i].AddNull(s); |
3230 |
csv := csv + ';' + FloatToStrF(y, ffFixed, 15, 15); |
3231 |
end;
|
3232 |
MExport.Lines.Append(csv); |
3233 |
end;
|
3234 |
end;
|
3235 |
3: // Besoin et apport |
3236 |
begin
|
3237 |
Graph.BottomAxis.Title.Caption := CBAA2D.Text; |
3238 |
Graph.Legend.Alignment := laTop; |
3239 |
csv := CBAA2D.Text; |
3240 |
if CBAA5.ItemIndex = 2 |
3241 |
then // En digestibilit? totale, seul l'apport est affich? |
3242 |
csv := csv + ';' + Format('%s (%s)', [LineAA[1].Title, CBAA4.Text]) |
3243 |
else
|
3244 |
for i := 1 to 3 do |
3245 |
csv := csv + ';' + Format('%s (%s)', [LineAA[i].Title, CBAA4.Text]); |
3246 |
MExport.Lines.Append(csv); |
3247 |
// Affichage des lignes
|
3248 |
LineAA[1].Active := TRUE;
|
3249 |
if CBAA5.ItemIndex <> 2 |
3250 |
then // En digestibilit? totale, le besoin n'a pas de sens |
3251 |
begin
|
3252 |
LineAA[3].Active := TRUE;
|
3253 |
if (CBAA4.ItemIndex <> 1) and (CBAA4.ItemIndex <> 2) |
3254 |
then // Besoin de la population |
3255 |
LineAA[2].Active := TRUE;
|
3256 |
end;
|
3257 |
for i := 1 to 3 do |
3258 |
LineAA[i].Clear; |
3259 |
for j := 1 to PResSimulP.NbJSim do |
3260 |
begin
|
3261 |
x := AAX; |
3262 |
csv := FloatToStrF(x, ffFixed, 15, 15); |
3263 |
// Apport
|
3264 |
i := 1;
|
3265 |
y := AAY; |
3266 |
LineAA[1].AddXY (x, y, '', clTeeColor); |
3267 |
csv := csv + ';' + FloatToStrF(y, ffFixed, 15, 15); |
3268 |
// Besoin
|
3269 |
i := 2;
|
3270 |
if CBAA5.ItemIndex <> 2 |
3271 |
then // En digestibilit? totale, le besoin n'a pas de sens |
3272 |
begin
|
3273 |
y := AAY; |
3274 |
if CBAA4.ItemIndex = 2 |
3275 |
then // Cas particulier : Besoin / GMQ |
3276 |
begin
|
3277 |
PD := PResSimulP.TabResult[79, j];
|
3278 |
py1 := PResSimulP.TabResult[77, j];
|
3279 |
if PD < py1 / GEProtJaap - PICO
|
3280 |
then // Cas limitant -> non affich? |
3281 |
LineAA[3].AddNullXY(x, y, '') |
3282 |
else // Cas non limitant -> affich? |
3283 |
LineAA[3].AddXY(x, y, '', clTeeColor); |
3284 |
end
|
3285 |
else
|
3286 |
LineAA[3].AddXY(x, y, '', clTeeColor); |
3287 |
if (CBAA4.ItemIndex <> 1) and (CBAA4.ItemIndex <> 2) |
3288 |
then // Besoin de la population (+10%) |
3289 |
LineAA[2].AddXY(x, y * 1.1, '', clTeeColor); |
3290 |
csv := csv + ';' + FloatToStrF(y * 1.1, ffFixed, 15, 15); |
3291 |
csv := csv + ';' + FloatToStrF(y, ffFixed, 15, 15); |
3292 |
end;
|
3293 |
MExport.Lines.Append(csv); |
3294 |
end;
|
3295 |
if CBAA2D.ItemIndex = 3 |
3296 |
then // Dur?e (semaine) |
3297 |
Graph.BottomAxis.Increment := 1
|
3298 |
else
|
3299 |
Graph.BottomAxis.Increment := 10;
|
3300 |
end;
|
3301 |
end;
|
3302 |
if PieAA.Active
|
3303 |
then
|
3304 |
begin
|
3305 |
Graph.View3DOptions.Orthogonal := FALSE; |
3306 |
Graph.View3DOptions.Elevation := 315;
|
3307 |
Graph.View3DOptions.Rotation := 360;
|
3308 |
Graph.View3DOptions.Perspective := 0;
|
3309 |
end
|
3310 |
else
|
3311 |
begin
|
3312 |
Graph.View3DOptions.Orthogonal := TRUE; |
3313 |
Graph.View3DOptions.Elevation := 345;
|
3314 |
Graph.View3DOptions.Rotation := 345;
|
3315 |
Graph.View3DOptions.Perspective := 15;
|
3316 |
end;
|
3317 |
AjustEchelle(Graph); |
3318 |
end;
|
3319 |
|
3320 |
procedure TFResSimulP.CBAA1Change(Sender: TObject);
|
3321 |
begin
|
3322 |
CBAA4.Items.Clear; |
3323 |
case CBAA1.ItemIndex of |
3324 |
0: // R?partition globale |
3325 |
begin
|
3326 |
CBAA2D.Visible := FALSE; |
3327 |
CBAA2P.Visible := FALSE; |
3328 |
// Unit?s
|
3329 |
CBAA4.Items.Add(StrG); |
3330 |
CBAA4.Items.Add('%');
|
3331 |
end;
|
3332 |
1: // R?partition dynamique |
3333 |
begin
|
3334 |
CBAA2D.Visible := TRUE; |
3335 |
CBAA2P.Visible := FALSE; |
3336 |
// Unit?s
|
3337 |
CBAA4.Items.Add(Format('%s/%s', [StrG, StrJ]));
|
3338 |
CBAA4.Items.Add(Format('%s/%s %s', [StrG, StrKg, StrAlimentUnit]));
|
3339 |
CBAA4.Items.Add('%');
|
3340 |
end;
|
3341 |
2: // R?partition par p?riode |
3342 |
begin
|
3343 |
CBAA2D.Visible := FALSE; |
3344 |
CBAA2P.Visible := TRUE; |
3345 |
// Unit?s
|
3346 |
CBAA4.Items.Add(StrG); |
3347 |
CBAA4.Items.Add(Format('%s/%s', [StrG, StrJ]));
|
3348 |
CBAA4.Items.Add(Format('%s/%s %s', [StrG, StrKg, StrAlimentUnit]));
|
3349 |
CBAA4.Items.Add('%');
|
3350 |
end;
|
3351 |
3: // Besoin et apport |
3352 |
begin
|
3353 |
if AffBesoin
|
3354 |
then
|
3355 |
begin
|
3356 |
FWarning := TFWarning.Create (Self); |
3357 |
with FWarning do |
3358 |
begin
|
3359 |
Msg := 'Besoin';
|
3360 |
ShowModal; |
3361 |
Release; |
3362 |
AffBesoin := FALSE; |
3363 |
end;
|
3364 |
end;
|
3365 |
CBAA2D.Visible := TRUE; |
3366 |
CBAA2P.Visible := FALSE; |
3367 |
// Unit?s
|
3368 |
CBAA4.Items.Add(Format('%s/%s', [StrG, StrJ]));
|
3369 |
CBAA4.Items.Add(Format('%% %s', [StrLys]));
|
3370 |
CBAA4.Items.Add(Format('%s/%s %s', [StrG, StrKg, StrGMQUnit]));
|
3371 |
CBAA4.Items.Add(Format('%s/%s %s', [StrG, StrMJ, StrED]));
|
3372 |
CBAA4.Items.Add(Format('%s/%s %s', [StrG, StrMJ, StrEM]));
|
3373 |
CBAA4.Items.Add(Format('%s/%s %s', [StrG, StrMJ, StrEN]));
|
3374 |
CBAA4.Items.Add(Format('%s/%s %s', [StrG, StrKg, StrAlimentUnit]));
|
3375 |
end;
|
3376 |
end;
|
3377 |
CBAA4.ItemIndex := 0;
|
3378 |
AffGraphAA; |
3379 |
end;
|
3380 |
|
3381 |
procedure TFResSimulP.CBAA2Change(Sender: TObject);
|
3382 |
begin
|
3383 |
AffGraphAA; |
3384 |
end;
|
3385 |
|
3386 |
procedure TFResSimulP.CBAA3Change(Sender: TObject);
|
3387 |
begin
|
3388 |
AffGraphAA; |
3389 |
end;
|
3390 |
|
3391 |
procedure TFResSimulP.CBAA4Change(Sender: TObject);
|
3392 |
begin
|
3393 |
AffGraphAA; |
3394 |
end;
|
3395 |
|
3396 |
procedure TFResSimulP.CBAA5Change(Sender: TObject);
|
3397 |
begin
|
3398 |
AffGraphAA; |
3399 |
end;
|
3400 |
|
3401 |
/////////////////
|
3402 |
// Energie //
|
3403 |
/////////////////
|
3404 |
procedure TFResSimulP.InitNRJ;
|
3405 |
const
|
3406 |
TabColor1: array[0..7] of TColor |
3407 |
= (clBlack, clTeal, clYellow, clOlive, clGray, clFuchsia, clBlue, clLime); |
3408 |
TabColor2: array[1..2] of TColor |
3409 |
= (clGreen, clRed); |
3410 |
var
|
3411 |
i: integer; |
3412 |
begin
|
3413 |
// ListNRJ : liste pour l'?nergie
|
3414 |
ListNRJ := TStringList.Create; |
3415 |
ListNRJ.Assign(LBNRJ.Items); |
3416 |
// PieNRJ : s?rie (camembert) graphique
|
3417 |
PieNRJ := TPieSeries.Create(Graph); |
3418 |
PieNRJ.ParentChart := Graph; |
3419 |
PieNRJ.Circled := TRUE; |
3420 |
PieNRJ.Marks.ArrowLength := 24;
|
3421 |
PieNRJ.Marks.Arrow.Color := clBlack; |
3422 |
PieNRJ.Marks.Brush.Style := bsClear; |
3423 |
PieNRJ.Marks.Frame.Visible := FALSE; |
3424 |
PieNRJ.ValueFormat := Format('# ##0 %s', [StrMJ]);
|
3425 |
PieNRJ.PercentFormat := '##0 %';
|
3426 |
Graph.AddSeries(PieNRJ); |
3427 |
// AreaNRJ : s?ries (aires) graphiques
|
3428 |
SetLength(AreaNRJ, ListNRJ.Count); |
3429 |
for i := 0 to ListNRJ.Count - 1 do |
3430 |
begin
|
3431 |
AreaNRJ[i] := TAreaSeries.Create(Graph); |
3432 |
AreaNRJ[i].ParentChart := Graph; |
3433 |
AreaNRJ[i].Title := ListNRJ[i]; |
3434 |
AreaNRJ[i].SeriesColor := TabColor1[i]; |
3435 |
AreaNRJ[i].AreaLinesPen.Visible := FALSE; |
3436 |
Graph.AddSeries(AreaNRJ[i]); |
3437 |
end;
|
3438 |
// BarNRJ : s?ries (barres) graphiques
|
3439 |
SetLength(BarNRJ, ListNRJ.Count); |
3440 |
for i := 0 to ListNRJ.Count - 1 do |
3441 |
begin
|
3442 |
BarNRJ[i] := TBarSeries.Create(Graph); |
3443 |
BarNRJ[i].ParentChart := Graph; |
3444 |
BarNRJ[i].Title := ListNRJ[i]; |
3445 |
BarNRJ[i].SeriesColor := TabColor1[i]; |
3446 |
BarNRJ[i].BarPen.Color := BarNRJ[i].SeriesColor; |
3447 |
BarNRJ[i].Marks.Visible := FALSE; |
3448 |
Graph.AddSeries(BarNRJ[i]); |
3449 |
end;
|
3450 |
// LineNRJ : s?ries (lignes) graphiques
|
3451 |
for i := 1 to 2 do |
3452 |
begin
|
3453 |
LineNRJ[i] := TLineSeries.Create(Graph); |
3454 |
LineNRJ[i].ParentChart := Graph; |
3455 |
// LineNRJ[i].Title := ' ';
|
3456 |
LineNRJ[i].SeriesColor := TabColor2[i]; |
3457 |
LineNRJ[i].LinePen.Color := LineNRJ[i].SeriesColor; |
3458 |
LineNRJ[i].LinePen.Width := 3 - i;
|
3459 |
Graph.AddSeries(LineNRJ[i]); |
3460 |
end;
|
3461 |
end;
|
3462 |
|
3463 |
procedure TFResSimulP.AffGraphNRJ;
|
3464 |
var
|
3465 |
i, j, k: integer; |
3466 |
x, y, t, p: double; |
3467 |
s, csv: string;
|
3468 |
|
3469 |
// Abscisse
|
3470 |
function NRJX: double;
|
3471 |
begin
|
3472 |
case CBNRJ1.ItemIndex of |
3473 |
1: // R?partition dynamique |
3474 |
case CBNRJ2D.ItemIndex of |
3475 |
0: // Poids vif |
3476 |
result := PResSimulP.TabResult[2, j];
|
3477 |
1: // Age |
3478 |
result := PResSimulP.TabResult[1, j];
|
3479 |
2: // Jours |
3480 |
result := j; |
3481 |
3: // Semaines |
3482 |
result := j / 7;
|
3483 |
else
|
3484 |
result := 0;
|
3485 |
end;
|
3486 |
2: // R?partition par p?riode |
3487 |
case CBNRJ2P.ItemIndex of |
3488 |
0: // Semaine |
3489 |
result := (j - 1) div 7 + 1; |
3490 |
1: // R?gle qualit? |
3491 |
result := PResSimulP.TabResult[3, j];
|
3492 |
2: // R?gle quantit? |
3493 |
result := PResSimulP.TabResult[5, j];
|
3494 |
else
|
3495 |
result := 0;
|
3496 |
end;
|
3497 |
3: // Energie retenue |
3498 |
case CBNRJ2D.ItemIndex of |
3499 |
0: // Poids vif |
3500 |
result := PResSimulP.TabResult[2, j];
|
3501 |
1: // Age |
3502 |
result := PResSimulP.TabResult[1, j];
|
3503 |
2: // Jours |
3504 |
result := j; |
3505 |
3: // Semaines |
3506 |
result := j / 7;
|
3507 |
else
|
3508 |
result := 0;
|
3509 |
end;
|
3510 |
4: // Valeurs ?nerg?tiques |
3511 |
case CBNRJ2D.ItemIndex of |
3512 |
0: // Poids vif |
3513 |
result := PResSimulP.TabResult[2, j];
|
3514 |
1: // Age |
3515 |
result := PResSimulP.TabResult[1, j];
|
3516 |
2: // Jours |
3517 |
result := j; |
3518 |
3: // Semaines |
3519 |
result := j / 7;
|
3520 |
else
|
3521 |
result := 0;
|
3522 |
end;
|
3523 |
else
|
3524 |
result := 0;
|
3525 |
end;
|
3526 |
end;
|
3527 |
|
3528 |
// Ordonn?e
|
3529 |
function NRJY: double;
|
3530 |
var
|
3531 |
h: integer; |
3532 |
v, d, PV, EBing, EDing, {MAD, MGD, CBD, Amidon, Sucre, ResiduD,} MEintake,
|
3533 |
PDfreeNEintake, PDfreeNEreq, FHP60, kdiet, Standing, Entretien, Activite, |
3534 |
energyPD, energyLD, px1, py1, F, a, b, PD, LD, p, l, NEcrois, NEmAL, NEm, |
3535 |
dietNE, mrPDen, mrPDen2, mrLD, mrLD2, MEcrois, NEintake, Gaspillage: double; |
3536 |
begin
|
3537 |
case CBNRJ1.ItemIndex of |
3538 |
0: // R?partition globale |
3539 |
begin
|
3540 |
v := 0;
|
3541 |
case i of |
3542 |
0: // Gaspillage |
3543 |
if CBNRJ3.ItemIndex = 0 |
3544 |
then // EB |
3545 |
for h := 1 to PResSimulP.NbJSim do |
3546 |
begin
|
3547 |
EBing := PResSimulP.TabResult[12, h];
|
3548 |
Gaspillage := PResSimulP.TabResult[112, h];
|
3549 |
v := v + EBing / (1 - Gaspillage) - EBing;
|
3550 |
end;
|
3551 |
1: // Indigestible |
3552 |
if CBNRJ3.ItemIndex = 0 |
3553 |
then // EB |
3554 |
for h := 1 to PResSimulP.NbJSim do |
3555 |
begin
|
3556 |
EBing := PResSimulP.TabResult[12, h];
|
3557 |
EDing := PResSimulP.TabResult[109, h] * PResSimulP.TabResult[11, h]; |
3558 |
v := v + (EBing - EDing); |
3559 |
end;
|
3560 |
2: // M?thane et urines |
3561 |
if CBNRJ3.ItemIndex <= 1 |
3562 |
then // EB ou ED |
3563 |
for h := 1 to PResSimulP.NbJSim do |
3564 |
begin
|
3565 |
EDing := PResSimulP.TabResult[109, h] * PResSimulP.TabResult[11, h]; |
3566 |
MEintake := PResSimulP.TabResult[86, h] / 1000; |
3567 |
v := v + (EDing - MEintake); |
3568 |
end;
|
3569 |
3: // Entretien |
3570 |
for h := 1 to PResSimulP.NbJSim do |
3571 |
begin
|
3572 |
FHP60 := PResSimulP.TabResult[91, h] / 1000; |
3573 |
PV := PResSimulP.TabResult[2, h];
|
3574 |
if CBNRJ3.ItemIndex = 3 |
3575 |
then // EN |
3576 |
Entretien := PProfilP.Entretien * kBR * FHP60 * Power (PV, 0.6)
|
3577 |
else // EB, ED ou EM |
3578 |
begin
|
3579 |
PDfreeNEintake := PResSimulP.TabResult[65, h] / 1000; |
3580 |
MEintake := PResSimulP.TabResult[86, h] / 1000; |
3581 |
energyPD := PResSimulP.TabResult[66, h] / 1000; |
3582 |
kdiet := PDfreeNEintake / (MEintake - energyPD); |
3583 |
Entretien := PProfilP.Entretien * kBR * FHP60 * Power (PV, 0.6) / kdiet;
|
3584 |
end;
|
3585 |
v := v + Entretien; |
3586 |
end;
|
3587 |
4: // Activit? |
3588 |
for h := 1 to PResSimulP.NbJSim do |
3589 |
begin
|
3590 |
Standing := PResSimulP.TabResult[70, h];
|
3591 |
PV := PResSimulP.TabResult[2, h];
|
3592 |
if CBNRJ3.ItemIndex = 3 |
3593 |
then // EN |
3594 |
Activite := Standing * (NEact60h / 1000) * Power (PV, 0.6) |
3595 |
else // EB, ED ou EM |
3596 |
begin
|
3597 |
PDfreeNEintake := PResSimulP.TabResult[65, h] / 1000; |
3598 |
MEintake := PResSimulP.TabResult[86, h] / 1000; |
3599 |
energyPD := PResSimulP.TabResult[66, h] / 1000; |
3600 |
kdiet := PDfreeNEintake / (MEintake - energyPD); |
3601 |
Activite := Standing * (NEact60h / 1000) * Power (PV, 0.6) / kdiet; |
3602 |
end;
|
3603 |
v := v + Activite; |
3604 |
end;
|
3605 |
5: // Extrachaleur |
3606 |
if CBNRJ3.ItemIndex <= 2 |
3607 |
then // EB ou ED ou EM |
3608 |
for h := 1 to PResSimulP.NbJSim do |
3609 |
begin
|
3610 |
MEintake := PResSimulP.TabResult[86, h] / 1000; |
3611 |
energyPD := PResSimulP.TabResult[66, h] / 1000; |
3612 |
PDfreeNEintake := PResSimulP.TabResult[65, h] / 1000; |
3613 |
PDfreeNEreq := PResSimulP.TabResult[73, h] / 1000; |
3614 |
energyLD := PDfreeNEintake - PDfreeNEreq; |
3615 |
FHP60 := PResSimulP.TabResult[91, h] / 1000; |
3616 |
PV := PResSimulP.TabResult[2, h];
|
3617 |
kdiet := PDfreeNEintake / (MEintake - energyPD); |
3618 |
Entretien := PProfilP.Entretien * kBR * FHP60 * Power (PV, 0.6) / kdiet;
|
3619 |
Standing := PResSimulP.TabResult[70, h];
|
3620 |
Activite := Standing * (NEact60h / 1000) * Power (PV, 0.6) / kdiet; |
3621 |
v := v + (MEintake - (energyPD + energyLD + Entretien + Activite)); |
3622 |
end;
|
3623 |
6: // Prot?ines |
3624 |
for h := 1 to PResSimulP.NbJSim do |
3625 |
begin
|
3626 |
energyPD := PResSimulP.TabResult[66, h] / 1000; |
3627 |
v := v + energyPD; |
3628 |
end;
|
3629 |
7: // Lipides |
3630 |
for h := 1 to PResSimulP.NbJSim do |
3631 |
begin
|
3632 |
PDfreeNEintake := PResSimulP.TabResult[65, h] / 1000; |
3633 |
PDfreeNEreq := PResSimulP.TabResult[73, h] / 1000; |
3634 |
energyLD := PDfreeNEintake - PDfreeNEreq; |
3635 |
v := v + energyLD; |
3636 |
end;
|
3637 |
end;
|
3638 |
result := v; |
3639 |
end;
|
3640 |
1: // R?partition dynamique |
3641 |
begin
|
3642 |
// Diviseur
|
3643 |
case CBNRJ4.ItemIndex of |
3644 |
1: // PV^0.60 |
3645 |
d := Power (PResSimulP.TabResult[2, j], 0.60); |
3646 |
2: // PV^0.75 |
3647 |
d := Power (PResSimulP.TabResult[2, j], 0.75); |
3648 |
3: // Aliment |
3649 |
d := PResSimulP.TabResult[113, j];
|
3650 |
else
|
3651 |
d := 1;
|
3652 |
end;
|
3653 |
case i of |
3654 |
0: // Gaspillage |
3655 |
if CBNRJ3.ItemIndex = 0 |
3656 |
then // EB |
3657 |
begin
|
3658 |
EBing := PResSimulP.TabResult[12, j];
|
3659 |
Gaspillage := PResSimulP.TabResult[112, j];
|
3660 |
v := EBing / (1 - Gaspillage) - EBing;
|
3661 |
end
|
3662 |
else
|
3663 |
v := 0;
|
3664 |
1: // Indigestible |
3665 |
if CBNRJ3.ItemIndex = 0 |
3666 |
then // EB |
3667 |
begin
|
3668 |
EBing := PResSimulP.TabResult[12, j];
|
3669 |
EDing := PResSimulP.TabResult[109, j] * PResSimulP.TabResult[11, j]; |
3670 |
v := EBing - EDing; |
3671 |
end
|
3672 |
else
|
3673 |
v := 0;
|
3674 |
2: // M?thane et urines |
3675 |
if CBNRJ3.ItemIndex <= 1 |
3676 |
then // EB ou ED |
3677 |
begin
|
3678 |
EDing := PResSimulP.TabResult[109, j] * PResSimulP.TabResult[11, j]; |
3679 |
MEintake := PResSimulP.TabResult[86, j] / 1000; |
3680 |
v := EDing - MEintake; |
3681 |
end
|
3682 |
else
|
3683 |
v := 0;
|
3684 |
3: // Entretien |
3685 |
begin
|
3686 |
FHP60 := PResSimulP.TabResult[91, j] / 1000; |
3687 |
PV := PResSimulP.TabResult[2, j];
|
3688 |
if CBNRJ3.ItemIndex = 3 |
3689 |
then // EN |
3690 |
Entretien := PProfilP.Entretien * kBR * FHP60 * Power (PV, 0.6)
|
3691 |
else // EB, ED ou EM |
3692 |
begin
|
3693 |
PDfreeNEintake := PResSimulP.TabResult[65, j] / 1000; |
3694 |
MEintake := PResSimulP.TabResult[86, j] / 1000; |
3695 |
energyPD := PResSimulP.TabResult[66, j] / 1000; |
3696 |
kdiet := PDfreeNEintake / (MEintake - energyPD); |
3697 |
Entretien := PProfilP.Entretien * kBR * FHP60 * Power (PV, 0.6) / kdiet;
|
3698 |
end;
|
3699 |
v := Entretien; |
3700 |
end;
|
3701 |
4: // Activit? |
3702 |
begin
|
3703 |
Standing := PResSimulP.TabResult[70, j];
|
3704 |
PV := PResSimulP.TabResult[2, j];
|
3705 |
if CBNRJ3.ItemIndex = 3 |
3706 |
then // EN |
3707 |
Activite := Standing * (NEact60h / 1000) * Power (PV, 0.6) |
3708 |
else // EB, ED ou EM |
3709 |
begin
|
3710 |
PDfreeNEintake := PResSimulP.TabResult[65, j] / 1000; |
3711 |
MEintake := PResSimulP.TabResult[86, j] / 1000; |
3712 |
energyPD := PResSimulP.TabResult[66, j] / 1000; |
3713 |
kdiet := PDfreeNEintake / (MEintake - energyPD); |
3714 |
Activite := Standing * (NEact60h / 1000) * Power (PV, 0.6) / kdiet; |
3715 |
end;
|
3716 |
v := Activite; |
3717 |
end;
|
3718 |
5: // Extrachaleur |
3719 |
if CBNRJ3.ItemIndex <= 2 |
3720 |
then // EB ou ED ou EM |
3721 |
begin
|
3722 |
MEintake := PResSimulP.TabResult[86, j] / 1000; |
3723 |
energyPD := PResSimulP.TabResult[66, j] / 1000; |
3724 |
PDfreeNEintake := PResSimulP.TabResult[65, j] / 1000; |
3725 |
PDfreeNEreq := PResSimulP.TabResult[73, j] / 1000; |
3726 |
energyLD := PDfreeNEintake - PDfreeNEreq; |
3727 |
FHP60 := PResSimulP.TabResult[91, j] / 1000; |
3728 |
PV := PResSimulP.TabResult[2, j];
|
3729 |
kdiet := PDfreeNEintake / (MEintake - energyPD); |
3730 |
Entretien := PProfilP.Entretien * kBR * FHP60 * Power (PV, 0.6) / kdiet;
|
3731 |
Standing := PResSimulP.TabResult[70, j];
|
3732 |
Activite := Standing * (NEact60h / 1000) * Power (PV, 0.6) / kdiet; |
3733 |
v := MEintake - (energyPD + energyLD + Entretien + Activite); |
3734 |
end
|
3735 |
else
|
3736 |
v := 0;
|
3737 |
6: // Prot?ines |
3738 |
begin
|
3739 |
energyPD := PResSimulP.TabResult[66, j] / 1000; |
3740 |
v := energyPD; |
3741 |
end;
|
3742 |
7: // Lipides |
3743 |
begin
|
3744 |
PDfreeNEintake := PResSimulP.TabResult[65, j] / 1000; |
3745 |
PDfreeNEreq := PResSimulP.TabResult[73, j] / 1000; |
3746 |
energyLD := PDfreeNEintake - PDfreeNEreq; |
3747 |
v := energyLD; |
3748 |
end;
|
3749 |
else
|
3750 |
v := 0;
|
3751 |
end;
|
3752 |
result := v / d; |
3753 |
end;
|
3754 |
2: // R?partition par p?riode |
3755 |
begin
|
3756 |
// Diviseur
|
3757 |
case CBNRJ4.ItemIndex of |
3758 |
1: // Dur?e |
3759 |
d := j - k; |
3760 |
2: // Aliment |
3761 |
begin
|
3762 |
d := 0;
|
3763 |
for h := k to j - 1 do |
3764 |
d := d + PResSimulP.TabResult[113, h];
|
3765 |
end;
|
3766 |
else
|
3767 |
d := 1;
|
3768 |
end;
|
3769 |
v := 0;
|
3770 |
case i of |
3771 |
0: // Gaspillage |
3772 |
if CBNRJ3.ItemIndex = 0 |
3773 |
then // EB |
3774 |
for h := k to j - 1 do |
3775 |
begin
|
3776 |
EBing := PResSimulP.TabResult[12, h];
|
3777 |
Gaspillage := PResSimulP.TabResult[112, h];
|
3778 |
v := v + EBing / (1 - Gaspillage) - EBing;
|
3779 |
end;
|
3780 |
1: // Indigestible |
3781 |
if CBNRJ3.ItemIndex = 0 |
3782 |
then // EB |
3783 |
for h := k to j - 1 do |
3784 |
begin
|
3785 |
EBing := PResSimulP.TabResult[12, h];
|
3786 |
EDing := PResSimulP.TabResult[109, h] * PResSimulP.TabResult[11, h]; |
3787 |
v := v + (EBing - EDing); |
3788 |
end;
|
3789 |
2: // M?thane et urines |
3790 |
if CBNRJ3.ItemIndex <= 1 |
3791 |
then // EB ou ED |
3792 |
for h := k to j - 1 do |
3793 |
begin
|
3794 |
EDing := PResSimulP.TabResult[109, h] * PResSimulP.TabResult[11, h]; |
3795 |
MEintake := PResSimulP.TabResult[86, h] / 1000; |
3796 |
v := v + (EDing - MEintake); |
3797 |
end;
|
3798 |
3: // Entretien |
3799 |
for h := k to j - 1 do |
3800 |
begin
|
3801 |
FHP60 := PResSimulP.TabResult[91, h] / 1000; |
3802 |
PV := PResSimulP.TabResult[2, h];
|
3803 |
if CBNRJ3.ItemIndex = 3 |
3804 |
then // EN |
3805 |
Entretien := PProfilP.Entretien * kBR * FHP60 * Power (PV, 0.6)
|
3806 |
else // EB, ED ou EM |
3807 |
begin
|
3808 |
PDfreeNEintake := PResSimulP.TabResult[65, h] / 1000; |
3809 |
MEintake := PResSimulP.TabResult[86, h] / 1000; |
3810 |
energyPD := PResSimulP.TabResult[66, h] / 1000; |
3811 |
kdiet := PDfreeNEintake / (MEintake - energyPD); |
3812 |
Entretien := PProfilP.Entretien * kBR * FHP60 * Power (PV, 0.6) / kdiet;
|
3813 |
end;
|
3814 |
v := v + Entretien; |
3815 |
end;
|
3816 |
4: // Activit? |
3817 |
for h := k to j - 1 do |
3818 |
begin
|
3819 |
Standing := PResSimulP.TabResult[70, h];
|
3820 |
PV := PResSimulP.TabResult[2, h];
|
3821 |
if CBNRJ3.ItemIndex = 3 |
3822 |
then // EN |
3823 |
Activite := Standing * (NEact60h / 1000) * Power (PV, 0.6) |
3824 |
else // EB, ED ou EM |
3825 |
begin
|
3826 |
PDfreeNEintake := PResSimulP.TabResult[65, h] / 1000; |
3827 |
MEintake := PResSimulP.TabResult[86, h] / 1000; |
3828 |
energyPD := PResSimulP.TabResult[66, h] / 1000; |
3829 |
kdiet := PDfreeNEintake / (MEintake - energyPD); |
3830 |
Activite := Standing * (NEact60h / 1000) * Power (PV, 0.6) / kdiet; |
3831 |
end;
|
3832 |
v := v + Activite; |
3833 |
end;
|
3834 |
5: // Extrachaleur |
3835 |
if CBNRJ3.ItemIndex <= 2 |
3836 |
then // EB ou ED ou EM |
3837 |
for h := k to j - 1 do |
3838 |
begin
|
3839 |
MEintake := PResSimulP.TabResult[86, h] / 1000; |
3840 |
energyPD := PResSimulP.TabResult[66, h] / 1000; |
3841 |
PDfreeNEintake := PResSimulP.TabResult[65, h] / 1000; |
3842 |
PDfreeNEreq := PResSimulP.TabResult[73, h] / 1000; |
3843 |
energyLD := PDfreeNEintake - PDfreeNEreq; |
3844 |
FHP60 := PResSimulP.TabResult[91, h] / 1000; |
3845 |
PV := PResSimulP.TabResult[2, h];
|
3846 |
kdiet := PDfreeNEintake / (MEintake - energyPD); |
3847 |
Entretien := PProfilP.Entretien * kBR * FHP60 * Power (PV, 0.6) / kdiet;
|
3848 |
Standing := PResSimulP.TabResult[70, h];
|
3849 |
Activite := Standing * (NEact60h / 1000) * Power (PV, 0.6) / kdiet; |
3850 |
v := v + (MEintake - (energyPD + energyLD + Entretien + Activite)); |
3851 |
end;
|
3852 |
6: // Prot?ines |
3853 |
for h := k to j - 1 do |
3854 |
begin
|
3855 |
energyPD := PResSimulP.TabResult[66, h] / 1000; |
3856 |
v := v + energyPD; |
3857 |
end;
|
3858 |
7: // Lipides |
3859 |
for h := k to j - 1 do |
3860 |
begin
|
3861 |
PDfreeNEintake := PResSimulP.TabResult[65, h] / 1000; |
3862 |
PDfreeNEreq := PResSimulP.TabResult[73, h] / 1000; |
3863 |
energyLD := PDfreeNEintake - PDfreeNEreq; |
3864 |
v := v + energyLD; |
3865 |
end;
|
3866 |
end;
|
3867 |
result := v / d; |
3868 |
end;
|
3869 |
3: // Energie retenue |
3870 |
case CBNRJ3R.ItemIndex of |
3871 |
0: // PD marginal |
3872 |
case i of |
3873 |
1: // Acides amin?s non limitants |
3874 |
begin
|
3875 |
px1 := PResSimulP.TabResult[76, j];
|
3876 |
F := PResSimulP.TabResult[52, j];
|
3877 |
if px1 < F
|
3878 |
then
|
3879 |
begin
|
3880 |
a := PResSimulP.TabResult[74, j];
|
3881 |
b := PResSimulP.TabResult[75, j];
|
3882 |
NEcrois := PResSimulP.TabResult[90, j];
|
3883 |
NEmAL := PResSimulP.TabResult[71, j];
|
3884 |
mrPDen := (a + 2 * b * (px1 - 1)) * (NEcrois * 1000) / NEmAL; |
3885 |
end
|
3886 |
else
|
3887 |
mrPDen := 0;
|
3888 |
result := mrPDen / GEProtJaap; |
3889 |
end;
|
3890 |
2: // Acides amin?s potentiellement limitants |
3891 |
begin
|
3892 |
PD := PResSimulP.TabResult[79, j];
|
3893 |
py1 := PResSimulP.TabResult[77, j];
|
3894 |
if (py1 / GEProtJaap - PICO < PD)
|
3895 |
and (PD < py1 / GEProtJaap + PICO)
|
3896 |
then
|
3897 |
begin
|
3898 |
px1 := PResSimulP.TabResult[76, j];
|
3899 |
F := PResSimulP.TabResult[52, j];
|
3900 |
if px1 < F
|
3901 |
then
|
3902 |
begin
|
3903 |
a := PResSimulP.TabResult[74, j];
|
3904 |
b := PResSimulP.TabResult[75, j];
|
3905 |
NEcrois := PResSimulP.TabResult[90, j];
|
3906 |
NEmAL := PResSimulP.TabResult[71, j];
|
3907 |
mrPDen := (a + 2 * b * (px1 - 1)) * (NEcrois * 1000) / NEmAL; |
3908 |
end
|
3909 |
else
|
3910 |
mrPDen := 0;
|
3911 |
mrPDen2 := mrPDen |
3912 |
end
|
3913 |
else
|
3914 |
mrPDen2 := 0;
|
3915 |
result := mrPDen2 / GEProtJaap; |
3916 |
end;
|
3917 |
else
|
3918 |
result := 0;
|
3919 |
end;
|
3920 |
1: // X |
3921 |
case i of |
3922 |
1: // Acides amin?s non limitants |
3923 |
begin
|
3924 |
px1 := PResSimulP.TabResult[76, j];
|
3925 |
py1 := PResSimulP.TabResult[77, j];
|
3926 |
NEmAL := PResSimulP.TabResult[71, j];
|
3927 |
result := (1 + NEPD) * py1 / ((px1 - 1) * NEmAL); |
3928 |
end;
|
3929 |
2: // Acides amin?s potentiellement limitants |
3930 |
begin
|
3931 |
px1 := PResSimulP.TabResult[76, j];
|
3932 |
PD := PResSimulP.TabResult[79, j];
|
3933 |
NEmAL := PResSimulP.TabResult[71, j];
|
3934 |
result := (1 + NEPD) * (PD * GEProtJaap) / ((px1 - 1) * NEmAL); |
3935 |
end;
|
3936 |
else
|
3937 |
result := 0;
|
3938 |
end;
|
3939 |
2: // LD / PD |
3940 |
case i of |
3941 |
1: // Acides amin?s non limitants |
3942 |
begin
|
3943 |
LD := PResSimulP.TabResult[80, j];
|
3944 |
PD := PResSimulP.TabResult[79, j];
|
3945 |
result := LD / PD; |
3946 |
end;
|
3947 |
2: // Acides amin?s potentiellement limitants |
3948 |
begin
|
3949 |
PDfreeNEintake := PResSimulP.TabResult[65, j];
|
3950 |
NEm := PResSimulP.TabResult[72, j];
|
3951 |
py1 := PResSimulP.TabResult[77, j];
|
3952 |
result := (((PDfreeNEintake - NEm) - py1 * NEPD) |
3953 |
/ ValEnergie[2, 2]) / (py1 / GEProtJaap); |
3954 |
end;
|
3955 |
else
|
3956 |
result := 0;
|
3957 |
end;
|
3958 |
3: // (PD / LD) marginal |
3959 |
case i of |
3960 |
1: // Acides amin?s non limitants |
3961 |
begin
|
3962 |
px1 := PResSimulP.TabResult[76, j];
|
3963 |
F := PResSimulP.TabResult[52, j];
|
3964 |
if px1 < F
|
3965 |
then
|
3966 |
begin
|
3967 |
a := PResSimulP.TabResult[74, j];
|
3968 |
b := PResSimulP.TabResult[75, j];
|
3969 |
NEcrois := PResSimulP.TabResult[90, j];
|
3970 |
NEmAL := PResSimulP.TabResult[71, j];
|
3971 |
mrPDen := (a + 2 * b * (px1 - 1)) * (NEcrois * 1000) / NEmAL; |
3972 |
end
|
3973 |
else
|
3974 |
mrPDen := 0;
|
3975 |
dietNE := PResSimulP.TabResult[88, j];
|
3976 |
mrLD := (dietNE * 1000 - mrPDen * (1 + NEPD)) / ValEnergie[2, 2]; |
3977 |
result := (mrPDen / GEProtJaap) / mrLD; |
3978 |
end;
|
3979 |
2: // Acides amin?s potentiellement limitants |
3980 |
begin
|
3981 |
PD := PResSimulP.TabResult[79, j];
|
3982 |
py1 := PResSimulP.TabResult[77, j];
|
3983 |
if (py1 / GEProtJaap - PICO < PD)
|
3984 |
and (PD < py1 / GEProtJaap + PICO)
|
3985 |
then
|
3986 |
begin
|
3987 |
px1 := PResSimulP.TabResult[76, j];
|
3988 |
F := PResSimulP.TabResult[52, j];
|
3989 |
if px1 < F
|
3990 |
then
|
3991 |
begin
|
3992 |
a := PResSimulP.TabResult[74, j];
|
3993 |
b := PResSimulP.TabResult[75, j];
|
3994 |
NEcrois := PResSimulP.TabResult[90, j];
|
3995 |
NEmAL := PResSimulP.TabResult[71, j];
|
3996 |
mrPDen := (a + 2 * b * (px1 - 1)) * (NEcrois * 1000) / NEmAL; |
3997 |
end
|
3998 |
else
|
3999 |
mrPDen := 0;
|
4000 |
mrPDen2 := mrPDen |
4001 |
end
|
4002 |
else
|
4003 |
mrPDen2 := 0;
|
4004 |
dietNE := PResSimulP.TabResult[88, j];
|
4005 |
mrLD2 := (dietNE * 1000 - mrPDen2 * (1 + NEPD)) |
4006 |
/ ValEnergie[2, 2]; |
4007 |
result := (mrPDen2 / GEProtJaap) / mrLD2; |
4008 |
end;
|
4009 |
else
|
4010 |
result := 0;
|
4011 |
end;
|
4012 |
4: // l / p |
4013 |
case i of |
4014 |
1: // Acides amin?s non limitants |
4015 |
result := 0;
|
4016 |
2: // Acides amin?s potentiellement limitants |
4017 |
begin
|
4018 |
l := PResSimulP.TabResult[82, j];
|
4019 |
p := PResSimulP.TabResult[81, j];
|
4020 |
result := l / p; |
4021 |
end;
|
4022 |
else
|
4023 |
result := 0;
|
4024 |
end;
|
4025 |
else
|
4026 |
result := 0;
|
4027 |
end;
|
4028 |
4: // Valeurs ?nerg?tiques |
4029 |
begin
|
4030 |
// Diviseur
|
4031 |
case CBNRJ4.ItemIndex of |
4032 |
1: // PV^0.60 |
4033 |
d := Power (PResSimulP.TabResult[2, j], 0.60); |
4034 |
2: // PV^0.75 |
4035 |
d := Power (PResSimulP.TabResult[2, j], 0.75); |
4036 |
3: // Aliment ing?r? |
4037 |
d := PResSimulP.TabResult[11, j];
|
4038 |
4: // GMQ |
4039 |
d := PResSimulP.TabResult[84, j];
|
4040 |
else
|
4041 |
d := 1;
|
4042 |
end;
|
4043 |
case CBNRJ3V.ItemIndex of |
4044 |
0: // Energie digestible |
4045 |
begin
|
4046 |
EDing := PResSimulP.TabResult[109, j] * PResSimulP.TabResult[11, j]; |
4047 |
v := EDing; |
4048 |
end;
|
4049 |
1: // Energie m?tabolisable |
4050 |
case i of |
4051 |
1: // Valeur calcul?e |
4052 |
begin
|
4053 |
MEcrois := PResSimulP.TabResult[89, j];
|
4054 |
v := MEcrois * PResSimulP.TabResult[11, j];
|
4055 |
end;
|
4056 |
2: // Valeur simul?e |
4057 |
begin
|
4058 |
MEintake := PResSimulP.TabResult[86, j] / 1000; |
4059 |
v := MEintake; |
4060 |
end;
|
4061 |
else
|
4062 |
v := 0;
|
4063 |
end;
|
4064 |
2: // Energie nette |
4065 |
case i of |
4066 |
1: // Valeur calcul?e |
4067 |
begin
|
4068 |
NEcrois := PResSimulP.TabResult[90, j];
|
4069 |
v := NEcrois * PResSimulP.TabResult[11, j];
|
4070 |
end;
|
4071 |
2: // Valeur simul?e |
4072 |
begin
|
4073 |
NEintake := PResSimulP.TabResult[67, j];
|
4074 |
PD := PResSimulP.TabResult[79, j];
|
4075 |
v := (NEintake - PD * GEProtJaap * NEPD) / 1000;
|
4076 |
end;
|
4077 |
else
|
4078 |
v := 0;
|
4079 |
end;
|
4080 |
else
|
4081 |
v := 0;
|
4082 |
end;
|
4083 |
result := v / d; |
4084 |
end;
|
4085 |
else
|
4086 |
result := 0;
|
4087 |
end;
|
4088 |
end;
|
4089 |
|
4090 |
// AffGraphNRJ
|
4091 |
begin
|
4092 |
ResetGraph; |
4093 |
case CBNRJ1.ItemIndex of |
4094 |
0: // R?partition globale |
4095 |
begin
|
4096 |
Graph.LeftAxis.Title.Caption := Format('%s (%s)', [CBNRJ3.Text, CBNRJ4.Text]);
|
4097 |
// Graph.View3D := TRUE;
|
4098 |
Graph.Legend.Visible := FALSE; |
4099 |
Graph.Title.Text.Add(Format('%s (%s)', [CBNRJ3.Text, CBNRJ1.Text]));
|
4100 |
csv := '';
|
4101 |
for i := 0 to ListNRJ.Count - 1 do |
4102 |
csv := csv + Format('%s (%s)', [ListNRJ[i], CBNRJ4.Text]) + ';'; |
4103 |
MExport.Lines.Append(csv); |
4104 |
// Affichage du camembert
|
4105 |
PieNRJ.Active := TRUE; |
4106 |
PieNRJ.Clear; |
4107 |
if CBNRJ4.ItemIndex = 1 |
4108 |
then
|
4109 |
PieNRJ.Marks.Style := smsLabelPercent |
4110 |
else
|
4111 |
PieNRJ.Marks.Style := smsLabelValue; |
4112 |
t := 0;
|
4113 |
csv := '';
|
4114 |
for i := 0 to ListNRJ.Count - 1 do |
4115 |
begin
|
4116 |
y := NRJY; |
4117 |
if y > PICO
|
4118 |
then
|
4119 |
PieNRJ.AddPie(y, ListNRJ[i], AreaNRJ[i].SeriesColor); |
4120 |
t := t + y; |
4121 |
csv := csv + FloatToStrF(y, ffFixed, 15, 15) + ';'; |
4122 |
end;
|
4123 |
Graph.SubTitle.Text.Add(Format('%s = %1.0f %s', [StrTotal, t, StrMJ]));
|
4124 |
MExport.Lines.Append(csv); |
4125 |
end;
|
4126 |
1: // R?partition dynamique |
4127 |
begin
|
4128 |
Graph.LeftAxis.Title.Caption := Format('%s (%s)', [CBNRJ3.Text, CBNRJ4.Text]);
|
4129 |
Graph.BottomAxis.Title.Caption := CBNRJ2D.Text; |
4130 |
Graph.Title.Text.Add(Format('%s (%s)', [CBNRJ3.Text, CBNRJ1.Text]));
|
4131 |
csv := CBNRJ2D.Text; |
4132 |
for i := 0 to ListNRJ.Count - 1 do |
4133 |
csv := csv + ';' + Format('%s (%s)', [ListNRJ[i], CBNRJ4.Text]); |
4134 |
MExport.Lines.Append(csv); |
4135 |
// Affichage des aires
|
4136 |
for i := 0 to ListNRJ.Count - 1 do |
4137 |
AreaNRJ[i].Active := TRUE; |
4138 |
for i := 0 to ListNRJ.Count - 1 do |
4139 |
AreaNRJ[i].Clear; |
4140 |
if CBNRJ4.ItemIndex = 4 |
4141 |
then
|
4142 |
for i := 0 to ListNRJ.Count - 1 do |
4143 |
AreaNRJ[i].MultiArea := maStacked100 |
4144 |
else
|
4145 |
for i := 0 to ListNRJ.Count - 1 do |
4146 |
AreaNRJ[i].MultiArea := maStacked; |
4147 |
for j := 1 to PResSimulP.NbJSim do |
4148 |
begin
|
4149 |
csv := FloatToStrF(NRJX, ffFixed, 15, 15); |
4150 |
for i := 0 to ListNRJ.Count - 1 do |
4151 |
begin
|
4152 |
AreaNRJ[i].AddXY(NRJX, NRJY, '', clTeeColor);
|
4153 |
csv := csv + ';' + FloatToStrF(NRJY, ffFixed, 15, 15); |
4154 |
end;
|
4155 |
MExport.Lines.Append(csv); |
4156 |
end;
|
4157 |
if CBNRJ2D.ItemIndex = 3 |
4158 |
then // Dur?e (semaine) |
4159 |
Graph.BottomAxis.Increment := 1
|
4160 |
else
|
4161 |
Graph.BottomAxis.Increment := 10;
|
4162 |
end;
|
4163 |
2: // R?partition par p?riode |
4164 |
begin
|
4165 |
Graph.LeftAxis.Title.Caption := Format('%s (%s)', [CBNRJ3.Text, CBNRJ4.Text]);
|
4166 |
Graph.BottomAxis.Title.Caption := CBNRJ2P.Text; |
4167 |
Graph.Title.Text.Add(Format('%s (%s)', [CBNRJ3.Text, CBNRJ1.Text]));
|
4168 |
csv := CBNRJ2P.Text; |
4169 |
for i := 0 to ListNRJ.Count - 1 do |
4170 |
csv := csv + ';' + Format('%s (%s)', [ListNRJ[i], CBNRJ4.Text]); |
4171 |
MExport.Lines.Append(csv); |
4172 |
// Affichage des barres
|
4173 |
for i := 0 to ListNRJ.Count - 1 do |
4174 |
BarNRJ[i].Active := TRUE; |
4175 |
for i := 0 to ListNRJ.Count - 1 do |
4176 |
BarNRJ[i].Clear; |
4177 |
if CBNRJ4.ItemIndex = 3 |
4178 |
then
|
4179 |
for i := 0 to ListNRJ.Count - 1 do |
4180 |
BarNRJ[i].MultiBar := mbStacked100 |
4181 |
else
|
4182 |
for i := 0 to ListNRJ.Count - 1 do |
4183 |
BarNRJ[i].MultiBar := mbStacked; |
4184 |
j := 1;
|
4185 |
x := NRJX; |
4186 |
k := 1;
|
4187 |
if PResSimulP.NbJSim > 1 |
4188 |
then
|
4189 |
for j := 2 to PResSimulP.NbJSim do |
4190 |
begin
|
4191 |
p := NRJX; |
4192 |
if x <> p
|
4193 |
then
|
4194 |
begin
|
4195 |
// Changement de p?riode
|
4196 |
s := Format('%1.0f', [x]);
|
4197 |
csv := s; |
4198 |
for i := 0 to ListNRJ.Count - 1 do |
4199 |
begin
|
4200 |
y := NRJY; |
4201 |
if y > PICO
|
4202 |
then
|
4203 |
BarNRJ[i].AddBar(y, s, clTeeColor) |
4204 |
else
|
4205 |
BarNRJ[i].AddNull(s); |
4206 |
csv := csv + ';' + FloatToStrF(y, ffFixed, 15, 15); |
4207 |
end;
|
4208 |
MExport.Lines.Append(csv); |
4209 |
x := p; |
4210 |
k := j; |
4211 |
end;
|
4212 |
end;
|
4213 |
j := PResSimulP.NbJSim + 1;
|
4214 |
if j > k
|
4215 |
then
|
4216 |
begin
|
4217 |
if CBNRJ2P.ItemIndex = 3 |
4218 |
then // Globale |
4219 |
s := ' '
|
4220 |
else
|
4221 |
s := Format('%1.0f', [x]);
|
4222 |
csv := s; |
4223 |
for i := 0 to ListNRJ.Count - 1 do |
4224 |
begin
|
4225 |
y := NRJY; |
4226 |
if y > PICO
|
4227 |
then
|
4228 |
BarNRJ[i].AddBar(y, s, clTeeColor) |
4229 |
else
|
4230 |
BarNRJ[i].AddNull(s); |
4231 |
csv := csv + ';' + FloatToStrF(y, ffFixed, 15, 15); |
4232 |
end;
|
4233 |
MExport.Lines.Append(csv); |
4234 |
end;
|
4235 |
end;
|
4236 |
3: // Energie retenue |
4237 |
begin
|
4238 |
Graph.LeftAxis.Title.Caption := Format('%s (%s)', [CBNRJ3R.Text, CBNRJ4.Text]);
|
4239 |
Graph.BottomAxis.Title.Caption := CBNRJ2D.Text; |
4240 |
Graph.Legend.Alignment := laTop; |
4241 |
Graph.Title.Text.Add(CBNRJ1.Text); |
4242 |
LineNRJ[1].Title := StrAANonLim;
|
4243 |
LineNRJ[2].Title := StrAAPotLim;
|
4244 |
csv := CBNRJ2D.Text; |
4245 |
if CBNRJ3R.ItemIndex = 4 |
4246 |
then // le calcul lipides / prot?ines n?cessiterait une simulation |
4247 |
csv := csv + ';' + Format('%s (%s)', [LineNRJ[2].Title, CBNRJ4.Text]) |
4248 |
else
|
4249 |
for i := 1 to 2 do |
4250 |
csv := csv + ';' + Format('%s (%s)', [LineNRJ[i].Title, CBNRJ4.Text]); |
4251 |
MExport.Lines.Append(csv); |
4252 |
// Affichage des lignes
|
4253 |
for i := 1 to 2 do |
4254 |
LineNRJ[i].Active := TRUE; |
4255 |
for i := 1 to 2 do |
4256 |
LineNRJ[i].Clear; |
4257 |
if CBNRJ3R.ItemIndex = 4 |
4258 |
then // le calcul lipides / prot?ines n?cessiterait une simulation |
4259 |
LineNRJ[1].Active := FALSE;
|
4260 |
for j := 1 to PResSimulP.NbJSim do |
4261 |
begin
|
4262 |
csv := FloatToStrF(NRJX, ffFixed, 15, 15); |
4263 |
for i := 1 to 2 do |
4264 |
if (CBNRJ3R.ItemIndex = 4) and (i = 1) |
4265 |
then // le calcul lipides / prot?ines n?cessiterait une simulation |
4266 |
Continue |
4267 |
else
|
4268 |
begin
|
4269 |
LineNRJ[i].AddXY(NRJX, NRJY, '', clTeeColor);
|
4270 |
csv := csv + ';' + FloatToStrF(NRJY, ffFixed, 15, 15); |
4271 |
end;
|
4272 |
MExport.Lines.Append(csv); |
4273 |
end;
|
4274 |
if CBNRJ2D.ItemIndex = 3 |
4275 |
then // Dur?e (semaine) |
4276 |
Graph.BottomAxis.Increment := 1
|
4277 |
else
|
4278 |
Graph.BottomAxis.Increment := 10;
|
4279 |
end;
|
4280 |
4: // Valeurs ?nerg?tiques |
4281 |
begin
|
4282 |
Graph.LeftAxis.Title.Caption := Format('%s (%s)', [CBNRJ3V.Text, CBNRJ4.Text]);
|
4283 |
Graph.BottomAxis.Title.Caption := CBNRJ2D.Text; |
4284 |
Graph.Legend.Alignment := laTop; |
4285 |
Graph.Title.Text.Add(Format('%s (%s)', [CBNRJ3V.Text, CBNRJ1.Text]));
|
4286 |
LineNRJ[1].Title := StrValCal;
|
4287 |
LineNRJ[2].Title := StrValSim;
|
4288 |
csv := CBNRJ2D.Text; |
4289 |
for i := 1 to 2 do |
4290 |
csv := csv + ';' + Format('%s (%s)', [LineNRJ[i].Title, CBNRJ4.Text]); |
4291 |
MExport.Lines.Append(csv); |
4292 |
// Affichage des lignes
|
4293 |
for i := 1 to 2 do |
4294 |
LineNRJ[i].Active := TRUE; |
4295 |
for i := 1 to 2 do |
4296 |
LineNRJ[i].Clear; |
4297 |
for j := 1 to PResSimulP.NbJSim do |
4298 |
begin
|
4299 |
csv := FloatToStrF(NRJX, ffFixed, 15, 15); |
4300 |
for i := 1 to 2 do |
4301 |
begin
|
4302 |
LineNRJ[i].AddXY(NRJX, NRJY, '', clTeeColor);
|
4303 |
csv := csv + ';' + FloatToStrF(NRJY, ffFixed, 15, 15); |
4304 |
end;
|
4305 |
MExport.Lines.Append(csv); |
4306 |
end;
|
4307 |
if CBNRJ2D.ItemIndex = 3 |
4308 |
then // Dur?e (semaine) |
4309 |
Graph.BottomAxis.Increment := 1
|
4310 |
else
|
4311 |
Graph.BottomAxis.Increment := 10;
|
4312 |
end;
|
4313 |
end;
|
4314 |
if PieNRJ.Active
|
4315 |
then
|
4316 |
begin
|
4317 |
Graph.View3DOptions.Orthogonal := FALSE; |
4318 |
Graph.View3DOptions.Elevation := 315;
|
4319 |
Graph.View3DOptions.Rotation := 360;
|
4320 |
Graph.View3DOptions.Perspective := 0;
|
4321 |
end
|
4322 |
else
|
4323 |
begin
|
4324 |
Graph.View3DOptions.Orthogonal := TRUE; |
4325 |
Graph.View3DOptions.Elevation := 345;
|
4326 |
Graph.View3DOptions.Rotation := 345;
|
4327 |
Graph.View3DOptions.Perspective := 15;
|
4328 |
end;
|
4329 |
AjustEchelle(Graph); |
4330 |
end;
|
4331 |
|
4332 |
procedure TFResSimulP.CBNRJ1Change(Sender: TObject);
|
4333 |
begin
|
4334 |
CBNRJ4.Items.Clear; |
4335 |
case CBNRJ1.ItemIndex of |
4336 |
0: // R?partition globale |
4337 |
begin
|
4338 |
CBNRJ2D.Visible := FALSE; |
4339 |
CBNRJ2P.Visible := FALSE; |
4340 |
CBNRJ3.Visible := TRUE; |
4341 |
CBNRJ3R.Visible := FALSE; |
4342 |
CBNRJ3V.Visible := FALSE; |
4343 |
CBNRJ4.Visible := TRUE; |
4344 |
// Unit?s
|
4345 |
CBNRJ4.Items.Add(StrMJ); |
4346 |
CBNRJ4.Items.Add('%');
|
4347 |
end;
|
4348 |
1: // R?partition dynamique |
4349 |
begin
|
4350 |
CBNRJ2D.Visible := TRUE; |
4351 |
CBNRJ2P.Visible := FALSE; |
4352 |
CBNRJ3.Visible := TRUE; |
4353 |
CBNRJ3R.Visible := FALSE; |
4354 |
CBNRJ3V.Visible := FALSE; |
4355 |
CBNRJ4.Visible := TRUE; |
4356 |
// Unit?s
|
4357 |
CBNRJ4.Items.Add(Format('%s/%s', [StrMJ, StrJ]));
|
4358 |
CBNRJ4.Items.Add(Format('%s/(%s %s)^0.60/%s', [StrMJ, StrKg, StrPV, StrJ]));
|
4359 |
CBNRJ4.Items.Add(Format('%s/(%s %s)^0.75/%s', [StrMJ, StrKg, StrPV, StrJ]));
|
4360 |
CBNRJ4.Items.Add(Format('%s/%s %s', [StrMJ, StrKg, StrAlimentUnit]));
|
4361 |
CBNRJ4.Items.Add('%');
|
4362 |
end;
|
4363 |
2: // R?partition par p?riode |
4364 |
begin
|
4365 |
CBNRJ2D.Visible := FALSE; |
4366 |
CBNRJ2P.Visible := TRUE; |
4367 |
CBNRJ3.Visible := TRUE; |
4368 |
CBNRJ3R.Visible := FALSE; |
4369 |
CBNRJ3V.Visible := FALSE; |
4370 |
CBNRJ4.Visible := TRUE; |
4371 |
// Unit?s
|
4372 |
CBNRJ4.Items.Add(StrMJ); |
4373 |
CBNRJ4.Items.Add(Format('%s/%s', [StrMJ, StrJ]));
|
4374 |
CBNRJ4.Items.Add(Format('%s/%s %s', [StrMJ, StrKg, StrAlimentUnit]));
|
4375 |
CBNRJ4.Items.Add('%');
|
4376 |
end;
|
4377 |
3: // Energie retenue |
4378 |
begin
|
4379 |
CBNRJ2D.Visible := TRUE; |
4380 |
CBNRJ2P.Visible := FALSE; |
4381 |
CBNRJ3.Visible := FALSE; |
4382 |
CBNRJ3R.Visible := TRUE; |
4383 |
CBNRJ3V.Visible := FALSE; |
4384 |
CBNRJ4.Visible := FALSE; |
4385 |
// Unit?s
|
4386 |
case CBNRJ3R.ItemIndex of |
4387 |
0: // PD marginal |
4388 |
CBNRJ4.Items.Add(Format('%s/%s %s', [StrG, StrKg, StrAlimentUnit]));
|
4389 |
1: // X |
4390 |
CBNRJ4.Items.Add('%');
|
4391 |
2, 3: // PD / LD ou (PD / LD) marginal |
4392 |
CBNRJ4.Items.Add(Format('%s/%s', [StrG, StrG]));
|
4393 |
4: // p / l |
4394 |
CBNRJ4.Items.Add(Format('%s/%s', [StrKg, StrKg]));
|
4395 |
end;
|
4396 |
end;
|
4397 |
4: // Valeurs ?nerg?tiques |
4398 |
begin
|
4399 |
CBNRJ2D.Visible := TRUE; |
4400 |
CBNRJ2P.Visible := FALSE; |
4401 |
CBNRJ3.Visible := FALSE; |
4402 |
CBNRJ3R.Visible := FALSE; |
4403 |
CBNRJ3V.Visible := TRUE; |
4404 |
CBNRJ4.Visible := TRUE; |
4405 |
// Unit?s
|
4406 |
CBNRJ4.Items.Add(Format('%s/%s', [StrMJ, StrJ]));
|
4407 |
CBNRJ4.Items.Add(Format('%s/(%s %s)^0.60/%s', [StrMJ, StrKg, StrPV, StrJ]));
|
4408 |
CBNRJ4.Items.Add(Format('%s/(%s %s)^0.75/%s', [StrMJ, StrKg, StrPV, StrJ]));
|
4409 |
CBNRJ4.Items.Add(Format('%s/%s %s', [StrMJ, StrKg, StrAlimentUnit]));
|
4410 |
CBNRJ4.Items.Add(Format('%s/%s %s', [StrMJ, StrKg, StrGMQUnit]));
|
4411 |
end;
|
4412 |
end;
|
4413 |
CBNRJ4.ItemIndex := 0;
|
4414 |
AffGraphNRJ; |
4415 |
end;
|
4416 |
|
4417 |
procedure TFResSimulP.CBNRJ2Change(Sender: TObject);
|
4418 |
begin
|
4419 |
AffGraphNRJ; |
4420 |
end;
|
4421 |
|
4422 |
procedure TFResSimulP.CBNRJ3Change(Sender: TObject);
|
4423 |
begin
|
4424 |
if CBNRJ1.ItemIndex = 3 |
4425 |
then // Energie retenue |
4426 |
begin
|
4427 |
CBNRJ4.Items.Clear; |
4428 |
case CBNRJ3R.ItemIndex of |
4429 |
0: // PD marginal |
4430 |
CBNRJ4.Items.Add(Format('%s/%s %s', [StrG, StrKg, StrAlimentUnit]));
|
4431 |
1: // X |
4432 |
CBNRJ4.Items.Add('%');
|
4433 |
2, 3: // PD / LD ou (PD / LD) marginal |
4434 |
CBNRJ4.Items.Add(Format('%s/%s', [StrG, StrG]));
|
4435 |
4: // p / l |
4436 |
CBNRJ4.Items.Add(Format('%s/%s', [StrKg, StrKg]));
|
4437 |
end;
|
4438 |
CBNRJ4.ItemIndex := 0;
|
4439 |
end;
|
4440 |
AffGraphNRJ; |
4441 |
end;
|
4442 |
|
4443 |
procedure TFResSimulP.CBNRJ4Change(Sender: TObject);
|
4444 |
begin
|
4445 |
AffGraphNRJ; |
4446 |
end;
|
4447 |
|
4448 |
//////////////////
|
4449 |
// Min?raux //
|
4450 |
//////////////////
|
4451 |
procedure TFResSimulP.InitMin;
|
4452 |
const
|
4453 |
TabColor1: array[0..5] of TColor |
4454 |
= (clBlack, clTeal, clOlive, clPink, clRed, clGreen); |
4455 |
TabColor2: array[1..2] of TColor |
4456 |
= (clGreen, clRed); |
4457 |
var
|
4458 |
i: integer; |
4459 |
begin
|
4460 |
// ListMin : liste pour les min?raux
|
4461 |
ListMin := TStringList.Create; |
4462 |
ListMin.Assign(LBMin.Items); |
4463 |
// PieMin : s?rie (camembert) graphique
|
4464 |
PieMin := TPieSeries.Create(Graph); |
4465 |
PieMin.ParentChart := Graph; |
4466 |
PieMin.Circled := TRUE; |
4467 |
PieMin.Marks.ArrowLength := 24;
|
4468 |
PieMin.Marks.Arrow.Color := clBlack; |
4469 |
PieMin.Marks.Brush.Style := bsClear; |
4470 |
PieMin.Marks.Frame.Visible := FALSE; |
4471 |
PieMin.ValueFormat := Format('# ##0 %s', [StrG]);
|
4472 |
PieMin.PercentFormat := '##0 %';
|
4473 |
Graph.AddSeries(PieMin); |
4474 |
// AreaMin : s?ries (aires) graphiques
|
4475 |
SetLength(AreaMin, ListMin.Count); |
4476 |
for i := 0 to ListMin.Count - 1 do |
4477 |
begin
|
4478 |
AreaMin[i] := TAreaSeries.Create(Graph); |
4479 |
AreaMin[i].ParentChart := Graph; |
4480 |
AreaMin[i].Title := ListMin[i]; |
4481 |
AreaMin[i].SeriesColor := TabColor1[i]; |
4482 |
AreaMin[i].AreaLinesPen.Visible := FALSE; |
4483 |
Graph.AddSeries(AreaMin[i]); |
4484 |
end;
|
4485 |
// BarMin : s?ries (barres) graphiques
|
4486 |
SetLength(BarMin, ListMin.Count); |
4487 |
for i := 0 to ListMin.Count - 1 do |
4488 |
begin
|
4489 |
BarMin[i] := TBarSeries.Create(Graph); |
4490 |
BarMin[i].ParentChart := Graph; |
4491 |
BarMin[i].Title := ListMin[i]; |
4492 |
BarMin[i].SeriesColor := TabColor1[i]; |
4493 |
BarMin[i].BarPen.Color := BarMin[i].SeriesColor; |
4494 |
BarMin[i].Marks.Visible := FALSE; |
4495 |
Graph.AddSeries(BarMin[i]); |
4496 |
end;
|
4497 |
// LineMin : s?ries (lignes) graphiques
|
4498 |
for i := 1 to 2 do |
4499 |
begin
|
4500 |
LineMin[i] := TLineSeries.Create(Graph); |
4501 |
LineMin[i].ParentChart := Graph; |
4502 |
if i = 1 |
4503 |
then // Apport |
4504 |
LineMin[i].Title := StrApport |
4505 |
else // Besoin |
4506 |
LineMin[i].Title := StrBesoin; |
4507 |
LineMin[i].SeriesColor := TabColor2[i]; |
4508 |
LineMin[i].LinePen.Color := LineMin[i].SeriesColor; |
4509 |
LineMin[i].LinePen.Width := 2;
|
4510 |
Graph.AddSeries(LineMin[i]); |
4511 |
end;
|
4512 |
end;
|
4513 |
|
4514 |
procedure TFResSimulP.AffGraphMin;
|
4515 |
var
|
4516 |
i, j, k: integer; |
4517 |
x, y, t, p: double; |
4518 |
s, csv: string;
|
4519 |
|
4520 |
// Abscisse
|
4521 |
function MinX: double;
|
4522 |
begin
|
4523 |
case CBMin1.ItemIndex of |
4524 |
1: // R?partition dynamique |
4525 |
case CBMin2D.ItemIndex of |
4526 |
0: // Poids vif |
4527 |
result := PResSimulP.TabResult[2, j];
|
4528 |
1: // Age |
4529 |
result := PResSimulP.TabResult[1, j];
|
4530 |
2: // Jours |
4531 |
result := j; |
4532 |
3: // Semaines |
4533 |
result := j / 7;
|
4534 |
else
|
4535 |
result := 0;
|
4536 |
end;
|
4537 |
2: // R?partition par p?riode |
4538 |
case CBMin2P.ItemIndex of |
4539 |
0: // Semaine |
4540 |
result := (j - 1) div 7 + 1; |
4541 |
1: // R?gle qualit? |
4542 |
result := PResSimulP.TabResult[3, j];
|
4543 |
2: // R?gle quantit? |
4544 |
result := PResSimulP.TabResult[5, j];
|
4545 |
else
|
4546 |
result := 0;
|
4547 |
end;
|
4548 |
3: // Besoin et apport |
4549 |
case CBMin2D.ItemIndex of |
4550 |
0: // Poids vif |
4551 |
result := PResSimulP.TabResult[2, j];
|
4552 |
1: // Age |
4553 |
result := PResSimulP.TabResult[1, j];
|
4554 |
2: // Jours |
4555 |
result := j; |
4556 |
3: // Semaines |
4557 |
result := j / 7;
|
4558 |
else
|
4559 |
result := 0;
|
4560 |
end;
|
4561 |
else
|
4562 |
result := 0;
|
4563 |
end;
|
4564 |
end;
|
4565 |
|
4566 |
// Ordonn?e
|
4567 |
function MinY: double;
|
4568 |
var
|
4569 |
h: integer; |
4570 |
v, d, Ptot, Pdig, PV, GMQ, Indigestible, Entretien, Retenu, Gaspillage: double; |
4571 |
|
4572 |
// Composition des aliments
|
4573 |
procedure Composition(jour: integer);
|
4574 |
var
|
4575 |
Aliment1, Aliment2: integer; |
4576 |
IngereFrais, Taux1, Taux2, IngereSec1, IngereSec2, Ptot1, Ptot2, Pdig1, Pdig2: double; |
4577 |
CC1, CC2: CompositionChimique; |
4578 |
begin
|
4579 |
IngereFrais := PresSimulP.TabResult[11, jour];
|
4580 |
// Aliment 1
|
4581 |
Aliment1 := Round (PresSimulP.TabResult[7, jour]);
|
4582 |
if Aliment1 = -1 |
4583 |
then
|
4584 |
CC1 := CCVide |
4585 |
else
|
4586 |
begin
|
4587 |
PAliment := ListAliment[FindIdxAliment (FindNomAliment (Aliment1))]; |
4588 |
CC1 := PAliment.CC; |
4589 |
end;
|
4590 |
Taux1 := PresSimulP.TabResult[9, jour] / 100; |
4591 |
IngereSec1 := IngereFrais * Taux1 * CC1.MS / 1000;
|
4592 |
Ptot1 := IngereSec1 * CC1.P; |
4593 |
if Aliment1 = -1 |
4594 |
then
|
4595 |
Pdig1 := 0
|
4596 |
else
|
4597 |
if PAliment.Presentation = 0 |
4598 |
then // Granul?s |
4599 |
Pdig1 := IngereSec1 * PAliment.CC.PdigG |
4600 |
else // Farine |
4601 |
Pdig1 := IngereSec1 * PAliment.CC.PdigF; |
4602 |
// Aliment 2
|
4603 |
Aliment2 := Round (PresSimulP.TabResult[8, jour]);
|
4604 |
if Aliment2 = -1 |
4605 |
then
|
4606 |
CC2 := CCVide |
4607 |
else
|
4608 |
begin
|
4609 |
PAliment := ListAliment[FindIdxAliment (FindNomAliment (Aliment2))]; |
4610 |
CC2 := PAliment.CC; |
4611 |
end;
|
4612 |
Taux2 := PresSimulP.TabResult[10, jour] / 100; |
4613 |
IngereSec2 := IngereFrais * Taux2 * CC2.MS / 1000;
|
4614 |
Ptot2 := IngereSec2 * CC2.P; |
4615 |
if Aliment2 = -1 |
4616 |
then
|
4617 |
Pdig2 := 0
|
4618 |
else
|
4619 |
if PAliment.Presentation = 0 |
4620 |
then // Granul?s |
4621 |
Pdig2 := IngereSec2 * PAliment.CC.PdigG |
4622 |
else // Farine |
4623 |
Pdig2 := IngereSec2 * PAliment.CC.PdigF; |
4624 |
// Cumul
|
4625 |
Ptot := Ptot1 + Ptot2; |
4626 |
Pdig := Pdig1 + Pdig2; |
4627 |
end;
|
4628 |
|
4629 |
begin
|
4630 |
case CBMin1.ItemIndex of |
4631 |
0: // R?partition globale |
4632 |
begin
|
4633 |
v := 0;
|
4634 |
case CBMin3.ItemIndex of |
4635 |
0: // Phosphore |
4636 |
case i of |
4637 |
0: // Gaspillage |
4638 |
if CBMin5.ItemIndex = 1 |
4639 |
then // Total |
4640 |
for h := 1 to PresSimulP.NbJSim do |
4641 |
begin
|
4642 |
Composition(h); |
4643 |
Gaspillage := PResSimulP.TabResult[112, h];
|
4644 |
v := v + Ptot / (1 - Gaspillage) - Ptot;
|
4645 |
end;
|
4646 |
1: // Indigestible |
4647 |
if CBMin5.ItemIndex = 1 |
4648 |
then // Total |
4649 |
for h := 1 to PresSimulP.NbJSim do |
4650 |
begin
|
4651 |
Composition(h); |
4652 |
Indigestible := Ptot - Pdig; |
4653 |
v := v + Indigestible; |
4654 |
end;
|
4655 |
2: // Entretien |
4656 |
for h := 1 to PresSimulP.NbJSim do |
4657 |
begin
|
4658 |
Composition (h); |
4659 |
Indigestible := Ptot - Pdig; |
4660 |
PV := PResSimulP.TabResult[2, h];
|
4661 |
Entretien := 10 * PV / 1000; |
4662 |
if Ptot < Indigestible + Entretien
|
4663 |
then // D?ficit |
4664 |
v := v + Ptot - Indigestible |
4665 |
else
|
4666 |
v := v + Entretien; |
4667 |
end;
|
4668 |
3: // Retenu |
4669 |
for h := 1 to PresSimulP.NbJSim do |
4670 |
begin
|
4671 |
Composition (h); |
4672 |
Indigestible := Ptot - Pdig; |
4673 |
PV := PResSimulP.TabResult[2, h];
|
4674 |
Entretien := 10 * PV / 1000; |
4675 |
GMQ := PResSimulP.TabResult[84, h];
|
4676 |
Retenu := (5.4199 - 2 * 0.002857 * PV) * GMQ; |
4677 |
if Ptot < Indigestible + Entretien + Retenu
|
4678 |
then
|
4679 |
v := v + Max (Ptot - Indigestible - Entretien, 0)
|
4680 |
else
|
4681 |
v := v + Retenu; |
4682 |
end;
|
4683 |
4: // D?ficit |
4684 |
for h := 1 to PresSimulP.NbJSim do |
4685 |
begin
|
4686 |
Composition (h); |
4687 |
Indigestible := Ptot - Pdig; |
4688 |
PV := PResSimulP.TabResult[2, h];
|
4689 |
Entretien := 10 * PV / 1000; |
4690 |
GMQ := PResSimulP.TabResult[84, h];
|
4691 |
Retenu := (5.4199 - 2 * 0.002857 * PV) * GMQ; |
4692 |
if Ptot < Indigestible + Entretien + Retenu
|
4693 |
then
|
4694 |
v := v + Indigestible + Entretien + Retenu - Ptot; |
4695 |
end;
|
4696 |
5: // Exc?s |
4697 |
for h := 1 to PresSimulP.NbJSim do |
4698 |
begin
|
4699 |
Composition (h); |
4700 |
Indigestible := Ptot - Pdig; |
4701 |
PV := PResSimulP.TabResult[2, h];
|
4702 |
Entretien := 10 * PV / 1000; |
4703 |
GMQ := PResSimulP.TabResult[84, h];
|
4704 |
Retenu := (5.4199 - 2 * 0.002857 * PV) * GMQ; |
4705 |
if Ptot > Indigestible + Entretien + Retenu
|
4706 |
then
|
4707 |
v := v + Ptot - Indigestible - Entretien - Retenu; |
4708 |
end;
|
4709 |
end;
|
4710 |
end;
|
4711 |
result := v; |
4712 |
end;
|
4713 |
1: // R?partition dynamique |
4714 |
begin
|
4715 |
// Diviseur
|
4716 |
if CBMin4.ItemIndex = 1 |
4717 |
then // Aliment |
4718 |
d := PResSimulP.TabResult[113, j]
|
4719 |
else
|
4720 |
d := 1;
|
4721 |
case CBMin3.ItemIndex of |
4722 |
0: // Phosphore |
4723 |
case i of |
4724 |
0: // Gaspillage |
4725 |
if CBMin5.ItemIndex = 1 |
4726 |
then // Total |
4727 |
begin
|
4728 |
Composition(j); |
4729 |
Gaspillage := PResSimulP.TabResult[112, j];
|
4730 |
v := Ptot / (1 - Gaspillage) - Ptot;
|
4731 |
end
|
4732 |
else
|
4733 |
v := 0;
|
4734 |
1: // Indigestible |
4735 |
if CBMin5.ItemIndex = 1 |
4736 |
then // Total |
4737 |
begin
|
4738 |
Composition(j); |
4739 |
Indigestible := Ptot - Pdig; |
4740 |
v := Indigestible; |
4741 |
end
|
4742 |
else
|
4743 |
v := 0;
|
4744 |
2: // Entretien |
4745 |
begin
|
4746 |
Composition (j); |
4747 |
Indigestible := Ptot - Pdig; |
4748 |
PV := PResSimulP.TabResult[2, j];
|
4749 |
Entretien := 10 * PV / 1000; |
4750 |
if Ptot < Indigestible + Entretien
|
4751 |
then // D?ficit |
4752 |
v := Ptot - Indigestible |
4753 |
else
|
4754 |
v := Entretien; |
4755 |
end;
|
4756 |
3: // Retenu |
4757 |
begin
|
4758 |
Composition (j); |
4759 |
Indigestible := Ptot - Pdig; |
4760 |
PV := PResSimulP.TabResult[2, j];
|
4761 |
Entretien := 10 * PV / 1000; |
4762 |
GMQ := PResSimulP.TabResult[84, j];
|
4763 |
Retenu := (5.4199 - 2 * 0.002857 * PV) * GMQ; |
4764 |
if Ptot < Indigestible + Entretien + Retenu
|
4765 |
then // D?ficit |
4766 |
v := Max (Ptot - Indigestible - Entretien, 0)
|
4767 |
else
|
4768 |
v := Retenu; |
4769 |
end;
|
4770 |
4: // D?ficit |
4771 |
begin
|
4772 |
Composition (j); |
4773 |
Indigestible := Ptot - Pdig; |
4774 |
PV := PResSimulP.TabResult[2, j];
|
4775 |
Entretien := 10 * PV / 1000; |
4776 |
GMQ := PResSimulP.TabResult[84, j];
|
4777 |
Retenu := (5.4199 - 2 * 0.002857 * PV) * GMQ; |
4778 |
if Ptot < Indigestible + Entretien + Retenu
|
4779 |
then
|
4780 |
v := Indigestible + Entretien + Retenu - Ptot |
4781 |
else
|
4782 |
v := 0;
|
4783 |
end;
|
4784 |
5: // Exc?s |
4785 |
begin
|
4786 |
Composition (j); |
4787 |
Indigestible := Ptot - Pdig; |
4788 |
PV := PResSimulP.TabResult[2, j];
|
4789 |
Entretien := 10 * PV / 1000; |
4790 |
GMQ := PResSimulP.TabResult[84, j];
|
4791 |
Retenu := (5.4199 - 2 * 0.002857 * PV) * GMQ; |
4792 |
if Ptot > Indigestible + Entretien + Retenu
|
4793 |
then
|
4794 |
v := Ptot - Indigestible - Entretien - Retenu |
4795 |
else
|
4796 |
v := 0;
|
4797 |
end;
|
4798 |
else
|
4799 |
v := 0;
|
4800 |
end;
|
4801 |
else
|
4802 |
v := 0;
|
4803 |
end;
|
4804 |
result := v / d; |
4805 |
end;
|
4806 |
2: // R?partition par p?riode |
4807 |
begin
|
4808 |
// Diviseur
|
4809 |
case CBMin4.ItemIndex of |
4810 |
1: // Dur?e |
4811 |
d := j - k; |
4812 |
2: // Aliment |
4813 |
begin
|
4814 |
d := 0;
|
4815 |
for h := k to j - 1 do |
4816 |
d := d + PResSimulP.TabResult[113, h];
|
4817 |
end;
|
4818 |
else
|
4819 |
d := 1;
|
4820 |
end;
|
4821 |
v := 0;
|
4822 |
case CBMin3.ItemIndex of |
4823 |
0: // Phosphore |
4824 |
case i of |
4825 |
0: // Gaspillage |
4826 |
if CBMin5.ItemIndex = 1 |
4827 |
then // Total |
4828 |
for h := k to j - 1 do |
4829 |
begin
|
4830 |
Composition(h); |
4831 |
Gaspillage := PResSimulP.TabResult[112, h];
|
4832 |
v := v + Ptot / (1 - Gaspillage) - Ptot;
|
4833 |
end;
|
4834 |
1: // Indigestible |
4835 |
if CBMin5.ItemIndex = 1 |
4836 |
then // Total |
4837 |
for h := k to j - 1 do |
4838 |
begin
|
4839 |
Composition(h); |
4840 |
Indigestible := Ptot - Pdig; |
4841 |
v := v + Indigestible; |
4842 |
end;
|
4843 |
2: // Entretien |
4844 |
for h := k to j - 1 do |
4845 |
begin
|
4846 |
Composition (h); |
4847 |
Indigestible := Ptot - Pdig; |
4848 |
PV := PResSimulP.TabResult[2, h];
|
4849 |
Entretien := 10 * PV / 1000; |
4850 |
if Ptot < Indigestible + Entretien
|
4851 |
then // D?ficit |
4852 |
v := v + Ptot - Indigestible |
4853 |
else
|
4854 |
v := v + Entretien; |
4855 |
end;
|
4856 |
3: // Retenu |
4857 |
for h := k to j - 1 do |
4858 |
begin
|
4859 |
Composition (h); |
4860 |
Indigestible := Ptot - Pdig; |
4861 |
PV := PResSimulP.TabResult[2, h];
|
4862 |
Entretien := 10 * PV / 1000; |
4863 |
GMQ := PResSimulP.TabResult[84, h];
|
4864 |
Retenu := (5.4199 - 2 * 0.002857 * PV) * GMQ; |
4865 |
if Ptot < Indigestible + Entretien + Retenu
|
4866 |
then // D?ficit |
4867 |
v := v + Max (Ptot - Indigestible - Entretien, 0)
|
4868 |
else
|
4869 |
v := v + Retenu; |
4870 |
end;
|
4871 |
4: // D?ficit |
4872 |
for h := k to j - 1 do |
4873 |
begin
|
4874 |
Composition (h); |
4875 |
Indigestible := Ptot - Pdig; |
4876 |
PV := PResSimulP.TabResult[2, h];
|
4877 |
Entretien := 10 * PV / 1000; |
4878 |
GMQ := PResSimulP.TabResult[84, h];
|
4879 |
Retenu := (5.4199 - 2 * 0.002857 * PV) * GMQ; |
4880 |
if Ptot < Indigestible + Entretien + Retenu
|
4881 |
then
|
4882 |
v := v + Indigestible + Entretien + Retenu - Ptot; |
4883 |
end;
|
4884 |
5: // Exc?s |
4885 |
for h := k to j - 1 do |
4886 |
begin
|
4887 |
Composition (h); |
4888 |
Indigestible := Ptot - Pdig; |
4889 |
PV := PResSimulP.TabResult[2, h];
|
4890 |
Entretien := 10 * PV / 1000; |
4891 |
GMQ := PResSimulP.TabResult[84, h];
|
4892 |
Retenu := (5.4199 - 2 * 0.002857 * PV) * GMQ; |
4893 |
if Ptot > Indigestible + Entretien + Retenu
|
4894 |
then
|
4895 |
v := v + Ptot - Indigestible - Entretien - Retenu; |
4896 |
end;
|
4897 |
end;
|
4898 |
end;
|
4899 |
result := v / d; |
4900 |
end;
|
4901 |
3: // Besoin et apport |
4902 |
begin
|
4903 |
// Diviseur
|
4904 |
case CBMin4.ItemIndex of |
4905 |
1: // GMQ |
4906 |
d := PResSimulP.TabResult[84, j];
|
4907 |
2: // Aliment ing?r? |
4908 |
d := PResSimulP.TabResult[11, j];
|
4909 |
else
|
4910 |
d := 1;
|
4911 |
end;
|
4912 |
case CBMin3.ItemIndex of |
4913 |
0: // Phosphore |
4914 |
case i of |
4915 |
1: // Apport |
4916 |
begin
|
4917 |
Composition (j); |
4918 |
if CBMin5.ItemIndex = 0 |
4919 |
then // Digestibilit? apparente |
4920 |
v := Pdig |
4921 |
else // Total |
4922 |
v := Ptot; |
4923 |
end;
|
4924 |
2: // Besoin |
4925 |
if CBMin5.ItemIndex = 0 |
4926 |
then // Digestibilit? apparente |
4927 |
begin
|
4928 |
PV := PResSimulP.TabResult[2, j];
|
4929 |
Entretien := 10 * PV / 1000; |
4930 |
GMQ := PResSimulP.TabResult[84, j];
|
4931 |
Retenu := (5.4199 - 2 * 0.002857 * PV) * GMQ; |
4932 |
v := Entretien + Retenu; |
4933 |
end
|
4934 |
else
|
4935 |
v := 0;
|
4936 |
else
|
4937 |
v := 0;
|
4938 |
end;
|
4939 |
else
|
4940 |
v := 0;
|
4941 |
end;
|
4942 |
result := v / d; |
4943 |
end;
|
4944 |
else
|
4945 |
result := 0;
|
4946 |
end;
|
4947 |
end;
|
4948 |
|
4949 |
// AffGraphMin
|
4950 |
begin
|
4951 |
ResetGraph; |
4952 |
Graph.Title.Text.Add(Format('%s (%s)', [CBMin3.Text, CBMin1.Text]));
|
4953 |
Graph.SubTitle.Text.Add(CBMin5.Text); |
4954 |
Graph.LeftAxis.Title.Caption := Format('%s (%s)', [CBMin3.Text, CBMin4.Text]);
|
4955 |
case CBMin1.ItemIndex of |
4956 |
0: // R?partition globale |
4957 |
begin
|
4958 |
// Graph.View3D := TRUE;
|
4959 |
Graph.Legend.Visible := FALSE; |
4960 |
csv := '';
|
4961 |
for i := 0 to ListMin.Count - 1 do |
4962 |
csv := csv + Format('%s (%s)', [ListMin[i], CBMin4.Text]) + ';'; |
4963 |
MExport.Lines.Append(csv); |
4964 |
// Affichage du camembert
|
4965 |
PieMin.Active := TRUE; |
4966 |
PieMin.Clear; |
4967 |
if CBMin4.ItemIndex = 1 |
4968 |
then
|
4969 |
PieMin.Marks.Style := smsLabelPercent |
4970 |
else
|
4971 |
PieMin.Marks.Style := smsLabelValue; |
4972 |
t := 0;
|
4973 |
csv := '';
|
4974 |
for i := 0 to ListMin.Count - 1 do |
4975 |
begin
|
4976 |
y := MinY; |
4977 |
if y > PICO
|
4978 |
then
|
4979 |
PieMin.AddPie(y, ListMin[i], AreaMin[i].SeriesColor); |
4980 |
t := t + y; |
4981 |
csv := csv + FloatToStrF(y, ffFixed, 15, 15) + ';'; |
4982 |
end;
|
4983 |
Graph.SubTitle.Text.Add(Format('%s = %1.0f %s', [StrTotal, t, StrG]));
|
4984 |
MExport.Lines.Append(csv); |
4985 |
end;
|
4986 |
1: // R?partition dynamique |
4987 |
begin
|
4988 |
Graph.BottomAxis.Title.Caption := CBMin2D.Text; |
4989 |
csv := CBMin2D.Text; |
4990 |
for i := 0 to ListMin.Count - 1 do |
4991 |
csv := csv + ';' + Format('%s (%s)', [ListMin[i], CBMin4.Text]); |
4992 |
MExport.Lines.Append(csv); |
4993 |
// Affichage des aires
|
4994 |
for i := 0 to ListMin.Count - 1 do |
4995 |
AreaMin[i].Active := TRUE; |
4996 |
for i := 0 to ListMin.Count - 1 do |
4997 |
AreaMin[i].Clear; |
4998 |
if CBMin4.ItemIndex = 2 |
4999 |
then
|
5000 |
for i := 0 to ListMin.Count - 1 do |
5001 |
AreaMin[i].MultiArea := maStacked100 |
5002 |
else
|
5003 |
for i := 0 to ListMin.Count - 1 do |
5004 |
AreaMin[i].MultiArea := maStacked; |
5005 |
for j := 1 to PResSimulP.NbJSim do |
5006 |
begin
|
5007 |
csv := FloatToStrF(MinX, ffFixed, 15, 15); |
5008 |
for i := 0 to ListMin.Count - 1 do |
5009 |
begin
|
5010 |
AreaMin[i].AddXY(MinX, MinY, '', clTeeColor);
|
5011 |
csv := csv + ';' + FloatToStrF(MinY, ffFixed, 15, 15); |
5012 |
end;
|
5013 |
MExport.Lines.Append(csv); |
5014 |
end;
|
5015 |
if CBMin2D.ItemIndex = 3 |
5016 |
then // Dur?e (semaine) |
5017 |
Graph.BottomAxis.Increment := 1
|
5018 |
else
|
5019 |
Graph.BottomAxis.Increment := 10;
|
5020 |
end;
|
5021 |
2: // R?partition par p?riode |
5022 |
begin
|
5023 |
Graph.BottomAxis.Title.Caption := CBMin2P.Text; |
5024 |
csv := CBMin2P.Text; |
5025 |
for i := 0 to ListMin.Count - 1 do |
5026 |
csv := csv + ';' + Format('%s (%s)', [ListMin[i], CBMin4.Text]); |
5027 |
MExport.Lines.Append(csv); |
5028 |
// Affichage des barres
|
5029 |
for i := 0 to ListMin.Count - 1 do |
5030 |
BarMin[i].Active := TRUE; |
5031 |
for i := 0 to ListMin.Count - 1 do |
5032 |
BarMin[i].Clear; |
5033 |
if CBMin4.ItemIndex = 3 |
5034 |
then
|
5035 |
for i := 0 to ListMin.Count - 1 do |
5036 |
BarMin[i].MultiBar := mbStacked100 |
5037 |
else
|
5038 |
for i := 0 to ListMin.Count - 1 do |
5039 |
BarMin[i].MultiBar := mbStacked; |
5040 |
j := 1;
|
5041 |
x := MinX; |
5042 |
k := 1;
|
5043 |
if PResSimulP.NbJSim > 1 |
5044 |
then
|
5045 |
for j := 2 to PResSimulP.NbJSim do |
5046 |
begin
|
5047 |
p := MinX; |
5048 |
if x <> p
|
5049 |
then
|
5050 |
begin
|
5051 |
// Changement de p?riode
|
5052 |
s := Format('%1.0f', [x]);
|
5053 |
csv := s; |
5054 |
for i := 0 to ListMin.Count - 1 do |
5055 |
begin
|
5056 |
y := MinY; |
5057 |
if y > PICO
|
5058 |
then
|
5059 |
BarMin[i].AddBar(y, s, clTeeColor) |
5060 |
else
|
5061 |
BarMin[i].AddNull(s); |
5062 |
csv := csv + ';' + FloatToStrF(y, ffFixed, 15, 15); |
5063 |
end;
|
5064 |
MExport.Lines.Append(csv); |
5065 |
x := p; |
5066 |
k := j; |
5067 |
end;
|
5068 |
end;
|
5069 |
j := PResSimulP.NbJSim + 1;
|
5070 |
if j > k
|
5071 |
then
|
5072 |
begin
|
5073 |
if CBMin2P.ItemIndex = 3 |
5074 |
then // Globale |
5075 |
s := ' '
|
5076 |
else
|
5077 |
s := Format('%1.0f', [x]);
|
5078 |
csv := s; |
5079 |
for i := 0 to ListMin.Count - 1 do |
5080 |
begin
|
5081 |
y := MinY; |
5082 |
if y > PICO
|
5083 |
then
|
5084 |
BarMin[i].AddBar(y, s, clTeeColor) |
5085 |
else
|
5086 |
BarMin[i].AddNull(s); |
5087 |
csv := csv + ';' + FloatToStrF(y, ffFixed, 15, 15); |
5088 |
end;
|
5089 |
MExport.Lines.Append(csv); |
5090 |
end;
|
5091 |
end;
|
5092 |
3: // Besoin et apport |
5093 |
begin
|
5094 |
Graph.BottomAxis.Title.Caption := CBMin2D.Text; |
5095 |
Graph.Legend.Alignment := laTop; |
5096 |
csv := CBMin2D.Text; |
5097 |
if CBMin5.ItemIndex = 1 |
5098 |
then // En digestibilit? totale, seul l'apport est affich? |
5099 |
csv := csv + ';' + Format('%s (%s)', [LineMin[1].Title, CBMin4.Text]) |
5100 |
else
|
5101 |
for i := 1 to 2 do |
5102 |
csv := csv + ';' + Format('%s (%s)', [LineMin[i].Title, CBMin4.Text]); |
5103 |
// Affichage des lignes
|
5104 |
if CBMin5.ItemIndex = 1 |
5105 |
then // En digestibilit? totale, seul l'apport est affich? |
5106 |
LineMin[1].Active := TRUE
|
5107 |
else
|
5108 |
for i := 1 to 2 do |
5109 |
LineMin[i].Active := TRUE; |
5110 |
for i := 1 to 2 do |
5111 |
LineMin[i].Clear; |
5112 |
for j := 1 to PResSimulP.NbJSim do |
5113 |
begin
|
5114 |
csv := FloatToStrF(MinX, ffFixed, 15, 15); |
5115 |
for i := 1 to 2 do |
5116 |
if (CBAA5.ItemIndex = 1) and (i = 2) |
5117 |
then // Le besoin total n'a pas de sens |
5118 |
Continue |
5119 |
else
|
5120 |
begin
|
5121 |
LineMin[i].AddXY(MinX, MinY, '', clTeeColor);
|
5122 |
csv := csv + ';' + FloatToStrF(MinY, ffFixed, 15, 15); |
5123 |
end;
|
5124 |
MExport.Lines.Append(csv); |
5125 |
end;
|
5126 |
if CBMin2D.ItemIndex = 3 |
5127 |
then // Dur?e (semaine) |
5128 |
Graph.BottomAxis.Increment := 1
|
5129 |
else
|
5130 |
Graph.BottomAxis.Increment := 10;
|
5131 |
end;
|
5132 |
end;
|
5133 |
if PieMin.Active
|
5134 |
then
|
5135 |
begin
|
5136 |
Graph.View3DOptions.Orthogonal := FALSE; |
5137 |
Graph.View3DOptions.Elevation := 315;
|
5138 |
Graph.View3DOptions.Rotation := 360;
|
5139 |
Graph.View3DOptions.Perspective := 0;
|
5140 |
end
|
5141 |
else
|
5142 |
begin
|
5143 |
Graph.View3DOptions.Orthogonal := TRUE; |
5144 |
Graph.View3DOptions.Elevation := 345;
|
5145 |
Graph.View3DOptions.Rotation := 345;
|
5146 |
Graph.View3DOptions.Perspective := 15;
|
5147 |
end;
|
5148 |
AjustEchelle(Graph); |
5149 |
end;
|
5150 |
|
5151 |
procedure TFResSimulP.CBMin1Change(Sender: TObject);
|
5152 |
begin
|
5153 |
CBMin4.Items.Clear; |
5154 |
case CBMin1.ItemIndex of |
5155 |
0: // R?partition globale |
5156 |
begin
|
5157 |
CBMin2D.Visible := FALSE; |
5158 |
CBMin2P.Visible := FALSE; |
5159 |
// Unit?s
|
5160 |
CBMin4.Items.Add(StrG); |
5161 |
CBMin4.Items.Add('%');
|
5162 |
end;
|
5163 |
1: // R?partition dynamique |
5164 |
begin
|
5165 |
CBMin2D.Visible := TRUE; |
5166 |
CBMin2P.Visible := FALSE; |
5167 |
// Unit?s
|
5168 |
CBMin4.Items.Add(Format('%s/%s', [StrG, StrJ]));
|
5169 |
CBMin4.Items.Add(Format('%s/%s %s', [StrG, StrKg, StrAlimentUnit]));
|
5170 |
CBMin4.Items.Add('%');
|
5171 |
end;
|
5172 |
2: // R?partition par p?riode |
5173 |
begin
|
5174 |
CBMin2D.Visible := FALSE; |
5175 |
CBMin2P.Visible := TRUE; |
5176 |
// Unit?s
|
5177 |
CBMin4.Items.Add(StrG); |
5178 |
CBMin4.Items.Add(Format('%s/%s', [StrG, StrJ]));
|
5179 |
CBMin4.Items.Add(Format('%s/%s %s', [StrG, StrKg, StrAlimentUnit]));
|
5180 |
CBMin4.Items.Add('%');
|
5181 |
end;
|
5182 |
3: // Besoin et apport |
5183 |
begin
|
5184 |
CBMin2D.Visible := TRUE; |
5185 |
CBMin2P.Visible := FALSE; |
5186 |
// Unit?s
|
5187 |
CBMin4.Items.Add(Format('%s/%s', [StrG, StrJ]));
|
5188 |
CBMin4.Items.Add(Format('%s/%s %s', [StrG, StrKg, StrGMQUnit]));
|
5189 |
CBMin4.Items.Add(Format('%s/%s %s', [StrG, StrKg, StrAlimentUnit]));
|
5190 |
end;
|
5191 |
end;
|
5192 |
CBMin4.ItemIndex := 0;
|
5193 |
AffGraphMin; |
5194 |
end;
|
5195 |
|
5196 |
procedure TFResSimulP.CBMin2Change(Sender: TObject);
|
5197 |
begin
|
5198 |
AffGraphMin; |
5199 |
end;
|
5200 |
|
5201 |
procedure TFResSimulP.CBMin3Change(Sender: TObject);
|
5202 |
begin
|
5203 |
AffGraphMin; |
5204 |
end;
|
5205 |
|
5206 |
procedure TFResSimulP.CBMin4Change(Sender: TObject);
|
5207 |
begin
|
5208 |
AffGraphMin; |
5209 |
end;
|
5210 |
|
5211 |
procedure TFResSimulP.CBMin5Change(Sender: TObject);
|
5212 |
begin
|
5213 |
AffGraphMin; |
5214 |
end;
|
5215 |
|
5216 |
////////////////
|
5217 |
// Rejets //
|
5218 |
////////////////
|
5219 |
procedure TFResSimulP.InitRej;
|
5220 |
const
|
5221 |
TabColor: array[0..4] of TColor |
5222 |
= (clBlack, clMaroon, clYellow, clMaroon, clPink); |
5223 |
var
|
5224 |
i: integer; |
5225 |
begin
|
5226 |
// ListRej : liste pour les rejets
|
5227 |
ListRej := TStringList.Create; |
5228 |
ListRej.Assign(LBRej.Items); |
5229 |
// PieRej : s?rie (camembert) graphique
|
5230 |
PieRej := TPieSeries.Create(Graph); |
5231 |
PieRej.ParentChart := Graph; |
5232 |
PieRej.Circled := TRUE; |
5233 |
PieRej.Marks.ArrowLength := 24;
|
5234 |
PieRej.Marks.Arrow.Color := clBlack; |
5235 |
PieRej.Marks.Brush.Style := bsClear; |
5236 |
PieRej.Marks.Frame.Visible := FALSE; |
5237 |
PieRej.ValueFormat := Format('# ##0 %s', [StrG]);
|
5238 |
PieRej.PercentFormat := '##0 %';
|
5239 |
Graph.AddSeries(PieRej); |
5240 |
// AreaRej : s?ries (aires) graphiques
|
5241 |
SetLength(AreaRej, ListRej.Count); |
5242 |
for i := 0 to ListRej.Count - 1 do |
5243 |
begin
|
5244 |
AreaRej[i] := TAreaSeries.Create(Graph); |
5245 |
AreaRej[i].ParentChart := Graph; |
5246 |
AreaRej[i].Title := ListRej[i]; |
5247 |
AreaRej[i].SeriesColor := TabColor[i]; |
5248 |
AreaRej[i].AreaLinesPen.Visible := FALSE; |
5249 |
Graph.AddSeries(AreaRej[i]); |
5250 |
end;
|
5251 |
// BarRej : s?ries (barres) graphiques
|
5252 |
SetLength(BarRej, ListRej.Count); |
5253 |
for i := 0 to ListRej.Count - 1 do |
5254 |
begin
|
5255 |
BarRej[i] := TBarSeries.Create(Graph); |
5256 |
BarRej[i].ParentChart := Graph; |
5257 |
BarRej[i].Title := ListRej[i]; |
5258 |
BarRej[i].SeriesColor := TabColor[i]; |
5259 |
BarRej[i].BarPen.Color := BarRej[i].SeriesColor; |
5260 |
BarRej[i].Marks.Visible := FALSE; |
5261 |
Graph.AddSeries(BarRej[i]); |
5262 |
end;
|
5263 |
end;
|
5264 |
|
5265 |
procedure TFResSimulP.AffGraphRej;
|
5266 |
var
|
5267 |
i, j, k: integer; |
5268 |
x, y, t, p: double; |
5269 |
s, csv: string;
|
5270 |
|
5271 |
// Abscisse
|
5272 |
function RejX: double;
|
5273 |
begin
|
5274 |
case CBRej1.ItemIndex of |
5275 |
1: // R?partition dynamique |
5276 |
case CBRej2D.ItemIndex of |
5277 |
0: // Poids vif |
5278 |
result := PResSimulP.TabResult[2, j];
|
5279 |
1: // Age |
5280 |
result := PResSimulP.TabResult[1, j];
|
5281 |
2: // Jours |
5282 |
result := j; |
5283 |
3: // Semaines |
5284 |
result := j / 7;
|
5285 |
else
|
5286 |
result := 0;
|
5287 |
end;
|
5288 |
2: // R?partition par p?riode |
5289 |
case CBRej2P.ItemIndex of |
5290 |
0: // Semaine |
5291 |
result := (j - 1) div 7 + 1; |
5292 |
1: // R?gle qualit? |
5293 |
result := PResSimulP.TabResult[3, j];
|
5294 |
2: // R?gle quantit? |
5295 |
result := PResSimulP.TabResult[5, j];
|
5296 |
else
|
5297 |
result := 0;
|
5298 |
end;
|
5299 |
else
|
5300 |
result := 0;
|
5301 |
end;
|
5302 |
end;
|
5303 |
|
5304 |
// Ordonn?e
|
5305 |
function RejY: double;
|
5306 |
var
|
5307 |
h: integer; |
5308 |
v, d, IngereSec1, IngereSec2, Ptot, Pdig, Ingere, Digestible, Depose, Gaspillage: double; |
5309 |
CC1, CC2: CompositionChimique; |
5310 |
|
5311 |
// Composition des aliments
|
5312 |
procedure Composition(jour: integer);
|
5313 |
var
|
5314 |
Aliment1, Aliment2: integer; |
5315 |
IngereFrais, Taux1, Taux2, Ptot1, Ptot2, Pdig1, Pdig2: double; |
5316 |
begin
|
5317 |
IngereFrais := PresSimulP.TabResult[11, jour];
|
5318 |
// Aliment 1
|
5319 |
Aliment1 := Round (PresSimulP.TabResult[7, jour]);
|
5320 |
if Aliment1 = -1 |
5321 |
then
|
5322 |
CC1 := CCVide |
5323 |
else
|
5324 |
begin
|
5325 |
PAliment := ListAliment[FindIdxAliment (FindNomAliment (Aliment1))]; |
5326 |
CC1 := PAliment.CC; |
5327 |
end;
|
5328 |
Taux1 := PresSimulP.TabResult[9, jour] / 100; |
5329 |
IngereSec1 := IngereFrais * Taux1 * CC1.MS / 1000;
|
5330 |
Ptot1 := IngereSec1 * CC1.P; |
5331 |
if Aliment1 = -1 |
5332 |
then
|
5333 |
Pdig1 := 0
|
5334 |
else
|
5335 |
if PAliment.Presentation = 0 |
5336 |
then // Granul?s |
5337 |
Pdig1 := IngereSec1 * PAliment.CC.PdigG |
5338 |
else // Farine |
5339 |
Pdig1 := IngereSec1 * PAliment.CC.PdigF; |
5340 |
// Aliment 2
|
5341 |
Aliment2 := Round (PresSimulP.TabResult[8, jour]);
|
5342 |
if Aliment2 = -1 |
5343 |
then
|
5344 |
CC2 := CCVide |
5345 |
else
|
5346 |
begin
|
5347 |
PAliment := ListAliment[FindIdxAliment (FindNomAliment (Aliment2))]; |
5348 |
CC2 := PAliment.CC; |
5349 |
end;
|
5350 |
Taux2 := PresSimulP.TabResult[10, jour] / 100; |
5351 |
IngereSec2 := IngereFrais * Taux2 * CC2.MS / 1000;
|
5352 |
Ptot2 := IngereSec2 * CC2.P; |
5353 |
if Aliment2 = -1 |
5354 |
then
|
5355 |
Pdig2 := 0
|
5356 |
else
|
5357 |
if PAliment.Presentation = 0 |
5358 |
then // Granul?s |
5359 |
Pdig2 := IngereSec2 * PAliment.CC.PdigG |
5360 |
else // Farine |
5361 |
Pdig2 := IngereSec2 * PAliment.CC.PdigF; |
5362 |
// Cumul
|
5363 |
Ptot := Ptot1 + Ptot2; |
5364 |
Pdig := Pdig1 + Pdig2; |
5365 |
end;
|
5366 |
|
5367 |
// Calcul de l'ing?r?
|
5368 |
function CalcIngere: Double;
|
5369 |
begin
|
5370 |
case CBRej3.ItemIndex of |
5371 |
0: // Azote |
5372 |
result := (IngereSec1*CC1.MAT + IngereSec2*CC2.MAT) * 0.16;
|
5373 |
1: // Phosphore |
5374 |
result := Ptot; |
5375 |
2: // Calcium |
5376 |
result := IngereSec1*CC1.Ca + IngereSec2*CC2.Ca; |
5377 |
3: // Potassium |
5378 |
result := IngereSec1*CC1.K + IngereSec2*CC2.K; |
5379 |
4: // Cuivre |
5380 |
result := IngereSec1*CC1.Cu + IngereSec2*CC2.Cu; |
5381 |
5: // Zinc |
5382 |
result := IngereSec1*CC1.Zn + IngereSec2*CC2.Zn; |
5383 |
else
|
5384 |
result := 0;
|
5385 |
end;
|
5386 |
end;
|
5387 |
|
5388 |
// Calcul du digestible
|
5389 |
function CalcDigestible: Double;
|
5390 |
begin
|
5391 |
case CBRej3.ItemIndex of |
5392 |
0: // Azote |
5393 |
result := (IngereSec1*CC1.MAT*CC1.dMAT_C/100 + IngereSec2*CC2.MAT*CC2.dMAT_C/100) * 0.16; |
5394 |
1: // Phosphore |
5395 |
result := Pdig; |
5396 |
else
|
5397 |
result := 0;
|
5398 |
end;
|
5399 |
end;
|
5400 |
|
5401 |
// Calcul du d?p?t (potentiel)
|
5402 |
function CalcDepot(jour: integer): Double;
|
5403 |
var
|
5404 |
PV, PVV, PVfin, PVVfin, GMQ, PD: Double; |
5405 |
begin
|
5406 |
PV := PResSimulP.TabResult[2, jour];
|
5407 |
PVV := CalcPVV (PV); |
5408 |
PVfin := PResSimulP.TabResult[83, jour];
|
5409 |
PVVfin := CalcPVV (PVfin); |
5410 |
GMQ := PResSimulP.TabResult[84, jour];
|
5411 |
PD := PResSimulP.TabResult[79, jour];
|
5412 |
case CBRej3.ItemIndex of |
5413 |
0: // Azote |
5414 |
result := PD * 0.16;
|
5415 |
1: // Phosphore |
5416 |
result := (5.4199 - 2 * 0.002857 * PV) * GMQ; |
5417 |
2: // Calcium |
5418 |
result := -0.00180 * (Power (PVVfin, 2) - Power (PVV, 2)) + 8.64633 * (PVVfin - PVV); |
5419 |
3: // Potassium |
5420 |
result := -0.00345 * (Power (PVVfin, 2) - Power (PVV, 2)) + 2.53338 * (PVVfin - PVV); |
5421 |
4: // Cuivre |
5422 |
result := -0.00251 * (Power (PVVfin, 2) - Power (PVV, 2)) + 1.05393 * (PVVfin - PVV); |
5423 |
5: // Zinc |
5424 |
result := 21.8 * (PVVfin - PVV); |
5425 |
else
|
5426 |
result := 0;
|
5427 |
end;
|
5428 |
end;
|
5429 |
|
5430 |
// RejY
|
5431 |
begin
|
5432 |
case CBRej1.ItemIndex of |
5433 |
0: // R?partition globale |
5434 |
begin
|
5435 |
v := 0;
|
5436 |
for h := 1 to PResSimulP.NbJSim do |
5437 |
begin
|
5438 |
Composition (h); |
5439 |
Ingere := CalcIngere; |
5440 |
Gaspillage := PResSimulP.TabResult[112, h];
|
5441 |
Digestible := CalcDigestible; |
5442 |
Depose := CalcDepot(h); |
5443 |
if CBRej3.ItemIndex < 2 |
5444 |
then // Azote ou phosphore |
5445 |
case i of |
5446 |
0: // Gaspillage |
5447 |
v := v + Ingere / (1 - Gaspillage) - Ingere;
|
5448 |
1: // F?cal |
5449 |
v := v + Ingere - Digestible; |
5450 |
2: // Urinaire |
5451 |
v := v + Max(Digestible - Depose, 0);
|
5452 |
4: // Retenu |
5453 |
v := v + Min(Digestible, Depose); |
5454 |
end
|
5455 |
else // Autres |
5456 |
case i of |
5457 |
0: // Gaspillage |
5458 |
v := v + Ingere / (1 - Gaspillage) - Ingere;
|
5459 |
3: // Ecr?t? |
5460 |
v := v + Max(Ingere - Depose, 0);
|
5461 |
4: // Retenu |
5462 |
v := v + Min(Ingere, Depose); |
5463 |
end;
|
5464 |
end;
|
5465 |
result := v; |
5466 |
end;
|
5467 |
1: // R?partition dynamique |
5468 |
begin
|
5469 |
// Diviseur
|
5470 |
if CBRej4.ItemIndex = 1 |
5471 |
then // Aliment ing?r? |
5472 |
d := PResSimulP.TabResult[113, j]
|
5473 |
else
|
5474 |
d := 1;
|
5475 |
Composition(j); |
5476 |
Ingere := CalcIngere; |
5477 |
Gaspillage := PResSimulP.TabResult[112, j];
|
5478 |
Digestible := CalcDigestible; |
5479 |
Depose := CalcDepot(j); |
5480 |
if CBRej3.ItemIndex < 2 |
5481 |
then // Azote ou phosphore |
5482 |
case i of |
5483 |
0: // Gaspillage |
5484 |
v := Ingere / (1 - Gaspillage) - Ingere;
|
5485 |
1: // F?cal |
5486 |
v := Ingere - Digestible; |
5487 |
2: // Urinaire |
5488 |
v := Max(Digestible - Depose, 0);
|
5489 |
4: // Retenu |
5490 |
v := Min(Digestible, Depose); |
5491 |
else
|
5492 |
v := 0;
|
5493 |
end
|
5494 |
else // Autres |
5495 |
case i of |
5496 |
0: // Gaspillage |
5497 |
v := Ingere / (1 - Gaspillage) - Ingere;
|
5498 |
3: // Ecr?t? |
5499 |
v := Max(Ingere - Depose, 0);
|
5500 |
4: // Retenu |
5501 |
v := Min(Ingere, Depose); |
5502 |
else
|
5503 |
v := 0;
|
5504 |
end;
|
5505 |
result := v / d; |
5506 |
end;
|
5507 |
2: // R?partition par p?riode |
5508 |
begin
|
5509 |
// Diviseur
|
5510 |
case CBRej4.ItemIndex of |
5511 |
1: // Dur?e |
5512 |
d := j - k; |
5513 |
2: // Aliment |
5514 |
begin
|
5515 |
d := 0;
|
5516 |
for h := k to j - 1 do |
5517 |
d := d + PResSimulP.TabResult[113, h];
|
5518 |
end;
|
5519 |
else
|
5520 |
d := 1;
|
5521 |
end;
|
5522 |
v := 0;
|
5523 |
for h := k to j - 1 do |
5524 |
begin
|
5525 |
Composition(h); |
5526 |
Ingere := CalcIngere; |
5527 |
Gaspillage := PResSimulP.TabResult[112, h];
|
5528 |
Digestible := CalcDigestible; |
5529 |
Depose := CalcDepot(h); |
5530 |
if CBRej3.ItemIndex < 2 |
5531 |
then // Azote ou phosphore |
5532 |
case i of |
5533 |
0: // Gaspillage |
5534 |
v := v + Ingere / (1 - Gaspillage) - Ingere;
|
5535 |
1: // F?cal |
5536 |
v := v + Ingere - Digestible; |
5537 |
2: // Urinaire |
5538 |
v := v + Max(Digestible - Depose, 0);
|
5539 |
4: // Retenu |
5540 |
v := v + Min(Digestible, Depose); |
5541 |
end
|
5542 |
else // Autres |
5543 |
case i of |
5544 |
0: // Gaspillage |
5545 |
v := v + Ingere / (1 - Gaspillage) - Ingere;
|
5546 |
3: // Ecr?t? |
5547 |
v := v + Max(Ingere - Depose, 0);
|
5548 |
4: // Retenu |
5549 |
v := v + Min(Ingere, Depose); |
5550 |
end;
|
5551 |
end;
|
5552 |
result := v / d; |
5553 |
end;
|
5554 |
else
|
5555 |
result := 0;
|
5556 |
end;
|
5557 |
end;
|
5558 |
|
5559 |
// AffGraphRej
|
5560 |
begin
|
5561 |
ResetGraph; |
5562 |
Graph.Title.Text.Add(Format('%s (%s)', [CBRej3.Text, CBRej1.Text]));
|
5563 |
Graph.LeftAxis.Title.Caption := Format('%s (%s)', [CBRej3.Text, CBRej4.Text]);
|
5564 |
case CBRej1.ItemIndex of |
5565 |
0: // R?partition globale |
5566 |
begin
|
5567 |
// Graph.View3D := TRUE;
|
5568 |
Graph.Legend.Visible := FALSE; |
5569 |
csv := '';
|
5570 |
for i := 0 to ListRej.Count - 1 do |
5571 |
csv := csv + Format('%s (%s)', [ListRej[i], CBRej4.Text]) + ';'; |
5572 |
MExport.Lines.Append(csv); |
5573 |
// Affichage du camembert
|
5574 |
PieRej.Active := TRUE; |
5575 |
PieRej.Clear; |
5576 |
if CBRej4.ItemIndex = 1 |
5577 |
then
|
5578 |
PieRej.Marks.Style := smsLabelPercent |
5579 |
else
|
5580 |
PieRej.Marks.Style := smsLabelValue; |
5581 |
t := 0;
|
5582 |
csv := '';
|
5583 |
for i := 0 to ListRej.Count - 1 do |
5584 |
begin
|
5585 |
y := RejY; |
5586 |
if y > PICO
|
5587 |
then
|
5588 |
PieRej.AddPie(y, ListRej[i], AreaRej[i].SeriesColor); |
5589 |
t := t + y; |
5590 |
csv := csv + FloatToStrF(y, ffFixed, 15, 15) + ';'; |
5591 |
end;
|
5592 |
if CBRej3.ItemIndex > 3 |
5593 |
then // Oligo-?l?ment |
5594 |
Graph.SubTitle.Text.Add(Format('%s = %1.0f %s', [StrTotal, t, StrMg]))
|
5595 |
else // Macro-?l?ment |
5596 |
Graph.SubTitle.Text.Add(Format('%s = %1.0f %s', [StrTotal, t, StrG]));
|
5597 |
MExport.Lines.Append(csv); |
5598 |
end;
|
5599 |
1: // R?partition dynamique |
5600 |
begin
|
5601 |
Graph.BottomAxis.Title.Caption := CBRej2D.Text; |
5602 |
csv := CBRej2D.Text; |
5603 |
for i := 0 to ListRej.Count - 1 do |
5604 |
csv := csv + ';' + Format('%s (%s)', [ListRej[i], CBRej4.Text]); |
5605 |
MExport.Lines.Append(csv); |
5606 |
// Affichage des aires
|
5607 |
AreaRej[0].Active := TRUE;
|
5608 |
AreaRej[1].Active := CBRej3.ItemIndex < 2; |
5609 |
AreaRej[2].Active := CBRej3.ItemIndex < 2; |
5610 |
AreaRej[3].Active := CBRej3.ItemIndex > 1; |
5611 |
AreaRej[4].Active := TRUE;
|
5612 |
for i := 0 to ListRej.Count - 1 do |
5613 |
AreaRej[i].Clear; |
5614 |
if CBRej4.ItemIndex = 2 |
5615 |
then
|
5616 |
for i := 0 to ListRej.Count - 1 do |
5617 |
AreaRej[i].MultiArea := maStacked100 |
5618 |
else
|
5619 |
for i := 0 to ListRej.Count - 1 do |
5620 |
AreaRej[i].MultiArea := maStacked; |
5621 |
for j := 1 to PResSimulP.NbJSim do |
5622 |
begin
|
5623 |
csv := FloatToStrF(RejX, ffFixed, 15, 15); |
5624 |
for i := 0 to ListRej.Count - 1 do |
5625 |
begin
|
5626 |
AreaRej[i].AddXY(RejX, RejY, '', clTeeColor);
|
5627 |
csv := csv + ';' + FloatToStrF(RejY, ffFixed, 15, 15); |
5628 |
end;
|
5629 |
MExport.Lines.Append(csv); |
5630 |
end;
|
5631 |
if CBRej2D.ItemIndex = 3 |
5632 |
then // Dur?e (semaine) |
5633 |
Graph.BottomAxis.Increment := 1
|
5634 |
else
|
5635 |
Graph.BottomAxis.Increment := 10;
|
5636 |
end;
|
5637 |
2: // R?partition par p?riode |
5638 |
begin
|
5639 |
Graph.BottomAxis.Title.Caption := CBRej2P.Text; |
5640 |
csv := CBRej2P.Text; |
5641 |
for i := 0 to ListRej.Count - 1 do |
5642 |
csv := csv + ';' + Format('%s (%s)', [ListRej[i], CBRej4.Text]); |
5643 |
MExport.Lines.Append(csv); |
5644 |
// Affichage des barres
|
5645 |
BarRej[0].Active := TRUE;
|
5646 |
BarRej[1].Active := CBRej3.ItemIndex < 2; |
5647 |
BarRej[2].Active := CBRej3.ItemIndex < 2; |
5648 |
BarRej[3].Active := CBRej3.ItemIndex > 1; |
5649 |
BarRej[4].Active := TRUE;
|
5650 |
for i := 0 to ListRej.Count - 1 do |
5651 |
BarRej[i].Clear; |
5652 |
if CBRej4.ItemIndex = 3 |
5653 |
then
|
5654 |
for i := 0 to ListRej.Count - 1 do |
5655 |
BarRej[i].MultiBar := mbStacked100 |
5656 |
else
|
5657 |
for i := 0 to ListRej.Count - 1 do |
5658 |
BarRej[i].MultiBar := mbStacked; |
5659 |
j := 1;
|
5660 |
x := RejX; |
5661 |
k := 1;
|
5662 |
if PResSimulP.NbJSim > 1 |
5663 |
then
|
5664 |
for j := 2 to PResSimulP.NbJSim do |
5665 |
begin
|
5666 |
p := RejX; |
5667 |
if x <> p
|
5668 |
then
|
5669 |
begin
|
5670 |
// Changement de p?riode
|
5671 |
s := Format('%1.0f', [x]);
|
5672 |
csv := s; |
5673 |
for i := 0 to ListRej.Count - 1 do |
5674 |
begin
|
5675 |
y := RejY; |
5676 |
if y > PICO
|
5677 |
then
|
5678 |
BarRej[i].AddBar(y, s, clTeeColor) |
5679 |
else
|
5680 |
BarRej[i].AddNull(s); |
5681 |
csv := csv + ';' + FloatToStrF(y, ffFixed, 15, 15); |
5682 |
end;
|
5683 |
MExport.Lines.Append(csv); |
5684 |
x := p; |
5685 |
k := j; |
5686 |
end;
|
5687 |
end;
|
5688 |
j := PResSimulP.NbJSim + 1;
|
5689 |
if j > k
|
5690 |
then
|
5691 |
begin
|
5692 |
if CBRej2P.ItemIndex = 3 |
5693 |
then // Globale |
5694 |
s := ' '
|
5695 |
else
|
5696 |
s := Format('%1.0f', [x]);
|
5697 |
csv := s; |
5698 |
for i := 0 to ListRej.Count - 1 do |
5699 |
begin
|
5700 |
y := RejY; |
5701 |
if y > PICO
|
5702 |
then
|
5703 |
BarRej[i].AddBar(y, s, clTeeColor) |
5704 |
else
|
5705 |
BarRej[i].AddNull(s); |
5706 |
csv := csv + ';' + FloatToStrF(y, ffFixed, 15, 15); |
5707 |
end;
|
5708 |
MExport.Lines.Append(csv); |
5709 |
end;
|
5710 |
end;
|
5711 |
end;
|
5712 |
if PieRej.Active
|
5713 |
then
|
5714 |
begin
|
5715 |
Graph.View3DOptions.Orthogonal := FALSE; |
5716 |
Graph.View3DOptions.Elevation := 315;
|
5717 |
Graph.View3DOptions.Rotation := 360;
|
5718 |
Graph.View3DOptions.Perspective := 0;
|
5719 |
end
|
5720 |
else
|
5721 |
begin
|
5722 |
Graph.View3DOptions.Orthogonal := TRUE; |
5723 |
Graph.View3DOptions.Elevation := 345;
|
5724 |
Graph.View3DOptions.Rotation := 345;
|
5725 |
Graph.View3DOptions.Perspective := 15;
|
5726 |
end;
|
5727 |
AjustEchelle(Graph); |
5728 |
end;
|
5729 |
|
5730 |
procedure TFResSimulP.CBRej1Change(Sender: TObject);
|
5731 |
begin
|
5732 |
case CBRej1.ItemIndex of |
5733 |
0: // R?partition globale |
5734 |
begin
|
5735 |
CBRej2D.Visible := FALSE; |
5736 |
CBRej2P.Visible := FALSE; |
5737 |
end;
|
5738 |
1: // R?partition dynamique |
5739 |
begin
|
5740 |
CBRej2D.Visible := TRUE; |
5741 |
CBRej2P.Visible := FALSE; |
5742 |
end;
|
5743 |
2: // R?partition par p?riode |
5744 |
begin
|
5745 |
CBRej2D.Visible := FALSE; |
5746 |
CBRej2P.Visible := TRUE; |
5747 |
end;
|
5748 |
end;
|
5749 |
CBRej3Change(nil);
|
5750 |
end;
|
5751 |
|
5752 |
procedure TFResSimulP.CBRej2Change(Sender: TObject);
|
5753 |
begin
|
5754 |
AffGraphRej; |
5755 |
end;
|
5756 |
|
5757 |
procedure TFResSimulP.CBRej3Change(Sender: TObject);
|
5758 |
begin
|
5759 |
if CBRej3.ItemIndex > 3 |
5760 |
then // Oligo-?l?ment |
5761 |
PieRej.ValueFormat := Format('# ##0 %s', [StrMg])
|
5762 |
else // Macro-?l?ment |
5763 |
PieRej.ValueFormat := Format('# ##0 %s', [StrG]);
|
5764 |
CBRej4.Items.Clear; |
5765 |
case CBRej1.ItemIndex of |
5766 |
0: // R?partition globale |
5767 |
if CBRej3.ItemIndex > 3 |
5768 |
then // Oligo-?l?ment |
5769 |
begin
|
5770 |
CBRej4.Items.Add(StrMG); |
5771 |
CBRej4.Items.Add('%');
|
5772 |
end
|
5773 |
else // Macro-?l?ment |
5774 |
begin
|
5775 |
CBRej4.Items.Add(StrG); |
5776 |
CBRej4.Items.Add('%');
|
5777 |
end;
|
5778 |
1: // R?partition dynamique |
5779 |
if CBRej3.ItemIndex > 3 |
5780 |
then // Oligo-?l?ment |
5781 |
begin
|
5782 |
CBRej4.Items.Add(Format('%s/%s', [StrMG, StrJ]));
|
5783 |
CBRej4.Items.Add(Format('%s/%s %s', [StrMG, StrKg, StrAlimentUnit]));
|
5784 |
CBRej4.Items.Add('%');
|
5785 |
end
|
5786 |
else // Macro-?l?ment |
5787 |
begin
|
5788 |
CBRej4.Items.Add(Format('%s/%s', [StrG, StrJ]));
|
5789 |
CBRej4.Items.Add(Format('%s/%s %s', [StrG, StrKg, StrAlimentUnit]));
|
5790 |
CBRej4.Items.Add('%');
|
5791 |
end;
|
5792 |
2: // R?partition par p?riode |
5793 |
if CBRej3.ItemIndex > 3 |
5794 |
then // Oligo-?l?ment |
5795 |
begin
|
5796 |
CBRej4.Items.Add(StrMG); |
5797 |
CBRej4.Items.Add(Format('%s/%s', [StrMG, StrJ]));
|
5798 |
CBRej4.Items.Add(Format('%s/%s %s', [StrMG, StrKg, StrAlimentUnit]));
|
5799 |
CBRej4.Items.Add('%');
|
5800 |
end
|
5801 |
else // Macro-?l?ment |
5802 |
begin
|
5803 |
CBRej4.Items.Add(StrG); |
5804 |
CBRej4.Items.Add(Format('%s/%s', [StrG, StrJ]));
|
5805 |
CBRej4.Items.Add(Format('%s/%s %s', [StrG, StrKg, StrAlimentUnit]));
|
5806 |
CBRej4.Items.Add('%');
|
5807 |
end;
|
5808 |
end;
|
5809 |
CBRej4.ItemIndex := 0;
|
5810 |
AffGraphRej; |
5811 |
end;
|
5812 |
|
5813 |
procedure TFResSimulP.CBRej4Change(Sender: TObject);
|
5814 |
begin
|
5815 |
AffGraphRej; |
5816 |
end;
|
5817 |
|
5818 |
procedure TFResSimulP.WMSysCommand(var Mess: TWMSysCommand); |
5819 |
begin
|
5820 |
if Mess.CmdType = SC_MINIMIZE
|
5821 |
then
|
5822 |
Application.Minimize |
5823 |
else
|
5824 |
inherited;
|
5825 |
end;
|
5826 |
|
5827 |
end.
|