gclib examples  0
Example Projects for the Communications API for Galil controllers and PLCs
commands_example.cpp File Reference
#include "examples.h"
#include <iostream>

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 Main function for Commands Example.
 

Detailed Description

See commands() for implementation of logic

Concepts

This example demonstrates:

  • How to connect to a controller via IP Address.
  • How to issue basic commands.
  • How to read data back from the controller.
  • How to get context on errors that occur in the program.

Prerequisites

A Galil controller is required for this example.

Example Output

`*****************************************************************************`
`************************** GCmdT() example *****************************`
`*****************************************************************************`
GCmdT() will return a trimmed response of GCommand()
The command 'PR ?,?' will return the relative position of the A and B axes
<<PR ?,? with GCommand(): 0, 10000
:>>
<<PR ?,? with GCmdT(): 0, 10000>>
`*****************************************************************************`
`************************** GCmdI() example *****************************`
`*****************************************************************************`
GCmdI() will return the value of GCommand() parsed as an int
The command 'MG _LMS' will return the available space in the vector buffer of the S plane.
MG _LMS with GCmdT(): 511.0000
MG _LMS with GCmdI(): 511
`*****************************************************************************`
`************************** GCmd() example ******************************`
`*****************************************************************************`
GCmd() will execute the given command but does not return a value.
GCmd is useful for basic operations such as beginning motion or setting speed
GCmd(g, "BG A");
GCmd(g, "SP 5000");
`*****************************************************************************`
`************************** GCmdD() example *****************************`
`*****************************************************************************`
GCmdD() will return the value of GCommand parsed as a double
The command 'MG @AN[1]' will return the value of Analog Input 1
MG @AN[1] with GCmdD(): 9.7726
`*****************************************************************************`
`************************ Galil Double Format ***************************`
`*****************************************************************************`
Galil Controllers expect double values to be formatted to 4 decimal places
Unformatted double value: 0.00235
Formatted double value rounded to 4 decimal places: 0.0024
`*****************************************************************************`
`******************* G_UTIL_ERROR_CONTEXT example ***********************`
`*****************************************************************************`
GUtility() with G_UTIL_ERROR_CONTEXT: Broken Pipe

Definition in file commands_example.cpp.