📄 form1.frm
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Form1
BorderStyle = 1 '窜老 绊沥
Caption = "柯嚼档 力绢扁"
ClientHeight = 2385
ClientLeft = 45
ClientTop = 330
ClientWidth = 6675
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2385
ScaleWidth = 6675
StartUpPosition = 3 'Windows 扁夯蔼
Begin VB.Timer Timer_control_load
Interval = 100
Left = 960
Top = 1560
End
Begin VB.Frame Frame2
Caption = "AUTO CONTROL"
Height = 2175
Left = 2280
TabIndex = 11
Top = 120
Width = 2295
Begin VB.CheckBox Check_auto
Caption = "AUTO"
Height = 375
Left = 1080
TabIndex = 20
Top = 240
Width = 1095
End
Begin VB.VScrollBar VScroll_humi
Height = 1815
Left = 600
Max = 100
TabIndex = 13
Top = 240
Width = 255
End
Begin VB.VScrollBar VScroll_temp
Height = 1815
Left = 240
Max = 100
TabIndex = 12
Top = 240
Width = 255
End
Begin VB.Label Label10
AutoSize = -1 'True
Caption = "汲沥嚼档"
Height = 180
Left = 1080
TabIndex = 19
Top = 1320
Width = 720
End
Begin VB.Label Label9
AutoSize = -1 'True
Caption = "汲沥柯档"
Height = 180
Left = 1080
TabIndex = 18
Top = 720
Width = 720
End
Begin VB.Label Label8
AutoSize = -1 'True
Caption = "%"
Height = 180
Left = 1800
TabIndex = 17
Top = 1560
Width = 150
End
Begin VB.Label Label7
AutoSize = -1 'True
Caption = "'C"
Height = 180
Left = 1800
TabIndex = 16
Top = 960
Width = 195
End
Begin VB.Label Lb_setting_humi
AutoSize = -1 'True
Caption = "汲沥嚼档"
Height = 180
Left = 1320
TabIndex = 15
Top = 1560
Width = 360
End
Begin VB.Label Lb_setting_temp
AutoSize = -1 'True
Caption = "汲沥柯档"
Height = 180
Left = 1320
TabIndex = 14
Top = 960
Width = 345
End
End
Begin VB.Frame Frame1
Caption = "MANUAL CONTROL"
Height = 2175
Left = 4680
TabIndex = 6
Top = 120
Width = 1935
Begin VB.CommandButton Cmd_feltio_off
Caption = "趁阿肛勉"
Height = 375
Left = 120
TabIndex = 10
Top = 1680
Width = 1695
End
Begin VB.CommandButton Cmd_feltio_on
Caption = "趁阿累悼"
Height = 375
Left = 120
TabIndex = 9
Top = 1200
Width = 1695
End
Begin VB.CommandButton Cmd_fan_off
Caption = "FAN OFF"
Height = 375
Left = 120
TabIndex = 8
Top = 720
Width = 1695
End
Begin VB.CommandButton Cmd_fan_on
Caption = "FAN ON"
Height = 375
Left = 120
TabIndex = 7
Top = 240
Width = 1695
End
End
Begin VB.Timer Timer1
Interval = 1000
Left = 1440
Top = 1560
End
Begin MSCommLib.MSComm MSComm1
Left = 120
Top = 1680
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DTREnable = 0 'False
NullDiscard = -1 'True
RThreshold = 1
RTSEnable = -1 'True
End
Begin VB.Label Label11
Caption = "Label11"
Height = 255
Left = 1200
TabIndex = 21
Top = 1080
Width = 735
End
Begin VB.Label Label6
AutoSize = -1 'True
Caption = "%"
Height = 180
Left = 1800
TabIndex = 5
Top = 600
Width = 150
End
Begin VB.Label Label5
AutoSize = -1 'True
Caption = "惑措嚼档 :"
Height = 180
Left = 240
TabIndex = 4
Top = 600
Width = 840
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "Label4"
Height = 180
Left = 1200
TabIndex = 3
Top = 600
Width = 555
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "'C"
Height = 180
Left = 1800
TabIndex = 2
Top = 240
Width = 195
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "泅犁柯档 :"
Height = 180
Left = 240
TabIndex = 1
Top = 240
Width = 840
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "Label1"
Height = 180
Left = 1200
TabIndex = 0
Top = 240
Width = 555
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim instring As String
Dim display_temp_string As String
Dim display_humi_string As String
Dim display_gradient_string As String
Dim VAL_temp As Single
Dim VAL_humi As Single
Dim FLAG_auto_control As Boolean
Dim FLAG_fan_on_off As Boolean
Dim flag_feltio_on_off As Boolean
Private Sub Check_auto_Click()
If (Check_auto.Value = 1) Then
FLAG_auto_control = True
End If
If (Check_auto.Value = 0) Then
FLAG_auto_control = False
End If
End Sub
Private Sub Cmd_fan_off_Click()
'MSComm1.Output = "D"
FLAG_fan_on_off = False
End Sub
Private Sub Cmd_fan_on_Click()
MSComm1.Output = "C"
FLAG_fan_on_off = True
End Sub
Private Sub Cmd_feltio_off_Click()
flag_feltio_on_off = False
End Sub
Private Sub Cmd_feltio_on_Click()
flag_feltio_on_off = True
End Sub
Private Sub Form_Load()
MSComm1.CommPort = 4
MSComm1.PortOpen = True
MSComm1.Settings = "9600,n,8,1"
Timer1.Interval = 1000
Timer1.Enabled = True
Timer_control_load.Interval = 100
Timer_control_load.Enabled = True
Lb_setting_temp.Caption = VScroll_temp.Value
Lb_setting_humi.Caption = VScroll_humi.Value
FLAG_fan_on_off = False
flag_feltio_on_off = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
MSComm1.PortOpen = False
End Sub
'''''''''''''''''''' 矫府倔肺 罐绰 单捞磐 '''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub MSComm1_OnComm()
Dim i As Integer
With MSComm1
Select Case MSComm1.CommEvent
Case comEvReceive
instring = MSComm1.Input
MSComm1.PortOpen = False
For i = 0 To 7
inbf(i) = Mid(instring, (i + 1), 1)
Next i
If inbf(0) = "C" And inbf(1) = "H" Then
display_humi_string = inbf(2) + inbf(3) + inbf(4) + inbf(5) + inbf(6) + inbf(7)
End If
If inbf(0) = "C" And inbf(1) = "T" Then
display_temp_string = inbf(2) + inbf(3) + inbf(4) + inbf(5) + inbf(6) + inbf(7)
End If
If inbf(0) = "C" And inbf(1) = "G" Then
display_gradient_string = inbf(2) + inbf(3) + inbf(4) + inbf(5) + inbf(6) + inbf(7)
End If
MSComm1.PortOpen = True
End Select
End With
End Sub
Private Sub Timer_control_load_Timer()
Dim i As Byte
'箭磊肺 官厕
VAL_temp = Val(display_temp_string)
VAL_humi = Val(display_humi_string)
If FLAG_auto_control = True Then
If (VScroll_temp.Value < VAL_temp) Then
MSComm1.Output = "C" ' 券浅扁 难扁
ElseIf (VScroll_temp.Value >= VAL_temp) Then
MSComm1.Output = "D" ' 券浅扁 掺扁
End If
If (VScroll_humi.Value < VAL_humi) Then
MSComm1.Output = "E" ' 歧萍绢 难扁
ElseIf (VScroll_humi.Value >= VAL_humi) Then
MSComm1.Output = "F" ' 歧萍绢 掺扁
End If
ElseIf (FLAG_auto_control = False) Then
'MSComm1.Output = "D"
'MSComm1.Output = "F"
If (FLAG_fan_on_off = True) Then
MSComm1.Output = "C"
Else
MSComm1.Output = "D"
End If
If (flag_feltio_on_off = True) Then
MSComm1.Output = "E"
Else
MSComm1.Output = "F"
End If
End If
End Sub
Private Sub Timer1_Timer()
Dim i As Integer
Label1.Caption = display_temp_string
Label4.Caption = display_humi_string
Label11.Caption = display_gradient_string
End Sub
Private Sub VScroll_humi_Change()
Lb_setting_humi.Caption = VScroll_humi.Value
End Sub
Private Sub VScroll_humi_Scroll()
Lb_setting_humi.Caption = VScroll_humi.Value
End Sub
Private Sub VScroll_temp_Change()
Lb_setting_temp.Caption = VScroll_temp.Value
End Sub
Private Sub VScroll_temp_Scroll()
Lb_setting_temp.Caption = VScroll_temp.Value
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -