📄 pubfunc.bas
字号:
Loop
GoTo NextFrame
Else '如果打开网关失败
rcGateMap.Edit
rcGateMap!Status = 2 '标记网段状态为故障
If isForward Then
rcGateMap!StartGateStatus = 2 '标记前向网关状态为故障
Else
rcGateMap!EndGateStatus = 2 '标记后向网关状态为故障
End If
rcGateMap!Date = Date
rcGateMap.Update
lbl2 = "失败"
lst.AddItem lbl1 + " " + lbl2
rcGateMap.Edit
rcGateMap!Status = 1
rcGateMap!Date = Date
rcGateMap.Update
CloseGate (curGate)
If isForward Then
isForward = False
rcGate.MoveLast
GoTo beginFrame
Else
Exit Do
End If
End If
NextFrame:
If isForward Then
rcGateMap.MoveNext
Else
rcGate.MovePrevious
End If
DoEvents
Loop
lbl1 = "全程巡检完毕"
lbl2 = ""
'lst.AddItem lbl1 + " " + lbl2
End Sub
Sub CheckBuild(chkBuild)
Dim rcBuild As Recordset
Dim rcGate As Recordset
Dim curFrame As Integer
Dim curGate As Integer
Dim curBuild As String
Dim curBuildAddr As Integer
Dim curBuildEnder As Integer
Dim chkBuildAddr As Integer
Dim chkBuildEnder As Integer
Dim chkFrame As Integer
Dim isForward As Boolean
Dim temVal As Boolean
Set rcBuild = dbCbb.OpenRecordset("BuildMap", dbOpenDynaset)
rcBuild.FindFirst "trim(BuildID)=""" + chkBuild + """"
If rcBuild.NoMatch Then
MsgBox "没有找到指定楼"
Exit Sub
End If
chkBuildAddr = rcBuild!Address
chkBuildEnder = rcBuild!Ender
chkFrame = rcBuild!FrameID
SQL = "select * from GateMap order by FrameID ASC "
Set rcGate = dbCbb.OpenRecordset(SQL)
isForward = True
Do While True
beginFrame:
If isForward Then
If rcGate.EOF Then
Exit Do
End If
Else
If rcGate.BOF Then
Exit Do
End If
End If
curFrame = rcGate!FrameID
If isForward Then
curGate = rcGate!StartGate
If curGate = 0 Then
rcGate.Edit
rcGate!Status = 0
rcGate!StartGateStatus = 0
rcGate!EndGateStatus = 0
rcGate!Date = Date
rcGate.Update
If curFrame = chkFrame Then
Exit Do
Else
GoTo Gate_GoOn
End If
End If
lbl1 = "打开网段" + Format(curFrame) + "前向网关" + Format(curGate)
lbl2 = ""
Else
curGate = rcGate!endGate
If curGate = 0 Then
rcGate.Edit
rcGate!Status = 0
rcGate!StartGateStatus = 0
rcGate!EndGateStatus = 0
rcGate!Date = Date
rcGate.Update
GoTo Gate_GoOn
End If
lbl1 = "打开网段" + Format(curFrame) + "前向网关" + Format(curGate)
lbl2 = ""
End If
temVal = openGate(curGate)
If temVal Then '网关正常
lbl2 = "正常"
lst.AddItem lbl1 + " " + lbl2
rcGate.Edit
rcGate!Date = Date
rcGate!Status = 1
If isForward Then
rcGate!StartGateStatus = 1
Else
rcGate!EndGateStatus = 1
End If
rcGate.Update
If curFrame = chkFrame Then '如果到达待检网段,且正常,停止打开网关,开始安全器检查
Exit Do
End If
Else '网关打开失败
lbl2 = "故障"
lst.AddItem lbl1 + " " + lbl2
CloseGate (curGate)
rcGate.Edit
rcGate!Date = Date
rcGate!Status = 2
If isForward Then
rcGate!StartGateStatus = 2
Else
rcGate!EndGateStatus = 2
End If
rcGate.Update
If curFrame = chkFrame Then
If isForward Then '如果是前向打开失败,从反向开始打开
isForward = False
rcGate.MoveLast
GoTo beginFrame
Else '如果后向打开失败,且到达待检网段,说明该网段前后网关均故障,该网段故障
lst.AddItem "待测楼所在网段故障,该楼不能检测."
Exit Sub
End If
Else
If isForward Then
isForward = False
rcGate.MoveLast
GoTo beginFrame
Else '如果后向打开失败,且不是待检网段,说明待检网段处于故障区内
lst.AddItem "待测楼所在网段处于故障区间内,无法检测"
Exit Sub
End If
End If
End If
Gate_GoOn:
If isForward Then
rcGate.MoveNext
Else
rcGate.MovePrevious
End If
Loop
If chkBuildAddr = 0 Then
rcBuild.Edit
rcBuild!Status = 0
rcBuild!Date = Date
rcBuild.Update
lbl1 = "打开待测楼" + chkBuild + "安全器已被取消"
lbl2 = ""
'lst.AddItem lbl1 + " " + lbl2
GoTo Build_GoOn
End If
lbl1 = "打开待测楼" + chkBuild + "安全器" + Format(chkBuildAddr)
lbl2 = ""
temVal = openBuild(chkBuildAddr)
If temVal Then
rcBuild.Edit
rcBuild!Date = Date
rcBuild!Status = 1
rcBuild.Update
lbl2 = "正常"
lst.AddItem lbl1 + " " + lbl2
Build_GoOn:
If chkBuildEnder = 0 Then
lbl1 = "打开待测楼" + chkBuild + " 总线终端器已被取消"
lbl2 = ""
'lst.AddItem lbl1 + " " + lbl2
GoTo endCheck
End If
lbl1 = "打开待测楼" + chkBuild + " 总线终端" + Format(chkBuildEnder)
lbl2 = ""
temVal = OpenBuildEnder(chkBuildEnder)
If temVal Then
rcBuild.Edit
rcBuild!Date = Date
rcBuild!Status = 1
rcBuild.Update
lbl2 = "正常"
lst.AddItem lbl1 + " " + lbl2
Else
rcBuild.Edit
rcBuild!Status = 3
rcBuild!Date = Date
rcBuild.Update
lbl2 = "故障"
lst.AddItem lbl1 + " " + lbl2
End If
Else
rcBuild.Edit
rcBuild!Status = 2
rcBuild!Date = Date
rcBuild.Update
lbl2 = "故障"
lst.AddItem lbl1 + " " + lbl2
rcBuild.Edit
rcBuild!Date = Date
rcBuild!Status = 1
rcBuild.Update
End If
endCheck:
If chkBuildAddr <> 0 Then
lbl1 = "关闭待测楼" + chkBuild + "安全器" + Format(chkBuildAddr)
lbl2 = ""
CloseBuild (chkBuildAddr)
End If
'lst.AddItem "待测楼" + chkBuild + "检测完毕!"
End Sub
Sub CheckGate(chkFrameID)
Dim rcGateMap As Recordset
Dim curFrame As Integer
Dim curGate As Integer
Dim isForward As Boolean
SQL = "select * from GateMap order by FrameID ASC "
Set rcGateMap = dbCbb.OpenRecordset(SQL)
isForward = True
Do While True
beginFrame:
curFrame = rcGateMap!FrameID
lbl1 = ""
lbl2 = ""
If isForward Then
curGate = rcGateMap!StartGate
If curGate = 0 Then
rcGateMap.Edit
rcGateMap!Status = 0
rcGateMap!StartGateStatus = 0
rcGateMap!EndGateStatus = 0
rcGateMap!Date = Date
rcGateMap.Update
GoTo Gate_GoOn
End If
lbl1 = "打开网段" + Format(curFrame) + "前向网关" + Format(curGate)
Else
curGate = rcGateMap!endGate
If curGate = 0 Then
GoTo Gate_GoOn
End If
lbl1 = "打开网段" + Format(curFrame) + "后向网关" + Format(curGate)
End If
temVal = openGate(curGate)
If temVal Then
rcGateMap.Edit
rcGateMap!Date = Date
rcGateMap!Status = 1
If isForward Then
rcGateMap!StartGateStatus = 1
Else
rcGateMap!EndGateStatus = 1
End If
rcGateMap.Update
lbl2 = "成功"
Else
rcGateMap.Edit
rcGateMap!Date = Date
rcGateMap!Status = 2
If isForward Then
rcGateMap!StartGateStatus = 2
Else
rcGateMap!EndGateStatus = 2
End If
rcGateMap.Update
lbl2 = "故障"
CloseGate (curGate)
End If
Gate_GoOn:
If curFrame = chkFrameID Then
If curGate = 0 Then
If isForward Then
'lst.AddItem "待测网段前向网关被取消,该网段可以直接采集"
Else
'lst.AddItem "待测网段后向网关被取消,该网段可以直接采集"
End If
Exit Sub
End If
If temVal Then
lst.AddItem "待测网段" + Format(chkFrameID) + "故障"
Exit Do
Else
isForward = False
rcGateMap.MoveLast
GoTo beginFrame
End If
Else
If Not temVal Then
If isForward Then
isForward = False
rcGateMap.MoveLast
GoTo beginFrame
Else
lst.AddItem "前后相关网段故障,待测网段" + Format(chkFrameID) + "处于故障区,无法检测,不能采集"
Exit Do
End If
End If
End If
NextGate:
If isForward Then
rcGateMap.MoveNext
Else
rcGateMap.MovePrevious
End If
Loop
End Sub
Sub CloseAllGate()
Dim rcGate As Recordset
Set rcGate = dbCbb.OpenRecordset("GateMap", dbOpenSnapshot)
Do While Not rcGate.EOF
CloseGate (rcGate!StartGate)
CloseGate (rcGate!endGate)
rcGate.MoveNext
Loop
Set rcGate = Nothing
End Sub
Function CloseUserGate(UserAddr) As Boolean
'发地址码--PortC_1的PC0置高(开)
'发地址码--PortC_1的PC0置低(关)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -