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
| unit Unit3;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls,
VCLTee.TeEngine, VCLTee.TeeProcs, VCLTee.Chart, VCLTee.TeeSpline, VCLTee.TeeEdiGene,
VCLTee.Series, Vcl.ComCtrls, Inifiles, Printers, VCLTee.TeeFunci;
type
TForm3 = class(TForm)
Panel1: TPanel;
CbxWaypoints: TComboBox;
LblWaypoints: TLabel;
LblFuelOnBoard: TLabel;
EdFOB: TEdit;
btnOK: TButton;
btnPrint: TButton;
LblRoute: TLabel;
REdLog: TRichEdit;
Chart1: TChart;
Series2: TFastLineSeries;
procedure FormActivate(Sender: TObject);
procedure RichEdit_MoveTo(RichEdit: TRichEdit; LineNumber, CharNumber: Word);
procedure btnPrintClick(Sender: TObject);
procedure btnOKClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Form3: TForm3;
lstWPT : TStringList;
implementation
{$R *.dfm}
procedure TForm3.btnOKClick(Sender: TObject);
var WP: Integer;
Qty : Double;
begin
if edFOB.Text<> '' then
begin
Qty:= StrToFloat(EdFOB.Text);
WP:= cbxWaypoints.ItemIndex;
Series2.AddXY(StrToFloat(lstWPT[WP]),QTY,'',clRed);
end;
end;
procedure TForm3.btnPrintClick(Sender: TObject);
begin
ChartPreview(Self,Chart1);
end;
procedure TForm3.FormActivate(Sender: TObject);
var Ini : TInifile;
CheminFs, stGd, Ligne : String;
SearchResult : TSearchRec;
i, LoDistGrd, GloDistGrd, Value : Integer;
Ratio, rayon : Extended;
begin
LstWPT:= TStringList.Create;
LstWPT.StrictDelimiter:= True;
lstWPT.Delimiter:= ',';
CbxWaypoints.Clear;
Ini := TiniFile.Create(extractFilePath
(application.exename)+'CPS.cfg');
CheminFs := Ini.ReadString('PATHS','FSX','');
if FindFirst(CheminFS + '\Civa\ADEU\' + '*.txt' , faAnyFile , searchResult)= 0 then
begin
REdLog.Lines.LoadFromFile(ExtractFilePath(CheminFS + '\Civa\ADEU\') + searchResult.Name);
LblRoute.Caption:= Copy(searchResult.Name, 1, 12);
Chart1.Axes.Bottom.Minimum := 0;
Chart1.Series[0].AddXY(LoDistGrd,0,copy(SearchResult.Name,1,4));
//--------------------------Calcul de la distance et des cumuls----------------
i:= 0;
While i < REdLog.Lines.Count+1 do
Begin
if TryStrToInt(Copy(REdLog.lines.Strings[i],44,4),Value) then
begin
LoDistGrd := LoDistGrd + Value;
stGd := IntToStr(LoDistGrd);
RichEdit_MoveTo(REdLog,i+1,(47 - Length(stGd)));
Application.ProcessMessages;
REdLog.SelLength:= 0;
REdLog.SelText:= IntToStr(LoDistGrd)+ ' ' + #124;
Chart1.Series[0].AddXY(LoDistGrd,0,Copy(REdLog.lines.Strings[i],17,6));
LstWPT.Add(StGd);
CbxWaypoints.Items.Add(Copy(REdLog.lines.Strings[i],17,6));
Value:= 0;
Inc(i);
end;
Inc(i);
End;
GloDistGrd:= LoDistGrd;
//Ratio := 181.5/274; //Dimensions Air France (90 t. x 3200nm) Rayon = 1837.3 mm
Ratio:= LoDistGrd / 3200;
Chart1.Axes.Bottom.Maximum := LoDistGrd;
Chart1.Axes.Left.Maximum := 90 * Ratio;
Rayon := Rayon * Ratio;
i:= 0;
while i <= REdLog.Lines.Count+1 do
Begin
if TryStrToInt(Copy(REdLog.lines.Strings[i],44,4),Value) then
begin
LoDistGrd := LoDistGrd
- Value;
stGd := IntToStr(LoDistGrd);
RichEdit_MoveTo(REdLog,i+1,(54 - Length(stGd)));
Application.ProcessMessages;
REdLog.SelLength:= 0;
REdLog.SelText:= IntToStr(LoDistGrd) + ' ';
Ligne:= REdLog.Lines[i+1];
Ligne:= Copy(Ligne,1, Length(Ligne)-2);
REdLog.Lines[i+1]:= Ligne;
Inc(i,3)
end
else
Inc(i);
End;
end;
FindClose(SearchResult);
cbxWaypoints.ItemIndex:= 0;
end;
procedure TForm3.FormClose(Sender: TObject; var Action: TCloseAction);
begin
LstWPT.Free;
end;
procedure TForm3.RichEdit_MoveTo(RichEdit: TRichEdit; LineNumber, CharNumber: Word);
begin
RichEdit.SelStart := RichEdit.Perform(EM_LINEINDEX, LineNumber, 0) + CharNumber;
end;
end. |
Partager