root / UFRapSimulT.pas @ 3
Historique | Voir | Annoter | Télécharger (15,05 ko)
1 |
unit UFRapSimulT ;
|
---|---|
2 |
|
3 |
interface
|
4 |
|
5 |
uses
|
6 |
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, |
7 |
Dialogs, OleCtrls, StdCtrls, ComCtrls, DB, DBClient, ExtCtrls, QRCtrls, |
8 |
QuickRpt, QRPrntr, MidasLib, UVariables, gnugettext; |
9 |
|
10 |
type
|
11 |
TFRapSimulT = class(TForm)
|
12 |
QRRapport: TQuickRep; |
13 |
PHBRapport: TQRBand; |
14 |
DBRapport: TQRBand; |
15 |
QRLTitre: TQRLabel; |
16 |
QRLCaract: TQRLabel; |
17 |
QRLSimul: TQRLabel; |
18 |
QRLProfil: TQRLabel; |
19 |
QRDBTSimul: TQRDBText; |
20 |
QRDBTProfil: TQRDBText; |
21 |
QRLabel1: TQRLabel; |
22 |
QRDBTLoge: TQRDBText; |
23 |
CDSRapport: TClientDataSet; |
24 |
SFSimul: TStringField; |
25 |
SFProfil: TStringField; |
26 |
SFSeqAli: TStringField; |
27 |
SFRation: TStringField; |
28 |
IFCycle: TIntegerField; |
29 |
SFLoge: TStringField; |
30 |
QRLInit: TQRLabel; |
31 |
QRDBTInit: TQRDBText; |
32 |
SFInit: TStringField; |
33 |
PFBRapport: TQRBand; |
34 |
QRLUser: TQRLabel; |
35 |
QRLWarning: TQRLabel; |
36 |
CDSRapport_DureeGest_: TIntegerField; |
37 |
CDSRapport_PVGest_: TFloatField; |
38 |
CDSRapport_GainTotGest_: TFloatField; |
39 |
CDSRapport_GainNetGest_: TFloatField; |
40 |
CDSRapport_P2Gest_: TFloatField; |
41 |
CDSRapport_P2VarGest_: TFloatField; |
42 |
CDSRapport_ConsoGest_: TFloatField; |
43 |
CDSRapport_PDGest_: TFloatField; |
44 |
CDSRapport_LDGest_: TFloatField; |
45 |
CDSRapport_DureeLact_: TIntegerField; |
46 |
CDSRapport_PVLact_: TFloatField; |
47 |
CDSRapport_GainTotLact_: TFloatField; |
48 |
CDSRapport_GainNetLact_: TFloatField; |
49 |
CDSRapport_P2Lact_: TFloatField; |
50 |
CDSRapport_P2VarLact_: TFloatField; |
51 |
CDSRapport_ConsoLact_: TFloatField; |
52 |
CDSRapport_PDLact_: TFloatField; |
53 |
CDSRapport_LDLact_: TFloatField; |
54 |
CDSRapport_DureeISSF_: TIntegerField; |
55 |
CDSRapport_PVISSF_: TFloatField; |
56 |
CDSRapport_GainTotISSF_: TFloatField; |
57 |
CDSRapport_GainNetISSF_: TFloatField; |
58 |
CDSRapport_P2ISSF_: TFloatField; |
59 |
CDSRapport_P2VarISSF_: TFloatField; |
60 |
CDSRapport_ConsoISSF_: TFloatField; |
61 |
CDSRapport_PDISSF_: TFloatField; |
62 |
CDSRapport_LDISSF_: TFloatField; |
63 |
CDSRapport_NesTot_: TFloatField; |
64 |
CDSRapport_Sevres_: TFloatField; |
65 |
CDSRapport_PdsNais_: TFloatField; |
66 |
CDSRapport_PdsSev_: TFloatField; |
67 |
CDSRapport_Lait_: TFloatField; |
68 |
FFNesVifs: TFloatField; |
69 |
QRExpr32: TQRExpr; |
70 |
QRExpr33: TQRExpr; |
71 |
QRExpr31: TQRExpr; |
72 |
QRExpr30: TQRExpr; |
73 |
QRExpr29: TQRExpr; |
74 |
QRExpr27: TQRExpr; |
75 |
QRExpr28: TQRExpr; |
76 |
QRExpr26: TQRExpr; |
77 |
QRExpr22: TQRExpr; |
78 |
QRExpr23: TQRExpr; |
79 |
QRExpr19: TQRExpr; |
80 |
QRExpr24: TQRExpr; |
81 |
QRExpr20: TQRExpr; |
82 |
QRExpr25: TQRExpr; |
83 |
QRExpr21: TQRExpr; |
84 |
QRExpr18: TQRExpr; |
85 |
QRExpr16: TQRExpr; |
86 |
QRExpr17: TQRExpr; |
87 |
QRExpr15: TQRExpr; |
88 |
QRExpr14: TQRExpr; |
89 |
QRExpr10: TQRExpr; |
90 |
QRExpr11: TQRExpr; |
91 |
QRExpr12: TQRExpr; |
92 |
QRExpr13: TQRExpr; |
93 |
QRExpr6: TQRExpr; |
94 |
QRExpr9: TQRExpr; |
95 |
QRExpr8: TQRExpr; |
96 |
QRExpr7: TQRExpr; |
97 |
QRExpr5: TQRExpr; |
98 |
QRExpr4: TQRExpr; |
99 |
QRExpr1: TQRExpr; |
100 |
QRExpr3: TQRExpr; |
101 |
QRExpr2: TQRExpr; |
102 |
QREAge: TQRExpr; |
103 |
QRLSeqAli: TQRLabel; |
104 |
QRLRation: TQRLabel; |
105 |
QRDBTSeqAli: TQRDBText; |
106 |
QRDBTRation: TQRDBText; |
107 |
QRLCycle: TQRLabel; |
108 |
QRDBTCycle: TQRDBText; |
109 |
QRLSaillie: TQRLabel; |
110 |
QRLPoids: TQRLabel; |
111 |
QRLMiseBas: TQRLabel; |
112 |
QRLP2: TQRLabel; |
113 |
QRLAge: TQRLabel; |
114 |
QRLVariation: TQRLabel; |
115 |
QRLabel2: TQRLabel; |
116 |
QRLabel3: TQRLabel; |
117 |
QRLabel4: TQRLabel; |
118 |
QRLabel5: TQRLabel; |
119 |
QRLabel6: TQRLabel; |
120 |
QRLabel7: TQRLabel; |
121 |
QRDBTAgeSail: TQRDBText; |
122 |
QRDBText1: TQRDBText; |
123 |
QRDBText2: TQRDBText; |
124 |
QRDBText3: TQRDBText; |
125 |
QRDBText4: TQRDBText; |
126 |
QRDBText5: TQRDBText; |
127 |
QRDBText6: TQRDBText; |
128 |
QRDBText7: TQRDBText; |
129 |
QRDBText8: TQRDBText; |
130 |
QRDBText9: TQRDBText; |
131 |
QRDBText10: TQRDBText; |
132 |
QRDBText11: TQRDBText; |
133 |
QRDBText12: TQRDBText; |
134 |
QRDBText13: TQRDBText; |
135 |
QRDBText14: TQRDBText; |
136 |
QRDBText15: TQRDBText; |
137 |
QRDBText16: TQRDBText; |
138 |
QRDBText17: TQRDBText; |
139 |
QRLIngere: TQRLabel; |
140 |
QRLAliTot: TQRLabel; |
141 |
QRLAliMoy: TQRLabel; |
142 |
QRDBText18: TQRDBText; |
143 |
QRDBText19: TQRDBText; |
144 |
QRDBText20: TQRDBText; |
145 |
QRLabel8: TQRLabel; |
146 |
QRLabel9: TQRLabel; |
147 |
QRLabel10: TQRLabel; |
148 |
QRLabel11: TQRLabel; |
149 |
QRLabel12: TQRLabel; |
150 |
QRLabel14: TQRLabel; |
151 |
QRLabel15: TQRLabel; |
152 |
QRLabel16: TQRLabel; |
153 |
QRLabel17: TQRLabel; |
154 |
QRDBText21: TQRDBText; |
155 |
QRDBText22: TQRDBText; |
156 |
QRDBText23: TQRDBText; |
157 |
QRDBText24: TQRDBText; |
158 |
QRLabel18: TQRLabel; |
159 |
QRLabel19: TQRLabel; |
160 |
QRLabel20: TQRLabel; |
161 |
QRShape2: TQRShape; |
162 |
QRShape1: TQRShape; |
163 |
QRDBText25: TQRDBText; |
164 |
QRDBText26: TQRDBText; |
165 |
QRExpr34: TQRExpr; |
166 |
QRLabel13: TQRLabel; |
167 |
QRLabel21: TQRLabel; |
168 |
QRLabel22: TQRLabel; |
169 |
QRLabel23: TQRLabel; |
170 |
QRLabel24: TQRLabel; |
171 |
QRShape3: TQRShape; |
172 |
QRLabel25: TQRLabel; |
173 |
QRSDDate: TQRSysData; |
174 |
QRIInraPorc: TQRImage; |
175 |
QRLInraPorc: TQRLabel; |
176 |
procedure FormCreate(Sender: TObject);
|
177 |
private
|
178 |
{ D?clarations priv?es }
|
179 |
public
|
180 |
{ D?clarations publiques }
|
181 |
end;
|
182 |
|
183 |
var
|
184 |
FRapSimulT: TFRapSimulT; |
185 |
|
186 |
implementation
|
187 |
|
188 |
uses
|
189 |
UStrings, UFindRec, UUtil, UFSimulT, UFPrevRap ; |
190 |
|
191 |
{$R *.dfm}
|
192 |
|
193 |
{ TFRapSimulT }
|
194 |
|
195 |
procedure TFRapSimulT.FormCreate(Sender: TObject);
|
196 |
var
|
197 |
Jour, Cycle, Stade, DebutStade, Duree: integer; |
198 |
GainTot, GainNet, P2Var, Ingere, PD, LD, Lait, GainProfil, GainSimul: double; |
199 |
begin
|
200 |
if Screen.Fonts.IndexOf('Arial Unicode MS') <> -1 |
201 |
then
|
202 |
Font.Name := 'Arial Unicode MS';
|
203 |
TranslateComponent(Self); |
204 |
// Licence
|
205 |
if IsEducation and (Length (Course) > 0) |
206 |
then
|
207 |
QRLUSer.Caption := Format('%s (%s)', [Course, Company])
|
208 |
else
|
209 |
if IsComplete or IsEducation |
210 |
then
|
211 |
QRLUSer.Caption := Format('%s %s (%s)', [FirstName, LastName, Company])
|
212 |
else
|
213 |
if IsEvaluation
|
214 |
then
|
215 |
QRLUSer.Caption := StrEvaluation |
216 |
else
|
217 |
begin
|
218 |
QRLUSer.Caption := StrReadOnly; |
219 |
QRLUser.Font.Color := clRed; |
220 |
end;
|
221 |
with CDSRapport do |
222 |
begin
|
223 |
CreateDataSet; |
224 |
// Initialisation
|
225 |
Cycle := Trunc(PResSimulT.TabResult[2, 1]); |
226 |
Stade := Trunc(PResSimulT.TabResult[3, 1]); |
227 |
GainTot := PResSimulT.TabResult[59, 1]; |
228 |
GainNet := PResSimulT.TabResult[61, 1]; |
229 |
P2Var := PResSimulT.TabResult[68, 1]; |
230 |
Ingere := PResSimulT.TabResult[11, 1]; |
231 |
PD := PResSimulT.TabResult[63, 1]; |
232 |
LD := PResSimulT.TabResult[66, 1]; |
233 |
Lait := PResSimulT.TabResult[69, 1]; |
234 |
DebutStade := 1;
|
235 |
Append; |
236 |
FieldValues['_Simul_'] := PSimulT.Nom;
|
237 |
FieldValues['_Profil_'] := FSimulT.CBProfil.Text;
|
238 |
FieldValues['_Loge_'] := FSimulT.CBLoge.Text;
|
239 |
FieldValues['_Init_'] := FSimulT.CBOptInit.Text;
|
240 |
FieldValues['_Cycle_'] := Cycle;
|
241 |
if PSimulT.SeqAli[Cycle] = -1 |
242 |
then // S?quence alimentaire du profil animal |
243 |
FieldValues['_SeqAli_'] := FindNomSeqAliT (PProfilT.SeqAli)
|
244 |
else // S?quence alimentaire de la simulation |
245 |
FieldValues['_SeqAli_'] := FindNomSeqAliT (PSimulT.SeqAli[Cycle]);
|
246 |
if PSimulT.Ration[Cycle] = -1 |
247 |
then // Ration de r?f?rence du profil animal |
248 |
FieldValues['_Ration_'] := FSimulT.CBRationProfil.Text
|
249 |
else // Plan de rationnement de la simulation |
250 |
FieldValues['_Ration_'] := FindNomRationT (PSimulT.Ration[Cycle]);
|
251 |
if Stade = 1 |
252 |
then // Lactation |
253 |
begin
|
254 |
// Naissance
|
255 |
FieldValues['_NesTot_'] := PProfilT.Porcelets[Cycle].NesTotaux;
|
256 |
FieldValues['_NesVifs_'] := PProfilT.Porcelets[Cycle].NesVivants;
|
257 |
FieldValues['_PdsNais_'] := PProfilT.Porcelets[Cycle].PdsNais;
|
258 |
end ;
|
259 |
if PResSimulT.NbJSim > 1 |
260 |
then
|
261 |
for Jour := 2 to PResSimulT.NbJSim do |
262 |
if (Cycle = Trunc(PResSimulT.TabResult[2, Jour])) |
263 |
and (Stade = Trunc(PResSimulT.TabResult[3, Jour])) |
264 |
then // Incr?menter les compteurs |
265 |
begin
|
266 |
GainTot := GainTot + PResSimulT.TabResult[59, Jour];
|
267 |
GainNet := GainNet + PResSimulT.TabResult[61, Jour];
|
268 |
P2Var := P2Var + PResSimulT.TabResult[68, Jour];
|
269 |
Ingere := Ingere + PResSimulT.TabResult[11, Jour];
|
270 |
PD := PD + PResSimulT.TabResult[63, Jour];
|
271 |
LD := LD + PResSimulT.TabResult[66, Jour];
|
272 |
Lait := Lait + PResSimulT.TabResult[69, Jour];
|
273 |
end
|
274 |
else // Rupture cycle ou stade |
275 |
begin
|
276 |
Duree := Jour - DebutStade; |
277 |
case Stade of |
278 |
0 : // Gestation |
279 |
begin
|
280 |
FieldValues['_DureeGest_'] := Duree;
|
281 |
FieldValues['_PVGest_'] := PResSimulT.TabResult[58, DebutStade]; |
282 |
FieldValues['_GainTotGest_'] := GainTot;
|
283 |
FieldValues['_GainNetGest_'] := GainNet;
|
284 |
FieldValues['_P2Gest_'] := PResSimulT.TabResult[67, DebutStade]; |
285 |
FieldValues['_P2VarGest_'] := P2Var;
|
286 |
FieldValues['_ConsoGest_'] := Ingere;
|
287 |
FieldValues['_PDGest_'] := PD;
|
288 |
FieldValues['_LDGest_'] := LD;
|
289 |
// Naissance
|
290 |
FieldValues['_NesTot_'] := PProfilT.Porcelets[Cycle].NesTotaux;
|
291 |
FieldValues['_NesVifs_'] := PProfilT.Porcelets[Cycle].NesVivants;
|
292 |
FieldValues['_PdsNais_'] := PProfilT.Porcelets[Cycle].PdsNais;
|
293 |
end;
|
294 |
1 : // Lactation |
295 |
begin
|
296 |
FieldValues['_DureeLact_'] := Duree;
|
297 |
FieldValues['_PVLact_'] := PResSimulT.TabResult[58, DebutStade]; |
298 |
FieldValues['_GainTotLact_'] := GainTot;
|
299 |
FieldValues['_GainNetLact_'] := GainNet;
|
300 |
FieldValues['_P2Lact_'] := PResSimulT.TabResult[67, DebutStade]; |
301 |
FieldValues['_P2VarLact_'] := P2Var;
|
302 |
FieldValues['_ConsoLact_'] := Ingere;
|
303 |
FieldValues['_PDLact_'] := PD;
|
304 |
FieldValues['_LDLact_'] := LD;
|
305 |
// Sevrage
|
306 |
FieldValues['_Sevres_'] := PProfilT.Porcelets[Cycle].Sevres;
|
307 |
// Ajustement du poids de sevrage ? la dur?e de lactation
|
308 |
GainProfil := (273 * PProfilT.DureeLact + (289 / 0.38) * Exp (-0.38 * PProfilT.DureeLact) - 289 / 0.38) / 1000; |
309 |
GainSimul := (273 * PSimulT.DureeLact + (289 / 0.38) * Exp (-0.38 * PSimulT.DureeLact) - 289 / 0.38) / 1000; |
310 |
FieldValues['_PdsSev_'] := PProfilT.Porcelets[Cycle].PdsNais + GainSimul * (PProfilT.Porcelets[Cycle].PdsSev - PProfilT.Porcelets[Cycle].PdsNais) / GainProfil;
|
311 |
FieldValues['_Lait_'] := Lait;
|
312 |
end;
|
313 |
else // ISSF |
314 |
begin
|
315 |
FieldValues['_DureeISSF_'] := Duree;
|
316 |
FieldValues['_PVISSF_'] := PResSimulT.TabResult[58, DebutStade]; |
317 |
FieldValues['_GainTotISSF_'] := GainTot;
|
318 |
FieldValues['_GainNetISSF_'] := GainNet;
|
319 |
FieldValues['_P2ISSF_'] := PResSimulT.TabResult[67, DebutStade]; |
320 |
FieldValues['_P2VarISSF_'] := P2Var;
|
321 |
FieldValues['_ConsoISSF_'] := Ingere;
|
322 |
FieldValues['_PDISSF_'] := PD;
|
323 |
FieldValues['_LDISSF_'] := LD;
|
324 |
end;
|
325 |
end;
|
326 |
// R?initialisation
|
327 |
Stade := Trunc(PResSimulT.TabResult[3, Jour]);
|
328 |
GainTot := PResSimulT.TabResult[59, Jour];
|
329 |
GainNet := PResSimulT.TabResult[61, Jour];
|
330 |
P2Var := PResSimulT.TabResult[68, Jour];
|
331 |
Ingere := PResSimulT.TabResult[11, Jour];
|
332 |
PD := PResSimulT.TabResult[63, Jour];
|
333 |
LD := PResSimulT.TabResult[66, Jour];
|
334 |
Lait := PResSimulT.TabResult[69, Jour];
|
335 |
DebutStade := Jour; |
336 |
if Cycle <> Trunc(PResSimulT.TabResult[2, Jour]) |
337 |
then // Changement de cycle |
338 |
begin
|
339 |
Post; |
340 |
Cycle := Trunc(PResSimulT.TabResult[2, Jour]);
|
341 |
Append; |
342 |
FieldValues['_Simul_'] := PSimulT.Nom;
|
343 |
FieldValues['_Profil_'] := FSimulT.CBProfil.Text;
|
344 |
FieldValues['_Loge_'] := FSimulT.CBLoge.Text;
|
345 |
FieldValues['_Init_'] := FSimulT.CBOptInit.Text;
|
346 |
FieldValues['_Cycle_'] := Cycle;
|
347 |
if PSimulT.SeqAli[Cycle] = -1 |
348 |
then // S?quence alimentaire du profil animal |
349 |
FieldValues['_SeqAli_'] := FindNomSeqAliT (PProfilT.SeqAli)
|
350 |
else // S?quence alimentaire de la simulation |
351 |
FieldValues['_SeqAli_'] := FindNomSeqAliT (PSimulT.SeqAli[Cycle]);
|
352 |
if PSimulT.Ration[Cycle] = -1 |
353 |
then // Ration de r?f?rence du profil animal |
354 |
FieldValues['_Ration_'] := FSimulT.CBRationProfil.Text
|
355 |
else // Plan de rationnement de la simulation |
356 |
FieldValues['_Ration_'] := FindNomRationT (PSimulT.Ration[Cycle]);
|
357 |
end;
|
358 |
end;
|
359 |
// Fin de simulation
|
360 |
Duree := PResSimulT.NbJSim - DebutStade + 1;
|
361 |
case Stade of |
362 |
0 : // Gestation |
363 |
begin
|
364 |
FieldValues['_DureeGest_'] := Duree;
|
365 |
FieldValues['_PVGest_'] := PResSimulT.TabResult[58, DebutStade]; |
366 |
FieldValues['_GainTotGest_'] := GainTot;
|
367 |
FieldValues['_GainNetGest_'] := GainNet;
|
368 |
FieldValues['_P2Gest_'] := PResSimulT.TabResult[67, DebutStade]; |
369 |
FieldValues['_P2VarGest_'] := P2Var;
|
370 |
FieldValues['_ConsoGest_'] := Ingere;
|
371 |
FieldValues['_PDGest_'] := PD;
|
372 |
FieldValues['_LDGest_'] := LD;
|
373 |
// Naissance
|
374 |
FieldValues['_NesTot_'] := PProfilT.Porcelets[Cycle].NesTotaux;
|
375 |
FieldValues['_NesVifs_'] := PProfilT.Porcelets[Cycle].NesVivants;
|
376 |
FieldValues['_PdsNais_'] := PProfilT.Porcelets[Cycle].PdsNais;
|
377 |
end;
|
378 |
1 : // Lactation |
379 |
begin
|
380 |
FieldValues['_DureeLact_'] := Duree;
|
381 |
FieldValues['_PVLact_'] := PResSimulT.TabResult[58, DebutStade]; |
382 |
FieldValues['_GainTotLact_'] := GainTot;
|
383 |
FieldValues['_GainNetLact_'] := GainNet;
|
384 |
FieldValues['_P2Lact_'] := PResSimulT.TabResult[67, DebutStade]; |
385 |
FieldValues['_P2VarLact_'] := P2Var;
|
386 |
FieldValues['_ConsoLact_'] := Ingere;
|
387 |
FieldValues['_PDLact_'] := PD;
|
388 |
FieldValues['_LDLact_'] := LD;
|
389 |
// Sevrage
|
390 |
FieldValues['_Sevres_'] := PProfilT.Porcelets[Cycle].Sevres;
|
391 |
// Ajustement du poids de sevrage ? la dur?e de lactation
|
392 |
GainProfil := (273 * PProfilT.DureeLact + (289 / 0.38) * Exp (-0.38 * PProfilT.DureeLact) - 289 / 0.38) / 1000; |
393 |
GainSimul := (273 * PSimulT.DureeLact + (289 / 0.38) * Exp (-0.38 * PSimulT.DureeLact) - 289 / 0.38) / 1000; |
394 |
FieldValues['_PdsSev_'] := PProfilT.Porcelets[Cycle].PdsNais + GainSimul * (PProfilT.Porcelets[Cycle].PdsSev - PProfilT.Porcelets[Cycle].PdsNais) / GainProfil;
|
395 |
FieldValues['_Lait_'] := Lait;
|
396 |
end;
|
397 |
else // ISSF |
398 |
begin
|
399 |
FieldValues['_DureeISSF_'] := Duree;
|
400 |
FieldValues['_PVISSF_'] := PResSimulT.TabResult[58, DebutStade]; |
401 |
FieldValues['_GainTotISSF_'] := GainTot;
|
402 |
FieldValues['_GainNetISSF_'] := GainNet;
|
403 |
FieldValues['_P2ISSF_'] := PResSimulT.TabResult[67, DebutStade]; |
404 |
FieldValues['_P2VarISSF_'] := P2Var;
|
405 |
FieldValues['_ConsoISSF_'] := Ingere;
|
406 |
FieldValues['_PDISSF_'] := PD;
|
407 |
FieldValues['_LDISSF_'] := LD;
|
408 |
end;
|
409 |
end;
|
410 |
Post; |
411 |
end;
|
412 |
RegisterPreviewClass(TQRPrevRapInterface); |
413 |
// QRRapport.PreviewModal;
|
414 |
// RegisterPreviewClass(TQRStandardPreviewInterface);
|
415 |
end;
|
416 |
|
417 |
end.
|