# A Family Mold

Orders for the two caps often come together, so CoreForge has bought a **family mold**, `M-ECF-4`: four cavities, two
shaped for `EC-25` and two for `EC-32`, filled by the same shot. It runs a little slower than `M-EC25-4`, at 5 shots a
minute, because the bigger cavities take longer to cool.

On a family mold, each cavity is set to the item it makes. A cavity counts toward an item's parts per cycle only when
that item runs, so each cap's standard rate comes from its own cavities.

## Add the Family Mold

:::action[Add M-ECF-4]

1. In **Configuration → Ops → Tooling**, click **Add a tool** (**+**) and enter:

   | Field | Value |
   | --- | --- |
   | Name | `M-ECF-4` |
   | Tooling type | `Mold` |
   | Location | `CoreForge\Philadelphia\Molding` |
   | Life measured in | `Cycles` |
   | PM interval | `20000` |
   | Warn at % | `90` |

2. Click **Save**.
3. On the **Positions** tab, add four `Cavity` positions numbered `1` to `4`, each with **Parts per cycle** `1`. Set
   **Item (family tools)** to `EC-25` on cavities 1 and 2, and to `EC-32` on cavities 3 and 4. Click **Save positions**.
4. On the **Cycle Rates** tab, pick `Injection Press 1`, enter `5` per `Minute`, and click **Save rate**.

:::

:::download[Download the M-ECF-4 tool]

If you want to check your work, or skip ahead, you can import `M-ECF-4` instead of adding it by hand.

<a href="/files/ops-resources/coreforge-mold-m-ecf-4-tooling.json" download="coreforge-mold-m-ecf-4-tooling.json">Download <code>coreforge-mold-m-ecf-4-tooling.json</code></a>

This file is a tooling export with the mold's details, its four cavities and its cycle rate on `Injection Press 1`.
Import it with the **Import** button on the tools list (**Configuration → Ops → Tooling**), check the preview, and click
**Import**. If you've already added `M-ECF-4`, choose **Overwrite it** to replace yours with this one. See [Exporting
and importing tools](../../../kanoa-ops/tooling/tools.md#exporting-and-importing-tools).

:::

## Run It

:::action[Mount M-ECF-4 and run EC-25]

1. Tap the **Tooling** card, unmount `M-EC25-4` (clicking **Changeover** when Kanoa asks) and mount `M-ECF-4`.
2. Tap the mode card and start an `EC-25` run from the **Product** tab. `EC-25`'s required tooling (from [Build the
   Molds](./2-build-the-molds.md#link-each-cap-to-its-mold)) names `M-EC25-4`, but Run Control doesn't warn: `M-ECF-4` has
   cavities set to `EC-25`, so it stands in for it (see [Required Tooling for a Family
   Mold](#required-tooling-for-a-family-mold)). The run starts in the family mold. Injection Press 1's outfeed counts the `EC-25` caps,
   about 10 a minute (2 a shot). The `EC-32` caps from cavities 3 and 4 are counted too, as co-products; see
   [What the run counts](#what-the-run-counts) below.
3. Look at the info panel. On the **Current Run** tab, the **Output** box lists `EC-25` and `EC-32 (co-product)`, each
   with its outfeed, rate and waste, and both go up with every shot. Select the **Current Shift** tab to see the same for
   the shift so far.
4. Run this in the Script Console to read `EC-25`'s standard rate:

   ```python
   asset = system.kanoa.asset.getAssets({'assetPath': 'CoreForge\\Philadelphia\\Molding\\Injection Press 1'})
   item = system.kanoa.item.getItems({'itemName': 'EC-25'})
   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
   ```

   `toolingName` is `M-ECF-4`, `partsPerCycle` is 2 and `standardRate` is 10: 5 shots × the 2 `EC-25` cavities.
5. Change `'EC-25'` to `'EC-32'` in the script and run it again. It's 10 a minute too, from the other two cavities.

:::

You can see how a mold's cavities split between items with `getPartsPerCycle`:

```python
tool = system.kanoa.asset.getAssets({'assetPath': 'CoreForge\\Philadelphia\\Molding\\M-ECF-4'})
parts = system.kanoa.tooling.getPartsPerCycle({'toolingAssetId': tool.getValueAt(0, 'assetId')})
print system.kanoa.utilities.convertDatasetToJSON(parts)
```

It returns a row for each item, with `partsPerCycle` (the cavities making it now) and `standardPartsPerCycle` (the ones
that count toward its standard, blocked ones included). Each has 2.

### What the Run Counts

A run is for one item: the one you started. Each shot of `M-ECF-4` makes 2 `EC-25` caps and 2 `EC-32` caps. The
`EC-25` caps are the run's outfeed, measured against `EC-25`'s 10 a minute. The `EC-32` caps are recorded as
**co-products**: production of `EC-32`, but not part of the run, its OEE or its work order.

:::action[See the co-products in Run Review]

1. Navigate to **Ops → Operations → Run Review**, select `Injection Press 1`, and click **Get data** (the refresh
   button).
2. Turn the **Table** toggle off, so the runs show as cards. The **Co-products** box only appears on the cards.
3. Find the `EC-25` run. Under **Outfeed** it shows the `EC-25` caps, and under **Co-products** the `EC-32` caps: about
   the same number, from the other two cavities.

:::

### Required Tooling for a Family Mold

A required mold is met by the mold itself, or by any mounted mold with a cavity set to the item that isn't blocked. So
`M-EC25-4` stays `EC-25`'s required mold, and a run in `M-ECF-4` starts without a warning because two of its cavities are
set to `EC-25`. Block both of them and the warning comes back: the family mold can't make `EC-25` any more.

Don't add `M-ECF-4` as a second *required* mold for `EC-25`. Each required tool is checked on its own, and `M-EC25-4`
can't stand in for the family mold (its cavities aren't set to an item), so every run in `M-EC25-4` would warn.

If one of the caps runs at a different speed in a family mold than the cycle rate gives it, set its own rate for the
mold in **Production Rates**, as in [Cycle Rates and Item
Rates](../../../kanoa-ops/tooling/rates.md#item-rates-for-a-tool). An item's own rate for the mounted mold comes first,
ahead of the cycle rate.

:::check

Copy this script into the Ignition Designer Script Console (**Tools → Script Console**) and run it. It checks that
`M-ECF-4` is a Mold with cavities 1 and 2 set to `EC-25` and 3 and 4 set to `EC-32`, that its cycle rate on
`Injection Press 1` is 5 a minute, that it's mounted on `Injection Press 1`, and that both caps' standard rates come
from its cycle rate at 10 a minute. Each check prints PASS or FAIL with what to fix. It doesn't change anything.

<details>
<summary>Show the check script</summary>

::check-script{src="ops/12-tooling/6-a-family-mold.py" title="checkLesson-aFamilyMold.py"}

</details>

:::
