|
本帖最后由 fsyuecw 于 2012-7-24 20:16 编辑
因工作关系,写了一个光路计算工具,还算好用,但运行中很慢,输入头同几参数还行,后边越来越慢。另外,需要在窗体上画箭头,没想出来办法,画了两个图片调用,但一动窗体,这个箭头就把输入框给覆盖了。请哪们大虾指点一下,不胜感谢。
#include <EditConstants.au3>
#include <array.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Dim $OpticalStationName="光节点名"
Dim $Juli[10],$Less[10],$Lessmain[10],$Lesssub[10],$SubJuli[10],$SubLess[10]
Dim $m,$n,$Length[10],$SubLength[10]
Dim $h=29,$v=175
Dim $d5=15.2,$d95=0.45,$d10=11.3,$d90=0.6,$d20=7.9,$d80=1.2,$d25=8.5,$d75=1.8,$d50=3.6
Dim $D_Main[10],$D_Sub[10]
GUICreate("简易EPON树形链路设计器——清原县广电局(2012-3)",1250,520)
;创建起点
GUICtrlCreateLabel("起点名称",15,71,60,20)
GUICtrlCreateInput("",5,87,60,20)
;GUICtrlCreateLabel("PON",15,89,30,20)
;GUICtrlCreateInput($OpticalStationName,10,65)
;循环创建其它光节点
GUISetState()
For $n=1 to 10
;画主路分光数据栏
GUICtrlCreateLabel(" 分光点"&$n&@crlf&"距离"&@CRLF&"衰减"&@CRLF&"主衰"&@crlf&"支衰",$n*110-2,20,75,64);分光点标签
GUICtrlSetBkColor(-1,0x00aa00);将上面标签加绿背景色
$Juli[$n-1]=GUICtrlCreateLabel("",$n*110+$h,32,43,15);显示距离的标签
;GUICtrlSetState(-1, $gui_DISABLE)
GUICtrlSetBkColor(-1,0x88aa00);将上面标签加黄背景色
$Less[$n-1]=GUICtrlCreateLabel("",$n*110+$h,44,43,15);显示上级光缆衰减值
;GUICtrlSetState(-1, $gui_DISABLE)
GUICtrlSetBkColor(-1,0x00aaaa);将上面标签加青北景色
$Lessmain[$n-1]=GUICtrlCreateLabel("",$n*110+$h,56,43,15);显示主路衰减值
;GUICtrlSetState(-1, $gui_DISABLE)
GUICtrlSetBkColor(-1,0xaaaa00);将上面标签加黄背景色
$Lesssub[$n-1]=GUICtrlCreateLabel("",$n*110+$h,68,43,15);显示支路衰减值
;GUICtrlSetState(-1, $gui_DISABLE)
GUICtrlSetBkColor(-1,0x00ffaa);将上面标签加蓝背景色
;GUICtrlCreateInput("分光点",$n*110-2,16,75,17);分光点名称输入框
;画分路分光数据栏
GUICtrlCreateLabel(" 支光节点"&$n&@crlf&"距离"&@CRLF&"衰减",$n*110-10,$v+20,75,40);分光点标签
GUICtrlSetBkColor(-1,0x00aa00);将上面标签加绿背景色
$SubJuli[$n-1]=GUICtrlCreateLabel("",$n*110+22,$v+32,43,15);显示距离的标签
;GUICtrlSetState(-1, $gui_DISABLE)
GUICtrlSetBkColor(-1,0x88aa00);将上面标签加黄背景色
$SubLess[$n-1]=GUICtrlCreateLabel("",$n*110+22,$v+44,43,15);显示上级光路衰减值
;GUICtrlSetState(-1, $gui_DISABLE)
GUICtrlSetBkColor(-1,0x00aaaa);将上面标签加青北景色
;说明标签
GUICtrlCreateLabel("说明:"&@CRLF&"1、分光点数据定义:距离=分光器到前端的距离(千米)。衰减=分光器入口到前端的光路损耗(dB)。主衰=分光器主路衰减量(dB)。支衰=分光器支路衰减量(dB)。"&@CRLF&"2、支路光节点:距离=ONU到前端的距离(千米)。衰减=ONU距前端的光路衰减量(dB)"&@CRLF&"3、光分路器只需输入支路分光比即可,本软件只支持5:95、10:90、20:80、25:75、50:50五种分光器。"&@CRLF&"4、光路衰减按1310nm每千米0.35dB计算,每点增加0.1的法兰衰减量"&@CRLF&"5、分光比参照华为设计原则确定,不同厂家不同工艺分光比会有差异。"&@CRLF&" 本软件采用的是:5:95(15.2:0.45)、10:90(11.3:0.6)、20:80(7.9:1.2)、25:75(8.5:1.8)、50:50(3.6:3.6),括号内为对应的衰减量,单位是dB."&@CRLF&"6、本软件只支持单支岔结构。"&@CRLF&"7、本软件计算结果仅做参考。"&@CRLF&"8、设计参考:20千米模块建议光链路衰减应大于6dB小于27dB。",120,300,1200,120)
;创建输入框
$Length[$n-1]=GUICtrlCreateInput("",$n*110-38,89,37,15);两点间距离输入框(主路)
$SubLength[$n-1]=GUICtrlCreateInput("",$n*110+6,130,37,15);两点间距离输入框(支路)
$D_Sub[$n-1]=GUICtrlCreateInput("支",$n*110+14,89,20,15);支路分光比
$D_Main[$n-1]=GUICtrlCreateInput("主",$n*110+33,89,20,15);主路分光比
$picjiantouh=GUICtrlCreatePic("jiantouh.jpg",$n*110-56,91,75,10);画水平箭头
$picjiantouv=GUICtrlCreatePic("jiantouv.jpg",$n*110+18,91,10,105);画垂直箭头
;$con=GUICtrlCreateLabel("",500,300,50,15)
;If $Length[$n-1]<>0 Then
Next
GUISetState()
GUIRegisterMsg($WM_COMMAND,"MY_WM_COMMAND")
While 1
$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func MY_WM_COMMAND($hWnd, $msg, $wParam, $ilParam);主函数
Dim $i=0,$j=0
Local $subnumber
Do
if GUICtrlRead($Length[0]) <> "" then
$subnumber = GUICtrlRead($D_Sub[0])
If $subnumber <> "支" Then
GUICtrlSetData($D_Main[0],100-$subnumber)
GUICtrlSetData($Lesssub[0], MY_SubLess($subnumber));支路衰减计算
GUICtrlSetData($Lessmain[0], MY_MainLess(100-$subnumber));主路衰减计算
EndIf
GUICtrlSetData($Less[0], GUICtrlRead($Length[0])*0.35+0.1)
GUICtrlSetData($Juli[0],GUICtrlRead($Length[0]))
;计算支路数据
if GUICtrlRead($SubLength[0]) <> "" then
GUICtrlSetData($SubLess[0], GUICtrlRead($SubLength[0])*0.35+0.1+GUICtrlRead($Less[0])+GUICtrlRead($Lesssub[0]))
GUICtrlSetData($SubJuli[0],GUICtrlRead($Juli[0])+GUICtrlRead($SubLength[0]))
EndIf
EndIf
if GUICtrlRead($Length[1]) <> "" then
$subnumber = GUICtrlRead($D_Sub[1])
If $subnumber <> "支" Then
GUICtrlSetData($D_Main[1],100-$subnumber)
GUICtrlSetData($Lesssub[1], MY_SubLess($subnumber));支路衰减计算
GUICtrlSetData($Lessmain[1], MY_MainLess(100-$subnumber));主路衰减计算
EndIf
GUICtrlSetData($Less[1], GUICtrlRead($Length[1])*0.35+0.1+GUICtrlRead($Less[0])+GUICtrlRead($Lessmain[0]))
GUICtrlSetData($Juli[1],GUICtrlRead($Juli[0])+GUICtrlRead($Length[1]))
;计算支路数据
if GUICtrlRead($SubLength[1]) <> "" then
GUICtrlSetData($SubLess[1], GUICtrlRead($SubLength[1])*0.35+0.1+GUICtrlRead($Less[1])+GUICtrlRead($Lesssub[1]))
GUICtrlSetData($SubJuli[1],GUICtrlRead($Juli[1])+GUICtrlRead($SubLength[1]))
EndIf
EndIf
if GUICtrlRead($Length[2]) <> "" then
$subnumber = GUICtrlRead($D_Sub[2])
If $subnumber <> "支" Then
GUICtrlSetData($D_Main[2],100-$subnumber)
GUICtrlSetData($Lesssub[2], MY_SubLess($subnumber));支路衰减计算
GUICtrlSetData($Lessmain[2], MY_MainLess(100-$subnumber));主路衰减计算
EndIf
GUICtrlSetData($Less[2], GUICtrlRead($Length[2])*0.35+0.1+GUICtrlRead($Less[1])+GUICtrlRead($Lessmain[1]))
GUICtrlSetData($Juli[2],GUICtrlRead($Juli[1])+GUICtrlRead($Length[2]))
;计算支路数据
if GUICtrlRead($SubLength[2]) <> "" then
GUICtrlSetData($SubLess[2], GUICtrlRead($SubLength[2])*0.35+0.1+GUICtrlRead($Less[2])+GUICtrlRead($Lesssub[2]))
GUICtrlSetData($SubJuli[2],GUICtrlRead($Juli[2])+GUICtrlRead($SubLength[2]))
EndIf
EndIf
if GUICtrlRead($Length[3]) <> "" then
$subnumber = GUICtrlRead($D_Sub[3])
If $subnumber <> "支" Then
GUICtrlSetData($D_Main[3],100-$subnumber)
GUICtrlSetData($Lesssub[3], MY_SubLess($subnumber));支路衰减计算
GUICtrlSetData($Lessmain[3], MY_MainLess(100-$subnumber));主路衰减计算
EndIf
GUICtrlSetData($Less[3], GUICtrlRead($Length[3])*0.35+0.1+GUICtrlRead($Less[2])+GUICtrlRead($Lessmain[2]))
GUICtrlSetData($Juli[3],GUICtrlRead($Juli[2])+GUICtrlRead($Length[3]))
;计算支路数据
if GUICtrlRead($SubLength[3]) <> "" then
GUICtrlSetData($SubLess[3], GUICtrlRead($SubLength[3])*0.35+0.1+GUICtrlRead($Less[3])+GUICtrlRead($Lesssub[3]))
GUICtrlSetData($SubJuli[3],GUICtrlRead($Juli[3])+GUICtrlRead($SubLength[3]))
EndIf
EndIf
if GUICtrlRead($Length[4]) <> "" then
$subnumber = GUICtrlRead($D_Sub[4])
If $subnumber <> "支" Then
GUICtrlSetData($D_Main[4],100-$subnumber)
GUICtrlSetData($Lesssub[4], MY_SubLess($subnumber));支路衰减计算
GUICtrlSetData($Lessmain[4], MY_MainLess(100-$subnumber));主路衰减计算
EndIf
GUICtrlSetData($Less[4], GUICtrlRead($Length[4])*0.35+0.1+GUICtrlRead($Less[3])+GUICtrlRead($Lessmain[3]))
GUICtrlSetData($Juli[4],GUICtrlRead($Juli[3])+GUICtrlRead($Length[4]))
;计算支路数据
if GUICtrlRead($SubLength[4]) <> "" then
GUICtrlSetData($SubLess[4], GUICtrlRead($SubLength[4])*0.35+0.1+GUICtrlRead($Less[4])+GUICtrlRead($Lesssub[4]))
GUICtrlSetData($SubJuli[4],GUICtrlRead($Juli[4])+GUICtrlRead($SubLength[4]))
EndIf
EndIf
if GUICtrlRead($Length[5]) <> "" then
$subnumber = GUICtrlRead($D_Sub[5])
If $subnumber <> "支" Then
GUICtrlSetData($D_Main[5],100-$subnumber)
GUICtrlSetData($Lesssub[5], MY_SubLess($subnumber));支路衰减计算
GUICtrlSetData($Lessmain[5], MY_MainLess(100-$subnumber));主路衰减计算
EndIf
GUICtrlSetData($Less[5], GUICtrlRead($Length[5])*0.35+0.1+GUICtrlRead($Less[4])+GUICtrlRead($Lessmain[4]))
GUICtrlSetData($Juli[5],GUICtrlRead($Juli[4])+GUICtrlRead($Length[5]))
;计算支路数据
if GUICtrlRead($SubLength[5]) <> "" then
GUICtrlSetData($SubLess[5], GUICtrlRead($SubLength[5])*0.35+0.1+GUICtrlRead($Less[5])+GUICtrlRead($Lesssub[5]))
GUICtrlSetData($SubJuli[5],GUICtrlRead($Juli[5])+GUICtrlRead($SubLength[5]))
EndIf
EndIf
if GUICtrlRead($Length[6]) <> "" then
$subnumber = GUICtrlRead($D_Sub[6])
If $subnumber <> "支" Then
GUICtrlSetData($D_Main[6],100-$subnumber)
GUICtrlSetData($Lesssub[6], MY_SubLess($subnumber));支路衰减计算
GUICtrlSetData($Lessmain[6], MY_MainLess(100-$subnumber));主路衰减计算
EndIf
GUICtrlSetData($Less[6], GUICtrlRead($Length[6])*0.35+0.1+GUICtrlRead($Less[5])+GUICtrlRead($Lessmain[5]))
GUICtrlSetData($Juli[6],GUICtrlRead($Juli[5])+GUICtrlRead($Length[6]))
;计算支路数据
if GUICtrlRead($SubLength[6]) <> "" then
GUICtrlSetData($SubLess[6], GUICtrlRead($SubLength[6])*0.35+0.1+GUICtrlRead($Less[6])+GUICtrlRead($Lesssub[6]))
GUICtrlSetData($SubJuli[6],GUICtrlRead($Juli[6])+GUICtrlRead($SubLength[6]))
EndIf
EndIf
if GUICtrlRead($Length[7]) <> "" then
$subnumber = GUICtrlRead($D_Sub[7])
If $subnumber <> "支" Then
GUICtrlSetData($D_Main[7],100-$subnumber)
GUICtrlSetData($Lesssub[7], MY_SubLess($subnumber));支路衰减计算
GUICtrlSetData($Lessmain[7], MY_MainLess(100-$subnumber));主路衰减计算
EndIf
GUICtrlSetData($Less[7], GUICtrlRead($Length[7])*0.35+0.1+GUICtrlRead($Less[6])+GUICtrlRead($Lessmain[6]))
GUICtrlSetData($Juli[7],GUICtrlRead($Juli[6])+GUICtrlRead($Length[7]))
;计算支路数据
if GUICtrlRead($SubLength[7]) <> "" then
GUICtrlSetData($SubLess[7], GUICtrlRead($SubLength[7])*0.35+0.1+GUICtrlRead($Less[7])+GUICtrlRead($Lesssub[7]))
GUICtrlSetData($SubJuli[7],GUICtrlRead($Juli[7])+GUICtrlRead($SubLength[7]))
EndIf
EndIf
if GUICtrlRead($Length[8]) <> "" then
$subnumber = GUICtrlRead($D_Sub[8])
If $subnumber <> "支" Then
GUICtrlSetData($D_Main[8],100-$subnumber)
GUICtrlSetData($Lesssub[8], MY_SubLess($subnumber));支路衰减计算
GUICtrlSetData($Lessmain[8], MY_MainLess(100-$subnumber));主路衰减计算
EndIf
GUICtrlSetData($Less[8], GUICtrlRead($Length[8])*0.35+0.1+GUICtrlRead($Less[7])+GUICtrlRead($Lessmain[7]))
GUICtrlSetData($Juli[8],GUICtrlRead($Juli[7])+GUICtrlRead($Length[8]))
;计算支路数据
if GUICtrlRead($SubLength[8]) <> "" then
GUICtrlSetData($SubLess[8], GUICtrlRead($SubLength[8])*0.35+0.1+GUICtrlRead($Less[8])+GUICtrlRead($Lesssub[8]))
GUICtrlSetData($SubJuli[8],GUICtrlRead($Juli[8])+GUICtrlRead($SubLength[8]))
EndIf
EndIf
if GUICtrlRead($Length[9]) <> "" then
$subnumber = GUICtrlRead($D_Sub[9])
If $subnumber <> "支" Then
GUICtrlSetData($D_Main[9],100-$subnumber)
GUICtrlSetData($Lesssub[9], MY_SubLess($subnumber));支路衰减计算
GUICtrlSetData($Lessmain[9], MY_MainLess(100-$subnumber));主路衰减计算
EndIf
GUICtrlSetData($Less[9], GUICtrlRead($Length[9])*0.35+0.1+GUICtrlRead($Less[8])+GUICtrlRead($Lessmain[8]))
GUICtrlSetData($Juli[9],GUICtrlRead($Juli[8])+GUICtrlRead($Length[9]))
;计算支路数据
if GUICtrlRead($SubLength[9]) <> "" then
GUICtrlSetData($SubLess[9], GUICtrlRead($SubLength[9])*0.35+0.1+GUICtrlRead($Less[9])+GUICtrlRead($Lesssub[9]))
GUICtrlSetData($SubJuli[9],GUICtrlRead($Juli[9])+GUICtrlRead($SubLength[9]))
EndIf
EndIf
$i=$i+1
Until $i =100
;Return $GUI_RUNDEFMSG
EndFunc ;==>MY_WM_COMMAND
Func MY_SubLess ($sub)
Select
Case $sub=5
$sub=$d5
Return $sub
Case $sub=10
$sub=$d10
Return $sub
Case $sub=20
$sub=$d20
Return $sub
Case $sub=25
$sub=$d25
Return $sub
Case $sub=50
$sub=$d50
Return $sub
;MsgBox(2,"输入错误","本软件只支持5:95 10:90 20:80 25:75 %0:50分路器")
EndSelect
EndFunc
Func MY_MainLess($sub)
Select
Case $sub=95
$sub=$d95
Return $sub
Case $sub=90
$sub=$d90
Return $sub
Case $sub=80
$sub=$d80
Return $sub
Case $sub=75
$sub=$d75
Return $sub
Case $sub=50
$sub=$d50
Return $sub
;MsgBox(2,"输入错误","本软件只支持5:95 10:90 20:80 25:75 %0:50分路器")
EndSelect
EndFunc
;GUIRegisterMsg($WM_COMMAND,"MY_WM_COMMAND1") |
|