Statistiques
| Révision:

root / UFBesGestE.pas @ 3

Historique | Voir | Annoter | Télécharger (19,269 ko)

1
unit UFBesGestE ;
2

    
3
interface
4

    
5
uses
6
  Windows, Forms, Classes, Controls, StdCtrls, Buttons, UVariables;
7

    
8
type
9
  TFBesGestE = class(TForm)
10
    GBProfil: TGroupBox;
11
    GBResult: TGroupBox;
12
    GBLoge: TGroupBox;
13
    CBProfil: TComboBox;
14
    CBLoge: TComboBox;
15
    ChkLoge: TCheckBox;
16
    BBRapGest: TBitBtn;
17
    BBResGest: TBitBtn;
18
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
19
    procedure FormActivate(Sender: TObject);
20
    procedure CBProfilChange(Sender: TObject);
21
    procedure CBLogeChange(Sender: TObject);
22
    procedure ChkLogeClick(Sender: TObject);
23
    procedure BBResGestClick(Sender: TObject);
24
    procedure BBRapGestClick(Sender: TObject);
25
    procedure FormCreate(Sender: TObject);
26
    procedure FormShow(Sender: TObject);
27
  private
28
    { D?clarations priv?es }
29
    Update, Modal: boolean;
30
    procedure CalcApport;
31
    procedure CalcResult;
32
  public
33
    { D?clarations publiques }
34
    AppAliTot, AppEDTot, AppEMTot, AppENTot: array[1..NB_CYCLES] of double;
35
    BesEMTot, BesEMEntTot, BesEMActTot, BesEMTheTot, BesEMPortTot, BesEMResTot: array[1..NB_CYCLES] of double;
36
    AppAli, AppED, AppEM, AppEN: array [1..NB_CYCLES, 1..DureeGest] of double;
37
    BesEMEnt, BesEMAct, BesEMThe, BesEMPort, BesP, BesCa: array [1..NB_CYCLES, 1..DureeGest] of double;
38
    AppAA, BesAA, BesAAEnt, BesAAPort, BesAARes: array[1..NB_CYCLES, 1..14, 1..DureeGest] of double;
39
  end;
40

    
41
var
42
  FBesGestE: TFBesGestE;
43

    
44
implementation
45

    
46
uses
47
  Math, gnugettext, UInit, UFindRec, UCalcul, UFResBesGestE, UFRapBesGestE;
48

    
49
{$R *.dfm}
50

    
51
{ TFBesGestE }
52

    
53
procedure TFBesGestE.FormCreate(Sender: TObject);
54
begin
55
  if Screen.Fonts.IndexOf('Arial Unicode MS') <> -1
56
  then
57
    Font.Name := 'Arial Unicode MS';
58
  TranslateComponent(Self);
59
  Constraints.MinWidth := 296 + (Width - ClientWidth);
60
  Width := Constraints.MinWidth;
61
  Constraints.MaxWidth := Constraints.MinWidth;
62
  Constraints.MinHeight := 160 + (Height - ClientHeight);
63
  Height := Constraints.MinHeight;
64
  Constraints.MaxHeight := Constraints.MinHeight;
65
end;
66

    
67
procedure TFBesGestE.FormShow(Sender: TObject);
68
begin
69
  Modal := False;
70
end;
71

    
72
procedure TFBesGestE.FormClose(Sender: TObject; var Action: TCloseAction);
73
begin
74
  Action := caFree ;
75
  NumWinBesGestE := -1;
76
end;
77

    
78
procedure TFBesGestE.FormActivate(Sender: TObject);
79
begin
80
  if not Modal
81
  then
82
  begin
83
    StringsProfilT(CBProfil.Items, False);
84
    StringsLogeT(CBLoge.Items, False);
85
  end;
86
end;
87

    
88
procedure TFBesGestE.CBProfilChange(Sender: TObject);
89
begin
90
  if CBProfil.ItemIndex = -1
91
  then
92
    CBProfil.Hint := ''
93
  else
94
  begin
95
    PProfilT := ListProfilT[FindIdxProfilT (CBProfil.Text)] ;
96
    CBProfil.Hint := PProfilT.Memo ;
97
    Update := TRUE ;
98
    if ChkLoge.Checked
99
    then
100
      ChkLogeClick (nil)
101
    else
