====Production Production Example====
===Our Goal===
The goal is to have daily summaries showing how much of **each individual product** was produced.
===Plan===
To do this, we will need a few steps.
----
1) Get the **days** our analytic will cover. \\
2) Get the history of the production during that day. \\
3) Calculate the total amount of the product produced, per-product. \\
----
In this example, our machine produces a constant flow of product in varying widths and thicknesses.
To determine how //much// is being produced, we will use the speed of the production line.
However, when comparing days, //length// of product isn't always a good metric. Thicker, heavier product is often slower to produce.
So to make the metrics a little more fair, it's best to compare the total //tonnage// of product made day-to-day.
This means adding an additional couple of steps...
----
4) Calculate the weight of the product being produced at any moment, \\
5) Calculate the total weight produced during the day. \\
----
===Step 1: Get Strict Days===
This step gets the last 24 hours up to 6:00AM in the current day. If the user chooses to run this analytic over many days, it will be broken up into 24-hour batches.
{
"type": "get_day",
"upto": "06:00",
"comment": "Get The Full Day Span"
}
===Step 2: Get the Values to be Summarised===
For each day, we need to get the history of what was produced so we can analyse it.
{
"type": "get_query",
"points": ["Paint Line.Status - Painting","Paint Line.Speed - Actual","Paint Line.Thickness","Paint Line.Width"],
"samples": 1000,
"comment": "Get Line Details"
}
===Step 3: Convert Speed into Daily Total===
This line makes a constant feed of product in different widths and thicknesses. Our first step is to figure out how many //meters of product// were produced in the day.
To do this, we take the **speed** of the line and turn it into a total.
{
"type": "valuesummary",
"values": ["total"],
"rate": "Paint Line.Speed - Actual",
"timebase": 60,
"columns": ["Paint Line.Speed - Actual"],
"named": ["Total Produced"],
"comment": "Calculate Total Produced Length"
}
===Step 3: Calculate Area & Weight===
Next, we convert **length** to **weight**.
We can do this in two steps - first, we calculate the **cross-sectional area** of the product at each moment, then we multiply that by the **density** of the product to end up with the total weight at any one time.
{
"type": "calc",
"value": "{Paint Line.Width} * {Paint Line.Thickness}",
"name": "Cross Sectional Area",
"comment": "Calculate Cross-Sectional Area"
},
{
"type": "calc",
"value": "{Cross Sectional Area} * 1225",
"name": "Weight Per Meter",
"comment": "Calculate Product Weight"
}
===Step 4: Calculate Total Weight by Product===
Finally, we calculate the total weight across the entire day.
{
"type": "valuesummary",
"values": ["total"],
"rate": "Paint Line.Speed - Actual",
"timebase": 60,
"columns": ["Weight Per Meter"],
"named": ["Total Tonnes"],
"multiplier": 0.0001,
"comment": "Calculate Tonnage",
"split": "Paint Line.Product Type"
}
===Full JSON===
{
"name": "Daily Per-Product Painting Totals",
"uniqueid": "{Date}",
"keys": ["Total Painted"],
"date": "StartTime",
"steps": [
{
"type": "get_day",
"upto": "06:00",
"comment": "Get The Full Day Span"
},
{
"type": "get_query",
"query": "'Paint Line' ASSET ('Status - Painting','Speed - Actual','Thickness','Width') PROPERTY VALUES",
"samples": 1000,
"comment": "Get Line Details"
},
{
"type": "valuesummary",
"values": ["total"],
"rate": "Paint Line.Speed - Actual",
"timebase": 60,
"columns": ["Paint Line.Speed - Actual"],
"named": ["Total Produced"],
"comment": "Calculate Total Produced Length"
},
{
"type": "calc",
"value": "{Paint Line.Width} * {Paint Line.Thickness}",
"name": "Cross Sectional Area",
"comment": "Calculate Cross-Sectional Area"
},
{
"type": "calc",
"value": "{Cross Sectional Area} * 1225",
"name": "Weight Per Meter",
"comment": "Calculate Product Weight"
},
{
"type": "valuesummary",
"values": ["total"],
"rate": "Paint Line.Speed - Actual",
"timebase": 60,
"columns": ["Weight Per Meter"],
"named": ["Total Produced Tonnes"],
"multiplier": 0.0001,
"comment": "Calculate Produced Tonnage"
}
}