root / UFRationP.pas
Historique | Voir | Annoter | Télécharger (32,438 ko)
1 | 3 | avalancogn | unit UFRationP;
|
---|---|---|---|
2 | |||
3 | interface
|
||
4 | |||
5 | uses
|
||
6 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, |
||
7 | Dialogs, StdCtrls, Buttons, ExtCtrls, Math, PBNumEdit, TeEngine, Series, |
||
8 | TeeProcs, Chart, JvExControls, JvComponent, JvEnterTab, UVariables, |
||
9 | gnugettext; |
||
10 | |||
11 | type
|
||
12 | TFRationP = class(TForm)
|
||
13 | GBRation: TGroupBox; |
||
14 | SBAddRation: TSpeedButton; |
||
15 | SBDelRation: TSpeedButton; |
||
16 | CBRation: TComboBox; |
||
17 | GBRule: TGroupBox; |
||
18 | LModeFin: TLabel; |
||
19 | LNo: TLabel; |
||
20 | SBAddRule: TSpeedButton; |
||
21 | SBDelRule: TSpeedButton; |
||
22 | LAli: TLabel; |
||
23 | LBRule: TListBox; |
||
24 | GBEnd: TGroupBox; |
||
25 | PBValFin: TPBNumEdit; |
||
26 | GBAjust: TGroupBox; |
||
27 | GBParam: TGroupBox; |
||
28 | LUnite: TLabel; |
||
29 | LEqPV: TLabel; |
||
30 | CBUnite: TComboBox; |
||
31 | PBaPV: TPBNumEdit; |
||
32 | RBCoef: TRadioButton; |
||
33 | RBIngere: TRadioButton; |
||
34 | PBbPV: TPBNumEdit; |
||
35 | PBIng50: TPBNumEdit; |
||
36 | PBIng100: TPBNumEdit; |
||
37 | Graph: TChart; |
||
38 | SeriesLigne: TLineSeries; |
||
39 | SBRename: TSpeedButton; |
||
40 | SBComment: TSpeedButton; |
||
41 | PEqPV: TPanel; |
||
42 | PCoefPV: TPanel; |
||
43 | CBModeFin: TComboBox; |
||
44 | PUnite: TPanel; |
||
45 | LType: TLabel; |
||
46 | CBType: TComboBox; |
||
47 | PQuantite: TPanel; |
||
48 | LQuantite: TLabel; |
||
49 | PBQuantite: TPBNumEdit; |
||
50 | CBEqPV: TComboBox; |
||
51 | CBX: TComboBox; |
||
52 | CBY: TComboBox; |
||
53 | GBSim: TGroupBox; |
||
54 | CBSim: TComboBox; |
||
55 | GBY: TGroupBox; |
||
56 | GBX: TGroupBox; |
||
57 | PRation: TPanel; |
||
58 | SBSave: TSpeedButton; |
||
59 | SBPrint: TSpeedButton; |
||
60 | PPercent: TPanel; |
||
61 | LPercent: TLabel; |
||
62 | PBPercent: TPBNumEdit; |
||
63 | JvEnterAsTab: TJvEnterAsTab; |
||
64 | LGaspillage: TLabel; |
||
65 | PBGaspillage: TPBNumEdit; |
||
66 | LaPV: TLabel; |
||
67 | LbPV: TLabel; |
||
68 | LIng100: TLabel; |
||
69 | LIng50: TLabel; |
||
70 | PCoefDuree: TPanel; |
||
71 | LaDuree: TLabel; |
||
72 | LbDuree: TLabel; |
||
73 | PBaDuree: TPBNumEdit; |
||
74 | PBbDuree: TPBNumEdit; |
||
75 | PEqDuree: TPanel; |
||
76 | LEqDuree: TLabel; |
||
77 | CBEqDuree: TComboBox; |
||
78 | GBGraph: TGroupBox; |
||
79 | PGraphTop: TPanel; |
||
80 | PRules: TPanel; |
||
81 | LProfilRef: TLabel; |
||
82 | LSeqAliRef: TLabel; |
||
83 | LWastage: TLabel; |
||
84 | PRight: TPanel; |
||
85 | procedure FormClose(Sender: TObject; var Action: TCloseAction); |
||
86 | procedure FormShow(Sender: TObject);
|
||
87 | procedure CBRationChange(Sender: TObject);
|
||
88 | procedure SBAddRationClick(Sender: TObject);
|
||
89 | procedure SBDelRationClick(Sender: TObject);
|
||
90 | procedure LBRuleClick(Sender: TObject);
|
||
91 | procedure LBRuleDrawItem(Control: TWinControl; Index: Integer;
|
||
92 | Rect: TRect; State: TOwnerDrawState); |
||
93 | procedure SBAddRuleClick(Sender: TObject);
|
||
94 | procedure SBDelRuleClick(Sender: TObject);
|
||
95 | procedure PBValFinChange(Sender: TObject);
|
||
96 | procedure CBUniteChange(Sender: TObject);
|
||
97 | procedure RBCoefClick(Sender: TObject);
|
||
98 | procedure PBaPVChange(Sender: TObject);
|
||
99 | procedure PBbPVChange(Sender: TObject);
|
||
100 | procedure PBIng50Change(Sender: TObject);
|
||
101 | procedure PBIng100Change(Sender: TObject);
|
||
102 | procedure FormDeactivate(Sender: TObject);
|
||
103 | procedure SBRenameClick(Sender: TObject);
|
||
104 | procedure SBCommentClick(Sender: TObject);
|
||
105 | procedure PBQuantiteChange(Sender: TObject);
|
||
106 | procedure CBTypeChange(Sender: TObject);
|
||
107 | procedure CBModeFinChange(Sender: TObject);
|
||
108 | procedure FormActivate(Sender: TObject);
|
||
109 | procedure CBEqDureeChange(Sender: TObject);
|
||
110 | procedure CBEqPVChange(Sender: TObject);
|
||
111 | procedure CBXChange(Sender: TObject);
|
||
112 | procedure CBYChange(Sender: TObject);
|
||
113 | procedure CBSimChange(Sender: TObject);
|
||
114 | procedure SBSaveClick(Sender: TObject);
|
||
115 | procedure SBPrintClick(Sender: TObject);
|
||
116 | procedure FormCreate(Sender: TObject);
|
||
117 | procedure PBPercentChange(Sender: TObject);
|
||
118 | procedure PBGaspillageChange(Sender: TObject);
|
||
119 | procedure PBaDureeChange(Sender: TObject);
|
||
120 | procedure PBbDureeChange(Sender: TObject);
|
||
121 | private
|
||
122 | { D?clarations priv?es }
|
||
123 | Update, Modified: boolean; |
||
124 | IdxRationP, NumRule: integer; |
||
125 | PResSimulP: PTabResSimulP; |
||
126 | procedure Save;
|
||
127 | procedure AffGraph;
|
||
128 | public
|
||
129 | { D?clarations publiques }
|
||
130 | function StrModeFin(n: integer): String; |
||
131 | function StrEquation(n: integer): String; |
||
132 | end;
|
||
133 | |||
134 | var
|
||
135 | FRationP: TFRationP; |
||
136 | |||
137 | implementation
|
||
138 | |||
139 | uses
|
||
140 | UStrings, UInit, UUtil, UFindRec, UCalcul, UEchelle, UFComment, UCalcSimulP, |
||
141 | UFRapRationP; |
||
142 | |||
143 | {$R *.dfm}
|
||
144 | |||
145 | { TFRationP }
|
||
146 | |||
147 | procedure TFRationP.FormCreate(Sender: TObject);
|
||
148 | begin
|
||
149 | if Screen.Fonts.IndexOf('Arial Unicode MS') <> -1 |
||
150 | then
|
||
151 | Font.Name := 'Arial Unicode MS';
|
||
152 | TranslateComponent(Self); |
||
153 | Constraints.MinWidth := 748 + (Width - ClientWidth);
|
||
154 | Width := Constraints.MinWidth; |
||
155 | Constraints.MinHeight := 440 + (Height - ClientHeight);
|
||
156 | Height := Constraints.MinHeight; |
||
157 | CBModeFin.ItemIndex := 0;
|
||
158 | CBType.ItemIndex := 0;
|
||
159 | CBUnite.ItemIndex := 0;
|
||
160 | CBEqDuree.ItemIndex := 0;
|
||
161 | CBEqPV.ItemIndex := 0;
|
||
162 | CBX.ItemIndex := 0;
|
||
163 | CBY.ItemIndex := 0;
|
||
164 | end;
|
||
165 | |||
166 | procedure TFRationP.FormShow(Sender: TObject);
|
||
167 | begin
|
||
168 | Modified := False; |
||
169 | // Abscisses par d?faut
|
||
170 | CBX.ItemIndex := XCrois; |
||
171 | New(PResSimulP); |
||
172 | StringsRationP(CBRation.Items, True); |
||
173 | SBAddRation.Enabled := IsComplete or (ListRationP.Count < 5); |
||
174 | SBSave.Enabled := IsComplete or IsEducation;
|
||
175 | IdxRationP := -1;
|
||
176 | // CBRationChange(nil);
|
||
177 | end;
|
||
178 | |||
179 | procedure TFRationP.FormClose(Sender: TObject; var Action: TCloseAction); |
||
180 | begin
|
||
181 | if Modified then Save; |
||
182 | Dispose(PResSimulP); |
||
183 | Action := caFree; |
||
184 | NumWinRationP := -1;
|
||
185 | end;
|
||
186 | |||
187 | procedure TFRationP.FormActivate(Sender: TObject);
|
||
188 | begin
|
||
189 | StringsSimulP(CBSim.Items, False); |
||
190 | // if IdxRationP <> -1
|
||
191 | // then
|
||
192 | // PRationP := ListRationP[IdxRationP];
|
||
193 | CBRationChange(nil);
|
||
194 | PRation.Enabled := IsComplete or IsEducation or IsEvaluation; |
||
195 | SBAddRule.Visible := PRation.Enabled; |
||
196 | SBDelRule.Visible := PRation.Enabled; |
||
197 | end;
|
||
198 | |||
199 | procedure TFRationP.FormDeactivate(Sender: TObject);
|
||
200 | begin
|
||
201 | if Modified then Save; |
||
202 | end;
|
||
203 | |||
204 | procedure TFRationP.Save;
|
||
205 | var
|
||
206 | s: string;
|
||
207 | begin
|
||
208 | Modified := False; |
||
209 | if IsComplete or IsEducation |
||
210 | then
|
||
211 | if MessageDlg(Caption + sLineBreak + MsgSave, mtConfirmation, [mbYes, mbNo], 0) = mrYes |
||
212 | then
|
||
213 | begin
|
||
214 | SaveRationP; |
||
215 | if not RationPValid(PRationP) |
||
216 | then
|
||
217 | MessageDlg(Format(MsgInvalidData, [Caption, PRationP.Nom]), mtWarning, [mbOK], 0);
|
||
218 | end
|
||
219 | else
|
||
220 | begin
|
||
221 | LoadRationP; |
||
222 | s := CBRation.Text; |
||
223 | StringsRationP(CBRation.Items, True); |
||
224 | if FindIdxRationP(s) = -1 |
||
225 | then
|
||
226 | begin
|
||
227 | IdxRationP := -1;
|
||
228 | CBRationChange(nil);
|
||
229 | end
|
||
230 | else
|
||
231 | CBRation.ItemIndex := CBRation.Items.IndexOf(s); |
||
232 | end;
|
||
233 | end;
|
||
234 | |||
235 | procedure TFRationP.CBRationChange (Sender : TObject) ;
|
||
236 | var
|
||
237 | i : integer ; |
||
238 | begin
|
||
239 | if (IdxRationP <> -1) and (CBRation.Text <> PRationP.Nom) |
||
240 | then
|
||
241 | if Modified then Save ; |
||
242 | IdxRationP := FindIdxRationP (CBRation.Text) ; |
||
243 | LBRule.Clear ; |
||
244 | if IdxRationP = -1 |
||
245 | then
|
||
246 | begin
|
||
247 | CBRation.Repaint ; |
||
248 | SBDelRation.Enabled := FALSE ; |
||
249 | SBRename.Enabled := FALSE ; |
||
250 | SBComment.Enabled := FALSE ; |
||
251 | SBSave.Enabled := FALSE ; |
||
252 | SBPrint.Enabled := FALSE ; |
||
253 | PRation.Visible := FALSE ; |
||
254 | end
|
||
255 | else // Affichage de l'enregistrement |
||
256 | begin
|
||
257 | SBDelRation.Enabled := TRUE ; |
||
258 | SBRename.Enabled := TRUE ; |
||
259 | SBComment.Enabled := TRUE ; |
||
260 | SBSave.Enabled := TRUE ; |
||
261 | SBPrint.Enabled := TRUE ; |
||
262 | PRation.Visible := TRUE ; |
||
263 | PRationP := ListRationP[IdxRationP] ; |
||
264 | with PRationP^ do |
||
265 | CBRation.Hint := Memo ; |
||
266 | with PRationP^ do |
||
267 | for i := 1 to NbRule do |
||
268 | LBRule.Items.Add ('') ;
|
||
269 | LBRule.ItemIndex := 0 ;
|
||
270 | LBRuleClick (nil) ;
|
||
271 | CBSimChange (nil) ;
|
||
272 | end ;
|
||
273 | end ;
|
||
274 | |||
275 | procedure TFRationP.SBAddRationClick (Sender : TObject) ;
|
||
276 | var
|
||
277 | i, n, q : integer ; |
||
278 | s : string ;
|
||
279 | ok : boolean ; |
||
280 | PBackup : PRecRationP ; |
||
281 | begin
|
||
282 | if Modified then Save ; |
||
283 | if IdxRationP = -1 |
||
284 | then
|
||
285 | q := mrNo |
||
286 | else
|
||
287 | q := MessageDlg (MsgCopy, mtConfirmation, [mbYes, mbNo], 0) ;
|
||
288 | // saisie du nouveau nom
|
||
289 | s := '' ;
|
||
290 | repeat
|
||
291 | if InputQuery (FRationP.Caption, MsgName, s)
|
||
292 | then // V?rification du nom |
||
293 | begin
|
||
294 | s := Trim (s) ; // Suppression des espaces au d?but et ? la fin
|
||
295 | if s = '' |
||
296 | then // Pas de nom |
||
297 | begin
|
||
298 | ok := FALSE ; |
||
299 | MessageDlg (MsgNameEmpty, mtWarning, [mbOk], 0) ;
|
||
300 | end
|
||
301 | else
|
||
302 | if Length (s) > 25 |
||
303 | then // Nom trop long |
||
304 | begin
|
||
305 | ok := FALSE ; |
||
306 | MessageDlg (Format (MsgNameTooLarge, [25]), mtWarning, [mbOk], 0) ; |
||
307 | s := Copy (s, 1, 25) ; |
||
308 | end
|
||
309 | else
|
||
310 | begin
|
||
311 | ok := TRUE ; |
||
312 | i := 0 ;
|
||
313 | while ok and (i < ListRationP.Count) do |
||
314 | begin
|
||
315 | PRationP := ListRationP[i] ; |
||
316 | if PRationP.Nom = s
|
||
317 | then // Nom d?j? utilis? |
||
318 | begin
|
||
319 | ok := FALSE ; |
||
320 | MessageDlg (MsgNameExists, mtWarning, [mbOk], 0) ;
|
||
321 | end
|
||
322 | else
|
||
323 | Inc (i) ; |
||
324 | end ;
|
||
325 | end ;
|
||
326 | end
|
||
327 | else // Annulation |
||
328 | begin
|
||
329 | s := '' ;
|
||
330 | if (IdxRationP <> -1) |
||
331 | then
|
||
332 | PRationP := ListRationP[IdxRationP] ; |
||
333 | ok := TRUE ; |
||
334 | end ;
|
||
335 | until ok ;
|
||
336 | if s <> '' |
||
337 | then // Cr?ation du nouvel enregistrement |
||
338 | begin
|
||
339 | // recherche du premier num?ro libre
|
||
340 | n := 0 ;
|
||
341 | repeat
|
||
342 | Inc (n) ; |
||
343 | ok := TRUE ; |
||
344 | i := 0 ;
|
||
345 | while ok and (i < ListRationP.Count) do |
||
346 | begin
|
||
347 | PRationP := ListRationP[i] ; |
||
348 | if PRationP.Num = n
|
||
349 | then
|
||
350 | ok := FALSE |
||
351 | else
|
||
352 | Inc (i) ; |
||
353 | end ;
|
||
354 | until ok ;
|
||
355 | New (PRationP) ; |
||
356 | with PRationP^ do |
||
357 | begin
|
||
358 | Nom := s ; |
||
359 | Num := n ; |
||
360 | if q = mrYes
|
||
361 | then
|
||
362 | begin
|
||
363 | PBackup := ListRationP[IdxRationP] ; |
||
364 | Memo := PBackup.Memo ; |
||
365 | NbRule := PBackup.NbRule ; |
||
366 | Rule := PBackup.Rule ; |
||
367 | end
|
||
368 | else
|
||
369 | begin
|
||
370 | Memo := '';
|
||
371 | NbRule := 1;
|
||
372 | for i := 1 to MAX_RULE do |
||
373 | with Rule[i] do |
||
374 | begin
|
||
375 | ModeFin := -1;
|
||
376 | ValFin := 0;
|
||
377 | Gaspillage := 0;
|
||
378 | RuleType := -1;
|
||
379 | Unite := -1;
|
||
380 | EqDuree := -1;
|
||
381 | EqPV := -1;
|
||
382 | Percent := 1;
|
||
383 | Quantity := 0;
|
||
384 | aDuree := 0;
|
||
385 | bDuree := 0;
|
||
386 | aPV := 0;
|
||
387 | bPV := 0;
|
||
388 | end;
|
||
389 | end;
|
||
390 | end ;
|
||
391 | ListRationP.Add (PRationP) ; |
||
392 | CBRation.Items.Add (PRationP.Nom) ; |
||
393 | CBRation.ItemIndex := CBRation.Items.IndexOf (PRationP.Nom) ; |
||
394 | CBRationChange (nil) ;
|
||
395 | Modified := TRUE ; |
||
396 | SBAddRation.Enabled := IsComplete or (ListRationP.Count < 5) ; |
||
397 | SBCommentClick (nil) ;
|
||
398 | end ;
|
||
399 | end;
|
||
400 | |||
401 | procedure TFRationP.SBDelRationClick (Sender : TObject) ;
|
||
402 | begin
|
||
403 | if RationPUsed (PRationP.Num)
|
||
404 | then // Enregistrement utilis? |
||
405 | MessageDlg (MsgDelErr, mtWarning, [mbOk], 0)
|
||
406 | else // Suppression de l'enregistrement |
||
407 | if MessageDlg (MsgDel, mtConfirmation, [mbYes, mbNo], 0) = mrYes |
||
408 | then
|
||
409 | begin
|
||
410 | Dispose (PRationP) ; |
||
411 | ListRationP.Delete (IdxRationP) ; |
||
412 | SaveRationP ; // Sauvegarde !
|
||
413 | Modified := FALSE ; |
||
414 | CBRation.DeleteSelected ; |
||
415 | IdxRationP := -1 ;
|
||
416 | CBRation.ItemIndex := -1 ;
|
||
417 | CBRationChange (nil) ;
|
||
418 | SBAddRation.Enabled := IsComplete or (ListRationP.Count < 5) ; |
||
419 | end ;
|
||
420 | end ;
|
||
421 | |||
422 | procedure TFRationP.SBRenameClick (Sender : TObject) ;
|
||
423 | var
|
||
424 | i : integer ; |
||
425 | s : string ;
|
||
426 | ok : boolean ; |
||
427 | begin
|
||
428 | // Saisie du nouveau nom
|
||
429 | s := CBRation.Text ; |
||
430 | repeat
|
||
431 | if InputQuery (FRationP.Caption, MsgRename, s) and (s <> CBRation.Text) |
||
432 | then // V?rification du nom |
||
433 | begin
|
||
434 | s := Trim (s) ; // Suppression des espaces au d?but et ? la fin
|
||
435 | if s = '' |
||
436 | then // Pas de nom |
||
437 | begin
|
||
438 | ok := FALSE ; |
||
439 | MessageDlg (MsgNameEmpty, mtWarning, [mbOk], 0) ;
|
||
440 | end
|
||
441 | else
|
||
442 | if Length (s) > 25 |
||
443 | then // Nom trop long |
||
444 | begin
|
||
445 | ok := FALSE ; |
||
446 | MessageDlg (Format (MsgNameTooLarge, [25]), mtWarning, [mbOk], 0) ; |
||
447 | s := Copy (s, 1, 25) ; |
||
448 | end
|
||
449 | else
|
||
450 | begin
|
||
451 | ok := TRUE ; |
||
452 | i := 0 ;
|
||
453 | while ok and (i < ListRationP.Count) do |
||
454 | begin
|
||
455 | PRationP := ListRationP[i] ; |
||
456 | if PRationP.Nom = s
|
||
457 | then // Nom d?j? utilis? |
||
458 | begin
|
||
459 | ok := FALSE ; |
||
460 | MessageDlg (MsgNameExists, mtWarning, [mbOk], 0) ;
|
||
461 | end
|
||
462 | else
|
||
463 | Inc (i) ; |
||
464 | end ;
|
||
465 | end ;
|
||
466 | end
|
||
467 | else // Annulation |
||
468 | begin
|
||
469 | s := '' ;
|
||
470 | ok := TRUE ; |
||
471 | end ;
|
||
472 | until ok ;
|
||
473 | PRationP := ListRationP[IdxRationP] ; |
||
474 | if s <> '' |
||
475 | then // Renommer l'enregistrement |
||
476 | begin
|
||
477 | PRationP.Nom := s ; |
||
478 | Modified := TRUE ; |
||
479 | StringsRationP (CBRation.Items, TRUE) ; |
||
480 | CBRation.ItemIndex := CBRation.Items.IndexOf (s) ; |
||
481 | end ;
|
||
482 | end ;
|
||
483 | |||
484 | procedure TFRationP.SBCommentClick (Sender : TObject) ;
|
||
485 | begin
|
||
486 | // Saisie du commentaire
|
||
487 | FComment := TFComment.Create (Self) ; |
||
488 | with FComment do |
||
489 | begin
|
||
490 | Memo.Text := PRationP.Memo ; |
||
491 | if ShowModal = mrOk
|
||
492 | then // Commenter l'enregistrement |
||
493 | begin
|
||
494 | PRationP.Memo := Memo.Text ; |
||
495 | Modified := TRUE ; |
||
496 | CBRation.Hint := PRationP.Memo ; |
||
497 | end ;
|
||
498 | Release ; |
||
499 | end ;
|
||
500 | end ;
|
||
501 | |||
502 | procedure TFRationP.SBSaveClick(Sender: TObject);
|
||
503 | begin
|
||
504 | SaveRationP ; |
||
505 | if not RationPValid (PRationP) |
||
506 | then
|
||
507 | MessageDlg(Format (MsgInvalidData, [Caption, PRationP.Nom]), mtWarning, [mbOK], 0) ;
|
||
508 | Modified := FALSE ; |
||
509 | end;
|
||
510 | |||
511 | procedure TFRationP.SBPrintClick(Sender: TObject);
|
||
512 | begin
|
||
513 | FRapRationP := TFRapRationP.Create (Self) ; |
||
514 | FRapRationP.QRRapport.PreviewModal ; |
||
515 | FRapRationP.Release ; |
||
516 | end;
|
||
517 | |||
518 | procedure TFRationP.LBRuleClick(Sender: TObject);
|
||
519 | begin
|
||
520 | NumRule := LBRule.ItemIndex + 1;
|
||
521 | SBAddRule.Enabled := LBRule.Items.Count < MAX_RULE; |
||
522 | SBDelRule.Enabled := NumRule < PRationP.NbRule; |
||
523 | GBEnd.Visible := SBDelRule.Enabled; |
||
524 | with PRationP.Rule[NumRule] do |
||
525 | begin
|
||
526 | Update := True; |
||
527 | CBModeFin.ItemIndex := ModeFin; |
||
528 | CBModeFinChange(nil);
|
||
529 | PBValFin.AsFloat := ValFin; |
||
530 | PBGaspillage.AsFloat := Gaspillage * 100;
|
||
531 | CBType.ItemIndex := RuleType; |
||
532 | CBTypeChange(nil);
|
||
533 | CBUnite.ItemIndex := Unite; |
||
534 | CBUniteChange(nil);
|
||
535 | CBEqDuree.ItemIndex := EqDuree; |
||
536 | CBEqDureeChange(nil);
|
||
537 | CBEqPV.ItemIndex := EqPV; |
||
538 | CBEqPVChange(nil);
|
||
539 | PBPercent.Value := Percent * 100;
|
||
540 | PBQuantite.AsFloat := Quantity / (1 - Gaspillage);
|
||
541 | PBaDuree.AsFloat := aDuree / (1 - Gaspillage);
|
||
542 | PBbDuree.AsFloat := bDuree / (1 - Gaspillage);
|
||
543 | PBaPV.AsFloat := aPV / (1 - Gaspillage);
|
||
544 | if EqPV = 0 |
||
545 | then // a+b*PV |
||
546 | PBbPV.AsFloat := bPV / (1 - Gaspillage)
|
||
547 | else
|
||
548 | PBbPV.AsFloat := bPV; |
||
549 | PBIng50.AsFloat := CalcIngere(EqPV, Unite, PBaPV.AsFloat, PBbPV.AsFloat, 50);
|
||
550 | PBIng100.AsFloat := CalcIngere(EqPV, Unite, PBaPV.AsFloat, PBbPV.AsFloat, 100);
|
||
551 | Update := False; |
||
552 | end;
|
||
553 | end;
|
||
554 | |||
555 | procedure TFRationP.LBRuleDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
|
||
556 | begin
|
||
557 | with (Control as TListBox).Canvas do |
||
558 | begin
|
||
559 | // Cadre principal
|
||
560 | FillRect(Rect); |
||
561 | // Texte
|
||
562 | SetTextAlign(Handle, TA_RIGHT); |
||
563 | Rect.Right := LBRule.Width - 4;
|
||
564 | TextRect(Rect, Rect.Right, Rect.Top, Format('%1.0f%%', [PRationP.Rule[Index + 1].Gaspillage * 100])); |
||
565 | Rect.Right := 338;
|
||
566 | SetTextAlign(Handle, TA_LEFT); |
||
567 | Rect.Left := 22;
|
||
568 | TextRect(Rect, Rect.Left, Rect.Top, StrModeFin(Index + 1));
|
||
569 | Rect.Left := 182;
|
||
570 | TextRect(Rect, Rect.Left, Rect.Top, StrEquation(Index + 1));
|
||
571 | Rect.Left := 0;
|
||
572 | // Num?ro
|
||
573 | SetTextAlign(Handle, TA_RIGHT); |
||
574 | Rect.Right := 14;
|
||
575 | TextRect(Rect, Rect.Right, Rect.Top, Format('%d', [Index + 1])); |
||
576 | end;
|
||
577 | end;
|
||
578 | |||
579 | procedure TFRationP.SBAddRuleClick (Sender : TObject) ;
|
||
580 | var
|
||
581 | i : integer ; |
||
582 | begin
|
||
583 | for i := PRationP.NbRule downto NumRule do |
||
584 | PRationP.Rule[i + 1] := PRationP.Rule[i] ;
|
||
585 | with PRationP.Rule[NumRule] do |
||
586 | begin
|
||
587 | ModeFin := -1 ;
|
||
588 | ValFin := 0 ;
|
||
589 | end ;
|
||
590 | Inc (PRationP.NbRule) ; |
||
591 | LBRule.Items.Add ('') ;
|
||
592 | LBRule.ItemIndex := NumRule - 1 ;
|
||
593 | LBRuleClick (nil) ;
|
||
594 | Modified := TRUE ; |
||
595 | ActiveControl := CBModeFin ; |
||
596 | end ;
|
||
597 | |||
598 | procedure TFRationP.SBDelRuleClick (Sender : TObject) ;
|
||
599 | var
|
||
600 | i : integer ; |
||
601 | begin
|
||
602 | PRationP.NbRule := PRationP.NbRule - 1 ;
|
||
603 | for i := NumRule to PRationP.NbRule do |
||
604 | PRationP.Rule[i] := PRationP.Rule[i + 1] ;
|
||
605 | i := NumRule ; // Position courante
|
||
606 | LBRule.DeleteSelected ; |
||
607 | LBRule.ItemIndex := i - 1 ;
|
||
608 | LBRuleClick (nil) ;
|
||
609 | CBSimChange (nil) ;
|
||
610 | ActiveControl := LBRule ; |
||
611 | Modified := TRUE ; |
||
612 | end ;
|
||
613 | |||
614 | procedure TFRationP.CBModeFinChange(Sender: TObject);
|
||
615 | begin
|
||
616 | PBValFin.Visible := CBModeFin.ItemIndex <> -1;
|
||
617 | if CBModeFin.ItemIndex >= 4 |
||
618 | then // Consommation |
||
619 | PBValFin.Decimals := 3
|
||
620 | else
|
||
621 | PBValFin.Decimals := 0;
|
||
622 | if not Update |
||
623 | then
|
||
624 | begin
|
||
625 | Modified := True; |
||
626 | PRationP.Rule[NumRule].ModeFin := CBModeFin.ItemIndex; |
||
627 | LBRule.Repaint; |
||
628 | CBSimChange(nil);
|
||
629 | end;
|
||
630 | end;
|
||
631 | |||
632 | procedure TFRationP.PBValFinChange(Sender : TObject);
|
||
633 | begin
|
||
634 | if not Update |
||
635 | then
|
||
636 | begin
|
||
637 | Modified := True; |
||
638 | PRationP.Rule[NumRule].ValFin := PBValFin.AsFloat; |
||
639 | LBRule.Repaint; |
||
640 | CBSimChange(nil);
|
||
641 | end;
|
||
642 | end;
|
||
643 | |||
644 | procedure TFRationP.PBGaspillageChange(Sender: TObject);
|
||
645 | begin
|
||
646 | if not Update |
||
647 | then
|
||
648 | begin
|
||
649 | Modified := True; |
||
650 | PRationP.Rule[NumRule].Gaspillage := PBGaspillage.AsFloat / 100;
|
||
651 | // Recalculer Quantity
|
||
652 | PRationP.Rule[NumRule].Quantity := PBQuantite.AsFloat * (1 - PRationP.Rule[NumRule].Gaspillage);
|
||
653 | // Recalculer aDuree et bDuree
|
||
654 | PRationP.Rule[NumRule].aDuree := PBaDuree.AsFloat * (1 - PRationP.Rule[NumRule].Gaspillage);
|
||
655 | PRationP.Rule[NumRule].bDuree := PBbDuree.AsFloat * (1 - PRationP.Rule[NumRule].Gaspillage);
|
||
656 | // Recalculer aPV et bPV
|
||
657 | PRationP.Rule[NumRule].aPV := PBaPV.AsFloat * (1 - PRationP.Rule[NumRule].Gaspillage);
|
||
658 | if CBEqPV.ItemIndex = 0 |
||
659 | then // a+b*PV |
||
660 | PRationP.Rule[NumRule].bPV := PBbPV.AsFloat * (1 - PRationP.Rule[NumRule].Gaspillage);
|
||
661 | LBRule.Repaint; |
||
662 | CBSimChange(nil);
|
||
663 | end;
|
||
664 | end;
|
||
665 | |||
666 | procedure TFRationP.CBTypeChange(Sender: TObject);
|
||
667 | begin
|
||
668 | PUnite.Visible := False; |
||
669 | PPercent.Visible := False; |
||
670 | PQuantite.Visible := False; |
||
671 | PEqDuree.Visible := False; |
||
672 | PCoefDuree.Visible := False; |
||
673 | PEqPV.Visible := False; |
||
674 | PCoefPV.Visible := False; |
||
675 | case CBType.ItemIndex of |
||
676 | 0: // % Ad libitum |
||
677 | PPercent.Visible := True; |
||
678 | 1: // Constant |
||
679 | begin
|
||
680 | PUnite.Visible := True; |
||
681 | PQuantite.Visible := True; |
||
682 | end;
|
||
683 | 2: // f(dur?e) |
||
684 | begin
|
||
685 | PUnite.Visible := True; |
||
686 | PEqDuree.Visible := True; |
||
687 | CBEqDureeChange(nil);
|
||
688 | end;
|
||
689 | 3: // f(poids vif) |
||
690 | begin
|
||
691 | PUnite.Visible := True; |
||
692 | PEqPV.Visible := True; |
||
693 | CBEqPVChange(nil);
|
||
694 | end;
|
||
695 | end;
|
||
696 | if not Update |
||
697 | then
|
||
698 | begin
|
||
699 | Modified := True; |
||
700 | PRationP.Rule[NumRule].RuleType := CBType.ItemIndex; |
||
701 | LBRule.Repaint; |
||
702 | CBSimChange(nil);
|
||
703 | end;
|
||
704 | end;
|
||
705 | |||
706 | procedure TFRationP.CBUniteChange(Sender: TObject);
|
||
707 | var
|
||
708 | etat: boolean; |
||
709 | d, m, Ing50, Ing100: Double; |
||
710 | begin
|
||
711 | etat := Update; |
||
712 | Update := True; |
||
713 | // Ajustement de la pr?cision de Quantity, aDuree, bDuree, Ing50 et Ing100
|
||
714 | if (CBUnite.ItemIndex = 0) or (CBUnite.ItemIndex = 4) |
||
715 | then // kg (QI ou MS) |
||
716 | begin
|
||
717 | PBQuantite.Decimals := 3;
|
||
718 | PBaDuree.Decimals := 3;
|
||
719 | PBbDuree.Decimals := 3;
|
||
720 | PBIng50.Decimals := 3;
|
||
721 | PBIng100.Decimals := 3;
|
||
722 | end
|
||
723 | else // MJ (ED, EM ou EN) |
||
724 | begin
|
||
725 | PBQuantite.Decimals := 2;
|
||
726 | PBaDuree.Decimals := 2;
|
||
727 | PBbDuree.Decimals := 2;
|
||
728 | PBIng50.Decimals := 2;
|
||
729 | PBIng100.Decimals := 2;
|
||
730 | end;
|
||
731 | Update := etat; |
||
732 | if not Update |
||
733 | then
|
||
734 | begin
|
||
735 | Update := True; |
||
736 | CBEqPVChange(nil);
|
||
737 | Update := False; |
||
738 | // Ancienne unit? (diviseur)
|
||
739 | case PProfilP.Unite of |
||
740 | 0: // Quantit? (kg/j) |
||
741 | d := cGammaFrais; |
||
742 | 1: // ED (MJ/j) |
||
743 | d := cGammaED; |
||
744 | 2: // EM (MJ/j) |
||
745 | d := cGammaEM; |
||
746 | 3: // EN (MJ/j) |
||
747 | d := cGammaEN; |
||
748 | 4: // MS (kg/j) |
||
749 | d := cGammaMS; |
||
750 | else
|
||
751 | d := 1;
|
||
752 | end;
|
||
753 | // Nouvelle unit? (multiplicateur)
|
||
754 | case CBUnite.ItemIndex of |
||
755 | 0: // Quantit? (kg/j) |
||
756 | m := cGammaFrais; |
||
757 | 1: // ED (MJ/j) |
||
758 | m := cGammaED; |
||
759 | 2: // EM (MJ/j) |
||
760 | m := cGammaEM; |
||
761 | 3: // EN (MJ/j) |
||
762 | m := cGammaEN; |
||
763 | 4: // MS (kg/j) |
||
764 | m := cGammaMS; |
||
765 | else
|
||
766 | m := 1;
|
||
767 | end;
|
||
768 | Modified := True; |
||
769 | PRationP.Rule[NumRule].Unite := CBUnite.ItemIndex; |
||
770 | if d <> m
|
||
771 | then // Conversion |
||
772 | begin
|
||
773 | Update := True; |
||
774 | RBIngere.Checked := True; |
||
775 | PBIng50.AsFloat := m * PBIng50.AsFloat / d; |
||
776 | PBIng100.AsFloat := m * PBIng100.AsFloat / d; |
||
777 | with PRationP.Rule[NumRule] do |
||
778 | begin
|
||
779 | Ing50 := PBIng50.AsFloat * (1 - Gaspillage);
|
||
780 | Ing100 := PBIng100.AsFloat * (1 - Gaspillage);
|
||
781 | CalcCoef(EqPV, Unite, Ing50, Ing100, aPV, bPV); |
||
782 | PBaPV.AsFloat := aPV / (1 - Gaspillage);
|
||
783 | if EqPV = 0 |
||
784 | then // a+b*PV |
||
785 | PBbPV.AsFloat := bPV / (1 - Gaspillage)
|
||
786 | else
|
||
787 | PBbPV.AsFloat := bPV; |
||
788 | end;
|
||
789 | Update := False; |
||
790 | end;
|
||
791 | LBRule.Repaint; |
||
792 | CBSimChange(nil);
|
||
793 | end;
|
||
794 | end;
|
||
795 | |||
796 | procedure TFRationP.CBEqDureeChange(Sender: TObject);
|
||
797 | begin
|
||
798 | PCoefDuree.Visible := (CBType.ItemIndex = 2) and (CBEqDuree.ItemIndex <> -1); |
||
799 | if not Update |
||
800 | then
|
||
801 | begin
|
||
802 | Modified := True; |
||
803 | PRationP.Rule[NumRule].EqDuree := CBEqDuree.ItemIndex; |
||
804 | LBRule.Repaint; |
||
805 | CBSimChange(nil);
|
||
806 | end;
|
||
807 | end;
|
||
808 | |||
809 | procedure TFRationP.CBEqPVChange(Sender: TObject);
|
||
810 | var
|
||
811 | etat: Boolean; |
||
812 | Ing50, Ing100: Double; |
||
813 | begin
|
||
814 | etat := Update; |
||
815 | Update := True; |
||
816 | // Ajustement de la pr?cision des coefficients a et b
|
||
817 | case CBEqPV.ItemIndex of |
||
818 | 0: // a+b*PV |
||
819 | if (CBUnite.ItemIndex = 0) or (CBUnite.ItemIndex = 4) |
||
820 | then // kg (QI ou MS) |
||
821 | begin
|
||
822 | PBaPV.Decimals := 3;
|
||
823 | PBbPV.Decimals := 3;
|
||
824 | end
|
||
825 | else // MJ (ED, EM ou EN) |
||
826 | begin
|
||
827 | PBaPV.Decimals := 2;
|
||
828 | PBbPV.Decimals := 2;
|
||
829 | end;
|
||
830 | 1: // a*PV^b |
||
831 | begin
|
||
832 | if (CBUnite.ItemIndex = 0) or (CBUnite.ItemIndex = 4) |
||
833 | then // kg (QI ou MS) |
||
834 | PBaPV.Decimals := 4
|
||
835 | else // MJ (ED, EM ou EN) |
||
836 | PBaPV.Decimals := 3;
|
||
837 | PBbPV.Decimals := 4;
|
||
838 | end;
|
||
839 | 2: // a*(1-exp(-b*PV)) |
||
840 | begin
|
||
841 | if (CBUnite.ItemIndex = 0) or (CBUnite.ItemIndex = 4) |
||
842 | then // kg (QI ou MS) |
||
843 | PBaPV.Decimals := 3
|
||
844 | else // MJ (ED, EM ou EN) |
||
845 | PBaPV.Decimals := 2;
|
||
846 | PBbPV.Decimals := 5;
|
||
847 | end;
|
||
848 | end;
|
||
849 | Update := etat; |
||
850 | PCoefPV.Visible := (CBType.ItemIndex = 3) and (CBEqPV.ItemIndex <> -1); |
||
851 | if not Update |
||
852 | then
|
||
853 | begin
|
||
854 | Modified := True; |
||
855 | PRationP.Rule[NumRule].EqPV := CBEqPV.ItemIndex; |
||
856 | Update := True; |
||
857 | RBIngere.Checked := True; |
||
858 | with PRationP.Rule[NumRule] do |
||
859 | begin
|
||
860 | Ing50 := PBIng50.AsFloat * (1 - Gaspillage);
|
||
861 | Ing100 := PBIng100.AsFloat * (1 - Gaspillage);
|
||
862 | CalcCoef(EqPV, Unite, Ing50, Ing100, aPV, bPV); |
||
863 | PBaPV.AsFloat := aPV / (1 - Gaspillage);
|
||
864 | if EqPV = 0 |
||
865 | then // a+b*PV |
||
866 | PBbPV.AsFloat := bPV / (1 - Gaspillage)
|
||
867 | else
|
||
868 | PBbPV.AsFloat := bPV; |
||
869 | end;
|
||
870 | Update := False; |
||
871 | LBRule.Repaint; |
||
872 | CBSimChange(nil);
|
||
873 | end;
|
||
874 | end;
|
||
875 | |||
876 | procedure TFRationP.PBPercentChange(Sender: TObject);
|
||
877 | begin
|
||
878 | if not Update |
||
879 | then
|
||
880 | begin
|
||
881 | Modified := True; |
||
882 | PRationP.Rule[NumRule].Percent := PBPercent.AsInteger / 100;
|
||
883 | LBRule.Repaint; |
||
884 | CBSimChange(nil);
|
||
885 | end;
|
||
886 | end;
|
||
887 | |||
888 | procedure TFRationP.PBQuantiteChange(Sender: TObject);
|
||
889 | begin
|
||
890 | if not Update |
||
891 | then
|
||
892 | begin
|
||
893 | Modified := True; |
||
894 | PRationP.Rule[NumRule].Quantity := PBQuantite.AsFloat * (1 - PRationP.Rule[NumRule].Gaspillage);
|
||
895 | LBRule.Repaint; |
||
896 | CBSimChange(nil);
|
||
897 | end;
|
||
898 | end;
|
||
899 | |||
900 | procedure TFRationP.PBaDureeChange(Sender: TObject);
|
||
901 | begin
|
||
902 | if not Update |
||
903 | then
|
||
904 | begin
|
||
905 | Modified := True; |
||
906 | PRationP.Rule[NumRule].aDuree := PBaDuree.AsFloat * (1 - PRationP.Rule[NumRule].Gaspillage);
|
||
907 | LBRule.Repaint; |
||
908 | CBSimChange(nil);
|
||
909 | end;
|
||
910 | end;
|
||
911 | |||
912 | procedure TFRationP.PBbDureeChange(Sender: TObject);
|
||
913 | begin
|
||
914 | if not Update |
||
915 | then
|
||
916 | begin
|
||
917 | Modified := True; |
||
918 | PRationP.Rule[NumRule].bDuree := PBbDuree.AsFloat * (1 - PRationP.Rule[NumRule].Gaspillage);
|
||
919 | LBRule.Repaint; |
||
920 | CBSimChange(nil);
|
||
921 | end;
|
||
922 | end;
|
||
923 | |||
924 | procedure TFRationP.RBCoefClick(Sender: TObject);
|
||
925 | begin
|
||
926 | PBaPV.Enabled := RBCoef.Checked; |
||
927 | PBbPV.Enabled := RBCoef.Checked; |
||
928 | PBIng50.Enabled := RBIngere.Checked; |
||
929 | PBIng100.Enabled := RBIngere.Checked; |
||
930 | end;
|
||
931 | |||
932 | procedure TFRationP.PBaPVChange(Sender: TObject);
|
||
933 | begin
|
||
934 | if not Update |
||
935 | then
|
||
936 | begin
|
||
937 | Modified := True; |
||
938 | PRationP.Rule[NumRule].aPV := PBaPV.AsFloat * (1 - PRationP.Rule[NumRule].Gaspillage);
|
||
939 | Update := True; |
||
940 | with PRationP.Rule[NumRule] do |
||
941 | begin
|
||
942 | PBIng50.AsFloat := CalcIngere(EqPV, Unite, PBaPV.AsFloat, PBbPV.AsFloat, 50);
|
||
943 | PBIng100.AsFloat := CalcIngere(EqPV, Unite, PBaPV.AsFloat, PBbPV.AsFloat, 100);
|
||
944 | end;
|
||
945 | Update := False; |
||
946 | LBRule.Repaint; |
||
947 | CBSimChange(nil);
|
||
948 | end;
|
||
949 | end;
|
||
950 | |||
951 | procedure TFRationP.PBbPVChange(Sender: TObject);
|
||
952 | begin
|
||
953 | if not Update |
||
954 | then
|
||
955 | begin
|
||
956 | Modified := True; |
||
957 | if CBEqPV.ItemIndex = 0 |
||
958 | then // a+b*PV |
||
959 | PRationP.Rule[NumRule].bPV := PBbPV.AsFloat * (1 - PRationP.Rule[NumRule].Gaspillage)
|
||
960 | else
|
||
961 | PRationP.Rule[NumRule].bPV := PBbPV.AsFloat; |
||
962 | Update := True; |
||
963 | with PRationP.Rule[NumRule] do |
||
964 | begin
|
||
965 | PBIng50.AsFloat := CalcIngere(EqPV, Unite, PBaPV.AsFloat, PBbPV.AsFloat, 50);
|
||
966 | PBIng100.AsFloat := CalcIngere(EqPV, Unite, PBaPV.AsFloat, PBbPV.AsFloat, 100);
|
||
967 | end;
|
||
968 | Update := False; |
||
969 | LBRule.Repaint; |
||
970 | CBSimChange(nil);
|
||
971 | end;
|
||
972 | end;
|
||
973 | |||
974 | procedure TFRationP.PBIng50Change(Sender: TObject);
|
||
975 | var
|
||
976 | Ing50, Ing100: Double; |
||
977 | begin
|
||
978 | if not Update |
||
979 | then
|
||
980 | begin
|
||
981 | Modified := True; |
||
982 | Update := True; |
||
983 | with PRationP.Rule[NumRule] do |
||
984 | begin
|
||
985 | Ing50 := PBIng50.AsFloat * (1 - Gaspillage);
|
||
986 | Ing100 := PBIng100.AsFloat * (1 - Gaspillage);
|
||
987 | CalcCoef(EqPV, Unite, Ing50, Ing100, aPV, bPV); |
||
988 | PBaPV.AsFloat := aPV / (1 - Gaspillage);
|
||
989 | if EqPV = 0 |
||
990 | then // a+b*PV |
||
991 | PBbPV.AsFloat := bPV / (1 - Gaspillage)
|
||
992 | else
|
||
993 | PBbPV.AsFloat := bPV; |
||
994 | end;
|
||
995 | Update := False; |
||
996 | LBRule.Repaint; |
||
997 | CBSimChange(nil);
|
||
998 | end;
|
||
999 | end;
|
||
1000 | |||
1001 | procedure TFRationP.PBIng100Change(Sender: TObject);
|
||
1002 | var
|
||
1003 | Ing50, Ing100: Double; |
||
1004 | begin
|
||
1005 | if not Update |
||
1006 | then
|
||
1007 | begin
|
||
1008 | Modified := True; |
||
1009 | Update := True; |
||
1010 | with PRationP.Rule[NumRule] do |
||
1011 | begin
|
||
1012 | Ing50 := PBIng50.AsFloat * (1 - Gaspillage);
|
||
1013 | Ing100 := PBIng100.AsFloat * (1 - Gaspillage);
|
||
1014 | CalcCoef(EqPV, Unite, Ing50, Ing100, aPV, bPV); |
||
1015 | PBaPV.AsFloat := aPV / (1 - Gaspillage);
|
||
1016 | if EqPV = 0 |
||
1017 | then // a+b*PV |
||
1018 | PBbPV.AsFloat := bPV / (1 - Gaspillage)
|
||
1019 | else
|
||
1020 | PBbPV.AsFloat := bPV; |
||
1021 | end;
|
||
1022 | Update := False; |
||
1023 | LBRule.Repaint; |
||
1024 | CBSimChange(nil);
|
||
1025 | end;
|
||
1026 | end;
|
||
1027 | |||
1028 | function TFRationP.StrModeFin(n: integer): String; |
||
1029 | begin
|
||
1030 | if n = PRationP.NbRule
|
||
1031 | then // Fin de simulation |
||
1032 | result := _('End of simulation')
|
||
1033 | else
|
||
1034 | with PRationP.Rule[n] do |
||
1035 | case ModeFin of |
||
1036 | 0, 1, 2, 3 : // Dur?e, Age, Poids vif ou Cumul aliment |
||
1037 | result := Format('%s=%1.0f', [CBModeFin.Items[ModeFin], ValFin]);
|
||
1038 | 4..8 : // Consommation |
||
1039 | result := Format('%s=%s', [CBModeFin.Items[ModeFin], DblToStr(ValFin, 3)]); |
||
1040 | else
|
||
1041 | result := '';
|
||
1042 | end;
|
||
1043 | end;
|
||
1044 | |||
1045 | function TFRationP.StrEquation(n: integer): String; |
||
1046 | begin
|
||
1047 | with PRationP.Rule[n] do |
||
1048 | case RuleType of |
||
1049 | 0: // % Ad libitum |
||
1050 | result := Format('%1.0f%% %s', [Percent * 100, StrAdLib]); |
||
1051 | 1: // Constant |
||
1052 | if (Unite = 0) or (Unite = 4) |
||
1053 | then // kg (QI ou MS) |
||
1054 | result := Format('%s=%s', [CBUnite.Items[Unite], DblToStr(Quantity / (1 - Gaspillage), 3)]) |
||
1055 | else // MJ (ED, EM ou EN) |
||
1056 | result := Format('%s=%s', [CBUnite.Items[Unite], DblToStr(Quantity / (1 - Gaspillage), 2)]); |
||
1057 | 2: // f(dur?e) |
||
1058 | case EqDuree of |
||
1059 | 0: // a+b*jour |
||
1060 | if (Unite = 0) or (Unite = 4) |
||
1061 | then // kg (QI ou MS) |
||
1062 | result := Format('%s=%s+%s*%s', [CBUnite.Items[Unite], DblToStr(aDuree / (1 - Gaspillage), 3), DblToStr (bDuree / (1 - Gaspillage), 2), _('Day')]) |
||
1063 | else // MJ (ED, EM ou EN) |
||
1064 | result := Format('%s=%s+%s*%s', [CBUnite.Items[Unite], DblToStr(aDuree / (1 - Gaspillage), 2), DblToStr (bDuree / (1 - Gaspillage), 3), _('Day')]); |
||
1065 | 1: // a+b*semaine |
||
1066 | if (Unite = 0) or (Unite = 4) |
||
1067 | then // kg (QI ou MS) |
||
1068 | result := Format('%s=%s+%s*%s', [CBUnite.Items[Unite], DblToStr(aDuree / (1 - Gaspillage), 3), DblToStr (bDuree / (1 - Gaspillage), 2), _('Week')]) |
||
1069 | else // MJ (ED, EM ou EN) |
||
1070 | result := Format('%s=%s+%s*%s', [CBUnite.Items[Unite], DblToStr(aDuree / (1 - Gaspillage), 2), DblToStr (bDuree / (1 - Gaspillage), 3), _('Week')]); |
||
1071 | else
|
||
1072 | result := '';
|
||
1073 | end;
|
||
1074 | 3: // f(poids vif) |
||
1075 | case EqPV of |
||
1076 | 0: // a+b*PV |
||
1077 | if (Unite = 0) or (Unite = 4) |
||
1078 | then // kg (QI ou MS) |
||
1079 | result := Format('%s=%s+%s*%s', [CBUnite.Items[Unite], DblToStr(aPV / (1 - Gaspillage), 3), DblToStr(bPV / (1 - Gaspillage), 2), _('BW')]) |
||
1080 | else // MJ (ED, EM ou EN) |
||
1081 | result := Format('%s=%s+%s*%s', [CBUnite.Items[Unite], DblToStr(aPV / (1 - Gaspillage), 2), DblToStr(bPV / (1 - Gaspillage), 3), _('BW')]); |
||
1082 | 1: // a*PV^b |
||
1083 | if (Unite = 0) or (Unite = 4) |
||
1084 | then // kg (QI ou MS) |
||
1085 | result := Format('%s=%s*%s^%s', [CBUnite.Items[Unite], DblToStr(aPV / (1 - Gaspillage), 4), _('BW'), DblToStr(bPV, 4)]) |
||
1086 | else // MJ (ED, EM ou EN) |
||
1087 | result := Format('%s=%s*%s^%s', [CBUnite.Items[Unite], DblToStr(aPV / (1 - Gaspillage), 3), _('BW'), DblToStr(bPV, 4)]); |
||
1088 | 2: // a*(1-exp(-b*PV)) |
||
1089 | if (Unite = 0) or (Unite = 4) |
||
1090 | then // kg (QI ou MS) |
||
1091 | result := Format('%s=%s*(1-exp(-%s*%s))', [CBUnite.Items[Unite], DblToStr(aPV / (1 - Gaspillage), 3), DblToStr(bPV, 5), _('BW')]) |
||
1092 | else // MJ (ED, EM ou EN) |
||
1093 | result := Format('%s=%s*(1-exp(-%s*%s))', [CBUnite.Items[Unite], DblToStr(aPV / (1 - Gaspillage), 2), DblToStr(bPV, 5), _('BW')]); |
||
1094 | else
|
||
1095 | result := '';
|
||
1096 | end;
|
||
1097 | else
|
||
1098 | result := '';
|
||
1099 | end;
|
||
1100 | end;
|
||
1101 | |||
1102 | procedure TFRationP.AffGraph;
|
||
1103 | var
|
||
1104 | j: integer; |
||
1105 | |||
1106 | // Abscisse
|
||
1107 | function X: double;
|
||
1108 | begin
|
||
1109 | case CBX.ItemIndex of |
||
1110 | 0: // Poids vif |
||
1111 | result := PResSimulP.TabResult[2, j];
|
||
1112 | 1: // Age |
||
1113 | result := PResSimulP.TabResult[1, j];
|
||
1114 | 2: // Jours |
||
1115 | result := j; |
||
1116 | 3: // Semaines |
||
1117 | result := j / 7;
|
||
1118 | else
|
||
1119 | result := 0;
|
||
1120 | end;
|
||
1121 | end;
|
||
1122 | |||
1123 | // Ordonn?e
|
||
1124 | function Y: double;
|
||
1125 | begin
|
||
1126 | case CBY.ItemIndex of |
||
1127 | 0: // QI |
||
1128 | result := PResSimulP.TabResult[113, j];
|
||
1129 | 1: // MS |
||
1130 | result := PResSimulP.TabResult[106, j] * PResSimulP.TabResult[113, j]; |
||
1131 | 2: // ED |
||
1132 | result := PResSimulP.TabResult[109, j] * PResSimulP.TabResult[113, j]; |
||
1133 | 3: // EM |
||
1134 | result := PResSimulP.TabResult[89, j] * PResSimulP.TabResult[113, j]; |
||
1135 | 4: // EN |
||
1136 | result := PResSimulP.TabResult[90, j] * PResSimulP.TabResult[113, j]; |
||
1137 | else
|
||
1138 | result := 0;
|
||
1139 | end;
|
||
1140 | end;
|
||
1141 | |||
1142 | // AffGraph
|
||
1143 | begin
|
||
1144 | Graph.LeftAxis.Title.Caption := CBY.Text; |
||
1145 | Graph.BottomAxis.Title.Caption := CBX.Text; |
||
1146 | SeriesLigne.Clear; |
||
1147 | if (CBSim.ItemIndex <> -1) and RationPValid (PRationP) |
||
1148 | then // Affichage de la ligne |
||
1149 | for j := 1 to PResSimulP.NbJSim do |
||
1150 | SeriesLigne.AddXY (X, Y, '', clTeeColor);
|
||
1151 | if CBX.ItemIndex = 3 |
||
1152 | then
|
||
1153 | Graph.BottomAxis.Increment := 1
|
||
1154 | else
|
||
1155 | Graph.BottomAxis.Increment := 10;
|
||
1156 | AjustEchelle(Graph); |
||
1157 | end;
|
||
1158 | |||
1159 | procedure TFRationP.CBXChange(Sender: TObject);
|
||
1160 | begin
|
||
1161 | AffGraph; |
||
1162 | end;
|
||
1163 | |||
1164 | procedure TFRationP.CBYChange(Sender: TObject);
|
||
1165 | begin
|
||
1166 | AffGraph; |
||
1167 | end;
|
||
1168 | |||
1169 | procedure TFRationP.CBSimChange(Sender: TObject);
|
||
1170 | begin
|
||
1171 | if RationPValid(PRationP) and (CBSim.ItemIndex <> -1) |
||
1172 | then
|
||
1173 | begin
|
||
1174 | PSimulP := ListSimulP[FindIdxSimulP(CBSim.Text)]; |
||
1175 | CBSim.Hint := PSimulP.Memo ; |
||
1176 | LProfilRef.Caption := Format(StrRationProfil, [FindNomProfilP(PSimulP.Profil)]); |
||
1177 | LSeqAliRef.Caption := Format(StrRationSeqAli, [FindNomSeqAliP(PSimulP.SeqAli)]); |
||
1178 | CalcSimulP(PSimulP.Num, -1, -1, PRationP.Num, -1, 1, {1,} PResSimulP); |
||
1179 | end
|
||
1180 | else
|
||
1181 | begin
|
||
1182 | CBSim.Hint := '';
|
||
1183 | LProfilRef.Caption := '';
|
||
1184 | LSeqAliRef.Caption := '';
|
||
1185 | end ;
|
||
1186 | AffGraph; |
||
1187 | end;
|
||
1188 | |||
1189 | end. |