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.
  • Constructor Details

    • Controller

      public Controller(@StdString String _address)
      Open a connection to a controller reported by addresses().
    • Controller

      public Controller(@StdString String _address, @Cast("size_t") long baud_rate)
      Open a serial connection to a controller reported by addresses().
  • 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

      @StdString @Name("address") public String connectionAddress()
      Returns the address that was used to connect to the controller.
    • connectionType

      @Name("connection_type") public Gclib.ConnectionType connectionType()
      Returns the type of address that was used to connect to the controller.
    • revisionInformation

      @StdString @Name("revision_information") public String revisionInformation()
      Returns controller ^R^V output.
    • serialNumber

      @Cast("uint32_t") @Name("serial_number") public long serialNumber()
    • command

      @StdString @Name("command<std::string>") public String command(@StdString String 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

      @StdString public String program()
    • setProgram

      @Name("set_program") public void setProgram(@StdString String program, @StdString String insert)
    • setProgram

      @Name("set_program") public void setProgram(@StdString String program)
    • array

      @StdString public String array(@StdString String name, @Cast("size_t") long start, @Cast("size_t") long end)
    • array

      @StdString public String array(@StdString String name)
    • setArray

      @Name("set_array") public void setArray(@StdString String name, @StdString String array, @Cast("size_t") long start, @Cast("size_t") long end)
    • setArray

      @Name("set_array") public void setArray(@StdString String name, @StdString String array)
    • setFirmware

      @Name("set_firmware") public void setFirmware(@StdString String file_path)
    • 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:
      cpp
       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 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.
    • setInterrupts

      public void setInterrupts(Gclib.Interrupt.Type interrupt_mask, byte axis_mask)
    • setInterrupts

      public void setInterrupts(Gclib.Interrupt.Type interrupt_mask)
    • 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. See subscribe_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

      public void subscribeMessages(Consumer<String> callback)
      \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

      public void subscribeInterrupts(Consumer<Gclib.Interrupt> callback)
      \brief Subscribe to interrupts. This method registers a callback to be run every time an interrupt is received from the controller. See set_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

      public void subscribeDataRecords(Consumer<Gclib.DataRecord> callback)
      \brief 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.
    • subscribeDataRecords

      @Name("subscribe_data_records") public void subscribeDataRecords()
    • subscribeProgress

      @Name("subscribe_progress") public void subscribeProgress(@ByVal Gclib.ProgressCallback callback)
      \brief Register a progress callback. This method registers a callback to be run every time data is written to the controller during a set_firmware, set_array, or set_program call. > [!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

      @StdString public String message(int timeout)
      Get a queued message, or wait up to timeout ms for one to arrive.
      Parameters:
      timeout - Timeout value in milliseconds. If -1, wait forever.
    • message

      @StdString public String message()
    • interrupt

      @ByVal public Gclib.Interrupt interrupt(int timeout)
      Get a queued interrupt, or wait up to timeout ms for one to arrive.
      Parameters:
      timeout - Timeout value in milliseconds. If -1, wait forever.
    • interrupt

      @ByVal public Gclib.Interrupt interrupt()
    • dataRecord

      @ByVal @Name("data_record") public Gclib.DataRecord dataRecord(int timeout)
      Get a queued data record, or wait up to timeout ms for one to arrive.
      Parameters:
      timeout - Timeout value in milliseconds. If -1, wait forever.
    • dataRecord

      @ByVal @Name("data_record") public Gclib.DataRecord dataRecord()