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.
Returns
True if the callback was successfully attached.
Example
if (!DLCradleMgr.onTrolleyExtraction(extractionReceived)) {
alert("Error trying to listen for cradle extraction events.");
}
// Called when a device is extracted from the trolley.
function extractionReceived(state) {
var dataStr = "State ID: " + state.id;
alert(dataStr);
}
onTrolleyInsertion
onTrolleyInsertion(callback: (state: {id: InsertState}) => void): boolean
Attach a callback function to the trolley insertion event. Only one callback can be attached at a time. If called multiple times, only the callback from the last call to onTrolleyInsertion() will be used. SelfShopping only.
Parameters
- callback: Function to call when a trolley 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.onTrolleyInsertion(insertionReceived)) {
alert("Error trying to listen for trolley insertion events.");
}
// Called when a device is inserted into the trolley.
function insertionReceived(state) {
var dataStr = "State ID: " + state.id;
alert(dataStr);
}
readCustomArea
readCustomArea(): String
Read a message from the JoyaTouch cradle custom area. SelfShopping only.
Returns
Message read from cradle custom area if the cradle read was successful, or "**FAILED TO READ FROM CRADLE**" if the read failed.
Example
let cradleMessage = DLCradleMgr.readCustomArea();
writeCustomArea
writeCustomArea(message: String): boolean
Writes a message to the JoyaTouch cradle custom area. SelfShopping only.
Parameters
- message: String to write to the cradle. The string must not be longer than the size of the cradle custom area.
Returns
True if the message was successfully written to the cradle custom area.
Example
let message = "Hello World";
let writeSuccess = DLCradleMgr.writeCustomArea(message);
Constants
DL_CRADLE_MGR_VER
The version of the DLCradleMgr.
InsertState
Device insertion state relative to the cradle.
Value | Description |
---|---|
INSERTION_UNKNOWN | Insertion state is unknown. |
DEVICE_INSERTION_NOT_SUPPORTED | Device does not support cradle insertion state. |
INSERTED_CORRECTLY | Device is correctly inserted into the cradle. |
INSERTED_WRONGLY | Device is incorrectly inserted into the cradle. |
EXTRACTED | Device is extracted from the cradle. |
LedAction
Available actions to control JoyaTouch cradle LED.
Value | Description |
---|---|
BLINK_FAST | Set cradle LED to blink fast. |
BLINK_SLOW | Set cradle LED to blink slow. |
LED_OFF | Turn cradle led off. |
LED_ON | Turn cradle led on. |
TOGGLE | Toggle cradle LED on or off. |
LockAction
Available actions to control cradle lock.
Value | Description |
---|---|
LOCK | Lock cradle with led on. |
LOCK_WITH_LED_OFF | Lock cradle with led off. |
UNLOCK | Unlock cradle with led off. |
UNLOCK_WITH_LED_ON | Unlock cradle with led on. |