root / UFCompSimulT.pas @ 5
Historique | Voir | Annoter | Télécharger (92,778 ko)
1 | 3 | avalancogn | unit UFCompSimulT;
|
---|---|---|---|
2 | |||
3 | interface
|
||
4 | |||
5 | uses
|
||
6 | Windows, Forms, Classes, Controls, Messages, Dialogs, StdCtrls, ExtCtrls, |
||
7 | ComCtrls, Menus, Graphics, TeeProcs, TeEngine, Series, Chart; |
||
8 | |||
9 | type
|
||
10 | TFCompSimulT = class(TForm)
|
||
11 | PC: TPageControl; |
||
12 | TabRej: TTabSheet; |
||
13 | CBRej3: TComboBox; |
||
14 | CBRej4: TComboBox; |
||
15 | TabPerf: TTabSheet; |
||
16 | CBPerf4: TComboBox; |
||
17 | CBPerf3: TComboBox; |
||
18 | CBPerf2: TComboBox; |
||
19 | TabAli: TTabSheet; |
||
20 | TabAA: TTabSheet; |
||
21 | CBAli4: TComboBox; |
||
22 | CBAA3: TComboBox; |
||
23 | CBAA4: TComboBox; |
||
24 | CBPerf1: TComboBox; |
||
25 | CBAA1: TComboBox; |
||
26 | CBAA5A: TComboBox; |
||
27 | CBAA2: TComboBox; |
||
28 | GBPerfX: TGroupBox; |
||
29 | GBPerfY: TGroupBox; |
||
30 | GBAAX: TGroupBox; |
||
31 | GBAliY: TGroupBox; |
||
32 | GBAAY: TGroupBox; |
||
33 | GBRejY: TGroupBox; |
||
34 | GBAAT: TGroupBox; |
||
35 | GBRejT: TGroupBox; |
||
36 | GBRejX: TGroupBox; |
||
37 | GBAliX: TGroupBox; |
||
38 | GBAliT: TGroupBox; |
||
39 | GBPerfT: TGroupBox; |
||
40 | Graph: TChart; |
||
41 | LBRej: TListBox; |
||
42 | CBAA5B: TComboBox; |
||
43 | CBPerf3Global: TComboBox; |
||
44 | TabNRJ: TTabSheet; |
||
45 | TabMin: TTabSheet; |
||
46 | GBNRJT: TGroupBox; |
||
47 | GBNRJY: TGroupBox; |
||
48 | CBNRJ3: TComboBox; |
||
49 | CBNRJ4: TComboBox; |
||
50 | GBNRJX: TGroupBox; |
||
51 | CBNRJ2: TComboBox; |
||
52 | LBNRJ: TListBox; |
||
53 | GBMinX: TGroupBox; |
||
54 | GBMinT: TGroupBox; |
||
55 | GBMinY: TGroupBox; |
||
56 | CBMin3: TComboBox; |
||
57 | CBMin4: TComboBox; |
||
58 | CBAli3: TComboBox; |
||
59 | LBMin: TListBox; |
||
60 | CBMin1: TComboBox; |
||
61 | CBMin2: TComboBox; |
||
62 | CBMin5A: TComboBox; |
||
63 | CBMin5B: TComboBox; |
||
64 | LBAA: TListBox; |
||
65 | PM: TPopupMenu; |
||
66 | MI3D: TMenuItem; |
||
67 | MIPreview: TMenuItem; |
||
68 | MIPrint: TMenuItem; |
||
69 | PD: TPrintDialog; |
||
70 | CBAli1: TComboBox; |
||
71 | CBAli5: TComboBox; |
||
72 | procedure FormShow(Sender: TObject);
|
||
73 | procedure FormClose(Sender: TObject; var Action: TCloseAction); |
||
74 | procedure PCChange(Sender: TObject);
|
||
75 | procedure CBRej3Change(Sender: TObject);
|
||
76 | procedure CBRej4Change(Sender: TObject);
|
||
77 | procedure CBPerf2Change(Sender: TObject);
|
||
78 | procedure CBPerf3Change(Sender: TObject);
|
||
79 | procedure CBAli4Change(Sender: TObject);
|
||
80 | procedure CBAA3Change(Sender: TObject);
|
||
81 | procedure CBAA4Change(Sender: TObject);
|
||
82 | procedure CBPerf1Change(Sender: TObject);
|
||
83 | procedure CBPerf4Change(Sender: TObject);
|
||
84 | procedure CBAA1Change(Sender: TObject);
|
||
85 | procedure CBAA5Change(Sender: TObject);
|
||
86 | procedure CBAA2Change(Sender: TObject);
|
||
87 | procedure CBNRJ2Change(Sender: TObject);
|
||
88 | procedure CBNRJ3Change(Sender: TObject);
|
||
89 | procedure CBNRJ4Change(Sender: TObject);
|
||
90 | procedure CBMin3Change(Sender: TObject);
|
||
91 | procedure CBMin4Change(Sender: TObject);
|
||
92 | procedure CBAli3Change(Sender: TObject);
|
||
93 | procedure FormCreate(Sender: TObject);
|
||
94 | procedure CBMin1Change(Sender: TObject);
|
||
95 | procedure CBMin2Change(Sender: TObject);
|
||
96 | procedure CBMin5Change(Sender: TObject);
|
||
97 | procedure MI3DClick(Sender: TObject);
|
||
98 | procedure MIPreviewClick(Sender: TObject);
|
||
99 | procedure MIPrintClick(Sender: TObject);
|
||
100 | procedure CBAli5Change(Sender: TObject);
|
||
101 | procedure CBAli1Change(Sender: TObject);
|
||
102 | procedure WMSysCommand(var Message: TWMSysCommand); message WM_SYSCOMMAND; |
||
103 | private
|
||
104 | { D?clarations priv?es }
|
||
105 | LinePerf : array[1..5] of TLineSeries ; |
||
106 | BarPerf : TBarSeries ; |
||
107 | ListAli, ListMat : TStrings ; |
||
108 | CompositionComplete : boolean ; |
||
109 | BarAli : array of TBarSeries ; |
||
110 | BarMat : TBarSeries ; |
||
111 | LineAA : array[1..5] of TLineSeries ; |
||
112 | ListAA : TStrings ; |
||
113 | BarAA : array of TBarSeries ; |
||
114 | ListNRJ : TStrings ; |
||
115 | BarNRJ : array of TBarSeries ; |
||
116 | ListRej : TStrings ; |
||
117 | BarRej : array of TBarSeries ; |
||
118 | ListMin : TStrings ; |
||
119 | BarMin : array of TBarSeries ; |
||
120 | LineMin : array[1..5] of TLineSeries ; |
||
121 | procedure ResetGraph ;
|
||
122 | procedure InitPerf ;
|
||
123 | procedure AffGraphPerf ;
|
||
124 | procedure InitAli ;
|
||
125 | procedure AffGraphAli ;
|
||
126 | procedure InitAA ;
|
||
127 | procedure AffGraphAA ;
|
||
128 | procedure InitNRJ ;
|
||
129 | procedure AffGraphNRJ ;
|
||
130 | procedure InitRej ;
|
||
131 | procedure AffGraphRej ;
|
||
132 | procedure InitMin ;
|
||
133 | procedure AffGraphMin ;
|
||
134 | public
|
||
135 | { D?clarations publiques }
|
||
136 | end;
|
||
137 | |||
138 | var
|
||
139 | FCompSimulT: TFCompSimulT; |
||
140 | |||
141 | implementation
|
||
142 | |||
143 | uses
|
||
144 | Printers, Math, SysUtils, gnugettext, UVariables, UStrings, UFindRec, UUtil, |
||
145 | UEchelle, UFSimulT, UFPrevGraph; |
||
146 | |||
147 | {$R *.dfm}
|
||
148 | |||
149 | { TFCompSimulT }
|
||
150 | |||
151 | procedure TFCompSimulT.FormCreate(Sender: TObject);
|
||
152 | begin
|
||
153 | if Screen.Fonts.IndexOf('Arial Unicode MS') <> -1 |
||
154 | then
|
||
155 | Font.Name := 'Arial Unicode MS';
|
||
156 | TranslateComponent(Self); |
||
157 | Constraints.MinWidth := 544 + (Width - ClientWidth);
|
||
158 | Width := 640;
|
||
159 | Constraints.MinHeight := 360 + (Height - ClientHeight);
|
||
160 | Height := 480;
|
||
161 | CBPerf1.ItemIndex := 0;
|
||
162 | CBPerf2.ItemIndex := 0;
|
||
163 | CBPerf3.ItemIndex := 0;
|
||
164 | CBPerf3Global.ItemIndex := 0;
|
||
165 | CBPerf4.Items.Add(StrKg); |
||
166 | CBPerf4.ItemIndex := 0;
|
||
167 | CBAli1.ItemIndex := 0;
|
||
168 | CBAli3.ItemIndex := 0;
|
||
169 | CBAli4.Items.Add(StrKg); |
||
170 | CBAli4.Items.Add(Format('%s/%s', [StrKg, StrJ]));
|
||
171 | CBAli4.Items.Add('%');
|
||
172 | CBAli4.ItemIndex := 0;
|
||
173 | CBAli5.ItemIndex := 0;
|
||
174 | CBAA1.ItemIndex := 0;
|
||
175 | CBAA2.ItemIndex := 0;
|
||
176 | CBAA3.ItemIndex := 1;
|
||
177 | CBAA4.Items.Add(StrG); |
||
178 | CBAA4.Items.Add(Format('%s/%s', [StrG, StrJ]));
|
||
179 | CBAA4.Items.Add(Format('%s/%s %s', [StrG, StrKg, StrAlimentUnit]));
|
||
180 | CBAA4.Items.Add('%');
|
||
181 | CBAA4.ItemIndex := 0;
|
||
182 | CBAA5A.ItemIndex := 0;
|
||
183 | CBAA5B.ItemIndex := 0;
|
||
184 | CBNRJ2.ItemIndex := 0;
|
||
185 | CBNRJ3.ItemIndex := 0;
|
||
186 | CBNRJ4.Items.Add(StrMJ); |
||
187 | CBNRJ4.Items.Add(Format('%s/%s', [StrMJ, StrJ]));
|
||
188 | CBNRJ4.Items.Add(Format('%s/%s %s', [StrMJ, StrKg, StrAlimentUnit]));
|
||
189 | CBNRJ4.Items.Add('%');
|
||
190 | CBNRJ4.ItemIndex := 0;
|
||
191 | CBMin1.ItemIndex := 0;
|
||
192 | CBMin2.ItemIndex := 0;
|
||
193 | CBMin3.ItemIndex := 0;
|
||
194 | CBMin4.Items.Add (StrG) ; |
||
195 | CBMin4.Items.Add (Format ('%s/%s', [StrG, StrJ])) ;
|
||
196 | CBMin4.Items.Add (Format ('%s/%s %s', [StrG, StrKg, StrAlimentUnit])) ;
|
||
197 | CBMin4.Items.Add ('%') ;
|
||
198 | CBMin4.ItemIndex := 0;
|
||
199 | CBMin5A.ItemIndex := 0;
|
||
200 | CBMin5B.ItemIndex := 0;
|
||
201 | CBRej3.ItemIndex := 0;
|
||
202 | CBRej4.Items.Add(StrG); |
||
203 | CBRej4.Items.Add(Format('%s/%s', [StrG, StrJ]));
|
||
204 | CBRej4.Items.Add(Format('%s/%s %s', [StrG, StrKg, StrAlimentUnit]));
|
||
205 | CBRej4.Items.Add('%');
|
||
206 | CBRej4.ItemIndex := 0;
|
||
207 | end;
|
||
208 | |||
209 | procedure TFCompSimulT.FormShow (Sender : TObject) ;
|
||
210 | var
|
||
211 | k : integer ; |
||
212 | begin
|
||
213 | MIPrint.Enabled := IsComplete or IsEducation ;
|
||
214 | // Bas de page du graphique
|
||
215 | Graph.Foot.Text.Clear ; |
||
216 | case FSimulT.PC.ActivePageIndex of |
||
217 | 1 : // Comparaison |
||
218 | for k := 5 downto 1 do |
||
219 | if TabSimulT[k].Ok
|
||
220 | then
|
||
221 | Graph.Foot.Text.Add (Format (StrSimulComp, [k, FindNomSimulT (TabSimulT[k].Simul)])) ; |
||
222 | 2 : // Sensibilit? |
||
223 | Graph.Foot.Text.Add (Format (StrSimulSens, [FSimulT.CBVariable.Text, FSimulT.CBSimulSens.Text])) ; |
||
224 | end ;
|
||
225 | // Aliment
|
||
226 | InitAli ; |
||
227 | // Performances
|
||
228 | InitPerf ; |
||
229 | // Acides amin?s
|
||
230 | InitAA ; |
||
231 | // Energie
|
||
232 | InitNRJ ; |
||
233 | // Min?raux
|
||
234 | InitMin ; |
||
235 | // Rejets
|
||
236 | InitRej ; |
||
237 | // Abscisses par d?faut
|
||
238 | CBPerf2.ItemIndex := XTruie ; |
||
239 | CBAA2.ItemIndex := XTruie ; |
||
240 | CBNRJ2.ItemIndex := XTruie ; |
||
241 | // Affichage principal
|
||
242 | PC.ActivePageIndex := 0 ;
|
||
243 | PCChange (nil) ;
|
||
244 | end ;
|
||
245 | |||
246 | procedure TFCompSimulT.FormClose (Sender : TObject ;
|
||
247 | var Action : TCloseAction) ;
|
||
248 | var
|
||
249 | i, k : integer ; |
||
250 | begin
|
||
251 | // Performances
|
||
252 | BarPerf.Free ; |
||
253 | for k := 1 to 5 do |
||
254 | if TabSimulT[k].Ok
|
||
255 | then
|
||
256 | LinePerf[k].Free ; |
||
257 | // Aliment
|
||
258 | BarMat.Free ; |
||
259 | for i := 0 to ListAli.Count - 1 do |
||
260 | BarAli[i].Free ; |
||
261 | SetLength (BarAli, 0) ;
|
||
262 | ListMat.Free ; |
||
263 | ListAli.Free ; |
||
264 | // Acides amin?s
|
||
265 | for k := 1 to 5 do |
||
266 | if TabSimulT[k].Ok
|
||
267 | then
|
||
268 | LineAA[k].Free ; |
||
269 | for i := 0 to ListAA.Count - 1 do |
||
270 | BarAA[i].Free ; |
||
271 | SetLength (BarAA, 0) ;
|
||
272 | ListAA.Free ; |
||
273 | // Energie
|
||
274 | for i := 0 to ListNRJ.Count - 1 do |
||
275 | BarNRJ[i].Free ; |
||
276 | SetLength (BarNRJ, 0) ;
|
||
277 | ListNRJ.Free ; |
||
278 | // Min?raux
|
||
279 | for k := 1 to 5 do |
||
280 | if TabSimulT[k].Ok
|
||
281 | then
|
||
282 | LineMin[k].Free ; |
||
283 | for i := 0 to ListMin.Count - 1 do |
||
284 | BarMin[i].Free ; |
||
285 | SetLength (BarMin, 0) ;
|
||
286 | ListMin.Free ; |
||
287 | // Rejets
|
||
288 | for i := 0 to ListRej.Count - 1 do |
||
289 | BarRej[i].Free ; |
||
290 | SetLength (BarRej, 0) ;
|
||
291 | ListRej.Free ; |
||
292 | end ;
|
||
293 | |||
294 | procedure TFCompSimulT.PCChange (Sender : TObject) ;
|
||
295 | begin
|
||
296 | case PC.ActivePageIndex of |
||
297 | 0 : // Performances |
||
298 | AffGraphPerf ; |
||
299 | 1 : // Aliment |
||
300 | AffGraphAli ; |
||
301 | 2 : // Acides amin?s |
||
302 | AffGraphAA ; |
||
303 | 3 : // Energie |
||
304 | AffGraphNRJ ; |
||
305 | 4: // Min?raux |
||
306 | AffGraphMin ; |
||
307 | 5: // Rejets |
||
308 | AffGraphRej ; |
||
309 | end ;
|
||
310 | end ;
|
||
311 | |||
312 | procedure TFCompSimulT.ResetGraph ;
|
||
313 | var
|
||
314 | i, k : integer ; |
||
315 | begin
|
||
316 | Graph.UndoZoom ; |
||
317 | Graph.Legend.Visible := TRUE ; |
||
318 | Graph.Title.Text.Clear ; |
||
319 | Graph.SubTitle.Text.Clear ; |
||
320 | Graph.BottomAxis.MinimumOffset := 0;
|
||
321 | Graph.BottomAxis.MaximumOffset := 0;
|
||
322 | // Performances
|
||
323 | for k := 1 to 5 do |
||
324 | if TabSimulT[k].Ok
|
||
325 | then
|
||
326 | LinePerf[k].Active := FALSE ; |
||
327 | BarPerf.Active := FALSE ; |
||
328 | // Aliment
|
||
329 | for i := 0 to ListAli.Count - 1 do |
||
330 | BarAli[i].Active := FALSE ; |
||
331 | BarMat.Active := FALSE ; |
||
332 | // Acides amin?s
|
||
333 | for i := 0 to ListAA.Count - 1 do |
||
334 | BarAA[i].Active := FALSE ; |
||
335 | for k := 1 to 5 do |
||
336 | if TabSimulT[k].Ok
|
||
337 | then
|
||
338 | LineAA[k].Active := FALSE ; |
||
339 | // Energie
|
||
340 | for i := 0 to ListNRJ.Count - 1 do |
||
341 | BarNRJ[i].Active := FALSE ; |
||
342 | // Min?raux
|
||
343 | for i := 0 to ListMin.Count - 1 do |
||
344 | BarMin[i].Active := FALSE ; |
||
345 | for k := 1 to 5 do |
||
346 | if TabSimulT[k].Ok
|
||
347 | then
|
||
348 | LineMin[k].Active := FALSE ; |
||
349 | // Rejets
|
||
350 | for i := 0 to ListRej.Count - 1 do |
||
351 | BarRej[i].Active := FALSE ; |
||
352 | end ;
|
||
353 | |||
354 | procedure TFCompSimulT.MI3DClick(Sender: TObject);
|
||
355 | begin
|
||
356 | Graph.View3D := not (Graph.View3D) ;
|
||
357 | end;
|
||
358 | |||
359 | procedure TFCompSimulT.MIPreviewClick(Sender: TObject);
|
||
360 | begin
|
||
361 | FPrevGraph := TFPrevGraph.Create (Self) ; |
||
362 | with FPrevGraph do |
||
363 | begin
|
||
364 | TPPGraph.Panels.Add (Graph) ; |
||
365 | ShowModal ; |
||
366 | Release ; |
||
367 | end ;
|
||
368 | end;
|
||
369 | |||
370 | procedure TFCompSimulT.MIPrintClick(Sender: TObject);
|
||
371 | begin
|
||
372 | if PD.Execute
|
||
373 | then
|
||
374 | begin
|
||
375 | Printer.Orientation := poLandscape ; |
||
376 | Graph.Print ; |
||
377 | end ;
|
||
378 | end;
|
||
379 | |||
380 | //////////////////////
|
||
381 | // Performances //
|
||
382 | //////////////////////
|
||
383 | procedure TFCompSimulT.InitPerf ;
|
||
384 | const
|
||
385 | TabColor : array[1..5] of TColor |
||
386 | = (clRed, clGreen, clYellow, clBlue, clFuchsia) ; |
||
387 | var
|
||
388 | k : integer ; |
||
389 | begin
|
||
390 | // LinePerf : s?ries (lignes) graphiques
|
||
391 | for k := 1 to 5 do |
||
392 | if TabSimulT[k].Ok
|
||
393 | then
|
||
394 | begin
|
||
395 | LinePerf[k] := TLineSeries.Create (Graph) ; |
||
396 | LinePerf[k].ParentChart := Graph ; |
||
397 | case FSimulT.PC.ActivePageIndex of |
||
398 | 1 : // Comparaison |
||
399 | LinePerf[k].Title := Format ('Simulation %d', [k]) ;
|
||
400 | 2 : // Sensibilit? |
||
401 | LinePerf[k].Title := Format ('%1.0f %%', [TabSimulT[k].Variation * 100]) ; |
||
402 | end ;
|
||
403 | LinePerf[k].SeriesColor := TabColor[k] ; |
||
404 | LinePerf[k].LinePen.Color := LinePerf[k].SeriesColor ; |
||
405 | LinePerf[k].LinePen.Width := 2 ;
|
||
406 | Graph.AddSeries (LinePerf[k]) ; |
||
407 | end ;
|
||
408 | // BarPerf : s?rie (barre) graphique
|
||
409 | BarPerf := TBarSeries.Create (Graph) ; |
||
410 | BarPerf.ParentChart := Graph ; |
||
411 | // BarPerf.Title := ' ' ;
|
||
412 | BarPerf.SeriesColor := clTeal ; |
||
413 | BarPerf.BarPen.Color := BarPerf.SeriesColor ; |
||
414 | BarPerf.Marks.Style := smsValue ; |
||
415 | BarPerf.Marks.ArrowLength := 0 ;
|
||
416 | BarPerf.Marks.Arrow.Visible := FALSE ; |
||
417 | BarPerf.Marks.Brush.Style := bsClear ; |
||
418 | BarPerf.Marks.Frame.Visible := FALSE ; |
||
419 | BarPerf.Marks.Font.Style := [fsBold] ; |
||
420 | Graph.AddSeries (BarPerf) ; |
||
421 | end ;
|
||
422 | |||
423 | procedure TFCompSimulT.AffGraphPerf ;
|
||
424 | var
|
||
425 | j, k : integer ; |
||
426 | |||
427 | // Abscisse
|
||
428 | function PerfX : double ;
|
||
429 | begin
|
||
430 | case CBPerf1.ItemIndex of |
||
431 | 0 : // Affichage dynamique |
||
432 | case CBPerf2.ItemIndex of |
||
433 | 0 : // Age |
||
434 | result := PResSimulT.TabResult[1, j] ;
|
||
435 | 1 : // Dur?e |
||
436 | result := j - 1 ;
|
||
437 | else
|
||
438 | result := 0 ;
|
||
439 | end ;
|
||
440 | else
|
||
441 | result := 0 ;
|
||
442 | end ;
|
||
443 | end ;
|
||
444 | |||
445 | // Ordonn?e
|
||
446 | function PerfY : double ;
|
||
447 | var
|
||
448 | h : integer ; |
||
449 | v, d, conso, gain : double ; |
||
450 | begin
|
||
451 | case CBPerf1.ItemIndex of |
||
452 | 0 : // Affichage dynamique |
||
453 | case CBPerf3.ItemIndex of |
||
454 | 0 : // Poids vif total |
||
455 | result := PResSimulT.TabResult[58, j] ;
|
||
456 | 1 : // Gain de poids total |
||
457 | result := PResSimulT.TabResult[59, j] * 1000 ; |
||
458 | 2 : // Poids vif net |
||
459 | result := PResSimulT.TabResult[60, j] ;
|
||
460 | 3 : // Gain de poids net |
||
461 | result := PResSimulT.TabResult[61, j] * 1000 ; |
||
462 | 4 : // Aliment consomm? |
||
463 | case CBPerf4.ItemIndex of |
||
464 | 0 : // Aliment |
||
465 | result := PResSimulT.TabResult[11, j] ;
|
||
466 | 1 : // MS |
||
467 | result := PResSimulT.TabResult[12, j] ;
|
||
468 | 2 : // ED |
||
469 | result := PResSimulT.TabResult[71, j] ;
|
||
470 | 3 : // EM |
||
471 | result := PResSimulT.TabResult[72, j] ;
|
||
472 | 4 : // EN |
||
473 | result := PResSimulT.TabResult[73, j] ;
|
||
474 | else
|
||
475 | result := 0 ;
|
||
476 | end ;
|
||
477 | 5 : // Indice de consommation |
||
478 | if PResSimulT.TabResult[59, j] <> 0 |
||
479 | then
|
||
480 | case CBPerf4.ItemIndex of |
||
481 | 0 : // Aliment |
||
482 | result := PResSimulT.TabResult[11, j] / PResSimulT.TabResult[59, j] ; |
||
483 | 1 : // MS |
||
484 | result := PResSimulT.TabResult[12, j] / PResSimulT.TabResult[59, j] ; |
||
485 | 2 : // ED |
||
486 | result := PResSimulT.TabResult[71, j] / PResSimulT.TabResult[59, j] ; |
||
487 | 3 : // EM |
||
488 | result := PResSimulT.TabResult[72, j] / PResSimulT.TabResult[59, j] ; |
||
489 | 4 : // EN |
||
490 | result := PResSimulT.TabResult[73, j] / PResSimulT.TabResult[59, j] ; |
||
491 | else
|
||
492 | result := 0 ;
|
||
493 | end
|
||
494 | else
|
||
495 | result := 0 ;
|
||
496 | 6 : // Efficacit? alimentaire |
||
497 | case CBPerf4.ItemIndex of |
||
498 | 0 : // Aliment |
||
499 | if PResSimulT.TabResult[11, j] <> 0 |
||
500 | then
|
||
501 | result := PResSimulT.TabResult[59, j] / PResSimulT.TabResult[11, j] |
||
502 | else
|
||
503 | result := 0 ;
|
||
504 | 1 : // MS |
||
505 | if PResSimulT.TabResult[12, j] <> 0 |
||
506 | then
|
||
507 | result := PResSimulT.TabResult[59, j] / PResSimulT.TabResult[12, j] |
||
508 | else
|
||
509 | result := 0 ;
|
||
510 | 2 : // ED |
||
511 | if PResSimulT.TabResult[71, j] <> 0 |
||
512 | then
|
||
513 | result := PResSimulT.TabResult[59, j] / PResSimulT.TabResult[71, j] |
||
514 | else
|
||
515 | result := 0 ;
|
||
516 | 3 : // EM |
||
517 | if PResSimulT.TabResult[72, j] <> 0 |
||
518 | then
|
||
519 | result := PResSimulT.TabResult[59, j] / PResSimulT.TabResult[72, j] |
||
520 | else
|
||
521 | result := 0 ;
|
||
522 | 4 : // EN |
||
523 | if PResSimulT.TabResult[73, j] <> 0 |
||
524 | then
|
||
525 | result := PResSimulT.TabResult[59, j] / PResSimulT.TabResult[73, j] |
||
526 | else
|
||
527 | result := 0 ;
|
||
528 | else
|
||
529 | result := 0 ;
|
||
530 | end ;
|
||
531 | 7 : // Poids de prot?ines |
||
532 | result := PResSimulT.TabResult[62, j] ;
|
||
533 | 8 : // D?p?t de prot?ines |
||
534 | result := PResSimulT.TabResult[63, j] ;
|
||
535 | 9 : // Poids de lipides |
||
536 | result := PResSimulT.TabResult[65, j] ;
|
||
537 | 10 : // D?p?t de lipides |
||
538 | result := PResSimulT.TabResult[66, j] ;
|
||
539 | 11 : // Epaisseur de lard |
||
540 | result := PResSimulT.TabResult[67, j] ;
|
||
541 | 12 : // Variation de P2 |
||
542 | result := PResSimulT.TabResult[68, j] ;
|
||
543 | 13 : // Production laiti?re |
||
544 | result := PResSimulT.TabResult[69, j] ;
|
||
545 | else
|
||
546 | result := 0 ;
|
||
547 | end ;
|
||
548 | 1 : // Affichage global |
||
549 | begin
|
||
550 | // Diviseur
|
||
551 | if (CBPerf3Global.ItemIndex in [0, 1, 6, 7]) and (CBPerf4.ItemIndex = 1) |
||
552 | then // Dur?e et conversion kg -> g |
||
553 | d := PresSimulT.NbJSim / 1000
|
||
554 | else
|
||
555 | if (CBPerf3Global.ItemIndex in [3, 8, 9]) and (CBPerf4.ItemIndex mod 2 = 1) |
||
556 | then // Dur?e |
||
557 | d := PresSimulT.NbJSim |
||
558 | else
|
||
559 | d := 1 ;
|
||
560 | v := 0 ;
|
||
561 | case CBPerf3Global.ItemIndex of |
||
562 | 0 : // Gain de poids total |
||
563 | for h := 1 to PresSimulT.NbJSim do |
||
564 | v := v + PResSimulT.TabResult[59, h] ;
|
||
565 | 1 : // Gain de poids net |
||
566 | for h := 1 to PresSimulT.NbJSim do |
||
567 | v := v + PResSimulT.TabResult[61, h] ;
|
||
568 | 2 : // Dur?e |
||
569 | v := PresSimulT.NbJSim ; |
||
570 | 3 : // Aliment consomm? |
||
571 | for h := 1 to PresSimulT.NbJSim do |
||
572 | case CBPerf4.ItemIndex of |
||
573 | 0, 1 : // Aliment |
||
574 | v := v + PResSimulT.TabResult[11, h] ;
|
||
575 | 2, 3 : // MS |
||
576 | v := v + PResSimulT.TabResult[12, h] ;
|
||
577 | 4, 5 : // ED |
||
578 | v := v + PResSimulT.TabResult[71, h] ;
|
||
579 | 6, 7 : // EM |
||
580 | v := v + PResSimulT.TabResult[72, h] ;
|
||
581 | 8, 9 : // EN |
||
582 | v := v + PResSimulT.TabResult[73, h] ;
|
||
583 | end ;
|
||
584 | 4 : // Indice de consommation |
||
585 | begin
|
||
586 | conso := 0 ;
|
||
587 | for h := 1 to PresSimulT.NbJSim do |
||
588 | case CBPerf4.ItemIndex of |
||
589 | 0 : // Aliment |
||
590 | conso := conso + PResSimulT.TabResult[11, h] ;
|
||
591 | 1 : // MS |
||
592 | conso := conso + PResSimulT.TabResult[12, h] ;
|
||
593 | 2 : // ED |
||
594 | conso := conso + PResSimulT.TabResult[71, h] ;
|
||
595 | 3 : // EM |
||
596 | conso := conso + PResSimulT.TabResult[72, h] ;
|
||
597 | 4 : // EN |
||
598 | conso := conso + PResSimulT.TabResult[73, h] ;
|
||
599 | end ;
|
||
600 | gain := 0 ;
|
||
601 | for h := 1 to PresSimulT.NbJSim do |
||
602 | gain := gain + PResSimulT.TabResult[59, h] ;
|
||
603 | if gain <> 0 |
||
604 | then
|
||
605 | v := conso / gain ; |
||
606 | end ;
|
||
607 | 5 : // Efficacit? alimentaire |
||
608 | begin
|
||
609 | gain := 0 ;
|
||
610 | for h := 1 to PresSimulT.NbJSim do |
||
611 | gain := gain + PResSimulT.TabResult[59, h] ;
|
||
612 | conso := 0 ;
|
||
613 | for h := 1 to PresSimulT.NbJSim do |
||
614 | case CBPerf4.ItemIndex of |
||
615 | 0 : // Aliment |
||
616 | conso := conso + PResSimulT.TabResult[11, h] ;
|
||
617 | 1 : // MS |
||
618 | conso := conso + PResSimulT.TabResult[12, h] ;
|
||
619 | 2 : // ED |
||
620 | conso := conso + PResSimulT.TabResult[71, h] ;
|
||
621 | 3 : // EM |
||
622 | conso := conso + PResSimulT.TabResult[72, h] ;
|
||
623 | 4 : // EN |
||
624 | conso := conso + PResSimulT.TabResult[73, h] ;
|
||
625 | end ;
|
||
626 | if conso <> 0 |
||
627 | then
|
||
628 | v := gain / conso ; |
||
629 | end ;
|
||
630 | 6 : // D?p?t de prot?ines |
||
631 | for h := 1 to PresSimulT.NbJSim do |
||
632 | v := v + PResSimulT.TabResult[63, h] / 1000 ; |
||
633 | 7 : // D?p?t de lipides |
||
634 | for h := 1 to PresSimulT.NbJSim do |
||
635 | v := v + PResSimulT.TabResult[66, h] / 1000 ; |
||
636 | 8 : // Variation de P2 |
||
637 | for h := 1 to PresSimulT.NbJSim do |
||
638 | v := v + PResSimulT.TabResult[68, h] ;
|
||
639 | 9 : // Production laiti?re |
||
640 | for h := 1 to PresSimulT.NbJSim do |
||
641 | v := v + PResSimulT.TabResult[69, h] ;
|
||
642 | end ;
|
||
643 | result := v / d ; |
||
644 | end ;
|
||
645 | else
|
||
646 | result := 0 ;
|
||
647 | end ;
|
||
648 | end ;
|
||
649 | |||
650 | // AffGraphPerf
|
||
651 | begin
|
||
652 | ResetGraph ; |
||
653 | Graph.Legend.Inverted := FALSE ; |
||
654 | Graph.Title.Text.Add (Format ('%s : %s', [TabPerf.Caption, CBPerf1.Text])) ;
|
||
655 | case CBPerf1.ItemIndex of |
||
656 | 0 : // Affichage dynamique |
||
657 | begin
|
||
658 | Graph.LeftAxis.Title.Caption := Format ('%s (%s)', [CBPerf3.Text, CBPerf4.Text]) ;
|
||
659 | Graph.BottomAxis.Title.Caption := CBPerf2.Text ; |
||
660 | // Affichage des lignes
|
||
661 | for k := 1 to 5 do |
||
662 | if TabSimulT[k].Ok
|
||
663 | then
|
||
664 | begin
|
||
665 | LinePerf[k].Active := TRUE ; |
||
666 | LinePerf[k].Clear ; |
||
667 | PResSimulT := TabSimulT[k].Result ; |
||
668 | for j := 1 to PResSimulT.NbJSim do |
||
669 | LinePerf[k].AddXY (PerfX, PerfY, '', clTeeColor) ;
|
||
670 | end ;
|
||
671 | end ;
|
||
672 | 1 : // Affichage global |
||
673 | begin
|
||
674 | Graph.LeftAxis.Title.Caption := Format ('%s (%s)', [CBPerf3Global.Text, CBPerf4.Text]) ;
|
||
675 | Graph.Legend.Visible := FALSE ; |
||
676 | case FSimulT.PC.ActivePageIndex of |
||
677 | 1 : // Comparaison |
||
678 | Graph.BottomAxis.Title.Caption := 'Simulation' ;
|
||
679 | 2 : // Sensibilit? |
||
680 | Graph.BottomAxis.Title.Caption := 'Variation' ;
|
||
681 | end ;
|
||
682 | // Affichage de la barre
|
||
683 | BarPerf.Active := TRUE ; |
||
684 | BarPerf.Clear ; |
||
685 | for k := 1 to 5 do |
||
686 | if TabSimulT[k].Ok
|
||
687 | then
|
||
688 | begin
|
||
689 | PResSimulT := TabSimulT[k].Result ; |
||
690 | case FSimulT.PC.ActivePageIndex of |
||
691 | 1 : // Comparaison |
||
692 | BarPerf.AddBar (PerfY, Format ('%d', [k]), clTeeColor) ;
|
||
693 | 2 : // Sensibilit? |
||
694 | BarPerf.AddBar (PerfY, Format ('%1.0f %%', [TabSimulT[k].Variation * 100]), clTeeColor) ; |
||
695 | end ;
|
||
696 | end ;
|
||
697 | end ;
|
||
698 | end ;
|
||
699 | AjustEchelle (Graph) ; |
||
700 | with BarPerf do |
||
701 | ValueFormat := AjustFormat (AjustPas (MaxYValue - MinYValue) / 10) ;
|
||
702 | end ;
|
||
703 | |||
704 | procedure TFCompSimulT.CBPerf1Change (Sender : TObject) ;
|
||
705 | begin
|
||
706 | case CBPerf1.ItemIndex of |
||
707 | 0 : // Affichage dynamique |
||
708 | begin
|
||
709 | CBPerf2.Visible := TRUE ; |
||
710 | CBPerf3.Visible := TRUE ; |
||
711 | CBPerf3Global.Visible := FALSE ; |
||
712 | // CBPerf4.Visible := FALSE ;
|
||
713 | end ;
|
||
714 | 1 : // Affichage global |
||
715 | begin
|
||
716 | CBPerf2.Visible := FALSE ; |
||
717 | CBPerf3.Visible := FALSE ; |
||
718 | CBPerf3Global.Visible := TRUE ; |
||
719 | // CBPerf4.Visible := TRUE ;
|
||
720 | end ;
|
||
721 | end ;
|
||
722 | CBPerf3Change (nil) ;
|
||
723 | end ;
|
||
724 | |||
725 | procedure TFCompSimulT.CBPerf2Change (Sender : TObject) ;
|
||
726 | begin
|
||
727 | AffGraphPerf ; |
||
728 | end ;
|
||
729 | |||
730 | procedure TFCompSimulT.CBPerf3Change (Sender : TObject) ;
|
||
731 | begin
|
||
732 | CBPerf4.Items.Clear ; |
||
733 | case CBPerf1.ItemIndex of |
||
734 | 0 : // Affichage dynamique |
||
735 | case CBPerf3.ItemIndex of |
||
736 | 0, 2 : // Poids vif (total ou net) |
||
737 | CBPerf4.Items.Add (StrKg) ; |
||
738 | 1, 3 : // Gain de poids (total ou net) |
||
739 | CBPerf4.Items.Add (Format ('%s/%s', [StrG, StrJ])) ;
|
||
740 | 4 : // Aliment consomm? |
||
741 | begin
|
||
742 | CBPerf4.Items.Add (Format ('%s %s/%s', [StrKg, StrAlimentUnit, StrJ])) ;
|
||
743 | CBPerf4.Items.Add (Format ('%s %s/%s', [StrKg, StrMS, StrJ])) ;
|
||
744 | CBPerf4.Items.Add (Format ('%s %s/%s', [StrMJ, StrED, StrJ])) ;
|
||
745 | CBPerf4.Items.Add (Format ('%s %s/%s', [StrMJ, StrEM, StrJ])) ;
|
||
746 | CBPerf4.Items.Add (Format ('%s %s/%s', [StrMJ, StrEN, StrJ])) ;
|
||
747 | end ;
|
||
748 | 5 : // Indice de consommation |
||
749 | begin
|
||
750 | CBPerf4.Items.Add (Format ('%s %s/%s %s', [StrKg, StrAlimentUnit, StrKg, StrGMQUnit])) ;
|
||
751 | CBPerf4.Items.Add (Format ('%s %s/%s %s', [StrKg, StrMS, StrKg, StrGMQUnit])) ;
|
||
752 | CBPerf4.Items.Add (Format ('%s %s/%s %s', [StrMJ, StrED, StrKg, StrGMQUnit])) ;
|
||
753 | CBPerf4.Items.Add (Format ('%s %s/%s %s', [StrMJ, StrEM, StrKg, StrGMQUnit])) ;
|
||
754 | CBPerf4.Items.Add (Format ('%s %s/%s %s', [StrMJ, StrEN, StrKg, StrGMQUnit])) ;
|
||
755 | end ;
|
||
756 | 6 : // Efficacit? alimentaire |
||
757 | begin
|
||
758 | CBPerf4.Items.Add (Format ('%s %s/%s %s', [StrKg, StrGMQUnit, StrKg, StrAlimentUnit])) ;
|
||
759 | CBPerf4.Items.Add (Format ('%s %s/%s %s', [StrKg, StrGMQUnit, StrKg, StrMS])) ;
|
||
760 | CBPerf4.Items.Add (Format ('%s %s/%s %s', [StrKg, StrGMQUnit, StrMJ, StrED])) ;
|
||
761 | CBPerf4.Items.Add (Format ('%s %s/%s %s', [StrKg, StrGMQUnit, StrMJ, StrEM])) ;
|
||
762 | CBPerf4.Items.Add (Format ('%s %s/%s %s', [StrKg, StrGMQUnit, StrMJ, StrEN])) ;
|
||
763 | end ;
|
||
764 | 7, 9 : // Poids de prot?ines ou de lipides |
||
765 | CBPerf4.Items.Add (StrKg) ; |
||
766 | 8, 10 : // D?p?t de prot?ines ou de lipides |
||
767 | CBPerf4.Items.Add (Format ('%s/%s', [StrG, StrJ])) ;
|
||
768 | 11 : // Epaisseur de lard |
||
769 | CBPerf4.Items.Add (StrMm) ; |
||
770 | 12 : // Variation de P2 |
||
771 | CBPerf4.Items.Add (Format ('%s/%s', [StrMm, StrJ])) ;
|
||
772 | 13 : // Production laiti?re |
||
773 | CBPerf4.Items.Add (Format ('%s/%s', [StrKg, StrJ])) ;
|
||
774 | end ;
|
||
775 | 1 : // Affichage global |
||
776 | case CBPerf3Global.ItemIndex of |
||
777 | 0, 1 : // Gain de poids (total ou net) |
||
778 | begin
|
||
779 | CBPerf4.Items.Add (StrKg) ; |
||
780 | CBPerf4.Items.Add (Format ('%s/%s', [StrG, StrJ])) ;
|
||
781 | end ;
|
||
782 | 2 : // Dur?e |
||
783 | CBPerf4.Items.Add (StrJ) ; |
||
784 | 3 : // Aliment consomm? |
||
785 | begin
|
||
786 | CBPerf4.Items.Add (Format ('%s %s', [StrKg, StrAlimentUnit])) ;
|
||
787 | CBPerf4.Items.Add (Format ('%s %s/%s', [StrKg, StrAlimentUnit, StrJ])) ;
|
||
788 | CBPerf4.Items.Add (Format ('%s %s', [StrKg, StrMS])) ;
|
||
789 | CBPerf4.Items.Add (Format ('%s %s/%s', [StrKg, StrMS, StrJ])) ;
|
||
790 | CBPerf4.Items.Add (Format ('%s %s', [StrMJ, StrED])) ;
|
||
791 | CBPerf4.Items.Add (Format ('%s %s/%s', [StrMJ, StrED, StrJ])) ;
|
||
792 | CBPerf4.Items.Add (Format ('%s %s', [StrMJ, StrEM])) ;
|
||
793 | CBPerf4.Items.Add (Format ('%s %s/%s', [StrMJ, StrEM, StrJ])) ;
|
||
794 | CBPerf4.Items.Add (Format ('%s %s', [StrMJ, StrEN])) ;
|
||
795 | CBPerf4.Items.Add (Format ('%s %s/%s', [StrMJ, StrEN, StrJ])) ;
|
||
796 | end ;
|
||
797 | 4 : // Indice de consommation |
||
798 | begin
|
||
799 | CBPerf4.Items.Add (Format ('%s %s/%s %s', [StrKg, StrAlimentUnit, StrKg, StrGMQUnit])) ;
|
||
800 | CBPerf4.Items.Add (Format ('%s %s/%s %s', [StrKg, StrMS, StrKg, StrGMQUnit])) ;
|
||
801 | CBPerf4.Items.Add (Format ('%s %s/%s %s', [StrMJ, StrED, StrKg, StrGMQUnit])) ;
|
||
802 | CBPerf4.Items.Add (Format ('%s %s/%s %s', [StrMJ, StrEM, StrKg, StrGMQUnit])) ;
|
||
803 | CBPerf4.Items.Add (Format ('%s %s/%s %s', [StrMJ, StrEN, StrKg, StrGMQUnit])) ;
|
||
804 | end ;
|
||
805 | 5 : // Efficacit? alimentaire |
||
806 | begin
|
||
807 | CBPerf4.Items.Add (Format ('%s %s/%s %s', [StrKg, StrGMQUnit, StrKg, StrAlimentUnit])) ;
|
||
808 | CBPerf4.Items.Add (Format ('%s %s/%s %s', [StrKg, StrGMQUnit, StrKg, StrMS])) ;
|
||
809 | CBPerf4.Items.Add (Format ('%s %s/%s %s', [StrKg, StrGMQUnit, StrMJ, StrED])) ;
|
||
810 | CBPerf4.Items.Add (Format ('%s %s/%s %s', [StrKg, StrGMQUnit, StrMJ, StrEM])) ;
|
||
811 | CBPerf4.Items.Add (Format ('%s %s/%s %s', [StrKg, StrGMQUnit, StrMJ, StrEN])) ;
|
||
812 | end ;
|
||
813 | 6, 7 : // D?p?t de prot?ines ou de lipides |
||
814 | begin
|
||
815 | CBPerf4.Items.Add (StrKg) ; |
||
816 | CBPerf4.Items.Add (Format ('%s/%s', [StrG, StrJ])) ;
|
||
817 | end ;
|
||
818 | 8 : // Variation de P2 |
||
819 | begin
|
||
820 | CBPerf4.Items.Add (StrMm) ; |
||
821 | CBPerf4.Items.Add (Format ('%s/%s', [StrMm, StrJ])) ;
|
||
822 | end ;
|
||
823 | 9 : // Production laiti?re |
||
824 | begin
|
||
825 | CBPerf4.Items.Add (StrKg) ; |
||
826 | CBPerf4.Items.Add (Format ('%s/%s', [StrKg, StrJ])) ;
|
||
827 | end ;
|
||
828 | end ;
|
||
829 | end ;
|
||
830 | CBPerf4.ItemIndex := 0 ;
|
||
831 | AffGraphPerf ; |
||
832 | end ;
|
||
833 | |||
834 | procedure TFCompSimulT.CBPerf4Change (Sender : TObject) ;
|
||
835 | begin
|
||
836 | AffGraphPerf ; |
||
837 | end ;
|
||
838 | |||
839 | /////////////////
|
||
840 | // Aliment //
|
||
841 | /////////////////
|
||
842 | procedure TFCompSimulT.InitAli ;
|
||
843 | var
|
||
844 | i, j, k : integer ; |
||
845 | nom : string ;
|
||
846 | begin
|
||
847 | // ListAli : liste des aliments utilis?s
|
||
848 | ListAli := TStringList.Create ; |
||
849 | for k := 1 to 5 do // 5 simulations |
||
850 | if TabSimulT[k].Ok
|
||
851 | then
|
||
852 | for i := 1 to 2 do // 2 aliments |
||
853 | for j := 1 to TabSimulT[k].Result.NbJSim do |
||
854 | if TabSimulT[k].Result.TabResult[8 + i, j] > 0 |
||
855 | then
|
||
856 | begin
|
||
857 | nom := FindNomAliment (Trunc (TabSimulT[k].Result.TabResult[6 + i, j])) ;
|
||
858 | if ListAli.IndexOf (nom) = -1 |
||
859 | then
|
||
860 | ListAli.Add (nom) ; |
||
861 | end ;
|
||
862 | // BarAli : s?ries (barres) graphiques
|
||
863 | SetLength (BarAli, ListAli.Count) ; |
||
864 | for i := 0 to ListAli.Count - 1 do |
||
865 | begin
|
||
866 | BarAli[i] := TBarSeries.Create (Graph) ; |
||
867 | BarAli[i].ParentChart := Graph ; |
||
868 | BarAli[i].Title := ListAli[i] ; |
||
869 | BarAli[i].BarPen.Color := BarAli[i].SeriesColor ; |
||
870 | BarAli[i].Marks.Visible := FALSE ; |
||
871 | Graph.AddSeries (BarAli[i]) ; |
||
872 | end ;
|
||
873 | // ListMat : liste des mati?res premi?res utilis?es
|
||
874 | CompositionComplete := TRUE ; |
||
875 | ListMat := TStringList.Create ; |
||
876 | for i := 0 to ListAli.Count - 1 do |
||
877 | begin
|
||
878 | PAliment := ListAliment[FindIdxAliment (ListAli[i])] ; |
||
879 | if PAliment.MP.NbMat > 0 |
||
880 | then
|
||
881 | for j := 0 to PAliment.MP.NbMat - 1 do |
||
882 | begin
|
||
883 | nom := FindNomMatiere (PAliment.MP.NumMat[j]) ; |
||
884 | if ListMat.IndexOf (nom) = -1 |
||
885 | then
|
||
886 | ListMat.Add (nom) ; |
||
887 | end
|
||
888 | else
|
||
889 | CompositionComplete := FALSE ; |
||
890 | end ;
|
||
891 | CBAli1.Visible := ConfAffMP and CompositionComplete ;
|
||
892 | CBAli5.Items.Assign(ListMat); |
||
893 | CBAli5.ItemIndex := 0 ;
|
||
894 | // BarMat : s?rie (barre) graphique
|
||
895 | BarMat := TBarSeries.Create (Graph) ; |
||
896 | BarMat.ParentChart := Graph ; |
||
897 | BarMat.SeriesColor := clTeal ; |
||
898 | BarMat.BarPen.Color := BarMat.SeriesColor ; |
||
899 | BarMat.Marks.ArrowLength := 0 ;
|
||
900 | BarMat.Marks.Arrow.Visible := FALSE ; |
||
901 | BarMat.Marks.Brush.Style := bsClear ; |
||
902 | BarMat.Marks.Frame.Visible := FALSE ; |
||
903 | BarMat.Marks.Font.Style := [fsBold] ; |
||
904 | BarMat.Marks.Style := smsValue ; |
||
905 | Graph.AddSeries (BarMat) ; |
||
906 | end ;
|
||
907 | |||
908 | procedure TFCompSimulT.AffGraphAli ;
|
||
909 | var
|
||
910 | i, k : integer ; |
||
911 | y : double ; |
||
912 | s : string ;
|
||
913 | |||
914 | // Ordonn?e (Aliments)
|
||
915 | function AliY : double ;
|
||
916 | var
|
||
917 | h : integer ; |
||
918 | v, d : double ; |
||
919 | begin
|
||
920 | // Diviseur
|
||
921 | case CBAli3.ItemIndex of |
||
922 | 0 : // Quantit? |
||
923 | case CBAli4.ItemIndex of |
||
924 | 1 : // Dur?e |
||
925 | d := PresSimulT.NbJSim ; |
||
926 | else
|
||
927 | d := 1 ;
|
||
928 | end ;
|
||
929 | 1 : // Co?t |
||
930 | case CBAli4.ItemIndex of |
||
931 | 1 : // Dur?e |
||
932 | d := PresSimulT.NbJSim ; |
||
933 | 2 : // Aliment ing?r? |
||
934 | begin
|
||
935 | d := 0 ;
|
||
936 | for h := 1 to PresSimulT.NbJSim do |
||
937 | d := d + PresSimulT.TabResult[11, h] ;
|
||
938 | end ;
|
||
939 | else
|
||
940 | d := 1 ;
|
||
941 | end ;
|
||
942 | else
|
||
943 | d := 1 ;
|
||
944 | end ;
|
||
945 | v := 0 ;
|
||
946 | for h := 1 to PresSimulT.NbJSim do |
||
947 | begin
|
||
948 | // Aliment 1
|
||
949 | if (PResSimulT.TabResult[7, h] <> -1) and (FindNomAliment (Trunc (PresSimulT.TabResult[7, h])) = ListAli[i]) |
||
950 | then
|
||
951 | v := v + (PresSimulT.TabResult[11, h] * PresSimulT.TabResult[9, h] / 100) ; |
||
952 | // Aliment 2
|
||
953 | if (PResSimulT.TabResult[8, h] <> -1) and (FindNomAliment (Trunc (PresSimulT.TabResult[8, h])) = ListAli[i]) |
||
954 | then
|
||
955 | v := v + (PresSimulT.TabResult[11, h] * PresSimulT.TabResult[10, h] / 100) ; |
||
956 | end ;
|
||
957 | if CBAli3.ItemIndex = 1 |
||
958 | then // Co?t |
||
959 | begin
|
||
960 | PAliment := ListAliment[FindIdxAliment (ListAli[i])] ; |
||
961 | v := v * PAliment.Prix / 1000 ;
|
||
962 | end ;
|
||
963 | result := v / d ; |
||
964 | end ;
|
||
965 | |||
966 | // Ordonn?es (Mati?res premi?res)
|
||
967 | function MatY : double ;
|
||
968 | var
|
||
969 | g, h : integer ; |
||
970 | v, d : double ; |
||
971 | begin
|
||
972 | // Diviseur
|
||
973 | if CBAli4.ItemIndex = 1 |
||
974 | then // Dur?e |
||
975 | d := PresSimulT.NbJSim |
||
976 | else
|
||
977 | d := 1 ;
|
||
978 | v := 0 ;
|
||
979 | for h := 1 to PResSimulT.NbJSim do |
||
980 | begin
|
||
981 | if PResSimulT.TabResult[7, h] <> -1 |
||
982 | then // Aliment 1 |
||
983 | begin
|
||
984 | PAliment := ListAliment[FindIdxAliment (FindNomAliment (Trunc (PResSimulT.TabResult[7, h])))] ;
|
||
985 | for g := 0 to PAliment.MP.NbMat - 1 do |
||
986 | if FindNomMatiere (PAliment.MP.NumMat[g]) = CBAli5.Text
|
||
987 | then
|
||
988 | v := v + (PAliment.MP.Qte[g] * PResSimulT.TabResult[11, h] * PResSimulT.TabResult[9, h] / 100) ; |
||
989 | end ;
|
||
990 | if PResSimulT.TabResult[8, h] <> -1 |
||
991 | then // Aliment 2 |
||
992 | begin
|
||
993 | PAliment := ListAliment[FindIdxAliment (FindNomAliment (Trunc (PResSimulT.TabResult[8, h])))] ;
|
||
994 | for g := 0 to PAliment.MP.NbMat - 1 do |
||
995 | if FindNomMatiere (PAliment.MP.NumMat[g]) = CBAli5.Text
|
||
996 | then
|
||
997 | v := v + (PAliment.MP.Qte[g] * PResSimulT.TabResult[11, h] * PResSimulT.TabResult[10, h] / 100) ; |
||
998 | end ;
|
||
999 | end ;
|
||
1000 | v := v / 1000 ; // Conversion g -> kg |
||
1001 | result := v / d ; |
||
1002 | end ;
|
||
1003 | |||
1004 | // AffGraphAli
|
||
1005 | begin
|
||
1006 | ResetGraph ; |
||
1007 | if CBAli1.ItemIndex = 0 |
||
1008 | then // Aliments |
||
1009 | begin
|
||
1010 | Graph.Legend.Inverted := TRUE ; |
||
1011 | Graph.Title.Text.Add (CBAli1.Text) ; |
||
1012 | end
|
||
1013 | else // Mati?res premi?res |
||
1014 | begin
|
||
1015 | Graph.Legend.Visible := FALSE ; |
||
1016 | Graph.Title.Text.Add (Format ('%s : %s', [CBAli1.Text, CBAli5.Text])) ;
|
||
1017 | end ;
|
||
1018 | Graph.LeftAxis.Title.Caption := Format ('%s (%s)', [CBAli3.Text, CBAli4.Text]) ;
|
||
1019 | case FSimulT.PC.ActivePageIndex of |
||
1020 | 1 : // Comparaison |
||
1021 | Graph.BottomAxis.Title.Caption := 'Simulation' ;
|
||
1022 | 2 : // Sensibilit? |
||
1023 | Graph.BottomAxis.Title.Caption := 'Variation' ;
|
||
1024 | end ;
|
||
1025 | // Affichage des barres
|
||
1026 | if CBAli1.ItemIndex = 0 |
||
1027 | then // Aliments |
||
1028 | begin
|
||
1029 | for i := 0 to ListAli.Count - 1 do |
||
1030 | BarAli[i].Active := TRUE ; |
||
1031 | for i := 0 to ListAli.Count - 1 do |
||
1032 | BarAli[i].Clear ; |
||
1033 | if CBAli4.ItemIndex = 2 |
||
1034 | then
|
||
1035 | for i := 0 to ListAli.Count - 1 do |
||
1036 | BarAli[i].MultiBar := mbStacked100 |
||
1037 | else
|
||
1038 | for i := 0 to ListAli.Count - 1 do |
||
1039 | BarAli[i].MultiBar := mbStacked ; |
||
1040 | for i := 0 to ListAli.Count - 1 do |
||
1041 | for k := 1 to 5 do |
||
1042 | if TabSimulT[k].Ok
|
||
1043 | then
|
||
1044 | begin
|
||
1045 | PResSimulT := TabSimulT[k].Result ; |
||
1046 | y := AliY ; |
||
1047 | case FSimulT.PC.ActivePageIndex of |
||
1048 | 1 : // Comparaison |
||
1049 | s := Format ('%d', [k]) ;
|
||
1050 | 2 : // Sensibilit? |
||
1051 | s := Format ('%1.0f %%', [TabSimulT[k].Variation * 100]) ; |
||
1052 | end ;
|
||
1053 | if y > 0 |
||
1054 | then
|
||
1055 | BarAli[i].AddBar (y, s, clTeeColor) |
||
1056 | else
|
||
1057 | BarAli[i].AddNull (s) ; |
||
1058 | end ;
|
||
1059 | end
|
||
1060 | else // Mati?res premi?res |
||
1061 | begin
|
||
1062 | BarMat.Active := TRUE ; |
||
1063 | BarMat.Clear ; |
||
1064 | for k := 1 to 5 do |
||
1065 | if TabSimulT[k].Ok
|
||
1066 | then
|
||
1067 | begin
|
||
1068 | PResSimulT := TabSimulT[k].Result ; |
||
1069 | y := MatY ; |
||
1070 | case FSimulT.PC.ActivePageIndex of |
||
1071 | 1 : // Comparaison |
||
1072 | s := Format ('%d', [k]) ;
|
||
1073 | 2 : // Sensibilit? |
||
1074 | s := Format ('%1.0f %%', [TabSimulT[k].Variation * 100]) ; |
||
1075 | end ;
|
||
1076 | if y > 0 |
||
1077 | then
|
||
1078 | BarMat.AddBar (y, s, clTeeColor) |
||
1079 | else
|
||
1080 | BarMat.AddNull (s) ; |
||
1081 | end ;
|
||
1082 | end ;
|
||
1083 | AjustEchelle (Graph) ; |
||
1084 | BarMat.ValueFormat := Format ('%s %s', [AjustFormat (Graph.LeftAxis.Increment), CBAli4.Text]) ;
|
||
1085 | end ;
|
||
1086 | |||
1087 | procedure TFCompSimulT.CBAli1Change(Sender: TObject);
|
||
1088 | begin
|
||
1089 | CBAli3.Enabled := CBAli1.ItemIndex = 0 ; // Aliments |
||
1090 | CBAli5.Visible := CBAli1.ItemIndex = 1 ; // Mati?res premi?res |
||
1091 | if CBAli1.ItemIndex = 1 |
||
1092 | then // Mati?res premi?res |
||
1093 | CBAli3.ItemIndex := 0 ;
|
||
1094 | CBAli3Change (nil) ;
|
||
1095 | end;
|
||
1096 | |||
1097 | procedure TFCompSimulT.CBAli3Change(Sender: TObject);
|
||
1098 | begin
|
||
1099 | CBAli4.Items.Clear ; |
||
1100 | case CBAli3.ItemIndex of |
||
1101 | 0 : // Quantit? |
||
1102 | begin
|
||
1103 | CBAli4.Items.Add (StrKg) ; |
||
1104 | CBAli4.Items.Add (Format ('%s/%s', [StrKg, StrJ])) ;
|
||
1105 | if CBAli1.ItemIndex = 0 |
||
1106 | then // Aliments |
||
1107 | CBAli4.Items.Add ('%') ;
|
||
1108 | end ;
|
||
1109 | 1 : // Co?t |
||
1110 | begin
|
||
1111 | CBAli4.Items.Add (CurrencySign) ; |
||
1112 | CBAli4.Items.Add (Format ('%s/%s', [CurrencySign, StrJ])) ;
|
||
1113 | CBAli4.Items.Add ('%') ;
|
||
1114 | end ;
|
||
1115 | end ;
|
||
1116 | CBAli4.ItemIndex := 0 ;
|
||
1117 | AffGraphAli ; |
||
1118 | end;
|
||
1119 | |||
1120 | procedure TFCompSimulT.CBAli4Change (Sender : TObject) ;
|
||
1121 | begin
|
||
1122 | AffGraphAli ; |
||
1123 | end ;
|
||
1124 | |||
1125 | procedure TFCompSimulT.CBAli5Change(Sender: TObject);
|
||
1126 | begin
|
||
1127 | AffGraphAli ; |
||
1128 | end;
|
||
1129 | |||
1130 | ///////////////////////
|
||
1131 | // Acides amin?s //
|
||
1132 | ///////////////////////
|
||
1133 | procedure TFCompSimulT.InitAA ;
|
||
1134 | const
|
||
1135 | TabColor1 : array[0..10] of TColor |
||
1136 | = (clTeal, clAqua, clOlive, clPurple, clSilver, clPink, clWhite, clSkyBlue, |
||
1137 | clGray, clRed, clGreen) ; |
||
1138 | TabColor2 : array[1..5] of TColor |
||
1139 | = (clRed, clGreen, clYellow, clBlue, clFuchsia) ; |
||
1140 | var
|
||
1141 | i, k : integer ; |
||
1142 | begin
|
||
1143 | // ListAA : liste pour les acides amin?s
|
||
1144 | ListAA := TStringList.Create ; |
||
1145 | ListAA.Assign (LBAA.Items) ; |
||
1146 | // BarAA : s?ries (barres) graphiques
|
||
1147 | SetLength (BarAA, ListAA.Count) ; |
||
1148 | for i := 0 to ListAA.Count - 1 do |
||
1149 | begin
|
||
1150 | BarAA[i] := TBarSeries.Create (Graph) ; |
||
1151 | BarAA[i].ParentChart := Graph ; |
||
1152 | BarAA[i].Title := ListAA[i] ; |
||
1153 | BarAA[i].SeriesColor := TabColor1[i] ; |
||
1154 | BarAA[i].BarPen.Color := BarAA[i].SeriesColor ; |
||
1155 | BarAA[i].Marks.Visible := FALSE ; |
||
1156 | Graph.AddSeries (BarAA[i]) ; |
||
1157 | end ;
|
||
1158 | // LineAA : s?ries (lignes) graphiques
|
||
1159 | for k := 1 to 5 do |
||
1160 | if TabSimulT[k].Ok
|
||
1161 | then
|
||
1162 | begin
|
||
1163 | LineAA[k] := TLineSeries.Create (Graph) ; |
||
1164 | LineAA[k].ParentChart := Graph ; |
||
1165 | case FSimulT.PC.ActivePageIndex of |
||
1166 | 1 : // Comparaison |
||
1167 | LineAA[k].Title := Format ('Simulation %d', [k]) ;
|
||
1168 | 2 : // Sensibilit? |
||
1169 | LineAA[k].Title := Format ('%1.0f %%', [TabSimulT[k].Variation * 100]) ; |
||
1170 | end ;
|
||
1171 | LineAA[k].SeriesColor := TabColor2[k] ; |
||
1172 | LineAA[k].LinePen.Color := LineAA[k].SeriesColor ; |
||
1173 | LineAA[k].LinePen.Width := 2 ;
|
||
1174 | Graph.AddSeries (LineAA[k]) ; |
||
1175 | end ;
|
||
1176 | end ;
|
||
1177 | |||
1178 | procedure TFCompSimulT.AffGraphAA ;
|
||
1179 | var
|
||
1180 | i, j, k : integer ; |
||
1181 | y : double ; |
||
1182 | s : string ;
|
||
1183 | |||
1184 | // Abscisse
|
||
1185 | function AAX : double ;
|
||
1186 | begin
|
||
1187 | case CBAA2.ItemIndex of |
||
1188 | 0 : // Age |
||
1189 | result := PresSimulT.TabResult[1, j] ;
|
||
1190 | 1 : // Dur?e |
||
1191 | result := j - 1 ;
|
||
1192 | else
|
||
1193 | result := 0 ;
|
||
1194 | end ;
|
||
1195 | end ;
|
||
1196 | |||
1197 | // Ordonn?e
|
||
1198 | function AAY : double ;
|
||
1199 | var
|
||
1200 | h : integer ; |
||
1201 | v, d, Lys, ProtId, ProdLait, PDMax, PVV : double ; |
||
1202 | |||
1203 | function Ingere(AA, Jour: integer): double;
|
||
1204 | begin
|
||
1205 | result := PresSimulT.TabResult[AA + 14, Jour];
|
||
1206 | if (AA = 3) or (AA = 7) |
||
1207 | then // met + cys, phe + tyr |
||
1208 | result := result + PresSimulT.TabResult[AA + 13, Jour];
|
||
1209 | end;
|
||
1210 | |||
1211 | function Digestible(AA, Jour: integer): double;
|
||
1212 | begin
|
||
1213 | result := PresSimulT.TabResult[AA + 27, Jour];
|
||
1214 | if (AA = 3) or (AA = 7) |
||
1215 | then // met + cys, phe + tyr |
||
1216 | result := result + PresSimulT.TabResult[AA + 26, Jour];
|
||
1217 | end;
|
||
1218 | |||
1219 | function Endogene(AA, Jour: integer): double;
|
||
1220 | var
|
||
1221 | IngereSec: double; |
||
1222 | begin
|
||
1223 | IngereSec := PResSimulT.TabResult[12, Jour] ;
|
||
1224 | result := IngereSec * AAendogene[AA] ; |
||
1225 | if (AA = 3) or (AA = 7) |
||
1226 | then // met + cys, phe + tyr |
||
1227 | result := result + IngereSec * AAendogene[AA - 1] ;
|
||
1228 | end;
|
||
1229 | |||
1230 | function Entretien(AA, Jour: integer): double;
|
||
1231 | var
|
||
1232 | PVTot, ProfilEnt: double; |
||
1233 | begin
|
||
1234 | PVTot := PresSimulT.TabResult[58, Jour];
|
||
1235 | ProfilEnt := AAm75[AA]; |
||
1236 | if (AA = 3) or (AA = 7) |
||
1237 | then // met + cys, phe + tyr |
||
1238 | ProfilEnt := ProfilEnt + AAm75[AA - 1];
|
||
1239 | result := ProfilEnt * Power(PVTot, 0.75);
|
||
1240 | end;
|
||
1241 | |||
1242 | function Portee(AA, Jour: integer): double;
|
||
1243 | var
|
||
1244 | PDTot, PDNet, ProfilRet : double ; |
||
1245 | begin
|
||
1246 | if PresSimulT.TabResult[3, Jour] = 0 |
||
1247 | then // Gestation |
||
1248 | begin
|
||
1249 | PDTot := PresSimulT.TabResult[64, Jour] ;
|
||
1250 | PDNet := PresSimulT.TabResult[63, Jour] ;
|
||
1251 | if AA = 0 |
||
1252 | then // Azote |
||
1253 | result := PDTot - PDNet |
||
1254 | else
|
||
1255 | begin
|
||
1256 | ProfilRet := ProtIdRet[AA] ; |
||
1257 | if (AA = 3) or (AA = 7) |
||
1258 | then // met + cys, phe + tyr |
||
1259 | ProfilRet := ProfilRet + ProtIdRet[AA - 1] ;
|
||
1260 | result := (PDTot - PDNet) * 0.060 * ProfilRet / 100 ; |
||
1261 | end ;
|
||
1262 | end
|
||
1263 | else // Lactation ou ISSF |
||
1264 | result := 0 ;
|
||
1265 | end;
|
||
1266 | |||
1267 | function DepotPot(AA, Jour: integer): double;
|
||
1268 | var
|
||
1269 | PDPot, PDTot, PDNet, ProfilRet : double ; |
||
1270 | begin
|
||
1271 | if PresSimulT.TabResult[3, Jour] = 1 |
||
1272 | then // Lactation |
||
1273 | result := 0
|
||
1274 | else // Gestation ou ISSF |
||
1275 | begin
|
||
1276 | PDPot := PresSimulT.TabResult[40, Jour] ;
|
||
1277 | PDTot := PresSimulT.TabResult[64, Jour] ;
|
||
1278 | PDNet := PresSimulT.TabResult[63, Jour] ;
|
||
1279 | if AA = 0 |
||
1280 | then // Azote |
||
1281 | result := PDPot - (PDTot - PDNet) |
||
1282 | else
|
||
1283 | begin
|
||
1284 | ProfilRet := ProtIdRet[AA] ; |
||
1285 | if (AA = 3) or (AA = 7) |
||
1286 | then // met + cys, phe + tyr |
||
1287 | ProfilRet := ProfilRet + ProtIdRet[AA - 1] ;
|
||
1288 | result := (PDPot - (PDTot - PDNet)) * 0.070 * ProfilRet / 100 ; |
||
1289 | end ;
|
||
1290 | end ;
|
||
1291 | end;
|
||
1292 | |||
1293 | function Depot(AA, Jour: integer): double;
|
||
1294 | var
|
||
1295 | PDPot, PDTot : double ; |
||
1296 | begin
|
||
1297 | if PresSimulT.TabResult[3, Jour] = 1 |
||
1298 | then // Lactation |
||
1299 | result := 0
|
||
1300 | else // Gestation ou ISSF |
||
1301 | begin
|
||
1302 | PDPot := PresSimulT.TabResult[40, Jour] ;
|
||
1303 | PDTot := PresSimulT.TabResult[64, Jour] ;
|
||
1304 | result := (Portee(AA, Jour) + DepotPot(AA, Jour)) / PDPot * PDTot - Portee(AA, Jour) ; |
||
1305 | end ;
|
||
1306 | end;
|
||
1307 | |||
1308 | function Cumul(AA, Jour: integer): double;
|
||
1309 | var
|
||
1310 | ProtLait, ProfilLact, ProfilGest : double ; |
||
1311 | begin
|
||
1312 | if PresSimulT.TabResult[3, Jour] = 1 |
||
1313 | then // Lactation |
||
1314 | if AA > 1 |
||
1315 | then
|
||
1316 | begin
|
||
1317 | ProfilLact := ProtIdLact[AA] ; |
||
1318 | if (AA = 3) or (AA = 7) |
||
1319 | then // met + cys, phe + tyr |
||
1320 | ProfilLact := ProfilLact + ProtIdLact[AA - 1] ;
|
||
1321 | result := Cumul(1, Jour) * ProfilLact / 100 ; |
||
1322 | end
|
||
1323 | else
|
||
1324 | begin
|
||
1325 | ProtLait := PresSimulT.TabResult[69, Jour] * 50 ; |
||
1326 | if AA = 0 |
||
1327 | then // Azote |
||
1328 | result := Endogene(0, Jour) + Entretien(0, Jour) + ProtLait / kAA[0] |
||
1329 | else // Lysine |
||
1330 | result := (14.2 + 0.629 * ProtLait / 6.28) / 1.335 ; |
||
1331 | end
|
||
1332 | else // Gestation ou ISSF |
||
1333 | if AA = 0 |
||
1334 | then // Azote |
||
1335 | result := Endogene(0, Jour) + Entretien(0, Jour) + (Portee(0, Jour) + Depot(0, Jour)) / kAA[0] |
||
1336 | else
|
||
1337 | if AA = 12 |
||
1338 | then // Arginine |
||
1339 | result := Endogene(12, Jour) + Entretien(12, Jour) + Portee(12, Jour) + Depot(12, Jour) |
||
1340 | else
|
||
1341 | begin
|
||
1342 | ProfilGest := ProtIdGest[AA] ; |
||
1343 | if (AA = 3) or (AA = 7) |
||
1344 | then // met + cys, phe + tyr |
||
1345 | ProfilGest := ProfilGest + ProtIdGest[AA - 1] ;
|
||
1346 | result := (Endogene(1, Jour) + Entretien(1, Jour) + (Portee(1, Jour) + Depot(1, Jour)) / KLysGest) * ProfilGest / 100 ; |
||
1347 | end ;
|
||
1348 | end;
|
||
1349 | |||
1350 | function CumulPot(AA, Jour: integer): double;
|
||
1351 | var
|
||
1352 | ProfilGest : double ; |
||
1353 | begin
|
||
1354 | if PresSimulT.TabResult[3, Jour] = 1 |
||
1355 | then // Lactation |
||
1356 | result := 0
|
||
1357 | else // Gestation ou ISSF |
||
1358 | if AA = 0 |
||
1359 | then // Azote |
||
1360 | result := Endogene(0, Jour) + Entretien(0, Jour) + (Portee(0, Jour) + DepotPot(0, Jour)) / kAA[0] |
||
1361 | else
|
||
1362 | if AA = 12 |
||
1363 | then // Arginine |
||
1364 | result := Endogene(12, Jour) + Entretien(12, Jour) + Portee(12, Jour) + DepotPot(12, Jour) |
||
1365 | else
|
||
1366 | begin
|
||
1367 | ProfilGest := ProtIdGest[AA] ; |
||
1368 | if (AA = 3) or (AA = 7) |
||
1369 | then // met + cys, phe + tyr |
||
1370 | ProfilGest := ProfilGest + ProtIdGest[AA - 1] ;
|
||
1371 | result := (Endogene(1, Jour) + Entretien(1, Jour) + (Portee(1, Jour) + DepotPot(1, Jour)) / KLysGest) * ProfilGest / 100 ; |
||
1372 | end ;
|
||
1373 | end;
|
||
1374 | |||
1375 | function Mobilisation(AA, Jour: integer): double;
|
||
1376 | begin
|
||
1377 | if PresSimulT.TabResult[3, Jour] = 1 |
||
1378 | then // Lactation |
||
1379 | result := Max(Cumul(AA, Jour) - Digestible(AA, Jour), 0)
|
||
1380 | else // Gestation ou ISSF |
||
1381 | result := 0 ;
|
||
1382 | end;
|
||
1383 | |||
1384 | // AA du lait provenant de l'aliment
|
||
1385 | function Lait(AA, Jour: integer): double;
|
||
1386 | var
|
||
1387 | ProtLait, ProfilLait, ExportLait, BesoinLait, CoeffLait : double ; |
||
1388 | begin
|
||
1389 | if PresSimulT.TabResult[3, Jour] = 1 |
||
1390 | then // Lactation |
||
1391 | begin
|
||
1392 | ProtLait := PresSimulT.TabResult[69, Jour] * 50 ; |
||
1393 | BesoinLait := Cumul(AA, Jour) - Mobilisation(AA, Jour) - Endogene(AA, Jour) - Entretien(AA, Jour) ; |
||
1394 | CoeffLait := Max ((BesoinLait - Mobilisation(AA, Jour)) / BesoinLait, 0) ;
|
||
1395 | if AA = 0 |
||
1396 | then // Azote |
||
1397 | ExportLait := ProtLait |
||
1398 | else
|
||
1399 | begin
|
||
1400 | ProfilLait := ProtIdLait[AA] ; |
||
1401 | if (AA = 3) or (AA = 7) |
||
1402 | then // met + cys, phe + tyr |
||
1403 | ProfilLait := ProfilLait + ProtIdLait[AA - 1] ;
|
||
1404 | ExportLait := ProtLait * 0.075 * ProfilLait / 100 ; |
||
1405 | end ;
|
||
1406 | result := CoeffLait * ExportLait ; |
||
1407 | end
|
||
1408 | else // Gestation ou ISSF |
||
1409 | result := 0 ;
|
||
1410 | end;
|
||
1411 | |||
1412 | function Deficit(AA, Jour: integer): double;
|
||
1413 | begin
|
||
1414 | if PresSimulT.TabResult[3, Jour] = 1 |
||
1415 | then // Lactation |
||
1416 | result := 0
|
||
1417 | else // Gestation ou ISSF |
||
1418 | result := Max(CumulPot(AA, Jour) - Digestible(AA, Jour), 0) ;
|
||
1419 | end;
|
||
1420 | |||
1421 | function Exces(AA, Jour: integer): double;
|
||
1422 | begin
|
||
1423 | if PresSimulT.TabResult[3, Jour] = 1 |
||
1424 | then // Lactation |
||
1425 | result := Max(Digestible(AA, Jour) - Cumul(AA, Jour), 0)
|
||
1426 | else // Gestation ou ISSF |
||
1427 | result := Max(Digestible(AA, Jour) - CumulPot(AA, Jour), 0) ;
|
||
1428 | end;
|
||
1429 | |||
1430 | function Desequilibre(AA, Jour: integer): double;
|
||
1431 | begin
|
||
1432 | if PresSimulT.TabResult[3, Jour] = 1 |
||
1433 | then // Lactation |
||
1434 | result := 0
|
||
1435 | else // Gestation ou ISSF |
||
1436 | result := Max(CumulPot(AA, Jour) - Cumul(AA, Jour) - Deficit(AA, Jour), 0) ;
|
||
1437 | end;
|
||
1438 | |||
1439 | function Oxydation(AA, Jour: integer): double;
|
||
1440 | begin
|
||
1441 | if PresSimulT.TabResult[3, Jour] = 1 |
||
1442 | then // Lactation |
||
1443 | begin
|
||
1444 | result := Cumul(AA, Jour) - Mobilisation(AA, Jour) - Endogene(AA, Jour) - Entretien(AA, Jour) - Lait(AA, Jour) |
||
1445 | end
|
||
1446 | else // Gestation ou ISSF |
||
1447 | result := Max(Cumul(AA, Jour) - Entretien(AA, Jour) - Endogene(AA, Jour) - Portee(AA, Jour) - Depot(AA, Jour), 0) ;
|
||
1448 | end;
|
||
1449 | |||
1450 | begin
|
||
1451 | case CBAA1.ItemIndex of |
||
1452 | 0 : // R?partition |
||
1453 | begin
|
||
1454 | // Diviseur
|
||
1455 | case CBAA4.ItemIndex of |
||
1456 | 1 : // Dur?e |
||
1457 | d := PresSimulT.NbJSim ; |
||
1458 | 2 : // Aliment ing?r? |
||
1459 | begin
|
||
1460 | d := 0 ;
|
||
1461 | for h := 1 to PresSimulT.NbJSim do |
||
1462 | d := d + PresSimulT.TabResult[11, h] ;
|
||
1463 | end ;
|
||
1464 | else
|
||
1465 | d := 1 ;
|
||
1466 | end ;
|
||
1467 | v := 0 ;
|
||
1468 | case i of |
||
1469 | 0 : // Indigestible |
||
1470 | if CBAA5A.ItemIndex = 2 |
||
1471 | then // Total |
||
1472 | for h := 1 to PresSimulT.NbJSim do |
||
1473 | v := v + Ingere(CBAA3.ItemIndex, h) - Digestible(CBAA3.ItemIndex, h) ; |
||
1474 | 1 : // Endog?ne basal |
||
1475 | if CBAA5A.ItemIndex <> 1 |
||
1476 | then // Total ou Digestible standardis? |
||
1477 | for h := 1 to PresSimulT.NbJSim do |
||
1478 | v := v + Endogene(CBAA3.ItemIndex, h) ; |
||
1479 | 2 : // Entretien |
||
1480 | for h := 1 to PresSimulT.NbJSim do |
||
1481 | v := v + Entretien(CBAA3.ItemIndex, h) ; |
||
1482 | 3 : // Port?e |
||
1483 | for h := 1 to PresSimulT.NbJSim do |
||
1484 | v := v + Portee(CBAA3.ItemIndex, h) ; |
||
1485 | 4 : // Oxydation minimale |
||
1486 | for h := 1 to PresSimulT.NbJSim do |
||
1487 | v := v + Oxydation(CBAA3.ItemIndex, h) ; |
||
1488 | 5 : // D?p?t |
||
1489 | for h := 1 to PresSimulT.NbJSim do |
||
1490 | v := v + Depot(CBAA3.ItemIndex, h) ; |
||
1491 | 6 : // Lait |
||
1492 | for h := 1 to PresSimulT.NbJSim do |
||
1493 | v := v + Lait(CBAA3.ItemIndex, h) ; |
||
1494 | 7 : // Mobilisation |
||
1495 | for h := 1 to PresSimulT.NbJSim do |
||
1496 | v := v + Mobilisation(CBAA3.ItemIndex, h) ; |
||
1497 | 8 : // D?s?quilibre |
||
1498 | for h := 1 to PresSimulT.NbJSim do |
||
1499 | v := v + Desequilibre(CBAA3.ItemIndex, h) ; |
||
1500 | 9 : // D?ficit |
||
1501 | for h := 1 to PresSimulT.NbJSim do |
||
1502 | v := v + DEficit(CBAA3.ItemIndex, h) ; |
||
1503 | 10 : // Exc?s |
||
1504 | for h := 1 to PresSimulT.NbJSim do |
||
1505 | v := v + Exces(CBAA3.ItemIndex, h) ; |
||
1506 | end ;
|
||
1507 | result := v / d ; |
||
1508 | end ;
|
||
1509 | 1 : // Apport |
||
1510 | begin
|
||
1511 | // Diviseur
|
||
1512 | case CBAA4.ItemIndex of |
||
1513 | 1 : // Lysine |
||
1514 | begin
|
||
1515 | case CBAA5A.ItemIndex of |
||
1516 | 0 : // Standardis? |
||
1517 | d := Digestible(1, j) ;
|
||
1518 | 1 : // Apparent |
||
1519 | d := Digestible(1, j) - Endogene(1, j) ; |
||
1520 | 2 : // Total |
||
1521 | d := Ingere(1, j) ;
|
||
1522 | else
|
||
1523 | d := 1 ;
|
||
1524 | end ;
|
||
1525 | d := d / 100 ;
|
||
1526 | end ;
|
||
1527 | 2 : // ED |
||
1528 | d := PResSimulT.TabResult[71, j] ;
|
||
1529 | 3 : // EM |
||
1530 | d := PResSimulT.TabResult[72, j] ;
|
||
1531 | 4 : // EN |
||
1532 | d := PResSimulT.TabResult[73, j] ;
|
||
1533 | 5 : // Aliment ing?r? |
||
1534 | d := PResSimulT.TabResult[11, j] ;
|
||
1535 | else
|
||
1536 | d := 1 ;
|
||
1537 | end ;
|
||
1538 | case CBAA5A.ItemIndex of |
||
1539 | 0 : // Standardis? |
||
1540 | v := Digestible(CBAA3.ItemIndex, j) ; |
||
1541 | 1 : // Apparent |
||
1542 | v := Digestible(CBAA3.ItemIndex, j) - Endogene(CBAA3.ItemIndex, j) ; |
||
1543 | 2 : // Total |
||
1544 | v := Ingere(CBAA3.ItemIndex, j) ; |
||
1545 | else
|
||
1546 | v := 0 ;
|
||
1547 | end ;
|
||
1548 | result := v / d ; |
||
1549 | end ;
|
||
1550 | 2 : // Besoin |
||
1551 | begin
|
||
1552 | PDmax := PResSimulT.TabResult[40, j] ;
|
||
1553 | PVV := PResSimulT.TabResult[58, j] * PV2PVV ;
|
||
1554 | if PResSimulT.TabResult[3, j] = 1 |
||
1555 | then // Lactation |
||
1556 | begin
|
||
1557 | ProdLait := PResSimulT.TabResult[69, j] ;
|
||
1558 | Lys := (14.2 + 0.629 * ProdLait / 0.1325) / 1.335 ; |
||
1559 | end
|
||
1560 | else // Gestation ou ISSF |
||
1561 | Lys := (PDmax * 0.065 + 0.036 * Power (PVV, 0.75)) / KLysGest ; |
||
1562 | // Diviseur
|
||
1563 | case CBAA4.ItemIndex of |
||
1564 | 1 : // Lysine |
||
1565 | begin
|
||
1566 | case CBAA5B.ItemIndex of |
||
1567 | 0 : // Standardis? |
||
1568 | d := Lys ; |
||
1569 | 1 : // Apparent |
||
1570 | d := Lys - Endogene(1, j) ;
|
||
1571 | else
|
||
1572 | d := 1 ;
|
||
1573 | end ;
|
||
1574 | d := d / 100 ;
|
||
1575 | end ;
|
||
1576 | 2 : // ED |
||
1577 | d := PResSimulT.TabResult[71, j] ;
|
||
1578 | 3 : // EM |
||
1579 | d := PResSimulT.TabResult[72, j] ;
|
||
1580 | 4 : // EN |
||
1581 | d := PResSimulT.TabResult[73, j] ;
|
||
1582 | 5 : // Aliment ing?r? |
||
1583 | d := PResSimulT.TabResult[11, j] ;
|
||
1584 | else
|
||
1585 | d := 1 ;
|
||
1586 | end ;
|
||
1587 | if PResSimulT.TabResult[3, j] = 1 |
||
1588 | then // Lactation |
||
1589 | begin
|
||
1590 | ProtId := ProtIdLact[CBAA3.ItemIndex] ; |
||
1591 | if (CBAA3.ItemIndex = 3) or (CBAA3.ItemIndex = 7) |
||
1592 | then // met + cys, phe + tyr |
||
1593 | ProtId := ProtId + ProtIdLact[CBAA3.ItemIndex - 1] ;
|
||
1594 | end
|
||
1595 | else // Gestation ou ISSF |
||
1596 | begin
|
||
1597 | ProtId := ProtIdGest[CBAA3.ItemIndex] ; |
||
1598 | if (CBAA3.ItemIndex = 3) or (CBAA3.ItemIndex = 7) |
||
1599 | then // met + cys, phe + tyr |
||
1600 | ProtId := ProtId + ProtIdGest[CBAA3.ItemIndex - 1] ;
|
||
1601 | end ;
|
||
1602 | case CBAA5B.ItemIndex of |
||
1603 | 0 : // Standardis? |
||
1604 | if CBAA3.ItemIndex = 0 |
||
1605 | then // Mati?res azot?es |
||
1606 | v := (PDmax + AAm75[0] * Power (PVV, 0.75) + Endogene(0, j)) / kAA[0] |
||
1607 | else
|
||
1608 | v := Lys * ProtId / 100 ;
|
||
1609 | 1 : // Apparent |
||
1610 | if CBAA3.ItemIndex = 0 |
||
1611 | then // Mati?res azot?es |
||
1612 | v := (PDmax + AAm75[0] * Power (PVV, 0.75)) / kAA[0] |
||
1613 | else
|
||
1614 | v := Lys * ProtId / 100 - Endogene(CBAA3.ItemIndex, j) ;
|
||
1615 | else
|
||
1616 | v := 0 ;
|
||
1617 | end ;
|
||
1618 | result := v / d ; |
||
1619 | end ;
|
||
1620 | else
|
||
1621 | result := 0 ;
|
||
1622 | end ;
|
||
1623 | end ;
|
||
1624 | |||
1625 | // AffGraphAA
|
||
1626 | begin
|
||
1627 | ResetGraph ; |
||
1628 | Graph.Title.Text.Add (Format ('%s : %s', [CBAA3.Text, CBAA1.Text])) ;
|
||
1629 | Graph.LeftAxis.Title.Caption := Format ('%s (%s)', [CBAA3.Text, CBAA4.Text]) ;
|
||
1630 | case CBAA1.ItemIndex of |
||
1631 | 0 : // R?partition |
||
1632 | begin
|
||
1633 | Graph.Legend.Inverted := TRUE ; |
||
1634 | Graph.SubTitle.Text.Add (CBAA5A.Text) ; |
||
1635 | case FSimulT.PC.ActivePageIndex of |
||
1636 | 1 : // Comparaison |
||
1637 | Graph.BottomAxis.Title.Caption := 'Simulation' ;
|
||
1638 | 2 : // Sensibilit? |
||
1639 | Graph.BottomAxis.Title.Caption := 'Variation' ;
|
||
1640 | end ;
|
||
1641 | // Affichage des barres
|
||
1642 | for i := 0 to ListAA.Count - 1 do |
||
1643 | BarAA[i].Active := TRUE ; |
||
1644 | for i := 0 to ListAA.Count - 1 do |
||
1645 | BarAA[i].Clear ; |
||
1646 | if CBAA4.ItemIndex = 3 |
||
1647 | then
|
||
1648 | for i := 0 to ListAA.Count - 1 do |
||
1649 | BarAA[i].MultiBar := mbStacked100 |
||
1650 | else
|
||
1651 | for i := 0 to ListAA.Count - 1 do |
||
1652 | BarAA[i].MultiBar := mbStacked ; |
||
1653 | for i := 0 to ListAA.Count - 1 do |
||
1654 | for k := 1 to 5 do |
||
1655 | if TabSimulT[k].Ok
|
||
1656 | then
|
||
1657 | begin
|
||
1658 | PResSimulT := TabSimulT[k].Result ; |
||
1659 | case FSimulT.PC.ActivePageIndex of |
||
1660 | 1 : // Comparaison |
||
1661 | s := Format ('%d', [k]) ;
|
||
1662 | 2 : // Sensibilit? |
||
1663 | s := Format ('%1.0f %%', [TabSimulT[k].Variation * 100]) ; |
||
1664 | end ;
|
||
1665 | y := AAY ; |
||
1666 | if y > PICO
|
||
1667 | then
|
||
1668 | BarAA[i].AddBar (y, s, clTeeColor) |
||
1669 | else
|
||
1670 | BarAA[i].AddNull (s) ; |
||
1671 | end ;
|
||
1672 | end ;
|
||
1673 | 1, 2 : // Apport ou besoin |
||
1674 | begin
|
||
1675 | Graph.Legend.Inverted := FALSE ; |
||
1676 | if CBAA1.ItemIndex = 2 |
||
1677 | then // Besoin |
||
1678 | Graph.SubTitle.Text.Add (CBAA5B.Text) |
||
1679 | else
|
||
1680 | Graph.SubTitle.Text.Add (CBAA5A.Text) ; |
||
1681 | Graph.BottomAxis.Title.Caption := CBAA2.Text ; |
||
1682 | // Affichage des lignes
|
||
1683 | for k := 1 to 5 do |
||
1684 | if TabSimulT[k].Ok
|
||
1685 | then
|
||
1686 | begin
|
||
1687 | LineAA[k].Active := TRUE ; |
||
1688 | LineAA[k].Clear ; |
||
1689 | PResSimulT := TabSimulT[k].Result ; |
||
1690 | for j := 1 to PresSimulT.NbJSim do |
||
1691 | LineAA[k].AddXY (AAX, AAY, '', clTeeColor) ;
|
||
1692 | end ;
|
||
1693 | end ;
|
||
1694 | end ;
|
||
1695 | AjustEchelle (Graph) ; |
||
1696 | end ;
|
||
1697 | |||
1698 | procedure TFCompSimulT.CBAA1Change (Sender : TObject) ;
|
||
1699 | begin
|
||
1700 | CBAA4.Items.Clear ; |
||
1701 | case CBAA1.ItemIndex of |
||
1702 | 0 : // R?partition |
||
1703 | begin
|
||
1704 | CBAA2.Visible := FALSE ; |
||
1705 | CBAA5A.Visible := TRUE ; |
||
1706 | CBAA5B.Visible := FALSE ; |
||
1707 | // Unit?s
|
||
1708 | CBAA4.Items.Add (StrG) ; |
||
1709 | CBAA4.Items.Add (Format ('%s/%s', [StrG, StrJ])) ;
|
||
1710 | CBAA4.Items.Add (Format ('%s/%s %s', [StrG, StrKg, StrAlimentUnit])) ;
|
||
1711 | CBAA4.Items.Add ('%') ;
|
||
1712 | end ;
|
||
1713 | 1, 2 : // Apport ou besoin |
||
1714 | begin
|
||
1715 | CBAA2.Visible := TRUE ; |
||
1716 | CBAA5A.Visible := (CBAA1.ItemIndex = 1) ;
|
||
1717 | CBAA5B.Visible := (CBAA1.ItemIndex = 2) ;
|
||
1718 | // Unit?s
|
||
1719 | CBAA4.Items.Add (Format ('%s/%s', [StrG, StrJ])) ;
|
||
1720 | CBAA4.Items.Add (Format ('%% %s', [StrLys])) ;
|
||
1721 | CBAA4.Items.Add (Format ('%s/%s %s', [StrG, StrMJ, StrED])) ;
|
||
1722 | CBAA4.Items.Add (Format ('%s/%s %s', [StrG, StrMJ, StrEM])) ;
|
||
1723 | CBAA4.Items.Add (Format ('%s/%s %s', [StrG, StrMJ, StrEN])) ;
|
||
1724 | CBAA4.Items.Add (Format ('%s/%s %s', [StrG, StrKg, StrAlimentUnit])) ;
|
||
1725 | if (CBAA1.ItemIndex = 2) and(CBAA5A.ItemIndex = 2) |
||
1726 | then // Besoin -> Total |
||
1727 | CBAA5A.ItemIndex := 0 ;
|
||
1728 | end ;
|
||
1729 | end ;
|
||
1730 | CBAA4.ItemIndex := 0 ;
|
||
1731 | AffGraphAA ; |
||
1732 | end ;
|
||
1733 | |||
1734 | procedure TFCompSimulT.CBAA2Change (Sender : TObject) ;
|
||
1735 | begin
|
||
1736 | AffGraphAA ; |
||
1737 | end ;
|
||
1738 | |||
1739 | procedure TFCompSimulT.CBAA3Change (Sender : TObject) ;
|
||
1740 | begin
|
||
1741 | AffGraphAA ; |
||
1742 | end ;
|
||
1743 | |||
1744 | procedure TFCompSimulT.CBAA4Change (Sender : TObject) ;
|
||
1745 | begin
|
||
1746 | AffGraphAA ; |
||
1747 | end ;
|
||
1748 | |||
1749 | procedure TFCompSimulT.CBAA5Change (Sender : TObject) ;
|
||
1750 | begin
|
||
1751 | if CBAA1.ItemIndex = 2 |
||
1752 | then // Besoin |
||
1753 | CBAA5A.ItemIndex := CBAA5B.ItemIndex |
||
1754 | else
|
||
1755 | if CBAA5A.ItemIndex = 2 |
||
1756 | then // Total |
||
1757 | CBAA5B.ItemIndex := 0
|
||
1758 | else
|
||
1759 | CBAA5B.ItemIndex := CBAA5A.ItemIndex ; |
||
1760 | AffGraphAA ; |
||
1761 | end ;
|
||
1762 | |||
1763 | /////////////////
|
||
1764 | // Energie //
|
||
1765 | /////////////////
|
||
1766 | procedure TFCompSimulT.InitNRJ ;
|
||
1767 | const
|
||
1768 | TabColor : array[0..9] of TColor |
||
1769 | = (clTeal, clYellow, clOlive, clAqua, clFuchsia, clPurple, clWhite, clBlue, |
||
1770 | clLime, clRed) ; |
||
1771 | var
|
||
1772 | i : integer ; |
||
1773 | begin
|
||
1774 | // ListNRJ : liste pour l'?nergie
|
||
1775 | ListNRJ := TStringList.Create ; |
||
1776 | ListNRJ.Assign (LBNRJ.Items) ; |
||
1777 | // BarNRJ : s?ries (barres) graphiques
|
||
1778 | SetLength (BarNRJ, ListNRJ.Count) ; |
||
1779 | for i := 0 to ListNRJ.Count - 1 do |
||
1780 | begin
|
||
1781 | BarNRJ[i] := TBarSeries.Create (Graph) ; |
||
1782 | BarNRJ[i].ParentChart := Graph ; |
||
1783 | BarNRJ[i].Title := ListNRJ[i] ; |
||
1784 | BarNRJ[i].SeriesColor := TabColor[i] ; |
||
1785 | BarNRJ[i].BarPen.Color := BarNRJ[i].SeriesColor ; |
||
1786 | BarNRJ[i].Marks.Visible := FALSE ; |
||
1787 | Graph.AddSeries (BarNRJ[i]) ; |
||
1788 | end ;
|
||
1789 | end ;
|
||
1790 | |||
1791 | procedure TFCompSimulT.AffGraphNRJ ;
|
||
1792 | var
|
||
1793 | i, j, k : integer ; |
||
1794 | y : double ; |
||
1795 | s : string ;
|
||
1796 | |||
1797 | // Abscisse
|
||
1798 | function NRJX : double ;
|
||
1799 | begin
|
||
1800 | case CBNRJ2.ItemIndex of |
||
1801 | 0 : // Age |
||
1802 | result := PresSimulT.TabResult[1, j] ;
|
||
1803 | 1 : // Dur?e |
||
1804 | result := j - 1 ;
|
||
1805 | else
|
||
1806 | result := 0 ;
|
||
1807 | end ;
|
||
1808 | end ;
|
||
1809 | |||
1810 | // Ordonn?e
|
||
1811 | function NRJY : double ;
|
||
1812 | var
|
||
1813 | h : integer ; |
||
1814 | v, d, EBIng, EDIng, EMIng, EMEnt, EMThe, EMAct, Chaleur, ENProd, Deficit, |
||
1815 | ENProt, ENLip, EMProd, EMRes : double ; |
||
1816 | begin
|
||
1817 | // Diviseur
|
||
1818 | case CBNRJ4.ItemIndex of |
||
1819 | 1 : // Dur?e |
||
1820 | d := PresSimulT.NbJSim ; |
||
1821 | 2 : // Aliment ing?r? |
||
1822 | begin
|
||
1823 | d := 0 ;
|
||
1824 | for h := 1 to PresSimulT.NbJSim do |
||
1825 | d := d + PresSimulT.TabResult[11, h] ;
|
||
1826 | end ;
|
||
1827 | else
|
||
1828 | d := 1 ;
|
||
1829 | end ;
|
||
1830 | v := 0 ;
|
||
1831 | case i of |
||
1832 | 0 : // Indigestible |
||
1833 | if CBNRJ3.ItemIndex = 0 |
||
1834 | then // EB |
||
1835 | for h := 1 to PresSimulT.NbJSim do |
||
1836 | begin
|
||
1837 | EBIng := PresSimulT.TabResult[13, h] ;
|
||
1838 | EDIng := PresSimulT.TabResult[71, h] ;
|
||
1839 | v := v + EBIng - EDIng ; |
||
1840 | end ;
|
||
1841 | 1 : // M?thane et urines |
||
1842 | if CBNRJ3.ItemIndex <= 1 |
||
1843 | then // EB ou ED |
||
1844 | for h := 1 to PresSimulT.NbJSim do |
||
1845 | begin
|
||
1846 | EDIng := PresSimulT.TabResult[71, h] ;
|
||
1847 | EMIng := PresSimulT.TabResult[72, h] ;
|
||
1848 | v := v + EDIng - EMIng ; |
||
1849 | end ;
|
||
1850 | 2 : // Entretien et activit? |
||
1851 | for h := 1 to PresSimulT.NbJSim do |
||
1852 | begin
|
||
1853 | EMEnt := PresSimulT.TabResult[74, h] ;
|
||
1854 | EMAct := PresSimulT.TabResult[76, h] ;
|
||
1855 | if CBNRJ3.ItemIndex = 3 |
||
1856 | then // EN |
||
1857 | v := v + (EMEnt + EMAct) * KGest |
||
1858 | else // EB, ED ou EM |
||
1859 | v := v + EMEnt + EMAct ; |
||
1860 | end ;
|
||
1861 | 3 : // Thermor?gulation |
||
1862 | for h := 1 to PresSimulT.NbJSim do |
||
1863 | begin
|
||
1864 | EMThe := PresSimulT.TabResult[75, h] ;
|
||
1865 | v := v + EMThe ; |
||
1866 | end ;
|
||
1867 | 4 : // Extrachaleur |
||
1868 | if CBNRJ3.ItemIndex <= 2 |
||
1869 | then // EB ou ED ou EM |
||
1870 | for h := 1 to PresSimulT.NbJSim do |
||
1871 | begin
|
||
1872 | Chaleur := PresSimulT.TabResult[70, h] ;
|
||
1873 | EMEnt := PresSimulT.TabResult[74, h] ;
|
||
1874 | EMThe := PresSimulT.TabResult[75, h] ;
|
||
1875 | EMAct := PresSimulT.TabResult[76, h] ;
|
||
1876 | if PresSimulT.TabResult[3, h] = 1 |
||
1877 | then // Lactation |
||
1878 | begin
|
||
1879 | EMIng := PresSimulT.TabResult[72, h] ;
|
||
1880 | EMProd := PresSimulT.TabResult[77, h] ;
|
||
1881 | EMRes := EMIng - EMEnt - EMThe - EMAct - EMProd ; |
||
1882 | if EMRes > 0 |
||
1883 | then // D?p?t |
||
1884 | v := v + Chaleur - EMEnt - EMThe - EMAct |
||
1885 | else // Mobilisation |
||
1886 | v := v + Chaleur - EMEnt - EMThe - EMAct - EMRes * KL / KResL * (1 - KResL) ;
|
||
1887 | end
|
||
1888 | else
|
||
1889 | v := v + Chaleur - EMEnt - EMThe - EMAct ; |
||
1890 | end ;
|
||
1891 | 5 : // Port?e |
||
1892 | for h := 1 to PresSimulT.NbJSim do |
||
1893 | if PresSimulT.TabResult[3, h] = 0 |
||
1894 | then // Gestation |
||
1895 | begin
|
||
1896 | ENProd := PresSimulT.TabResult[77, h] * KU ;
|
||
1897 | ENProt := PresSimulT.TabResult[63, h] * 23.8 / 1000 ; |
||
1898 | ENLip := PresSimulT.TabResult[66, h] * 39.7 / 1000 ; |
||
1899 | Deficit := Abs (Min (ENProt, 0) + Min (ENLip, 0)) ; |
||
1900 | if Deficit > Max (ENProt, 0) |
||
1901 | then // Deficit |
||
1902 | v := v + Max (ENProd + Max (ENProt, 0) - Deficit, 0) |
||
1903 | else
|
||
1904 | v := v + ENProd ; |
||
1905 | end ;
|
||
1906 | 6 : // Lait |
||
1907 | for h := 1 to PresSimulT.NbJSim do |
||
1908 | if PresSimulT.TabResult[3, h] = 1 |
||
1909 | then // Lactation |
||
1910 | begin
|
||
1911 | ENProd := PresSimulT.TabResult[77, h] * KL ;
|
||
1912 | ENProt := PresSimulT.TabResult[63, h] * 23.8 / 1000 ; |
||
1913 | ENLip := PresSimulT.TabResult[66, h] * 39.7 / 1000 ; |
||
1914 | Deficit := Abs (Min (ENProt, 0) + Min (ENLip, 0)) * KResL ; |
||
1915 | v := v + Max (ENProd - Deficit, 0) ;
|
||
1916 | end ;
|
||
1917 | 7 : // d?p?t de prot?ines |
||
1918 | for h := 1 to PresSimulT.NbJSim do |
||
1919 | if PresSimulT.TabResult[3, h] <> 1 |
||
1920 | then // Gestation ou ISSF |
||
1921 | begin
|
||
1922 | ENProt := PresSimulT.TabResult[63, h] * 23.8 / 1000 ; |
||
1923 | ENLip := PresSimulT.TabResult[66, h] * 39.7 / 1000 ; |
||
1924 | Deficit := Abs (Min (ENProt, 0) + Min (ENLip, 0)) ; |
||
1925 | v := v + Max (ENProt - Deficit, 0) ;
|
||
1926 | end ;
|
||
1927 | 8 : // D?p?t de lipides |
||
1928 | for h := 1 to PresSimulT.NbJSim do |
||
1929 | begin
|
||
1930 | ENLip := PresSimulT.TabResult[66, h] * 39.7 / 1000 ; |
||
1931 | v := v + Max (ENLip, 0) ;
|
||
1932 | end ;
|
||
1933 | 9 : // D?ficit (mobilisation) |
||
1934 | for h := 1 to PresSimulT.NbJSim do |
||
1935 | begin
|
||
1936 | ENProt := PresSimulT.TabResult[63, h] * 23.8 / 1000 ; |
||
1937 | ENLip := PresSimulT.TabResult[66, h] * 39.7 / 1000 ; |
||
1938 | if PresSimulT.TabResult[3, h] = 1 |
||
1939 | then // Lactation |
||
1940 | begin
|
||
1941 | ENProd := PresSimulT.TabResult[77, h] * KL ;
|
||
1942 | Deficit := (Max (- ENProt, 0) + Max (- ENLip, 0)) * KResL ; |
||
1943 | if Deficit > ENProd
|
||
1944 | then // on limite le d?ficit ? la production de lait |
||
1945 | Deficit := ENProd ; |
||
1946 | end
|
||
1947 | else
|
||
1948 | Deficit := Max (- ENProt, 0) + Max (- ENLip, 0) ; |
||
1949 | v := v + Deficit ; |
||
1950 | end ;
|
||
1951 | end ;
|
||
1952 | result := v / d ; |
||
1953 | end ;
|
||
1954 | |||
1955 | // AffGraphNRJ
|
||
1956 | begin
|
||
1957 | ResetGraph ; |
||
1958 | Graph.LeftAxis.Title.Caption := Format ('%s (%s)', [CBNRJ3.Text, CBNRJ4.Text]) ;
|
||
1959 | Graph.Title.Text.Add (CBNRJ3.Text) ; |
||
1960 | Graph.Legend.Inverted := TRUE ; |
||
1961 | case FSimulT.PC.ActivePageIndex of |
||
1962 | 1 : // Comparaison |
||
1963 | Graph.BottomAxis.Title.Caption := 'Simulation' ;
|
||
1964 | 2 : // Sensibilit? |
||
1965 | Graph.BottomAxis.Title.Caption := 'Variation' ;
|
||
1966 | end ;
|
||
1967 | // Affichage des barres
|
||
1968 | for i := 0 to ListNRJ.Count - 1 do |
||
1969 | BarNRJ[i].Active := TRUE ; |
||
1970 | for i := 0 to ListNRJ.Count - 1 do |
||
1971 | BarNRJ[i].Clear ; |
||
1972 | if CBNRJ4.ItemIndex = 3 |
||
1973 | then
|
||
1974 | for i := 0 to ListNRJ.Count - 1 do |
||
1975 | BarNRJ[i].MultiBar := mbStacked100 |
||
1976 | else
|
||
1977 | for i := 0 to ListNRJ.Count - 1 do |
||
1978 | BarNRJ[i].MultiBar := mbStacked ; |
||
1979 | for i := 0 to ListNRJ.Count - 1 do |
||
1980 | for k := 1 to 5 do |
||
1981 | if TabSimulT[k].Ok
|
||
1982 | then
|
||
1983 | begin
|
||
1984 | PResSimulT := TabSimulT[k].Result ; |
||
1985 | case FSimulT.PC.ActivePageIndex of |
||
1986 | 1 : // Comparaison |
||
1987 | s := Format ('%d', [k]) ;
|
||
1988 | 2 : // Sensibilit? |
||
1989 | s := Format ('%1.0f %%', [TabSimulT[k].Variation * 100]) ; |
||
1990 | end ;
|
||
1991 | y := NRJY ; |
||
1992 | if y > PICO
|
||
1993 | then
|
||
1994 | BarNRJ[i].AddBar (y, s, clTeeColor) |
||
1995 | else
|
||
1996 | BarNRJ[i].AddNull (s) ; |
||
1997 | end ;
|
||
1998 | AjustEchelle (Graph) ; |
||
1999 | end ;
|
||
2000 | |||
2001 | procedure TFCompSimulT.CBNRJ2Change (Sender : TObject) ;
|
||
2002 | begin
|
||
2003 | AffGraphNRJ ; |
||
2004 | end ;
|
||
2005 | |||
2006 | procedure TFCompSimulT.CBNRJ3Change (Sender : TObject) ;
|
||
2007 | begin
|
||
2008 | AffGraphNRJ ; |
||
2009 | end ;
|
||
2010 | |||
2011 | procedure TFCompSimulT.CBNRJ4Change (Sender : TObject) ;
|
||
2012 | begin
|
||
2013 | AffGraphNRJ ; |
||
2014 | end ;
|
||
2015 | |||
2016 | //////////////////
|
||
2017 | // Min?raux //
|
||
2018 | //////////////////
|
||
2019 | procedure TFCompSimulT.InitMin ;
|
||
2020 | const
|
||
2021 | TabColor1 : array[0..6] of TColor |
||
2022 | = (clTeal, clOlive, clPurple, clPink, clWhite, clRed, clGreen) ; |
||
2023 | TabColor2 : array[1..5] of TColor |
||
2024 | = (clRed, clGreen, clYellow, clBlue, clFuchsia) ; |
||
2025 | var
|
||
2026 | i, k : integer ; |
||
2027 | begin
|
||
2028 | // ListMin : liste pour les min?raux
|
||
2029 | ListMin := TStringList.Create ; |
||
2030 | ListMin.Assign (LBMin.Items) ; |
||
2031 | // BarMin : s?ries (barres) graphiques
|
||
2032 | SetLength (BarMin, ListMin.Count) ; |
||
2033 | for i := 0 to ListMin.Count - 1 do |
||
2034 | begin
|
||
2035 | BarMin[i] := TBarSeries.Create (Graph) ; |
||
2036 | BarMin[i].ParentChart := Graph ; |
||
2037 | BarMin[i].Title := ListMin[i] ; |
||
2038 | BarMin[i].SeriesColor := TabColor1[i] ; |
||
2039 | BarMin[i].BarPen.Color := BarMin[i].SeriesColor ; |
||
2040 | BarMin[i].Marks.Visible := FALSE ; |
||
2041 | Graph.AddSeries (BarMin[i]) ; |
||
2042 | end ;
|
||
2043 | // LineMin : s?ries (lignes) graphiques
|
||
2044 | for k := 1 to 5 do |
||
2045 | if TabSimulT[k].Ok
|
||
2046 | then
|
||
2047 | begin
|
||
2048 | LineMin[k] := TLineSeries.Create (Graph) ; |
||
2049 | LineMin[k].ParentChart := Graph ; |
||
2050 | case FSimulT.PC.ActivePageIndex of |
||
2051 | 1 : // Comparaison |
||
2052 | LineMin[k].Title := Format ('Simulation %d', [k]) ;
|
||
2053 | 2 : // Sensibilit? |
||
2054 | LineMin[k].Title := Format ('%1.0f %%', [TabSimulT[k].Variation * 100]) ; |
||
2055 | end ;
|
||
2056 | LineMin[k].SeriesColor := TabColor2[k] ; |
||
2057 | LineMin[k].LinePen.Color := LineMin[k].SeriesColor ; |
||
2058 | LineMin[k].LinePen.Width := 2 ;
|
||
2059 | Graph.AddSeries (LineMin[k]) ; |
||
2060 | end ;
|
||
2061 | end ;
|
||
2062 | |||
2063 | procedure TFCompSimulT.AffGraphMin ;
|
||
2064 | var
|
||
2065 | i, j, k : integer ; |
||
2066 | y : double ; |
||
2067 | s : string ;
|
||
2068 | |||
2069 | // Abscisse
|
||
2070 | function MinX : double ;
|
||
2071 | begin
|
||
2072 | case CBMin1.ItemIndex of |
||
2073 | 1, 2 : // Apport ou besoin |
||
2074 | case CBMin2.ItemIndex of |
||
2075 | 0 : // Age |
||
2076 | result := PResSimulT.TabResult[1, j] ;
|
||
2077 | 1 : // Dur?e |
||
2078 | result := j - 1 ;
|
||
2079 | else
|
||
2080 | result := 0 ;
|
||
2081 | end ;
|
||
2082 | else
|
||
2083 | result := 0 ;
|
||
2084 | end ;
|
||
2085 | end ;
|
||
2086 | |||
2087 | // Ordonn?e
|
||
2088 | function MinY : double ;
|
||
2089 | var
|
||
2090 | h, Cycle, Jour : integer ; |
||
2091 | v, d, Ptot, Pdig, PVtot, PVnet, GMQnet, PdsPortee, NesT, Foetus, Placenta, |
||
2092 | Indigestible, Entretien, Portee, Retenu, Lait : double ; |
||
2093 | |||
2094 | // Composition des aliments
|
||
2095 | procedure Composition (jour : integer) ;
|
||
2096 | var
|
||
2097 | Aliment1, Aliment2 : integer ; |
||
2098 | IngereFrais, Taux1, Taux2, IngereSec1, IngereSec2, Ptot1, Ptot2, Pdig1, Pdig2 : double ; |
||
2099 | CC1, CC2 : CompositionChimique ; |
||
2100 | begin
|
||
2101 | IngereFrais := PresSimulT.TabResult[11, jour] ;
|
||
2102 | // Aliment 1
|
||
2103 | Aliment1 := Round (PresSimulT.TabResult[7, jour]) ;
|
||
2104 | if Aliment1 = -1 |
||
2105 | then
|
||
2106 | CC1 := CCVide |
||
2107 | else
|
||
2108 | begin
|
||
2109 | PAliment := ListAliment[FindIdxAliment (FindNomAliment (Aliment1))] ; |
||
2110 | CC1 := PAliment.CC ; |
||
2111 | end ;
|
||
2112 | Taux1 := PresSimulT.TabResult[9, jour] / 100 ; |
||
2113 | IngereSec1 := IngereFrais * Taux1 * CC1.MS / 1000 ;
|
||
2114 | Ptot1 := IngereSec1 * CC1.P ; |
||
2115 | if Aliment1 = -1 |
||
2116 | then
|
||
2117 | Pdig1 := 0
|
||
2118 | else
|
||
2119 | if PAliment.Presentation = 0 |
||
2120 | then // Granul?s |
||
2121 | Pdig1 := IngereSec1 * PAliment.CC.PdigG |
||
2122 | else // Farine |
||
2123 | Pdig1 := IngereSec1 * PAliment.CC.PdigF ; |
||
2124 | // Aliment 2
|
||
2125 | Aliment2 := Round (PresSimulT.TabResult[8, jour]) ;
|
||
2126 | if Aliment2 = -1 |
||
2127 | then
|
||
2128 | CC2 := CCVide |
||
2129 | else
|
||
2130 | begin
|
||
2131 | PAliment := ListAliment[FindIdxAliment (FindNomAliment (Aliment2))] ; |
||
2132 | CC2 := PAliment.CC ; |
||
2133 | end ;
|
||
2134 | Taux2 := PresSimulT.TabResult[10, jour] / 100 ; |
||
2135 | IngereSec2 := IngereFrais * Taux2 * CC2.MS / 1000 ;
|
||
2136 | Ptot2 := IngereSec2 * CC2.P ; |
||
2137 | if Aliment2 = -1 |
||
2138 | then
|
||
2139 | Pdig2 := 0
|
||
2140 | else
|
||
2141 | if PAliment.Presentation = 0 |
||
2142 | then // Granul?s |
||
2143 | Pdig2 := IngereSec2 * PAliment.CC.PdigG |
||
2144 | else // Farine |
||
2145 | Pdig2 := IngereSec2 * PAliment.CC.PdigF ; |
||
2146 | // Cumul
|
||
2147 | Ptot := Ptot1 + Ptot2 ; |
||
2148 | Pdig := Pdig1 + Pdig2 ; |
||
2149 | end ;
|
||
2150 | |||
2151 | begin
|
||
2152 | case CBMin1.ItemIndex of |
||
2153 | 0 : // R?partition |
||
2154 | begin
|
||
2155 | // Diviseur
|
||
2156 | case CBMin4.ItemIndex of |
||
2157 | 1 : // Dur?e |
||
2158 | d := PresSimulT.NbJSim ; |
||
2159 | 2 : // Aliment ing?r? |
||
2160 | begin
|
||
2161 | d := 0 ;
|
||
2162 | for h := 1 to PresSimulT.NbJSim do |
||
2163 | d := d + PresSimulT.TabResult[11, h] ;
|
||
2164 | end ;
|
||
2165 | else
|
||
2166 | d := 1 ;
|
||
2167 | end ;
|
||
2168 | v := 0 ;
|
||
2169 | case CBMin3.ItemIndex of |
||
2170 | 0 : // Phosphore |
||
2171 | case i of |
||
2172 | 0 : // Indigestible |
||
2173 | if CBMin5A.ItemIndex = 1 |
||
2174 | then // Total |
||
2175 | for h := 1 to PresSimulT.NbJSim do |
||
2176 | begin
|
||
2177 | Composition (h) ; |
||
2178 | Indigestible := Ptot - Pdig ; |
||
2179 | v := v + Indigestible ; |
||
2180 | end ;
|
||
2181 | 1 : // Entretien |
||
2182 | for h := 1 to PresSimulT.NbJSim do |
||
2183 | begin
|
||
2184 | Composition (h) ; |
||
2185 | Indigestible := Ptot - Pdig ; |
||
2186 | PVtot := PResSimulT.TabResult[58, h] ;
|
||
2187 | Entretien := 10 * PVtot / 1000 ; |
||
2188 | if Ptot < Indigestible + Entretien
|
||
2189 | then // D?ficit |
||
2190 | v := v + Ptot - Indigestible |
||
2191 | else
|
||
2192 | v := v + Entretien ; |
||
2193 | end ;
|
||
2194 | 2 : // Port?e |
||
2195 | for h := 1 to PresSimulT.NbJSim do |
||
2196 | if PResSimulT.TabResult[3, h] = 0 |
||
2197 | then // Gestation |
||
2198 | begin
|
||
2199 | Composition (h) ; |
||
2200 | Indigestible := Ptot - Pdig ; |
||
2201 | PVtot := PResSimulT.TabResult[58, h] ;
|
||
2202 | Entretien := 10 * PVtot / 1000 ; |
||
2203 | Cycle := Trunc(PResSimulT.TabResult[2, h]) ;
|
||
2204 | with PPRofilT.Porcelets[Cycle] do |
||
2205 | begin
|
||
2206 | PdsPortee := NesTotaux * PdsNais ; |
||
2207 | NesT := NesTotaux ; |
||
2208 | end ;
|
||
2209 | Jour := Trunc(PResSimulT.TabResult[78, h]) ;
|
||
2210 | Foetus := 6.25 * 6.389 * 0.023998 * PdsPortee |
||
2211 | * Exp(-0.023998 * (Jour - 45) |
||
2212 | - 6.389 * Exp(-0.023998 * (Jour - 45)) |
||
2213 | + 6.389 * Exp(-0.023998 * (115 - 45))) ; |
||
2214 | Placenta := (1.40598 * 0.06250 * Exp(-0.06250 * (Jour - 45)) + 0.00759) |
||
2215 | * Exp(7.34264 - 1.40598 * Exp(-0.06250 * (Jour - 45)) |
||
2216 | + 0.00759 * Jour + 0.06339 * NesT) |
||
2217 | * 0.0096 / 23.8 ; |
||
2218 | Portee := Foetus + Placenta ; |
||
2219 | if Ptot < Indigestible + Entretien + Portee
|
||
2220 | then // D?ficit |
||
2221 | v := v + Max (Ptot - Indigestible - Entretien, 0)
|
||
2222 | else
|
||
2223 | v := v + Portee ; |
||
2224 | end ;
|
||
2225 | 3 : // Retenu |
||
2226 | for h := 1 to PresSimulT.NbJSim do |
||
2227 | if PResSimulT.TabResult[3, h] <> 1 |
||
2228 | then // Gestation ou ISSF |
||
2229 | begin
|
||
2230 | Composition (h) ; |
||
2231 | Indigestible := Ptot - Pdig ; |
||
2232 | PVtot := PResSimulT.TabResult[58, h] ;
|
||
2233 | Entretien := 10 * PVtot / 1000 ; |
||
2234 | if PResSimulT.TabResult[3, h] = 0 |
||
2235 | then // Gestation |
||
2236 | begin
|
||
2237 | Cycle := Trunc(PResSimulT.TabResult[2, h]) ;
|
||
2238 | with PPRofilT.Porcelets[Cycle] do |
||
2239 | begin
|
||
2240 | PdsPortee := NesTotaux * PdsNais ; |
||
2241 | NesT := NesTotaux ; |
||
2242 | end ;
|
||
2243 | Jour := Trunc(PResSimulT.TabResult[78, h]) ;
|
||
2244 | Foetus := 6.25 * 6.389 * 0.023998 * PdsPortee |
||
2245 | * Exp(-0.023998 * (Jour - 45) |
||
2246 | - 6.389 * Exp(-0.023998 * (Jour - 45)) |
||
2247 | + 6.389 * Exp(-0.023998 * (115 - 45))) ; |
||
2248 | Placenta := (1.40598 * 0.06250 * Exp(-0.06250 * (Jour - 45)) + 0.00759) |
||
2249 | * Exp(7.34264 - 1.40598 * Exp(-0.06250 * (Jour - 45)) |
||
2250 | + 0.00759 * Jour + 0.06339 * NesT) |
||
2251 | * 0.0096 / 23.8 ; |
||
2252 | Portee := Foetus + Placenta ; |
||
2253 | end
|
||
2254 | else
|
||
2255 | Portee := 0 ;
|
||
2256 | PVnet := PResSimulT.TabResult[60, h] ;
|
||
2257 | GMQnet := PResSimulT.TabResult[61, h] ;
|
||
2258 | Retenu := Max ((5.4199 - 2 * 0.002857 * PVnet) * GMQnet, 0) ; |
||
2259 | if Ptot < Indigestible + Entretien + Portee + Retenu
|
||
2260 | then // D?ficit |
||
2261 | v := v + Max (Ptot - Indigestible - Entretien - Portee, 0)
|
||
2262 | else
|
||
2263 | v := v + Retenu ; |
||
2264 | end ;
|
||
2265 | 4 : // Lait |
||
2266 | for h := 1 to PresSimulT.NbJSim do |
||
2267 | if PResSimulT.TabResult[3, h] = 1 |
||
2268 | then // Lactation |
||
2269 | begin
|
||
2270 | Composition (h) ; |
||
2271 | Indigestible := Ptot - Pdig ; |
||
2272 | PVtot := PResSimulT.TabResult[58, h] ;
|
||
2273 | Entretien := 10 * PVtot / 1000 ; |
||
2274 | Lait := PResSimulT.TabResult[69, h] * 1.55 ; |
||
2275 | if Ptot < Indigestible + Entretien + Lait
|
||
2276 | then // D?ficit |
||
2277 | v := v + Max (Ptot - Indigestible - Entretien, 0)
|
||
2278 | else
|
||
2279 | v := v + Lait ; |
||
2280 | end ;
|
||
2281 | 5 : // D?ficit |
||
2282 | for h := 1 to PresSimulT.NbJSim do |
||
2283 | begin
|
||
2284 | Composition (h) ; |
||
2285 | Indigestible := Ptot - Pdig ; |
||
2286 | PVtot := PResSimulT.TabResult[58, h] ;
|
||
2287 | Entretien := 10 * PVtot / 1000 ; |
||
2288 | if PResSimulT.TabResult[3, h] = 0 |
||
2289 | then // Gestation |
||
2290 | begin
|
||
2291 | Cycle := Trunc(PResSimulT.TabResult[2, h]) ;
|
||
2292 | with PPRofilT.Porcelets[Cycle] do |
||
2293 | begin
|
||
2294 | PdsPortee := NesTotaux * PdsNais ; |
||
2295 | NesT := NesTotaux ; |
||
2296 | end ;
|
||
2297 | Jour := Trunc(PResSimulT.TabResult[78, h]) ;
|
||
2298 | Foetus := 6.25 * 6.389 * 0.023998 * PdsPortee |
||
2299 | * Exp(-0.023998 * (Jour - 45) |
||
2300 | - 6.389 * Exp(-0.023998 * (Jour - 45)) |
||
2301 | + 6.389 * Exp(-0.023998 * (115 - 45))) ; |
||
2302 | Placenta := (1.40598 * 0.06250 * Exp(-0.06250 * (Jour - 45)) + 0.00759) |
||
2303 | * Exp(7.34264 - 1.40598 * Exp(-0.06250 * (Jour - 45)) |
||
2304 | + 0.00759 * Jour + 0.06339 * NesT) |
||
2305 | * 0.0096 / 23.8 ; |
||
2306 | Portee := Foetus + Placenta ; |
||
2307 | end
|
||
2308 | else
|
||
2309 | Portee := 0 ;
|
||
2310 | if PResSimulT.TabResult[3, h] <> 1 |
||
2311 | then // Gestation ou ISSF |
||
2312 | begin
|
||
2313 | PVnet := PResSimulT.TabResult[60, h] ;
|
||
2314 | GMQnet := PResSimulT.TabResult[61, h] ;
|
||
2315 | Retenu := Max ((5.4199 - 2 * 0.002857 * PVnet) * GMQnet, 0) ; |
||
2316 | end
|
||
2317 | else
|
||
2318 | Retenu := 0 ;
|
||
2319 | if PResSimulT.TabResult[3, h] = 1 |
||
2320 | then // Lactation |
||
2321 | Lait := PResSimulT.TabResult[69, h] * 1.55 |
||
2322 | else
|
||
2323 | Lait := 0 ;
|
||
2324 | if Ptot < Indigestible + Entretien + Portee + Retenu + Lait
|
||
2325 | then
|
||
2326 | v := v + Indigestible + Entretien + Portee + Retenu + Lait - Ptot ; |
||
2327 | end ;
|
||
2328 | 6 : // Exc?s |
||
2329 | for h := 1 to PresSimulT.NbJSim do |
||
2330 | begin
|
||
2331 | Composition (h) ; |
||
2332 | Indigestible := Ptot - Pdig ; |
||
2333 | PVtot := PResSimulT.TabResult[58, h] ;
|
||
2334 | Entretien := 10 * PVtot / 1000 ; |
||
2335 | if PResSimulT.TabResult[3, h] = 0 |
||
2336 | then // Gestation |
||
2337 | begin
|
||
2338 | Cycle := Trunc(PResSimulT.TabResult[2, h]) ;
|
||
2339 | with PPRofilT.Porcelets[Cycle] do |
||
2340 | begin
|
||
2341 | PdsPortee := NesTotaux * PdsNais ; |
||
2342 | NesT := NesTotaux ; |
||
2343 | end ;
|
||
2344 | Jour := Trunc(PResSimulT.TabResult[78, h]) ;
|
||
2345 | Foetus := 6.25 * 6.389 * 0.023998 * PdsPortee |
||
2346 | * Exp(-0.023998 * (Jour - 45) |
||
2347 | - 6.389 * Exp(-0.023998 * (Jour - 45)) |
||
2348 | + 6.389 * Exp(-0.023998 * (115 - 45))) ; |
||
2349 | Placenta := (1.40598 * 0.06250 * Exp(-0.06250 * (Jour - 45)) + 0.00759) |
||
2350 | * Exp(7.34264 - 1.40598 * Exp(-0.06250 * (Jour - 45)) |
||
2351 | + 0.00759 * Jour + 0.06339 * NesT) |
||
2352 | * 0.0096 / 23.8 ; |
||
2353 | Portee := Foetus + Placenta ; |
||
2354 | end
|
||
2355 | else
|
||
2356 | Portee := 0 ;
|
||
2357 | if PResSimulT.TabResult[3, h] <> 1 |
||
2358 | then // Gestation ou ISSF |
||
2359 | begin
|
||
2360 | PVnet := PResSimulT.TabResult[60, h] ;
|
||
2361 | GMQnet := PResSimulT.TabResult[61, h] ;
|
||
2362 | Retenu := Max ((5.4199 - 2 * 0.002857 * PVnet) * GMQnet, 0) ; |
||
2363 | end
|
||
2364 | else
|
||
2365 | Retenu := 0 ;
|
||
2366 | if PResSimulT.TabResult[3, h] = 1 |
||
2367 | then // Lactation |
||
2368 | Lait := PResSimulT.TabResult[69, h] * 1.55 |
||
2369 | else
|
||
2370 | Lait := 0 ;
|
||
2371 | if Ptot > Indigestible + Entretien + Portee + Retenu + Lait
|
||
2372 | then
|
||
2373 | v := v + Ptot - Indigestible - Entretien - Portee - Retenu - Lait ; |
||
2374 | end ;
|
||
2375 | end ;
|
||
2376 | end ;
|
||
2377 | result := v / d ; |
||
2378 | end ;
|
||
2379 | 1 : // Apport |
||
2380 | begin
|
||
2381 | // Diviseur
|
||
2382 | if CBMin4.ItemIndex = 1 |
||
2383 | then // Aliment ing?r? |
||
2384 | d := PResSimulT.TabResult[11, j]
|
||
2385 | else
|
||
2386 | d := 1 ;
|
||
2387 | case CBMin3.ItemIndex of |
||
2388 | 0 : // Phosphore |
||
2389 | begin
|
||
2390 | Composition (j) ; |
||
2391 | if CBMin5A.ItemIndex = 0 |
||
2392 | then // Digestibilit? apparente |
||
2393 | v := Pdig |
||
2394 | else // Total |
||
2395 | v := Ptot ; |
||
2396 | end ;
|
||
2397 | else
|
||
2398 | v := 0 ;
|
||
2399 | end ;
|
||
2400 | result := v / d ; |
||
2401 | end ;
|
||
2402 | 2 : // Besoin |
||
2403 | begin
|
||
2404 | // Diviseur
|
||
2405 | if CBMin4.ItemIndex = 1 |
||
2406 | then // Aliment ing?r? |
||
2407 | d := PResSimulT.TabResult[11, j]
|
||
2408 | else
|
||
2409 | d := 1 ;
|
||
2410 | case CBMin3.ItemIndex of |
||
2411 | 0 : // Phosphore |
||
2412 | begin
|
||
2413 | PVtot := PResSimulT.TabResult[58, j] ;
|
||
2414 | Entretien := 10 * PVtot / 1000 ; |
||
2415 | if PResSimulT.TabResult[3, j] = 0 |
||
2416 | then // Gestation |
||
2417 | begin
|
||
2418 | Cycle := Trunc(PResSimulT.TabResult[2, j]) ;
|
||
2419 | with PPRofilT.Porcelets[Cycle] do |
||
2420 | begin
|
||
2421 | PdsPortee := NesTotaux * PdsNais ; |
||
2422 | NesT := NesTotaux ; |
||
2423 | end ;
|
||
2424 | Jour := Trunc(PResSimulT.TabResult[78, j]) ;
|
||
2425 | Foetus := 6.25 * 6.389 * 0.023998 * PdsPortee |
||
2426 | * Exp(-0.023998 * (Jour - 45) |
||
2427 | - 6.389 * Exp(-0.023998 * (Jour - 45)) |
||
2428 | + 6.389 * Exp(-0.023998 * (115 - 45))) ; |
||
2429 | Placenta := (1.40598 * 0.06250 * Exp(-0.06250 * (Jour - 45)) + 0.00759) |
||
2430 | * Exp(7.34264 - 1.40598 * Exp(-0.06250 * (Jour - 45)) |
||
2431 | + 0.00759 * Jour + 0.06339 * NesT) |
||
2432 | * 0.0096 / 23.8 ; |
||
2433 | Portee := Foetus + Placenta ; |
||
2434 | end
|
||
2435 | else
|
||
2436 | Portee := 0 ;
|
||
2437 | if PResSimulT.TabResult[3, j] <> 1 |
||
2438 | then // Gestation ou ISSF |
||
2439 | begin
|
||
2440 | PVnet := PResSimulT.TabResult[60, j] ;
|
||
2441 | GMQnet := PResSimulT.TabResult[61, j] ;
|
||
2442 | Retenu := Max ((5.4199 - 2 * 0.002857 * PVnet) * GMQnet, 0) ; |
||
2443 | end
|
||
2444 | else
|
||
2445 | Retenu := 0 ;
|
||
2446 | if PResSimulT.TabResult[3, j] = 1 |
||
2447 | then // Lactation |
||
2448 | Lait := PResSimulT.TabResult[69, j] * 1.55 |
||
2449 | else
|
||
2450 | Lait := 0 ;
|
||
2451 | v := Entretien + Portee + Retenu + Lait ; |
||
2452 | end ;
|
||
2453 | else
|
||
2454 | v := 0 ;
|
||
2455 | end ;
|
||
2456 | result := v / d ; |
||
2457 | end ;
|
||
2458 | else
|
||
2459 | result := 0 ;
|
||
2460 | end ;
|
||
2461 | end ;
|
||
2462 | |||
2463 | // AffGraphMin
|
||
2464 | begin
|
||
2465 | ResetGraph ; |
||
2466 | Graph.Title.Text.Add (Format ('%s : %s', [CBMin3.Text, CBMin1.Text])) ;
|
||
2467 | if CBMin1.ItemIndex = 1 |
||
2468 | then // Besoin |
||
2469 | Graph.SubTitle.Text.Add (CBMin5B.Text) |
||
2470 | else
|
||
2471 | Graph.SubTitle.Text.Add (CBMin5A.Text) ; |
||
2472 | Graph.LeftAxis.Title.Caption := Format ('%s (%s)', [CBMin3.Text, CBMin4.Text]) ;
|
||
2473 | case CBMin1.ItemIndex of |
||
2474 | 0 : // R?partition |
||
2475 | begin
|
||
2476 | Graph.Legend.Inverted := TRUE ; |
||
2477 | case FSimulT.PC.ActivePageIndex of |
||
2478 | 1 : // Comparaison |
||
2479 | Graph.BottomAxis.Title.Caption := 'Simulation' ;
|
||
2480 | 2 : // Sensibilit? |
||
2481 | Graph.BottomAxis.Title.Caption := 'Variation' ;
|
||
2482 | end ;
|
||
2483 | // Affichage des barres
|
||
2484 | for i := 0 to ListMin.Count - 1 do |
||
2485 | BarMin[i].Active := TRUE ; |
||
2486 | for i := 0 to ListMin.Count - 1 do |
||
2487 | BarMin[i].Clear ; |
||
2488 | if CBMin4.ItemIndex = 3 |
||
2489 | then
|
||
2490 | for i := 0 to ListMin.Count - 1 do |
||
2491 | BarMin[i].MultiBar := mbStacked100 |
||
2492 | else
|
||
2493 | for i := 0 to ListMin.Count - 1 do |
||
2494 | BarMin[i].MultiBar := mbStacked ; |
||
2495 | for i := 0 to ListMin.Count - 1 do |
||
2496 | for k := 1 to 5 do |
||
2497 | if TabSimulT[k].Ok
|
||
2498 | then
|
||
2499 | begin
|
||
2500 | PResSimulT := TabSimulT[k].Result ; |
||
2501 | PSimulT := ListSimulT[FindIdxSimulT(FindNomSimulT(TabSimulT[k].Simul))] ; |
||
2502 | PProfilT := ListProfilT[FindIdxProfilT(FindNomProfilT(PSimulT.Profil))] ; |
||
2503 | case FSimulT.PC.ActivePageIndex of |
||
2504 | 1 : // Comparaison |
||
2505 | s := Format ('%d', [k]) ;
|
||
2506 | 2 : // Sensibilit? |
||
2507 | s := Format ('%1.0f %%', [TabSimulT[k].Variation * 100]) ; |
||
2508 | end ;
|
||
2509 | y := MinY ; |
||
2510 | if y > PICO
|
||
2511 | then
|
||
2512 | BarMin[i].AddBar (y, s, clTeeColor) |
||
2513 | else
|
||
2514 | BarMin[i].AddNull (s) ; |
||
2515 | end ;
|
||
2516 | end ;
|
||
2517 | 1, 2 : // Apport ou besoin |
||
2518 | begin
|
||
2519 | Graph.Legend.Inverted := FALSE ; |
||
2520 | Graph.BottomAxis.Title.Caption := CBMin2.Text ; |
||
2521 | // Affichage des lignes
|
||
2522 | for k := 1 to 5 do |
||
2523 | if TabSimulT[k].Ok
|
||
2524 | then
|
||
2525 | begin
|
||
2526 | LineMin[k].Active := TRUE ; |
||
2527 | LineMin[k].Clear ; |
||
2528 | PResSimulT := TabSimulT[k].Result ; |
||
2529 | for j := 1 to PresSimulT.NbJSim do |
||
2530 | LineMin[k].AddXY (MinX, MinY, '', clTeeColor) ;
|
||
2531 | end ;
|
||
2532 | end ;
|
||
2533 | end ;
|
||
2534 | AjustEchelle (Graph) ; |
||
2535 | end ;
|
||
2536 | |||
2537 | procedure TFCompSimulT.CBMin1Change(Sender: TObject);
|
||
2538 | begin
|
||
2539 | CBMin4.Items.Clear ; |
||
2540 | case CBMin1.ItemIndex of |
||
2541 | 0 : // R?partition |
||
2542 | begin
|
||
2543 | CBMin2.Visible := FALSE ; |
||
2544 | CBMin5A.Visible := TRUE ; |
||
2545 | CBMin5B.Visible := FALSE ; |
||
2546 | // Unit?s
|
||
2547 | CBMin4.Items.Add (StrG) ; |
||
2548 | CBMin4.Items.Add (Format ('%s/%s', [StrG, StrJ])) ;
|
||
2549 | CBMin4.Items.Add (Format ('%s/%s %s', [StrG, StrKg, StrAlimentUnit])) ;
|
||
2550 | CBMin4.Items.Add ('%') ;
|
||
2551 | end ;
|
||
2552 | 1, 2 : // Apport ou besoin |
||
2553 | begin
|
||
2554 | CBMin2.Visible := TRUE ; |
||
2555 | CBMin5A.Visible := (CBMin1.ItemIndex = 1) ;
|
||
2556 | CBMin5B.Visible := (CBMin1.ItemIndex = 2) ;
|
||
2557 | // Unit?s
|
||
2558 | CBMin4.Items.Add (Format ('%s/%s', [StrG, StrJ])) ;
|
||
2559 | CBMin4.Items.Add (Format ('%s/%s %s', [StrG, StrKg, StrAlimentUnit])) ;
|
||
2560 | end ;
|
||
2561 | end ;
|
||
2562 | if CBMin1.ItemIndex = 2 |
||
2563 | then // Besoin |
||
2564 | if CBMin5A.ItemIndex = 1 |
||
2565 | then // Total |
||
2566 | CBMin5A.ItemIndex := 0 ;
|
||
2567 | CBMin4.ItemIndex := 0 ;
|
||
2568 | AffGraphMin ; |
||
2569 | end;
|
||
2570 | |||
2571 | procedure TFCompSimulT.CBMin2Change(Sender: TObject);
|
||
2572 | begin
|
||
2573 | AffGraphMin ; |
||
2574 | end;
|
||
2575 | |||
2576 | procedure TFCompSimulT.CBMin3Change(Sender: TObject);
|
||
2577 | begin
|
||
2578 | AffGraphMin ; |
||
2579 | end;
|
||
2580 | |||
2581 | procedure TFCompSimulT.CBMin4Change(Sender: TObject);
|
||
2582 | begin
|
||
2583 | AffGraphMin ; |
||
2584 | end;
|
||
2585 | |||
2586 | procedure TFCompSimulT.CBMin5Change(Sender: TObject);
|
||
2587 | begin
|
||
2588 | if CBMin1.ItemIndex = 2 |
||
2589 | then // Besoin |
||
2590 | CBMin5A.ItemIndex := CBMin5B.ItemIndex |
||
2591 | else
|
||
2592 | if CBMin5A.ItemIndex = 1 |
||
2593 | then // Total |
||
2594 | CBMin5B.ItemIndex := 0
|
||
2595 | else
|
||
2596 | CBMin5B.ItemIndex := CBMin5A.ItemIndex ; |
||
2597 | AffGraphMin ; |
||
2598 | end;
|
||
2599 | |||
2600 | ////////////////
|
||
2601 | // Rejets //
|
||
2602 | ////////////////
|
||
2603 | procedure TFCompSimulT.InitRej ;
|
||
2604 | const
|
||
2605 | TabColor : array[0..3] of TColor |
||
2606 | = (clMaroon, clYellow, clPink, clMaroon) ; |
||
2607 | var
|
||
2608 | i : integer ; |
||
2609 | begin
|
||
2610 | // ListRej : liste pour les rejets
|
||
2611 | ListRej := TStringList.Create ; |
||
2612 | ListRej.Assign (LBRej.Items) ; |
||
2613 | // BarRej : s?ries (barres) graphiques
|
||
2614 | SetLength (BarRej, ListRej.Count) ; |
||
2615 | for i := 0 to ListRej.Count - 1 do |
||
2616 | begin
|
||
2617 | BarRej[i] := TBarSeries.Create (Graph) ; |
||
2618 | BarRej[i].ParentChart := Graph ; |
||
2619 | BarRej[i].Title := ListRej[i] ; |
||
2620 | BarRej[i].SeriesColor := TabColor[i] ; |
||
2621 | BarRej[i].BarPen.Color := BarRej[i].SeriesColor ; |
||
2622 | BarRej[i].Marks.Visible := FALSE ; |
||
2623 | Graph.AddSeries (BarRej[i]) ; |
||
2624 | end ;
|
||
2625 | end ;
|
||
2626 | |||
2627 | procedure TFCompSimulT.AffGraphRej ;
|
||
2628 | var
|
||
2629 | i, k : integer ; |
||
2630 | y : double ; |
||
2631 | s : string ;
|
||
2632 | |||
2633 | // Ordonn?e
|
||
2634 | function RejY : double ;
|
||
2635 | var
|
||
2636 | h : integer ; |
||
2637 | v, d, IngereSec1, IngereSec2, Ptot, Pdig, Ingere, Digestible, Depose, Exporte : double ; |
||
2638 | CC1, CC2 : CompositionChimique ; |
||
2639 | |||
2640 | // Composition des aliments
|
||
2641 | procedure Composition (jour : integer) ;
|
||
2642 | var
|
||
2643 | Aliment1, Aliment2 : integer ; |
||
2644 | IngereFrais, Taux1, Taux2, Ptot1, Ptot2, Pdig1, Pdig2 : double ; |
||
2645 | begin
|
||
2646 | IngereFrais := PresSimulT.TabResult[11, jour] ;
|
||
2647 | // Aliment 1
|
||
2648 | Aliment1 := Round (PresSimulT.TabResult[7, jour]) ;
|
||
2649 | if Aliment1 = -1 |
||
2650 | then
|
||
2651 | CC1 := CCVide |
||
2652 | else
|
||
2653 | begin
|
||
2654 | PAliment := ListAliment[FindIdxAliment (FindNomAliment (Aliment1))] ; |
||
2655 | CC1 := PAliment.CC ; |
||
2656 | end ;
|
||
2657 | Taux1 := PresSimulT.TabResult[9, jour] / 100 ; |
||
2658 | IngereSec1 := IngereFrais * Taux1 * CC1.MS / 1000 ;
|
||
2659 | Ptot1 := IngereSec1 * CC1.P ; |
||
2660 | if Aliment1 = -1 |
||
2661 | then
|
||
2662 | Pdig1 := 0
|
||
2663 | else
|
||
2664 | if PAliment.Presentation = 0 |
||
2665 | then // Granul?s |
||
2666 | Pdig1 := IngereSec1 * PAliment.CC.PdigG |
||
2667 | else // Farine |
||
2668 | Pdig1 := IngereSec1 * PAliment.CC.PdigF ; |
||
2669 | // Aliment 2
|
||
2670 | Aliment2 := Round (PresSimulT.TabResult[8, jour]) ;
|
||
2671 | if Aliment2 = -1 |
||
2672 | then
|
||
2673 | CC2 := CCVide |
||
2674 | else
|
||
2675 | begin
|
||
2676 | PAliment := ListAliment[FindIdxAliment (FindNomAliment (Aliment2))] ; |
||
2677 | CC2 := PAliment.CC ; |
||
2678 | end ;
|
||
2679 | Taux2 := PresSimulT.TabResult[10, jour] / 100 ; |
||
2680 | IngereSec2 := IngereFrais * Taux2 * CC2.MS / 1000 ;
|
||
2681 | Ptot2 := IngereSec2 * CC2.P ; |
||
2682 | if Aliment2 = -1 |
||
2683 | then
|
||
2684 | Pdig2 := 0
|
||
2685 | else
|
||
2686 | if PAliment.Presentation = 0 |
||
2687 | then // Granul?s |
||
2688 | Pdig2 := IngereSec2 * PAliment.CC.PdigG |
||
2689 | else // Farine |
||
2690 | Pdig2 := IngereSec2 * PAliment.CC.PdigF ; |
||
2691 | // Cumul
|
||
2692 | Ptot := Ptot1 + Ptot2 ; |
||
2693 | Pdig := Pdig1 + Pdig2 ; |
||
2694 | end ;
|
||
2695 | |||
2696 | // Calcul de l'ing?r?
|
||
2697 | function CalcIngere : Double ;
|
||
2698 | begin
|
||
2699 | case CBRej3.ItemIndex of |
||
2700 | 0 : // Azote |
||
2701 | result := (IngereSec1*CC1.MAT + IngereSec2*CC2.MAT) * 0.16 ;
|
||
2702 | 1 : // Phosphore |
||
2703 | result := Ptot; |
||
2704 | 2 : // Calcium |
||
2705 | result := IngereSec1*CC1.Ca + IngereSec2*CC2.Ca ; |
||
2706 | 3 : // Potassium |
||
2707 | result := IngereSec1*CC1.K + IngereSec2*CC2.K ; |
||
2708 | 4 : // Cuivre |
||
2709 | result := IngereSec1*CC1.Cu + IngereSec2*CC2.Cu ; |
||
2710 | 5 : // Zinc |
||
2711 | result := IngereSec1*CC1.Zn + IngereSec2*CC2.Zn ; |
||
2712 | else
|
||
2713 | result := 0 ;
|
||
2714 | end ;
|
||
2715 | end ;
|
||
2716 | |||
2717 | // Calcul du digestible
|
||
2718 | function CalcDigestible : Double ;
|
||
2719 | begin
|
||
2720 | case CBRej3.ItemIndex of |
||
2721 | 0 : // Azote |
||
2722 | result := (IngereSec1*CC1.MAT*CC1.dMAT_C/100 + IngereSec2*CC2.MAT*CC2.dMAT_C/100) * 0.16 ; |
||
2723 | 1 : // Phosphore |
||
2724 | result := Pdig; |
||
2725 | else
|
||
2726 | result := 0 ;
|
||
2727 | end ;
|
||
2728 | end ;
|
||
2729 | |||
2730 | // Calcul du d?p?t (potentiel)
|
||
2731 | function CalcDepot (jour : integer) : Double ;
|
||
2732 | var
|
||
2733 | PV, GMQ, PD : Double ; |
||
2734 | begin
|
||
2735 | PV := PresSimulT.TabResult[58, jour] ;
|
||
2736 | GMQ := PresSimulT.TabResult[59, jour] ;
|
||
2737 | PD := PResSimulT.TabResult[64, jour] ;
|
||
2738 | case CBRej3.ItemIndex of |
||
2739 | 0 : // Azote |
||
2740 | result := PD * 0.16 ;
|
||
2741 | 1 : // Phosphore |
||
2742 | if GMQ > 0 |
||
2743 | then
|
||
2744 | result := -0.00227 * (Power(PV+GMQ, 2) - Power(PV, 2)) + 5.36335 * GMQ |
||
2745 | else
|
||
2746 | result := 0 ;
|
||
2747 | 2 : // Calcium |
||
2748 | if GMQ > 0 |
||
2749 | then
|
||
2750 | result := -0.00180 * (Power(PV+GMQ, 2) - Power(PV, 2)) + 8.64633 * GMQ |
||
2751 | else
|
||
2752 | result := 0 ;
|
||
2753 | 3 : // Potassium |
||
2754 | if GMQ > 0 |
||
2755 | then
|
||
2756 | result := -0.00345 * (Power(PV+GMQ, 2) - Power(PV, 2)) + 2.53338 * GMQ |
||
2757 | else
|
||
2758 | result := 0 ;
|
||
2759 | 4 : // Cuivre |
||
2760 | if GMQ > 0 |
||
2761 | then
|
||
2762 | result := 1.0 * GMQ
|
||
2763 | else
|
||
2764 | result := 0 ;
|
||
2765 | 5 : // Zinc |
||
2766 | if GMQ > 0 |
||
2767 | then
|
||
2768 | result := 21.8 * GMQ |
||
2769 | else
|
||
2770 | result := 0 ;
|
||
2771 | else
|
||
2772 | result := 0 ;
|
||
2773 | end ;
|
||
2774 | end ;
|
||
2775 | |||
2776 | // Calcul de l'export (lait)
|
||
2777 | function CalcExport (jour : integer) : Double ;
|
||
2778 | var
|
||
2779 | Lait : Double ; |
||
2780 | begin
|
||
2781 | Lait := PResSimulT.TabResult[69, jour] ;
|
||
2782 | case CBRej3.ItemIndex of |
||
2783 | 0 : // Azote |
||
2784 | result := Lait / 0.1325 ;
|
||
2785 | 1 : // Phosphore |
||
2786 | result := Lait * 1.41 ;
|
||
2787 | 2 : // Calcium |
||
2788 | result := Lait * 1.95 ;
|
||
2789 | 3 : // Potassium |
||
2790 | result := Lait * 0.59 ;
|
||
2791 | 4 : // Cuivre |
||
2792 | result := Lait * 0.002 ;
|
||
2793 | 5 : // Zinc |
||
2794 | result := Lait * 0.007 ;
|
||
2795 | else
|
||
2796 | result := 0 ;
|
||
2797 | end ;
|
||
2798 | end ;
|
||
2799 | |||
2800 | // RejY
|
||
2801 | begin
|
||
2802 | // Diviseur
|
||
2803 | case CBRej4.ItemIndex of |
||
2804 | 1 : // Dur?e |
||
2805 | d := PresSimulT.NbJSim ; |
||
2806 | 2 : // Aliment ing?r? |
||
2807 | begin
|
||
2808 | d := 0 ;
|
||
2809 | for h := 1 to PresSimulT.NbJSim do |
||
2810 | d := d + PresSimulT.TabResult[11, h] ;
|
||
2811 | end ;
|
||
2812 | else
|
||
2813 | d := 1 ;
|
||
2814 | end ;
|
||
2815 | v := 0 ;
|
||
2816 | for h := 1 to PResSimulT.NbJSim do |
||
2817 | begin
|
||
2818 | Composition (h) ; |
||
2819 | Ingere := CalcIngere ; |
||
2820 | Digestible := CalcDigestible ; |
||
2821 | Depose := CalcDepot (h) ; |
||
2822 | Exporte := CalcExport (h) ; |
||
2823 | if CBRej3.ItemIndex < 2 |
||
2824 | then // Azote ou phosphore |
||
2825 | case i of |
||
2826 | 0 : // F?cal |
||
2827 | v := v + Ingere - Digestible ; |
||
2828 | 1 : // Urinaire |
||
2829 | v := v + Max (Digestible - Depose - Exporte, 0) ;
|
||
2830 | 2 : // Retenu ou export? |
||
2831 | v := v + Min (Digestible, Depose + Exporte) ; |
||
2832 | end
|
||
2833 | else // Autres |
||
2834 | case i of |
||
2835 | 2 : // Retenu ou export? |
||
2836 | v := v + Min (Ingere, Depose + Exporte) ; |
||
2837 | 3 : // Ecr?t? |
||
2838 | v := v + Max (Ingere - Depose - Exporte, 0) ;
|
||
2839 | end ;
|
||
2840 | end ;
|
||
2841 | result := v / d ; |
||
2842 | end ;
|
||
2843 | |||
2844 | // AffGraphRej
|
||
2845 | begin
|
||
2846 | ResetGraph ; |
||
2847 | Graph.Legend.Inverted := TRUE ; |
||
2848 | Graph.Title.Text.Add (TabRej.Caption) ; |
||
2849 | Graph.LeftAxis.Title.Caption := Format ('%s (%s)', [CBRej3.Text, CBRej4.Text]) ;
|
||
2850 | case FSimulT.PC.ActivePageIndex of |
||
2851 | 1 : // Comparaison |
||
2852 | Graph.BottomAxis.Title.Caption := 'Simulation' ;
|
||
2853 | 2 : // Sensibilit? |
||
2854 | Graph.BottomAxis.Title.Caption := 'Variation' ;
|
||
2855 | end ;
|
||
2856 | // Affichage des barres
|
||
2857 | if CBRej3.ItemIndex < 2 |
||
2858 | then // Azote ou phosphore : F?cal, Urinaire et Retenu |
||
2859 | for i := 0 to 2 do |
||
2860 | BarRej[i].Active := TRUE |
||
2861 | else // Autres : Retenu et Excr?t? |
||
2862 | for i := 2 to ListRej.Count - 1 do |
||
2863 | BarRej[i].Active := TRUE ; |
||
2864 | for i := 0 to ListRej.Count - 1 do |
||
2865 | BarRej[i].Clear ; |
||
2866 | if CBRej4.ItemIndex = 3 |
||
2867 | then
|
||
2868 | for i := 0 to ListRej.Count - 1 do |
||
2869 | BarRej[i].MultiBar := mbStacked100 |
||
2870 | else
|
||
2871 | for i := 0 to ListRej.Count - 1 do |
||
2872 | BarRej[i].MultiBar := mbStacked ; |
||
2873 | for i := 0 to ListRej.Count - 1 do |
||
2874 | for k := 1 to 5 do |
||
2875 | if TabSimulT[k].Ok
|
||
2876 | then
|
||
2877 | begin
|
||
2878 | PResSimulT := TabSimulT[k].Result ; |
||
2879 | case FSimulT.PC.ActivePageIndex of |
||
2880 | 1 : // Comparaison |
||
2881 | s := Format ('%d', [k]) ;
|
||
2882 | 2 : // Sensibilit? |
||
2883 | s := Format ('%1.0f %%', [TabSimulT[k].Variation * 100]) ; |
||
2884 | end ;
|
||
2885 | y := RejY ; |
||
2886 | if y > PICO
|
||
2887 | then
|
||
2888 | BarRej[i].AddBar (y, s, clTeeColor) |
||
2889 | else
|
||
2890 | BarRej[i].AddNull (s) ; |
||
2891 | end ;
|
||
2892 | AjustEchelle (Graph) ; |
||
2893 | end ;
|
||
2894 | |||
2895 | procedure TFCompSimulT.CBRej3Change (Sender : TObject) ;
|
||
2896 | begin
|
||
2897 | CBRej4.Items.Clear ; |
||
2898 | if CBRej3.ItemIndex > 3 |
||
2899 | then // Oligo-?l?ment |
||
2900 | begin
|
||
2901 | CBRej4.Items.Add (StrMG) ; |
||
2902 | CBRej4.Items.Add (Format ('%s/%s', [StrMG, StrJ])) ;
|
||
2903 | CBRej4.Items.Add (Format ('%s/%s %s', [StrMG, StrKg, StrAlimentUnit])) ;
|
||
2904 | CBRej4.Items.Add ('%') ;
|
||
2905 | end
|
||
2906 | else // Macro-?l?ment |
||
2907 | begin
|
||
2908 | CBRej4.Items.Add (StrG) ; |
||
2909 | CBRej4.Items.Add (Format ('%s/%s', [StrG, StrJ])) ;
|
||
2910 | CBRej4.Items.Add (Format ('%s/%s %s', [StrG, StrKg, StrAlimentUnit])) ;
|
||
2911 | CBRej4.Items.Add ('%') ;
|
||
2912 | end ;
|
||
2913 | CBRej4.ItemIndex := 0 ;
|
||
2914 | AffGraphRej ; |
||
2915 | end ;
|
||
2916 | |||
2917 | procedure TFCompSimulT.CBRej4Change (Sender : TObject) ;
|
||
2918 | begin
|
||
2919 | AffGraphRej ; |
||
2920 | end ;
|
||
2921 | |||
2922 | procedure TFCompSimulT.WMSysCommand(var Message: TWMSysCommand); |
||
2923 | begin
|
||
2924 | if Message.CmdType = SC_MINIMIZE
|
||
2925 | then
|
||
2926 | Application.Minimize |
||
2927 | else
|
||
2928 | inherited;
|
||
2929 | end;
|
||
2930 | |||
2931 | end. |