Class ScaleProperties

java.lang.Object
de.gmxhome.conrad.jpos.jpos_base.JposCommonProperties
de.gmxhome.conrad.jpos.jpos_base.scale.ScaleProperties
All Implemented Interfaces:
JposBaseInterface, ScaleInterface
Direct Known Subclasses:
Device.SampleScaleAccessor

public class ScaleProperties extends JposCommonProperties implements ScaleInterface
Class containing the scales specific properties, their default values and default implementations of ScaleInterface. For details about properties, methods and method parameters, see UPOS specification, chapter Scale.
  • Field Details

    • CapDisplay

      public boolean CapDisplay
      UPOS property CapDisplay. Default: false. Can be overwritten by objects derived from JposDevice within the changeDefaults method.
    • CapDisplayText

      public boolean CapDisplayText
      UPOS property CapDisplayText. Default: false. Can be overwritten by objects derived from JposDevice within the changeDefaults method.
    • CapFreezeValue

      public boolean CapFreezeValue
      UPOS property CapFreezeValue. Default: false. Can be overwritten by objects derived from JposDevice within the changeDefaults method.
    • CapPriceCalculating

      public boolean CapPriceCalculating
      UPOS property CapPriceCalculating. Default: false. Can be overwritten by objects derived from JposDevice within the changeDefaults method.
    • CapReadLiveWeightWithTare

      public boolean CapReadLiveWeightWithTare
      UPOS property CapReadLiveWeightWithTare. Default: false. Can be overwritten by objects derived from JposDevice within the changeDefaults method.
    • CapSetPriceCalculationMode

      public boolean CapSetPriceCalculationMode
      UPOS property CapSetPriceCalculationMode. Default: false. Can be overwritten by objects derived from JposDevice within the changeDefaults method.
    • CapSetUnitPriceWithWeightUnit

      public boolean CapSetUnitPriceWithWeightUnit
      UPOS property CapSetUnitPriceWithWeightUnit. Default: false. Can be overwritten by objects derived from JposDevice within the changeDefaults method.
    • CapSpecialTare

      public boolean CapSpecialTare
      UPOS property CapSpecialTare. Default: false. Can be overwritten by objects derived from JposDevice within the changeDefaults method.
    • CapStatusUpdate

      public boolean CapStatusUpdate
      UPOS property CapStatusUpdate. Default: false. Can be overwritten by objects derived from JposDevice within the changeDefaults method.
    • CapTarePriority

      public boolean CapTarePriority
      UPOS property CapTarePriority. Default: false. Can be overwritten by objects derived from JposDevice within the changeDefaults method.
    • CapTareWeight

      public boolean CapTareWeight
      UPOS property CapTareWeight. Default: false. Can be overwritten by objects derived from JposDevice within the changeDefaults method.
    • CapZeroScale

      public boolean CapZeroScale
      UPOS property CapZeroScale. Default: false. Can be overwritten by objects derived from JposDevice within the changeDefaults method.
    • MaxDisplayTextChars

      public int MaxDisplayTextChars
      UPOS property MaxDisplayTextChars. Default: 0. Can be overwritten by objects derived from JposDevice within the changeDefaults method.
    • MaximumWeight

      public int MaximumWeight
      UPOS property MaximumWeight. Default: 0. Can be overwritten by objects derived from JposDevice within the changeDefaults method.
    • MinimumWeight

      public int MinimumWeight
      UPOS property MinimumWeight. Default: 0. Can be overwritten by objects derived from JposDevice within the changeDefaults method.
    • TareWeightDef

      public int TareWeightDef
      Default value of TareWeight property. Default: 0. Can be overwritten by objects derived from JposDevice within the changeDefaults method.
    • WeightUnit

      public int WeightUnit
      UPOS property WeightUnit. Default: SCAL_WU_KILOGRAM. Can be overwritten by objects derived from JposDevice within the changeDefaults method.
    • SalesPrice

      public long SalesPrice
      UPOS property SalesPrice.
    • ScaleLiveWeight

      public int ScaleLiveWeight
      UPOS property ScaleLiveWeight.
    • StatusNotify

      public int StatusNotify
      UPOS property StatusNotify.
    • TareWeight

      public int TareWeight
      UPOS property TareWeight.
    • UnitPrice

      public long UnitPrice
      UPOS property UnitPrice.
    • ZeroValid

      public boolean ZeroValid
      UPOS property ZeroValid.
  • Constructor Details

    • ScaleProperties

      public ScaleProperties(int dev)
      Constructor.
      Parameters:
      dev - Device index
  • Method Details

    • initOnOpen

      public void initOnOpen()
      Description copied from class: JposCommonProperties
      Initialization of properties that must be initialized during open.
      Overrides:
      initOnOpen in class JposCommonProperties
    • initOnFirstEnable

      public boolean initOnFirstEnable()
      Description copied from class: JposCommonProperties
      Initialize properties that must be initialized whenever the device will be enabled the first time-
      Overrides:
      initOnFirstEnable in class JposCommonProperties
      Returns:
      Returns true in case of first enable.
    • statusNotify

      public void statusNotify(int notify) throws jpos.JposException
      Description copied from interface: ScaleInterface
      Final part of setting StatusNotify. 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 enabled,
      • CapStatusUpdate is true,
      • The new status value is one of the predefined values,
      • internal property AllowAlwaysSetProperties is true or notify equals the previous value of StatusNotify.
      Specified by:
      statusNotify in interface ScaleInterface
      Parameters:
      notify - New StatusNotify value
      Throws:
      jpos.JposException - If an error occurs
    • tareWeight

      public void tareWeight(int i) 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
      Parameters:
      i - New TareWeight value
      Throws:
      jpos.JposException - If an error occurs
    • unitPrice

      public void unitPrice(long l) 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
      Parameters:
      l - New UnitPrice value
      Throws:
      jpos.JposException - If an error occurs
    • zeroValid

      public void zeroValid(boolean flag) 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
      Parameters:
      flag - New ZeroValid value
      Throws:
      jpos.JposException - If an error occurs
    • displayText

      public void displayText(String data) 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
      Parameters:
      data - The string of characters to display.
      Throws:
      jpos.JposException - See UPOS specification, method DisplayText.
    • 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
      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.
    • doPriceCalculating

      public void doPriceCalculating(DoPriceCalculating request) throws jpos.JposException
      Description copied from interface: ScaleInterface
      Final part of DoPriceCalculating method. Can be overwritten within derived classes, if necessary. The parameters of the method will be passed via a DoPriceCalculating 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:
      doPriceCalculating in interface ScaleInterface
      Parameters:
      request - Input request object that contains all parameters to be used by DoPriceCalculating.
      Throws:
      jpos.JposException - If an error occurs.
    • freezeValue

      public void freezeValue(int item, boolean freeze) throws jpos.JposException
      Description copied from interface: ScaleInterface
      Final part of FreezeValue 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,
      • CapFreezeValue is true,
      • The given item is a bitwise combination of SCAL_SFR_MANUAL_TARE, SCAL_SFR_PERCENT_TARE, SCAL_SFR_WEIGHTED_TARE and SCAL_SFR_UNITPRICE.
      Specified by:
      freezeValue in interface ScaleInterface
      Parameters:
      item - The bitwise value setting the state of the selected parameter item(s).
      freeze - Specifies behavior after readWeight method finished. See UPOS specification, chapter Scale - Methods - doPriceCalculating Method.
      Throws:
      jpos.JposException - See UPOS specification, method FreezeValue.
    • readLiveWeightWithTare

      public ReadLiveWeightWithTare readLiveWeightWithTare(int[] weightData, int[] tare, int timeout) throws jpos.JposException
      Description copied from interface: ScaleInterface
      Validation part of ReadLiveWeightWithTare 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,
      • CapReadLiveWeightWithTare is true,
      • Device state is not S_BUSY,
      • The dimension of weightData and tare is 1,
      • If AsyncMode = false: timeout ≥ 0 or JPOS_FOREVER.
      If AsyncMode = true, setting weightData[0] and tare[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 ReadLiveWeightWithTare object created with weightData[0], tare[0] and timeout as parameters must be returned.
      Specified by:
      readLiveWeightWithTare in interface ScaleInterface
      Parameters:
      weightData - On return, net weight calculated by the scale.
      tare - On return, tare weight used to calculate the net weight.
      timeout - Number of milliseconds to wait for a settled weight before failing the method.
      Returns:
      ReadLiveWeightWithTare object for use in final part.
      Throws:
      jpos.JposException - See UPOS specification, method ReadLiveWeightWithTare.
    • readLiveWeightWithTare

      public void readLiveWeightWithTare(ReadLiveWeightWithTare request) throws jpos.JposException
      Description copied from interface: ScaleInterface
      Final part of ReadLiveWeightWithTare method. Can be overwritten within derived classes, if necessary. The parameters of the method will be passed via a ReadLiveWeightWithTare 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:
      readLiveWeightWithTare in interface ScaleInterface
      Parameters:
      request - Output request object that contains all parameters to be used by ReadLiveWeightWithTare.
      Throws:
      jpos.JposException - If an error occurs.
    • readWeight

      public ReadWeight readWeight(int[] weightData, 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
      Parameters:
      weightData - 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
      Parameters:
      request - Output request object that contains all parameters to be used by ReadWeight.
      Throws:
      jpos.JposException - If an error occurs.
    • setPriceCalculationMode

      public void setPriceCalculationMode(int mode) throws jpos.JposException
      Description copied from interface: ScaleInterface
      Final part of SetPriceCalculationMode 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,
      • CapSetPriceCalculationMode is true,
      • The new mode is one of SCAL_PCM_PRICE_LABELING, SCAL_PCM_SELF_SERVICE or SCAL_PCM_OPERATOR.
      Specified by:
      setPriceCalculationMode in interface ScaleInterface
      Parameters:
      mode - The operation functionality selected for the scale.
      Throws:
      jpos.JposException - See UPOS specification, method SetPriceCalculationMode.
    • setSpecialTare

      public void setSpecialTare(int mode, int data) throws jpos.JposException
      Description copied from interface: ScaleInterface
      Final part of SetSpecialTare 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,
      • CapSpecialTare is true,
      • The new mode value is one of SCAL_SST_DEFAULT, SCAL_SST_MANUAL, SCAL_SST_PERCENT or SCAL_SST_WEIGHTED,
      • The new tare specifier is ≥ 0,
      • In case of SCAL_SST_DEFAULT and SCAL_SST_MANUAL: The new tare is ≤ MaximumWeight.
      Specified by:
      setSpecialTare in interface ScaleInterface
      Parameters:
      mode - Select the tare mode that is to be modified.
      data - Provides additional information specific to the mode.
      Throws:
      jpos.JposException - See UPOS specification, method SetSpecialTare.
    • setTarePriority

      public void setTarePriority(int priority) throws jpos.JposException
      Description copied from interface: ScaleInterface
      Final part of SetTarePriority 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,
      • CapTarePriority is true,
      • The new priority is one of SCAL_STP_FIRST or SCAL_STP_NONE.
      Specified by:
      setTarePriority in interface ScaleInterface
      Parameters:
      priority - The sequence in which a tare value is used when determining the net weight.
      Throws:
      jpos.JposException - See UPOS specification, method SetTarePriority.
    • setUnitPriceWithWeightUnit

      public void setUnitPriceWithWeightUnit(long unitPrice, int weightUnit, int weightNumerator, int weightDenominator) throws jpos.JposException
      Description copied from interface: ScaleInterface
      Final part of SetUnitPriceWithWeightUnit 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,
      • CapSetUnitPriceWithWeightUnit is true,
      • The new weight unit is one of SCAL_WU_GRAM, SCAL_WU_KILOGRAM, SCAL_WU_OUNCE or SCAL_WU_POUND,
      • The new unitPrice is ≥ 0,
      • weightNumerator and weightDenominator are ≥0, both.
      Specified by:
      setUnitPriceWithWeightUnit in interface ScaleInterface
      Parameters:
      unitPrice - The cost per unit price as calculated by this method.
      weightUnit - The value representing the new unit of weight that differs from the default value for the scale.
      weightNumerator - The dividend which is the weight value based on the current unit weight.
      weightDenominator - The divisor which is the weight value based on the new unit weight.
      Throws:
      jpos.JposException - See UPOS specification, method SetUnitPriceWithWeightUnit.
    • zeroScale

      public void zeroScale() throws jpos.JposException
      Description copied from interface: ScaleInterface
      Final part of ZeroScale 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,
      • CapZeroScale is true,
      • Device state is not S_BUSY.
      Specified by:
      zeroScale in interface ScaleInterface
      Throws:
      jpos.JposException - See UPOS specification, method ZeroScale.