Package SampleScale

Class Device

All Implemented Interfaces:
Runnable

public class Device extends JposDevice implements Runnable
JposDevice based implementation of a JavaPOS Scale device service implementation for the sample device implemented in SampleScale.tcl.

This is an implementation based on the Scales Dialog 02 / 04.

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

  • Baudrate: Baud rate of the communication device. Must be 2400 or 4800, if set. Default: 2400.
    This property may only be set if the communication with the device shall be made via serial port.
  • CharacterTimeout: Positive integer value, specifying the maximum delay between bytes that belong to the same frame. Default value: 20 milliseconds.
  • DefaultTara: Default tare value. Default: 2. If the scale shall use any other default, you can set it here.
  • MaximumWeight: Maximum weight supported by the scale. Default: 5000. Any higher weight results in an overweight condition.
  • 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: 0.
  • 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.
  • PollDelay: Minimum time between status requests, in milliseconds. Status requests will be used to monitor the device state. Default: 500.
  • RequestTimeout: Maximum time, in milliseconds, between sending a command to the simulator and getting the first byte of its response. Default: 2000.
  • Target: 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.
  • Constructor Details

    • Device

      protected Device(String id)
      Constructor. id specifies either the COM port to be used or the server to be connected in format host:port
      Parameters:
      id - COM port or IP 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
    • changeDefaults

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

      public void run()
      Thread main, used for status check loop while device is enabled.
      Specified by:
      run in interface Runnable
    • getScaleProperties

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