渠道水力计算在delphi上的实现(1)

摘要:渠道水力计算一直以来在渠道设计中就是一件烦琐的事情,因为其涉及到大量的试算工作,在水利工程灌溉渠系设计中常令人不胜其烦。为化繁为简,减少设计中的工作量,考虑使用计算机技术实现试算工作的程序化。我局正使用delphi编程技术进行管理信息系统(mis)的开发建设工作,故决定将其纳入mis系统建设中,成为本局mis系统的一部分。delphi技术是美国inprise公司开发的基于pascal语言的程序开发软件,其不仅在数据库编程方面有卓越表现,而且在数学计算中也成绩斐然。

关键词:水力计算 delphi 谢才系数 流量模数 业务服务器 客户端

 

一、          水力计算简介

将渠道内水流视作明渠均匀流这是渠道水力计算的前提,故计算公式采用明渠均匀流公式。主要任务是解决渠道的过水能力问题,即设计渠道的断面尺寸,以保证通过所需的流量,或校核渠道是否满足输水流量的要求等。总体而言,渠道水力计算的问题主要分两类:1、校核渠道过水能力;2、计算渠道的断面尺寸。

校核渠道的过水能力主要指在渠道的断面形式、尺寸、糙率、底坡等都已确定的情况下,计算其过水能力。计算步骤为:先根据水深h,底宽b及边坡系数m计算出过水断面面积ω、湿周χ、水力半径r。再根据糙率n及水力半径r计算(或查表)求出谢才系数c。最后用明渠均匀流公式q=ωc(ri)1/2计算出流量。

计算渠道的断面尺寸是渠系工程设计中遇到最多的问题。在规划设计新渠道时,设计流量由工程要求而定,坡度一般是由渠道大小根据地形条件确定,边坡系数m及糙率n,则由土质及渠壁材料与施工、管理运用等条件而定。也即已知q、m、n、i,求渠道的水深h及底宽b。此问题有两个未知数b及h,故须经过试算才能确定。计算步骤为:1、根据已知的流量q及渠道底坡i,求出流量模数k0(标准流量模数);2、初步假定一水深,计算其相应的过水断面ω、湿周χ、水力半径r,并根据糙率n及水力半径r计算或查表求出相应的谢才系数c值。然后,按公式k=ωcr1/2求出相应的流量模数值(设计流量模数);3、将计算出的设计流量模数与标准流量模数比较,若两者相等,则所设水深即为所求。若不等,则可另设一水深,重复上述步骤,直到计算出的设计流量模数与标准流量模数相等为止。然后经综合考虑各方面因素,如施工便利,防洪超高和其他用途后最终确定渠道断面尺寸。

 二、delphi技术简介

     delphi是由美国inprise公司(前borland公司)推出的可视化编程环境,它提供了一种方便、快捷的windows应用程序开发工具。delphi使用了microsoft windows图形用户界面的许多先进特性和设计思想,采用了可重复利用的完整的面向对象程序语言(object-oriented language)、当今世界上最快的编辑器、最为领先的数据库技术。delphi技术的基础源自pascal语言,是对pascal语言编程的可视化、面向对象化发展,从早期的对turbo pascal的windows化到如今对网络化编程拥有强大功能,delphi已经升级到了如今的第七个版本,功能更加强大,对网络开发的需求更为适应,对数据库开发的技术更为成熟与稳定。

三、程序实现的方法

本程序作为我局管理信息系统(mis)的一部分外挂于我局管理信息系统的主界面上,属于水利常用计算模块。我局管理信息系统采用客户端、业务服务器、数据库管理系统(dbms)三级结构,客户端和业务服务器采用dephi开发实现,数据库管理系统(dbms)选择美国microsoft 公司倍受业界好评的sql server 2000。因此,本程序的数据计算、数据添加和数据删除功能以函数的形式建于业务服务器中,在客户端通过函数调用达到功能的实现。为实现数据的保存与查询,相应地在我局管理信息系统的业务数据库lsdata中建立一个数据库表watercalculationtable。客户端除实现业务服务器相关函数的调用外,还承担程序外观界面设置和部分简单功能的实现。用户只能通过程序客户端实现对软件的操作。

