Class Device

All Implemented Interfaces:
Runnable
Direct Known Subclasses:
BeltCashboxDrawer, Biometrics

public class Device extends JposDevice implements Runnable
JposDevice based implementation base for JavaPOS device service implementations for the sample device implemented in SampleUdpDevice.tcl. It implements methods, properties and interfaces that can be used for server class implementations.

All frames have variable length and start with a SUBDEV:Function where SUBDEV is a sub-device specific id (e.g. DRAWER) and Function the name of a sub-device specific function to be processed. The corresponding response starts with the same SUBDEV:Function pair.
Communication will be made with UDP sockets. Multiple commands can be sent in a single frame, separated by comma (,). The corresponding responses will be sent in one frame, separated by comma as well.

Here a full list of all device specific properties that can be changed via jpos.xml:

  • MaxRetry: Specifies the maximum number of retries. Default: 2.
  • OwnPort: Integer value between 0 and 65535 specifying the UDP port used for communication with the device simulator. Default: 0 (for random port number selected by operating system).
  • PollDelay: Minimum time between status requests, in milliseconds. Status requests will be used to monitor the device state. Default: 200.
  • Port: Operating system specific name of the UDP address to be used for communication with the device simulator. Names are of the form IPv4:port, where IPv4 is the IP address of the device and port its UDP port.
  • RequestTimeout: Maximum time, in milliseconds, between sending a command to the simulator and getting the first byte of its response. Default: 200.
  • UseClientIO: Specifies whether UdpClientIOProcessor or UdpIOProcessor shall be used for communication. If true, UdpClientIOProcessor will be used, otherwise UdpIOProcessor. Default: true.
  • Field Details

    • Toolsets

      public Device.CommonSubDeviceToolset[] Toolsets
      List of ReturnValueCheckers to be used by a specific device implementation for the UDP sample
  • Constructor Details

    • Device

      protected Device(String id)
      Constructor. id specifies the server to be connected in format host:port.
      Parameters:
      id - IPv4 target address and port
  • Method Details

    • checkProperties

      public void checkProperties(jpos.config.JposEntry entry) throws jpos.JposException
      Description copied from class: JposBaseDevice
      Checks whether a JposEntry belongs to a predefined property value an if so, sets the corresponding driver value
      Overrides:
      checkProperties in class JposBaseDevice
      Parameters:
      entry - Entry to be checked, contains value to be set
      Throws:
      jpos.JposException - if a property value is invalid
    • sendResp

      protected String sendResp(String command)
      Sends a single command to the device and returns the response on success. In case of a recoverable error, maximum MaxRetry to send the command will be made.
      Parameters:
      command - Command to be sent to the device.
      Returns:
      Return parameters of the response on success, otherwise null.
    • sendResp

      protected String[] sendResp(String[] commandParts)
      Sends multiple commands to the device and returns the responses on success. In case of a recoverable error, maximum MaxRetry to send the commands will be made.
      On success, the response values will be returned within a String array of the same length as the array of commands passed as method parameter.
      Parameters:
      commandParts - Array of commands to be sent to the device.
      Returns:
      Array of return parameters of the corresponding responses on success, otherwise null.
    • run

      public void run()
      Specified by:
      run in interface Runnable