unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 =
class(TForm)
Button1: TButton;
Button2: TButton;
Timer1: TTimer;
Prot: TPanel;
Pgelb: TPanel;
Pgruen: TPanel;
Edit1: TEdit;
Prot2: TPanel;
Pgelb2: TPanel;
Pgruen2: TPanel;
Label1: TLabel;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure ShowAmpel(Sender: TObject);
private
{ Private declarations }
phase, phase2 : Integer;
counter : Integer;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
counter := 0;
phase := 0;
Prot.Visible := False;
Pgelb.Visible := False;
Pgruen.Visible := False;
Prot2.Visible := False;
Pgelb2.Visible := False;
Pgruen2.Visible := False;
Edit1.Text := '
';
Timer1.Enabled := True;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Timer1.Enabled := False;
Edit1.Text := '
';
Prot.Visible := False;
Pgelb.Visible := False;
Pgruen.Visible := False;
Prot2.Visible := False;
Pgelb2.Visible := False;
Pgruen2.Visible := False;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
counter := counter + 1;
//Sekunden
case counter
of
0..5 : phase := 1;
// Rot
6..10 : phase := 2;
// Rot-Gelb
11..15 : phase := 3;
// Gruen
16..20 : phase := 4;
// Gruen
21..25 : phase := 5;
// Gelb
26..29 : phase := 6;
// Rot
30 :
begin
phase := 6;
counter := 0;
end;
end;
// end case of
if (phase + 3) > 6
then phase2 := phase -3
else phase2 := phase +3;
Edit1.Text := '
Phase : '+IntToStr(phase);
ShowAmpel(Self);
end;
procedure TForm1.ShowAmpel(Sender: TObject);
begin
case phase
of
1 :
begin Prot.Visible := True;
end;
2 :
begin Prot.Visible := True; Pgelb.Visible := True;
end;
3 :
begin Prot.Visible := False; Pgelb.Visible := False; Pgruen.Visible := True;
end;
4 :
begin Prot.Visible := False; Pgelb.Visible := False; Pgruen.Visible := True;
end;
5 :
begin Pgruen.Visible := False; Pgelb.Visible := True;
end;
6 :
begin Pgelb.Visible := False; Prot.Visible := True;
end;
end;
// end case of
case phase2
of
1 :
begin Prot2.Visible := True;
end;
2 :
begin Prot2.Visible := True; Pgelb2.Visible := True;
end;
3 :
begin Prot2.Visible := False; Pgelb2.Visible := False; Pgruen2.Visible := True;
end;
4 :
begin Prot2.Visible := False; Pgelb2.Visible := False; Pgruen2.Visible := True;
end;
5 :
begin Pgruen2.Visible := False; Pgelb2.Visible := True;
end;
6 :
begin Pgelb2.Visible := False; Prot2.Visible := True;
end;
end;
// end case of
end;
end.