Skip to main content

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

FunctionDescription
controlLedControl cradle LED.
controlLockLock/Unlock a cradle.
getInsertionStateGet the cradle insertion state of the device.
getSlotIndexGet the cradle slot index of the device.
ignoreCradleExtractionRemoves cradle extraction listener.
ignoreCradleInsertionRemoves cradle insertion listener.
ignoreTrolleyExtractionRemoves trolley extraction listener.
ignoreTrolleyInsertionRemoves trolley insertion listener.
isDeviceInTrolleyCheck if a device is in a trolley.
onCradleExtractionAttach a callback function to the cradle extraction event.
onCradleInsertionAttach a callback function to the cradle insertion event.
onTrolleyExtractionAttach a callback function to the trolley extraction event.
onTrolleyInsertionAttach a callback function to the trolley insertion event.
readCustomAreaRead data from cradle custom area.
writeCustomAreaWrite data to cradle custom area.

Constants

ConstantsDescription
DL_CRADLE_MGR_VERThe version of DLCradleMgr.
InsertStateDevice insertion state relative to the cradle.
LedActionAvailable actions to control cradle LED.
LockActionAvailable 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

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

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.

note

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:

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:

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:

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:

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.

ValueDescription
INSERTION_UNKNOWNInsertion state is unknown.
DEVICE_INSERTION_NOT_SUPPORTEDDevice does not support cradle insertion state.
INSERTED_CORRECTLYDevice is correctly inserted into the cradle.
INSERTED_WRONGLYDevice is incorrectly inserted into the cradle.
EXTRACTEDDevice is extracted from the cradle.

LedAction

Available actions to control JoyaTouch cradle LED.

ValueDescription
BLINK_FASTSet cradle LED to blink fast.
BLINK_SLOWSet cradle LED to blink slow.
LED_OFFTurn cradle led off.
LED_ONTurn cradle led on.
TOGGLEToggle cradle LED on or off.

LockAction

Available actions to control cradle lock.

ValueDescription
LOCKLock cradle with led on.
LOCK_WITH_LED_OFFLock cradle with led off.
UNLOCKUnlock cradle with led off.
UNLOCK_WITH_LED_ONUnlock cradle with led on.