| gclib 1.32.6 Communications API for Galil controllers and PLCs |

motion_complete_example.cs
Go to the documentation of this file.
1
10 using System;
11 using System.Linq;
12
13 namespace examples
14 {
22
23 class Motion_Complete_Example
24 {
31 public static int Main(string[] args)
32 {
33 int rc = Examples.GALIL_EXAMPLE_OK;
34 gclib gclib = new gclib();
35
36 try
37 {
38 if(args.Count() != 1)
39 {
40 Console.WriteLine("Incorrect number of arguments provided");
41 Console.WriteLine("Usage: motion_complete_exmample.exe <ADDRESS>");
42
43 Console.Write("\nPress any key to close the example");
44 Console.ReadKey();
45 return Examples.GALIL_EXAMPLE_ERROR;
46 }
47
48 //Retrieves address from the command line
49 string address = args[0];
50
51 //Open a connection at the provided address and subcribe to event interrupts
52 gclib.GOpen(address + " --subscribe EI");
53
54 //Uses interrupts to track when the motion of the controller is completed
55 rc = Examples.Motion_Complete(gclib);
56 }
57 catch(Exception ex)
58 {
59 Examples.PrintError(gclib, ex);
60 rc = Examples.GALIL_EXAMPLE_ERROR;
61 }
62 finally
63 {
64 gclib.GClose();
65 }
66
67 Console.Write("\nPress any key to close the example");
68 Console.ReadKey();
69
70 return rc;
71 }
72 }
74 }
examples.Examples.PrintError
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
examples.Examples
Provides a class of shared constants and methods for gclib's example projects.
Definition: commands.cs:16
examples.Examples.GALIL_EXAMPLE_OK
const int GALIL_EXAMPLE_OK
Examples success code.
Definition: examples.cs:29
examples.Examples.GALIL_EXAMPLE_ERROR
const int GALIL_EXAMPLE_ERROR
Examples error code.
Definition: examples.cs:30
examples.Motion_Complete_Example.Main
static int Main(string[] args)
Main function for the Motion Complete example.
Definition: motion_complete_example.cs:31
examples.Motion_Complete_Example
Uses controller interrupts to detect when motion is complete.
Definition: motion_complete_example.cs:24
examples.Examples.Motion_Complete
static int Motion_Complete(gclib gclib)
Uses interrupts to track when the motion of controller is completed.
Definition: motion_complete.cs:26
examples
Definition: commands.cs:14