www.pudn.com > Elevator.rar > MAIN.PAS, change:2001-07-12,size:20881b


unit main; 
 
interface 
 
uses 
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 
  Dialogs, Buttons, StdCtrls, ExtCtrls, Menus,MMsystem; 
 
const OPENING=1;        //表示电梯处于正在打开状态 
const OPENED=2;         //表示电梯处于已经打开状态 
const CLOSEING=3;       //表示电梯处于正在关闭状态 
const CLOSEED=4;         //表示电梯处于已经关闭状态 
 
const NEEDUP=1;         //用户想上楼 
const NEEDDOWN=-1;       //用户想下楼 
const NONEED=0;          //无请求 
 
type 
  TForm1 = class(TForm) 
    Panel_dl: TPanel; 
    Panel_glzx: TPanel; 
    Panel_dt: TPanel; 
    Shape1: TShape; 
    Label1: TLabel; 
    Panel_dtnb: TPanel; 
    Panel1: TPanel; 
    Panel2: TPanel; 
    Panel3: TPanel; 
    Panel4: TPanel; 
    Panel5: TPanel; 
    Panel6: TPanel; 
    Panel7: TPanel; 
    Panel8: TPanel; 
    Panel9: TPanel; 
    BitBtn1: TBitBtn; 
    BitBtn2: TBitBtn; 
    Shape2: TShape; 
    BitBtn3: TBitBtn; 
    BitBtn4: TBitBtn; 
    Panel10: TPanel; 
    Panel17: TPanel; 
    SpeedButton12: TSpeedButton; 
    Label8: TLabel; 
    Shape_door: TShape; 
    Timer_door: TTimer; 
    Timer_move: TTimer; 
    Image_Up2: TImage; 
    Image_Up1: TImage; 
    Image_Down1: TImage; 
    Image_Down2: TImage; 
    Label12: TLabel; 
    Label13: TLabel; 
    Label14: TLabel; 
    Label15: TLabel; 
    Label16: TLabel; 
    Label25: TLabel; 
    Timer1: TTimer; 
    Button1: TButton; 
    Panel18: TPanel; 
    SpeedButton22: TSpeedButton; 
    Label10: TLabel; 
    SpeedButton21: TSpeedButton; 
    Label24: TLabel; 
    Panel16: TPanel; 
    SpeedButton32: TSpeedButton; 
    Label7: TLabel; 
    SpeedButton31: TSpeedButton; 
    Label23: TLabel; 
    Panel15: TPanel; 
    SpeedButton42: TSpeedButton; 
    Label6: TLabel; 
    SpeedButton41: TSpeedButton; 
    Label22: TLabel; 
    Panel20: TPanel; 
    SpeedButton52: TSpeedButton; 
    Label11: TLabel; 
    SpeedButton51: TSpeedButton; 
    Label21: TLabel; 
    Panel11: TPanel; 
    SpeedButton62: TSpeedButton; 
    Label2: TLabel; 
    SpeedButton61: TSpeedButton; 
    Label20: TLabel; 
    Panel12: TPanel; 
    SpeedButton72: TSpeedButton; 
    Label3: TLabel; 
    SpeedButton71: TSpeedButton; 
    Label19: TLabel; 
    Panel13: TPanel; 
    SpeedButton82: TSpeedButton; 
    Label4: TLabel; 
    SpeedButton81: TSpeedButton; 
    Label18: TLabel; 
    Panel14: TPanel; 
    SpeedButton91: TSpeedButton; 
    Label5: TLabel; 
    Label17: TLabel; 
    Shape3: TShape; 
    Label26: TLabel; 
    Label27: TLabel; 
    Label28: TLabel; 
    Label29: TLabel; 
    Label30: TLabel; 
    Label31: TLabel; 
    Label32: TLabel; 
    Label33: TLabel; 
    Label34: TLabel; 
    Label35: TLabel; 
    Label36: TLabel; 
    Label37: TLabel; 
    Label38: TLabel; 
    Label39: TLabel; 
    Label40: TLabel; 
    Label41: TLabel; 
    Label42: TLabel; 
    Label43: TLabel; 
    Label44: TLabel; 
    Timer2: TTimer; 
    Image1: TImage; 
    procedure Timer_doorTimer(Sender: TObject); 
    procedure FormCreate(Sender: TObject); 
    procedure BitBtn2Click(Sender: TObject); 
    procedure Timer_moveTimer(Sender: TObject); 
    procedure SpeedButton12Click(Sender: TObject); 
    procedure SpeedButton22Click(Sender: TObject); 
    procedure SpeedButton32Click(Sender: TObject); 
    procedure SpeedButton42Click(Sender: TObject); 
    procedure SpeedButton52Click(Sender: TObject); 
    procedure SpeedButton62Click(Sender: TObject); 
    procedure SpeedButton72Click(Sender: TObject); 
    procedure SpeedButton82Click(Sender: TObject); 
    procedure SpeedButton91Click(Sender: TObject); 
    procedure SpeedButton81Click(Sender: TObject); 
    procedure SpeedButton71Click(Sender: TObject); 
    procedure SpeedButton61Click(Sender: TObject); 
    procedure SpeedButton51Click(Sender: TObject); 
    procedure SpeedButton41Click(Sender: TObject); 
    procedure SpeedButton31Click(Sender: TObject); 
    procedure SpeedButton21Click(Sender: TObject); 
    procedure Panel1Click(Sender: TObject); 
    procedure Panel2Click(Sender: TObject); 
    procedure Panel3Click(Sender: TObject); 
    procedure Panel4Click(Sender: TObject); 
    procedure Panel5Click(Sender: TObject); 
    procedure Panel6Click(Sender: TObject); 
    procedure Panel7Click(Sender: TObject); 
    procedure Panel8Click(Sender: TObject); 
    procedure Panel9Click(Sender: TObject); 
    procedure BitBtn1Click(Sender: TObject); 
    procedure Timer1Timer(Sender: TObject); 
    procedure BitBtn3Click(Sender: TObject); 
    procedure BitBtn4Click(Sender: TObject); 
    procedure Button1Click(Sender: TObject); 
    procedure Timer2Timer(Sender: TObject); 
  private 
    { Private declarations } 
    door_state:integer;         //电梯门当前处于状态 
    current:integer;            //电梯当前所在楼层 
    WaitTime:integer;           //电梯等待命令的时间 
    door_control:boolean;       //控制电梯门开关的变量,true为要求打开,false为要求关闭 
    dy:integer;                 //电梯当前的运动方向,1为向下,-1为向上,0为停止 
    agody:integer;              //原来的方向 
    Upflag,Downflag:boolean; 
    UpStop:array[1..9]of boolean;  //向上运动时需暂停的楼层 
    DownStop:array[1..9]of boolean;//向下运动时需暂停的楼层 
    myPanel:array[1..9] of TPanel; 
    myLabel:array[1..9] of TLabel; 
    myUpsb:array[1..9]of TSpeedButton; 
    myDownsb:array[1..9]of TSpeedButton; 
  public 
    { Public declarations } 
  end; 
 
var 
  Form1: TForm1; 
 
implementation 
 
{$R *.dfm} 
 
procedure TForm1.Timer_doorTimer(Sender: TObject); 
begin 
  if door_control then          //打开门 
  begin 
    door_state:=OPENING; 
    shape_door.Width :=Shape_door.Width +2; 
    shape_door.Left :=Shape_door.Left -1; 
    if Shape_door.Width >=Panel_dt.Width then 
    begin 
      door_state:=OPENED; 
      Timer2.Enabled :=true;    //开始开门等待时间计时器 
      Timer_door.Enabled :=false; 
    end; 
  end 
  else                          //关闭门 
  begin 
    door_state:=CLOSEING; 
    shape_door.Width :=Shape_door.Width -2; 
    shape_door.Left :=Shape_door.Left +1; 
    if Shape_door.Width <=0 then 
    begin 
      door_state:=CLOSEED; 
      Timer_door.Enabled :=false; 
      Timer_move.Enabled :=true; 
    end; 
  end; 
end; 
 
procedure TForm1.FormCreate(Sender: TObject); 
var 
  i:integer; 
begin 
  myLabel[1]:=Label8; 
  myLabel[2]:=Label10; 
  myLabel[3]:=Label7; 
  myLabel[4]:=Label6; 
  myLabel[5]:=Label11; 
  myLabel[6]:=Label2; 
  myLabel[7]:=Label3; 
  myLabel[8]:=Label4; 
  myLabel[9]:=Label5; 
 
  myPanel[1]:=Panel1; 
  myPanel[2]:=Panel2; 
  myPanel[3]:=Panel3; 
  myPanel[4]:=Panel4; 
  myPanel[5]:=Panel5; 
  myPanel[6]:=Panel6; 
  myPanel[7]:=Panel7; 
  myPanel[8]:=Panel8; 
  myPanel[9]:=Panel9; 
 
  myUpsb[1]:=SpeedButton12; 
  myUpsb[2]:=SpeedButton22; 
  myUpsb[3]:=SpeedButton32; 
  myUpsb[4]:=SpeedButton42; 
  myUpsb[5]:=SpeedButton52; 
  myUpsb[6]:=SpeedButton62; 
  myUpsb[7]:=SpeedButton72; 
  myUpsb[8]:=SpeedButton82; 
 
  myDownsb[2]:=SpeedButton21; 
  myDownsb[3]:=SpeedButton31; 
  myDownsb[4]:=SpeedButton41; 
  myDownsb[5]:=SpeedButton51; 
  myDownsb[6]:=SpeedButton61; 
  myDownsb[7]:=SpeedButton71; 
  myDownsb[8]:=SpeedButton81; 
  myDownsb[9]:=SpeedButton91; 
 
  for i:=1 to 8 do 
    myUpsb[i].Glyph :=Image_up2.Picture.Bitmap; 
  for i:=2 to 9 do 
    myDownsb[i].Glyph :=Image_Down2.Picture.Bitmap; 
 
  WaitTime:=0; 
  Shape_door.Width :=1; 
  Shape_door.Left :=Panel_dt.Width div 2; 
  door_state:=CLOSEED; 
  door_control:=true; 
  current:=1;   //初始状态电梯在底楼 
  dy:=0;        //入于停止状态 
  agody:=1; 
  for i:=1 to 9 do 
  begin 
    UpStop[i]:=false;         //没有向上需停的标志 
    DownStop[i]:=false;       //没有向下需停的标志 
    myLabel[i].Caption :='电梯正在9楼'; 
  end; 
  self.Brush.Bitmap :=Image1.Picture.Bitmap; 
end; 
 
procedure TForm1.BitBtn2Click(Sender: TObject); 
begin 
  door_control:=not door_control; 
  Timer_door.Enabled :=true; 
  Timer_move.Enabled :=true;            //临时的 
  WaitTime:=0; 
end; 
 
procedure TForm1.Timer_moveTimer(Sender: TObject); 
var 
  i:integer; 
begin 
       if not(Door_state=ClOSEED) then exit; 
  case dy of 
  0: begin              //处于停止状态时;循环检测各层楼有无申请 
       if (UpStop[current]or DownStop[current]) then 
       begin 
         if current<>1 then 
         begin 
           DownStop[current]:=false; 
           myDownsb[current].Glyph :=Image_Down2.Picture.Bitmap; 
         end; 
         if current<>9 then 
         begin 
           UpStop[current]:=false; 
           myUpsb[current].Glyph :=Image_Up2.Picture.Bitmap; 
         end; 
         door_control:=true; 
         Timer_door.Enabled :=true; 
         Timer_move.Enabled :=false; 
         exit; 
       end; 
       for i:=current to 8 do 
       begin 
         if UpStop[i] then 
         begin 
           dy:=1; 
           exit; 
         end; 
       end; 
       for i:=current downto 2 do 
       begin 
         if DownStop[i] then 
         begin 
           dy:=-1; 
           exit; 
         end; 
       end; 
       for i:=current to 9 do 
       begin 
         if DownStop[i] then 
         begin 
           dy:=1; 
           exit; 
         end; 
       end; 
       for i:=current downto 1 do 
       begin 
         if UpStop[i] then 
         begin 
           dy:=-1; 
           exit; 
         end; 
       end; 
     end; 
 -1: begin              //电梯处于向下运动状态 
       if Panel_dt.Top =(Panel_dt.Height-1 )*(9-Current+1) then 
       begin                         //经过各楼层时 
         Bitbtn2.Enabled :=true; 
         Current:=Current-1; 
         for i:=1 to 9 do 
           myLabel[i].Caption :='电梯正在'+inttostr(Current)+'楼'; 
         if Current=1 then 
         begin 
           UpStop[current]:=false; 
           myUpsb[current].Glyph :=Image_Up2.Picture.Bitmap; 
           myPanel[current].Color :=clBtnface; 
           door_control:=true; 
           dy:=0; 
           for i:=2 to 9 do 
             if (UpStop[i] or DownStop[i]) then 
             begin 
               dy:=1; 
               break; 
             end; 
           Timer_door.Enabled :=true; 
           Timer_move.Enabled :=false; 
           exit; 
         end; 
         if DownStop[Current]then 
         begin 
           door_control:=true; 
           DownStop[current]:=false; 
           myDownsb[current].Glyph :=Image_Down2.Picture.Bitmap; 
           myPanel[current].Color :=clBtnface; 
           Timer_door.Enabled :=true; 
           Timer_move.Enabled :=false; 
           Downflag:=false; 
           for i:=current downto 2 do 
             if DownStop[i] then begin Downflag:=true; break; end; 
           if not Downflag then 
             for i:=current downto 1 do 
               if UpStop[i] then begin Downflag:=true; break; end; 
           if not Downflag then 
           begin 
             Upflag:=false; 
             for i:=current to 8 do 
               if UpStop[i] then begin Upflag:=true; break; end; 
             if not Upflag then 
               for i:=current to 9 do 
                 if DownStop[i] then begin Upflag:=true; break; end; 
           end; 
           if not Upflag then dy:=0 
           else dy:=1;   //到此,尚未考虑下方也没请求的分支; 
         exit; 
         end; 
       end 
       else 
         begin 
           BitBtn2.Enabled :=false; 
           Panel_dt.Top :=Panel_dt.Top +1; 
         end; 
     end; 
  1: begin                              //电梯处于向上运动状态 
       if Panel_dt.Top =(Panel_dt.Height -1)*(9-Current-1) then 
       begin                            //经过各楼层时 
         bitbtn2.Enabled :=true; 
         Current:=Current+1; 
         for i:=1 to 9 do 
           myLabel[i].Caption :='电梯正在'+inttostr(Current)+'楼'; 
         //如果电梯到达9楼,则 
         if Current=9 then 
         begin 
//           showmessage('dkfjd'); 
           DownStop[current]:=false; 
           myDownsb[current].Glyph :=Image_Down2.Picture.Bitmap; 
           myPanel[current].Color :=clBtnface; 
//           showmessage('34'); 
           door_control:=true; 
           dy:=0; 
           for i:=1 to 8 do 
             if (UpStop[i] or DownStop[i]) then 
             begin 
               dy:=-1; 
               break; 
             end; 
           Timer_door.Enabled :=true; 
           Timer_move.Enabled :=false; 
           exit; 
         end; 
         //如果该楼层有向上的请请或是目的地,则停梯开门 
         if UpStop[Current]then 
         begin 
           door_control:=true; 
           UpStop[current]:=false; 
           myUpsb[current].Glyph :=Image_Up2.Picture.Bitmap; 
           myPanel[current].Color :=clBtnface; 
           Timer_door.Enabled :=true; 
           Timer_move.Enabled :=false; 
           Upflag:=false; 
           for i:=current to 8 do 
             if UpStop[i] then  exit; 
           if not Upflag then 
             for i:=current to 9 do 
               if DownStop[i] then  exit; 
           if not Upflag then 
           begin 
             Downflag:=false; 
             for i:=current downto 2 do 
               if DownStop[i] then begin Downflag:=true; break; end; 
             if not Downflag then 
               for i:=current downto 1 do 
                 if UpStop[i] then begin Downflag:=true; break; end; 
           end; 
           if not Downflag then dy:=0 
           else dy:=-1;   //到此,尚未考虑下方也没请求的分支; 
         exit; 
         end      //if UpStop[Current] 
         else if DownStop[Current] then 
         //如果存在向下需停时,则检查是否该转向了 
         begin 
           for i:=current+1 to 8 do 
             if UpStop[i] then exit; 
           for i:=current+1 to 9 do 
             if DownStop[i] then exit; 
           door_control:=true; 
           DownStop[current]:=false; 
           myDownsb[current].Glyph :=Image_Down2.Picture.Bitmap; 
           myPanel[current].Color :=clBtnface; 
           Timer_door.Enabled :=true; 
           Timer_move.Enabled :=false; 
           dy:=-1; 
         end; 
       end 
       else 
         begin 
           bitbtn2.Enabled :=false; 
           Panel_dt.Top :=Panel_dt.Top -1; 
         end; 
     end; 
 end; 
end; 
 
procedure TForm1.SpeedButton12Click(Sender: TObject); 
begin 
  UpStop[1]:=true; 
  SpeedButton12.Glyph :=Image_Up1.Picture.Bitmap; 
end; 
 
procedure TForm1.SpeedButton22Click(Sender: TObject); 
begin 
  Upstop[2]:=true; 
  SpeedButton22.Glyph :=Image_Up1.Picture.Bitmap; 
end; 
 
procedure TForm1.SpeedButton32Click(Sender: TObject); 
begin 
  Upstop[3]:=true; 
  SpeedButton32.Glyph :=Image_Up1.Picture.Bitmap; 
end; 
 
procedure TForm1.SpeedButton42Click(Sender: TObject); 
begin 
  Upstop[4]:=true; 
  SpeedButton42.Glyph :=Image_Up1.Picture.Bitmap; 
end; 
 
procedure TForm1.SpeedButton52Click(Sender: TObject); 
begin 
  Upstop[5]:=true; 
  SpeedButton52.Glyph :=Image_Up1.Picture.Bitmap; 
end; 
 
procedure TForm1.SpeedButton62Click(Sender: TObject); 
begin 
  Upstop[6]:=true; 
  SpeedButton62.Glyph :=Image_Up1.Picture.Bitmap; 
end; 
 
procedure TForm1.SpeedButton72Click(Sender: TObject); 
begin 
  Upstop[7]:=true; 
  SpeedButton72.Glyph :=Image_Up1.Picture.Bitmap; 
end; 
 
procedure TForm1.SpeedButton82Click(Sender: TObject); 
begin 
  Upstop[8]:=true; 
  SpeedButton82.Glyph :=Image_Up1.Picture.Bitmap; 
end; 
 
procedure TForm1.SpeedButton91Click(Sender: TObject); 
begin 
  Downstop[9]:=true; 
  SpeedButton91.Glyph :=Image_Down1.Picture.Bitmap; 
end; 
 
procedure TForm1.SpeedButton81Click(Sender: TObject); 
begin 
  DownStop[8]:=true; 
  SpeedButton81.Glyph :=Image_Down1.Picture.Bitmap; 
end; 
 
procedure TForm1.SpeedButton71Click(Sender: TObject); 
begin 
  DownStop[7]:=true; 
  SpeedButton71.Glyph :=Image_Down1.Picture.Bitmap; 
end; 
 
procedure TForm1.SpeedButton61Click(Sender: TObject); 
begin 
  DownStop[6]:=true; 
  SpeedButton61.Glyph :=Image_Down1.Picture.Bitmap; 
end; 
 
procedure TForm1.SpeedButton51Click(Sender: TObject); 
begin 
  DownStop[5]:=true; 
  SpeedButton51.Glyph :=Image_Down1.Picture.Bitmap; 
end; 
 
procedure TForm1.SpeedButton41Click(Sender: TObject); 
begin 
  DownStop[4]:=true; 
  SpeedButton41.Glyph :=Image_Down1.Picture.Bitmap; 
end; 
 
procedure TForm1.SpeedButton31Click(Sender: TObject); 
begin 
  DownStop[3]:=true; 
  SpeedButton31.Glyph :=Image_Down1.Picture.Bitmap; 
end; 
 
procedure TForm1.SpeedButton21Click(Sender: TObject); 
begin 
  DownStop[2]:=true; 
  SpeedButton21.Glyph :=Image_Down1.Picture.Bitmap; 
end; 
 
procedure TForm1.Panel1Click(Sender: TObject); 
begin 
  if Current=1 then exit; 
  Panel1.Color :=clRed; 
  if dy=1 then UpStop[1]:=true 
  else if dy=-1 then DownStop[1]:=true 
  else 
  begin 
    if Current<1 then begin UpStop[1]:=true;end 
    else begin DownStop[1]:=true;end; 
  end; 
  Timer_move.Enabled :=true; 
  WaitTime:=0; 
end; 
 
procedure TForm1.Panel2Click(Sender: TObject); 
begin 
  if Current=2 then exit; 
  Panel2.Color :=clRed; 
  if dy=1 then UpStop[2]:=true 
  else if dy=-1 then DownStop[2]:=true 
  else 
  begin 
    if Current<2 then begin UpStop[2]:=true;end 
    else begin DownStop[2]:=true;end; 
  end; 
  Timer_move.Enabled :=true; 
  WaitTime:=0; 
end; 
 
procedure TForm1.Panel3Click(Sender: TObject); 
begin 
  if Current=3 then exit; 
  Panel3.Color :=clRed; 
  if dy=1 then UpStop[3]:=true 
  else if dy=-1 then DownStop[3]:=true 
  else 
  begin 
    if Current<3 then begin UpStop[3]:=true;end 
    else begin DownStop[3]:=true;end; 
  end; 
  Timer_move.Enabled :=true; 
  WaitTime:=0; 
end; 
 
