Class Device

All Implemented Interfaces:
Runnable

public class Device extends JposDevice implements Runnable
Base of a JposDevice based implementation of JavaPOS CashDrawer, ElectronicJournal, FiscalPrinter and LineDisplay device service implementations for the sample device implemented in SampleFiscalPrinter.tcl.

Supported features are:
FiscalPrinter:

  • Basic functionality,
  • Set header, trailer, vat rates, POS ID
  • Additional lines, additional header and trailer lines, pre and post lines, tax ID
  • Item and subtotal adjustments (amount, percent, surcharge),
  • Status handling for receipt (neither journal nor slip station),
  • Subtotal,
  • MessageType MT_CASHIER to change cashier on-the-fly (alternative to signon / signoff),
  • Training Mode,
  • X report,
  • Totalizers (only GD_PRINTER_ID, GD_CURRENT_TOTAL, GD_DAILY_TOTAL, GD_GRAND_TOTAL, GD_NOT_PAID, GD_RECEIPT_NUMBER, GD_FISCAL_REC, GD_REFUND, GD_NONFISCAL_REC, GD_Z_REPORT, GD_DESCRIPTION_LENGTH),
  • Report from counter to counter,
  • non-fiscal reports,
  • fixed-output documents for signon and signoff.
ElectronicJournal (markers constructed from sessionNo and documentNo using format mask "%d-%d"). Session-No. corresponds to Z count of fiscal printer and document no. to receipt number of the fiscal printer. Supported features:
  • Basic electronic journal capabilities,
  • Print stored data.
LineDisplay:
  • Basic LineDisplay capabilities,
  • 2x20 lines.
CashDrawer:
  • Basic cash drawer capabilities,
  • Drawer status reporting.

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

  • AdjustmentVoidText: Additional text line for adjustment void. Default "*** ADJUSTMENT VOID ***".
  • 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.
  • CashierID: Cashier id prefix for signon or signoff receipt. Default: "Cashier ID".
  • CashierName: Cashier name prefix for signon or signoff receipt. Default: "Cashier Name".
  • CharacterTimeout: Positive integer value, specifying the maximum delay between bytes that belong to the same frame. Default value: 50 milliseconds.
  • 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.
  • JournalSizeNearFull: Cumulated size of all journal files to generate journal near full status update event. Default 99% of MaxJournalSize.
  • MaxJournalSize: Maximum size of all journal files of the device simulator. Default fits for 100 periods, 100000 receipts per period, 10000 characters per receipt.
  • 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.
  • NonFiscalReceiptWithTrailer: Flag specifying whether non-fiscal receipts shall be printed with (true) or without (false) trailer lines. Default is false (without trailer lines).
  • 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: 500.
  • 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.
  • PrinterResetText: Text to be printed during printer reset. Default "*** RESET PRINTER ***".
  • RefundVoidText: Additional text line for refund void. Default "*** REFUND VOID ***".
  • RequestTimeout: Maximum time, in milliseconds, between sending a command to the simulator and getting the first byte of its response. Default: 2000.
  • SecretText: Secret code prefix for signon or signoff receipt. Default: "Secret".
  • SerialNumber: Fiscal printer serial number. If not set, serial no. of the currently connected printer will be retrieved. Otherwise, serial number must match the serial number stored in the printer. Default is not set.
  • SignOffHeader: Header text for signoff receipt. Default: "S I G N O F F".
  • SignOnHeader: Header text for signon receipt. Default: "S I G N O N".
  • 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.
  • Field Details

    • RequestTimeout

      public int RequestTimeout
      Maximum time between acknowledge and response frame. Default: 2000. Can be set via jpos.xml.
    • SAMPLEFISCALPRINTERDIO_EXECCOMMAND

      public static final int SAMPLEFISCALPRINTERDIO_EXECCOMMAND
      Command for DirectIO: Send native command(s) and retrieve the response(s).
      See Also:
      Constant Field Values
    • SAMPLEFISCALPRINTERDIO_NONFISCALRECEIPTTRAILER

      public static final int SAMPLEFISCALPRINTERDIO_NONFISCALRECEIPTTRAILER
      DirectIO: Sets flag for non-fiscal receipt printing (with / without trailer lines).
      See Also:
      Constant Field Values
    • SAMPLEFISCALPRINTERDIO_FISCALIZE

      public static final int SAMPLEFISCALPRINTERDIO_FISCALIZE
      DirectIO: Perform fiscalization. In addition to VAT table, header and trailer lines, store fiscal ID and POS ID, the serial number must be set as well. This can be done in the simulator (debug window, "set SerialNo [number]", where [number] should be replaced by any unique number).
      See Also:
      Constant Field Values
    • SAMPLEFISCALPRINTERFXO_SIGNON

      public static final int SAMPLEFISCALPRINTERFXO_SIGNON
      BeginFixedOutput: documentType for sign on. It can be used to set the cashier number after day has been opened to a non-zero value.
      See Also:
      Constant Field Values
    • SAMPLEFISCALPRINTERFXO_SIGNOFF

      public static final int SAMPLEFISCALPRINTERFXO_SIGNOFF
      BeginFixedOutput: documentType for sign off. It can be used to set the cashier number after day has been opened to zero.
      See Also:
      Constant Field Values
    • SAMPLEFISCALPRINTERFXO_HEAD

      public static final int SAMPLEFISCALPRINTERFXO_HEAD
      Header of fixed output receipts. Data must be an empty string.
      See Also:
      Constant Field Values
    • SAMPLEFISCALPRINTERFXO_ON_CASHIER

      public static final int SAMPLEFISCALPRINTERFXO_ON_CASHIER
      First line no. of SIGNON receipt. Data must be the number of the cashier to be signed on.
      See Also:
      Constant Field Values
    • SAMPLEFISCALPRINTERFXO_ON_END

      public static final int SAMPLEFISCALPRINTERFXO_ON_END
      Last line of a SIGNON. Data must be an empty string.
      See Also:
      Constant Field Values
    • SAMPLEFISCALPRINTERFXO_OFF_CASHIER

      public static final int SAMPLEFISCALPRINTERFXO_OFF_CASHIER
      First line no. of SIGNOFF receipt. Data must be the number of the cashier to be signed off.
      See Also:
      Constant Field Values
    • SAMPLEFISCALPRINTERFXO_OFF_SECRET

      public static final int SAMPLEFISCALPRINTERFXO_OFF_SECRET
      Optional second line of a SIGNOFF receipt. Data must be a secret number used for later sign on operations.
      See Also:
      Constant Field Values
    • SAMPLEFISCALPRINTERFXO_OFF_END

      public static final int SAMPLEFISCALPRINTERFXO_OFF_END
      Last line of a SIGNOFF. Data must be an empty string.
      See Also:
      Constant Field Values
  • Constructor Details

    • Device

      protected Device(String id)
      The device implementation. See parent for further details.
      Parameters:
      id - COM port or TCP address for simulator communication.
  • 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(FiscalPrinterProperties props)
      Description copied from class: JposDevice
      Change defaults of properties. Must be implemented within derived classed that support fiscal printer services.
      Overrides:
      changeDefaults in class JposDevice
      Parameters:
      props - Property set for setting the property defaults
    • changeDefaults

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

      public void changeDefaults(LineDisplayProperties props)
      Description copied from class: JposDevice
      Change defaults of properties. Must be implemented within derived classed that support line display services.
      Overrides:
      changeDefaults in class JposDevice
      Parameters:
      props - Property set for setting the propperty 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
    • run

      public void run()
      Specified by:
      run in interface Runnable
    • 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.
    • getLineDisplayProperties

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

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

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