# CONVEYOR

Conveyor belt that carries parts from one end to the other at a set speed, holds a limited number, and blocks the machine before it when full.

Family: move. Python builder: `m.conveyor(...)`.

## Typical uses

Use CONVEYOR for a belt where length, speed and spacing matter. Parts take time to travel, the belt holds a limited number of them, and a blocked exit backs parts up. If the stretch is only a wait with no capacity, a [DELAY](delay.md) is simpler. For a vehicle that picks up and carries a part, use [TRANSPORT](transport.md).

## Behaviour and rules

The belt holds `floor(length / spacing)` parts, at least one. A part takes `length / speed` to cross. Consecutive parts enter at least `spacing / speed` apart, so the belt can never feed faster than that. If `length` is 0, the length is the network distance between `from_node` and `to_node`.

A full belt, or one whose entry rhythm is not met, holds back the station that feeds it. That station keeps its finished part and its resource. This is blocking after service, the same rule that [BUFFER](buffer.md) follows.

At the exit, a part leaves only when `exit_resource` (if set) is taken and any downstream belt has room. The part carries the resource on, so release it downstream, for example with a PROCESS whose action is Delay Release. With neither, the belt is a delay with a capacity.

With `accumulating` on, a blocked part stops at the end and the parts behind pack against it. With it off, the whole belt stops. Optional `stops` halt each part at a point, `diverts` send some parts out sideways on the links after the first, and `merges` let parts from another block join. The `conveyor_summary` frame reports occupancy, blocked time and transit time.

## Ports

- Inputs: any number of incoming links.
- Outputs: one outgoing link.

## Parameters

