#include <EditConstants.au3>
#include <array.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
Local $Num,$hGUI, $hGraphic, $hPen, $hEndCap
Dim $OpticalStationName="光节点名"
Dim $Juli[10],$Less[10],$Lessmain[10],$Lesssub[10],$SubJuli[10],$SubLess[10]
Dim $m,$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]
$hGUI=GUICreate("简易EPON树形链路设计器——清原县广电局(2012-3)",1250,520)
GUISetState()
; 创建资源
_GDIPlus_Startup()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
$hPen = _GDIPlus_PenCreate(0xFF000000, 2)
$hEndCap = _GDIPlus_ArrowCapCreate(3, 6)
_GDIPlus_PenSetCustomEndCap($hPen, $hEndCap)
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);将上面标签加青北景色
; 描绘箭头
_GDIPlus_GraphicsDrawLine($hGraphic, $n*110-56, 95, $n*110+13,95, $hPen) ;水平
_GDIPlus_PenSetWidth($hPen, 2)
_GDIPlus_GraphicsDrawLine($hGraphic, $n*110+28, 91, $n*110+28, 196, $hPen) ;竖直
_GDIPlus_PenSetWidth($hPen, 2)
;创建输入框
$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);主路分光比
Sleep(100)
Next
;创建起点
GUICtrlCreateLabel("起点名称",15,71,60,20)
GUICtrlCreateInput("",5,87,60,20)
;说明标签
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)
GUISetState()
GUIRegisterMsg($WM_COMMAND,"MY_WM_COMMAND")
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
Func MY_WM_COMMAND($hWnd, $msg, $wParam, $ilParam);主函数
Local $subnumber
$Num=0
Do
if GUICtrlRead($Length[$Num]) <> "" then
$subnumber = GUICtrlRead($D_Sub[$Num])
If $subnumber <> "支" Then
GUICtrlSetData($D_Main[$Num],100-$subnumber)
GUICtrlSetData($Lesssub[$Num], MY_SubLess($subnumber));支路衰减计算
GUICtrlSetData($Lessmain[$Num], MY_MainLess(100-$subnumber));主路衰减计算
EndIf
GUICtrlSetData($Less[$Num], GUICtrlRead($Length[$Num])*0.35+0.1)
GUICtrlSetData($Juli[$Num],GUICtrlRead($Length[$Num]))
;计算支路数据
if GUICtrlRead($SubLength[$Num]) <> "" then
GUICtrlSetData($SubLess[$Num], GUICtrlRead($SubLength[$Num])*0.35+0.1+GUICtrlRead($Less[$Num])+GUICtrlRead($Lesssub[$Num]))
GUICtrlSetData($SubJuli[$Num],GUICtrlRead($Juli[$Num])+GUICtrlRead($SubLength[$Num]))
EndIf
EndIf
$Num=$Num+1
Until $Num=10
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
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
; 清理资源
_GDIPlus_ArrowCapDispose($hEndCap)
_GDIPlus_PenDispose($hPen)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()
正好今天放假,就帮你简单调试一下。你自己试试看。完整源代码如上,用GDI画出箭头,再用控件覆盖上去。