1 Partial Public Module Examples
2 Public Function Vector_Mode(gclib As Gclib, file As String) As Integer
3 gclib.GCommand("ST") 'Stop all motors
4 gclib.GCommand("SH AB") 'Set servo here
5 gclib.GCommand("DP 0,0") 'Start position at absolute zero
7 gclib.GCommand("CAS") 'Defines S As active coordinate system
8 gclib.GCommand("VS 20000") 'Defines vector speed
9 gclib.GCommand("VA 200000") 'Defines vector acceleration
10 gclib.GCommand("VD 200000") 'Defines vector decelerlation
11 gclib.GCommand("VM AB") 'Begin vector segment
13 Using reader As System.IO.StreamReader = New System.IO.StreamReader(file)
14 'Stores the available space of the vector buffer in the capacity variable
15 Dim capacity = gclib.GCmdI("MG _LMS")
16 Load_Buffer(gclib, reader, capacity)
18 Console.WriteLine("Begin Motion")
19 gclib.GCommand("BG S")
21 Do 'Load buffer with more commands
22 System.Threading.Thread.Sleep(100)
24 'Stores the available space of the vector buffer in the capacity variable
25 capacity = gclib.GCmdI("MG _LMS")
26 Loop While Load_Buffer(gclib, reader, capacity)
28 gclib.GCommand("VE") 'Segment End
29 gclib.GMotionComplete("S")
30 Console.WriteLine("Motion Complete")
32 Return GALIL_EXAMPLE_OK
36 Private Function Load_Buffer(gclib As Gclib, reader As System.IO.StreamReader, capacity As Integer) As Boolean
37 Dim s_cmd As String = ""
38 'Fully load the vector buffer leaving room for one VE command
39 For i = capacity To 1 Step -1
40 'If there Is another line of the text file
41 If reader.Peek() >= 0 Then
42 s_cmd = reader.ReadLine()
43 'Run the command on each line of the text file