102
      ChkLoge.Checked := TRUE ;
103
    CalcApport ;
104
    CalcResult ;
105
    Update := FALSE ;
106
    BBResGest.Enabled := TRUE ;
107
    BBRapGest.Enabled := TRUE ;
108
  end ;
109
end;
110

    
111
procedure TFBesGestE.CBLogeChange(Sender: TObject);
112
begin
113
  if CBLoge.ItemIndex = -1
114
  then
115
    CBLoge.Hint := ''
116
  else
117
  begin
118
    PLogeT := ListLogeT[FindIdxLogeT (CBLoge.Text)] ;
119
    CBLoge.Hint := PLogeT.Memo ;
120
    if not Update
121
    then
122
    begin
123
      Update := TRUE ;
124
      CalcResult ;
125
      Update := FALSE ;
126
    end ;
127
  end ;
128
end;
129

    
130
procedure TFBesGestE.ChkLogeClick(Sender: TObject);
131
begin
132
  if ChkLoge.Checked
133
  then
134
  begin
135
    CBLoge.Enabled := FALSE ;
136
    if CBProfil.ItemIndex <> -1
137
    then
138
      if not Update
139
      then
140
      begin
141
        Update := TRUE ;
142
        CBLoge.ItemIndex := CBLoge.Items.IndexOf (FindNomLogeT (PProfilT.Loge)) ;
143
        CBLogeChange (nil) ;
144
        CalcResult ;
145
        Update := FALSE ;
146
      end
147
      else
148
      begin
149
        CBLoge.ItemIndex := CBLoge.Items.IndexOf (FindNomLogeT (PProfilT.Loge)) ;
150
        CBLogeChange (nil) ;
151
      end ;
152
  end
153
  else
154
    CBLoge.Enabled := TRUE ;
155
end;
156

    
157
procedure TFBesGestE.CalcApport ;
158
var
159
  i, Cycle, Jour, AA, Unite : integer ;
160
  PctAli1, PctAli2, Quantite, Ingere, IngSec1, IngSec2 : double ;
161
  NumRuleSeqAli, NumRuleRation : integer ;
162
  RuleSeqAli : array[1..MAX_RULE] of RecRuleSeqAliT ;
163
  RuleRation : array[1..MAX_RULE] of RecRuleRationT ;
164
  RuleSeqAliInit, RuleRationInit, Ecart : integer ;
165
  RecCC1, RecCC2 : CompositionChimique ;
166
  TabAAtotal1, TabAAtotal2, TabCUDAA1, TabCUDAA2 : array[0..12] of double ;
167
  ok : boolean ;
168
begin
169
  for Cycle := 1 to NB_CYCLES do
170
  begin
171
    PSeqAliT := ListSeqAliT[FindIdxSeqAliT (FindNomSeqAliT (PProfilT.SeqAli))] ;
172
    for i := 1 to PSeqAliT.NbRuleGest do
173
      RuleSeqAli[i] := PSeqAliT.RuleGest[i] ;
174
    NumRuleSeqAli := 1 ;
175
    RuleSeqAliInit := 1 ;
176
    with RuleRation[1] do
177
    begin
178
      ModeFin := -1 ;
179
      Equation := 0 ; // Constant
180
      a := PProfilT.Gest[Cycle] ;
181
    end ;
182
    Unite := PProfilT.Unite ;
183
    NumRuleRation := 1 ;
184
    RuleRationInit := 1 ;
185
    // Boucle des jours
186
    for Jour := 1 to DureeGest do
187
    begin
188
      // Aliment(s) distribu?(s)
189
      repeat
190
        ok := TRUE ;
191
        with RuleSeqAli[NumRuleSeqAli] do
192
          if ModeFin = 0
193
          then // Dur?e
194
            if (Jour - RuleSeqAliInit + 1 > ValFin) then ok := FALSE ;
195
        if not (ok)
196
        then // Changement de r?gle
197
        begin
198
          Inc (NumRuleSeqAli) ;
199
          RuleSeqAliInit := Jour ;
200
        end ;
201
      until ok ;
202
      with RuleSeqAli[NumRuleSeqAli] do
203
      begin
204
        // Composition aliment 1
205
        if NumAli1 = -1
206
        then
207
        begin
208
          RecCC1 := CCVide ;
209
          for i := 0 to 12 do
