Class Device


public class Device extends JposDevice
Base of a JposDevice based implementation of JavaPOS CashDrawer and POSPrinter device service implementations for the sample device implemented in SamplePrinterSimulator.tcl. For a complete list of possible commands and responses, look at the comments at the beginning of the device simulator script.

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

  • AdjustLineChars: Specifies whether setting RecLineChars sets RecLineChars to the given value (false) or to the maximum value allowed for the largest font that can print the specified number of characters per line. Default: true.
  • AsyncProcessingCommandDelay: Delay between asynchronous commands in milliseconds . May be helpful for testing. Default: 0.
  • Baudrate: Baud rate of the communication device. Must be one of the baud rate constants specified in the SerialIOProcessor class. Default: 9600 (SerialIOProcessor.BAUDRATE_9600).
    This property may only be set if the communication with the device shall be made via serial port.
  • Databits: Number of data bits per data unit. Must be 7 or 8. Default: 8. It is strictly recommended to let this value unchanged.
    This property may only be set if the communication with the device shall be made via serial port.
  • LoggingType: Specifies the logging format used by the IO processor. Must be one of the logging type values specified in the UniqueIOProcessor class. Default: 1 (UniqueIOProcessor.LoggingTypeEscapeString).
  • MapCharacterSet: Default for MapCharacterSet property. Default: true.
  • MaxRetry: Specifies the maximum number of retries. Should be > 0 only for RS232 (real COM ports) where characters can become lost or corrupted on the communication line. Default: 2.
  • OwnPort: Integer value between 0 and 65535 specifying the TCP port used for communication with the device simulator. Default: 0 (for random port number selected by operating system).
    This property may only be set if the communication with the device shall be made via TCP.
  • Parity: Parity of each data unit. Must be one of the parity constants specified in the SerialIOProcessor class. Default: 0 (SerialIOProcessor.PARITY_NONE).
    This property may only be set if the communication with the device shall be made via serial port.
  • PollDelay: Minimum time between status requests, in milliseconds. Status requests will be used to monitor the device state. Default: 1000.
  • Port: Operating system specific name of the serial communication port (e.g. RS232, Usb2Serial, Bluetooth...) or the TCP address to be used for communication with the device simulator. In case of RS232, names look typically like COM2 or /dev/ttyS1. In case of TCP, names are of the form IPv4:port, where IPv4 is the IP address of the device and port its TCP port.
  • RequestTimeout: Maximum time, in milliseconds, between sending a command to the simulator and getting the first byte of its response. Default: 500.
  • Stopbits: Number of stop bits per data unit. Must be 1 or 2. Default: 2.
    This property may only be set if the communication with the device shall be made via serial port.
  • UsbToSerial: Specifies whether the specified port is a virtual port that will be removed by the operating system when the device is not connected. Default: false.
    This property may only be set if the communication with the device shall be made via serial port.
  • Constructor Details

    • Device

      public Device(String port) throws jpos.JposException
      Constructor, Stores communication target. Communication target can be a COM port or a TCP tagret. Valid COM port specifiers differ between operating systems, e.g. on Windows, COM1 can be a valid communication target while on Linux, /dev/ttyS0 might specify the same target. Format of TCP targets is IpAddress:Port, e.g. 10.11.12.13:45678.
      Parameters:
      port - COM port or TCP target.
      Throws:
      jpos.JposException - if Communication target invalid.
  • 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
    • changeDefaults

      public void changeDefaults(POSPrinterProperties props)
      Description copied from class: JposDevice
      Change defaults of properties. Must be implemented within derived classed that support POS printer services.
      Overrides:
      changeDefaults in class JposDevice
      Parameters:
      props - Property set for setting the property defaults
    • changeDefaults

      public void changeDefaults(CashDrawerProperties props)
      Description copied from class: JposDevice
      Change defaults of properties. Must be implemented within derived classed that support cash drawer services.
      Overrides:
      changeDefaults in class JposDevice
      Parameters:
      props - Property set for setting the property defaults
    • sendCommand

      protected void sendCommand(byte[] request) throws jpos.JposException
      Method to write data synchronized.
      Parameters:
      request - Data to be sent.
      Throws:
      jpos.JposException - if sending data fails due to missing or loosing output device.
    • getPOSPrinterProperties

      public POSPrinterProperties getPOSPrinterProperties(int index)
      Description copied from class: JposDevice
      Returns device implementation of POSPrinterProperties.
      Overrides:
      getPOSPrinterProperties in class JposDevice
      Parameters:
      index - Device index, see constructor of JposCommonProperties.
      Returns:
      Instance of POSPrinterProperties that matches the requirements of the corresponding device service.
    • getCashDrawerProperties

      public CashDrawerProperties getCashDrawerProperties(int index)
      Description copied from class: JposDevice
      Returns device implementation of CashDrawerProperties.
      Overrides:
      getCashDrawerProperties in class JposDevice
      Parameters:
      index - Device index, see constructor of JposCommonProperties.
      Returns:
      Instance of CashDrawerProperties that matches the requirements of the corresponding device service.