VB编程在管线排水量计算中的应用
2019-04-24李兆崔张为华席晓宋章亮
李兆崔 张为华 席晓 宋章亮
摘 要:大口径单管供运行过程中,管线一旦被机械损伤漏水,甚至爆管,需要快速动作维修。在关阀后的维修一般需要抽水这一重要的工序,而这道工序的时间长短决定着抢修成败的关键。故需要准确计算排水量的多少,以确定泵的类型,求得排水用时。本文采用计算机自动计算的办法,算出排水量的多少,为决策排水模式选用,也为预先设计排水工程具有重要的参考价值。
关键词:排水量;VB编程;爆管
中图分类号:TU832 文献标识码:A 文章编号:1671-2064(2019)05-0032-04
1 概述
一般对管道进行维修、维护要对管道内部水进行排空。在管线设计中,对此也做了充分的考虑。理论上,对管线内部水都能通过预设排水阀进行排空。对于管线排水,通常排水需要关阀最上游的阀门和最下游的阀门。关闭上游是为了水库的水不能补入。关下游阀门是为了不干挠影响下游的用水网络。
为了排空所处位置的管内水,譬如该处管爆,或该点故障。首先从故障点所在的管线段逆管线流向追踪,得到上游第一个排水阀门后即停止,然后以得到的阀门为出发点向管线下游追踪,得到另一个排水阀门。分别用故障点,对比两个阀门,选择合适的一个,然后再分别向外找到最近的两个闸阀并关闭。最后是从选定的排水阀进行自流排水或抽排。
而在实际的运行中,需要工程师参考图纸,凭借经验,统筹考虑,选定方案。而通过该软件可把整个管线图放在一张图中,并通过任意点击放水点可自动算出排水方量,同时也依次得出相临两个阀间的排水量。并画出放水后管内水位线,可直接观察到管道放水最后的效果。便于直接投放显示,以供实践中决策排水的方案。
2 计算排水量VB编程参数
与排水有关的管线参数,一是主管道直径,排水管直径。管道的桩号与高程。考虑闸阀对放水段的区隔要明确闸阀的桩号。因为排水要开启排水阀,要明确排水阀的桩号和高程,排水阀不特殊说明,均安装在管道的最下部。考虑自流排水要明确排水井的井口高度,如果设有排水管要明确排水管的管底高程。关于这个参数可实地测量以求准确。同时要参考地面参数,便是地面的里程与地面高程。以上数据在管道设计资料中均有体现。无论自流排水还是泵抽排水在实践中要考虑与就近的排水系统相联接。要避免发生对周围庄稼作物等造成涝灾。对重要部位,对设计排水要进行专项设计和论证。要严格按照排水的结论成果操作排水。
对于该参数数据由于因管线不同而不同,采用常用办公表格EXCEL作为软件输入的数据来源。按照要求的格式输入,存放在要求的目录之下。由程序直接读取。
3 VB程序设计
程序设计思路。读收表格中的管道参数。进行绘制管线、地面线、水面线。算出水平线以下的管道面积。折算成水量长度。
利用VB开发的计算程序如下:
第一步,运行VB6.0[1]。
第二步,画控件。如图1所示,画TEXTBOK控件四个,对应的横比、纵比、桩号与横比的积、高程与纵比的积。(纵横比默认值是1,两个积值自动生成,用于观测和引用)。根据管线的不同可选用不同的比例。画LABEL标签控件四个,作为TEXTBOK的说明。画COMMANDBUTTON控件四个,一是显示管道图示,二是清屏。用于对显示图的清空。三是对计算成果输出到文件DOC中。四是对图示输出到CAD。由于管道一般都无法在一张图中显示,左上角加设了一个的水平滚动条和一个竖直滚动条可用于对成图的漫游观察。
第三步,分别以双击COMMANDBUTTON便进入编程界面,主体程序如图1:
第三步,分别以双击COMMANDBUTTON便进入编程界面,主体程序如下:
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim a(500) As Double
Dim b(500) As Double
Dim a1(500) As Double
Dim b1(500) As Double
Dim a2(500) As Double
Dim b2(500) As Double
Dim c(2000) As Double
Dim d(2000) As Double
Dim e(550) As Double
Dim f(550) As Double
Dim g(550) As Double
Dim h(550) As Double
Dim u(500) As Double
Dim v(500) As Double
Dim u1(150) As Double
Dim v1(150) As Double
Dim u2(150) As Double
Dim v2(150) As Double
Private Sub Command2_Click()
Picture1.Cls
End Sub
Private Sub Command6_Click()
If Text1 = flase Then Text1 = 1
If Text2 = flase Then Text2 = 1
Set xlApp = CreateObject("Excel.Application") '创建EXCEL对象
Set xlBook = xlApp.Workbooks.Open("c:\water.xls") '打開已经存在的EXCEL工件簿文件
xlApp.Visible = True '設置EXCEL对象可见(或不可见)
Set xlSheet = xlBook.Worksheets("sheet1") '设置活动工作表
w = xlSheet.Cells(1, 8) + xlSheet.Cells(1, 11)
For i = 2 To xlSheet.Cells(1, 8) + 1
a(i - 1) = xlSheet.Cells(i, 1) '.................... ..................
b(i - 1) = xlSheet.Cells(i, 2)
Next
For i = 2 To xlSheet.Cells(1, 9) + 1
c(i - 1) = xlSheet.Cells(i, 3) '..................... .................
d(i - 1) = xlSheet.Cells(i, 4)
Next
For i = 1 To xlSheet.Cells(1, 8) - 1
Picture1.Line (a(i) * Text1, 20000 - (b(i) - xlSheet.Cells(2, 7) / 2) * Text2 * 100)-(a(i + 1) * Text1, 20000 - (b(i + 1) - xlSheet.Cells(2, 7) / 2) * Text2 * 100)
Picture1.Line (a(i) * Text1, 20000 - b(i) * Text2 * 100)-(a(i + 1) * Text1, 20000 - b(i + 1) * Text2 * 100)
Picture1.Line (a(i) * Text1, 20000 - (b(i) + xlSheet.Cells(2, 7) / 2) * Text2 * 100)-(a(i + 1) * Text1, 20000 - (b(i + 1) + xlSheet.Cells(2, 7) / 2) * Text2 * 100)
Next i
For i = 2 To xlSheet.Cells(1, 11) + 1
u1(i - 1) = xlSheet.Cells(i, 5) '................... ...................
Next
For j = 0 To xlSheet.Cells(1, 11)
For k = xlSheet.Cells(1, 8) To 2 Step -1
If u1(j) <= a(k) Then v1(j) = b(k) - (a(k) - u1(j)) * (b(k) - b(k - 1)) / (a(k) - a(k - 1))
Next
Next j
For l = 1 To xlSheet.Cells(1, 11)
Picture1.Circle ((u1(l) * Text1), (20000 - v1(l) * Text2 * 100)), 50 * Text2
Next l
For i = 1 To xlSheet.Cells(1, 8)
a1(i) = a(i)
b1(i) = b(i)
Next i
For j = 1 To xlSheet.Cells(1, 11)
a1(j + xlSheet.Cells(1, 8)) = u1(j)
b1(j + xlSheet.Cells(1, 8)) = v1(j)
Next j
For i = w To 2 Step -1 '排序
For j = 1 To i - 1
If (a1(j) > a1(j + 1)) Then
t = a1(j): s = b1(j)
a1(j) = a1(j + 1): b1(j) = b1(j + 1)
a1(j + 1) = t: b1(j + 1) = s
End If
Next j
Next i
For i = 2 To xlSheet.Cells(1, 12) + 1
g(i - 1) = xlSheet.Cells(i, 6) '.................. ....................
Next
For j = 1 To xlSheet.Cells(1, 12)
For k = xlSheet.Cells(1, 8) To 2 Step -1
If g(j) < a(k) Then h(j) = b(k) - (a(k) - g(j)) * (b(k) - b(k - 1)) / (a(k) - a(k - 1))
Next
Next j
For l = 1 To xlSheet.Cells(1, 12)
Picture1.Circle ((g(l) * Text1), (20000 - (h(l) - (xlSheet.Cells(2, 7) / 2 + xlSheet.Cells(2, 10) / 2)) * Text2 * 100)), (xlSheet.Cells(2, 10)) * 50 * Text2
Next l
For i = 1 To xlSheet.Cells(1, 9) - 1
Picture1.Line (c(i) * Text1, 20000 - d(i) * Text2 * 100)-(c(i + 1) * Text1, 20000 - d(i + 1) * Text2 * 100)
Next i
End Sub
Private Sub Form_Load()
Picture1.Move 0, 0
HScroll1.ZOrder 0
VScroll1.ZOrder 0
End Sub
Private Sub HScroll1_Change()
Picture1.Left = -(HScroll1.Value / HScroll1.Max) * Picture1.Width
End Sub
Private Sub HScroll1_Scroll()
Picture1.Left = -(HScroll1.Value / HScroll1.Max) * Picture1.Width
End Sub
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
e(0) = Text3 / Text1
f(0) = Text4 / Text2
u(0) = Text3 / Text1
v(0) = Text4 / Text2
Call zz
End Sub
Private Sub VScroll1_Change()
Picture1.Top = -(VScroll1.Value / VScroll1.Max) * Picture1.Height
End Sub
Private Sub VScroll1_Scroll()
Picture1.Top = -(VScroll1.Value / VScroll1.Max) * Picture1.Height
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Cls
Text3 = X
Text4 = (20000 - Y) / 100
End Sub
Sub zz()
w = xlSheet.Cells(1, 8) + xlSheet.Cells(1, 11)
j = 1
For i = w To 1 Step -1 '賦值到数组
If a1(i) <= e(0) Then e(j) = a1(i): f(j) = b1(i): j = j + 1 '把A(i)小于指定点的数组内容赋到E(J)
Next i
k = 1
For i = 1 To w '赋值到数组
If a1(i) > u(0) Then u(k) = a1(i): v(k) = b1(i): k = k + 1 '把A(i)大于指定点的数组内容赋到U(K),如果
Next i
Picture1.ForeColor = RGB(255, 0, 0) '红色
X = 0
For i = 0 To j - 2 '操作E数组
If f(i + 1) < f(i) Then f(i + 1) = f(i)
If f(i + 1) >= f(i) And f(i + 2) >= f(i + 1) Then f(i + 1) = f(i)
If f(i + 1) >= f(i) And f(i + 2) >= f(i + 1) And f(i + 3) >= f(i + 2) Then f(i + 1) = f(i)
Picture1.Line (e(i + 1) * Text1, 20000 - (f(i + 1) - xlSheet.Cells(2, 7) / 2) * Text2 * 100)-(e(i) * Text1, 20000 - (f(i) - xlSheet.Cells(2, 7) / 2) * Text2 * 100)
Next i
For i = 0 To k - 2 '操作U数组
If v(i + 1) < v(i) Then v(i + 1) = v(i)
If v(i + 1) >= v(i) And v(i + 2) >= v(i + 1) Then v(i + 1) = v(i)
If v(i + 1) >= v(i) And v(i + 2) >= v(i + 1) And v(i + 3) >= v(i + 2) Then v(i + 1) = v(i)
Picture1.Line (u(i + 1) * Text1, 20000 - (v(i + 1) - xlSheet.Cells(2, 7) / 2) * Text2 * 100)-(u(i) * Text1, 20000 - (v(i) - xlSheet.Cells(2, 7) / 2) * Text2 * 100)
Next i
For i = j + k - 1 To j + 1 Step -1
k1 = a1(i - 1)
q1 = b1(i - 1)
a1(i) = k1
b1(i) = q1
Next i
a1(j) = e(0)
If a1(j + 1) = a1(j - 1) Then b1(j) = b1(j - 1)
If a1(j + 1) <> a1(j - 1) Then b1(j) = b1(j - 1) + (a1(j) - a1(j - 1)) * (b1(j + 1) - b1(j - 1)) / (a1(j + 1) - a1(j - 1))
i = 1
a2(j) = e(0)
b2(j) = f(0)
For m = j - 1 To 1 Step -1
a2(i) = e(m)
b2(i) = f(m)
i = i + 1
Next m
i = i + 1
For n = 1 To k
a2(i) = u(n)
b2(i) = v(n)
i = i + 1
Next n
For i = 1 To j + k - 1
Picture1.Print a1(i); b1(i); a2(i); b2(i)
Next i
Y1 = 0
Y2 = 0
For i = 2 To j + k - 1
If b1(i - 1) >= b2(i - 1) And b1(i) >= b2(i) Then Y1 = Int((b1(i - 1) - b2(i - 1) + (b1(i) - b2(i))) * (a2(i) - a2(i - 1)) / 2) + Y1
If b1(i - 1) < b2(i - 1) And b1(i) < b2(i) Then Y1 = Y1
If b1(i - 1) > b2(i - 1) And b1(i) < b2(i) Then Y1 = Int((a2(i) - a2(i - 1)) * (b1(i - 1) - b2(i - 1)) / (b1(i - 1) - b2(i - 1) + b2(i) - b1(i))) + Y1
If b1(i - 1) < b2(i - 1) And b1(i) > b2(i) Then Y1 = Int((a2(i) - a2(i - 1)) * (b1(i) - b2(i)) / (b2(i - 1) - b1(i - 1) - b2(i) + b1(i))) + Y1
For i1 = 1 To xlSheet.Cells(1, 11)
If a1(i) = u1(i1) Then u2(X1) = Y1: X1 = X1 + 1
Next i1
Next i
Picture1.Print ""
For i = 2 To j + k - 1
If b1(i - 1) + xlSheet.Cells(2, 7) / 2 * 2 >= b2(i - 1) And b1(i) + 2 * xlSheet.Cells(2, 7) / 2 >= b2(i) Then Y2 = Int((b1(i - 1) + 2 * xlSheet.Cells(2, 7) / 2 - b2(i - 1) + b1(i) + 2 * xlSheet.Cells(2, 7) / 2 - b2(i)) * (a2(i) - a2(i - 1)) / 2) + Y2 If b1(i - 1) + xlSheet.Cells(2, 7) / 2 * 2 < b2(i - 1) And b1(i) + 2 * xlSheet.Cells(2, 7) / 2 < b2(i) Then Y2 = Y2
If b1(i - 1) + xlSheet.Cells(2, 7) / 2 * 2 > b2(i - 1) And b1(i) + 2 * xlSheet.Cells(2, 7) / 2 < b2(i) Then Y2 = Int((a2(i) - a2(i - 1)) * (b1(i - 1) + 2 * xlSheet.Cells(2, 7) / 2 - b2(i - 1)) / (b1(i - 1) - b2(i - 1) + b2(i) - b1(i))) + Y2
If b1(i - 1) + xlSheet.Cells(2, 7) / 2 * 2 < b2(i - 1) And b1(i) + 2 * xlSheet.Cells(2, 7) / 2 > b2(i) Then Y2 = Int((a2(i) - a2(i - 1)) * (b1(i) + 2 * xlSheet.Cells(2, 7) / 2 - b2(i)) / (b1(i) - b2(i) + b2(i - 1) - b1(i - 1))) + Y2
For i1 = 1 To xlSheet.Cells(1, 11)
If a1(i) = u1(i1) Then v2(X2) = Y2: X2 = X2 + 1
Next i1
Next i
For i = 1 To xlSheet.Cells(1, 11)
Picture1.Print (v2(i) - u2(i)) - (v2(i - 1) - u2(i - 1))
Next i
Picture1.Print Y2 - Y1
End Sub
程序編制完成后可进行编译生成可执行文件保存。该可执行文可以运行演示,程序中TEXT1-TEXT2可以输入相应比例。点击COMMANDBUTTON后便可进行相应的程序计算。
本程序调试通过,程序运行结果见图2、3。
4 结语
排水计算软件经过我公司一年多的试用完善,已基本满足工作需要。该程序有如下优点:
(1)工作效率极大提高。很方便快捷得到所需要的排水数据。
(2)提高了准确性。较手工计算,准确性提高,避免了不必要的误差。
(3)程序的通用性强。只需要修改表格便可以得到对应的相应计算结果。
参考文献
[1] 张晋西.Visual Basic与AutoCAD二次开发[M].北京:清华大学出版社,2000.
[2] 龚沛曾,陆慰民,杨志强.Visual Basic程序设计简明教程[M].北京:高等教育出版社,2003.
[3] 程建华.小区排水总图计算机辅助设计计算的方法及程序[J]给水排水,1997,23(5):39-44.
[4] 李兆崔,刘福臣.VB编程在钢管弯头制作中的应用[J]华东公路,2013,203(6):90-93.