Class Device

All Implemented Interfaces:
Runnable

public class Device extends JposDevice implements Runnable
Base of a JposDevice based implementation of JavaPOS ElectronicValueRW device service implementations for the sample device implemented in SampleCAT.tcl. The sample device simulates EFT payment transactions without ticket printing (the simulator sends ticket and display data to its target).
Supported features are:
  • Sale, refund and void.
  • Start transaction before amount to approve is known.
  • Confirmation in case of signature based approval.
  • Lock / unlock terminal.
  • Card issuer, transaction number, transaction date, tip, approved amount, approval result, terminal result, masked card number (last 4 digit readable), expiration date sent in case of successful operation.
  • Display output will be used to generate specific TransitionEvent events.
  • Ticket layout will be passed to the application via TransitionEvent events.
  • In synchronous mode, passing display data to the application and operator confirmation in case of signature based authorizations will not be possible. The service will expect a positive confirmation whenever needed.
Display data will be provided via TransitionEvent with EventNumber TE_NOTIFY_BUSY. pData will be set to the line number and pString to the corresponding display line. In synchronous mode, display data will not be provided.
Transition events with EventNumber TE_CONFIRM_DEVICE_DATA will be used to request the ticket printer state. The application must set AdditionalSecurityInformation to "0" if ticket printing is possible, to "1" if ticket printing is currently not available and to "2" if ticket printing is not supported. If not an empty string, Ticket data will be passed directly via property pString. If pString is an empty string, only the ticket printing state is requested. In synchronous mode, ticket data will be written to property AdditionalSecurityInformation.
Even if passed via TransitionEvent or via AdditionalSecurityInformation, the format of ticket data is of the form
sequenceNo STX count STX ticket data
where sequenceNo is the sequence number of the current operation, count specifies the number of tickets to be printed (if two, one ticket must be signed by the customer and verified by the user) and ticket dataspecifies the ticket data to be printed, with LF (0Ah) as line separator. STX (02h) will be used as delimiter between count, sequenceNo and ticket data.
In case of a signature based operation, a TransitionEvent with EventNumber TE_CONFIRM_CANCEL will be fired. The application must change the event property pData to 1 to cancel the operation or to 0 to finish the operation successfully.
In case of synchronous operation, no TransitionEvent event with EventNumber TE_CONFIRM_CANCEL can be fired. In this case, ticket data part count = 2 implies that validation must be performed afterwards. If validation fails, the transaction must be voided.
Here a full list of all device specific properties that can be changed via jpos.xml:
  • CharacterTimeout: Positive integer value, specifying the maximum delay between bytes that belong to the same frame. Default value: 50 milliseconds.
  • ClientPort: 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).
  • MinClaimTimeout: Minimum timeout in milliseconds used by method Claim to ensure correct working. Must be a positive value. If this value is too small, Claim might throw a JposException even if everything is OK if the specified timeout is less than or equal to MinClaimTimeout. Default: 100.
  • PollDelay: The interval for printer status polling if response is "1" (currently not available), default: 200.
  • Port: The IPv4 address of the device. Must always be specified and not empty. Notation: address:port, where address is a IPv4 address and port the TCP port of the device.
  • RequestTimeout: Maximum time the service object waits for the reception of a response frame after sending a request to the target, in milliseconds. Default: 1000.
  • TicketWidth: Length of one ticket line passed vie TransitionEvent. Must be a value between 28 and 99 (inclusive). Default: 32.
  • Constructor Details

    • Device

      protected Device(String id)
      Constructor. ID is the network address of the EFT (as ElectronicValueRW).
      Parameters:
      id - Network address of the display controller.
  • 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(ElectronicValueRWProperties props)
      Description copied from class: JposDevice
      Change defaults of properties. Must be implemented within derived classed that support electronic value reader / writer services.
      Overrides:
      changeDefaults in class JposDevice
      Parameters:
      props - Property set for setting the property defaults
    • caesar

      public static String caesar(String s, int keyValue)
      Cesar's encryption: Simply add keyValue to each character for encryption. For decryption, pass -keyValue.
      Parameters:
      s - String to be encrypted or decrypted.
      keyValue - Encryption key.
      Returns:
      The encrypted text.
    • run

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

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