2 Public Function Contour(
gclib As Gclib, fileA As String, fileB As String) As Integer
3 Record_Position(
gclib, fileA, fileB)
'Record positional data on Axis A and B
5 Dim positions_A = System.IO.File.ReadAllText(fileA).Split(",").ToList()
6 Dim positions_B = System.IO.File.ReadAllText(fileB).Split(",").ToList()
8 gclib.GCommand("SH AB") 'Set servo here
10 gclib.GMotionComplete("AB") 'Wait For motion To complete
12 gclib.GCommand("DT -1") 'Pauses
contour mode To pre-load buffer
13 gclib.
GCommand(
"CD 0,0")
'Pre load buffer With zeros To prevent under buffering
14 gclib.GCommand("CD 0,0") 'Pre load buffer With zeros To prevent under buffering
15 gclib.
GCommand(
"CD 0,0")
'Pre load buffer With zeros To prevent under buffering
16 gclib.GCommand("DT 1") 'Sets the time interval For
contour mode To be 2 samples
18 Dim capacity = 0
'Holds the capacity of the contour buffer
19 Dim cmd = 0 'Holds the counter
for which position to send next
21 If positions_A.Count <> positions_B.Count() Then
22 Console.WriteLine(
"Error: The two datasets are not the same size")
27 'Sleep while buffer is emptying
28 System.Threading.Thread.Sleep(400)
30 'Stores the available space of the
contour buffer in the capacity variable
32 Loop While Load_Buffer(
gclib, positions_A, positions_B, capacity, cmd)
36 Return Examples.GALIL_EXAMPLE_OK
40 Private Function Load_Buffer(gclib As Gclib, positions_A As List(Of String), positions_B As List(Of String),
41 capacity As Integer, ByRef cmd As Integer)
42 For i = capacity To 1 Step -1
43 If cmd + 1 < positions_A.Count() Then
44 'Subtract previous position from
new position to
get how
for of a move to make
45 Dim cdA = Double.Parse(positions_A(cmd + 1)) - Double.Parse(positions_A(cmd))
47 'Subtract previous position from new position to get how for of a move to make
48 Dim cdB = Double.Parse(positions_B(cmd + 1)) - Double.Parse(positions_B(cmd))
50 gclib.GCommand($"CD {cdA},{cdB}")
string GCommand(string Command, bool Trim=true)
Used for command-and-response transactions.
Int16 GCmdI(string Command)
Used for command-and-response transactions.
Provides a class that binds to gclib's unmanaged dll. Wraps each call and provides a more user-friend...
GReturn contour(GCon g, char *fileA, char *fileB)
Record user's training and plays back training through contour mode.