2 Public Function Record_Position(
gclib As Gclib, fileA As String, fileB As String)
3 Dim writerA = New System.IO.StreamWriter(fileA, False)
4 Dim writerB = New System.IO.StreamWriter(fileB, False)
9 "RC 0;' Disable Recording" + vbCr +
10 "DP 0, 0;' Set current position to 0" + vbCr +
11 "DM posA[1000], posB[1000];' Define a new array that will hold positional data" + vbCr +
12 "RA posA[], posB[];' Sets position array to be where recorded data will be stored" + vbCr +
13 "RD _TPA, _TPB;' Defines Position to be the type of data that will be recorded" + vbCr +
14 "RC 1,-1000;' Begins recording at 512Hz in continuous mode" + vbCr +
15 "MO AB;' Turns motors off" + vbCr +
16 "AI -1;' Waits for active low on Input 1" + vbCr +
17 "RC 0;' Disable Recording after Input 1 goes low" + vbCr +
25 Dim leading_comma = False
27 Console.WriteLine(
"Begin recording")
30 System.Threading.Thread.Sleep(1000)
'Sleep while we wait for roughly half the array to be written
31 rd = gclib.GCmdI("MG _RD") 'Gets address of next value in the position array
33 'Get values from posA[] array and write to file
34 Write_Array_To_File(gclib, writerA, "posA", previous_rd, rd, leading_comma)
36 'Get values from posB[] array and write to file
37 Write_Array_To_File(
gclib, writerB,
"posB", previous_rd, rd, leading_comma)
41 recording =
gclib.
GCmdI(
"MG _RC")
'Check status of RC
45 Loop While recording > 0 'While recording is active
47 Console.WriteLine(
"End recording")
55 Private Sub Write_Array_To_File(
gclib As Gclib, writer As System.IO.StreamWriter, array_name As String, previous_rd As Integer, rd As Integer, leading_comma As Boolean)
56 Dim values = New List(Of Double)
58 If previous_rd < rd Then
'No array wrap around
59 'Grab list of doubles from controller and add it to values
62 'Grab list of doubles from controller and add it to values
63 values.AddRange(gclib.GArrayUpload(array_name, previous_rd, 999))
66 'Grab list of doubles from controller and add it to values
71 For i = 0 To values.Count() - 1
78 writer.Write(String.Format(
"{0:0.000}", values(i)))
string GCommand(string Command, bool Trim=true)
Used for command-and-response transactions.
void GProgramDownload(string program, string preprocessor="")
Allows downloading of a DMC program from a string buffer.
List< double > GArrayUpload(string array_name, Int16 first=-1, Int16 last=-1)
Uploads array data from the controller's array table.
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...