电气工程及其自动化毕业设计大论文123(2) - 图文 联系客服

发布时间 : 星期日 文章电气工程及其自动化毕业设计大论文123(2) - 图文更新完毕开始阅读a1f881e5cfc789eb162dc8c2

东北电力大学本科毕业设计论文

附 录

附录1

上位机接收收据程序

Option Explicit Dim sprv(12), k As Byte Dim a1, a2, a3, a4, a5, a6 As Byte

Public m, m1, m2, m3, m4, m5, m6, m7, m8 As Double Dim rdata(0) As Byte Dim strbuff As String Private Sub Form_Load() MSComm1.CommPort = 3 MSComm1.Settings = \

MSComm1.SThreshold = 1 '设置发射区字符的长度 MSComm1.RThreshold = 1 '设置接收缓冲区字符的长度 MSComm1.InputMode = 1 MSComm1.PortOpen = True End Sub

Private Sub Timer1_Timer()

Text46.Text = Format(Date, \

Text47.Text = Format(Date, \ Text48.Text = Format(Date, \ Text49.Text = Format(Now, \ Text50.Text = Minute(Now) Text51.Text = Second(Now) End Sub

Private Sub MSComm1_OnComm() Dim strbuff As Variant, i As Integer Dim rdata() As Byte Dim temp1 As Single On Error Resume Next Dim adors As New Recordset adors.ActiveConnection = ADOcn Dim strsql As String

If MSComm1.CommEvent = 2 Then MSComm1.InputLen = 1 rdata = MSComm1.Input strbuff = Hex(rdata(0)) k = \ Select Case a1 Case 1

a2 = a2 + 1

40

东北电力大学本科毕业设计论文

sprv(a2) = k

If a2 = 12 And sprv(12) = &H55 Then a2 = 0 a1 = 0 a3 = 1 End If If a3 = 1 Then

If BitCheck(sprv(2), 7) = True Then

temp1 = sprv(2) '直接代入下式会溢出,故用single变量传递 Text36.Text = Format(Left(1000000 / ((temp1 * 256 + sprv(1)) - 2 ^ 16), 6), \ '补码 Else

Text36.Text = Format(Left(1000000 / (sprv(2) * 256 + sprv(1)), 6), \ End If

If BitCheck(sprv(4), 7) = True Then

temp1 = sprv(4) '直接代入下式会溢出,故用single变量传递 Text1.Text = Format((temp1 * 256 + sprv(3) - 2 ^ 16) / 100, \ '补码 Else

Text1.Text = Format((sprv(4) * 256 + sprv(3)) / 100, \ End If

If BitCheck(sprv(6), 7) = True Then

temp1 = sprv(6) '直接代入下式会溢出,故用single变量传递 Text2.Text = Format((temp1 * 256 + sprv(5) - 2 ^ 16) / 5000, \ '补码 Else

Text2.Text = Format((sprv(6) * 256 + sprv(5)) / 5000, \ End If

If BitCheck(sprv(8), 7) = True Then

temp1 = sprv(8) '直接代入下式会溢出,故用single变量传递 Text3.Text = Format((temp1 * 256 + sprv(7) - 2 ^ 16) / 30, \ '补码 Else

Text3.Text = Format((sprv(8) * 256 + sprv(7)) / 30, \ End If

If BitCheck(sprv(10), 7) = True Then

temp1 = sprv(10) '直接代入下式会溢出,故用single变量传递 Text4.Text = Format((temp1 * 256 + sprv(9) - 2 ^ 16) / 30, \ '补码 Else

Text4.Text = Format((sprv(10) * 256 + sprv(9)) / 30, \ End If

If Text4.Text <> 0 And Text3.Text <> 0 Then

Text5.Text = Format(Cos(Atn(Text4.Text / Text3.Text)), \ Else: Text5.Text = \ End If

Text46.Text = Format(Date, \ Text47.Text = Format(Date, \ Text48.Text = Format(Date, \

41

东北电力大学本科毕业设计论文

Text49.Text = Format(Now, \ Text50.Text = Minute(Now) Text51.Text = Second(Now)

strsql = \测试系统1(频率,电压,电流,有功,无功,功率因数,年,月,日,时,分,秒)\

strsql = strsql + \\\

ADOcn.Execute strsql a3 = 0 a4 = 0 a5 = 0 a6 = 0 End If Case 2

a2 = a2 + 1 sprv(a2) = k

If a2 = 12 And sprv(12) = &H55 Then a2 = 0 a1 = 0 a3 = 2 End If If a3 = 2 Then

If BitCheck(sprv(2), 7) = True Then

temp1 = sprv(2) '直接代入下式会溢出,故用single变量传递 Text36.Text = Format(Left(1000000 / ((temp1 * 256 + sprv(1)) - 2 ^ 16), 6), \ '补码 Else

Text36.Text = Format(Left(1000000 / (sprv(2) * 256 + sprv(1)), 6), \ End If

If BitCheck(sprv(4), 7) = True Then

temp1 = sprv(4) '直接代入下式会溢出,故用single变量传递 Text6.Text = Format((temp1 * 256 + sprv(3) - 2 ^ 16) / 100, \ '补码 Else

Text6.Text = Format((sprv(4) * 256 + sprv(3)) / 100, \ End If

If BitCheck(sprv(6), 7) = True Then

temp1 = sprv(6) '直接代入下式会溢出,故用single变量传递 Text7.Text = Format((temp1 * 256 + sprv(5) - 2 ^ 16) / 5000, \ '补码 Else

Text7.Text = Format((sprv(6) * 256 + sprv(5)) / 5000, \ End If

If BitCheck(sprv(8), 7) = True Then

temp1 = sprv(8) '直接代入下式会溢出,故用single变量传递 Text8.Text = Format((temp1 * 256 + sprv(7) - 2 ^ 16) / 30, \ '补码 Else

42

东北电力大学本科毕业设计论文

Text8.Text = Format((sprv(8) * 256 + sprv(7)) / 30, \ End If

If BitCheck(sprv(10), 7) = True Then

temp1 = sprv(10) '直接代入下式会溢出,故用single变量传递 Text9.Text = Format((temp1 * 256 + sprv(9) - 2 ^ 16) / 30, \ '补码 Else

Text9.Text = Format((sprv(10) * 256 + sprv(9)) / 30, \ End If

If Text9.Text <> 0 And Text8.Text <> 0 Then

Text10.Text = Format(Cos(Atn(Text9.Text / Text8.Text)), \ Else: Text10.Text = \ End If

Text46.Text = Format(Date, \ Text47.Text = Format(Date, \ Text48.Text = Format(Date, \ Text49.Text = Format(Now, \ Text50.Text = Minute(Now) Text51.Text = Second(Now)

strsql = \测试系统2(频率,电压,电流,有功,无功,功率因数,年,月,日,时,分,秒)\

strsql = strsql + \\+ \

ADOcn.Execute strsql a3 = 0 a4 = 0 a5 = 0 a6 = 0 End If Case 3

a2 = a2 + 1 sprv(a2) = k

If a2 = 12 And sprv(12) = &H55 Then a2 = 0 a1 = 0 a3 = 3 End If If a3 = 3 Then

If BitCheck(sprv(2), 7) = True Then

temp1 = sprv(2) '直接代入下式会溢出,故用single变量传递 Text36.Text = Format(Left(1000000 / ((temp1 * 256 + sprv(1)) - 2 ^ 16), 6), \ '补码

Else

Text36.Text = Format(Left(1000000 / (sprv(2) * 256 + sprv(1)), 6), \ End If

43