Class Device


public class Device extends JposDevice
Base of a JposDevice based implementation of JavaPOS HardTotals device service implementation for the sample device based on the RandomAccessFile class. Error detection is not supported by this sample.

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

  • DevIndex: Positive integer between 0 and MaxTotals - 1, specifying one part of the hard totals file. Default: 0
  • HardTotalsFileName: Path to the disk file that contains the HardTotals. Stored in class variable ID.
  • MaxHardTotalFileSize: Maximum size of each of the MaxTotals Hard totals. Default 32768 (0x8000).
  • MaxTotals: Maximum number of hard totals. Limited by memory and disk space because each hard total requires MaxHardTotalFileSize bytes in both, RAM and disk. Default: DevIndex + 1.
  • SingleFileOnly: Must be true if only one file shall be supported per hard total, otherwise false. Default: false.
Keep in mind that values can only be set once. once the hard totals file has been created (that will be made after first enable), these properties cannot be modified any longer. The structure of the HardTotals file is as follows:
  • MaxTotals: 32-bit integer value.
  • MaxTotals times:
    • MaxHardTotalFileSize: 32-bit integer value, size of the corresponding HardTotals device,
    • SingleFileOnly: 8-bit boolean value, specifies whether the corresponding HardTotals device supports only one single file.
  • MaxTotals times: N bytes representing the corresponding HardTotals, where N is the corresponding MaxHardTotalFileSize value.
The structure of a HardTotals device where SingleFileOnly is true:
  • Size: 32-bit integer value, the size of the created file or 0 if file has not been created,
  • Contents: Size byte contents of the hard totals file, if it exists.
  • Undefined: N - Size - 4 byte random values, where N is the corresponding MaxHardTotalFileSize value.
The structure of a HardTotals device where SingleFileOnly is false:
  • For NumberOfFiles:
    • Size: 32-bit integer value, the size of a file,
    • Name: 10 byte file name,
    • Contents: Size byte contents.
  • At the end: 32-bit integer 0 as end of information mark.
  • All remaining bytes of a HardTotals device contain random values.
  • Constructor Details

    • Device

      protected Device(String id) throws jpos.JposException
      The device implementation. See parent for further details.
      Parameters:
      id - Device ID, interface to HardTotals device. Name of file representing the hard totals hardware in this implementation.
      Throws:
      jpos.JposException - if id cannot be opened or has bad format.
  • Method Details

    • checkProperties

      public void checkProperties(jpos.config.JposEntry entry, int index) throws jpos.JposException
      Checks whether a JposEntry belongs to a predefined property value an if so, sets the corresponding driver value for device global properties or for a specific hard totals device. This is the first method called after creation of a Device instance. Therefore, all variables and properties set within this method can be used in all other methods except the constructor.
      Parameters:
      entry - Entry to be checked, contains value to be set
      index - Index of the specific device.
      Throws:
      jpos.JposException - if a property value is invalid
    • changeDefaults

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

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