1、功能设计

本程序设计的主要目的在于实现对渠道水力计算的程序化和智能化,主要功能包括计算、成果显示、数据打印,另外为方便数据输入加入重置功能,为便于数据管理加入删除功能,另外为实现计算界面的退出而加入界面退出功能。

2、界面设计

为实现计算成果的显示功能在界面上添加一个dxdbgrid控件,作为成果显示的载体。为方便数据的录入和计算成果的单条显示添加十五个coastedit控件,为逐一说明各个coastedit控件代表的数据而增入十五个与之对应的label控件,为程序美观用一个groupbox将所有coastedit控件和label控件归为一组。为了实现计算、删除、重置、打印、退出功能,引入五个 button控件其中计算按钮除在单击时触发计算功能外,在计算结束后自动执行数据添加功能,将计算数据添加入数据库中;删除按钮实现对库内单条数据的删除;重置按钮主要对coastedit控件中的数据进行清除,以利于新数据的输入;打印功能作用在于将计算所得的成果通过外接打印机打印出来;退出按钮的功能在于实现界面的退出,返回主界面。

程序界面中渠道名称、试算次序数、渠道底宽、渠道水深、渠道比降、边坡系数、渠道糙率、设计流量等数据可以手动输入,其他数据不能在界面上输入,由程序自动计算,并显示。根据渠道水力计算原理,可输入的数据除设计流量外均不允许为空,此外渠道糙率和渠道比降不能为零,出现上述情况,计算时程序将予以提示。

为实现程序的打印功能,特增加一打印界面,在点击打印按钮时自动弹出,打印界面可以实现打印、打印预览功能,在此界面可以调用windows打印程序。

具体界面设计图样见图1。

                            (图一)

3、数据库表设计

   本程序只有一张库表,即渠道水力计算表(watercalculationtable),经过慎密的数据分析,设计该表共包含十五个字段,分别为:渠道名称、试算次序数、渠道宽度、渠道水深、渠道比降、边坡系数、设计流量、渠道糙率、湿周、标准流量模数、过水断面面积、水力半径、谢才系数、设计断面过水流量、设计流量模数。具体库表设计见表一:

 渠道水力计算表(watercalculationtable)
            表一

4、内置代码设计

内置代码主要是针对程序中相关控件触发的事件而设定的相应响应。本程序包含的事件主要有各button控件引发的单击事件、单击dxdbgrid控件引发的事件(dxdbgridclick)、数据集控件滚动事件(adodataset1afterscroll)和程序界面建立时的事件(formcreat)。另外,业务服务器(teoperationserver)中包含的两个函数addwatercalculation和deletewatercalculation也用程序代码建立。

各事件代码分别如下:

1)              addwatercalculation函数,代码为:

function tteoperationserver.addwatercalculation(

  const ditchname: widestring; ditchwidth, ditchheight, ditchslope,

  slopenumer, ditchrough, planvolume: currency;

  const calculationno: widestring): longword;

var

  strsql : string;

  dwaffected : integer;

  kstandard,flowarea,waterradius,cnumer,designvolume,kdesign,xnumer:currency;

begin

  result := makeresult(sev_error,facility_account,err_suc);

kstandard:=strtofloat(formatfloat('0.00',(planvolume/sqrt(ditchslope)))); flowarea:=strtofloat(formatfloat('0.00',((ditchwidth+slopenumer*ditchheight)*ditchheight)));  xnumer:=strtofloat(formatfloat('0.00',(ditchwidth+2*ditchheight*sqrt(1+sqr(slopenumer)))));

  waterradius:=strtofloat(formatfloat('0.000',(flowarea/xnumer)));  cnumer:=strtofloat(formatfloat('0.00',(1/ditchrough*power(waterradius,1/6))));