procedure TForm1.Panel4Click(Sender: TObject); 
begin 
  if Current=4 then exit; 
  Panel4.Color :=clRed; 
  if dy=1 then UpStop[4]:=true 
  else if dy=-1 then DownStop[4]:=true 
  else 
  begin 
    if Current<4 then begin UpStop[4]:=true;end 
    else begin DownStop[4]:=true;end; 
  end; 
  Timer_move.Enabled :=true; 
  WaitTime:=0; 
end; 
 
procedure TForm1.Panel5Click(Sender: TObject); 
begin 
  if Current=5 then exit; 
  Panel5.Color :=clRed; 
  if dy=1 then UpStop[5]:=true 
  else if dy=-1 then DownStop[5]:=true 
  else 
  begin 
    if Current<5 then begin UpStop[5]:=true;end 
    else begin DownStop[5]:=true;end; 
  end; 
  Timer_move.Enabled :=true; 
  WaitTime:=0; 
end; 
 
procedure TForm1.Panel6Click(Sender: TObject); 
begin 
  if Current=6 then exit; 
  Panel6.Color :=clRed; 
  if dy=1 then UpStop[6]:=true 
  else if dy=-1 then DownStop[6]:=true 
  else 
  begin 
    if Current<6 then begin UpStop[6]:=true;end 
    else begin DownStop[6]:=true;end; 
  end; 
  Timer_move.Enabled :=true; 
  WaitTime:=0; 
end; 
 
procedure TForm1.Panel7Click(Sender: TObject); 
begin 
  if Current=7 then exit; 
  Panel7.Color :=clRed; 
  if dy=1 then UpStop[7]:=true 
  else if dy=-1 then DownStop[7]:=true 
  else 
  begin 
    if Current<7 then begin UpStop[7]:=true;end 
    else begin DownStop[7]:=true;end; 
  end; 
  Timer_move.Enabled :=true; 
  WaitTime:=0; 
end; 
 
procedure TForm1.Panel8Click(Sender: TObject); 
begin 
  if Current=8 then exit; 
  Panel8.Color :=clRed; 
  if dy=1 then UpStop[8]:=true 
  else if dy=-1 then DownStop[8]:=true 
  else 
  begin 
    if Current<8 then begin UpStop[8]:=true;end 
    else begin DownStop[8]:=true;end; 
  end; 
  Timer_move.Enabled :=true; 
  WaitTime:=0; 
end; 
 
procedure TForm1.Panel9Click(Sender: TObject); 
begin 
  if Current=9 then exit; 
  Panel9.Color :=clRed; 
//  DownStop 
{  if dy=1 then UpStop[9]:=true 
  else if dy=-1 then DownStop[9]:=true 
  else 
  begin 
    if Current<9 then begin UpStop[9]:=true;end 
    else begin DownStop[9]:=true;end; 
  end;      } 
  DownStop[9]:=true; 
  Timer_move.Enabled :=true; 
  WaitTime:=0; 
end; 
 
procedure TForm1.BitBtn1Click(Sender: TObject); 
begin 
  PlaySound('ring.wav',0,SND_ASYNC or SND_LOOP); 
  Timer1.Enabled:=true ; 
  Timer_move.Enabled :=false; 
end; 
 
procedure TForm1.Timer1Timer(Sender: TObject); 
begin 
  if Shape1.Brush.Color =clRed then 
  begin 
    Shape1.Brush.Color :=clGreen; 
    Shape2.Brush.Color :=clGreen; 
  end 
  else 
  begin 
    Shape1.Brush.Color :=clRed; 
    Shape2.Brush.Color :=clRed; 
  end; 
end; 
 
procedure TForm1.BitBtn3Click(Sender: TObject); 
var 
  i:integer; 
begin 
  PlaySound(nil,0,0); 
  Timer1.Enabled :=false; 
  Timer_move.Enabled :=false; 
  for i:=1 to 9 do 
    myLabel[i].Caption :='电梯停用'; 
end; 
 
procedure TForm1.BitBtn4Click(Sender: TObject); 
var 
  i:integer; 
begin 
  Timer_move.Enabled :=true; 
  for i:=1 to 9 do 
    myLabel[i].Caption :='电梯在'+inttostr(Current)+'楼'; 
end; 
 
procedure TForm1.Button1Click(Sender: TObject); 
begin 
  Application.Terminate; 
end; 
 
procedure TForm1.Timer2Timer(Sender: TObject); 
begin 
       if door_state=OPENED then 
       begin 
        Inc(WaitTime); 
        if WaitTime>=5 then 
        begin 
          WaitTime:=0; 
          Door_control:=false; 
          Timer_door.Enabled :=true; 
        end; 
       end; 
end; 
 
end.