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