| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 697 人关注过本帖
标题:原创PS型节点排队论代码,1.遇到类型转换不成功,2.声明报错了。。讨论解决 ...
只看楼主 加入收藏
龙弟弟
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2013-5-27
收藏
 问题点数:0 回复次数:2 
原创PS型节点排队论代码,1.遇到类型转换不成功,2.声明报错了。。讨论解决。。
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Edit1: TEdit;
    Label3: TLabel;
    Edit2: TEdit;
    Label4: TLabel;
    Edit3: TEdit;
    Label5: TLabel;
    Edit4: TEdit;
    Label6: TLabel;
    Edit5: TEdit;
    Label7: TLabel;
    Edit6: TEdit;
    Label8: TLabel;
    Edit7: TEdit;
    Label9: TLabel;
    Edit8: TEdit;
    Label10: TLabel;
    Edit9: TEdit;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    Procedure GetOneLivingGuest(var GuestTime:double;var GuesttoNode:double);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  NumofNode,NumofCusmtor,NumofServer,NumofCustmer,Buf:integer;
   f,y,now,v,overtime,servertime:double;
   k,guest:integer;
   Tnow,Tovertime,GuestTimes:double;
   Tserver,Dbuffer,curguest,GuestNodes:integer;
implementation

{$R *.dfm}

function InitialNode(NumofNode,NumofCustmer,NumofServer,Buf:integer):Boolean;
 begin
  if (NumofNode>=1)and(NumofCustmer>=1)and(NumofServer>=1)and(Buf>=0) then
   Result:=True
   else
   Result:=False;
end;
procedure TForm1.FormCreate(Sender: TObject);
 var i:integer;
 begin
 for i:=1 to 10 do
 //begin
 Randomize ;  //初始化随机数发生器
 i:=Random(10);
//label1.Caption:=IntToStr(i);
 f:=i/10;
 end;
 //end;
function AppendOneGuest( y:double;guest:integer):Boolean;//一个顾客到达
  begin
   Randomize ;
   y:=FloatToStr(random(f));                                 // 记录顾客到来时间点
   NumofCustmer:=guest+1;                //顾客总数加1
   NumofNode:=NumofNode+1;               //节点数加1
   NumofServer:=NumofServer-1;
   Buf:=Buf-1;
   if Buf>=0 then                           //服务台数加1
   Result:=True
   else
   Result:=False;
   end;
function DrivetoNextEvent(now,v,overtime,servertime:double):real;      //推进节点的下一事件
 begin
      now:=y;
      v:=5/NumofCustmer;
      servertime:= NumofServer/v;
      overtime:=y+servertime;
     if overtime>y+servertime then
      NumofNode:=NumofNode+1
      else
      NumofCustmer:=NumofCustmer+1;
      begin
      now:=overtime;
      end;
end;
function GetCurTime(Tnow:double):real;
 begin  Tnow:=now;
 end;
function GetNextTime(Tovertime: double):real;
 begin  Tovertime:=overtime;
 end;
function GetNumofServer(Tserver :integer):integer;
 begin  Tserver:= NumofServer;
 end;
function GetSizeofBuffer(Dbuffer:integer):integer;
 begin  Dbuffer:= Buf;
 end;
function GetNumofGuest(curguest: integer):integer;
 begin  if Tnow>=Tovertime then
         curguest:=guest-1
         else curguest:=guest+1;
 end;
Procedure TForm1.GetOneLivingGuest(var GuestTime:double;var GuesttoNode:double);
  var GuestTimes,GuestNodes:double;
    begin
     GuestTimes:=GuestTime;
     GuestNodes:=GuesttoNode;
     GuestTime:=Tnow;
     if Tnow>=Tovertime then
      GuestNodes:=0
      //ShowMessage('服务完毕')
      else GuestNodes:=1 ;
       //showMessage('正在服务');
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
 //Randseed:=i+1;   //每次点击按钮均重新定义随机数种子
 //i:=Random(10);
//label1.Caption:=IntToStr(i);
k:=1;
Tserver:=2;
Buf:=50;
guest:=1;
GuestNodes:=1;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
 begin
  Tserver:=Tserver+k;
  Buf:=Buf-k;
  guest:=guest+k;
  GuestNodes:=GuestNodes+k;
   Edit1.Text:=FloatToStr(Tnow);
   Edit2.Text:=FloatToStr(Tovertime);
   Edit3.Text:=IntToStr(Tserver);
   Edit4.Text:=IntToStr(Dbuffer);
   Edit5.Text:=IntToStr(curguest);
   Edit6.Text:=FloatToStr(GuestTimes);
   Edit7.Text:=IntToStr(GuestNodes);
   Edit8.Text:=FloatToStr(v);
   Edit9.Text:=FloatToStr(NumofNode);
   k:=k+1;
   if k>20 then
   //Timer1.Enabled:= False;
   if k>20 then
   ShowMessage('仿真完毕!');
   //对程序的流程做简单的处理。
end;
end.



问题是


搜索更多相关主题的帖子: 成功 Edit5 Windows 声明 
2013-05-27 12:33
龙弟弟
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2013-5-27
收藏
得分:0 
delphi专家帮忙分析下。。谢谢!
2013-05-27 12:34
龙弟弟
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2013-5-27
收藏
得分:0 
问题是incomplete type ,在y:=FloatToStr(random(f));                                 
2013-05-29 12:14
快速回复:原创PS型节点排队论代码,1.遇到类型转换不成功,2.声明报错了。。讨论 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016902 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved