串口接收程序

VERSION 5.00

Object = "{648A5603-2C6E-101B-82B6-[1**********]4}#1.1#0"; "MSCOMM32.OCX" Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX" Begin VB.Form Form1

Caption = " 西安亚川电力科技有限公司火灾报警器调试" ClientHeight = 9660

ClientLeft = 60

ClientTop = 510

ClientWidth = 11625

LinkTopic = "Form1"

ScaleHeight = 9660

ScaleWidth = 11625

StartUpPosition = 3 ' 窗口缺省

Begin VB.Frame Frame8

Caption = " 校验上限"

Height = 975

Left = 240

TabIndex = 74

Top = 8520

Width = 11175

Begin VB.CommandButton Command35

Caption = " 校验C 相电流"

Height = 380

Left = 9840

TabIndex = 82

Top = 360

Width = 1125

End

Begin VB.CommandButton Command34

Caption = " 校验漏电流"

Height = 380

Left = 240

TabIndex = 81

Top = 360

Width = 1125

End

Begin VB.CommandButton Command33

Caption = " 校验1路温度"

Height = 380

Left = 1600

TabIndex = 80

Top = 360

Width = 1125

End

Begin VB.CommandButton Command32 Caption = " 校验2路温度" Height = 380

Left = 2950 TabIndex = 79

Top = 360

Width = 1125 End

Begin VB.CommandButton Command31 Caption = " 校验3路温度" Height = 380

Left = 4300 TabIndex = 78

Top = 360

Width = 1125 End

Begin VB.CommandButton Command30 Caption = " 校验4路温度" Height = 380

Left = 5650 TabIndex = 77

Top = 360

Width = 1125 End

Begin VB.CommandButton Command29 Caption = " 校验A 相电流" Height = 380

Left = 7060 TabIndex = 76

Top = 360

Width = 1125 End

Begin VB.CommandButton Command28 Caption = " 校验B 相电流" Height = 380

Left = 8480 TabIndex = 75

Top = 360

Width = 1125 End

End

Begin VB.CommandButton Command27 Caption = " 校验C 相电流" Height = 380

Left = 10100

TabIndex = 73

Top = 7680

Width = 1125

End

Begin VB.Frame Frame7

Caption = " 校验上限" Height = 975

Left = 240

TabIndex = 65

Top = 7440

Width = 11175

Begin VB.CommandButton Command26 Caption = " 校验B 相电流" Height = 380

Left = 8480 TabIndex = 72

Top = 360

Width = 1125 End

Begin VB.CommandButton Command25 Caption = " 校验A 相电流" Height = 380

Left = 7060 TabIndex = 71

Top = 360

Width = 1125 End

Begin VB.CommandButton Command24 Caption = " 校验4路温度" Height = 380

Left = 5650 TabIndex = 70

Top = 360

Width = 1125 End

Begin VB.CommandButton Command23 Caption = " 校验3路温度" Height = 380

Left = 4300 TabIndex = 69

Top = 360

Width = 1125 End

Begin VB.CommandButton Command22 Caption = " 校验2路温度" Height = 380

Left = 2950 TabIndex = 68

Top = 360

Width = 1125 End

Begin VB.CommandButton Command21 Caption = " 校验1路温度" Height = 380

Left = 1600 TabIndex = 67

Top = 360

Width = 1125 End

Begin VB.CommandButton Command20 Caption = " 校验漏电流" Height = 380

Left = 240

TabIndex = 66

Top = 360

Width = 1125 End

End

Begin VB.Frame Frame6

Caption = " 数据采集" Height = 2295

Left = 7680

TabIndex = 55

Top = 4800

Width = 3855

Begin VB.CommandButton Command17 Caption = " 采集A 相电流" Height = 380

Left = 120

TabIndex = 64

Top = 1560 Width = 1125 End

Begin VB.CommandButton Command18 Caption = " 采集B 相电流" Height = 380

Left = 1350

TabIndex = 63

Top = 1560 Width = 1125 End

Begin VB.CommandButton Command19 Caption = " 采集C 相电流" Height = 380

Left = 2565 TabIndex = 62

Top = 1560 Width = 1125 End

Begin VB.CommandButton Command16 Caption = " 采集4路温度" Height = 380

Left = 2560 TabIndex = 61

Top = 960 Width = 1125 End

Begin VB.CommandButton Command15 Caption = " 采集3路温度" Height = 380

Left = 1350 TabIndex = 60

Top = 960 Width = 1125 End

Begin VB.CommandButton Command14 Caption = " 采集1路温度" Height = 380

Left = 2560 TabIndex = 59

Top = 360 Width = 1125 End

Begin VB.CommandButton Command13 Caption = " 采集2路温度" Height = 380

Left = 120

TabIndex = 58

Top = 960 Width = 1125 End

Begin VB.CommandButton Command12 Caption = " 采集开关量" Height = 380

Left = 1350 TabIndex = 57

Top = 360 Width = 1125 End

Begin VB.CommandButton Command11 Caption = " 采集漏电流" Height = 380

Left = 120

TabIndex = 56

Top = 360 Width = 1125 End

End

Begin VB.TextBox txtReceivedText

Height = 810

Left = 6960

MultiLine = -1 'True ScrollBars = 2 'Vertical TabIndex = 52

Top = 2160

Width = 4275

End

Begin VB.CommandButton Command9 Caption = " 清除"

Height = 380

Left = 6260

TabIndex = 50

Top = 6000

Width = 1000

End

Begin VB.TextBox txtStart

Height = 375

Left = 1230

TabIndex = 47

Top = 6000

Width = 855

End

Begin VB.Frame Frame5

Caption = " 发送"

Height = 1575

Left = 240

TabIndex = 39

Top = 5760

Width = 7215

Begin VB.OptionButton optCommData Caption = " 文本(&X)" Height = 180

Index = 1

Left = 120

TabIndex = 86

Top = 1110 Width = 1035 End

Begin VB.OptionButton optCommData Caption = " 十六进制" Height = 180

Index = 0

Left = 120

TabIndex = 85

Top = 840 Width = 1050 End

Begin VB.CheckBox chkCheckSum Caption = " 校验和" Height = 330

Left = 1920 TabIndex = 84

Top = 280 Width = 945 End

Begin VB.CommandButton cmdSend Caption = " 发送" Height = 380

Left = 4920 TabIndex = 54

Top = 240 Width = 1000 End

Begin VB.TextBox txtSend

Height = 570

Left = 1320 MultiLine = -1 'True ScrollBars = 2 'Vertical TabIndex = 51

Top = 840 Width = 5595 End

Begin VB.TextBox txtEnd

Height = 375

Left = 3960 TabIndex = 49

Top = 240 Width = 855 End

Begin VB.Label Label1

Caption = " 前段标志:" Height = 255

Index = 4

Left = 120

TabIndex = 41

Top = 360 Width = 1095 End

Begin VB.Label Label1

Caption = " 结束标志:" Height = 255

Index = 1

Left = 3000 TabIndex = 40

Top = 360 Width = 1215 End

End

Begin VB.Frame Frame4

Caption = " 接收数据" Height = 3015

Left = 6840

TabIndex = 38

Top = 120

Width = 4575

Begin VB.TextBox txtReceivedBinary Height = 810

Left = 120

MultiLine = -1 'True ScrollBars = 2 'Vertical TabIndex = 53

Top = 840 Width = 4275

End

Begin VB.CommandButton cmdClear Caption = " 清除" Height = 380

Left = 3360 TabIndex = 44

Top = 240 Width = 1000 End

Begin VB.CommandButton CmdCS Caption = "CS" Height = 380

Left = 2280 TabIndex = 43

Top = 240 Width = 1000 End

Begin VB.CommandButton Cmd485 Caption = "485" Height = 380

Left = 1200 TabIndex = 42

Top = 240 Width = 1000 End

Begin VB.Label Label1

Caption = " 文本信息:" Height = 375

Index = 6

Left = 120

TabIndex = 46

Top = 1800 Width = 1095 End

Begin VB.Label Label1

Caption = " 二进制信息:" Height = 375

Index = 5

Left = 120

TabIndex = 45

Top = 350 Width = 1095 End

End

Begin VB.CommandButton cmdClose Caption = " 关闭串口" Height = 380

Left = 6240

TabIndex = 37

Top = 5040

Width = 1000

End

Begin VB.CommandButton cmdCommOpen Caption = " 打开串口" Height = 380

Left = 5040

TabIndex = 36

Top = 5040

Width = 1000

End

Begin VB.Frame Frame3

Caption = " 端口设置" Height = 855

Left = 240

TabIndex = 31

Top = 4800

Width = 7215

Begin VB.ComboBox Combo2

Height = 300

Left = 3120 TabIndex = 32

Top = 300 Width = 1455 End

Begin VB.ComboBox Combo1

Height = 300

Left = 950

TabIndex = 33

Text = "cboCommPort" Top = 300 Width = 735 End

Begin VB.Label Label1

Caption = " 端口:" Height = 255

Index = 3

Left = 360

TabIndex = 83

Width = 615

End

Begin VB.Label Label1

Caption = " 数据格式(F):"

Height = 255

Index = 2

Left = 1920

TabIndex = 35

Top = 360

Width = 1215

End

Begin VB.Label Label17

Caption = " 端口(P):"

Height = 255

Left = 0

TabIndex = 34

Top = 840

Width = 855

End

End

Begin VB.Frame Frame2

Caption = " 电流统计计算"

Height = 1335

Left = 5280

TabIndex = 18

Top = 3360

Width = 4860

Begin VB.TextBox Text8

Height = 380

Left = 1000

TabIndex = 22

Top = 260

Width = 1000

End

Begin VB.TextBox Text7

Height = 380

Left = 3450

TabIndex = 21

Top = 240

Width = 1000

End

Begin VB.TextBox Text6

Height = 380

TabIndex = 20

Top = 720

Width = 1000

End

Begin VB.TextBox Text5

Height = 380

Left = 1000

TabIndex = 19

Top =

Width =

End

Begin VB.Label Label16

Caption =

Height =

Left =

TabIndex =

Top =

Width =

End

Begin VB.Label Label15

Caption =

Height =

Left =

TabIndex =

Top =

Width =

End

Begin VB.Label Label14

Caption =

Height =

Left =

TabIndex =

Top =

Width =

End

Begin VB.Label Label13

Caption =

Height =

Left =

TabIndex =

Top =

Width =

End 735 1000 " 漏电流:" 375 240 30 360 855 "mA" 255 2100 29 360 375 "A 相电流:" 375 2640 28 360 855 "A" 255 4550 27 360 255

Begin VB.Label Label12

Caption = "C 相电流:"

Height = 375

Left = 2640

TabIndex = 26

Top = 840

Width = 855

End

Begin VB.Label Label11

Caption = "A"

Height = 255

Left = 2100

TabIndex = 25

Top = 840

Width = 375

End

Begin VB.Label Label10

Caption = "B 相电流:"

Height = 375

Left = 240

TabIndex = 24

Top = 840

Width = 855

End

Begin VB.Label Label9

Caption = "A"

Height = 255

Left = 4550

TabIndex = 23

Top = 840

Width = 255

End

End

Begin VB.CommandButton Command3

Caption = " 关闭软件"

Height = 380

Left = 10320

TabIndex = 17

Top = 4320

Width = 1000

End

Begin VB.CommandButton Command2

Caption = " 停止采集"

Height = 380

TabIndex = 16

Top = 3840

Width = 1000

End

Begin VB.CommandButton Command1

Caption = " 采集线性"

Height = 380

Left = 10320

TabIndex = 15

Top = 3360

Width = 1000

End

Begin VB.Frame Frame1

Caption = " 温度统计计算"

Height = 1335

Left = 200

TabIndex = 2

Top = 3360

Width = 4860

Begin VB.TextBox Text4

Height = 380

Left = 1000

TabIndex = 10

Top = 735

Width = 1000

End

Begin VB.TextBox Text3

Height = 380

Left = 3360

TabIndex = 9

Top = 720

Width = 1000

End

Begin VB.TextBox Text2

Height = 380

Left = 3360

TabIndex = 7

Top = 240

Width = 1000

End

Begin VB.TextBox Text1

Height = 380

Left = 1000

Top = 260

Width = 1000

End

Begin VB.Label Label8

Caption = " ℃ "

Height = 255

Left = 4440

TabIndex = 14

Top =

Width =

End

Begin VB.Label Label7

Caption =

Height =

Left =

TabIndex =

Top =

Width =

End

Begin VB.Label Label6

Caption =

Height =

Left =

TabIndex =

Top =

Width =

End

Begin VB.Label Label5

Caption =

Height =

Left =

TabIndex =

Top =

Width =

End

Begin VB.Label Label4

Caption =

Height =

Left =

TabIndex =

Top =

Width =

End 840 375 " 最小值:" 375 240 13 840 855 " ℃ " 255 2100 12 840 375 " 最大值:" 375 2640 11 840 855 " ℃ " 255 4440 8 360 375

Begin VB.Label Label2

Caption = " 平均值:"

Height = 375

Left = 2640

TabIndex = 6

Top = 360

Width = 855

End

Begin VB.Label Label3

Caption = " ℃ "

Height = 255

Left = 2100

TabIndex = 5

Top = 360

Width = 375

End

Begin VB.Label Label1

Caption = " 当前值:"

Height = 375

Index = 0

Left = 240

TabIndex = 3

Top = 360

Width = 855

End

End

Begin VB.Timer Timer1

Left = 7320

Top = 5640

End

Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1

Height = 3000

Left = 4560

TabIndex = 1

Top = 240

Width = 2085

_ExtentX = 3678

_ExtentY = 5292

_Version = 393216

Rows = 200

End

Begin MSCommLib.MSComm MSComm1

Left = 7320

Top = 6240

_ExtentX = 1005

_ExtentY = 1005

_Version = 393216

DTREnable = -1 'True

End

Begin VB.PictureBox Picture1

BackColor = &H00FFFFFF&

Height = 3000

Left = 200

ScaleHeight = 2940

ScaleWidth = 4080

TabIndex = 0

Top = 240

Width = 4140

End

Begin VB.Label Label23

Caption = " 校验和"

Height = 255

Left = 4200

TabIndex = 48

Top = 6120

Width = 1215

End

End

Attribute VB_Name = "Form1"

Attribute VB_GlobalNameSpace = False

Attribute VB_Creatable = False

Attribute VB_PredeclaredId = True

Attribute VB_Exposed = False

'**************************************************************************** ' 西安亚川电力科技有限公司

' 火灾报警器调试软件

' 发布日期:2011/06/16

' 描 述:FY900火灾监控器专用调试软件

' 网 站:http://www.yachuan.com.cn/ (西安亚川电力科技有限公司网站)

' 网 站:http://www.yachuan.com.cn/ (西安亚川电力科技有限公司网站)

'e-mail :[email protected]

'e-mail :[email protected]

'OICQ :029-85368687

'

'****************************************************************************

' 定义窗体级变量

' 在显示、绘图、报警等过程中使用

Dim datatemp(1000) As Single ' 用于存储温度采样值

Dim num As Integer ' 用于存储采样值个数

Dim I As Single

Option Explicit

Private Declare Function GetTickCount Lib "kernel32" () As Long

Private Sub Picture2_Click()

End Sub

Private Sub SubWizard1_GotFocus()

End Sub

Private Sub Cmd485_Click()

If Index = 0 Then

cboCommSettings = "1200,E,8,1"

txtSend.Text = "68 01 00 00 00 00 00 68 01 02 43 C3"

chkCheckSum.Value = vbChecked

txtEnd.Text = "16"

txtStart.Text = ""

optCommData(0).Value = True

Else

cboCommSettings = "300,E,7,1"

txtSend.Text = "2F 3F 21 D A"

chkCheckSum.Value = vbUnchecked

txtEnd.Text = ""

txtStart.Text = ""

optCommData(0).Value = True

End If

End Sub

Private Sub cmdClear_Click()

txtReceivedBinary.Text = ""

txtReceivedText.Text = ""

txtSend.SetFocus

End Sub

Private Sub cmdClose_Click()

CloseComm

End Sub

Private Sub cmdCommOpen_Click()

SetMP 11

CloseComm

On Error Resume Next

With MSComm1

.CommPort = Val(Mid(cboCommPort.Text, 4))

.Settings = cboCommSettings.Text

.PortOpen = True

If Err = 0 Then

cmdSend.Enabled = True

Else

MsgBox "错误信息:" & vbCrLf & vbCrLf & Error & Space(7), vbInformation End If

End With

SetMP 0

End Sub

Private Sub cmdSend_Click()

Dim arr() As Byte

Dim I As Long

Dim J As Long

Dim S As Long

Dim C As Long

Dim Msg(2) As String

SetMP 11

cmdSend.Enabled = False

On Error Resume Next

Msg(0) = txtStart.Text

Msg(1) = txtSend.Text

Msg(2) = txtEnd.Text

For I = 0 To 2

If I = 2 Then

If chkCheckSum.Value = vbChecked Then ' 数据字节校验和

C = C + 1

ReDim Preserve arr(C - 1)

arr(C - 1) = S Mod 256

End If

End If

If (I = 1) And optCommData(1).Value Then '文本方式

Do While Len(Msg(I)) > 0

C = C + 1

ReDim Preserve arr(C - 1)

arr(C - 1) = Asc(Msg(I))

If I = 1 Then S = S + arr(C - 1)

Msg(I) = Mid(Msg(I), 2)

Loop

Else ' 十六进制

Msg(I) = Trim(Msg(I))

Do While Len(Msg(I)) > 0

C = C + 1

ReDim Preserve arr(C - 1)

arr(C - 1) = Val("&H" & Left(Msg(I), 2))

If I = 1 Then S = S + arr(C - 1)

Msg(I) = Trim(Mid(Msg(I), 3))

Loop

End If

Next I

If C > 0 Then MSComm1.Output = arr()

If Err > 0 Then MsgBox "错误信息:" & vbCrLf & vbCrLf & Error & Space(7), vbInformation txtSend.SetFocus

cmdSend.Enabled = True

SetMP 0

End Sub

Private Sub Combo1_Change()

CloseComm

End Sub

Private Sub Combo2_Change()

CloseComm

End Sub

' 开始采集

Private Sub Command1_Click()

Timer1.Enabled = True

End Sub

Private Sub Command10_Click()

Dim arr() As Byte

Dim I As Long

Dim J As Long

Dim S As Long

Dim C As Long

Dim Msg(2) As String

SetMP 11

cmdSend.Enabled = False

On Error Resume Next

Msg(0) = txtStart.Text

Msg(1) = txtSend.Text

Msg(2) = txtEnd.Text

For I = 0 To 2

If I = 2 Then

If chkCheckSum.Value = vbChecked Then ' 数据字节校验和

C = C + 1

ReDim Preserve arr(C - 1)

arr(C - 1) = S Mod 256

End If

End If

If (I = 1) And optCommData(1).Value Then '文本方式

Do While Len(Msg(I)) > 0

C = C + 1

ReDim Preserve arr(C - 1)

arr(C - 1) = Asc(Msg(I))

If I = 1 Then S = S + arr(C - 1)

Msg(I) = Mid(Msg(I), 2)

Loop

Else ' 十六进制

Msg(I) = Trim(Msg(I))

Do While Len(Msg(I)) > 0

C = C + 1

ReDim Preserve arr(C - 1)

arr(C - 1) = Val("&H" & Left(Msg(I), 2))

If I = 1 Then S = S + arr(C - 1)

Msg(I) = Trim(Mid(Msg(I), 3))

Loop

End If

Next I

If C > 0 Then MSComm1.Output = arr()

If Err > 0 Then MsgBox "错误信息:" & vbCrLf & vbCrLf & Error & Space(7), vbInformation txtSend.SetFocus

cmdSend.Enabled = True

SetMP 0

End Sub

' 停止采集

Private Sub Command2_Click()

Timer1.Enabled = False

End Sub

Private Sub Command4_Click()

SetMP 11

CloseComm

On Error Resume Next

With MSComm1

.CommPort = Val(Mid(cboCommPort.Text, 4))

.Settings = cboCommSettings.Text

.PortOpen = True

If Err = 0 Then

cmdSend.Enabled = True

Else

MsgBox "错误信息:" & vbCrLf & vbCrLf & Error & Space(7), vbInformation End If

End With

SetMP 0

End Sub

Private Sub Command5_Click()

CloseComm

End Sub

Private Sub Command9_Click()

txtSend.Text = ""

End Sub

' 串口初始化

' 在窗体的Load 事件中加入下列代码对串口进行初始化:

Private Sub Form_Load()

MSComm1.CommPort = 1

MSComm1.InputMode = 1

MSComm1.RThreshold = 1

MSComm1.SThreshold = 1

MSComm1.Settings = "4800,n,8,2"

Call tabinit ' 调用表格初始化子程序 End Sub

Private Sub Label20_Click()

End Sub

' 获取温度测量值并显示

' 每发送一次指令,触发下面事件,返回数据串

Private Sub MSComm1_OnComm()

Dim Inbyte() As Byte

Dim buffer As String

Dim datatemp2a, datatemp2b As String

Dim datatemp2 As String

If num > 199 Then Call renew

' 读取仪表返回数据串

Select Case MSComm1.CommEvent

Case comEvReceive

Inbyte = MSComm1.Input

For I = LBound(Inbyte) To UBound(Inbyte)

buffer = buffer + Hex(Inbyte(I)) + Chr(32)

Next I

Case comEvSend

End Select

' 获取十进制测量数据

If Len(Trim(Mid(buffer, 1, 2))) = 1 Then

datatemp(num) = Val("&H" & Mid(buffer, 3, 2) & Str("0") & Mid(buffer, 1, 2)) * 0.1 Else

datatemp(num) = Val("&H" & Mid(buffer, 3, 2) & Mid(buffer, 1, 2)) * 0.1

End If

' 获取十六进制测量数据

If Len(Trim(Mid(buffer, 1, 2))) = 1 Then

datatemp2a = Str("0") & Trim(Mid(buffer, 1, 2))

Else

datatemp2a = Mid(buffer, 1, 2)

End If

If Len(Trim(Mid(buffer, 3, 2))) = 1 Then

datatemp2b = Str("0") & Trim(Mid(buffer, 3, 2))

Else

datatemp2b = Mid(buffer, 3, 2)

End If

datatemp2 = datatemp2a & " " & datatemp2b

' 显示测量温度值

If datatemp(num) 0 Then

Grid.Col = 1: Grid.Row = num + 1

Grid.Text = Format$(datatemp(num), "0.0")

TempText = Format$(datatemp(num), "0.0") '10进制显示, 保留一位小数 'Text2.Text = datatemp2 '16进制显示

num = num + 1

Call cal ' 调用计算极值、平均值子程序 Call draw ' 调用绘曲线

End Sub

' 每台仪表有一个仪表号,PC 机通过仪表号来识别网上的多台仪表

' 程序中仪表号(即地址代号)要与仪表设

' 每隔1000ms 向仪表发送读数据命令串

' 每台仪表有一个仪表号,PC 机通过仪表号来识别网上的多台仪表

' 程序中仪表号(即地址代号)要与仪表设定值一致,否则不能返回数据。 Private Sub Timer1_Timer()

MSComm1.Output = Chr(&H8282) & Chr(&H52) & Chr(&HC)

End Sub

' 计算极值、平均值

Sub cal()

On Error GoTo hh

Sum = 0

Max = datatemp(0): Min = Max

For I = 0 To num - 1

If datatemp(I) >= Max Then Max = datatemp(I)

If datatemp(I)

Sum = Sum + datatemp(I)

Next I

aver = Sum / num

MaxText.Text = Format$(Max, "0.0")

MinText.Text = Format$(Min, "0.0")

AverText.Text = Format$(aver, "0.0")

hh: Exit Sub

End Sub

' 绘制温度实时变化曲线

Private Sub draw()

Picture1.Cls

Picture1.DrawWidth = 1

Picture1.BackColor = QBColor(15)

Picture1.Scale (0, 50)-(200, 0)

For I = 1 To num - 1

X1 = (I - 1): Y1 = datatemp(I - 1)

X2 = I: Y2 = datatemp(I)

Picture1.Line (X1, Y1)-(X2, Y2), QBColor(0)

Next I

End Sub

' 刷新

Private Sub renew()

If num = 0 Then Exit Sub

TempText.Text = "": AverText.Text = ""

MinText.Text = "": MaxText.Text = ""

Grid.Clear

Picture1.Cls

For I = 0 To num - 1

datatemp(I) = 0

Next I

num = 0

Call tabinit

End Sub

' 数据表格初始化

Public Sub tabinit()

MSFlexGrid1.Cols = 2

MSFlexGrid1.Rows = 200 + 1

MSFlexGrid1.ColWidth(0) = 700

MSFlexGrid1.ColWidth(1) = 950

MSFlexGrid1.Col = 0

For I = 1 To 200

MSFlexGrid1.Row = I

MSFlexGrid1.Text = " " + Str$(I)

Next I

MSFlexGrid1.Row = 0

MSFlexGrid1.Col = 0: MSFlexGrid1.Text = " 序号" MSFlexGrid1.Col = 1: MSFlexGrid1.Text = " 温度值" MSFlexGrid1.TopRow = 1 MSFlexGrid1.LeftCol = 1

End Sub

' 当退出程序时,关闭串行口

Private Sub Command3_Click()

Unload Me

End Sub ' 置在第一页

VERSION 5.00

Object = "{648A5603-2C6E-101B-82B6-[1**********]4}#1.1#0"; "MSCOMM32.OCX" Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX" Begin VB.Form Form1

Caption = " 西安亚川电力科技有限公司火灾报警器调试" ClientHeight = 9660

ClientLeft = 60

ClientTop = 510

ClientWidth = 11625

LinkTopic = "Form1"

ScaleHeight = 9660

ScaleWidth = 11625

StartUpPosition = 3 ' 窗口缺省

Begin VB.Frame Frame8

Caption = " 校验上限"

Height = 975

Left = 240

TabIndex = 74

Top = 8520

Width = 11175

Begin VB.CommandButton Command35

Caption = " 校验C 相电流"

Height = 380

Left = 9840

TabIndex = 82

Top = 360

Width = 1125

End

Begin VB.CommandButton Command34

Caption = " 校验漏电流"

Height = 380

Left = 240

TabIndex = 81

Top = 360

Width = 1125

End

Begin VB.CommandButton Command33

Caption = " 校验1路温度"

Height = 380

Left = 1600

TabIndex = 80

Top = 360

Width = 1125

End

Begin VB.CommandButton Command32 Caption = " 校验2路温度" Height = 380

Left = 2950 TabIndex = 79

Top = 360

Width = 1125 End

Begin VB.CommandButton Command31 Caption = " 校验3路温度" Height = 380

Left = 4300 TabIndex = 78

Top = 360

Width = 1125 End

Begin VB.CommandButton Command30 Caption = " 校验4路温度" Height = 380

Left = 5650 TabIndex = 77

Top = 360

Width = 1125 End

Begin VB.CommandButton Command29 Caption = " 校验A 相电流" Height = 380

Left = 7060 TabIndex = 76

Top = 360

Width = 1125 End

Begin VB.CommandButton Command28 Caption = " 校验B 相电流" Height = 380

Left = 8480 TabIndex = 75

Top = 360

Width = 1125 End

End

Begin VB.CommandButton Command27 Caption = " 校验C 相电流" Height = 380

Left = 10100

TabIndex = 73

Top = 7680

Width = 1125

End

Begin VB.Frame Frame7

Caption = " 校验上限" Height = 975

Left = 240

TabIndex = 65

Top = 7440

Width = 11175

Begin VB.CommandButton Command26 Caption = " 校验B 相电流" Height = 380

Left = 8480 TabIndex = 72

Top = 360

Width = 1125 End

Begin VB.CommandButton Command25 Caption = " 校验A 相电流" Height = 380

Left = 7060 TabIndex = 71

Top = 360

Width = 1125 End

Begin VB.CommandButton Command24 Caption = " 校验4路温度" Height = 380

Left = 5650 TabIndex = 70

Top = 360

Width = 1125 End

Begin VB.CommandButton Command23 Caption = " 校验3路温度" Height = 380

Left = 4300 TabIndex = 69

Top = 360

Width = 1125 End

Begin VB.CommandButton Command22 Caption = " 校验2路温度" Height = 380

Left = 2950 TabIndex = 68

Top = 360

Width = 1125 End

Begin VB.CommandButton Command21 Caption = " 校验1路温度" Height = 380

Left = 1600 TabIndex = 67

Top = 360

Width = 1125 End

Begin VB.CommandButton Command20 Caption = " 校验漏电流" Height = 380

Left = 240

TabIndex = 66

Top = 360

Width = 1125 End

End

Begin VB.Frame Frame6

Caption = " 数据采集" Height = 2295

Left = 7680

TabIndex = 55

Top = 4800

Width = 3855

Begin VB.CommandButton Command17 Caption = " 采集A 相电流" Height = 380

Left = 120

TabIndex = 64

Top = 1560 Width = 1125 End

Begin VB.CommandButton Command18 Caption = " 采集B 相电流" Height = 380

Left = 1350

TabIndex = 63

Top = 1560 Width = 1125 End

Begin VB.CommandButton Command19 Caption = " 采集C 相电流" Height = 380

Left = 2565 TabIndex = 62

Top = 1560 Width = 1125 End

Begin VB.CommandButton Command16 Caption = " 采集4路温度" Height = 380

Left = 2560 TabIndex = 61

Top = 960 Width = 1125 End

Begin VB.CommandButton Command15 Caption = " 采集3路温度" Height = 380

Left = 1350 TabIndex = 60

Top = 960 Width = 1125 End

Begin VB.CommandButton Command14 Caption = " 采集1路温度" Height = 380

Left = 2560 TabIndex = 59

Top = 360 Width = 1125 End

Begin VB.CommandButton Command13 Caption = " 采集2路温度" Height = 380

Left = 120

TabIndex = 58

Top = 960 Width = 1125 End

Begin VB.CommandButton Command12 Caption = " 采集开关量" Height = 380

Left = 1350 TabIndex = 57

Top = 360 Width = 1125 End

Begin VB.CommandButton Command11 Caption = " 采集漏电流" Height = 380

Left = 120

TabIndex = 56

Top = 360 Width = 1125 End

End

Begin VB.TextBox txtReceivedText

Height = 810

Left = 6960

MultiLine = -1 'True ScrollBars = 2 'Vertical TabIndex = 52

Top = 2160

Width = 4275

End

Begin VB.CommandButton Command9 Caption = " 清除"

Height = 380

Left = 6260

TabIndex = 50

Top = 6000

Width = 1000

End

Begin VB.TextBox txtStart

Height = 375

Left = 1230

TabIndex = 47

Top = 6000

Width = 855

End

Begin VB.Frame Frame5

Caption = " 发送"

Height = 1575

Left = 240

TabIndex = 39

Top = 5760

Width = 7215

Begin VB.OptionButton optCommData Caption = " 文本(&X)" Height = 180

Index = 1

Left = 120

TabIndex = 86

Top = 1110 Width = 1035 End

Begin VB.OptionButton optCommData Caption = " 十六进制" Height = 180

Index = 0

Left = 120

TabIndex = 85

Top = 840 Width = 1050 End

Begin VB.CheckBox chkCheckSum Caption = " 校验和" Height = 330

Left = 1920 TabIndex = 84

Top = 280 Width = 945 End

Begin VB.CommandButton cmdSend Caption = " 发送" Height = 380

Left = 4920 TabIndex = 54

Top = 240 Width = 1000 End

Begin VB.TextBox txtSend

Height = 570

Left = 1320 MultiLine = -1 'True ScrollBars = 2 'Vertical TabIndex = 51

Top = 840 Width = 5595 End

Begin VB.TextBox txtEnd

Height = 375

Left = 3960 TabIndex = 49

Top = 240 Width = 855 End

Begin VB.Label Label1

Caption = " 前段标志:" Height = 255

Index = 4

Left = 120

TabIndex = 41

Top = 360 Width = 1095 End

Begin VB.Label Label1

Caption = " 结束标志:" Height = 255

Index = 1

Left = 3000 TabIndex = 40

Top = 360 Width = 1215 End

End

Begin VB.Frame Frame4

Caption = " 接收数据" Height = 3015

Left = 6840

TabIndex = 38

Top = 120

Width = 4575

Begin VB.TextBox txtReceivedBinary Height = 810

Left = 120

MultiLine = -1 'True ScrollBars = 2 'Vertical TabIndex = 53

Top = 840 Width = 4275

End

Begin VB.CommandButton cmdClear Caption = " 清除" Height = 380

Left = 3360 TabIndex = 44

Top = 240 Width = 1000 End

Begin VB.CommandButton CmdCS Caption = "CS" Height = 380

Left = 2280 TabIndex = 43

Top = 240 Width = 1000 End

Begin VB.CommandButton Cmd485 Caption = "485" Height = 380

Left = 1200 TabIndex = 42

Top = 240 Width = 1000 End

Begin VB.Label Label1

Caption = " 文本信息:" Height = 375

Index = 6

Left = 120

TabIndex = 46

Top = 1800 Width = 1095 End

Begin VB.Label Label1

Caption = " 二进制信息:" Height = 375

Index = 5

Left = 120

TabIndex = 45

Top = 350 Width = 1095 End

End

Begin VB.CommandButton cmdClose Caption = " 关闭串口" Height = 380

Left = 6240

TabIndex = 37

Top = 5040

Width = 1000

End

Begin VB.CommandButton cmdCommOpen Caption = " 打开串口" Height = 380

Left = 5040

TabIndex = 36

Top = 5040

Width = 1000

End

Begin VB.Frame Frame3

Caption = " 端口设置" Height = 855

Left = 240

TabIndex = 31

Top = 4800

Width = 7215

Begin VB.ComboBox Combo2

Height = 300

Left = 3120 TabIndex = 32

Top = 300 Width = 1455 End

Begin VB.ComboBox Combo1

Height = 300

Left = 950

TabIndex = 33

Text = "cboCommPort" Top = 300 Width = 735 End

Begin VB.Label Label1

Caption = " 端口:" Height = 255

Index = 3

Left = 360

TabIndex = 83

Width = 615

End

Begin VB.Label Label1

Caption = " 数据格式(F):"

Height = 255

Index = 2

Left = 1920

TabIndex = 35

Top = 360

Width = 1215

End

Begin VB.Label Label17

Caption = " 端口(P):"

Height = 255

Left = 0

TabIndex = 34

Top = 840

Width = 855

End

End

Begin VB.Frame Frame2

Caption = " 电流统计计算"

Height = 1335

Left = 5280

TabIndex = 18

Top = 3360

Width = 4860

Begin VB.TextBox Text8

Height = 380

Left = 1000

TabIndex = 22

Top = 260

Width = 1000

End

Begin VB.TextBox Text7

Height = 380

Left = 3450

TabIndex = 21

Top = 240

Width = 1000

End

Begin VB.TextBox Text6

Height = 380

TabIndex = 20

Top = 720

Width = 1000

End

Begin VB.TextBox Text5

Height = 380

Left = 1000

TabIndex = 19

Top =

Width =

End

Begin VB.Label Label16

Caption =

Height =

Left =

TabIndex =

Top =

Width =

End

Begin VB.Label Label15

Caption =

Height =

Left =

TabIndex =

Top =

Width =

End

Begin VB.Label Label14

Caption =

Height =

Left =

TabIndex =

Top =

Width =

End

Begin VB.Label Label13

Caption =

Height =

Left =

TabIndex =

Top =

Width =

End 735 1000 " 漏电流:" 375 240 30 360 855 "mA" 255 2100 29 360 375 "A 相电流:" 375 2640 28 360 855 "A" 255 4550 27 360 255

Begin VB.Label Label12

Caption = "C 相电流:"

Height = 375

Left = 2640

TabIndex = 26

Top = 840

Width = 855

End

Begin VB.Label Label11

Caption = "A"

Height = 255

Left = 2100

TabIndex = 25

Top = 840

Width = 375

End

Begin VB.Label Label10

Caption = "B 相电流:"

Height = 375

Left = 240

TabIndex = 24

Top = 840

Width = 855

End

Begin VB.Label Label9

Caption = "A"

Height = 255

Left = 4550

TabIndex = 23

Top = 840

Width = 255

End

End

Begin VB.CommandButton Command3

Caption = " 关闭软件"

Height = 380

Left = 10320

TabIndex = 17

Top = 4320

Width = 1000

End

Begin VB.CommandButton Command2

Caption = " 停止采集"

Height = 380

TabIndex = 16

Top = 3840

Width = 1000

End

Begin VB.CommandButton Command1

Caption = " 采集线性"

Height = 380

Left = 10320

TabIndex = 15

Top = 3360

Width = 1000

End

Begin VB.Frame Frame1

Caption = " 温度统计计算"

Height = 1335

Left = 200

TabIndex = 2

Top = 3360

Width = 4860

Begin VB.TextBox Text4

Height = 380

Left = 1000

TabIndex = 10

Top = 735

Width = 1000

End

Begin VB.TextBox Text3

Height = 380

Left = 3360

TabIndex = 9

Top = 720

Width = 1000

End

Begin VB.TextBox Text2

Height = 380

Left = 3360

TabIndex = 7

Top = 240

Width = 1000

End

Begin VB.TextBox Text1

Height = 380

Left = 1000

Top = 260

Width = 1000

End

Begin VB.Label Label8

Caption = " ℃ "

Height = 255

Left = 4440

TabIndex = 14

Top =

Width =

End

Begin VB.Label Label7

Caption =

Height =

Left =

TabIndex =

Top =

Width =

End

Begin VB.Label Label6

Caption =

Height =

Left =

TabIndex =

Top =

Width =

End

Begin VB.Label Label5

Caption =

Height =

Left =

TabIndex =

Top =

Width =

End

Begin VB.Label Label4

Caption =

Height =

Left =

TabIndex =

Top =

Width =

End 840 375 " 最小值:" 375 240 13 840 855 " ℃ " 255 2100 12 840 375 " 最大值:" 375 2640 11 840 855 " ℃ " 255 4440 8 360 375

Begin VB.Label Label2

Caption = " 平均值:"

Height = 375

Left = 2640

TabIndex = 6

Top = 360

Width = 855

End

Begin VB.Label Label3

Caption = " ℃ "

Height = 255

Left = 2100

TabIndex = 5

Top = 360

Width = 375

End

Begin VB.Label Label1

Caption = " 当前值:"

Height = 375

Index = 0

Left = 240

TabIndex = 3

Top = 360

Width = 855

End

End

Begin VB.Timer Timer1

Left = 7320

Top = 5640

End

Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1

Height = 3000

Left = 4560

TabIndex = 1

Top = 240

Width = 2085

_ExtentX = 3678

_ExtentY = 5292

_Version = 393216

Rows = 200

End

Begin MSCommLib.MSComm MSComm1

Left = 7320

Top = 6240

_ExtentX = 1005

_ExtentY = 1005

_Version = 393216

DTREnable = -1 'True

End

Begin VB.PictureBox Picture1

BackColor = &H00FFFFFF&

Height = 3000

Left = 200

ScaleHeight = 2940

ScaleWidth = 4080

TabIndex = 0

Top = 240

Width = 4140

End

Begin VB.Label Label23

Caption = " 校验和"

Height = 255

Left = 4200

TabIndex = 48

Top = 6120

Width = 1215

End

End

Attribute VB_Name = "Form1"

Attribute VB_GlobalNameSpace = False

Attribute VB_Creatable = False

Attribute VB_PredeclaredId = True

Attribute VB_Exposed = False

'**************************************************************************** ' 西安亚川电力科技有限公司

' 火灾报警器调试软件

' 发布日期:2011/06/16

' 描 述:FY900火灾监控器专用调试软件

' 网 站:http://www.yachuan.com.cn/ (西安亚川电力科技有限公司网站)

' 网 站:http://www.yachuan.com.cn/ (西安亚川电力科技有限公司网站)

'e-mail :[email protected]

'e-mail :[email protected]

'OICQ :029-85368687

'

'****************************************************************************

' 定义窗体级变量

' 在显示、绘图、报警等过程中使用

Dim datatemp(1000) As Single ' 用于存储温度采样值

Dim num As Integer ' 用于存储采样值个数

Dim I As Single

Option Explicit

Private Declare Function GetTickCount Lib "kernel32" () As Long

Private Sub Picture2_Click()

