Skip to content

Vision ​

Use machine numbers 1–4 in the high-level API. Trays are 11–18 and channels 0–9. Wire machine indexes are zero-based and are translated internally.

Query before dispensing ​

ts
jsd.on('vision:machine-status', status => {
  console.log(status.machine, status.availabilityToDispense);
});
await jsd.vision.requestMachineStatus({ machine: 1 });

getMachineStatus(1) reads the local cache, not the hardware. isAvailableToDispense({ machine: 1 }) requires a connected machine, in service, closed door, and availability AVAILABLE-TO-DISPENSE or ELEVATOR-COLLECTION-POSITION.

Dispense and completion ​

ts
jsd.on('vision:dispense-status', result => console.log(result.token, result.status));
if (jsd.vision.isAvailableToDispense({ machine: 1 })) {
  const delivered = await jsd.vision.dispense({ machine: 1, selection: 12 });
  console.log(delivered);
}

dispense() maps selection to tray/channel. Speed defaults to 5 and post-run time to 0. dispenseFromSelection() sends a JSD selection directly; channel-based operations check cached availability. dispenseFromChannelExtended() adds fragile/heavy and elevator adjustment options.

Without cart, COLLECTED or WAITING-COLLECTION resolves true. With cart: true, DISPENSED-CAN-MULTIPLE resolves true. Failure statuses resolve false. Other statuses keep the promise pending.

CodeStatus
0RECEIVED
1IN-PROGRESS
2WAITING-COLLECTION
3COLLECTED
4NO-PERFORMED
5TOKEN-NOT-FOUND
6QUEUE-FULL
7CHANNEL-NO-CONNECTED
8SELECTION-UNAVAILABLE
9FAILED-DISPENSE
10UNCOLLECTED
11DISPENSED-CAN-MULTIPLE
12DISPENSE-CANCELLED
13PRODUCT-EXPIRED

extendedStatus can report door, motor, sensor, elevator, stock, communication, or expiry details; unknown values produce UNKNOWN. Missing extended details are null. See the event payload.

Channels and carts ​

ts
jsd.on('vision:channels-progress', data => console.log(data.progress));
const channels = await jsd.vision.assignChannels({ machine: 1 });

Assignment verifies 80 selections and emits vision:channels when complete. Only one assignment runs at a time. dispenseCart() groups requests in batches of ten, waits for machine availability between batches, and returns selection results. It logs batch exceptions and continues; it has no cancellation deadline.

Configuration and maintenance ​

The full method reference includes channel linking, selection configuration, machine identification, temperature, wait timings, active/inactive faults, perishable products, lights, collection, queue management, self-test, and JSD restart. Their responses are all in the Vision event reference.

Do not confuse a machine's CONNECTED state with serial readiness; they describe different layers.

Explicit protocol, typed events, isolated transport.