210
            TabAAtotal1[i] := 0 ;
211
          for i := 0 to 12 do
212
            TabCUDAA1[i] := 0 ;
213
        end
214
        else
215
        begin
216
          PAliment := ListAliment[FindIdxAliment (FindNomAliment (NumAli1))] ;
217
          RecCC1 := PAliment.CC ;
218
          for i := 0 to 12 do
219
            TabAAtotal1[i] := PAliment.AAtotal[i] ;
220
          for i := 0 to 12 do
221
            TabCUDAA1[i] := PAliment.CUDAA[i] ;
222
        end ;
223
        // Composition aliment 2
224
        if NumAli2 = -1
225
        then
226
        begin
227
          RecCC2 := CCVide ;
228
          for i := 0 to 12 do
229
            TabAAtotal2[i] := 0 ;
230
          for i := 0 to 12 do
231
            TabCUDAA2[i] := 0 ;
232
        end
233
        else
234
        begin
235
          PAliment := ListAliment[FindIdxAliment (FindNomAliment (NumAli2))] ;
236
          RecCC2 := PAliment.CC ;
237
          for i := 0 to 12 do
238
            TabAAtotal2[i] := PAliment.AAtotal[i] ;
239
          for i := 0 to 12 do
240
            TabCUDAA2[i] := PAliment.CUDAA[i] ;
241
        end ;
242
        // Calcul des % aliments
243
        if PctAli1Init = PctAli1Fin
244
        then
245
          PctAli1 := PctAli1Init
246
        else // Transition
247
        begin
248
          Ecart := PctAli1Fin - PctAli1Init ;
249
          if ModeFin = 0
250
          then // Dur?e
251
            PctAli1 := PctAli1Init + (Jour - RuleSeqAliInit) * Ecart / ValFin
252
          else // Fin
253
            PctAli1 := PctAli1Init + (Jour - RuleSeqAliInit) * Ecart / (DureeGest - RuleSeqAliInit) ;
254
        end ;
255
      end ;
256
      PctAli2 := 100 - PctAli1 ;
257
      // Quantit?(s) distribu?e(s)
258
      repeat
259
        ok := TRUE ;
260
        with RuleRation[NumRuleRation] do
261
          if ModeFin = 0
262
          then // Dur?e
263
            if Jour - RuleRationInit + 1 > ValFin then ok := FALSE ;
264
        if not (ok)
265
        then // Changement de r?gle
266
        begin
267
          Inc (NumRuleRation) ;
268
          RuleRationInit := Jour ;
269
        end ;
270
      until ok ;
271
      with RuleRation[NumRuleRation] do
272
      begin
273
        // Calcul des quantit?s
274
        case Equation of
275
          0 : // Constant
276
            Quantite := a ;
277
          1 : // Lin?aire
278
            Quantite := a + b * (Jour - RuleRationInit) ;
279
          2 : // Lin?aire-plateau
280
            Quantite := LPvaleur (a, b, c, Jour - RuleRationInit + 1, d) ;
281
          3 : // Curvilin?aire
282
            Quantite := CLvaleur (a, c, Jour - RuleRationInit + 1, d) ;
283
          else
284
            Quantite := 0 ;
285
        end ;
286
        // Convertion de ED, EM, EN en quantit? si besoin
287
        case Unite of
288
          1 : // ED (MJ/j)
289
            Ingere := Quantite
290
              / (PctAli1 / 100 * RecCC1.ED_T * RecCC1.MS / 1000
291
                + PctAli2 / 100 * RecCC2.ED_T * RecCC2.MS / 1000) ;
292
          2 : // EM (MJ/j)
293
            Ingere := Quantite
294
              / (PctAli1 / 100 * RecCC1.EM_T * RecCC1.MS / 1000
295
                + PctAli2 / 100 * RecCC2.EM_T * RecCC2.MS / 1000) ;
296
          3 : // EN (MJ/j)
297
            Ingere := Quantite
298
              / (PctAli1 / 100 * RecCC1.EN_T * RecCC1.MS / 1000
299
                + PctAli2 / 100 * RecCC2.EN_T * RecCC2.MS / 1000) ;
300
          4 : // MS (kg/j)
301
            Ingere := Quantite
302
              / (PctAli1 / 100 * RecCC1.MS / 1000
303
                + PctAli2 / 100 * RecCC2.MS / 1000) ;