End Sub

Private Sub SubWizard1_GotFocus()

End Sub

Private Sub Cmd485_Click()

If Index = 0 Then

cboCommSettings = "1200,E,8,1"

txtSend.Text = "68 01 00 00 00 00 00 68 01 02 43 C3"

chkCheckSum.Value = vbChecked

txtEnd.Text = "16"

txtStart.Text = ""

optCommData(0).Value = True

Else

cboCommSettings = "300,E,7,1"

txtSend.Text = "2F 3F 21 D A"

chkCheckSum.Value = vbUnchecked

txtEnd.Text = ""

txtStart.Text = ""

optCommData(0).Value = True

End If

End Sub

Private Sub cmdClear_Click()

txtReceivedBinary.Text = ""

txtReceivedText.Text = ""

txtSend.SetFocus

End Sub

Private Sub cmdClose_Click()

CloseComm

End Sub

Private Sub cmdCommOpen_Click()

SetMP 11

CloseComm

On Error Resume Next

With MSComm1

.CommPort = Val(Mid(cboCommPort.Text, 4))

.Settings = cboCommSettings.Text

.PortOpen = True

If Err = 0 Then

cmdSend.Enabled = True

Else

MsgBox "错误信息:" & vbCrLf & vbCrLf & Error & Space(7), vbInformation End If

End With

SetMP 0

End Sub

Private Sub cmdSend_Click()

Dim arr() As Byte

Dim I As Long

Dim J As Long

Dim S As Long

Dim C As Long

Dim Msg(2) As String

SetMP 11

cmdSend.Enabled = False

On Error Resume Next

Msg(0) = txtStart.Text

Msg(1) = txtSend.Text

Msg(2) = txtEnd.Text

For I = 0 To 2

If I = 2 Then

If chkCheckSum.Value = vbChecked Then ' 数据字节校验和

C = C + 1

ReDim Preserve arr(C - 1)

arr(C - 1) = S Mod 256

End If

End If

If (I = 1) And optCommData(1).Value Then '文本方式

Do While Len(Msg(I)) > 0

C = C + 1

ReDim Preserve arr(C - 1)

arr(C - 1) = Asc(Msg(I))

If I = 1 Then S = S + arr(C - 1)

Msg(I) = Mid(Msg(I), 2)

Loop

Else ' 十六进制

Msg(I) = Trim(Msg(I))

Do While Len(Msg(I)) > 0

C = C + 1

ReDim Preserve arr(C - 1)

arr(C - 1) = Val("&H" & Left(Msg(I), 2))

If I = 1 Then S = S + arr(C - 1)

Msg(I) = Trim(Mid(Msg(I), 3))

Loop

End If

Next I

If C > 0 Then MSComm1.Output = arr()

If Err > 0 Then MsgBox "错误信息:" & vbCrLf & vbCrLf & Error & Space(7), vbInformation txtSend.SetFocus

cmdSend.Enabled = True

SetMP 0

End Sub

Private Sub Combo1_Change()

CloseComm

End Sub

Private Sub Combo2_Change()

CloseComm

End Sub

' 开始采集

Private Sub Command1_Click()

Timer1.Enabled = True

End Sub

Private Sub Command10_Click()

Dim arr() As Byte

Dim I As Long

Dim J As Long

Dim S As Long

Dim C As Long

Dim Msg(2) As String

SetMP 11

cmdSend.Enabled = False

On Error Resume Next

Msg(0) = txtStart.Text

Msg(1) = txtSend.Text

Msg(2) = txtEnd.Text

For I = 0 To 2

If I = 2 Then

If chkCheckSum.Value = vbChecked Then ' 数据字节校验和

C = C + 1

ReDim Preserve arr(C - 1)

arr(C - 1) = S Mod 256

End If

End If

If (I = 1) And optCommData(1).Value Then '文本方式

Do While Len(Msg(I)) > 0

C = C + 1

ReDim Preserve arr(C - 1)

arr(C - 1) = Asc(Msg(I))

If I = 1 Then S = S + arr(C - 1)

Msg(I) = Mid(Msg(I), 2)

Loop

Else ' 十六进制

Msg(I) = Trim(Msg(I))

Do While Len(Msg(I)) > 0

C = C + 1

ReDim Preserve arr(C - 1)

arr(C - 1) = Val("&H" & Left(Msg(I), 2))

If I = 1 Then S = S + arr(C - 1)

Msg(I) = Trim(Mid(Msg(I), 3))

Loop

End If

Next I

If C > 0 Then MSComm1.Output = arr()

If Err > 0 Then MsgBox "错误信息:" & vbCrLf & vbCrLf & Error & Space(7), vbInformation txtSend.SetFocus

cmdSend.Enabled = True

SetMP 0

End Sub

' 停止采集

Private Sub Command2_Click()

Timer1.Enabled = False

End Sub

Private Sub Command4_Click()

SetMP 11

CloseComm

On Error Resume Next

With MSComm1

.CommPort = Val(Mid(cboCommPort.Text, 4))

.Settings = cboCommSettings.Text

.PortOpen = True

If Err = 0 Then

cmdSend.Enabled = True

Else

MsgBox "错误信息:" & vbCrLf & vbCrLf & Error & Space(7), vbInformation End If

End With

SetMP 0

End Sub

Private Sub Command5_Click()

CloseComm

End Sub

Private Sub Command9_Click()

txtSend.Text = ""

End Sub

' 串口初始化

' 在窗体的Load 事件中加入下列代码对串口进行初始化:

Private Sub Form_Load()

MSComm1.CommPort = 1

MSComm1.InputMode = 1

MSComm1.RThreshold = 1

MSComm1.SThreshold = 1

MSComm1.Settings = "4800,n,8,2"

Call tabinit ' 调用表格初始化子程序 End Sub

Private Sub Label20_Click()

End Sub

' 获取温度测量值并显示

' 每发送一次指令,触发下面事件,返回数据串

Private Sub MSComm1_OnComm()

Dim Inbyte() As Byte

Dim buffer As String

Dim datatemp2a, datatemp2b As String

Dim datatemp2 As String

If num > 199 Then Call renew

' 读取仪表返回数据串

Select Case MSComm1.CommEvent

Case comEvReceive

Inbyte = MSComm1.Input

For I = LBound(Inbyte) To UBound(Inbyte)

buffer = buffer + Hex(Inbyte(I)) + Chr(32)

Next I

Case comEvSend

End Select

' 获取十进制测量数据

If Len(Trim(Mid(buffer, 1, 2))) = 1 Then

datatemp(num) = Val("&H" & Mid(buffer, 3, 2) & Str("0") & Mid(buffer, 1, 2)) * 0.1 Else

datatemp(num) = Val("&H" & Mid(buffer, 3, 2) & Mid(buffer, 1, 2)) * 0.1

End If

' 获取十六进制测量数据

If Len(Trim(Mid(buffer, 1, 2))) = 1 Then

