gclib  1.36.3
Communications API for Galil controllers and PLCs
record_position_example.cs
Go to the documentation of this file.
1 
10 using System;
11 using System.Linq;
12 
13 namespace examples
14 {
26 
28  {
38  public static int Main(string[] args)
39  {
40  int rc = Examples.GALIL_EXAMPLE_OK;
41  gclib gclib = new gclib();
42 
43  try
44  {
45  if(args.Count() != 3)
46  {
47  Console.WriteLine("Incorrect number of arguments provided");
48  Console.WriteLine("Usage: record_position_example.exe <ADDRESS> <FILE A> <FILE B>");
49 
50  Console.Write("\nPress any key to close the example");
51  Console.ReadKey();
53  }
54 
55  string address = args[0]; //Retrieve address from command line
56  string fileA = args[1]; //Retrieve filepath from command line
57  string fileB = args[2]; //Retrieve filepath from command line
58 
59  gclib.GOpen(address); //Opens connection at the provided address
60 
61  //Record user's training and saves to a text file
62  rc = Examples.Record_Position(gclib, fileA, fileB);
63  }
64  catch(Exception ex)
65  {
66  Examples.PrintError(gclib, ex);
68  }
69  finally
70  {
71  gclib.GClose();
72  }
73 
74  Console.Write("\nPress any key to close the example");
75  Console.ReadKey();
76 
77  return rc;
78  }
79  }
81 }
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
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 int Main(string[] args)
Main function for the Record Position example.
Takes two file paths at the command line to hold positional data for Axis A and Axis B....
static int Record_Position(gclib gclib, string fileA, string fileB)
Record user's training and saves to a text file.