Package com.galil
Class Gclib.Controller
java.lang.Object
org.bytedeco.javacpp.Pointer
com.galil.Gclib.Controller
- All Implemented Interfaces:
AutoCloseable
- Enclosing class:
- Gclib
@Namespace("gclib")
@NoOffset
public static class Gclib.Controller
extends org.bytedeco.javacpp.Pointer
Manages a connection to a controller.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.bytedeco.javacpp.Pointer
org.bytedeco.javacpp.Pointer.CustomDeallocator, org.bytedeco.javacpp.Pointer.Deallocator, org.bytedeco.javacpp.Pointer.NativeDeallocator, org.bytedeco.javacpp.Pointer.ReferenceCounter -
Field Summary
Fields inherited from class org.bytedeco.javacpp.Pointer
address, capacity, limit, position -
Constructor Summary
ConstructorsConstructorDescriptionController(String _address) Open a connection to a controller reported byaddresses().Controller(String _address, long baud_rate) Open a serial connection to a controller reported byaddresses(). -
Method Summary
Modifier and TypeMethodDescriptionvoid_close()\brief Issues a command to the controller and provides the response.Returns the address that was used to connect to the controller.Returns the type of address that was used to connect to the controller.dataRecord(int timeout) Get a queued data record, or wait up totimeoutms for one to arrive.interrupt(int timeout) Get a queued interrupt, or wait up totimeoutms for one to arrive.message()message(int timeout) Get a queued message, or wait up totimeoutms for one to arrive.voidopen()Open the connection.program()Returns controller^R^Voutput.longvoidvoidvoidsetDataRecords(long period_ms) \brief Configure controller data records.voidsetFirmware(String file_path) voidsetInterrupts(Gclib.Interrupt.Type interrupt_mask) voidsetInterrupts(Gclib.Interrupt.Type interrupt_mask, byte axis_mask) voidsetInterrupts(Gclib.Interrupt.Type interrupt_mask, byte axis_mask, byte digital_input_mask) \brief Configure which interrupts will be generated by the controller.voidsetProgram(String program) voidsetProgram(String program, String insert) voidvoidsubscribeDataRecords(Consumer<Gclib.DataRecord> callback) \brief Subscribe to data records.voidvoidsubscribeInterrupts(Consumer<Gclib.Interrupt> callback) \brief Subscribe to interrupts.voidvoidsubscribeMessages(Consumer<String> callback) \brief Subscribe to unsolicited messages.voidsubscribeProgress(Gclib.ProgressCallback callback) \brief Register a progress callback.voidvoidvoidvoidMethods inherited from class org.bytedeco.javacpp.Pointer
address, asBuffer, asByteBuffer, availablePhysicalBytes, calloc, capacity, capacity, close, deallocate, deallocate, deallocateReferences, deallocator, deallocator, equals, fill, formatBytes, free, getDirectBufferAddress, getPointer, getPointer, getPointer, getPointer, hashCode, interruptDeallocatorThread, isNull, isNull, limit, limit, malloc, maxBytes, maxPhysicalBytes, memchr, memcmp, memcpy, memmove, memset, offsetAddress, offsetof, offsetof, parseBytes, physicalBytes, physicalBytesInaccurate, position, position, put, realloc, referenceCount, releaseReference, retainReference, setNull, sizeof, sizeof, toString, totalBytes, totalCount, totalPhysicalBytes, trimMemory, withDeallocator, zero
-
Constructor Details
-
Controller
Open a connection to a controller reported byaddresses(). -
Controller
Open a serial connection to a controller reported byaddresses().
-
-
Method Details
-
open
public void open()Open the connection. If connection is already open, it will be closed and reopened. -
_close
@Name("close") public void _close() -
connectionAddress
Returns the address that was used to connect to the controller. -
connectionType
Returns the type of address that was used to connect to the controller. -
revisionInformation
Returns controller^R^Voutput. -
serialNumber
@Cast("uint32_t") @Name("serial_number") public long serialNumber() -
command
\brief 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.
-
program
-
setProgram
-
setProgram
-
array
-
array
-
setArray
-
setArray
-
setFirmware
-
setInterrupts
public void setInterrupts(Gclib.Interrupt.Type interrupt_mask, byte axis_mask, byte digital_input_mask) \brief 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:
Seecpp controller.set_interrupts(AllInterrupts); // Enable all interrupts. controller.set_interrupts( MotionComplete | DigitalInputLow, // Only enable two interrupts {0, 7}, // Only trigger MotionComplete on axis A or F {0, 3}); // Only trigger DigitalInputLow on digital input 1 and 4. controller.set_interrupts(); // Disable interruptssubscribe_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::MotionCompleteis ininterrupt_mask, this axis mask controls which axes will trigger a::MotionCompleteinterrupt. If0(default), all axes will be selected.digital_input_mask- When::DigitalInputLowis ininterrupt_mask, this bitmask selects which digital inputs will trigger an interrupt. If0(default), all digital inputs will be selected.
-
setInterrupts
-
setInterrupts
-
setDataRecords
@Name("set_data_records") public void setDataRecords(@Cast("size_t") long period_ms) \brief Configure controller data records. By default, data records are not sent by the controller. Seesubscribe_data_records()to enable receiving data records from the controller.- Parameters:
period_ms- Period (in milliseconds) between data records. Pass 0 (default) to disable data records.
-
subscribeMessages
\brief 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.
-
subscribeMessages
@Name("subscribe_messages") public void subscribeMessages() -
subscribeInterrupts
\brief Subscribe to interrupts. This method registers a callback to be run every time an interrupt is received from the controller. Seeset_interrupts()to enable and configure controller interrupts. > [!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 interrupts.- Parameters:
callback- A callback function, which will be invoked each time an interrupt arrives. Replaces any previously set message callback.
-
subscribeInterrupts
@Name("subscribe_interrupts") public void subscribeInterrupts() -
subscribeDataRecords
\brief Subscribe to data records. This method registers a callback to be run every time a data record is received from the controller. Seeset_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.
-
subscribeDataRecords
@Name("subscribe_data_records") public void subscribeDataRecords() -
subscribeProgress
\brief Register a progress callback. This method registers a callback to be run every time data is written to the controller during aset_firmware,set_array, orset_programcall. > [!note] > The callback will be invoked on a separate, dedicated thread. Be careful > when accessing any shared state.- Parameters:
callback- A callback function, which will be invoked each time data is written to the controller. Replaces any previously set message callback.
-
unsubscribeMessages
@Name("unsubscribe_messages") public void unsubscribeMessages() -
unsubscribeInterrupts
@Name("unsubscribe_interrupts") public void unsubscribeInterrupts() -
unsubscribeDataRecords
@Name("unsubscribe_data_records") public void unsubscribeDataRecords() -
unsubscribeProgress
@Name("unsubscribe_progress") public void unsubscribeProgress() -
message
Get a queued message, or wait up totimeoutms for one to arrive.- Parameters:
timeout- Timeout value in milliseconds. If-1, wait forever.
-
message
-
interrupt
Get a queued interrupt, or wait up totimeoutms for one to arrive.- Parameters:
timeout- Timeout value in milliseconds. If-1, wait forever.
-
interrupt
-
dataRecord
Get a queued data record, or wait up totimeoutms for one to arrive.- Parameters:
timeout- Timeout value in milliseconds. If-1, wait forever.
-
dataRecord
-