# Run and Change Over

A mold's rate only applies while it's mounted. In this lesson you'll mount `M-EC25-4` from the Operator Station's info panel, run
`EC-25` caps, check the rate the run is measured against, and then change Injection Press 1 over to the other mold and
cap.

::embed-section{src="../../../kanoa-ops/tooling/mounting.md" collapsed="true" summary="Reference Materials: Mounting Tools - The mount panel, mount rules and warnings."}

## Mount the 4-Cavity Mold

:::action[Mount M-EC25-4 on Injection Press 1]

1. Click **Home**, then `Injection Press 1` on the Asset Overview dashboard to open its Asset Operation screen.
2. The info panel's **Tooling** card says *No tooling installed*. Tap it to open the **Tooling** popup, on its **Mount /
   Unmount** tab.
3. Under **Mount a tool**, pick `M-EC25-4` as the **Tool** and leave it **On the machine**.
4. Leave **Mounted at** empty, so the mold is mounted now, and click **Mount**.
5. Kanoa asks whether to put Injection Press 1 into **Changeover** first. Click **Changeover**: setting a mold is
   changeover time, not production.
6. Close the popup. The **Tooling** card now shows *Tooling Installed - M-EC25-4 - 4 parts/cycle*, and how far the mold is
   through its PM interval: *PM 0/20,000 cycles*. Its stripe is green: the mold is within its limits.

:::

**Mounted at** can be back-dated to the start of the current shift, for a mold that went on before anyone recorded it.

:::tip[The Tooling nav item]
The Operator Station also has a **Tooling** nav item that opens the same mount panel. It's off by default; turn it on in
the asset operation navigation settings, as in
[Asset Operations Screen](../05-customize-navigation/03-asset-operations-page.md), if operators change molds often.
:::

## Run EC-25

:::action[Start a run of EC-25]

1. Tap the mode card (it says *Changeover*) to open **Run Control**, and select the **Product** tab.
2. Select `EC-25` and click **Start Run**, then close Run Control.
3. Within a minute, Injection Press 1's state changes to **Running**, and its outfeed count starts climbing every few
   seconds, by about 24 caps a minute.

:::

## Check the Run's Rate

Without a mold, Injection Press 1's standard rate for `EC-25` would be 20 a minute, from its own rate. With `M-EC25-4`
mounted, the run is measured against the mold instead.

:::action[Read the standard rate]

Run this in the Script Console:

```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
```

Confirm `rateSource` is `cycle`, `toolingName` is `M-EC25-4`, `cycleRate` is 6, `partsPerCycle` is 4 and `standardRate`
is 24.

:::

`rateSource` says where the rate came from, first match wins:

| rateSource | Meaning |
| --- | --- |
| `tool` | The item has its own rate for the mounted tool, in **Production Rates**. |
| `cycle` | The tool's cycle rate × the item's parts per cycle (× the package count of the machine's rate for the item, 1 here). |
| `asset` | The machine's own rate for the item: no tool is mounted, or it has no cycle rate on this machine. |

The run started after the mold was mounted, so it took the mold's rate from the start. Mounting or unmounting a mold
during a run that changes the rate ends that run and starts a new one at the new rate. Earlier runs keep the rate they
started with.

## Change Over to EC-32

The `EC-25` order is done, and the next order is for `EC-32`. The setter takes `M-EC25-4` off the press and puts
`M-EC32-2` on, then starts the new run.

:::action[Change Injection Press 1 over to M-EC32-2]

1. Tap the **Tooling** card, select `M-EC25-4` and click **Unmount**.
2. When Kanoa asks whether to put Injection Press 1 into **Changeover** first, click **Changeover**. The `EC-25` run
   ends, Injection Press 1 stops shooting, and the mold comes off.
3. Under **Mount a tool**, pick `M-EC32-2` and click **Mount**. The press is already in Changeover, so Kanoa doesn't ask
   again. Close the popup.
4. Tap the mode card, and on Run Control's **Product** tab select `EC-32` and click **Start Run**.
5. Run the script from **Read the standard rate** again with `'itemName': 'EC-32'`. `toolingName` is `M-EC32-2`,
   `partsPerCycle` is 2 and `standardRate` is 10.

:::

Changing molds in **Changeover** mode keeps the swap out of production: the changeover time is recorded as changeover,
not as a production run measured against whichever rate applied halfway through the swap. That's why the mount panel
asks before every mount and unmount, unless the machine is already in Changeover. Had you clicked **Unmount only** and
swapped the molds during the `EC-25` run, it would have been split into a run at Injection Press 1's own 20 a minute (no
mold) and another at `M-EC32-2`'s 10 a minute, because a mold with no items on its cavities makes whatever item is
running.

:::action[Review the runs]

1. Navigate to **Ops → Operations → Run Review**, select `Injection Press 1`, and click **Get data** (the refresh
   button).
2. Find the runs from this lesson: `EC-25` at 24 a minute, then the changeover, then `EC-32` at 10 a minute. Run Review
   doesn't show the mold, but the rates tell you which one ran: 24 a minute is `M-EC25-4`, 10 a minute is `M-EC32-2`.

:::

:::check

Copy this script into the Ignition Designer Script Console (**Tools → Script Console**) and run it. It checks that
`M-EC32-2` is mounted on `Injection Press 1` and `M-EC25-4` isn't, that `M-EC25-4` has shots counted from its run, that
Injection Press 1 is running `EC-32`, and that `EC-32`'s standard rate comes from `M-EC32-2`'s 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/3-run-and-change-over.py" title="checkLesson-runAndChangeOver.py"}

</details>

:::
