⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.pas

📁 模拟电梯系统,有40个楼层,10做电梯,实现全部人和动作,望大家参考,提意见.
💻 PAS
字号:
unit main;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls,
  setupin,Define,Forms, Dialogs, ComCtrls, ExtCtrls, StdCtrls, Grids;

type
  Tmainform = class(TForm)
    STB1: TStatusBar;
    Panel1: TPanel;
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    TabSheet2: TTabSheet;
    TabSheet3: TTabSheet;
    Panel2: TPanel;
    TB0: TTrackBar;
    TB1: TTrackBar;
    TB2: TTrackBar;
    TB3: TTrackBar;
    TB4: TTrackBar;
    TB5: TTrackBar;
    TB6: TTrackBar;
    TB7: TTrackBar;
    TB8: TTrackBar;
    TB9: TTrackBar;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    Memo0: TMemo;
    Memo1: TMemo;
    Memo2: TMemo;
    Memo3: TMemo;
    Memo4: TMemo;
    Memo5: TMemo;
    Memo6: TMemo;
    Memo7: TMemo;
    Memo8: TMemo;
    Memo9: TMemo;
    Label11: TLabel;
    Label12: TLabel;
    Label13: TLabel;
    Label14: TLabel;
    Label15: TLabel;
    Label16: TLabel;
    Label17: TLabel;
    Label18: TLabel;
    Label19: TLabel;
    Label20: TLabel;
    Label21: TLabel;
    Label22: TLabel;
    Label23: TLabel;
    Label24: TLabel;
    Label25: TLabel;
    Label26: TLabel;
    Label27: TLabel;
    Label28: TLabel;
    Label29: TLabel;
    Label30: TLabel;
    ST0: TStaticText;
    ST1: TStaticText;
    ST2: TStaticText;
    ST3: TStaticText;
    ST4: TStaticText;
    ST5: TStaticText;
    ST6: TStaticText;
    ST7: TStaticText;
    ST8: TStaticText;
    ST9: TStaticText;
    idleST0: TStaticText;
    idleST1: TStaticText;
    idleST2: TStaticText;
    idleST3: TStaticText;
    idleST4: TStaticText;
    idleST5: TStaticText;
    idleST6: TStaticText;
    idleST7: TStaticText;
    idleST8: TStaticText;
    idleST9: TStaticText;
    Panel3: TPanel;
    Panel4: TPanel;
    StrGD1: TStringGrid;
    Memo10: TMemo;
    Memo11: TMemo;
    Memo12: TMemo;
    Label31: TLabel;
    Label32: TLabel;
    Label33: TLabel;
    Memo13: TMemo;
    Label34: TLabel;
    Label35: TLabel;
    Label36: TLabel;
    Label37: TLabel;
    Label38: TLabel;
    Label39: TLabel;
    Label40: TLabel;
    Label41: TLabel;
    Label42: TLabel;
    Label43: TLabel;
    Label44: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  mainform: Tmainform;

implementation

{$R *.DFM}

procedure Tmainform.FormCreate(Sender: TObject);
var i:integer;
begin
     for i:=0 to 9 DO
      begin
         ElavotorTrack[i]:=TTrackbar.Create(nil);
         Elavotor_idle_Label[i]:=TStaticText.Create(nil);
         Elavotor_Busy_Label[i]:=TStaticText.Create(nil);
         Elavotor_Memo[i]:=Tmemo.Create(nil);
      end;
     ShowFloor:=TStringGrid.Create(nil);
     ShowFloor:=StrGD1;
      ElavotorTrack[0]:=TB0;
      ElavotorTrack[1]:=TB1;
      ElavotorTrack[2]:=TB2;
      ElavotorTrack[3]:=TB3;
      ElavotorTrack[4]:=TB4;
      ElavotorTrack[5]:=TB5;
      ElavotorTrack[6]:=TB6;
      ElavotorTrack[7]:=TB7;
      ElavotorTrack[8]:=TB8;
      ElavotorTrack[9]:=TB9;
        Elavotor_idle_Label[0]:=idleST0;
        Elavotor_idle_Label[1]:=idleST1;
        Elavotor_idle_Label[2]:=idleST2;
        Elavotor_idle_Label[3]:=idleST3;
        Elavotor_idle_Label[4]:=idleST4;
        Elavotor_idle_Label[5]:=idleST5;
        Elavotor_idle_Label[6]:=idleST6;
        Elavotor_idle_Label[7]:=idleST7;
        Elavotor_idle_Label[8]:=idleST8;
        Elavotor_idle_Label[9]:=idleST9;
          Elavotor_Busy_Label[0]:=ST0;
          Elavotor_Busy_Label[1]:=ST1;
          Elavotor_Busy_Label[2]:=ST2;
          Elavotor_Busy_Label[3]:=ST3;
          Elavotor_Busy_Label[4]:=ST4;
          Elavotor_Busy_Label[5]:=ST5;
          Elavotor_Busy_Label[6]:=ST6;
          Elavotor_Busy_Label[7]:=ST7;
          Elavotor_Busy_Label[8]:=ST8;
          Elavotor_Busy_Label[9]:=ST9;
            Elavotor_Memo[0]:=Memo0;
            Elavotor_Memo[1]:=Memo1;
            Elavotor_Memo[2]:=Memo2;
            Elavotor_Memo[3]:=Memo3;
            Elavotor_Memo[4]:=Memo4;
            Elavotor_Memo[5]:=Memo5;
            Elavotor_Memo[6]:=Memo6;
            Elavotor_Memo[7]:=Memo7;
            Elavotor_Memo[8]:=Memo8;
            Elavotor_Memo[9]:=Memo9;
    try
        SystemControl:=TSystemControl.Create;
        SystemControl.Initsystem;
    finally
    end;
          SystemControl.Initsystem;
end;

procedure Tmainform.FormDestroy(Sender: TObject);
var i:integer;
begin
 //释放所有类对象和线程的内存资源
 try
   SystemMonitor.FreeOnTerminate:=true;
   SystemMonitor.Terminate;
   for i:=0 to Systemcontrol.CurrentPersonTotal-1 DO
     Person[i].Free;
   for i:=0 to 9 Do
    begin
      RunThread[i].FreeOnTerminate:=true;
      RunThread[i].Terminate;
      Elavotor[i].Free;
      ElavotorTrack[i].Free;
      Elavotor_idle_Label[i].free;
      Elavotor_Busy_Label[i].free;
    end;
    for i:=0 to 39 DO
      Floor[i+1].Free;
    SystemControl.Free;
  finally
  end;
end;

procedure Tmainform.FormShow(Sender: TObject);
var i:integer;
begin
  SystemMonitor.Resume;
  sleep(1000);
  for i:=0 to 9 DO
  RunThread[i].Resume;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -