Package SampleScale

Class Device.SampleScaleAccessor

All Implemented Interfaces:
JposBaseInterface, ScaleInterface
Enclosing class:
Device

public class Device.SampleScaleAccessor extends ScaleProperties
The sample scale interface implementation class. Implementation as inner class only recommended for small classes. However, using inner classes makes things sometimes easier.
  • Method Details

    • deviceEnabled

      public void deviceEnabled(boolean enable) throws jpos.JposException
      Description copied from interface: JposBaseInterface
      Final part of setting DeviceEnabled. Can be overwritten within derived classes. Performs initOnEnable method of corresponding property set in addition to setting DeviceEnabled. This method will be called only if the following plausibility checks lead to a positive result:
      • Device has not been closed,
      • ExclusiveUse equals ExclusiveYes: Device is claimed,
      • DeviceEnabled != enabled.
      Specified by:
      deviceEnabled in interface JposBaseInterface
      Overrides:
      deviceEnabled in class JposCommonProperties
      Parameters:
      enable - True to enable, false to disable
      Throws:
      jpos.JposException - If an error occurs during enable or disable
    • handlePowerStateOnEnable

      public void handlePowerStateOnEnable() throws jpos.JposException
      Description copied from interface: JposBaseInterface
      Will be called whenever DeviceEnabled will be set to true if power notification is enabled (PowerNotify = PN_ENABLED). Should update the PowerState property. Further processing like firing a StatusUpdateEvent is not necessary, this will be made by the framework automatically.
      Specified by:
      handlePowerStateOnEnable in interface JposBaseInterface
      Overrides:
      handlePowerStateOnEnable in class JposCommonProperties
      Throws:
      jpos.JposException - If an error occurs.
    • checkHealth

      public void checkHealth(int level) throws jpos.JposException
      Description copied from interface: JposBaseInterface
      Final part of CheckHealth method. Can be overwritten in derived class, if necessary. Keep in mind that dvice class specific checks (e.g. check of Claimed or DeviceEnabled) must be done within derived classes. This method will be called only if the following plausibility checks lead to a positive result:
      • Device is neither enabled nor claimed.
      Specified by:
      checkHealth in interface JposBaseInterface
      Overrides:
      checkHealth in class JposCommonProperties
      Parameters:
      level - See UPOS specification, method CheckHealth
      Throws:
      jpos.JposException - See UPOS specification, method CheckHealth
    • tareWeight

      public void tareWeight(int weight) throws jpos.JposException
      Description copied from interface: ScaleInterface
      Final part of setting TareWeight. Can be overwritten within derived classes, if necessary. This method will be called only if the following plausibility checks lead to a positive result:
      • Device is enabled,
      • The new tare value is between 0 and MaximumWeight.
      Specified by:
      tareWeight in interface ScaleInterface
      Overrides:
      tareWeight in class ScaleProperties
      Parameters:
      weight - New TareWeight value
      Throws:
      jpos.JposException - If an error occurs
    • unitPrice

      public void unitPrice(long price) throws jpos.JposException
      Description copied from interface: ScaleInterface
      Final part of setting UnitPrice. Can be overwritten within derived classes, if necessary. This method will be called only if the following plausibility checks lead to a positive result:
      • Device is enabled,
      • New price is not negative.
      Specified by:
      unitPrice in interface ScaleInterface
      Overrides:
      unitPrice in class ScaleProperties
      Parameters:
      price - New UnitPrice value
      Throws:
      jpos.JposException - If an error occurs
    • zeroValid

      public void zeroValid(boolean b) throws jpos.JposException
      Description copied from interface: ScaleInterface
      Final part of setting ZeroValid. Can be overwritten within derived classes, if necessary. This method will be called only if the following plausibility checks lead to a positive result:
      • Device is not closed,
      • internal property AllowAlwaysSetProperties is true or flag equals the previous value of ZeroValid.
      Specified by:
      zeroValid in interface ScaleInterface
      Overrides:
      zeroValid in class ScaleProperties
      Parameters:
      b - New ZeroValid value
      Throws:
      jpos.JposException - If an error occurs
    • displayText

      public void displayText(String description) throws jpos.JposException
      Description copied from interface: ScaleInterface
      Final part of DisplayText method. Can be overwritten within derived classes, if necessary. This method will be called only if the following plausibility checks lead to a positive result:
      • Device is enabled,
      • CapDisplayText is true,
      • The new text is not null and its length is not longer than MaxDisplayTextChars.
      Specified by:
      displayText in interface ScaleInterface
      Overrides:
      displayText in class ScaleProperties
      Parameters:
      description - The string of characters to display.
      Throws:
      jpos.JposException - See UPOS specification, method DisplayText.
    • readWeight

      public ReadWeight readWeight(int[] weight, int timeout) throws jpos.JposException
      Description copied from interface: ScaleInterface
      Validation part of ReadWeight method. Can be overwritten within derived classes, if necessary. This method will be called only if the following plausibility checks lead to a positive result:
      • Device is enabled,
      • Device state is not S_BUSY,
      • The dimension of weightData is 1,
      • If AsyncMode = false: timeout ≥ 0 or JPOS_FOREVER.
      If AsyncMode = true, setting weightData[0] to 0 will not be necessary because this will be done within the calling method.
      A service may perform the full weight process inside this method, but this is not recommended, especially in asynchronous operation. The recommended functionality is to perform only validation in this method and to perform weighing inside the final part. If implemented the latter way, a ReadWeight object created with weightData[0] and timeout as parameters must be returned.
      Specified by:
      readWeight in interface ScaleInterface
      Overrides:
      readWeight in class ScaleProperties
      Parameters:
      weight - The weight measured by the scale.
      timeout - The number of milliseconds to wait for a settled weight before failing the method.
      Returns:
      ReadWeight object for use in final part.
      Throws:
      jpos.JposException - See UPOS specification, method ReadWeight.
    • readWeight

      public void readWeight(ReadWeight request) throws jpos.JposException
      Description copied from interface: ScaleInterface
      Final part of ReadWeight method. Can be overwritten within derived classes, if necessary. The parameters of the method will be passed via a ReadWeight object. This method will be called when the corresponding operation shall be performed, either synchronously or asynchronously. All plausibility checks have been made before, only runtime errors can occur.
      In case of asynchronous processing, the following additional checks have been made before as well:
      • Timeout ≥ 0 or JPOS_FOREVER.

      This method will only be called if the validation method threw a JposException with ErrorCode = 0.
      Specified by:
      readWeight in interface ScaleInterface
      Overrides:
      readWeight in class ScaleProperties
      Parameters:
      request - Output request object that contains all parameters to be used by ReadWeight.
      Throws:
      jpos.JposException - If an error occurs.
    • doPriceCalculating

      public DoPriceCalculating doPriceCalculating(int[] weightData, int[] tare, long[] unitPrice, long[] unitPriceX, int[] weightUnitX, int[] weightNumeratorX, int[] weightDenominatorX, long[] price, int timeout) throws jpos.JposException
      Description copied from interface: ScaleInterface
      Validation part of DoPriceCalculating method. Can be overwritten within derived classes, if necessary. This method will be called only if the following plausibility checks lead to a positive result:
      • Device is enabled,
      • The device state is not S_BUSY,
      • CapSetUnitPriceWithWeightUnit is true,
      • The dimension of the given array parameters is 1,
      • In case of AsyncMode = false: The timeout is ≥ 0 or JPOS_FOREVER.
      If AsyncMode = true, setting weightData[0], tare[0], unitPrice[0] and price[0] to 0 will not be necessary because this will be done within the calling method.

      Since the UPOS specification is very unclear for this method, further checks might be necessary and must be implemented within this method in derived classes:

      • Check whether SetUnitPriceWithWeightUnit has been called previously.

      In addition, this method must return the current values for initPriceX, weightUnitX, weightNumeratorX and weightDenominatorX as set via method SetUnitPriceWithWeightUnit.
      A service may perform the full weight process inside this method, but this is not recommended, especially in asynchronous operation. The recommended functionality is to perform only validation in this method and to perform weighing inside the final part. If implemented the latter way, a DoPriceCalculating object created with weightData[0], tare[0], unitPrice[0], unitPriceX[0], weightUnitX[0], weightNumeratorX[0], weightDenominatorX[0], price[0] and timeout as parameters must be returned.
      Specified by:
      doPriceCalculating in interface ScaleInterface
      Overrides:
      doPriceCalculating in class ScaleProperties
      Parameters:
      weightData - The value for the net weight in the price calculation algorithm.
      tare - The value used to determine the item net weight in the price calculation algorithm.
      unitPrice - The cost per measurement unit that is used in the price calcuation algorithm.
      unitPriceX - See UPOS specification, chapter Scale - Methods - doPriceCalculating Method.
      weightUnitX - See UPOS specification, chapter Scale - Methods - doPriceCalculating Method.
      weightNumeratorX - See UPOS specification, chapter Scale - Methods - doPriceCalculating Method.
      weightDenominatorX - See UPOS specification, chapter Scale - Methods - doPriceCalculating Method.
      price - The calculated monetary value for the item on the scale.
      timeout - The number of milliseconds to wait for a settled weight before failing the method.
      Returns:
      DoPriceCalculating object for use in final part.
      Throws:
      jpos.JposException - See UPOS specification, method DoPriceCalculating.