'IP链接方式链接控制器
Private Sub OPEN_ETH_Click(sender As Object, e As EventArgs) Handles OPEN_ETH.Click
If g_handle = 0 Then
Dim ret = ZAux_OpenEth(TextBox1.Text, g_handle)
If (ret = 0) Then
Label3.Text = "已链接"
Label3.TextAlign = ContentAlignment.MiddleCenter
Label3.BackColor = Color.FromArgb(192, 255, 192)
Else
MessageBox.Show("链接失败,请输入正确的ip!")
End If
Else
MessageBox.Show("控制器已链接,请先断开另一个链接!")
End If
End Sub
②通过LOCAL链接方式的链接按钮的消息响应函数来链接控制器。
'LOCAL链接方式链接控制器
Private Sub OPEN_LOCAL_Click(sender As Object, e As EventArgs) Handles OPEN_LOCAL.Click
If g_handle = 0 Then
Dim ret = ZAux_FastOpen(5, ComboBox1.Text, 3000, g_handle)
If (ret = 0) Then
Label4.Text = "已链接"
Label4.TextAlign = ContentAlignment.MiddleCenter
Label4.BackColor = Color.FromArgb(192, 255, 192)
Else
MessageBox.Show("链接失败,请选择正确的LOCAL!")
End If
Else
MessageBox.Show("控制器已链接,请先断开另一个链接!")
End If
End Sub
③通过断开按钮的消息响应函数来断开控制器的链接。
Private Sub CLOSE_LOCAL_Click(sender As Object, e As EventArgs) Handles CLOSE_LOCAL.Click
If g_handle <> 0 Then '断开LOCAL链接
ZAux_Close(g_handle)
g_handle = 0
Label4.Text = "未链接"
Label4.TextAlign = ContentAlignment.MiddleCenter
Label4.BackColor = Color.FromArgb(255, 192, 192)
End If
End Sub
④通过单条指令交互周期的测试按钮对单条指令交互的周期进行测试。
Private Sub SingleTest_Click(sender As Object, e As EventArgs) Handles SingleTest.Click
Dim CsDpos As Single = 0
Dim TestNum As Integer = 0
If ComboBox2.Text = "1W" Then
TestNum = 10000
ElseIf ComboBox2.Text = "10W" Then
TestNum = 100000
ElseIf ComboBox2.Text = "100W" Then
TestNum = 1000000
End If
Dim beforeDT As Date = Date.Now
For lv_i As Integer = 0 To TestNum
ZAux_Direct_GetDpos(g_handle, 0, CsDpos)
Next
Dim afterDT As Date = Date.Now
Dim intertime As TimeSpan = afterDT - beforeDT
TextBox3.Text = intertime.TotalMilliseconds.ToString()
TextBox2.Text = (intertime.TotalMilliseconds * 1000 / TestNum).ToString()
TextBox4.Text = CsDpos.ToString()
End Sub
⑤通过多条指令交互周期的测试按钮对多条指令交互的周期进行测试。
Private Sub MultTest_Click(sender As Object, e As EventArgs) Handles MultTest.Click
Dim cmd As String
Dim star As Integer = 0
Dim cmdBuff As New StringBuilder(2048)
Dim TestNum As Integer = 0
If ComboBox2.Text = "1W" Then
TestNum = 10000
ElseIf ComboBox2.Text = "10W" Then
TestNum = 100000
ElseIf ComboBox2.Text = "100W" Then
TestNum = 1000000
End If
cmd = "?dpos(0),dpos(1),dpos(2),speed(0),speed(1),speed(2),axisstatus(0),axisstatus(1),axisstatus(2)"
Dim beforeDT As Date = Date.Now
For lv_i As Integer = 0 To TestNum
ZAux_DirectCommand(g_handle, cmd, cmdBuff, 2048)
Next
Dim afterDT As Date = Date.Now
Dim intertime As TimeSpan = afterDT - beforeDT
TextBox6.Text = intertime.TotalMilliseconds.ToString()
TextBox7.Text = (intertime.TotalMilliseconds * 1000 / TestNum).ToString()
Dim str As String = cmdBuff.ToString()
Dim tmp(9) As String
For lv_i As Integer = 0 To str.Length - 1
If str(lv_i) <> Chr(32) Then
tmp(star) += str(lv_i)
Else
star += 1
End If
Next
TextBox5.Text = tmp(0)
TextBox12.Text = tmp(1)
TextBox15.Text = tmp(2)
TextBox8.Text = tmp(3)
TextBox11.Text = tmp(4)
TextBox14.Text = tmp(5)
TextBox9.Text = tmp(6)
TextBox10.Text = tmp(7)
TextBox13.Text = tmp(8)
End Sub