发表于:2009-03-06 11:52:20
楼主
‘-----BR 读X、Y、M----------------------
Private Sub Command7_Click()
Dim outstring As String
‘ outstring = "@" + "00" + "RD" + Text4.Text + Text5.Text ‘读从DM0000起的1个单元
‘ outstring = outstring + FCS(outstring) + "*" +chr(13)
‘ Text1.Text = outstring
‘ Text2.Text = COM2CPM2A(outstring)
‘If Device = "D" And CStr(Val(setad)) = setad And (Val(setad) < 1000 Or Val(setad) > 7999 And Val(setad) < 8256) Then
Dim addr As String
‘ dim Device as string = Left(setaddr, 1)
Dim DevAdd As String
Dim DevDat As String
Dim TnuA As Long
Dim instring As String
If Len(Text15.Text) > 1 Then
addr = Right(Text15.Text, Len(Text15.Text) - 1)
Device = Left(Text15.Text, 1)
End If
DevAdd = Right(("0000" + addr), 4)
DevDat = combbox_plc.Text + "FFBR0" + Device + DevAdd + "01" ‘使用WR命令读16bit数据
‘ DevDat = cboStation.Text + "FFWR0" + Device + DevAdd + "02" ‘使用WR命令读32bit数据
outstring =chr(5) + DevDat + SumChk(DevDat)
instring = COM_FX2N(outstring, 8)
‘ DevDData = Val("&H" +mid(SetIn, 6, 4))
‘ Text5.Text = CStr(DevDData)
Text14.Text =mid(instring, 6, 1)
‘ If Left$(instring, 7) =chr(2) + combbox_plc.Text + "FF0" +chr(3) Then
‘ Text14.Text = "SET"
‘ ElseIf Left$(instring, 7) =chr(2) + combbox_plc.Text + "FF1" +chr(3) Then
‘ Text14.Text = "RESET"
‘ Else
‘ Text14.Text = "ONLINE ERROR"
‘ End If
End Sub
‘-----BR 写 1 X、Y、M----------------------
Private Sub Command9_Click()
Dim outstring As String
‘ outstring = "@" + "00" + "RD" + Text4.Text + Text5.Text ‘读从DM0000起的1个单元
‘ outstring = outstring + FCS(outstring) + "*" +chr(13)
‘ Text1.Text = outstring
‘ Text2.Text = COM2CPM2A(outstring)
‘If Device = "D" And CStr(Val(setad)) = setad And (Val(setad) < 1000 Or Val(setad) > 7999 And Val(setad) < 8256) Then
Dim addr As String
‘ dim Device as string = Left(setaddr, 1)
Dim DevAdd As String
Dim DevDat As String
Dim TnuA As Long
Dim instring As String
If Len(Text16.Text) > 1 Then
addr = Right(Text16.Text, Len(Text16.Text) - 1)
Device = Left(Text16.Text, 1)
End If
DevAdd = Right(("0000" + addr), 4)
DevDat = combbox_plc.Text + "FFBW0" + Device + DevAdd + "011" ‘使用WR命令读16bit数据
‘ DevDat = cboStation.Text + "FFWR0" + Device + DevAdd + "02" ‘使用WR命令读32bit数据
outstring =chr(5) + DevDat + SumChk(DevDat)
instring = COM_FX2N(outstring, 5)
‘ DevDData = Val("&H" +mid(SetIn, 6, 4))
‘ Text5.Text = CStr(DevDData)
Label3.Caption = "闭合"
‘ If Left$(instring, 7) =chr(2) + combbox_plc.Text + "FF0" +chr(3) Then
‘ Text14.Text = "SET"
‘ ElseIf Left$(instring, 7) =chr(2) + combbox_plc.Text + "FF1" +chr(3) Then
‘ Text14.Text = "RESET"
‘ Else
‘ Text14.Text = "ONLINE ERROR"
‘ End If
End Sub