📄 teamform.frm
字号:
Call start_gg
filedForm.Show
End Sub
Sub start_gg()
If lgbacktime(hnum) > 0 Then
Grid1.Row = hnum
For i = 1 To num(hnum)
Grid1.Col = i
Grid1.CellForeColor = RGB(255, 0, 0) '正在灌溉的阀门数字显示红色
opentime(data(hnum, i)) = Time '获得正在灌溉阀门的开启时刻值
'将阀门号与模块上的阀门地址编号绑定
For k = 1 To maxnum
If filedata(hnum, i) = Trim$(addrdata(k, 1)) Then
fmID(hnum, i) = Trim$(addrdata(k, 2)) '继电器模块号(站址)
fmaddr(hnum, i) = Trim$(addrdata(k, 3)) '继电器端口号
fmname(hnum, i) = Trim$(addrdata(k, 4)) '承包户名
End If
Next k
Next i
lgopentime(hnum) = Time
Grid2.Col = 3
Grid2.Row = hnum
Grid2.Text = Time
Call open_all '在模块
Call close_jdq
'filedForm.Show
End If
End Sub
'闭合继电器开关(打开指定编组指定编号的阀门)
Private Sub close_jdq()
Dim canbuff(13) As Byte
Dim canbuff2(13) As Byte
Dim information As String
dout1 = 255: dout2 = 255: dout3 = 255
dout4 = 255: dout5 = 255: dout6 = 255
dout7 = 255
For i = 1 To num(hnum)
filedForm.Shape3(data(hnum, i)).FillColor = QBColor(12) '田间正在灌溉的阀门图形均成红色
TeamForm2.Check1(data(hnum, i) - 1).ForeColor = QBColor(12)
TeamForm2.Check1(data(hnum, i) - 1).value = 1
'1号RTU动作
If Val("&H" + fmID(hnum, i)) = 1 Then
dout1 = dout1 - 2 ^ (Val("&H" + fmaddr(hnum, i)) - 1)
canbuff(0) = &H3
canbuff(1) = 1
canbuff(2) = 0
canbuff(3) = &HAA
canbuff(4) = &H3
canbuff(5) = dout1
If (CAN_Trans(mindex, canbuff(0), 50) <> 1) Then
infor(hnum, i) = "异常"
filedForm.Shape5(0).FillColor = QBColor(13)
Else
infor(hnum, i) = "正常"
filedForm.Shape5(0).FillColor = QBColor(14)
End If
canbuff2(0) = &H2
canbuff2(1) = 1
canbuff2(2) = 0
canbuff2(3) = &H55
canbuff2(4) = &H3
If (CAN_Trans(mindex, canbuff2(0), 50) <> 1) Then
infor(hnum, i) = "异常"
filedForm.Shape5(0).FillColor = QBColor(13)
Else
If (CAN_Recv(mindex, canbuff2(0), 100)) Then
information = Hex(canbuff2(0)) & " " & Hex(canbuff2(1)) & " " & Hex(canbuff2(2)) & " " & Hex(canbuff2(3)) & " " & Hex(canbuff(4)) & " " & Hex(canbuff2(5))
infor(hnum, i) = "正常"
filedForm.Shape5(0).FillColor = QBColor(14)
Else
information = ""
infor(hnum, i) = "异常"
filedForm.Shape5(0).FillColor = QBColor(13)
End If
End If
End If
'2号RTU动作
If Val("&H" + fmID(hnum, i)) = 2 Then
dout2 = dout2 - 2 ^ (Val("&H" + fmaddr(hnum, i)) - 1)
canbuff(0) = &H3
canbuff(1) = 2
canbuff(2) = 0
canbuff(3) = &HAA
canbuff(4) = &H3
canbuff(5) = dout2
If (CAN_Trans(mindex, canbuff(0), 50) <> 1) Then
infor(hnum, i) = "异常"
filedForm.Shape5(1).FillColor = QBColor(13)
Else
infor(hnum, i) = "正常"
filedForm.Shape5(1).FillColor = QBColor(14)
End If
canbuff2(0) = &H2
canbuff2(1) = 2
canbuff2(2) = 0
canbuff2(3) = &H55
canbuff2(4) = &H3
If (CAN_Trans(mindex, canbuff2(0), 50) <> 1) Then
infor(hnum, i) = "异常"
filedForm.Shape5(1).FillColor = QBColor(13)
Else
If (CAN_Recv(mindex, canbuff2(0), 100)) Then
information = Hex(canbuff2(0)) & " " & Hex(canbuff2(1)) & " " & Hex(canbuff2(2)) & " " & Hex(canbuff2(3)) & " " & Hex(canbuff(4)) & " " & Hex(canbuff2(5))
infor(hnum, i) = "正常"
filedForm.Shape5(1).FillColor = QBColor(14)
Else
information = ""
infor(hnum, i) = "异常"
filedForm.Shape5(1).FillColor = QBColor(13)
End If
End If
End If
'3号RTU动作
If Val("&H" + fmID(hnum, i)) = 3 Then
dout3 = dout3 - 2 ^ (Val("&H" + fmaddr(hnum, i)) - 1)
canbuff(0) = &H3
canbuff(1) = 3
canbuff(2) = 0
canbuff(3) = &HAA
canbuff(4) = &H3
canbuff(5) = dout3
'canbuff(6) = 0
'canbuff(7) = 0
If (CAN_Trans(mindex, canbuff(0), 50) <> 1) Then
infor(hnum, i) = "异常"
filedForm.Shape5(2).FillColor = QBColor(13)
Else
infor(hnum, i) = "正常"
filedForm.Shape5(2).FillColor = QBColor(14)
End If
canbuff2(0) = &H2
canbuff2(1) = 3
canbuff2(2) = 0
canbuff2(3) = &H55
canbuff2(4) = &H3
If (CAN_Trans(mindex, canbuff2(0), 50) <> 1) Then
infor(hnum, i) = "异常"
filedForm.Shape5(2).FillColor = QBColor(13)
Else
If (CAN_Recv(mindex, canbuff2(0), 100)) Then
information = Hex(canbuff2(0)) & " " & Hex(canbuff2(1)) & " " & Hex(canbuff2(2)) & " " & Hex(canbuff2(3)) & " " & Hex(canbuff(4)) & " " & Hex(canbuff2(5))
infor(hnum, i) = "正常"
filedForm.Shape5(2).FillColor = QBColor(14)
Else
information = ""
infor(hnum, i) = "异常"
filedForm.Shape5(2).FillColor = QBColor(13)
End If
End If
End If
'4号RTU动作
If Val("&H" + fmID(hnum, i)) = 4 Then
dout4 = dout4 - 2 ^ (Val("&H" + fmaddr(hnum, i)) - 1)
canbuff(0) = &H3
canbuff(1) = 4
canbuff(2) = 0
canbuff(3) = &HAA
canbuff(4) = &H3
canbuff(5) = dout4
If (CAN_Trans(mindex, canbuff(0), 50) <> 1) Then
infor(hnum, i) = "异常"
filedForm.Shape5(3).FillColor = QBColor(13)
Else
infor(hnum, i) = "正常"
filedForm.Shape5(3).FillColor = QBColor(14)
End If
canbuff2(0) = &H2
canbuff2(1) = 4
canbuff2(2) = 0
canbuff2(3) = &H55
canbuff2(4) = &H3
If (CAN_Trans(mindex, canbuff2(0), 50) <> 1) Then
infor(hnum, i) = "异常"
filedForm.Shape5(3).FillColor = QBColor(13)
Else
If (CAN_Recv(mindex, canbuff2(0), 100)) Then
information = Hex(canbuff2(0)) & " " & Hex(canbuff2(1)) & " " & Hex(canbuff2(2)) & " " & Hex(canbuff2(3)) & " " & Hex(canbuff(4)) & " " & Hex(canbuff2(5))
infor(hnum, i) = "正常"
filedForm.Shape5(3).FillColor = QBColor(14)
Else
information = ""
infor(hnum, i) = "异常"
filedForm.Shape5(3).FillColor = QBColor(13)
End If
End If
End If
'5号RTU动作
If Val("&H" + fmID(hnum, i)) = 5 Then
dout5 = dout5 - 2 ^ (Val("&H" + fmaddr(hnum, i)) - 1)
canbuff(0) = &H3
canbuff(1) = 5
canbuff(2) = 0
canbuff(3) = &HAA
canbuff(4) = &H3
canbuff(5) = dout5
If (CAN_Trans(mindex, canbuff(0), 50) <> 1) Then
infor(hnum, i) = "异常"
filedForm.Shape5(4).FillColor = QBColor(13)
Else
infor(hnum, i) = "正常"
filedForm.Shape5(4).FillColor = QBColor(14)
End If
canbuff2(0) = &H2
canbuff2(1) = 5
canbuff2(2) = 0
canbuff2(3) = &H55
canbuff2(4) = &H3
If (CAN_Trans(mindex, canbuff2(0), 50) <> 1) Then
infor(hnum, i) = "异常"
filedForm.Shape5(4).FillColor = QBColor(13)
Else
If (CAN_Recv(mindex, canbuff2(0), 100)) Then
information = Hex(canbuff2(0)) & " " & Hex(canbuff2(1)) & " " & Hex(canbuff2(2)) & " " & Hex(canbuff2(3)) & " " & Hex(canbuff(4)) & " " & Hex(canbuff2(5))
infor(hnum, i) = "正常"
filedForm.Shape5(4).FillColor = QBColor(14)
Else
information = ""
infor(hnum, i) = "异常"
filedForm.Shape5(4).FillColor = QBColor(13)
End If
End If
End If
'6号RTU动作
If Val("&H" + fmID(hnum, i)) = 6 Then
dout6 = dout6 - 2 ^ (Val("&H" + fmaddr(hnum, i)) - 1)
canbuff(0) = &H3
canbuff(1) = 6
canbuff(2) = 0
canbuff(3) = &HAA
canbuff(4) = &H3
canbuff(5) = dout6
If (CAN_Trans(mindex, canbuff(0), 50) <> 1) Then
infor(hnum, i) = "异常"
filedForm.Shape5(5).FillColor = QBColor(13)
Else
infor(hnum, i) = "正常"
filedForm.Shape5(5).FillColor = QBColor(14)
End If
canbuff2(0) = &H2
canbuff2(1) = 6
canbuff2(2) = 0
canbuff2(3) = &H55
canbuff2(4) = &H3
If (CAN_Trans(mindex, canbuff2(0), 50) <> 1) Then
infor(hnum, i) = "异常"
filedForm.Shape5(5).FillColor = QBColor(13)
Else
If (CAN_Recv(mindex, canbuff2(0), 100)) Then
information = Hex(canbuff2(0)) & " " & Hex(canbuff2(1)) & " " & Hex(canbuff2(2)) & " " & Hex(canbuff2(3)) & " " & Hex(canbuff(4)) & " " & Hex(canbuff2(5))
infor(hnum, i) = "正常"
filedForm.Shape5(5).FillColor = QBColor(14)
Else
information = ""
infor(hnum, i) = "异常"
filedForm.Shape5(5).FillColor = QBColor(13)
End If
End If
End If
'7号RTU动作
If Val("&H" + fmID(hnum, i)) = 7 Then
dout7 = dout7 - 2 ^ (Val("&H" + fmaddr(hnum, i)) - 1)
canbuff(0) = &H3
canbuff(1) = 7
canbuff(2) = 0
canbuff(3) = &HAA
canbuff(4) = &H3
canbuff(5) = dout7
If (CAN_Trans(mindex, canbuff(0), 50) <> 1) Then
infor(hnum, i) = "异常"
filedForm.Shape5(6).FillColor = QBColor(13)
Else
infor(hnum, i) = "正常"
filedForm.Shape5(6).FillColor = QBColor(14)
End If
canbuff2(0) = &H2
canbuff2(1) = 7
canbuff2(2) = 0
canbuff2(3) = &H55
canbuff2(4) = &H3
If (CAN_Trans(mindex, canbuff2(0), 50) <> 1) Then
infor(hnum, i) = "异常"
filedForm.Shape5(6).FillColor = QBColor(13)
Else
If (CAN_Recv(mindex, canbuff2(0), 100)) Then
information = Hex(canbuff2(0)) & " " & Hex(canbuff2(1)) & " " & Hex(canbuff2(2)) & " " & Hex(canbuff2(3)) & " " & Hex(canbuff(4)) & " " & Hex(canbuff2(5))
infor(hnum, i) = "正常"
filedForm.Shape5(6).FillColor = QBColor(14)
Else
information = ""
infor(hnum, i) = "异常"
filedForm.Shape5(6).FillColor = QBColor(13)
End If
End If
End If
Next i
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
If lgbacktime(hnum) > 0 Then
filedForm.Ladd.Caption = timeadd
For i = 1 To num(hnum)
addtime(data(hnum, i)) = addtime(data(hnum, i)) + 1 '正在灌溉阀门的打开时间累加
Next i
timeadd = timeadd - 1
timeText.Text = timeadd
lgbacktime(hnum) = lgbacktime(hnum) - 1 '倒计时
Grid2.Col = 2
Grid2.Row = hnum
Grid2.Text = lgbacktime(hnum)
filedForm.Lteam.Caption = lgnum
filedForm.Lnum.Caption = hnum
filedForm.Lback.Caption = lgbacktime(hnum)
If (lgbacktime(hnum) = 0) Then '如果该组倒计时为零
Grid1.Row = hnum
For i = 1 To num(hnum)
Grid1.Col = i
Grid1.CellForeColor = RGB(0, 0, 255) '灌溉后的阀门数字显示蓝色
filedForm.Shape3(data(hnum, i)).FillColor = QBColor(9) '田间灌溉后的阀门图形均成蓝色
TeamForm2.Check1(data(hnum, i) - 1).ForeColor = QBColor(0)
TeamForm2.Check1(data(hnum, i) - 1).value = 0
closetime(data(hnum, i)) = Time '获得灌溉后阀门的关闭时刻值
lgclosetime(hnum) = Time
Grid2.Col = 4
Grid2.Row = hnum
Grid2.Text = Time
Next i
If ggtype = 1 Then '如果是手动轮灌模式
Call HisForm.his_data '将阀门信息记录在数据库中
hnum = hnum + 1
If hnum <= lgnum Then
Call start_gg
Else
Timer1.Enabled = False
Exit Sub
End If
End If
If ggtype = 2 Then '如果是手动随机模式
Timer1.Enabled = False
End If
End If
Else
If ggtype = 1 Then
Call HisForm.his_data '将阀门信息记录在数据库中
hnum = hnum + 1
Call start_gg
End If
If ggtype = 2 Then
Timer1.Enabled = False
End If
End If
End Sub
Private Sub Timer12_Timer()
Label19.Caption = Date
Label18.Caption = Time
End Sub
Private Sub Cmdzt_Click()
filedForm.Show
End Sub
Private Sub Cmdxx_Click()
xxForm.Show
End Sub
Private Sub Cdata_Click()
HisForm.Show
Call HisForm.get_cdata
End Sub
Private Sub Cmdset_Click()
commandbz = 2
PassForm.Show
End Sub
Private Sub Cmdzn_Click()
GuideForm.Show
End Sub
Private Sub Cmdquit_Click()
commandbz = 3
PassForm.Show
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -