9 Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
10 Print("Enter a FULL GOpen() address above and click Go", PrintStyle.Instruction)
11 Print("NOTE: This demo will attempt to move Axis A", PrintStyle.Instruction)
15 Private Sub HelpLabel_Click(sender As Object, e As EventArgs) Handles HelpLabel.Click
50 Case PrintStyle.Instruction
52 Case PrintStyle.GalilData
54 Case PrintStyle.Normal
58 Case PrintStyle.GclibData
121 Print("
gclib version: ", PrintStyle.Normal,
True)
131 ' Print(
m, PrintStyle.GclibData)
143 Print(
a, PrintStyle.GclibData)
160 Print("Uploading Program")
161 Print(gclib.GProgramUpload(), PrintStyle.GalilData)
163 Print("Blocking GMessage call")
165 System.Threading.Thread.Sleep(200) 'wait a bit to queue up some messages
166 Print(gclib.GMessage(), PrintStyle.GalilData) 'get them all in one blocking read
168 Print("Downloading Program... ", , True)
169 gclib.GProgramDownload("WT 1000; MG TIME; EN", "") 'prints a messsage after 1 second
171 Print("Uploading Program")
172 Print(gclib.GProgramUpload(), PrintStyle.GalilData)
174 Print("Non-blocking GMessage call", , True)
176 gclib.GTimeout(0) 'set a zero timeout for a non-blocking read
177 Dim msg As String = ""
179 msg = gclib.GMessage()
180 Print(".", PrintStyle.Normal, True)
181 System.Threading.Thread.Sleep(20) 'do something useful here...
183 Print("Message: ", PrintStyle.Normal, True)
184 Print(msg.Trim(), PrintStyle.GalilData)
185 gclib.GTimeout(-1) 'put the timeout back
186 'NOTE: Both GRecord and GInterrupt also have non-blocking mode with 0 timeout.
188 Print("Downloading Program... ", , True)
189 gclib.GProgramDownload("WT 1000; UI 8; EN", "") 'fires an interrupt after 1 second
191 Print("Uploading Program")
192 Print(gclib.GProgramUpload(), PrintStyle.GalilData)
194 Print("Non-blocking GInterrupt call", , True)
196 gclib.GTimeout(0) 'set a zero timeout for a non-blocking read
199 b = gclib.GInterrupt()
200 Print(".", PrintStyle.Normal, True)
201 System.Threading.Thread.Sleep(20) 'do something useful here...
203 Print("Byte: ", PrintStyle.Normal, True)
204 Print(b.ToString("X02"), PrintStyle.GalilData)
205 gclib.GTimeout(-1) 'put the timeout back
207 Print("Getting some synchronous data records")
208 Dim DataRecord As Gclib.GDataRecord4000
210 DataRecord = gclib.GRecord(Of Gclib.GDataRecord4000)(False)
211 Print(DataRecord.sample_number.ToString() & " ", PrintStyle.GalilData, True) 'byte 4 and 5 are typically TIME counter
212 'need help accessing the data record? Contact softwaresupport@galil.com
213 System.Threading.Thread.Sleep(10)
217 Print("Getting some asynchronous data records")
218 gclib.GRecordRate(10) 'set up data records every 10 ms
220 DataRecord = gclib.GRecord(Of Gclib.GDataRecord4000)(True)
221 Print(DataRecord.sample_number.ToString() & " ", PrintStyle.GalilData, True) 'byte 4 and 5 are typically TIME counter
222 'no need to delay, asynchronous mode is dispatched by the Galil's RTOS.
224 gclib.GRecordRate(0) 'turn off data records
227 Print("Downloading an array... ", , True)
228 Dim array As New List(Of Double)
229 For i As Double = 0 To 9
232 gclib.GCommand("DA *[];DM array[10]") 'arrays must be dimensioned prior to download
233 gclib.GArrayDownload("array", array)
235 Print("Ok. Uploading array")
236 array = gclib.GArrayUpload("array")
237 For Each d As Double In array
238 Print(d.ToString("F4") & " ", PrintStyle.GalilData, True)
242 Print("Performing a write... ", , True)
243 gclib.GWrite("QR" & vbCr) 'QR returns the binary data record
244 Print("Ok. Reading binary data... ", , True)
245 Dim data As Byte() = gclib.GRead()
246 Print("Ok. Read " & data.Length() & " bytes.")
248 Print("Preparing A axis. This could cause errors if the axis is not initialized...", , True)
249 gclib.GCommand("AB;MO;SHA") 'compound commands are possible though typically not recommended
251 gclib.GCommand("PRA=5000")
252 gclib.GCommand("SPA=5000")
253 Print("Profiling a move on axis A... ", , True)
254 gclib.GCommand("BGA")
255 Print("Waiting for motion to complete... ", , True)
256 gclib.GMotionComplete("A")
258 Print("Going back... ", , True)
259 gclib.GCommand("PRA=-5000")
260 gclib.GCommand("BGA")
261 gclib.GMotionComplete("A")
263 Catch ex As Exception
264 Print("Error: " & ex.Message, PrintStyle.Err)
266 If Not gclib Is Nothing Then
267 gclib.GClose() 'don't forget to close connections!
Provides a class that binds to gclib's unmanaged dll. Wraps each call and provides a more user-friend...
GCLIB_DLL_EXPORTED GReturn GCALL GAssign(GCStringIn ip, GCStringIn mac)
Uses GUtility(), G_UTIL_GCAPS_ASSIGN or G_UTIL_ASSIGN to assign an IP address over the Ethernet to a ...
GCLIB_DLL_EXPORTED GReturn GCALL GIpRequests(GCStringOut requests, GSize requests_len)
Uses GUtility(), G_UTIL_GCAPS_IPREQUEST or G_UTIL_IPREQUEST to provide a list of all Galil controller...
GCLIB_DLL_EXPORTED GReturn GCALL GVersion(GCStringOut ver, GSize ver_len)
Uses GUtility(), G_UTIL_VERSION and G_UTIL_GCAPS_VERSION to provide the library and gcaps version num...
GCLIB_DLL_EXPORTED GReturn GCALL GCommand(GCon g, GCStringIn command, GBufOut buffer, GSize buffer_len, GSize *bytes_returned)
Performs a command-and-response transaction on the connection.
GCLIB_DLL_EXPORTED GReturn GCALL GProgramDownload(GCon g, GCStringIn program, GCStringIn preprocessor)
Downloads a program to the controller's program buffer.
GCLIB_DLL_EXPORTED GReturn GCALL GInfo(GCon g, GCStringOut info, GSize info_len)
Uses GUtility() and G_UTIL_INFO to provide a useful connection string.
GCLIB_DLL_EXPORTED GReturn GCALL GAddresses(GCStringOut addresses, GSize addresses_len)
Uses GUtility(), G_UTIL_GCAPS_ADDRESSES or G_UTIL_ADDRESSES to provide a listing of all available con...
GCLIB_DLL_EXPORTED GReturn GCALL GOpen(GCStringIn address, GCon *g)
Open a connection to a Galil Controller.
void e(GReturn rc)
A trivial, C++ style return code check used in Galil's examples and demos.
GReturn message(GCon g)
Demonstrates how to receive messages from the controller and detect differences in Trace and crashed ...
GReturn vector(GCon g, char *file)
Puts controller into Vector Mode and accepts a file defining vector points.