Class DAServer

All Implemented Interfaces:
Device, Configurable, Findable, gda.observable.IObservable
Direct Known Subclasses:
DummyDAServer

public class DAServer extends DeviceBase
Provides Ethernet communications with OS9/Linux DAServer
  • Field Details

  • Constructor Details

    • DAServer

      public DAServer()
  • Method Details

    • setHost

      public void setHost(String host)
      Set the host on which da.server is running
      Parameters:
      host -
    • getHost

      public String getHost()
      Returns:
      the host name on which da.server is running
    • setPort

      public void setPort(int port)
      Set the port on which da.server is listening
      Parameters:
      port -
    • getPort

      public int getPort()
      Returns:
      the port on which da.server is listening
    • setDataPort

      public void setDataPort(int dataPort)
      Set the data port on which da.server can make socket connection back to this.
      Parameters:
      dataPort -
    • getDataPort

      public int getDataPort()
      Returns:
      Get the data port on which da.server can make socket connection back to this.
    • setStartupCommands

      public void setStartupCommands(ArrayList<String> startupCommands)
      Parameters:
      startupCommands -
    • getStartupCommands

      public ArrayList<String> getStartupCommands()
      Returns:
      an array list of startup commands to be processed by da.server on startup
    • getReplyTimeOut

      public long getReplyTimeOut()
      Returns:
      Returns the replyTimeOut.
    • setReplyTimeOut

      public void setReplyTimeOut(long replyTimeOut)
      Parameters:
      replyTimeOut - Set the replyTimeOut in msec. This is the time before we give up on da.Server
    • configure

      public void configure() throws FactoryException
      Description copied from class: ConfigurableBase
      Default implementation for classes that do not have to do any specific configuration.
      Classes that do their own configuration should *not* call this superclass function, as it may cause the object to appear configured before it really is.
      Specified by:
      configure in interface Configurable
      Overrides:
      configure in class ConfigurableBase
      Throws:
      FactoryException - if there is an error in configuration e.g. required variable not set or cannot connect to device
    • reconfigure

      public void reconfigure() throws FactoryException
      Description copied from interface: Configurable
      Re-initialisation of values and states.

      Moved from Reconfigurable which has been deleted

      Specified by:
      reconfigure in interface Configurable
      Overrides:
      reconfigure in class ConfigurableBase
      Throws:
      FactoryException
    • connect

      public void connect()
    • reconnect

      public void reconnect() throws DeviceException
      Tidy existing socket streams and try to connect them again within the thread. This method is synchronized as both the main thread and run thread use this method.
      Throws:
      DeviceException
    • close

      public void close() throws DeviceException
      Close and unconfigure the device. tidy up all streams before ending program
      Specified by:
      close in interface Device
      Overrides:
      close in class DeviceBase
      Throws:
      DeviceException
      See Also:
    • isConnected

      public boolean isConnected()
      Returns the state of the socket connection
      Returns:
      true if connected
    • sendCommand

      public Object sendCommand(String msg, int timeout) throws DeviceException
      Send command to the server and specify a timeout on this command
      Parameters:
      msg - an unterminated command
      timeout - value in milliseconds
      Returns:
      the reply which may be integer or string.
      Throws:
      DeviceException
    • sendCommand

      public Object sendCommand(String msg) throws DeviceException
      Throws:
      DeviceException
    • sendCommand

      public Object sendCommand(String msg, Boolean multiline) throws DeviceException
      Send command to the server.
      Parameters:
      msg - an unterminated command
      Returns:
      the reply which may be integer or string.
      Throws:
      DeviceException
    • getData

      public Object[] getData(String msg) throws Exception
      Get data from the server.
      Parameters:
      msg - an unterminated command
      Returns:
      returns data as an array of string objects.
      Throws:
      Exception
    • getBinaryDataBuffer

      protected ByteBuffer getBinaryDataBuffer(String command, int ndata) throws Exception
      Throws:
      Exception
    • getBinaryData

      public double[] getBinaryData(String message, int ndata) throws Exception
      Get binary data from the server and transform to double
      Parameters:
      message - an unterminated command
      ndata - number of data values to fetch.
      Returns:
      returns data as an array.
      Throws:
      Exception
    • getFloatBinaryData

      public float[] getFloatBinaryData(String message, int ndata) throws Exception
      Get binary data from the server as float
      Parameters:
      message - an unterminated command
      ndata - number of data values to fetch.
      Returns:
      returns data as an array.
      Throws:
      Exception
    • getLongBinaryData

      public long[] getLongBinaryData(String message, int ndata) throws Exception
      Get binary data from the server and transform to long (64bit) *
      Parameters:
      message - an unterminated command
      ndata - number of data values to fetch.
      Returns:
      returns data as an array.
      Throws:
      Exception
    • getIntBinaryData

      public int[] getIntBinaryData(String message, int ndata) throws Exception
      Get binary data from the server and transform to int[] (32bit)
      Parameters:
      message - an unterminated command
      ndata - number of data values to fetch.
      Returns:
      returns data as an array.
      Throws:
      Exception
    • test

      public void test() throws Exception
      test method
      Throws:
      Exception