304
          else // QI (kg/j)
305
            Ingere := Quantite ;
306
        end ;
307
      end ;
308
      // Aliment ing?r?
309
      AppAli[Cycle, Jour] := Ingere ;
310
      IngSec1 := Ingere * PctAli1 / 100 * RecCC1.MS / 1000 ;
311
      IngSec2 := Ingere * PctAli2 / 100 * RecCC2.MS / 1000 ;
312
      // Energie ing?r?e
313
      AppED[Cycle, Jour] := IngSec1 * RecCC1.ED_T + IngSec2 * RecCC2.ED_T ;
314
      AppEM[Cycle, Jour] := IngSec1 * RecCC1.EM_T + IngSec2 * RecCC2.EM_T ;
315
      AppEN[Cycle, Jour] := IngSec1 * RecCC1.EN_T + IngSec2 * RecCC2.EN_T ;
316
      // Acides amin?s digestibles
317
      for AA := 1 to 12 do
318
        AppAA[Cycle, AA, Jour] := IngSec1 * TabAAtotal1[AA] * TabCUDAA1[AA] / 100
319
          + IngSec2 * TabAAtotal2[AA] * TabCUDAA2[AA] / 100 ;
320
      // met+cys
321
      AppAA[Cycle, 13, Jour] := AppAA[Cycle, 2, Jour] + AppAA[Cycle, 3, Jour] ;
322
      // phe+tyr
323
      AppAA[Cycle, 14, Jour] := AppAA[Cycle, 6, Jour] + AppAA[Cycle, 7, Jour] ;
324
    end ;
325
    // Totaux
326
    AppAliTot[Cycle] := Sum (AppAli[Cycle]) ;
327
    AppEDTot[Cycle] := Sum (AppED[Cycle]) ;
328
    AppEMTot[Cycle] := Sum (AppEM[Cycle]) ;
329
    AppENTot[Cycle] := Sum (AppEN[Cycle]) ;
330
  end ;
331
end ;
332

    
333
procedure TFBesGestE.CalcResult ;
334
{
335
const
336
  DELTA = 0.3 ;
337
  SEUIL = 0.001 ;
338
  MAX_TOURS = 1000 ;
339
}
340
var
341
  i, j, {tour, mini,} Cycle, Jour, AA, AgeSail : integer ;
342
  NumRuleLoge, RuleLogeInit, Ecart, Temperature : integer ;
343
//  delta_pmax, delta_a, delta_b : double ;
344
//  tab_pmax, tab_a, tab_b, tab_ecart : array[0..NB_CYCLES] of double ;
345
  PdsPort, PdsSail, PdsApMB, PdsAvMB, P2Sail, P2MB, NesTotaux : double ;
346
  EMSail, EMApMB, GMQ, PV, PFoetus, PPlacenta : double ;
347
  BesEMBaseTot, EMEntSail, CorrJ, CorrNR, NRUterus, NR, LysRet, LysEnt : double ;
348
  BesEMBase : array [1..DureeGest] of double ;
349
  EMPortCum : array [0..DureeGest] of double ;
350
  RuleLoge : array[1..MAX_RULE] of RecRuleLogeT ;
351
  ok : boolean ;