datatemp2a = Str("0") & Trim(Mid(buffer, 1, 2))

Else

datatemp2a = Mid(buffer, 1, 2)

End If

If Len(Trim(Mid(buffer, 3, 2))) = 1 Then

datatemp2b = Str("0") & Trim(Mid(buffer, 3, 2))

Else

datatemp2b = Mid(buffer, 3, 2)

End If

datatemp2 = datatemp2a & " " & datatemp2b

' 显示测量温度值

If datatemp(num) 0 Then

Grid.Col = 1: Grid.Row = num + 1

Grid.Text = Format$(datatemp(num), "0.0")

TempText = Format$(datatemp(num), "0.0") '10进制显示, 保留一位小数 'Text2.Text = datatemp2 '16进制显示

num = num + 1

Call cal ' 调用计算极值、平均值子程序 Call draw ' 调用绘曲线

End Sub

' 每台仪表有一个仪表号,PC 机通过仪表号来识别网上的多台仪表

' 程序中仪表号(即地址代号)要与仪表设

' 每隔1000ms 向仪表发送读数据命令串

' 每台仪表有一个仪表号,PC 机通过仪表号来识别网上的多台仪表

' 程序中仪表号(即地址代号)要与仪表设定值一致,否则不能返回数据。 Private Sub Timer1_Timer()

MSComm1.Output = Chr(&H8282) & Chr(&H52) & Chr(&HC)

End Sub

' 计算极值、平均值

Sub cal()

On Error GoTo hh

Sum = 0

Max = datatemp(0): Min = Max

For I = 0 To num - 1

If datatemp(I) >= Max Then Max = datatemp(I)

If datatemp(I)

Sum = Sum + datatemp(I)

Next I

aver = Sum / num

MaxText.Text = Format$(Max, "0.0")

MinText.Text = Format$(Min, "0.0")

AverText.Text = Format$(aver, "0.0")

hh: Exit Sub

End Sub

' 绘制温度实时变化曲线

Private Sub draw()

Picture1.Cls

Picture1.DrawWidth = 1

Picture1.BackColor = QBColor(15)

Picture1.Scale (0, 50)-(200, 0)

For I = 1 To num - 1

X1 = (I - 1): Y1 = datatemp(I - 1)

X2 = I: Y2 = datatemp(I)

Picture1.Line (X1, Y1)-(X2, Y2), QBColor(0)

Next I

End Sub

' 刷新

Private Sub renew()

If num = 0 Then Exit Sub

TempText.Text = "": AverText.Text = ""

MinText.Text = "": MaxText.Text = ""

Grid.Clear

Picture1.Cls

For I = 0 To num - 1

datatemp(I) = 0

Next I

num = 0

Call tabinit

End Sub

' 数据表格初始化

Public Sub tabinit()

MSFlexGrid1.Cols = 2

MSFlexGrid1.Rows = 200 + 1

MSFlexGrid1.ColWidth(0) = 700

MSFlexGrid1.ColWidth(1) = 950

MSFlexGrid1.Col = 0

For I = 1 To 200

MSFlexGrid1.Row = I

MSFlexGrid1.Text = " " + Str$(I)

Next I

MSFlexGrid1.Row = 0

MSFlexGrid1.Col = 0: MSFlexGrid1.Text = " 序号" MSFlexGrid1.Col = 1: MSFlexGrid1.Text = " 温度值" MSFlexGrid1.TopRow = 1 MSFlexGrid1.LeftCol = 1

End Sub

' 当退出程序时,关闭串行口

Private Sub Command3_Click()

Unload Me

End Sub ' 置在第一页


相关内容

  • 单片机软件UART(通用异步接收/发送装置)的设计资料
  • 单片机软件UART的设计资料 目前扩展串口的方法主要有以下方法, ①.采用串口扩展芯片实现,如ST16C550.ST16C554.SP2538.MAX3110等,虽然成本较高, 但系统的可靠性得到了保证,适用于数据量较大.串口需求较多的系统;②.采用分时切换的方法将一个串口扩展与多个串口设备通信,分 ...

  • 单片机通信电源监控器
  • 摘 要 本文主要阐述MCS51单片机软件和硬件设计的基本思路,根据经验,谈一些经常遇到的问题和对策. 关键词 单片机:软件设计:硬件设计:时间片:串口通信 中图分类号TP368.1 文献标识码A 文章编号 1674-6708(2013)96-0201-04 0引言 单片机在智能仪表,控制设备,机电一 ...

  • STC12C5A60S2 串口中断接收程序
  • STC12C5A60S2 串口中断接收程序 标签: c工具工作windowsunixsystem 2012-01-28 08:47 4367人阅读 评论(0) 收藏 举报 分类: 硬件开发技术(42) 版权声明:本文为博主原创文章,未经博主允许不得转载. #define UART0_BUF_LEN  ...

  • 单片机考试题库
  • 1.十进制数170的十六进制表示数是(A) AAH; AFH; B0H; B1H 2.十进制数175的十六进制表示数是(B) AAH; AFH; ACH; ADH 3.十进制数180的十六进制表示数是(C) B6H; B7H; B4H; B9H 4.十进制数185的十六进制表示数是(D) BAH; ...

  • 无线网络技术课程设计报告(论文)
  • 计算机科学与技术学院 无线网络技术课程设计报告(论文) 题目:点对点射频通信实验 专业班级: 姓 名: 时 间: 指导教师: 完成日期:2015年06月 22日 目录 摘要 ----------......--------------------1 关键词 ----................. ...

  • VC++中用通讯控件开发串行通信程序
  • 本文详细介绍了Visual C++5.0版中有关通讯控件的使用方法,并给出了一个利用该控件编写的简单通用的通信示例程序. 关键词:串行通信       通讯控件 随着Win 95的逐步普及,程序员们越来越愿意在Win95下编程,而Visual C++正成为主要的开发工具.然而用VC在Win95下开发 ...

  • 网关连接器
  • The WIZ110SR is a gateway module that converts RS-232 protocol into TCP/IP. It enables remote gauging, managing and control of TCP/IP devices through ...

  • sscanf(函数)
  • sscanf 名称: 名称 sscanf() - 从一个字符串中读进与指定格式相符的数据. 函数原型: 函数原型 Int sscanf( string str, string fmt, mixed var1, mixed var2 ... ); int scanf( const char *form ...

  • 说明书模板
  • 苏 州 市 职 业 大 学 实习(实训)报告 名称 2013年 1 月 7 日至 2013 年 1 月 11 日共 1 周 院 系 计算机工程系 班 级姓 名 系 主 任 教研室主任 指导教师 目 录 一.课程设计的目的与要求..................................... ...

  • 单片机论文
  • 目 录 摘要---------------------...1 关键词---------------------1 前言--------------------.......1 一.火灾智能报警控制系统基本功能及硬件组成--...2 二.报警系统软件设计-----------..--.3 三.系统可 ...