|
| | Controller (std::string address) |
| | Open a connection to a controller reported by addresses().
|
| | Controller (std::string address, size_t baud_rate) |
| | Open a serial connection to a controller reported by addresses().
|
| | ~Controller () |
| void | open () |
| | Open the connection. If connection is already open, it will be closed and reopened.
|
| void | close () |
| std::string | address () |
| | Returns the address that was used to connect to the controller.
|
| ConnectionType | connection_type () |
| | Returns the type of address that was used to connect to the controller.
|
| std::string | revision_information () |
| | Returns controller ^R^V output.
|
| uint32_t | serial_number () |
| template<typename T = std::string> |
| T | command (std::string command) |
| | Issues a command to the controller and provides the response.
|
| std::string | program () |
| void | set_program (std::string program, std::string insert="") |
| std::string | array (std::string name, size_t start=0, size_t end=0) |
| void | set_array (std::string name, std::string array, size_t start=0, size_t end=0) |
| void | set_firmware (std::string file_path) |
| void | set_interrupts (Interrupt::Type mask, std::bitset< 8 > motion_complete_axes=0, std::bitset< 8 > digital_inputs=0) |
| | Configure which interrupts will be generated by the controller.
|
| void | set_data_records (size_t period_ms) |
| | Configure controller data records.
|
| void | subscribe_messages (std::function< void(std::string message)> callback) |
| | Subscribe to unsolicited messages.
|
| void | subscribe_messages () |
| | Subscribe to unsolicited messages.
|
| void | subscribe_interrupts (std::function< void(Interrupt interrupt)> callback) |
| | Subscribe to interrupts.
|
| void | subscribe_interrupts () |
| | Subscribe to interrupts.
|
| void | subscribe_data_records (std::function< void(DataRecord data_record)> callback) |
| | Subscribe to data records.
|
| void | subscribe_data_records () |
| | Subscribe to data records.
|
| void | subscribe_progress (std::function< void(size_t current, size_t max)> callback) |
| | Register a progress callback.
|
| void | unsubscribe_messages () |
| void | unsubscribe_interrupts () |
| void | unsubscribe_data_records () |
| void | unsubscribe_progress () |
| std::string | message (int timeout=-1) |
| Interrupt | interrupt (int timeout=-1) |
| DataRecord | data_record (int timeout=-1) |
Manages a connection to a controller.
Definition at line 303 of file gclib.hpp.
template<typename T = std::string>
| T command |
( |
std::string | command | ) |
|
|
inline |
Issues a command to the controller and provides the response.
Note that a single command cannot be longer than 80 characters, similar to a program line.
- Parameters
-
| command | Command to be sent to the controller. Will be terminated with a carriage return. |
- Returns
- The controller response.
Definition at line 345 of file gclib.hpp.
| void set_interrupts |
( |
Interrupt::Type | mask, |
|
|
std::bitset< 8 > | motion_complete_axes = 0, |
|
|
std::bitset< 8 > | digital_inputs = 0 ) |
|
inline |
Configure which interrupts will be generated by the controller.
By default, the controller will not generate any interrupts.
Controllers can be configured to send only an exact list of desired interrupts, to avoid unnecessary processing and network traffic.
Example usage:
controller.set_interrupts(AllInterrupts);
controller.set_interrupts(
MotionComplete | DigitalInputLow,
{0, 7},
{0, 3});
controller.set_interrupts();
See subscribe_interrupts() to enable receiving interrupts from the controller.
- Parameters
-
| interrupt_mask | Bitmask of desired interrupts. Use ::NoInterrupts (0) to disable interrupts. Note that User Interrupts cannot be disabled. |
| axis_mask | When ::MotionComplete is in interrupt_mask, this axis mask controls which axes will trigger a ::MotionComplete interrupt. If 0 (default), all axes will be selected. |
| digital_input_mask | When ::DigitalInputLow is in interrupt_mask, this bitmask selects which digital inputs will trigger an interrupt. If 0 (default), all digital inputs will be selected. |
Definition at line 390 of file gclib.hpp.
| void subscribe_messages |
( |
std::function< void(std::string message)> | callback | ) |
|
|
inline |
Subscribe to unsolicited messages.
This method registers a callback to be run every time an unsolicited message is received from the controller.
- Note
- The callback will be invoked on a separate, dedicated thread. Be careful when accessing any shared state.
On ethernet connections, a handle is opened for unsolicited data (if not already open) and the controller is configured to use it for messages.
- Parameters
-
| callback | A callback function, which will be invoked each time a message arrives. Replaces any previously set message callback. |
Definition at line 420 of file gclib.hpp.
| void subscribe_messages |
( |
| ) |
|
|
inline |
Subscribe to unsolicited messages.
This method begins queueing unsolicited messages for later retrieval by message().
On ethernet connections, a handle is opened for unsolicited data (if not already open) and the controller is configured to use it for messages.
Definition at line 433 of file gclib.hpp.
| void subscribe_interrupts |
( |
| ) |
|
|
inline |
Subscribe to interrupts.
This method begins queueing unsolicited interrupts for later retrieval by interrupt().
See set_interrupts() to enable and configure controller interrupts.
On ethernet connections, a handle is opened for unsolicited data (if not already open) and the controller is configured to use it for interrupts.
Definition at line 469 of file gclib.hpp.
Subscribe to data records.
This method registers a callback to be run every time a data record is received from the controller. See set_data_records() to enable data records and configure how often they will be generated by the controller.
- Note
- The callback will be invoked on a separate, dedicated thread. Be careful when accessing any shared state.
On ethernet connections, a handle is opened for unsolicited data (if not already open) and the controller is configured to use it for data records.
- Parameters
-
| callback | A callback function, which will be invoked each time a data record arrives. Replaces any previously set message callback. |
Definition at line 489 of file gclib.hpp.
| void subscribe_data_records |
( |
| ) |
|
|
inline |
Subscribe to data records.
This method begins queueing unsolicited interrupts for later retrieval by data_record().
On ethernet connections, a handle is opened for unsolicited data (if not already open) and the controller is configured to use it for data records.
Definition at line 502 of file gclib.hpp.