Class VABBaSyxTCPInterface<ModelProvider extends org.eclipse.basyx.vab.modelprovider.api.IModelProvider>

  • All Implemented Interfaces:
    java.lang.Runnable

    public class VABBaSyxTCPInterface<ModelProvider extends org.eclipse.basyx.vab.modelprovider.api.IModelProvider>
    extends java.lang.Thread
    Provider class that enables access to an IModelProvider via native BaSyx protocol. Taken over from BaSyx to be able to run BaSyx with JDK 8.
    Author:
    kuhn, pschorn
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.lang.Thread

        java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static byte BASYX_CREATE
      BaSyx create command.
      static byte BASYX_DELETE
      BaSyx delete command.
      static byte BASYX_GET
      BaSyx get command.
      static byte BASYX_INVOKE
      BaSyx invoke command.
      static byte BASYX_RESULT_OK
      BaSyx result 'OK' : 0x00.
      static byte BASYX_SET
      BaSyx set command.
      protected java.nio.channels.SocketChannel commChannel
      Socket communication channel.
      private static org.slf4j.Logger logger  
      protected org.eclipse.basyx.vab.coder.json.provider.JSONProvider<ModelProvider> providerBackend
      Reference to IModelProvider backend.
      • Fields inherited from class java.lang.Thread

        MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
    • Constructor Summary

      Constructors 
      Constructor Description
      VABBaSyxTCPInterface​(ModelProvider modelProviderBackend, java.nio.channels.SocketChannel channel)
      Constructor that accepts an already created server socket channel.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void processInputFrame​(byte[] rxFrame)
      Process input frame.
      protected void readBytes​(java.nio.ByteBuffer bytes, int expectedBytes)
      Read a number of bytes.
      void run()
      Thread main function.
      private void sendResponseFrame​(java.io.ByteArrayOutputStream byteArrayOutput)
      Sends a response to the client that carries the JSON response.
      private void sendResponseFrame​(java.io.ByteArrayOutputStream byteArrayOutput, int result)
      Sends a response to the client that carries the JSON response.
      • Methods inherited from class java.lang.Thread

        activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • BASYX_CREATE

        public static final byte BASYX_CREATE
        BaSyx create command.
        See Also:
        Constant Field Values
      • BASYX_DELETE

        public static final byte BASYX_DELETE
        BaSyx delete command.
        See Also:
        Constant Field Values
      • BASYX_INVOKE

        public static final byte BASYX_INVOKE
        BaSyx invoke command.
        See Also:
        Constant Field Values
      • BASYX_RESULT_OK

        public static final byte BASYX_RESULT_OK
        BaSyx result 'OK' : 0x00.
        See Also:
        Constant Field Values
      • logger

        private static org.slf4j.Logger logger
      • providerBackend

        protected org.eclipse.basyx.vab.coder.json.provider.JSONProvider<ModelProvider extends org.eclipse.basyx.vab.modelprovider.api.IModelProvider> providerBackend
        Reference to IModelProvider backend.
      • commChannel

        protected java.nio.channels.SocketChannel commChannel
        Socket communication channel.
    • Constructor Detail

      • VABBaSyxTCPInterface

        public VABBaSyxTCPInterface​(ModelProvider modelProviderBackend,
                                    java.nio.channels.SocketChannel channel)
        Constructor that accepts an already created server socket channel.
        Parameters:
        modelProviderBackend - model provider backend
        channel - channel
    • Method Detail

      • processInputFrame

        public void processInputFrame​(byte[] rxFrame)
                               throws java.io.IOException
        Process input frame.
        Parameters:
        rxFrame - received frame
        Throws:
        java.io.IOException - if I/O operations fail
      • sendResponseFrame

        private void sendResponseFrame​(java.io.ByteArrayOutputStream byteArrayOutput)
                                throws java.io.IOException
        Sends a response to the client that carries the JSON response.
        Parameters:
        byteArrayOutput - the output
        Throws:
        java.io.IOException - in case of I/O exceptions
      • sendResponseFrame

        private void sendResponseFrame​(java.io.ByteArrayOutputStream byteArrayOutput,
                                       int result)
                                throws java.io.IOException
        Sends a response to the client that carries the JSON response.
        Parameters:
        byteArrayOutput - the output
        result - the result
        Throws:
        java.io.IOException - in case of I/O exceptions
      • readBytes

        protected void readBytes​(java.nio.ByteBuffer bytes,
                                 int expectedBytes)
                          throws java.io.IOException
        Read a number of bytes.
        Parameters:
        bytes - the buffer to read from
        expectedBytes - the expected bytes
        Throws:
        java.io.IOException - if the information cannot be read
      • run

        public void run()
        Thread main function.
        Specified by:
        run in interface java.lang.Runnable
        Overrides:
        run in class java.lang.Thread