📄 form1.frm
字号:
VERSION 5.00
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Begin VB.Form Form1
BackColor = &H00FFA466&
Caption = "Form1"
ClientHeight = 9390
ClientLeft = 60
ClientTop = 450
ClientWidth = 13905
LinkTopic = "Form1"
Picture = "Form1.frx":0000
ScaleHeight = 9390
ScaleWidth = 13905
StartUpPosition = 3 '窗口缺省
WindowState = 2 'Maximized
Begin VB.Frame Frame1
Appearance = 0 'Flat
BackColor = &H00FF8635&
Caption = "Frame1"
ForeColor = &H80000008&
Height = 2415
Left = 840
TabIndex = 8
Top = 960
Width = 3975
Begin VB.Timer shrink1
Interval = 700
Left = 3360
Top = 360
End
Begin VB.CommandButton Command2
Caption = "查看"
Height = 375
Left = 2880
TabIndex = 15
Top = 1800
Width = 735
End
Begin VB.TextBox Text5
Height = 270
Left = 1440
TabIndex = 10
Top = 1200
Width = 1695
End
Begin VB.TextBox Text4
Height = 270
Left = 1440
TabIndex = 9
Top = 600
Width = 1695
End
Begin VB.Shape Shape2
BorderColor = &H00000000&
BorderStyle = 0 'Transparent
FillColor = &H0000FF00&
FillStyle = 0 'Solid
Height = 255
Left = 2040
Shape = 3 'Circle
Top = 1800
Width = 255
End
Begin VB.Shape Shape1
BorderColor = &H00000000&
BorderStyle = 0 'Transparent
FillColor = &H0000FF00&
FillStyle = 0 'Solid
Height = 255
Left = 960
Shape = 3 'Circle
Top = 1800
Width = 255
End
Begin VB.Label Label4
BackColor = &H00FF8635&
Caption = "报警"
Height = 255
Left = 1560
TabIndex = 14
Top = 1800
Width = 495
End
Begin VB.Label Label3
BackColor = &H00FF8635&
Caption = "通讯"
Height = 255
Left = 480
TabIndex = 13
Top = 1800
Width = 495
End
Begin VB.Label Label2
BackColor = &H00FF8635&
Caption = "平均湿度"
Height = 255
Left = 480
TabIndex = 12
Top = 1200
Width = 855
End
Begin VB.Label Label1
Appearance = 0 'Flat
BackColor = &H00FF8635&
Caption = "平均温度"
ForeColor = &H80000008&
Height = 255
Left = 480
TabIndex = 11
Top = 600
Width = 855
End
End
Begin VB.TextBox Text2
Height = 375
Left = 120
TabIndex = 7
Text = "Text2"
Top = 8760
Width = 13455
End
Begin VB.TextBox Text1
Height = 375
Left = 120
TabIndex = 6
Top = 9240
Width = 12495
End
Begin VB.Timer visor1
Interval = 10000
Left = 6840
Top = 360
End
Begin VB.TextBox Text3
Height = 270
Index = 4
Left = 480
TabIndex = 5
Text = "Text3"
Top = 6480
Width = 1815
End
Begin VB.TextBox Text3
Height = 270
Index = 3
Left = 480
TabIndex = 4
Text = "Text3"
Top = 6840
Width = 1815
End
Begin VB.TextBox Text3
Height = 270
Index = 2
Left = 480
TabIndex = 3
Text = "Text3"
Top = 7200
Width = 1815
End
Begin VB.TextBox Text3
Height = 270
Index = 1
Left = 480
TabIndex = 2
Text = "Text3"
Top = 6120
Width = 1815
End
Begin VB.TextBox Text3
Height = 270
Index = 0
Left = 480
TabIndex = 1
Text = "Text3"
Top = 5760
Width = 1815
End
Begin VB.CommandButton Command1
Caption = "1"
Height = 465
Left = 3000
TabIndex = 0
Top = 6360
Width = 975
End
Begin VB.Timer Timer1
Enabled = 0 'False
Interval = 2000
Left = 0
Top = 480
End
Begin MSWinsockLib.Winsock Winsock1
Left = 0
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
RemoteHost = "192.168.1.150"
RemotePort = 10001
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim S_COM(31) As Integer
Dim S_ALM(31) As Integer
Private Sub Command1_Click()
If Winsock1.State <> sckConnected Then
Winsock1.Close
Winsock1.Connect
End If
End Sub
Private Sub Command2_Click()
Form2.Show
End Sub
Private Sub Form_Load()
Dim tmp As Integer
tmp = read_conf()
'初始化变量
T_OFFSET0 = 0
T_CMD0 = True
S_COM(0) = 0
S_ALM(0) = 0
Frame1.Caption = T_PNAME(0)
End Sub
Private Sub shrink1_Timer()
Dim avgt As Double
Dim avgw As Double
Dim tmp As Integer
avgt = 0
avgw = 0
For tmp = 0 To T_SN(0) - 1
avgt = avgt + T_TMP(0, tmp)
avgw = avgw + T_WET(0, tmp)
Next tmp
Text4.Text = avgt / T_SN(0)
Text5.Text = avgw / T_SN(0)
If avgt / T_SN(0) > 30 Then
S_ALM(0) = 1
Else
S_ALM(0) = 0
End If
If avgw / T_SN(0) < 10 Then
S_ALM(0) = 1
Else
S_ALM(0) = 0
End If
If S_COM(0) = 1 Then
If Shape1.FillColor = &HFF& Then
Shape1.FillColor = &HC0&
Else
Shape1.FillColor = &HFF&
End If
Else
Shape1.FillColor = &HFF00&
End If
If S_ALM(0) = 1 Then
If Shape2.FillColor = &HFF& Then
Shape2.FillColor = &HC0&
Else
Shape2.FillColor = &HFF&
End If
Else
Shape2.FillColor = &HFF00&
End If
End Sub
Private Sub Timer1_Timer()
Dim tmp As Integer
T_OFFSET0 = 0
If T_CMD0 = True Then
Winsock1.SendData "#000" & vbCr
T_CMD0 = False
Else
Winsock1.SendData "#007" & vbCr
T_CMD0 = True
End If
For tmp = 0 To 4
T_TMP(0, tmp) = gettem(T_E0(), tmp)
T_WET(0, tmp) = getwet(T_E0(), tmp)
Text3(tmp).Text = T_TMP(0, tmp) & "," & T_WET(0, tmp)
Next tmp
Timer1.Enabled = False
End Sub
Private Sub visor1_Timer()
S_COM(0) = 1
End Sub
Private Sub Winsock1_Connect()
Timer1.Enabled = True
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim e() As Byte
Dim tmp As Integer
visor1.Enabled = False
S_COM(0) = 0
If T_CMD0 = False Then
Winsock1.GetData e
For tmp = 0 To bytesTotal - 1
T_E0(T_OFFSET0) = e(tmp)
T_OFFSET0 = T_OFFSET0 + 1
If e(tmp) = &HD Then
Timer1.Enabled = True
End If
Next tmp
Text2.Text = ""
For tmp = 0 To T_OFFSET0
Text2.Text = Text2.Text & "[" & T_E0(tmp) & "] "
Next tmp
Else
Winsock1.GetData e
T_FIRE(0) = testfire(e())
Timer1.Enabled = True
Text1.Text = Text1.Text & T_FIRE(0) & ","
End If
visor1.Enabled = True
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -