Package inputOutput

Class OpenIGTLinkConnection

java.lang.Object
inputOutput.OpenIGTLinkConnection
All Implemented Interfaces:
IOpenIgtPacketListener

public class OpenIGTLinkConnection extends Object implements IOpenIgtPacketListener
builds a connection based on OpenIGTLink for tracking data and image data. As a prerequisite MITK v2016.11 has to run in the background. The connection is established by using the online stream.
  • Field Details

    • fps

      public long fps
  • Constructor Details

    • OpenIGTLinkConnection

      public OpenIGTLinkConnection()
      This constructor establishes a connection to a OpenIGTLink server using the default ip-address and port.
    • OpenIGTLinkConnection

      public OpenIGTLinkConnection(String ip, int port)
      An IP-address and a port number is needed for the connection. Here both are set through the constructor.
      Parameters:
      ip -
      port -
  • Method Details

    • setIp

      public void setIp(String ip)
    • setPort

      public void setPort(int port)
    • onRxImage

      public void onRxImage(String name, ImageMessage image)
      This method is receiving an image as ImageMessage from the server, while it is running in the background during the connection. After getting an ImageMessage, the setImageMessage(ImageMessage img) method is called in order to set the received ImageMessage and the body of ImageMessage is unpacked in order to get the image data, which is also set by calling setImageData(byte[] imgData). The framerate is also determined here.
      Specified by:
      onRxImage in interface IOpenIgtPacketListener
      Parameters:
      name - A string of what type of data to get
      image - the image
    • getImageMessage

      public ImageMessage getImageMessage()
      This method is for getting the current ImageMessage.
      Returns:
      ImageMessage
    • setImageMessage

      public void setImageMessage(ImageMessage img)
      This method is for setting an ImageMessage.
    • setImageDataByte

      public void setImageDataByte(byte[] imgData)
      This method is for setting an image data in the form of a byte.
    • getImageDataByte

      public byte[] getImageDataByte()
      This method is for getting the current image data.
      Returns:
      It returns the image data as a byte[]
    • stop

      public boolean stop()
      This method is for stopping the connection (the client).
      Returns:
      client.isInterrupted() is true if closing the connection was successful
    • isConnected

      public boolean isConnected()
      This method is for checking the connection while the application is running.
      Returns:
      isConnected
    • onRxTransform

      public void onRxTransform(String name, TransformNR t)
      Description copied from interface: IOpenIgtPacketListener
      This method will be called by the IGT server when a transform is received. Supports: TRANSFORM QTRANS QTRANSFORM POSITION
      Specified by:
      onRxTransform in interface IOpenIgtPacketListener
      Parameters:
      name - The string in the 'NAME' field of the IGT packet
      t -
    • getToolDataList

      public List<OpenIGTLinkConnection.ToolData> getToolDataList()
    • parseXMLStringMessage

      public static void parseXMLStringMessage(String msg)
    • getTxTransform

      public TransformNR getTxTransform(String name)
      The methods below are not used during a connection over MITK
      Specified by:
      getTxTransform in interface IOpenIgtPacketListener
      Parameters:
      name - A string of what type of transform to get
      Returns:
      the requested transform
    • onGetStatus

      public Status onGetStatus(String name)
      Description copied from interface: IOpenIgtPacketListener
      Request for status from IGT/Slicer
      Specified by:
      onGetStatus in interface IOpenIgtPacketListener
      Parameters:
      name - A string of what type of transform to get
      Returns:
      the requested status
    • onRxString

      public void onRxString(String name, String body)
      Description copied from interface: IOpenIgtPacketListener
      This is the handler for a String packet
      Specified by:
      onRxString in interface IOpenIgtPacketListener
      Parameters:
      name - A string of what type of data to get
      body - A string of the content
    • onTxString

      public String onTxString(String name)
      Description copied from interface: IOpenIgtPacketListener
      This is the request handler for a String packet
      Specified by:
      onTxString in interface IOpenIgtPacketListener
      Parameters:
      name - A string of what type of transform to get
    • onRxDataArray

      public void onRxDataArray(String name, Matrix3D data)
      Description copied from interface: IOpenIgtPacketListener
      This is the handler for an array of raw data in an array
      Specified by:
      onRxDataArray in interface IOpenIgtPacketListener
      Parameters:
      name - A string of what type of data to get
      data - An array of data
    • onTxDataArray

      public double[] onTxDataArray(String name)
      Description copied from interface: IOpenIgtPacketListener
      THis is a request for an array of data
      Specified by:
      onTxDataArray in interface IOpenIgtPacketListener
      Parameters:
      name - A string of what type of data to get
      Returns:
      an array of data
    • onTxNDArray

      public void onTxNDArray(String name)
      Description copied from interface: IOpenIgtPacketListener
      THis is a request for an array of data
      Specified by:
      onTxNDArray in interface IOpenIgtPacketListener
      Parameters:
      name - A string of what type of data to get returns an array of data
    • onRxNDArray

      public void onRxNDArray(String name, float[] data)
      Description copied from interface: IOpenIgtPacketListener
      THis is a request for an array of data
      Specified by:
      onRxNDArray in interface IOpenIgtPacketListener
      Parameters:
      name - A string of what type of data to get returns an array of data