352
//  pmax, a, b : double ;
353
begin
354
{
355
  // Recherche des param?tres pour la courbe de poids apr?s mise-bas
356
  tab_pmax[0] := 0 ;
357
  for i := 1 to NB_CYCLES do
358
    with PProfilT.Truies[i] do
359
      if PdsApMB > tab_pmax[0]
360
      then
361
        tab_pmax[0] := PdsApMB ;
362
  tab_a[0] := 1.5 ;
363
  tab_b[0] := 1.1 ;
364
  delta_pmax := tab_pmax[0] * DELTA ;
365
  delta_a := tab_a[0] * DELTA ;
366
  delta_b := tab_b[0] * DELTA ;
367
  tour := 0 ;
368
  repeat
369
    // ?value les points
370
    for i := 1 to NB_CYCLES do
371
      tab_pmax[i] := tab_pmax[0] + Power (-1, i) * delta_pmax ;
372
    for i := 1 to NB_CYCLES do
373
      tab_a[i] := tab_a[0] + Power (-1, i) * delta_a ;
374
    for i := 1 to NB_CYCLES do
375
      tab_b[i] := tab_b[0] + Power (-1, (i + 1) div 2) * delta_b ;
376
    for j := 0 to NB_CYCLES do
377
    begin
378
      tab_ecart[j] := 0 ;
379
      for i := 1 to NB_CYCLES do
380
        with PProfilT.Truies[i] do
381
          tab_ecart[j] := tab_ecart[j] + Power (tab_pmax[j] * (1 - Exp ((- tab_a[j] / 1000) * Power (AgeSail + 114, tab_b[j]))) - PdsApMB, 2) ;
382
    end ;
383
    // recherche le meilleur point
384
    mini := 0 ;
385
    for i := 1 to NB_CYCLES do
386
      if tab_ecart[i] < tab_ecart[mini]
387
      then
388
        mini := i ;
389
    // d?termine le point central
390
    if mini = 0
391
    then
392
    begin
393
      delta_pmax := delta_pmax * 0.8 ;
394
      delta_a := delta_a * 0.8 ;
395
      delta_b := delta_b * 0.8 ;
396
    end
397
    else
398
    begin
399
      tab_pmax[0] := tab_pmax[mini] ;
400
      tab_a[0] := tab_a[mini] ;
401
      tab_b[0] := tab_b[mini] ;
402
    end ;
403
   // ?value si les crit?res de sortie sont satisfaits
404
    ok := (delta_pmax < Abs (tab_pmax [mini] * SEUIL))
405
      and (delta_a < Abs (tab_a [mini] * SEUIL))
406
      and (delta_b < Abs (tab_b [mini] * SEUIL)) ;
407
    Inc (tour) ;
408
  until ok or (tour > MAX_TOURS) ;
409
  if ok
410
  then
411
  begin
412
    pmax := tab_pmax[0] ;
413
    a := tab_a[0] ;
414
    b := tab_b[0] ;
415
  end ;
416
}
417
  for Cycle := 1 to NB_CYCLES do
418
  begin
419
    for i := 1 to PLogeT.NbRuleGest do
420
      RuleLoge[i] := PLogeT.RuleGest[i] ;
421
    NumRuleLoge := 1 ;
422
    RuleLogeInit := 1 ;
423
    AgeSail := PProfilT.Truies[Cycle].AgeSail ;
424
    NesTotaux := PProfilT.Porcelets[Cycle].NesTotaux ;
425
    PdsSail := PProfilT.Truies[Cycle].PdsSail ;
426
    P2Sail := PProfilT.Truies[Cycle].P2Sail ;
427
    P2MB := PProfilT.Truies[Cycle].P2MB ;
428
    // Poids port?e
429
    PdsPort := NesTotaux * PProfilT.Porcelets[Cycle].PdsNais ;
430
    // Poids apr?s mise-bas (selon ?quation)
431
    PdsApMB := PProfilT.pmax * (1 - Exp ((- PProfilT.a / 1000) * Power (AgeSail + DureeGest, PProfilT.b))) ;
432
    PdsApMB := RoundTo (PdsApMB, -1) ;
433
    // Poids avant mise-bas
434
    PdsAvMB := PdsApMB + 0.3 + 1.329 * PdsPort ;
435
    // Gain de poids (lin?aire)
436
    GMQ := (PdsAvMB - PdsSail) / DureeGest ;
437
    //
438
    // Besoins ?n?rg?tiques
439
    //
440
    // Energie pour la constitution de r?serves
441
    EMSail := (-256.8 + 3.2672 * PdsSail * PV2PVV + 10.992 * P2Sail) * 4.18 ;
442
    EMApMB := (-256.8 + 3.2672 * PdsApMB * PV2PVV + 10.992 * P2MB) * 4.18 ;
443
    BesEMResTot[Cycle] := (EMApMB - EMSail) / DureeGest / 0.77 ;
444
    EMPortCum[0] := 0 ;
445
    for Jour := 1 to DureeGest do
446
    begin
447
      repeat
448
        ok := TRUE ;
449
        with RuleLoge[NumRuleLoge] do
450
          if ModeFin = 0
451
          then // Dur?e
452
            if Jour - RuleLogeInit + 1 > ValFin then ok := FALSE ;
453
        if not (ok)
454
        then // Changement de r?gle
455
        begin
456
          Inc (NumRuleLoge) ;