kdesign:=strtofloat(formatfloat('0.00',(flowarea*cnumer*sqrt(waterradius))));  designvolume:=strtofloat(formatfloat('0.00',(flowarea*cnumer*sqrt(waterradius*ditchslope))));

  strsql:='insert into watercalculationtable (ditchname,ditchwidth,ditchheight,'

        + ' ditchslope,slopenumer,planvolume,ditchrough,kstandard,'

        + ' flowarea,waterradius,cnumer,designvolume,kdesign,xnumer,calculationno)'

        + ' values ('+''''+ditchname+''','

        + ' '''+floattostr(ditchwidth)+''','

        + ' '''+floattostr(ditchheight)+''','

        + ' '''+floattostr(ditchslope)+''','

        + ' '''+floattostr(slopenumer)+''','

        + ' '''+floattostr(planvolume)+''','

        + ' '''+floattostr(ditchrough)+''','

        + ' '''+floattostr(kstandard)+''','

        + ' '''+floattostr(flowarea)+''','

        + ' '''+floattostr(waterradius)+''','

        + ' '''+floattostr(cnumer)+''','

        + ' '''+floattostr(designvolume)+''','

        + ' '''+floattostr(kdesign)+''','

        + ' '''+floattostr(xnumer)+''','

        + ' '''+calculationno+''')';

  executesql(strsql,@dwaffected);

  if dwaffected <= 0 then

  begin

    result := makeresult(sev_error,facility_account,err_insert);

    exit;

  end;

end;

  2)deletewatercalculation函数的代码为:

function tteoperationserver.deletewatercalculation(const ditchname,

  calculationno: widestring): longword;

var

  strsql : string;

  dwaffected : integer;

begin

  result := makeresult(sev_error,facility_account,err_suc);

  strsql := ' delete from watercalculationtable '

          + ' where  ditchname= ' + '''' + ditchname + ''''

          + '       and calculationno = ' + '''' + calculationno + '''';

  executesql(strsql,@dwaffected);

  if dwaffected < 0 then

  begin

    result := makeresult(sev_error,facility_account,err_delete);

    exit;

  end;

end;

3)计算按钮(button1click)的代码为:

procedure tformprice.button1click(sender: tobject);

var

  resultcode:hresult;

begin

  resultcode:=-1;

    if coastedit1.text='' then

  begin

    application.messagebox('对不起,''渠道名称'' 不能为空.','提示',mb_ok+mb_iconwarning);

    coastedit1.setfocus;

    exit;

  end;

  if coastedit2.text='' then

  begin

    application.messagebox('对不起,''渠道底宽'',不能为空','提示',mb_ok+mb_iconwarning);

    coastedit2.setfocus;

    exit;

  end;

  if coastedit3.text='' then

  begin

    application.messagebox('对不起,''渠道水深'',不能为空','提示',mb_ok+mb_iconwarning);

    coastedit3.setfocus;

    exit;

  end;

  if coastedit4.text='' then

  begin

    application.messagebox('对不起,''边坡系数'',不能为空','提示',mb_ok+mb_iconwarning);

    coastedit4.setfocus;

    exit;

  end;

   if coastedit5.text='' then

  begin

    application.messagebox('对不起,''渠道糙率'',不能为空','提示',mb_ok+mb_iconwarning);

    coastedit5.setfocus;

    exit;

  end;

   if coastedit6.text='' then

  begin

    application.messagebox('对不起,''渠道比降'',不能为空','提示',mb_ok+mb_iconwarning);

    coastedit6.setfocus;

    exit;

  end;

  if coastedit15.text='' then

  begin

    application.messagebox('对不起,''试算次序数'',不能为空','提示',mb_ok+mb_iconwarning);

    coastedit15.setfocus;

    exit;

  end;

  if coastedit2.value=0 then

  begin

    application.messagebox('对不起,''渠道底宽'',不能为零','提示',mb_ok+mb_iconwarning);

    coastedit2.setfocus;

    exit;

  end;

  if coastedit3.value=0 then

  begin

    application.messagebox('对不起,''渠道水深'',不能为零','提示',mb_ok+mb_iconwarning);

    coastedit3.setfocus;

    exit;

  end;

  if coastedit6.value=0 then

  begin

    application.messagebox('对不起,''渠道比降'',不能为零','提示',mb_ok+mb_iconwarning);

    coastedit6.setfocus;

    exit;

  end;

  if coastedit5.value=0 then

  begin

    application.messagebox('对不起,''渠道糙率'',不能为零','提示',mb_ok+mb_iconwarning);

    coastedit5.setfocus;

    exit;

  end;

  try

    teoperationserver.begintrans;    resultcode:=teoperationserver.addwatercalculation(coastedit1.text,coastedit2.value,coastedit3.value,coastedit6.value,coastedit4.value,coastedit5.value,coastedit7.value,coastedit15.text);

  finally

    if hresultcode(resultcode) = 0 then

    begin

      网址未加载mit;

      refresh;

      coastedit1.text:='';

      coastedit2.text:='';

      coastedit3.text:='';

      coastedit4.text:='';

      coastedit5.text:='';

      coastedit6.text:='';

      coastedit7.text:='';

      coastedit8.text:='';

      coastedit9.text:='';

      coastedit10.text:='';

      coastedit11.text:='';

      coastedit12.text:='';

      coastedit13.text:='';

      coastedit14.text:='';

      coastedit15.text:='';

      coastedit1.setfocus;

    end

    else

    begin

      teoperationserver.rollback;

      application.messagebox('添加失败','提示',mb_ok+mb_iconwarning);

       coastedit1.setfocus;

    end;

  end;

end;

4)打印按钮(button2click)的代码为:

procedure tformprice.button2click(sender: tobject);

var

  svdata: string;

  iheader: integer;

  iheaderobject: integer;

  strsql: string;

  recordset10: _recordset;

begin

  svdatafile :=getparentdir(extractfilepath(paramstr(0))) + 'datawatercalculation.txt';

  ppreport1.closedatapipelines;

  if hfile <> 0 then fileclose(hfile);

  if fileexists(svdatafile) then

    deletefile(svdatafile);

  hfile := filecreate(svdatafile);

  strsql := 'select * from lsdata.dbo.watercalculationtable' ;

  svdata:= teoperationserver.resultstrorder(strsql);

  filewrite(hfile, pointer(svdata)^, length(svdata));

  fileclose(hfile);

  pptextpipeline1.filename := svdatafile;

  ppreport1.datapipeline := pptextpipeline1;

  //处理表尾

  if ppreport1.objectbyname(iheader, iheaderobject, 'pplabel8') then

    tpplabel(ppreport1.bands[iheader].objects[iheaderobject]).caption := fmainframeobject.operatorname;

  with tfrmreportpreview1.create(self) do

  try

    ppviewer1.report := ppreport1;

    ppviewer1.firstpage;

    show;

  except

    free;

  end;

  ppreport1.closedatapipelines;

  fileclose(hfile);

end;

5)重置按钮(button5click)的代码为:

procedure tformprice.button5click(sender: tobject);

begin

  coastedit1.text:='';

  coastedit2.text:='';

  coastedit3.text:='';

  coastedit4.text:='';

  coastedit5.text:='';

  coastedit6.text:='';

  coastedit7.text:='';

  coastedit8.text:='';

  coastedit9.text:='';

  coastedit10.text:='';

  coastedit11.text:='';

  coastedit12.text:='';

  coastedit13.text:='';

  coastedit14.text:='';

  coastedit15.text:='';

end;

end.

6)删除按钮(button4click)的代码为:

procedure tformprice.button4click(sender: tobject);

var

  resultcode:hresult;

 

begin

  resultcode:=-1;

  if application.messagebox(' 您确实要删除吗?','删除确认',mb_yesno+mb_iconwarning+mb_defbutton2+mb_systemmodal)=idno then

    exit;

  try

    teoperationserver.begintrans;

    resultcode:=teoperationserver.deletewatercalculation(coastedit1.text,coastedit15.text);

  finally

    if hresultcode(resultcode) = 0 then

    begin

      application.messagebox('删除成功','提示',mb_ok+mb_iconwarning);

      网址未加载mit;

      refresh;

      coastedit1.text:='';

      coastedit2.text:='';

      coastedit3.text:='';

      coastedit4.text:='';

      coastedit5.text:='';

      coastedit6.text:='';

      coastedit7.text:='';

      coastedit8.text:='';

      coastedit9.text:='';

      coastedit10.text:='';

      coastedit11.text:='';

      coastedit12.text:='';

      coastedit13.text:='';

      coastedit14.text:='';

      coastedit15.text:='';

    end

    else

    begin

      application.messagebox('删除失败','提示',mb_ok+mb_iconwarning);

      teoperationserver.rollback;

    end;

  end;

end;

7)退出按钮(button4click)的代码为:

procedure tformprice.button3click(sender: tobject);

begin

close;

end;

8)程序界面创建事件(formcreat)的代码为:

procedure tformprice.formcreate(sender: tobject);

var

  strsql:string;

  codestring1: string;

begin

  teoperationserver:=getserver('teoperationserver');

  refresh;

  coastedit1.text:='';

  coastedit2.text:='';

  coastedit3.text:='';

  coastedit4.text:='';

  coastedit5.text:='';

  coastedit6.text:='';

  coastedit7.text:='';

  coastedit8.text:='';

  coastedit9.text:='';

  coastedit10.text:='';

  coastedit11.text:='';

  coastedit12.text:='';

  coastedit13.text:='';

  coastedit14.text:='';

  coastedit15.text:='';

end;

9)单击dxdbgrid事件和数据集控件滚动事件的代码(两事件代码基本一样):

begin

  if (adodataset1.recordset<>nil ) and (adodataset1.recordcount>0 ) then

  begin

    coastedit1.text:=adodataset1.fields[0].value;

    coastedit2.value:=adodataset1.fields[1].value;

    coastedit3.value:=adodataset1.fields[2].value;

    coastedit4.value:=adodataset1.fields[3].value;

    coastedit5.value:=adodataset1.fields[4].value;

    coastedit6.value:=adodataset1.fields[5].value;

    coastedit7.value:=adodataset1.fields[6].value;

    coastedit8.value:=adodataset1.fields[7].value;

    coastedit9.value:=adodataset1.fields[8].value;

    coastedit10.value:=adodataset1.fields[9].value;

    coastedit11.value:=adodataset1.fields[10].value;

    coastedit12.value:=adodataset1.fields[11].value;

    coastedit13.value:=adodataset1.fields[12].value;

    coastedit14.value:=adodataset1.fields[13].value;

    coastedit15.text:=adodataset1.fields[14].value;

  end;

10)refresh函数的代码为:

procedure tformprice.refresh;

var

  strsql:string;

begin

  strsql := ' select * from watercalculationtable' ;

  adodataset1.recordset:=vartorecordset(teoperationserver.query(strsql));

end;

 

共2页: 1

论文出处(作者):

渠道水力计算在delphi上的实现(1)

下载Word文档到电脑,方便收藏和打印~

下载Word文档

带你看艺考
艺考信息时光机

最新:减少4所!教育部最新批准的独立设置艺术院校名单出炉!

西安美术学院、四川音乐学院、已不在最新的教育部批准的独立设置本科艺术院校名单序列;中央民族大学、河北美术学院也不在最新的参照独立设置本科院校之中。
独立设置艺术院校名单
2022艺考独立设置艺术院校名单2022/8/17

大学和学院、专科和职业技术学院的区别

“我感觉这所学校是公办的”“一听这所学校的名字就像民办的”........今天,小编就带大家了解一下,“大学、学院”“专科学校、职业技术学院”之间的区别。
大学和学院、专科和职业技术学院的区别
2022高考大学和学院、专科和职业技术学院的区别2022/8/17

郑州大学2022年上海市本科批录取结果查询

郑州大学2022年上海市本科批录取结果查询
郑大招生
普通类录取分数线郑大招生2022/8/17

云南省2022年普高投档分数线(8月15日)

云南省2022年普高投档分数线(8月15日)
云南省教育厅
云南高考投档线云南省教育厅2022/8/17

贵州省2022年8月16日高考投档分数线

贵州省2022年8月16日高考投档分数线
贵州省招生考试院
贵州高考投档线贵州省招生考试院2022/8/17

河北东方学院2022年河北省美术类本科专业录取分数线

河北东方学院2022年河北省美术类本科专业录取分数线
河北东方学院2022年河北省美术类本科专业录取分数线
艺术类录取分数线河北东方学院2022年河北省美术类本科专业录取分数线2022/8/17

2021年信阳农林学院美术类专业录取分数线

2021年信阳农林学院美术类专业录取分数线
2021年信阳农林学院美术类专业录取分数线
艺术类录取分数线2021年信阳农林学院美术类专业录取分数线2022/8/17

河北建筑工程学院2022年环境设计专业录取分数线

河北建筑工程学院2022年环境设计专业录取分数线
河北建筑工程学院2022年环境设计专业录取分数线
艺术类录取分数线河北建筑工程学院2022年环境设计专业录取分数线2022/8/17

河北传媒学院2022年艺术类本科专业录取分数线

河北传媒学院2022年艺术类本科专业录取分数线
河北传媒学院2022年艺术类本科专业录取分数线
艺术类录取分数线河北传媒学院2022年艺术类本科专业录取分数线2022/8/17

曲靖师范学院2022年艺术类本科专业录取分数线

曲靖师范学院2022年艺术类本科专业录取分数线
曲靖师范学院2022年艺术类本科专业录取分数线
艺术类录取分数线曲靖师范学院2022年艺术类本科专业录取分数线2022/8/17

楚雄师范学院2021年艺术类本科专业录取分数线

楚雄师范学院2021年艺术类本科专业录取分数线
楚雄师范学院2021年艺术类本科专业录取分数线
艺术类录取分数线楚雄师范学院2021年艺术类本科专业录取分数线2022/8/17

保山学院2022年艺术类本科专业录取分数线

保山学院2022年艺术类本科专业录取分数线
保山学院2022年艺术类本科专业录取分数线
艺术类录取分数线保山学院2022年艺术类本科专业录取分数线2022/8/17

2022年三峡大学美术设计类专业录取分数线

2022年三峡大学美术设计类专业录取分数线
2022年三峡大学美术设计类专业录取分数线
艺术类录取分数线2022年三峡大学美术设计类专业录取分数线2022/8/17

廊坊师范学院2022年艺术类本科专业分省招生计划

廊坊师范学院2022年艺术类本科专业分省招生计划
廊坊师范学院2022年艺术类本科专业分省招生计划
艺术类招生计划廊坊师范学院2022年艺术类本科专业分省招生计划2022/8/17

河北东方学院2022年河北省美术类本科专业招生计划

河北东方学院2022年河北省美术类本科专业招生计划
河北东方学院2022年河北省美术类本科专业招生计划
艺术类招生计划河北东方学院2022年河北省美术类本科专业招生计划2022/8/17

河北工程技术学院2022年艺术类本科专业分省招生计划

河北工程技术学院2022年艺术类本科专业分省招生计划
河北工程技术学院2022年艺术类本科专业分省招生计划
艺术类招生计划河北工程技术学院2022年艺术类本科专业分省招生计划2022/8/17

四川旅游学院2022年四川、云南省的本科批次以及四川体育和对口专科批次录取结果查询

四川旅游学院2022年四川、云南省的本科批次以及四川体育和对口专科批次录取结果查询
四川旅游学院
录取查询四川旅游学院2022/8/16

宁波诺丁汉大学2022年高考录取结果查询(2022-08-15更新)

宁波诺丁汉大学2022年高考录取结果查询(2022-08-15更新)
宁波诺丁汉大学招生办
录取查询宁波诺丁汉大学招生办2022/8/16

西安外事学院2022年青海、甘肃、吉林、四川普通类专科录取结果查询

西安外事学院2022年青海、甘肃、吉林、四川普通类专科录取结果查询
西安外事学院招办
录取查询西安外事学院招办2022/8/16

嘉兴学院2022年上海市录取结果查询

嘉兴学院2022年上海市录取结果查询
嘉兴学院招生办公室
录取查询嘉兴学院招生办公室2022/8/16
没有更多了?去看看其它艺考内容吧

艺考热搜

艺考数据
艺考资源站

  • 艺考分数线
  • 艺考简章