MsgBox("还未与PLC建立联接!")
Exit Sub
End If
'
Call butRead_Click(Nothing, Nothing)
Call butWrite_Click(Nothing, Nothing)
'
If (Val(txtReRead.Text)0) Or (Val(txtReWrite.Text)0) Then
butScan.Text = "Cycle R/W"
Exit Sub
Else
ScanCount1 += 1
txtScanCnt.Text = ScanCount1
txtScanPrd.Text = (timeGetTime - tim)"ms"
End If
Timer1.Enabled = True
End Sub
Private Sub butBitTest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butBitTest.Click
If Not EntLink1 Then
MsgBox("还未与PLC建立联接!")
Exit Sub
End If
Dim rd As Boolean
Dim re As Short
Dim mry As EntQsPlc_Asc.PlcClient.PlcMemory = cmbBitMry.SelectedIndex + 1
re = PLC.Bit_Test(Handle1, mry, CUShort(txtBitAdd.Text), rd)
txtBitTest.Text = rd
txtReBit.Text = re
End Sub
Private Sub butBitSet_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butBitSet.Click
If Not EntLink1 Then
MsgBox("还未与PLC建立联接!")
Exit Sub
【vb.net以太网通信 vb以太网通讯控件】End If
Dim re As Short
re = PLC.Bit_Set(Handle1, cmbBitMry.SelectedIndex + 1, Val(txtBitAdd.Text))
txtReBit.Text = re
End Sub
Private Sub butBitRst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butBitRst.Click
If Not EntLink1 Then
MsgBox("还未与PLC建立联接!")
Exit Sub
End If
Dim re As Short
re = PLC.Bit_Reset(Handle1, cmbBitMry.SelectedIndex + 1, Val(txtBitAdd.Text))
txtReBit.Text = re
End Sub
End Class
谁有VB和OMRON PLC 通信例子?。磕芊穹⒏鲈即耄?再次特别感谢!提供一个VB.NET与OMRON以太网通讯的代码,是我项目里面复制出来的:
Dim Handle1 As Int32 'PLC的连接句柄
Dim EntLink As Boolean '连接标志
Dim PLC As New FinsTcp.PlcClient '引用OMRON的通讯组件
Private Sub butLink_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butLink.Click
Dim re As Short
Dim restr As String = ""
re = PLC.EntLink(Trim(txtLocalIP.Text), Val(txtLocalPort.Text), Trim(txtRemoteIP.Text), Val(txtRemotePort.Text), "DEMO", Handle1)
txtReLink.Text = re.ToString
If re = 0 Then
EntLink = True
MsgBox("PLC联接成功! ")
Else
EntLink = False
MsgBox("PLC联接失败: "restr)
End If
End Sub
Private Sub butClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butClose.Click
Dim re As Short
EntLink = False
re = PLC.DeLink(Handle1)
txtReClose.Text = re.ToString
End Sub
Private Sub butRead_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butRead.Click
Dim re As Short
Dim i As Short
Dim RD() As Object
ReDim RD(Val(txtReadCnt.Text - 1))
If Not EntLink Then
MsgBox("还未与PLC建立联接!")
Exit Sub
End If
Dim mry As FinsTcp.PlcClient.PlcMemory = cmbReadMry.SelectedIndex + 1
Dim typ As FinsTcp.PlcClient.DataType = cmbReadType.SelectedIndex + 1
re = PLC.CmdRead(Handle1, mry, typ, CUShort(Val(txtReadAdd.Text)), CUShort(Val(txtReadCnt.Text)), RD)
txtReRead.Text = re.ToString
lstRead.Items.Clear()
For i = 0 To UBound(RD) Step 1
If Not IsNothing(RD(i)) Then lstRead.Items.Add(RD(i))
Next i
If re0 Then
Timer1.Enabled = False
butScan.Text = "Cycle R/W"
End If
End Sub
Private Sub butWrite_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butWrite.Click
Dim re As Short
Dim i As Short
Dim temp() As String
Dim WD() As Object
If Not EntLink Then
MsgBox("还未与PLC建立联接!")
Exit Sub
End If
推荐阅读
- 虎牙直播虎牙福袋脚本下载,虎牙抽奖辅助
- 播放视频太阳是什么颜色,太阳是什么颜色的的短视频
- 模拟景色游戏软件,模拟风景游戏
- 下载地址1,下载地址1 长按复制链接后在浏览器中打开
- linux命令行切换画面 linux命令行切换图形
- 企业上erp系统的前提条件,企业上erp前的准备
- 网页css把内容放右下,网页css把内容放右下角怎么弄
- 无锡虎牙直播拍摄公司,虎牙直播总公司在哪个城市
- mysql权限不够怎么办 mysql权限不足