457
          RuleLogeInit := Jour ;
458
        end ;
459
      until ok ;
460
      PV := PdsSail + GMQ * Jour ;
461
      BesEMEnt[Cycle, Jour] := Power (PV, 0.75) * EEGest
462
        - 0.3 * Power (PV, 0.75) * 240 / 1000 ;
463
      EMPortCum[Jour] := Exp (11.72 - 8.62 * Exp (-0.01382 * Jour) + 0.0932 * NesTotaux) / 1000
464
        * (PdsPort * 1.3 * 4.18) / (Exp (11.72 - 8.62 * Exp (-0.01382 * DureeGest) + 0.0932 * NesTotaux) / 1000) ;
465
      BesEMPort[Cycle, Jour] := (EMPortCum[Jour] - EMPortCum[Jour - 1]) / 0.48 ;
466
      BesEMBase[Jour] := BesEMEnt[Cycle, Jour] + BesEMPort[Cycle, Jour] + BesEMResTot[Cycle]
467
        + 0.3 * Power (PV, 0.75) * 240 / 1000 ; // Activit? de base
468
      BesEMAct[Cycle, Jour] := 0.3 * Power (PV, 0.75) * RuleLoge[NumRuleLoge].Act / 1000 ;
469
      if (RuleLoge[NumRuleLoge].Sol = 1)
470
      then // Paill?
471
        Temperature := RuleLoge[NumRuleLoge].Temp + 3
472
      else
473
        Temperature := RuleLoge[NumRuleLoge].Temp ;
474
      if (RuleLoge[NumRuleLoge].Typ = 1)
475
      then // Collectif
476
        if Temperature < TCICol
477
        then
478
          BesEMThe[Cycle, Jour] := (TCICol - Temperature) * Power (PV, 0.75) * EThCol / 1000
479
        else
480
          BesEMThe[Cycle, Jour] := 0
481
      else
482
        if Temperature < TCIInd
483
        then
484
          BesEMThe[Cycle, Jour] := (TCIInd - Temperature) * Power (PV, 0.75) * EThInd / 1000
485
        else
486
          BesEMThe[Cycle, Jour] := 0 ;
487
    end ;
488
    BesEMEntTot[Cycle] := Mean (BesEMEnt[Cycle]) ;
489
    BesEMPortTot[Cycle] := Mean (BesEMPort[Cycle]) ;
490
    BesEMBaseTot := Mean (BesEMBase) ;
491
    BesEMActTot[Cycle] := Mean (BesEMAct[Cycle]) ;
492
    BesEMTheTot[Cycle] := Mean (BesEMThe[Cycle]) ;
493
    // Besoin total en ?nergie
494
    BesEMTot[Cycle] := BesEMEntTot[Cycle] + BesEMActTot[Cycle] + BesEMResTot[Cycle] + BesEMPortTot[Cycle] + BesEMTheTot[Cycle] ;
495
    //
496
    // Besoins en acides amin?s
497
    //
498
    EMEntSail := Power (PdsSail, 0.75) * EEGest ;
499
    for Jour := 1 to DureeGest do
500
    begin
501
      PV := PdsSail + GMQ * Jour ;
502
      NRUterus := Exp (8.09 - 8.71 * Exp (-0.01494 * Jour) + 0.0872 * NesTotaux) / 6.25
503
        - Exp (8.09 - 8.71 * Exp (-0.01494 * (Jour - 1)) + 0.0872 * NesTotaux) / 6.25 ;
504
      if (Jour < 98)
505
      then
506
        CorrJ := Jour
507
      else
508
        CorrJ := Jour - 6 / 16 * (Jour - 98) ;
509
      Case cycle of
510
        1 : // Port?e 1
511
          CorrNR := 0.5708 ;
512
        2 : // Port?e 2
513
          CorrNR := 0.4345 ;
514
        else
515
          CorrNR := 0.3664 ;
516
      end ;
517
      NR := (-0.43 + 45.92 * CorrJ / 100 - 105.35 * Power (CorrJ / 100, 2) + 64.388 * Power (CorrJ / 100, 3)
518
        + CorrNR * (BesEMBaseTot - EMEntSail) + NRUterus) * 0.85 ;
519
      LysRet := NR * 6.25 * 0.067 ;
520
      LysEnt := power (PV, 0.75) * 0.036 ;