| Parameter | Type | Default | Required | Quantity | Unit key | Description |
|---|---|---|---|---|---|---|
| `length` | float | `0.0` |  | length | `length_unit` | Belt length in layout units. 0 takes the network distance between `from_node` and `to_node`. |
| `length_unit` | str | `'base'` |  |  |  | Unit of `length`: "base" (the model's) or one of its quantity's units. |
| `speed` | float | `1.0` | yes | speed | `speed_unit` | Belt speed, length units per model time unit. |
| `speed_unit` | str | `'base'` |  |  |  | Unit of `speed`: "base" (the model's) or one of its quantity's units. |
| `spacing` | float | `1.0` | yes | length | `spacing_unit` | Belt length one entity occupies; capacity is floor(length / spacing) and the entry rhythm is spacing / speed. |
| `spacing_unit` | str | `'base'` |  |  |  | Unit of `spacing`: "base" (the model's) or one of its quantity's units. |
| `accumulating` | bool | `True` |  |  |  | True: a blocked entity stops and the others pack behind it. False: the whole belt stops while the exit is blocked. |
| `exit_resource` | str | `''` |  |  |  | Resource an entity must take to leave the belt -- the end stop that makes accumulation happen. It carries the resource onward, so release it downstream (a PROCESS with action "Delay Release"). Empty: no end stop. Either way, a belt that feeds another belt keeps its end part until that belt has room (back-pressure). |
| `from_node` | str | `''` |  |  |  | Path-network node the belt starts at (drawing, and the length when `length` is 0). |
| `to_node` | str | `''` |  |  |  | Path-network node the belt ends at. |
| `stops` | list | `[]` |  |  |  | Points where each part halts on the belt: {"at": <distance from the entry, in the unit of `length`, between 0 and the length>, "time": <number or expression>, "resource"?: <seized for the stop>}. Parts behind pack against a stop on an accumulating belt; a non-accumulating belt stops while a part is at one. Empty: none. |
| `diverts` | list | `[]` |  |  |  | Points where a part may leave the belt sideways: {"at": <distance from the entry, in the unit of `length`>, "condition": <expression, read once as the part reaches it>, "time"?: <push time, number or expression>, "when_full"?: "wait" (default: the part waits there for room) or "pass" (it rides on), "intercept"?: true (a robot on link k + 1 picks the part on the move; its first move targets this divert), "on_late"?: what the part does when that robot is busy: "wait" (default: it stands where the robot meets it), "pass" (it rides on) or an expression, true meaning wait}. Divert k leaves by outgoing link k + 1; link 0 is the belt's end. A link may name its exit instead: source_port "out" (the end) or "d<k>", each exit once. "side"?: "left" (default) or "right" of a part travelling along the belt as seen on screen, where the divert's exit port faces on the floor plan; "angle"?: degrees from the belt's travel to that exit, above 0 and below 180 (90, the default, is square; 45 leans downstream), floor geometry only. "rule"?: a routing rule in place of the condition, {"kind", "exits"?, "conditions"?, "limit"?, "attribute"?} as a Rule-mode DECIDE's, read once as the part reaches it; "rule_group"?: a name the diverts sharing one rule all give, the rule on the first of them along the belt only; the exits are the group's diverts in belt order (names default to their ports), and an exit named "out" passes them all to the belt's end. A part counts under way until it reaches its exit's target piece or leaves a belt on its way there by a divert; name an exit "L1:L1" to stop the count at branch L1. While every exit is at its limit the part waits at the group's first divert and the belt behind packs as at a stop. Empty: none. |
| `merges` | list | `[]` |  |  |  | Points where parts from another block join the belt: {"at": <distance from the entry, in the unit of `length`>, "from": <the block linking to this belt whose parts join there>, "priority"?: "belt" (default: they wait for a gap of two spacings) or "merge" (parts on the belt make room)}. Accumulating belts only. Empty: none. |
| `eyes` | list | `[]` |  |  |  | Photo-eyes, points that fire as a part passes: {"at": <distance from the entry, in the unit of `length`>, "edge"?: "front" (default: as the part's front reaches `at`) or "back" (as its back clears `at`, a `part_length` later), "assign"?: <rows {"target", "expr"} run on that part as ASSIGN runs them>, "signal"?: <signal raised, for HOLD blocks and item code>}. Each firing is counted and traced; a queue that stands short of an eye delays it. Empty: none. |
| `path` | list | `[]` |  |  |  | The belt as pieces laid end to end from its entry: {"straight": <length>} or {"arc": {"radius": <r>, "angle": <degrees, up to 360>, "turn": "left" or "right" as seen on screen}}, lengths in the unit of `length`. Their total is the belt's length, so set `length` to 0 and give no nodes. Empty: a straight belt of `length`. |
| `type` | str | `''` |  |  |  | Conveyor type: "belt", "roller", "chain", "pallet" or "mdr". Empty: an untyped belt with `spacing`, one item per cell. A typed belt has cells of `cell` and an item takes ceil((its length + `gap`) / cell) of them; `spacing` is ignored and the results' Capacity counts cells. |
| `gap` | float | `0.0` |  | length | `gap_unit` | Free belt length kept between two items on a typed belt. |
| `gap_unit` | str | `'base'` |  |  |  | Unit of `gap`: "base" (the model's) or one of its quantity's units. |
| `cell` | float | `0.0` |  | length | `cell_unit` | Length of one cell of a typed belt; an item takes as many as its length plus `gap` needs. 0: 1 cm in any length unit. Ignored on an untyped belt. |
| `cell_unit` | str | `'base'` |  |  |  | Unit of `cell`: "base" (the model's) or one of its quantity's units. |
| `zones` | dict | `{}` |  |  |  | Accumulation zones: {"count": <zones of equal length, zone 1 at the exit>, "release_delay"?: <time, in the model's time unit unless "time_unit" says another>}. Parts accumulate as without zones; when the held exit frees, a standing part restarts release_delay times its front's zone later, never nearer than its own length to the part ahead; the end part keeps the exit unit through its delay, and a part handed to a next belt waits it before that belt takes it. Delay 0 is a belt without zones and releases the queue as one slug, as Emulate3D does at 0; Emulate3D's staggered headways at a 1 s delay (1.26 s and 0.96 s measured) differ, an open comparison. Accumulating belts with no stop or merge only. Empty: none. |
| `release` | dict | `{}` |  |  |  | How parts leave the end, one form: {"metering": {"gap": <length>}} (a part leaves once the one before is that far past the end, measured from its tail), {"metering": {"interval": <length>}} (front to front, never nearer than the part before takes on the belt), {"singulation": {"gap": <length>}} (the same as metering by gap) or {"slug": {"count": <parts>, "timeout": <time>, "time_unit"?}} (the end holds until count parts are queued or timeout has passed since the first stood there, then lets them go nose to tail). Lengths are in the unit of `length` and travelled at the belt speed; the timeout is in the model's time unit unless time_unit says another. Held parts make the ones behind accumulate. A slug counts every part standing in the queue, behind a photo-eye or a stop too; a part whose place in the queue is behind a stop dwells there after the release. Each part's hold at the end is kept (in a slug the lead's; the parts let go with it hold 0). Accumulating belts without zones only. Empty: parts leave as soon as they can. |
| `reversible` | bool | `False` |  |  |  | True: the belt can run backward during a run, turned by `reverse_signal` or by item code (item.reverse). Each part on it then rides back the distance it has travelled and leaves at the start by `reverse_to`; nothing gets on until it runs forward again. Reversible belts linked end to start, with nothing between them, are one chain that turns as one: a part crosses each joint the way the chain runs. A reversible belt has no stops, diverts, merges, photo-eyes, zones or release rule. |
| `reverse_signal` | str | `''` |  |  |  | Signal that turns a reversible belt each time it is raised (forward, backward, forward...), with its whole chain. Empty: only item code turns it. |
| `reverse_to` | str | `''` |  |  |  | Exit of a reversible belt for parts leaving at its start: the target block of one of its links, or "in" (the link whose source_port is "in"); not a conveyor feeding this belt, since nothing boards a belt by its end. In a chain, only the first piece names it: a later piece hands back to the one before. |
| `part_length` | float | `0.0` |  | length | `part_length_unit` | Length of one part along the belt, which a back-edge eye reads. 0: the spacing, or a typed belt's type zone length. On an untyped belt it is no longer than the spacing. |
| `part_length_unit` | str | `'base'` |  |  |  | Unit of `part_length`: "base" (the model's) or one of its quantity's units. |
| `expose` | bool | `False` |  |  |  | True: the belt writes its state as model variables, read with VAR("<belt>.running") in a HOLD condition or item code: `running` (0 only while a non-accumulating belt stands for a part held at the exit it runs to), `forward` on a reversible belt (0 while it runs backward), `eye<k>.count` (eye k's firings so far) and `eye<k>.blocked` (1 while a part's body lies across eye k, front edge to back edge; not on a belt with both zones and diverts). |

## Statistics

Every run fills `system` and `entity_summary` (see the [KPI reference](../kpis.md)). The example below also fills:

| Frame | Columns |
|---|---|
| `conveyor_summary` | `Run`, `Conveyor`, `Length`, `Capacity`, `Entered`, `Exited`, `Avg Occupancy`, `Max Occupancy`, `Blocked %`, `Avg Transit Time` |
| `material_flow_summary` | `Run`, `From`, `To`, `Entities` |

## Problem codes

A check of the model reports these about this block:

| Code | Meaning |
|---|---|
| `E_CONVEYOR_DIVERT` | A CONVEYOR divert is not {at, condition, time?, when_full?}, its `at` is off the belt or on another point, its condition is empty, its time is not a number >= 0 or an expression, its when_full is not wait/pass, the belt has fewer links than 1 + diverts, a "pass" divert's link does not go straight to a CONVEYOR, BUFFER or queue_capacity station, or an intercept divert has a push time or when_full, a bad on_late, or a link that is not the robot picking from it, a divert's side is not left or right, or a link out of the belt names an exit that is not out or d<k>, or a routing rule is not usable, is not on the first divert of its rule_group along the belt, has an exit count other than its group's diverts, or sits beside a condition, a robot pick or when_full "pass", or a rule exit names a target piece that is not a CONVEYOR its loads reach; or a CONVEYOR_TRANSFER's links do not match its exits one to one (a port that is not one of its exits, or named twice), or its routing rule is not usable. |
| `E_CONVEYOR_EYE` | A CONVEYOR photo-eye is not on the belt, shares its place with another point, has an edge other than front or back, or the belt's part_length is longer than its spacing. |
| `E_CONVEYOR_MERGE` | A CONVEYOR merge is not {at, from, priority?}, its `at` is off the belt or on another point, its `from` is not a block linking to the belt or is named twice, its priority is not belt/merge, or the belt is not accumulating. |
| `E_CONVEYOR_PARAM` | A CONVEYOR's type is not belt, roller, chain, pallet or mdr, or its length, speed or spacing is not a number > 0, or its gap or cell is negative, or its endpoints name unknown nodes, or its zones are not {count >= 1, release_delay >= 0} on an accumulating belt with no stop, merge or routing rule that can hold a part; or a CONVEYOR_TRANSFER's mechanism is not popup, turntable or lift, an exit is not {port, angle} or shares or holds a ':' in its port, a time, length or speed is negative (a turn_rate or lift_speed not > 0), or transfer_speed is 0 where a move needs it and no one CONVEYOR speed feeds the module; or a stop, divert, merge or eye of a belt with a path lies at or past the path's end, or a divert's angle is not a number above 0 and below 180. |
| `E_CONVEYOR_PATH` | A CONVEYOR's path has a piece that is not a straight or an arc, or it has a length or end nodes beside it. |
| `E_CONVEYOR_RELEASE` | A CONVEYOR's release is not one of metering {gap or interval}, singulation {gap} or slug {count, timeout, time_unit?} with numbers >= 0, or the belt is not accumulating or has zones. |
| `E_CONVEYOR_REVERSE` | A reversible CONVEYOR has stops, diverts, robot picks, merges, photo-eyes, zones or a release rule, which only work one way, or its reverse_to is missing or names no exit of the belt, or a later piece of a reversible chain names one, or the chain is a ring. |
| `E_CONVEYOR_STOP` | A CONVEYOR stop is not {at, time, resource?}, its `at` is not between 0 and the belt's length, its time is not a number >= 0 or an expression, or its resource is not declared. |
| `E_DECIDE_RULE` | A Rule-mode DECIDE's routing rule is not usable (an unknown kind, conditions that do not fit its exits, a limit that is not a whole number >= 0, no attribute name, a key it does not take), or it names a number of exits other than its outgoing links, or an exit names a target piece that is not a CONVEYOR its loads reach. |
| `E_INITIAL_BELT` | A part on a belt in initial_state does not fit the model: not one entity at an accumulating CONVEYOR, a stage it does not have, a time on the wrong side of the clock, or more than one part at the belt's end. |
| `W_CONVEYOR_HANDED_TO_NOTHING` | In the run, a part reached a CONVEYOR's end (or a reversible belt's start) with no next block; it stands there and the belt is blocked, so a run that drains ends with a deadlock naming it. Warned once per belt; an error that stops the run under simulation.strict_checks. |
| `W_CONVEYOR_OPEN_PORT` | A conveyor piece on the floor (a CONVEYOR with a path, or a CONVEYOR_TRANSFER's exit) has a port no link joins: a belt's in, out or divert port d<k>, a transfer's exit port. An area link counts as a link. An error under simulation.strict_checks. |
| `W_CONVEYOR_STOP_HELD` | A CONVEYOR stop seizes a resource a part still holds when it gets there (seized upstream, not yet released); the run stops with an error when a part asks for it twice. |
| `W_REVERSED_HELD_AT_END` | At the end of a run that stopped at its time limit, a reversible CONVEYOR runs backward with a part held at its start; nothing boards it meanwhile, so if no signal turns it again this is a deadlock (a cheap notice, not a proof). |
| `W_ROUTE_RULE` | A routing rule (a divert's, a transfer's or a Rule-mode DECIDE's) has a condition per exit and no ELSE, so a part no condition takes stops the run, or it has a limit or is least_loaded while an exit leads to no CONVEYOR and names no target piece, so nothing is counted under way there; or a CONVEYOR_TRANSFER exit reaches its conveyor through a block that branches (no handshake at its eye), hands to a conveyor with no eye and a stop nearer its entry than the longest item, or counts a limit or least_loaded only until the handshake; or a merge joins a belt between the first and last divert of a rule group, so its parts are never routed; or a zoned belt has diverts, so its zone timing is not modelled behind the last divert or eye. |

## Example

The snippet seeds itself; its output is from a run made when this page was generated.

```python
from nagasim import build as nb

m = nb.Model(time_limit=300, time_unit="seconds")
m.create(distribution=nb.Constant(value=5)) >> m.conveyor(length=30, speed=1.0, spacing=1.0) >> m.dispose()

results = m.run(seed=1)
print(results["conveyor_summary"].round(2).to_string(index=False))
```

```text
 Run   Conveyor  Length  Capacity  Entered  Exited  Avg Occupancy  Max Occupancy  Blocked %  Avg Transit Time
   1 conveyor_1    30.0        30       61      55           5.75            6.0        0.0              30.0
```

## Used in

Bundled models: [Belt with stops, a divert and a merge](../../gallery/logistics.md), [Warehouse with forklifts (floor plan)](../../gallery/logistics.md), [Order-driven warehouse (library assets)](../../gallery/logistics.md), [Palletizing line](../../gallery/manufacturing.md).

Guides: [How do I move parts along a belt?](../../how-to/recipes/belt-transit.md), [Coming from AnyLogic](../../coming-from/anylogic.md), [Coming from Arena](../../coming-from/arena.md), [Finite buffers and blocking after service](../../modelling-guide/finite-buffers.md), [Layout, paths and vehicles](../../modelling-guide/layout-paths-vehicles.md), [Motion cycles](../../modelling-guide/motion.md) and 1 more.

## See also

- [All blocks](index.md), [KPI reference](../kpis.md), [Model file keys](../schema.md), [Model file format](../../model-file-format.md)
- Same family (move): [BUFFER](buffer.md), [CONVEYOR_TRANSFER](conveyor-transfer.md), [STATION](station.md), [TRANSFER](transfer.md), [TRANSPORT](transport.md)
