DLCradleMgr
Summary
The DLCradleMgr namespace handles the configuration and use of the device's cradle. The interface described here is found in dl_cradle.js
.
Functions
Function | Description |
---|---|
controlLed | Control cradle LED. |
controlLock | Lock/Unlock a cradle. |
getInsertionState | Get the cradle insertion state of the device. |
getSlotIndex | Get the cradle slot index of the device. |
ignoreCradleExtraction | Removes cradle extraction listener. |
ignoreCradleInsertion | Removes cradle insertion listener. |
ignoreTrolleyExtraction | Removes trolley extraction listener. |
ignoreTrolleyInsertion | Removes trolley insertion listener. |
isDeviceInTrolley | Check if a device is in a trolley. |
onCradleExtraction | Attach a callback function to the cradle extraction event. |
onCradleInsertion | Attach a callback function to the cradle insertion event. |
onTrolleyExtraction | Attach a callback function to the trolley extraction event. |
onTrolleyInsertion | Attach a callback function to the trolley insertion event. |
readCustomArea | Read data from cradle custom area. |
writeCustomArea | Write data to cradle custom area. |
Constants
Constants | Description |
---|---|
DL_CRADLE_MGR_VER | The version of DLCradleMgr. |
InsertState | Device insertion state relative to the cradle. |
LedAction | Available actions to control cradle LED. |
LockAction | Available actions to control cradle lock. |
Functions
Device Compatibility
Not all devices support all cradle manager functions. Functions which include a "SelfShopping only" reference will only work on devices with a SelfShopping SDK.
controlLed
controlLed(action: number): boolean
Set the cradle LED behavior. SelfShopping only.
Parameters
- action: Action from LedAction.
Returns
True if the action was successful.
Example
if (!DLCradleMgr.controlLed(LedAction.LED_ON)) {
alert("Could not turn cradle LED on.");
}
controlLock
controlLock(action: number): boolean
Lock or unlock the cradle.
Parameters
- action: Action from LockAction.
Returns
True if the action was successful.
Example
if (!DLCradleMgr.controlLock(LockAction.UNLOCK)) {
alert("Could not unlock cradle.");
}
getInsertionState
getInsertionState(): number
Get the cradle insertion state of the device.
Returns
Insertion state as InsertState.
Example
let state = DLCradleMgr.getInsertionState();
getSlotIndex
getSlotIndex(): number
Get the cradle slot index of the device.
This only works on SelfShopping devices or Datalogic devices with SDK version 33 and above.
Returns
Slot index of the cradle the device is in. If the function is not supported, the return value is -1
.
Example
let slotIndex = DLCradleMgr.getSlotIndex();
ignoreCradleExtraction
ignoreCradleExtraction(): boolean
Remove any callback function from the cradle extraction event.
Returns
True if callback was successfully removed.
Example
if (!DLCradleMgr.ignoreCradleExtraction()) {
alert("Error trying to clear onCradleExtraction callback.");
}
ignoreCradleInsertion
ignoreCradleInsertion(): boolean
Remove any callback function from the cradle insertion event.
Returns
True if callback was successfully removed.
Example
if (!DLCradleMgr.ignoreCradleInsertion()) {
alert("Error trying to clear onCradleInsertion callback.");
}
ignoreTrolleyExtraction
ignoreTrolleyExtraction(): boolean
Remove any callback function from the trolley extraction event. SelfShopping only.
Returns
True if callback was successfully removed.
Example
if (!DLCradleMgr.ignoreTrolleyExtraction()) {
alert("Error trying to clear onTrolleyExtraction callback.");
}
ignoreTrolleyInsertion
ignoreTrolleyInsertion(): boolean
Remove any callback function from the trolley insertion event. SelfShopping only.
Returns
True if callback was successfully removed.
Example
if (!DLCradleMgr.ignoreTrolleyInsertion()) {
alert("Error trying to clear onTrolleyInsertion callback.");
}
isDeviceInTrolley
isDeviceInTrolley(): boolean
Checks if a device is in a trolley. SelfShopping only.
Returns
True if device is in a trolley.
Example
let deviceInTrolley = DLCradleMgr.isDeviceInTrolley();
onCradleExtraction
onCradleExtraction(callback: (state: {id: InsertState}) => void): boolean
Attach a callback function to the cradle extraction event. Only one callback can be attached at a time. If called multiple times, only the callback from the last call to onCradleExtraction() will be used.
Parameters
- callback: Function to call when a cradle extraction event occurs. The callback function receives a single parameter, which is an object representing the state result. It contains the following properties:
- id: Represents the InsertState of the device.
Returns
True if the callback was successfully attached.
Example
if (!DLCradleMgr.onCradleExtraction(extractionReceived)) {
alert("Error trying to listen for cradle extraction events.");
}
// Called when a device is extracted from the cradle.
function extractionReceived(state) {
var dataStr = "State ID: " + state.id;
alert(dataStr);
}
onCradleInsertion
onCradleInsertion(callback: (state: {id: InsertState}) => void): boolean
Attach a callback function to the cradle insertion event. Only one callback can be attached at a time. If called multiple times, only the callback from the last call to onCradleInsertion() will be used.
Parameters
- callback: Function to call when a cradle insertion event occurs. The callback function receives a single parameter, which is an object representing the state result. It contains the following properties:
- id: Represents the InsertState of the device.
Returns
True if the callback was successfully attached.
Example
if (!DLCradleMgr.onCradleInsertion(insertionReceived)) {
alert("Error trying to listen for cradle insertion events.");
}
// Called when a device is inserted into the cradle.
function insertionReceived(state) {
var dataStr = "State ID: " + state.id;
alert(dataStr);
}
onTrolleyExtraction
onTrolleyExtraction(callback: (state: {id: InsertState}) => void): boolean
Attach a callback function to the trolley extraction event. Only one callback can be attached at a time. If called multiple times, only the callback from the last call to onTrolleyExtraction() will be used. SelfShopping only.
Parameters
- callback: Function to call when a trolley extraction event occurs. The callback function receives a single parameter, which is an object representing the state result. It contains the following properties:
- id: Represents the InsertState of the device.