gclib 2.0.9
Communications API for Galil controllers and PLCs
 
Loading...
Searching...
No Matches
vector_mode.cs
Go to the documentation of this file.
1
10using System.IO;
12
13namespace examples
14{
15 public static partial class Examples
16 {
44
45 public static int Vector_Mode(gclib gclib, string file)
46 {
47 gclib.GCommand("ST"); // Stop all motors
48 gclib.GCommand("SH AB"); // Set servo here
49 gclib.GCommand("DP 0,0"); // Start position at absolute zero
50
51 gclib.GCommand("CAS"); // Defines S as active coordinate system
52 gclib.GCommand("VS 20000"); // Defines vector speed
53 gclib.GCommand("VA 200000"); // Defines vector acceleration
54 gclib.GCommand("VD 200000"); // Defines vector decelerlation
55 gclib.GCommand("VM AB"); // Begin vector segment
56
58 {
59 //Stores the available space of the vector buffer in the capacity variable
60 int capacity = gclib.GCmdI("MG _LMS");
61 Load_Buffer(gclib, reader, capacity);
62
63 gclib.GCommand("BG S");
64
65 do // Load buffer with more commands
66 {
67 Thread.Sleep(100);
68
69 //Stores the available space of the vector buffer in the capacity variable
70 capacity = gclib.GCmdI("MG _LMS");
71 } while (Load_Buffer(gclib, reader, capacity));
72 }
73
74 gclib.GCommand("VE"); // Segment End
76
77 return GALIL_EXAMPLE_OK;
78 }
79
80 private static bool Load_Buffer(gclib gclib, StreamReader reader, int capacity)
81 {
82 string s_cmd;
83 // Fully load the vector buffer leaving room for one VE command
84 for (; capacity > 1; capacity--)
85 {
86 // If there is another line of the text file
87 if ((s_cmd = reader.ReadLine()) != null)
88 {
89 // Run the command on each line of the text file
91 }
92 else
93 return false;
94 }
95
96 return true;
97 }
99 }
100}
const int GALIL_EXAMPLE_OK
Examples success code.
Definition examples.cs:29
string GCommand(string Command, bool Trim=true)
Used for command-and-response transactions.
Definition gclib.cs:257
void GMotionComplete(string axes)
Blocking call that returns once all axes specified have completed their motion.
Definition gclib.cs:428
Int16 GCmdI(string Command)
Used for command-and-response transactions.
Definition gclib.cs:288
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 Vector_Mode(gclib gclib, string file)
Puts controller into Vector Mode and accepts a file defining vector points.
partial Module Examples
Definition Commands.vb:4