# Getting Started with Tooling

This guide sets up one tool from start to finish: a 4-cavity mold, `M-100`, that runs on an injection molding machine,
`Press 1`, at 15 shots a minute. By the end, the mold is mounted, the press's runs are measured against the mold's rate,
and the mold's life is counted against a PM interval. Swap in your own machine and tool as you go.

You need an OEE-enabled machine with an item (`PART-100` below) linked to it in **Production Rates**, and Kanoa MES 1.16 or later.

## 1. Let the Machine Use Tooling

1. Open **Configuration > Ops > Assets** and select the machine in the asset tree.
2. On its info tab, next to **OEE Enabled**, tick **Uses tooling** and save.

**Uses tooling** only shows on an OEE-enabled asset. Saving it creates the machine's `Tooling` tags (see
[Tooling Tags](./tooling-tags.md)).

## 2. Add the Tool

1. Open **Configuration > Ops > Tooling** and click **Add a tool** (**+**).
2. On the **Details** tab, enter:

   | Field | Value | Why |
   | --- | --- | --- |
   | Name | `M-100` | Unique within the site; a machine's tag mounts a tool by this name. |
   | Tooling type | `Mold` | Picking a type fills in its defaults. A Mold has positions and holds inserts. |
   | Location | The press's site, or a storage location under it | The site decides which machines the tool can go on. |
   | Life measured in | `Cycles` | One cycle is one shot of the mold. |
   | PM interval | `50000` | The mold needs a PM every 50,000 shots. |
   | Warn at % | `90` | The mold is *Due for PM* at 45,000 shots. |

3. Click **Save**. The other tabs appear once the tool is saved.

See [Tools and Tool Types](./tools.md) for every field.

## 3. Add Its Positions

A position is one cavity, station or nest: something that makes parts each cycle.

1. On the **Positions** tab, click **Add position** four times.
2. Number them `1` to `4`, set **Type** to `Cavity` and **Parts per cycle** to `1`. Leave **Item** empty: a position with
   no item makes whatever item is running.
3. Click **Save positions**.

The mold now makes 4 parts per shot. Set an item on a position only for a family tool, where different cavities make
different parts (see [Positions](./positions.md)).

## 4. Set Its Cycle Rate on the Machine

1. On the **Cycle Rates** tab, pick `Press 1` as the **Machine**.
2. Enter a **Cycle rate** of `15`, **Per** `Minute`, and click **Save rate**.

The standard rate of anything the mold runs on `Press 1` is now 15 shots x 4 cavities = **60 parts a minute**. Positions
count parts. If the press's rate for the item is in other units, for example pounds of resin in, the
**Package Count** of that rate converts parts to those units. See [Cycle Rates and Item Rates](./rates.md).

## 5. Say Which Item Needs It

The positions say what the mold makes; **required tooling** says which item needs it. Without it, Kanoa can't warn an
operator who starts the wrong run, and the scheduler can't reserve the mold.

1. Open **Configuration > Ops > Materials** and select the **Required Tooling** tab.
2. Pick the item (`PART-100`) and click **Add a required tool** (**+**).
3. Set **Machine** to `Press 1`, **Needs** to *A specific tool*, **Tool** to `M-100`, leave **Required** ticked, and click
   **Save**.

Now starting a `PART-100` run on `Press 1` without `M-100` mounted asks the operator to confirm, and operations scheduled
for `PART-100` on `Press 1` reserve `M-100`. See [Required Tooling](./required-tooling.md).

:::tip
To keep `M-100` on `Press 1` only, add a rule on its **Fits On** tab: **Fits** *A machine*, **On** `Press 1`. Without
one, it fits any machine in its site that uses tooling. See [Fit Rules](./fit-rules.md).
:::

## 6. Mount It

1. Open the Operator Station for `Press 1`. The info panel's **Tooling** card says *No tooling installed*.
2. Tap the card to open the **Tooling** popup, on its **Mount / Unmount** tab.
3. Under **Mount a tool**, pick `M-100` as the **Tool**, leave it **On the machine**, leave **Mounted at** empty, and click
   **Mount**.

The **Tooling** card now shows *Tooling Installed - M-100 - 4 parts/cycle* and *PM 0/50,000 cycles*. If the press is running, the run in
progress ends and a new one starts at 60 a minute.

:::tip
To mount from the PLC instead, write the tool's name to the machine's `Tooling/Inputs/Tooling` tag. A blank name unmounts
it. See [Mounting Tools](./mounting.md).
:::

## 7. Check the Run's Rate

Run this in the Designer's Script Console, using your machine's and item's paths:

```python
asset = system.kanoa.asset.getAssets({'assetPath': 'Enterprise\\Site\\Molding\\Press 1'})
item = system.kanoa.item.getItems({'itemName': 'PART-100'})
rate = system.kanoa.tooling.getStandardRate({
    'assetId': asset.getValueAt(0, 'assetId'),
    'itemId': item.getValueAt(0, 'itemId'),
})
rateList = system.kanoa.utilities.convertDatasetToJSON(rate)
for row in rateList:
    for k,v in row.items():
        print k,v
```

`rateSource` is `cycle` when the rate comes from the mold's cycle rate, `tool` when the item has its own rate for the mold,
and `asset` when the machine's own rate applies.

## 8. Count Its Cycles

The mold's life counts come from the machine's tags, so connect them to the PLC:

- Point `Tooling/Inputs/Cycle Count` at the machine's cycle (shot) counter. Each increase is added to every tool mounted
  on the machine, and becomes the machine's outfeed: the cycles × the parts per cycle. Leave the asset's own
  `Inputs/Outfeed Count` unbound, so the outfeed isn't counted twice (see [Tooling Tags](./tooling-tags.md)).
- Or, if the mold has its own shot counter, point `Tooling/Inputs/Tool Shot Counter` at it. Its readings then count for
  the mold instead of the machine's cycle count.

Open the tool's **Life** tab to watch the counts come in. Run minutes are counted from the machine's *Running* time while
the mold is mounted, with no tags needed.

## 9. Keep Up With Its Life

At 45,000 shots the mold's status changes to *Due for PM*, and at 50,000 to *Over limit*. Tools that are due or over a
limit show in the tools list's **Alert** column, on the machine's info panel (the **Tooling** and **Notifications** cards),
and in the Event Notifications widget.
Mounting a tool that is over a limit asks you to confirm.

After the PM, open the **Life** tab, add a **Note** such as the work order number, and click **PM done**. The since-PM
count goes back to 0. See [Tool Life](./tool-life.md).

## What's Next

- **Block a cavity** that stops making parts, from the mount panel. The standard rate stays the same, so the missing parts
  show as a [speed loss](../speed-loss.md) with the reason *Positions blocked*. Retire it once it's off the machine for
  good. See [Positions](./positions.md).
- **Give an item its own rate** for the mold if it runs slower than the mold's other items. See
  [Cycle Rates and Item Rates](./rates.md).
- **Put inserts in a mold base**: give the base pockets, and mount each insert **Into** one of them. See
  [Mounting Tools](./mounting.md).
