# Cells on a Line

{/*
DRAFT. To check on a 1.16 gateway before release: that the Edit Events Asset list offers the line's cells
and the state tree then shows the selected cell's states, and that the Downtime Editor's Asset column shows
the cell after the update. Still to add: a check script (exams/ops/01-base-configuration/10-cells.py) and
a knowledge check question.
*/}

Spray Line 1 isn't one machine. Parts go through a **pump** that feeds the coating, a **spray booth** where the nozzles
apply it, and a **curing oven** that sets it. When the line stops, the question an engineer asks next is *which one stopped
it?*

In Kanoa, the pieces of equipment that make up a line are **cells**: assets of type **Cell** under the line. In this lesson
you'll keep OEE on Spray Line 1 and use cells to record which part of the line caused each stop:

- The stop still counts against **Spray Line 1's** availability, as one line with one OEE.
- Each stop also records the **cell** that caused it, with one of that cell's own states.

| Cell | What it does | Its downtime states |
| --- | --- | --- |
| `Spray Pump` | Feeds the coating to the booth | `Pump Pressure Fault` |
| `Spray Booth` | Applies the coating through the nozzles | `Spray Nozzle Clog`, `Cleaning` |
| `Curing Oven` | Cures the coating | `Temperature Out of Range` |

These are the Spray Line 1 states you created in [Configure States](./6-configure-states.md). Each one belongs to a single
piece of the line, so each moves to its cell.

:::info[Other ways to set up a line with cells]
This lesson uses one OEE for the line, with stops by cell. A plant can also OEE Enable each cell, with its own states,
counts and runs, when it wants OEE for each piece of equipment. Then only the cell that makes the item should count
outfeed, so the item's production isn't counted once per cell.
:::

## Create the Cells

:::action[Add three cells under Spray Line 1]

1. Navigate to **Configuration → Ops → Assets**.
2. Select `CoreForge\Philadelphia\Coating\Spray Line 1` in the tree and click **+** (**Add Asset**).
3. Enter `Spray Pump` as the **Asset Name**, set the **Asset Type** to **Cell**, and click the save icon. Leave **OEE
   Enabled** off: the cell's stops count against the line.
4. Select Spray Line 1 again and add `Spray Booth` and `Curing Oven` the same way.

:::

The tree now shows the three cells under Spray Line 1:

```text
Coating
└── Spray Line 1
    ├── Spray Pump
    ├── Spray Booth
    └── Curing Oven
```

## Link Each Cell's States

A stop recorded against a cell uses one of **that cell's** states. Link each state to the cell it belongs to, the same way
you linked them to Spray Line 1.

:::action[Link the states to the cells]

1. Select the **States** tab, then the **Asset Links** tab.
2. Select `Spray Pump` and, holding the CTRL key, also select `Pump Pressure Fault`. Click the **Link** button.
3. Select `Spray Booth` and, holding CTRL, `Spray Nozzle Clog` and `Cleaning`. Click **Link**.
4. Select `Curing Oven` and, holding CTRL, `Temperature Out of Range`. Click **Link**.

:::

Leave the states linked to Spray Line 1 as well. A stop that isn't any one cell's fault is still coded on the line.

## Code a Stop to the Cell That Caused It

Spray Line 1's simulator stops the line now and then, and records each stop on the line. Here you'll do what an operator
or supervisor does after a stop: say which cell caused it, and why.

:::action[Code a stop to Spray Booth]

1. Click **Home**, then `Spray Line 1` on the Asset Overview dashboard to open its Asset Operation screen.
2. Tap the **Downtime** tile. The **Downtime Editor** lists Spray Line 1's states.
3. Select a downtime stop and click the edit button (✎). The **Edit Events** popup opens.
4. In **Asset**, select `Spray Booth`.
5. Click the edit button next to the state, select `Mechanical\Nozzle\Spray Nozzle Clog` in the tree, and click
   **Select**.
6. Add a comment if you like, such as *Nozzle 3 blocked, cleaned and restarted*, and click **Update**.

:::

The stop is marked as updated. It's still a Spray Line 1 stop, so it still counts against the line's availability, and
now it also records that Spray Booth caused it, with a Spray Booth state.

![Edit Events popup: the asset set to a cell and its state picked from the tree](https://docs.kanoa.ai/img/asset-operation/editDowntimeEvent.png)

::embed-section{src="../../../kanoa-ops/asset-operation.md#downtime-event-editor" collapsed="true" summary="Reference Materials: Downtime Event Editor - Edit, split and revert stops, and pick the cell that caused one."}

## From the PLC

Coding stops by hand works for a few stops a shift. On a real line, the PLC usually knows which cell stopped the line. Kanoa's
data interface tag has a **Machine ID** input for this: when a cell stops the line, the PLC sets **Machine ID** to the
cell's asset ID and **State** to the code linking that cell to its state. The stop is then recorded on the line with the
cell's state, with nobody having to code it.

::embed-section{src="../../../kanoa-ops/assets/assetOEEInfo.md#inputs-folder" collapsed="true" summary="Reference Materials: Inputs Folder - Machine ID and the other inputs of the data interface tag."}
