gclib 2.0.9
Communications API for Galil controllers and PLCs
 
Loading...
Searching...
No Matches
position_tracking_example.cs
Go to the documentation of this file.
1
10using System;
11using System.Linq;
12
13namespace examples
14{
25
27 {
36 public static int Main(string[] args)
37 {
39 gclib gclib = new gclib();
40
41 try
42 {
43 int speed = 0;
44
45 if(args.Count() == 1)
46 {
47 speed = 5000;
48 }
49 else if(args.Count() == 2)
50 {
51 bool ok = int.TryParse(args[1], out speed);
52
53 if(!ok)
54 {
55 Console.WriteLine("An invalid speed was entered. " +
56 "Please enter a valid integer for speed.");
57 Console.WriteLine("Usage: position_tracking_example.exe <ADDRESS> <SPEED=5000>");
58
59 Console.Write("\nPress any key to close the example");
60 Console.ReadKey();
62 }
63 }
64 else
65 {
66 Console.WriteLine("Incorrect number of arguments provided");
67 Console.WriteLine("Usage: position_tracking_example.exe <ADDRESS> <SPEED=5000>");
68
69 Console.Write("\nPress any key to close the example");
70 Console.ReadKey();
72 }
73
74 string address = args[0]; //Retrieve address from command line
75 gclib.GOpen(address); // Open a connection at the provided address
76
77 rc = Examples.Position_Tracking(gclib, speed); // Begin position tracking mode
78 }
79 catch(Exception ex)
80 {
83 }
84 finally
85 {
86 gclib.GClose();
87 }
88
89 Console.Write("\nPress any key to close the example");
90 Console.ReadKey();
91
92 return rc;
93 }
94 }
96}
const int GALIL_EXAMPLE_OK
Examples success code.
Definition examples.cs:29
const int GALIL_EXAMPLE_ERROR
Examples error code.
Definition examples.cs:30
static void PrintError(gclib gclib, Exception ex)
Prints the exception to the console and queries the controller for the most recent error message.
Definition examples.cs:39
Provides a class of shared constants and methods for gclib's example projects.
Definition commands.cs:16
static int Main(string[] args)
Main function for the position tracking example.
Places controller into position tracking mode. Accepts user-defined positional values at the command ...
void GOpen(string address)
Used to open a connection to Galil hardware.
Definition gclib.cs:445
void GClose()
Used to close a connection to Galil hardware.
Definition gclib.cs:239
Provides a class that binds to gclib's unmanaged dll. Wraps each call and provides a more user-friend...
Definition gclib.cs:68
GReturn vector(GCon g, char *file)
Puts controller into Vector Mode and accepts a file defining vector points.
Definition vector.cpp:36
static int Position_Tracking(gclib gclib, int speed)
Puts controller into Position Tracking Mode and accepts user-entered positions.