1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
|
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, ExtCtrls, Spin, math;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
FloatSpinEdit1: TFloatSpinEdit;
FloatSpinEdit2: TFloatSpinEdit;
FloatSpinEdit3: TFloatSpinEdit;
FloatSpinEdit4: TFloatSpinEdit;
FloatSpinEdit5: TFloatSpinEdit;
FloatSpinEdit6: TFloatSpinEdit;
FloatSpinEdit7: TFloatSpinEdit;
Label1: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioButton3: TRadioButton;
RadioButton4: TRadioButton;
RadioButton5: TRadioButton;
RadioButton6: TRadioButton;
RadioButton7: TRadioButton;
RadioButton8: TRadioButton;
RadioGroup1: TRadioGroup;
RadioGroup2: TRadioGroup;
RadioGroup3: TRadioGroup;
SpinEdit1: TSpinEdit;
SpinEdit2: TSpinEdit;
SpinEdit3: TSpinEdit;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure RadioButton1Change(Sender: TObject);
procedure RadioButton2Change(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
begin
close;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
ShowMessage ( 'Calcul de puissance à vélo - C. journoud avec Lazarus/Free Pascal - Août 2010' );
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
FloatSpinEdit1.value := 0.0;
FloatSpinEdit2.value := 0.0;
FloatSpinEdit3.value := 0.0;
FloatSpinEdit4.value := 0.0;
FloatSpinEdit5.value := 0.0;
FloatSpinEdit7.value := 0.0;
SpinEdit1.Value := 0;
SpinEdit2.Value := 0;
SpinEdit3.Value := 0;
Label8.caption := ' NC ';
Label9.caption := ' NC ';
Label10.caption := ' NC ';
Label11.caption := ' NC ';
Label14.caption := ' NC ';
end;
procedure TForm1.Button4Click(Sender: TObject);
var masse1, masse2, massetot, deniv : double;
var altmoy, temps, distance, pente : double;
var vitesse, coef_pente, cp1, cp2, cp3, air : double;
var densite, frot, puissance, rendement : double;
var heure, min, sec : integer;
var str_temp : string;
begin
masse1 := FloatSpinEdit1.value;
if masse1 > 90 then ShowMessage ('Attention : supprimer la bière !');
if masse1 = 0 then ShowMessage ('La masse corporelle ne peut être nulle');
masse2 := FloatSpinEdit2.Value;
if masse2 > 12 then ShowMessage ('Change ton vélo Papy !');
if masse2 = 0 then ShowMessage ('La masse du vélo ne peut être nulle');
massetot := masse1 + masse2;
distance := FloatSpinEdit5.Value;
if distance = 0 then ShowMessage ('La distance ne peut être nulle');
altmoy := FloatSpinEdit7.Value;
if altmoy = 0 then ShowMessage ('L''altitude moyenne ne peut être nulle');
if RadioButton1.Checked = True then
begin
deniv := FloatSpinEdit3.Value;
if deniv > (distance * 1000) then ShowMessage ('Le dénivelé ne doit pas être spérieur à la distance');
if deniv <> 0 then pente := deniv * 100 / (deniv / Tan(ArcSin(deniv / (distance * 1000))))
else pente := 0.0;
Str(pente:1:2, str_temp);
Label14.caption := str_temp;
FloatSpinEdit4.Value := pente;
FloatSpinEdit4.Visible := True;
end
else begin
pente := FloatSpinEdit4.Value;
deniv := Sin(ArcTan(pente / 100)) * distance * 1000;
FloatSpinEdit3.Value := deniv;
FloatSpinEdit3.Visible := True;
end;
heure := SpinEdit1.Value;
min := SpinEdit2.Value;
sec := SpinEdit3.Value;
temps := heure + min / 60 + sec / 3600;
if temps = 0 then ShowMessage ('Il faut saisir une durée')
else begin
vitesse := distance / temps;
coef_pente := pente / 100;
Str(vitesse:1:2, str_temp);
Label9.caption := str_temp;
cp1 := 9.81 * massetot * coef_pente * (vitesse / 3.6);
Str(cp1:1:2, str_temp);
Label10.caption := str_temp;
if RadioButton3.Checked = True then air := 0.35;
if RadioButton4.Checked = True then air := 0.30;
if RadioButton5.Checked = True then air := 0.22;
densite := altmoy / 8 / 100;
cp2 := (densite / 2) * air * Power((vitesse / 3.6), 3);
Str(cp2:1:2, str_temp);
Label8.caption := str_temp;
if RadioButton6.Checked = True then frot := 0.004;
if RadioButton7.Checked = True then frot := 0.006;
if RadioButton8.Checked = True then frot := 0.009;
cp3 := 9.81 * massetot * frot * vitesse / 3.6;
Str(cp3:1:2, str_temp);
Label11.caption := str_temp;
rendement := FloatSpinEdit6.Value;
if rendement = 0 then ShowMessage ('Il faut une valeur non nulle pour rendement');
puissance := (cp1 + cp2 + cp3) * 100 / rendement;
Str(puissance:1:2, str_temp);
Label14.caption := str_temp;
end
end;
procedure TForm1.RadioButton1Change(Sender: TObject);
begin
FloatSpinEdit4.Visible := False;
FloatSpinEdit3.Visible := True;
end;
procedure TForm1.RadioButton2Change(Sender: TObject);
begin
FloatSpinEdit3.Visible := False;
FloatSpinEdit4.Visible := True;
end;
initialization
{$I unit1.lrs}
end. |