Package SampleScale
Class Device.SampleScaleAccessor
java.lang.Object
de.gmxhome.conrad.jpos.jpos_base.JposCommonProperties
de.gmxhome.conrad.jpos.jpos_base.scale.ScaleProperties
SampleScale.Device.SampleScaleAccessor
- All Implemented Interfaces:
JposBaseInterface,ScaleInterface
- Enclosing class:
- Device
The sample scale interface implementation class. Implementation as inner class only recommended for small
classes. However, using inner classes makes things sometimes easier.
-
Field Summary
Fields inherited from class de.gmxhome.conrad.jpos.jpos_base.scale.ScaleProperties
CapDisplay, CapDisplayText, CapFreezeValue, CapPriceCalculating, CapReadLiveWeightWithTare, CapSetPriceCalculationMode, CapSetUnitPriceWithWeightUnit, CapSpecialTare, CapStatusUpdate, CapTarePriority, CapTareWeight, CapZeroScale, MaxDisplayTextChars, MaximumWeight, MinimumWeight, SalesPrice, ScaleLiveWeight, StatusNotify, TareWeight, TareWeightDef, UnitPrice, WeightUnit, ZeroValidFields inherited from class de.gmxhome.conrad.jpos.jpos_base.JposCommonProperties
AllowAlwaysSetProperties, AllowDeprecatedMethods, AsyncInputActive, AsyncMode, AutoDisable, CapStatisticsReporting, CapUpdateStatistics, CheckHealthText, Claimed, Claiming, ClaimWaiters, CurrentCommands, CurrentUnitID, DataCount, DataEventEnabled, DataEventList, Device, DeviceEnabled, DeviceServiceDescription, DeviceServiceVersion, DevProps, ErrorString, ErrorUnits, EventCB, EventList, EventSource, EventString, EventUnitID, EventUnits, ExclusiveAllowed, ExclusiveNo, ExclusiveUse, ExclusiveYes, FirstEnableHappened, FlagWhenIdle, FlagWhenIdleStatusValue, FreezeEvents, Index, LogicalName, MaximumConfirmationEventWaitingTime, OutputID, PowerNotify, PowerState, SerializedRequestRunner, SerializedRequests, State, StrictFIFOEventHandling, SuspendedCommands, SuspendedConcurrentCommands, UnitsOnline, UsesSubsystemUnits -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckHealth(int level)Final part of CheckHealth method.voiddeviceEnabled(boolean enable)Final part of setting DeviceEnabled.voiddisplayText(String description)Final part of DisplayText method.doPriceCalculating(int[] weightData, int[] tare, long[] unitPrice, long[] unitPriceX, int[] weightUnitX, int[] weightNumeratorX, int[] weightDenominatorX, long[] price, int timeout)Validation part of DoPriceCalculating method.voidWill be called whenever DeviceEnabled will be set to true if power notification is enabled (PowerNotify = PN_ENABLED).readWeight(int[] weight, int timeout)Validation part of ReadWeight method.voidreadWeight(ReadWeight request)Final part of ReadWeight method.voidtareWeight(int weight)Final part of setting TareWeight.voidunitPrice(long price)Final part of setting UnitPrice.voidzeroValid(boolean b)Final part of setting ZeroValid.Methods inherited from class de.gmxhome.conrad.jpos.jpos_base.scale.ScaleProperties
doPriceCalculating, freezeValue, initOnFirstEnable, initOnOpen, readLiveWeightWithTare, readLiveWeightWithTare, setPriceCalculationMode, setSpecialTare, setTarePriority, setUnitPriceWithWeightUnit, statusNotify, zeroScaleMethods inherited from class de.gmxhome.conrad.jpos.jpos_base.JposCommonProperties
addProperties, asyncMode, attachWaiter, autoDisable, checkForDeprecation, checkProperties, claim, clearDataProperties, clearErrorProperties, clearInput, clearOutput, clearOutputErrorProperties, close, compareFirmwareVersion, dataEventEnabled, directIO, directIO, flagWhenIdle, freezeEvents, getClaimingInstance, initOnClaim, initOnEnable, newJposOutputRequest, open, powerNotify, release, releaseWaiter, removeFromPropertySetList, resetStatistics, retrieveStatistics, retryInput, retryOutput, signalWaiter, unitDataCount, updateFirmware, updateFirmware, updateStatistics, waitWaiterMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.gmxhome.conrad.jpos.jpos_base.JposBaseInterface
asyncMode, autoDisable, claim, clearInput, clearOutput, close, compareFirmwareVersion, dataEventEnabled, directIO, directIO, flagWhenIdle, freezeEvents, newJposOutputRequest, open, powerNotify, release, removeFromPropertySetList, resetStatistics, retrieveStatistics, retryInput, retryOutput, unitDataCount, updateFirmware, updateFirmware, updateStatistics
-
Method Details
-
deviceEnabled
public void deviceEnabled(boolean enable) throws jpos.JposExceptionDescription copied from interface:JposBaseInterfaceFinal 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:
deviceEnabledin interfaceJposBaseInterface- Overrides:
deviceEnabledin classJposCommonProperties- 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.JposExceptionDescription copied from interface:JposBaseInterfaceWill 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:
handlePowerStateOnEnablein interfaceJposBaseInterface- Overrides:
handlePowerStateOnEnablein classJposCommonProperties- Throws:
jpos.JposException- If an error occurs.
-
checkHealth
public void checkHealth(int level) throws jpos.JposExceptionDescription copied from interface:JposBaseInterfaceFinal 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:
checkHealthin interfaceJposBaseInterface- Overrides:
checkHealthin classJposCommonProperties- Parameters:
level- See UPOS specification, method CheckHealth- Throws:
jpos.JposException- See UPOS specification, method CheckHealth
-
tareWeight
public void tareWeight(int weight) throws jpos.JposExceptionDescription copied from interface:ScaleInterfaceFinal 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:
tareWeightin interfaceScaleInterface- Overrides:
tareWeightin classScaleProperties- Parameters:
weight- New TareWeight value- Throws:
jpos.JposException- If an error occurs
-
unitPrice
public void unitPrice(long price) throws jpos.JposExceptionDescription copied from interface:ScaleInterfaceFinal 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:
unitPricein interfaceScaleInterface- Overrides:
unitPricein classScaleProperties- Parameters:
price- New UnitPrice value- Throws:
jpos.JposException- If an error occurs
-
zeroValid
public void zeroValid(boolean b) throws jpos.JposExceptionDescription copied from interface:ScaleInterfaceFinal 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:
zeroValidin interfaceScaleInterface- Overrides:
zeroValidin classScaleProperties- Parameters:
b- New ZeroValid value- Throws:
jpos.JposException- If an error occurs
-
displayText
Description copied from interface:ScaleInterfaceFinal 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:
displayTextin interfaceScaleInterface- Overrides:
displayTextin classScaleProperties- Parameters:
description- The string of characters to display.- Throws:
jpos.JposException- See UPOS specification, method DisplayText.
-
readWeight
Description copied from interface:ScaleInterfaceValidation 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.
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:
readWeightin interfaceScaleInterface- Overrides:
readWeightin classScaleProperties- 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
Description copied from interface:ScaleInterfaceFinal 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:
readWeightin interfaceScaleInterface- Overrides:
readWeightin classScaleProperties- 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.JposExceptionDescription copied from interface:ScaleInterfaceValidation 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.
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:
doPriceCalculatingin interfaceScaleInterface- Overrides:
doPriceCalculatingin classScaleProperties- 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.
-