summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2015-11-25 10:12:23 +0100
committerErich Eckner <git@eckner.net>2015-11-25 10:12:23 +0100
commit99d177bae2bb50c19637df212c97fc3a2c4f5f10 (patch)
treeee6214a3212b6e8a67541974273ae99015f6dd73
downloadjenah-99d177bae2bb50c19637df212c97fc3a2c4f5f10.tar.xz
Windows-Version
-rw-r--r--.gitignore8
-rw-r--r--bus_da.icobin0 -> 766 bytes
-rw-r--r--filterunit.pas218
-rw-r--r--jenah.icobin0 -> 137040 bytes
-rw-r--r--jenah.lpi97
-rw-r--r--jenah.lpr21
-rw-r--r--jenah.lps172
-rw-r--r--jenah.resbin0 -> 1700 bytes
-rw-r--r--normal.icobin0 -> 766 bytes
-rw-r--r--optionen.txt25
-rw-r--r--unbekannt.icobin0 -> 766 bytes
-rw-r--r--unit1.lfm51
-rw-r--r--unit1.pas254
13 files changed, 846 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..e4914d2
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,8 @@
+*.bak
+*.ppu
+*.o
+*.tar.gz
+*~
+jenah
+lib
+Log*
diff --git a/bus_da.ico b/bus_da.ico
new file mode 100644
index 0000000..7ca1dfa
--- /dev/null
+++ b/bus_da.ico
Binary files differ
diff --git a/filterunit.pas b/filterunit.pas
new file mode 100644
index 0000000..e030bcb
--- /dev/null
+++ b/filterunit.pas
@@ -0,0 +1,218 @@
+unit filterunit;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+ Classes, SysUtils;
+
+type
+ tAbfahrt = record
+ haltestellenId: integer;
+ Linie,Ziel,Richtung: String;
+ sAn,sAb,iAn,iAb: TDatetime;
+ end;
+ tFilterKriterium = (fkZeit,fkLinie,fkHaltestelle);
+ tBoolOperation = (boPush1,boPop1,boPush2,boPop2,
+ boNot,boAnd,boOr,
+ boSet,boPropablySet,boClr,
+ boTrust,boMistrust,
+ boDrop,boCopy);
+ tFilter = class
+ Kriterien: array of TFilterKriterium;
+ Vergleiche: array of string;
+ Verknuepfung: array of TBoolOperation;
+ function Regel_erfuellt(Abf: TAbfahrt; Genuegsamkeit: byte): boolean;
+ constructor create(var f: textfile);
+ destructor destroy;
+ end;
+
+function extract_time(source: string): tdatetime;
+function extract_advtime(source: string): tdatetime;
+function extract(verifyer,source: string): string; overload;
+function extract(verifyer,source: string; var Tag: string): string; overload;
+
+implementation
+
+uses math;
+
+function tFilter.Regel_erfuellt(abf: TAbfahrt; genuegsamkeit: Byte): boolean;
+var i: longint;
+ stack1,stack2,reg: array of byte;
+begin
+ setlength(stack1,0);
+ setlength(stack2,0);
+ setlength(reg,min(length(Kriterien),length(Vergleiche)));
+ for I:=0 to length(Reg)-1 do begin
+ case Kriterien[I] of
+ fkZeit: Reg[I]:=max(Byte(Abf.sAb - now < strtotime(Vergleiche[I])),
+ 2*Byte(Abf.iAb - now < strtotime(Vergleiche[I])));
+ fkLinie: Reg[I]:=2*Byte(strtoint(Abf.Linie) = strtoint(Vergleiche[I]));
+ fkHaltestelle: Reg[I]:=2*Byte(Abf.haltestellenId = strtoint(Vergleiche[I]));
+ end{of Case};
+ end;
+ for I:=0 to length(Verknuepfung)-1 do
+ case Verknuepfung[I] of
+ boNot: Reg[length(Reg)-1]:=2-Reg[length(Reg)-1];
+ boPush1: begin
+ setlength(Stack1,length(Stack1)+1);
+ Stack1[length(Stack1)-1]:=Reg[length(Reg)-1];
+ setlength(Reg,length(Reg)-1);
+ end;
+ boPop1: begin
+ setlength(Reg,length(Reg)+1);
+ Reg[length(Reg)-1]:=Stack1[length(Stack1)-1];
+ setlength(Stack1,length(Stack1)-1);
+ end;
+ boPush2: begin
+ setlength(Stack2,length(Stack2)+1);
+ Stack2[length(Stack2)-1]:=Reg[length(Reg)-1];
+ setlength(Reg,length(Reg)-1);
+ end;
+ boPop2: begin
+ setlength(Reg,length(Reg)+1);
+ Reg[length(Reg)-1]:=Stack1[length(Stack2)-1];
+ setlength(Stack2,length(Stack2)-1);
+ end;
+ boAnd: begin
+ Reg[length(Reg)-2]:=min(Reg[length(Reg)-1],Reg[length(Reg)-2]);
+ setlength(Reg,length(Reg)-1);
+ end;
+ boOr: begin
+ Reg[length(Reg)-2]:=max(Reg[length(Reg)-1],Reg[length(Reg)-2]);
+ setlength(Reg,length(Reg)-1);
+ end;
+ boSet: Reg[length(Reg)-1]:=2;
+ boPropablySet: Reg[length(Reg)-1]:=1;
+ boClr: Reg[length(Reg)-1]:=0;
+ boDrop: setlength(Reg,length(Reg)-1);
+ boTrust: Reg[length(Reg)-1]:=2*Byte(Reg[length(Reg)-1]<>0);
+ boMistrust: Reg[length(Reg)-1]:=2*Byte(Reg[length(Reg)-1]=2);
+ boCopy: begin
+ setlength(Reg,length(Reg)+1);
+ Reg[length(Reg)-1]:=Reg[length(Reg)-2];
+ end;
+ end{of case};
+ Result:=Reg[0]>=Genuegsamkeit;
+ setlength(Reg,0);
+ setlength(Stack1,0);
+ setlength(Stack2,0);
+end;
+
+constructor TFilter.create(var f: textfile);
+var s: string;
+ i: byte;
+begin
+ inherited create;
+ setlength(Kriterien,0);
+ setlength(Vergleiche,0);
+ setlength(Verknuepfung,0);
+ i:=0;
+
+ while not eof(f) do begin
+ readln(f,s);
+ if s=':filter' then exit;
+ if (length(s)=0) or (s[1]='#') then continue;
+ if s=':filter:' then begin
+ if i<>0 then
+ raise Exception.create('Ich habe zu häufig '':filter:''!');
+ inc(i);
+ continue;
+ end;
+ case i of
+ 0: begin
+ setlength(Kriterien,length(Kriterien)+1);
+ case s[1] of
+ 't': Kriterien[length(Kriterien)-1]:=fkZeit;
+ 'l': Kriterien[length(Kriterien)-1]:=fkLinie;
+ 'h': Kriterien[length(Kriterien)-1]:=fkHaltestelle;
+ else raise Exception.create('Ich kenne Kriterium '''+s[1]+''' nicht!');
+ end{of Case};
+ delete(s,1,1);
+ setlength(Vergleiche,length(Vergleiche)+1);
+ Vergleiche[length(Vergleiche)-1]:=s;
+ end;
+ 1: begin
+ setlength(Verknuepfung,length(Verknuepfung)+1);
+ case s[1] of
+ '-': Verknuepfung[length(Verknuepfung)-1]:=boNot;
+ '&': Verknuepfung[length(Verknuepfung)-1]:=boAnd;
+ '|': Verknuepfung[length(Verknuepfung)-1]:=boOr;
+ '0': Verknuepfung[length(Verknuepfung)-1]:=boClr;
+ '1': Verknuepfung[length(Verknuepfung)-1]:=boPropablySet;
+ '2': Verknuepfung[length(Verknuepfung)-1]:=boSet;
+ 'v': Verknuepfung[length(Verknuepfung)-1]:=boPush1;
+ '^': Verknuepfung[length(Verknuepfung)-1]:=boPop1;
+ '<': Verknuepfung[length(Verknuepfung)-1]:=boPush2;
+ '>': Verknuepfung[length(Verknuepfung)-1]:=boPop2;
+ '*': Verknuepfung[length(Verknuepfung)-1]:=boDrop;
+ '~': Verknuepfung[length(Verknuepfung)-1]:=boCopy;
+ 'T': Verknuepfung[length(Verknuepfung)-1]:=boTrust;
+ 'M': Verknuepfung[length(Verknuepfung)-1]:=boMistrust;
+ else raise Exception.create('Ich kenne Verknüpfung '''+s[1]+''' nicht!');
+ end{of Case};
+ end;
+ end{of Case};
+ end;
+ raise Exception.create('Unerwartetes Dateiende!');
+end;
+
+destructor TFilter.destroy;
+var i: longint;
+begin
+ for i:=0 to length(Vergleiche)-1 do
+ Vergleiche[i]:='';
+ setlength(Kriterien,0);
+ setlength(Vergleiche,0);
+ setlength(Verknuepfung,0);
+ inherited destroy;
+end;
+
+function extract_time(source: string): tdatetime;
+var s: string;
+begin
+ s:=copy(source,1,pos('-',source)-1);
+ delete(source,1,pos('-',source));
+ s:=copy(source,1,pos('-',source)-1)+'.'+s;
+ delete(source,1,pos('-',source));
+ s:=copy(source,1,pos('T',source)-1)+'.'+s;
+ delete(source,1,pos('T',source));
+ s:=s+' '+source;
+ result:=strtodatetime(s);
+end;
+
+function extract_advtime(source: string): tdatetime;
+begin
+ delete(source,1,pos('"',source));
+ source:=copy(source,1,pos('"',source)-1);
+ result:=extract_time(source);
+end;
+
+function extract(verifyer,source: string): string; overload;
+begin
+ result:='';
+ if (pos('<'+verifyer+'>',source)>0) or
+ (pos('<'+verifyer+' ',source)>0) then
+ begin
+ delete(source,1,pos('<'+verifyer,source)+length('<'+verifyer)-1);
+ delete(source,1,pos('>',source));
+ result:=copy(source,1,pos('</'+verifyer+'>',source)-1);
+ end;
+end;
+
+function extract(verifyer,source: string; var Tag: string): string; overload;
+begin
+ result:='';
+ if (pos('<'+verifyer+'>',source)>0) or
+ (pos('<'+verifyer+' ',source)>0) then
+ begin
+ delete(source,1,pos('<'+verifyer,source)+length('<'+verifyer)-1);
+ Tag:=copy(source,2,pos('>',source)-2);
+ delete(source,1,pos('>',source));
+ result:=copy(source,1,pos('</'+verifyer+'>',source)-1);
+ end;
+end;
+
+end.
+
diff --git a/jenah.ico b/jenah.ico
new file mode 100644
index 0000000..14c2183
--- /dev/null
+++ b/jenah.ico
Binary files differ
diff --git a/jenah.lpi b/jenah.lpi
new file mode 100644
index 0000000..4c0f222
--- /dev/null
+++ b/jenah.lpi
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<CONFIG>
+ <ProjectOptions>
+ <Version Value="9"/>
+ <PathDelim Value="\"/>
+ <General>
+ <SessionStorage Value="InProjectDir"/>
+ <MainUnit Value="0"/>
+ <Title Value="jenah"/>
+ <ResourceType Value="res"/>
+ <UseXPManifest Value="True"/>
+ <Icon Value="0"/>
+ </General>
+ <i18n>
+ <EnableI18N LFM="False"/>
+ </i18n>
+ <VersionInfo>
+ <StringTable ProductVersion=""/>
+ </VersionInfo>
+ <BuildModes Count="1">
+ <Item1 Name="Default" Default="True"/>
+ </BuildModes>
+ <PublishOptions>
+ <Version Value="2"/>
+ </PublishOptions>
+ <RunParams>
+ <local>
+ <FormatVersion Value="1"/>
+ </local>
+ </RunParams>
+ <RequiredPackages Count="2">
+ <Item1>
+ <PackageName Value="lnetvisual"/>
+ </Item1>
+ <Item2>
+ <PackageName Value="LCL"/>
+ </Item2>
+ </RequiredPackages>
+ <Units Count="3">
+ <Unit0>
+ <Filename Value="jenah.lpr"/>
+ <IsPartOfProject Value="True"/>
+ <UnitName Value="jenah"/>
+ </Unit0>
+ <Unit1>
+ <Filename Value="unit1.pas"/>
+ <IsPartOfProject Value="True"/>
+ <ComponentName Value="Form1"/>
+ <HasResources Value="True"/>
+ <ResourceBaseClass Value="Form"/>
+ <UnitName Value="Unit1"/>
+ </Unit1>
+ <Unit2>
+ <Filename Value="filterunit.pas"/>
+ <IsPartOfProject Value="True"/>
+ <UnitName Value="filterunit"/>
+ </Unit2>
+ </Units>
+ </ProjectOptions>
+ <CompilerOptions>
+ <Version Value="11"/>
+ <PathDelim Value="\"/>
+ <Target>
+ <Filename Value="jenah"/>
+ </Target>
+ <SearchPaths>
+ <IncludeFiles Value="$(ProjOutDir)"/>
+ <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
+ </SearchPaths>
+ <Linking>
+ <Options>
+ <Win32>
+ <GraphicApplication Value="True"/>
+ </Win32>
+ </Options>
+ </Linking>
+ <Other>
+ <CompilerMessages>
+ <MsgFileName Value=""/>
+ </CompilerMessages>
+ <CompilerPath Value="$(CompPath)"/>
+ </Other>
+ </CompilerOptions>
+ <Debugging>
+ <Exceptions Count="3">
+ <Item1>
+ <Name Value="EAbort"/>
+ </Item1>
+ <Item2>
+ <Name Value="ECodetoolError"/>
+ </Item2>
+ <Item3>
+ <Name Value="EFOpenError"/>
+ </Item3>
+ </Exceptions>
+ </Debugging>
+</CONFIG>
diff --git a/jenah.lpr b/jenah.lpr
new file mode 100644
index 0000000..c078881
--- /dev/null
+++ b/jenah.lpr
@@ -0,0 +1,21 @@
+program jenah;
+
+{$mode objfpc}{$H+}
+
+uses
+ {$IFDEF UNIX}{$IFDEF UseCThreads}
+ cthreads,
+ {$ENDIF}{$ENDIF}
+ Interfaces, // this includes the LCL widgetset
+ Forms, Unit1, lnetvisual, filterunit
+ { you can add units after this };
+
+{$R *.res}
+
+begin
+ RequireDerivedFormResource := True;
+ Application.Initialize;
+ Application.CreateForm(TForm1, Form1);
+ Application.Run;
+end.
+
diff --git a/jenah.lps b/jenah.lps
new file mode 100644
index 0000000..b7e8de6
--- /dev/null
+++ b/jenah.lps
@@ -0,0 +1,172 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<CONFIG>
+ <ProjectSession>
+ <PathDelim Value="\"/>
+ <Version Value="9"/>
+ <BuildModes Active="Default"/>
+ <Units Count="3">
+ <Unit0>
+ <Filename Value="jenah.lpr"/>
+ <IsPartOfProject Value="True"/>
+ <UnitName Value="jenah"/>
+ <WindowIndex Value="0"/>
+ <TopLine Value="1"/>
+ <CursorPos X="1" Y="1"/>
+ <UsageCount Value="23"/>
+ </Unit0>
+ <Unit1>
+ <Filename Value="unit1.pas"/>
+ <IsPartOfProject Value="True"/>
+ <ComponentName Value="Form1"/>
+ <HasResources Value="True"/>
+ <ResourceBaseClass Value="Form"/>
+ <UnitName Value="Unit1"/>
+ <EditorIndex Value="0"/>
+ <WindowIndex Value="0"/>
+ <TopLine Value="85"/>
+ <CursorPos X="22" Y="103"/>
+ <UsageCount Value="23"/>
+ <Loaded Value="True"/>
+ <LoadedDesigner Value="True"/>
+ </Unit1>
+ <Unit2>
+ <Filename Value="filterunit.pas"/>
+ <IsPartOfProject Value="True"/>
+ <UnitName Value="filterunit"/>
+ <IsVisibleTab Value="True"/>
+ <EditorIndex Value="1"/>
+ <WindowIndex Value="0"/>
+ <TopLine Value="107"/>
+ <CursorPos X="39" Y="123"/>
+ <UsageCount Value="23"/>
+ <Loaded Value="True"/>
+ </Unit2>
+ </Units>
+ <General>
+ <ActiveWindowIndexAtStart Value="0"/>
+ </General>
+ <JumpHistory Count="30" HistoryIndex="29">
+ <Position1>
+ <Filename Value="unit1.pas"/>
+ <Caret Line="68" Column="122" TopLine="43"/>
+ </Position1>
+ <Position2>
+ <Filename Value="unit1.pas"/>
+ <Caret Line="154" Column="19" TopLine="129"/>
+ </Position2>
+ <Position3>
+ <Filename Value="unit1.pas"/>
+ <Caret Line="156" Column="18" TopLine="131"/>
+ </Position3>
+ <Position4>
+ <Filename Value="unit1.pas"/>
+ <Caret Line="159" Column="19" TopLine="134"/>
+ </Position4>
+ <Position5>
+ <Filename Value="unit1.pas"/>
+ <Caret Line="163" Column="19" TopLine="138"/>
+ </Position5>
+ <Position6>
+ <Filename Value="unit1.pas"/>
+ <Caret Line="164" Column="19" TopLine="139"/>
+ </Position6>
+ <Position7>
+ <Filename Value="unit1.pas"/>
+ <Caret Line="168" Column="19" TopLine="143"/>
+ </Position7>
+ <Position8>
+ <Filename Value="unit1.pas"/>
+ <Caret Line="170" Column="57" TopLine="145"/>
+ </Position8>
+ <Position9>
+ <Filename Value="unit1.pas"/>
+ <Caret Line="171" Column="75" TopLine="146"/>
+ </Position9>
+ <Position10>
+ <Filename Value="unit1.pas"/>
+ <Caret Line="174" Column="19" TopLine="149"/>
+ </Position10>
+ <Position11>
+ <Filename Value="unit1.pas"/>
+ <Caret Line="69" Column="27" TopLine="54"/>
+ </Position11>
+ <Position12>
+ <Filename Value="unit1.pas"/>
+ <Caret Line="138" Column="1" TopLine="129"/>
+ </Position12>
+ <Position13>
+ <Filename Value="unit1.pas"/>
+ <Caret Line="29" Column="1" TopLine="14"/>
+ </Position13>
+ <Position14>
+ <Filename Value="unit1.pas"/>
+ <Caret Line="181" Column="1" TopLine="152"/>
+ </Position14>
+ <Position15>
+ <Filename Value="unit1.pas"/>
+ <Caret Line="140" Column="5" TopLine="125"/>
+ </Position15>
+ <Position16>
+ <Filename Value="unit1.pas"/>
+ <Caret Line="47" Column="21" TopLine="31"/>
+ </Position16>
+ <Position17>
+ <Filename Value="unit1.pas"/>
+ <Caret Line="117" Column="7" TopLine="102"/>
+ </Position17>
+ <Position18>
+ <Filename Value="unit1.pas"/>
+ <Caret Line="186" Column="13" TopLine="171"/>
+ </Position18>
+ <Position19>
+ <Filename Value="unit1.pas"/>
+ <Caret Line="188" Column="13" TopLine="173"/>
+ </Position19>
+ <Position20>
+ <Filename Value="unit1.pas"/>
+ <Caret Line="251" Column="35" TopLine="239"/>
+ </Position20>
+ <Position21>
+ <Filename Value="unit1.pas"/>
+ <Caret Line="102" Column="24" TopLine="87"/>
+ </Position21>
+ <Position22>
+ <Filename Value="unit1.pas"/>
+ <Caret Line="1" Column="1" TopLine="1"/>
+ </Position22>
+ <Position23>
+ <Filename Value="unit1.pas"/>
+ <Caret Line="45" Column="17" TopLine="22"/>
+ </Position23>
+ <Position24>
+ <Filename Value="unit1.pas"/>
+ <Caret Line="63" Column="113" TopLine="48"/>
+ </Position24>
+ <Position25>
+ <Filename Value="unit1.pas"/>
+ <Caret Line="107" Column="54" TopLine="90"/>
+ </Position25>
+ <Position26>
+ <Filename Value="unit1.pas"/>
+ <Caret Line="105" Column="39" TopLine="90"/>
+ </Position26>
+ <Position27>
+ <Filename Value="unit1.pas"/>
+ <Caret Line="104" Column="39" TopLine="89"/>
+ </Position27>
+ <Position28>
+ <Filename Value="unit1.pas"/>
+ <Caret Line="103" Column="39" TopLine="88"/>
+ </Position28>
+ <Position29>
+ <Filename Value="unit1.pas"/>
+ <Caret Line="102" Column="39" TopLine="87"/>
+ </Position29>
+ <Position30>
+ <Filename Value="unit1.pas"/>
+ <Caret Line="101" Column="39" TopLine="86"/>
+ </Position30>
+ </JumpHistory>
+ </ProjectSession>
+ <EditorMacros Count="0"/>
+</CONFIG>
diff --git a/jenah.res b/jenah.res
new file mode 100644
index 0000000..3bfffa0
--- /dev/null
+++ b/jenah.res
Binary files differ
diff --git a/normal.ico b/normal.ico
new file mode 100644
index 0000000..cb6b9a3
--- /dev/null
+++ b/normal.ico
Binary files differ
diff --git a/optionen.txt b/optionen.txt
new file mode 100644
index 0000000..7ed028a
--- /dev/null
+++ b/optionen.txt
@@ -0,0 +1,25 @@
+haltestelle:universitätsklinikum
+
+filter:
+h3117
+h3517
+t00:25:50
+t00:02:30
+:filter:
+-
+&
+&
+|
+T
+:filter
+
+filter:
+h3117
+h3118
+h3517
+h3518
+:filter:
+|
+|
+|
+:filter
diff --git a/unbekannt.ico b/unbekannt.ico
new file mode 100644
index 0000000..c92ec9e
--- /dev/null
+++ b/unbekannt.ico
Binary files differ
diff --git a/unit1.lfm b/unit1.lfm
new file mode 100644
index 0000000..d7926f7
--- /dev/null
+++ b/unit1.lfm
@@ -0,0 +1,51 @@
+object Form1: TForm1
+ Left = 362
+ Height = 576
+ Top = 176
+ Width = 779
+ Caption = 'Form1'
+ ClientHeight = 576
+ ClientWidth = 779
+ OnCreate = FormCreate
+ OnDestroy = FormDestroy
+ OnResize = FormResize
+ LCLVersion = '1.2.2.0'
+ object Memo1: TMemo
+ Left = 0
+ Height = 490
+ Top = 0
+ Width = 704
+ Lines.Strings = (
+ 'Memo1'
+ )
+ TabOrder = 0
+ end
+ object TrayIcon1: TTrayIcon
+ OnDblClick = TrayIcon1DblClick
+ OnMouseDown = TrayIcon1MouseDown
+ left = 8
+ top = 8
+ end
+ object LHTTPClientComponent1: TLHTTPClientComponent
+ Tag = -1
+ Host = 'fpl.jenah.de'
+ OnDoneInput = LHTTPClientComponent1DoneInput
+ OnInput = LHTTPClientComponent1Input
+ Timeout = 0
+ left = 120
+ top = 8
+ end
+ object Starttimer: TTimer
+ Tag = -3
+ Interval = 50
+ OnTimer = StarttimerTimer
+ left = 48
+ top = 8
+ end
+ object Timer1: TTimer
+ Interval = 30000
+ OnTimer = Timer1Timer
+ left = 83
+ top = 8
+ end
+end
diff --git a/unit1.pas b/unit1.pas
new file mode 100644
index 0000000..50e6baa
--- /dev/null
+++ b/unit1.pas
@@ -0,0 +1,254 @@
+unit Unit1;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+ Classes, SysUtils, FileUtil, lNetComponents, Forms, Controls, Graphics,
+ Dialogs, ExtCtrls, StdCtrls, lhttp, filterunit, math;
+
+type
+
+ { TForm1 }
+
+ TForm1 = class(TForm)
+ LHTTPClientComponent1: TLHTTPClientComponent;
+ Memo1: TMemo;
+ Starttimer: TTimer;
+ Timer1: TTimer;
+ TrayIcon1: TTrayIcon;
+ procedure FormCreate(Sender: TObject);
+ procedure FormDestroy(Sender: TObject);
+ procedure FormResize(Sender: TObject);
+ procedure LHTTPClientComponent1DoneInput(ASocket: TLHTTPClientSocket);
+ function LHTTPClientComponent1Input(ASocket: TLHTTPClientSocket;
+ ABuffer: pchar; ASize: integer): integer;
+ procedure StarttimerTimer(Sender: TObject);
+ procedure Timer1Timer(Sender: TObject);
+ procedure TrayIcon1DblClick(Sender: TObject);
+ procedure TrayIcon1MouseDown(Sender: TObject; Button: TMouseButton;
+ Shift: TShiftState; X, Y: Integer);
+ private
+ { private declarations }
+ procedure parseOptionFile;
+ procedure Station_waehlen;
+ procedure Zeiten_holen;
+ public
+ { public declarations }
+ mastnr: array of longint;
+ Stat,buff: string;
+ Anzeige: array of tAbfahrt;
+ Filter_s: array of tFilter;
+ lastButton: tMouseButton;
+ end;
+
+var
+ Form1: TForm1;
+
+implementation
+
+{$R *.lfm}
+
+{ TForm1 }
+
+procedure TForm1.Station_waehlen;
+begin
+ LHTTPClientComponent1.URI:='http://fpl.jenah.de/bontip-ifgi/php/getStation.php?action=getMastNo&q='+stat+'&q2=';
+ LHTTPClientComponent1.SendRequest;
+end;
+
+procedure TForm1.Zeiten_holen;
+begin
+ LHTTPClientComponent1.Tag:=0;
+ LHTTPClientComponent1.URI:='http://fpl.jenah.de/bontip-ifgi/php/proxy.php?vsz=120&azbid='+inttostr(mastnr[Starttimer.tag-1]);
+ LHTTPClientComponent1.SendRequest;
+end;
+
+procedure TForm1.TrayIcon1DblClick(Sender: TObject);
+begin
+ case lastButton of
+ mbLeft: begin
+ if form1.visible then Form1.Hide
+ else Form1.Show;
+ end;
+ mbRight: Application.Terminate;
+ end{of case};
+end;
+
+procedure TForm1.TrayIcon1MouseDown(Sender: TObject; Button: TMouseButton;
+ Shift: TShiftState; X, Y: Integer);
+begin
+ lastButton:=Button;
+end;
+
+procedure TForm1.parseOptionFile;
+var f: textfile;
+ s: string;
+begin
+ assignfile(f,extractfilepath(application.exename)+'optionen.txt');
+ reset(f);
+ while not eof(f) do begin
+ readln(f,s);
+ if (length(s)=0) or (s[1]='#') then continue;
+ if pos('haltestelle:',s)=1 then begin
+ delete(s,1,length('haltestelle:'));
+ stat:=s;
+ continue;
+ end;
+ if pos('filter:',s)=1 then begin
+ setlength(Filter_s,length(Filter_s)+1);
+ Filter_s[length(Filter_s)-1]:=TFilter.create(f);
+ continue;
+ end;
+ raise Exception.create('Verstehe '''+s+''' nicht!');
+ end;
+ closefile(f);
+end;
+
+procedure TForm1.FormCreate(Sender: TObject);
+begin
+ buff:='';
+ setlength(Filter_s,0);
+ setlength(mastnr,0);
+ lastButton:=mbLeft;
+ TrayIcon1.Icon.LoadFromFile(extractfilepath(application.exename)+'unbekannt.ico');
+ TrayIcon1.Show;
+ Application.ProcessMessages;
+ parseOptionFile;
+end;
+
+procedure TForm1.FormDestroy(Sender: TObject);
+var i: longint;
+begin
+ for i:=0 to length(Filter_s)-1 do
+ Filter_s[i].destroy;
+ setlength(Filter_s,0);
+ setlength(mastnr,0);
+end;
+
+procedure TForm1.FormResize(Sender: TObject);
+begin
+ memo1.width:=form1.clientwidth-memo1.left;
+ memo1.height:=form1.clientheight-memo1.top;
+end;
+
+procedure TForm1.LHTTPClientComponent1DoneInput(ASocket: TLHTTPClientSocket);
+var s,t,meth,zeit: string;
+ i: integer;
+begin
+ s:=buff;
+ buff:='';
+ meth:=extract('method',S);
+ if meth = 'getMastNo' then
+ begin
+ setlength(Anzeige,0);
+ s:=extract('result',s);
+ setlength(mastnr,strtoint(extract('stopcount',s)));
+ for i:=0 to length(mastnr)-1 do
+ begin
+ mastnr[i]:=strtoint(extract('stopno',extract('stop',s)));
+ delete(s,1,pos('</stop>',s));
+ end;
+ Starttimer.Tag:=1;
+ Starttimer.enabled:=true;
+ exit;
+ end;
+ if meth='' then
+ begin
+ s:=extract('AZBNachricht',s);
+ while pos('<AZBFahrplanlage',s)>0 do
+ begin
+ t:=extract('AZBFahrplanlage',s,zeit);
+ delete(s,1,pos('</AZBFahrplanlage>',s)+length('</AZBFahrplanlage>')-1);
+ setlength(Anzeige,length(Anzeige)+1);
+ meth:=extract('AZBID',t);
+ delete(meth,1,length(meth)-4);
+ Anzeige[length(Anzeige)-1].HaltestellenId:=strtoint(meth);
+ Anzeige[length(Anzeige)-1].Linie:=extract('LinienText',t);
+ Anzeige[length(Anzeige)-1].Ziel:=extract('ZielHst',t);
+ Anzeige[length(Anzeige)-1].Richtung:=extract('RichtungsText',t);
+ Anzeige[length(Anzeige)-1].sAn:=extract_time(extract('AnkunftszeitAZBPlan',t));
+ Anzeige[length(Anzeige)-1].iAn:=extract_time(extract('AnkunftszeitAZBPrognose',t));
+ Anzeige[length(Anzeige)-1].sAb:=extract_time(extract('AbfahrtszeitAZBPlan',t));
+ Anzeige[length(Anzeige)-1].iAb:=extract_time(extract('AbfahrtszeitAZBPrognose',t));
+ end;
+ Starttimer.Enabled:=true;
+ exit;
+ end;
+ Memo1.lines.add(meth);
+ Memo1.lines.add(S);
+end;
+
+function TForm1.LHTTPClientComponent1Input(ASocket: TLHTTPClientSocket;
+ ABuffer: pchar; ASize: integer): integer;
+begin
+ buff:=buff+copy(ABuffer,1,ASize);
+ result:=ASize;
+end;
+
+procedure TForm1.StarttimerTimer(Sender: TObject);
+var I: Integer;
+ Hinweis: string;
+begin
+ Starttimer.enabled:=false;
+ if Starttimer.tag = -3 then begin
+ Form1.visible:=false;
+ Starttimer.tag:=-1;
+ parseOptionFile;
+ end;
+ if Starttimer.tag = -1 then begin
+ Station_waehlen;
+ exit
+ end;
+ if Starttimer.Tag = 0 then begin
+ Starttimer.Tag := -1;
+ Form1.Visible:=false;
+ exit;
+ end;
+ if Starttimer.Tag >= 1 then begin
+ Zeiten_holen;
+ if Starttimer.Tag>=length(mastnr) then Starttimer.Tag := -2
+ else Starttimer.Tag := Starttimer.Tag + 1;
+ exit;
+ end;
+ if Starttimer.Tag = -2 then begin
+ Memo1.lines.clear;
+ Hinweis:='';
+ for I:=0 to length(Anzeige)-1 do begin
+ if (length(Filter_s)<=0) or
+ (Filter_s[0].regel_erfuellt(Anzeige[I],2)) then
+ Hinweis:=Hinweis+#$0D#$0A+Anzeige[I].Linie+'('+inttostr(Anzeige[I].HaltestellenID)+'): '+timetostr(Anzeige[I].iAb);
+ if (length(Filter_s)<=0) or
+ (Filter_s[min(1,length(Filter_s)-1)].regel_erfuellt(Anzeige[I],1)) then begin
+ Memo1.lines.add(inttostr(Anzeige[I].HaltestellenId)+': <'+
+ Anzeige[I].Linie+'> '''+
+ Anzeige[I].Richtung+''' nach '''+
+ Anzeige[I].Ziel+''': '+
+ timetostr(Anzeige[I].iAn)+' ('+
+ timetostr(Anzeige[I].sAn)+') -> '+
+ timetostr(Anzeige[I].iAb)+' ('+
+ timetostr(Anzeige[I].sAb)+')');
+ end;
+ end;
+ if length(Hinweis)>0 then begin
+ delete(Hinweis,1,2);
+ TrayIcon1.Hint:=Hinweis;
+ TrayIcon1.Icon.LoadFromFile(extractfilepath(application.exename)+'bus_da.ico');
+ end
+ else begin
+ TrayIcon1.Hint:='Busauskunft - kein Bus in Sicht!'#0;
+ TrayIcon1.Icon.LoadFromFile(extractfilepath(application.exename)+'normal.ico');
+ end;
+ exit;
+ end;
+end;
+
+procedure TForm1.Timer1Timer(Sender: TObject);
+begin
+ starttimer.Tag:=-1;
+ starttimer.enabled:=true;
+end;
+
+end.
+