521
      // 1) Besoin total
522
      BesAA[Cycle, 1, Jour] := (LysRet / 0.65) + LysEnt ;
523
      for AA := 2 to 12 do
524
        BesAA[Cycle, AA, Jour] := BesAA[Cycle, 1, Jour] * ProtIdGest[AA] / 100 ;
525
      // met+cys
526
      BesAA[Cycle, 13, Jour] := BesAA[Cycle, 1, Jour] * (ProtIdGest[2] + ProtIdGest[3]) / 100 ;
527
      // phe+tyr
528
      BesAA[Cycle, 14, Jour] := BesAA[Cycle, 1, Jour] * (ProtIdGest[6] + ProtIdGest[7]) / 100 ;
529
      // 2) Besoin d'entretien
530
      BesAAEnt[Cycle, 1, Jour] := LysEnt ;
531
      for AA := 2 to 12 do
532
        BesAAEnt[Cycle, AA, Jour] := BesAAEnt[Cycle, 1, Jour] * ProtIdEnt[AA] / 100 ;
533
      // met+cys
534
      BesAAEnt[Cycle, 13, Jour] := BesAAEnt[Cycle, 1, Jour] * (ProtIdEnt[2] + ProtIdEnt[3]) / 100 ;
535
      // phe+tyr
536
      BesAAEnt[Cycle, 14, Jour] := BesAAEnt[Cycle, 1, Jour] * (ProtIdEnt[6] + ProtIdEnt[7]) / 100 ;
537
      // 3) Besoin pour la port?e
538
      for AA := 1 to 14 do
539
        BesAAPort[Cycle, AA, Jour] := (BesAA[Cycle, AA, Jour] - BesAAEnt[Cycle, AA, Jour]) / NR * NRUterus ;
540
      // 4) Besoin pour la constitution de r?serves
541
      for AA := 1 to 14 do
542
        BesAARes[Cycle, AA, Jour] := BesAA[Cycle, AA, Jour] - BesAAEnt[Cycle, AA, Jour] - BesAAPort[Cycle, AA, Jour] ;
543
    end ;
544
    //
545
    // Besoin en min?raux
546
    //
547
    for Jour := 1 to DureeGest do
548
    begin
549
      PV := PdsSail + GMQ * Jour ;
550
      PFoetus := (Exp (4.591 - 6.389 * Exp (0.02398 * (45 - Jour)) + 0.0897 * NesTotaux)
551
          - Exp (4.591 - 6.389 * Exp (0.02398 * (45 - (Jour - 1))) + 0.0897 * NesTotaux))
552
        * PdsPort * 6.25 / Exp (4.591 - 6.389 * Exp (0.02398 * (45 - DureeGest)) + 0.0897 * NesTotaux) ;
553
      PPlacenta := Exp (7.34264 - 1.40598 * Exp (0.0625 * (45 - Jour)) + 0.00759 * Jour + 0.06339 * NesTotaux) * 0.0096 / 23.8
554
        - Exp (7.34264 - 1.40598 * Exp (0.0625 * (45 - (Jour - 1))) + 0.00759 * (Jour - 1) + 0.06339 * NesTotaux) * 0.0096 / 23.8 ;
555
      // Phosphore digestible
556
      BesP[Cycle, Jour] := 10 * PV / 1000
557
        + (5.42 - 0.002857 * 2 * PV) * (PdsApMB - PdsSail) / DureeGest
558
        + PFoetus + PPlacenta ;
559
      // Calcium total
560
      BesCa[Cycle, Jour] := BesP[Cycle, Jour] * 3.6 ;
561
    end ;
562
  end ;
563
end ;
564

    
565
procedure TFBesGestE.BBResGestClick(Sender: TObject);
566
begin
567
  Modal := True;
568
  FResBesGestE := TFResBesGestE.Create (Self) ;
569
  FResBesGestE.ShowModal ;
570
  FResBesGestE.Release ;
571
  Modal := False;
572
end;
573

    
574
procedure TFBesGestE.BBRapGestClick(Sender: TObject);
575
begin
576
  Modal := True;
577
  FRapBesGestE := TFRapBesGestE.Create(Self);
578
  FRapBesGestE.QRRapport.PreviewModal ;
579
  FRapBesGestE.Release;
580
  Modal := False;
581
end;
582

    
583
end.